react-native-nitro-compass 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.
- package/LICENSE +21 -0
- package/NitroCompass.podspec +31 -0
- package/README.md +206 -0
- package/android/CMakeLists.txt +32 -0
- package/android/build.gradle +148 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/margelo/nitro/nitrocompass/HybridNitroCompass.kt +481 -0
- package/android/src/main/java/com/margelo/nitro/nitrocompass/NitroCompassPackage.kt +18 -0
- package/app.plugin.js +16 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridNitroCompass.swift +473 -0
- package/lib/commonjs/hook.js +69 -0
- package/lib/commonjs/hook.js.map +1 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/multiplex.js +109 -0
- package/lib/commonjs/multiplex.js.map +1 -0
- package/lib/commonjs/native.js +9 -0
- package/lib/commonjs/native.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/NitroCompass.nitro.js +6 -0
- package/lib/commonjs/specs/NitroCompass.nitro.js.map +1 -0
- package/lib/module/hook.js +65 -0
- package/lib/module/hook.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/multiplex.js +103 -0
- package/lib/module/multiplex.js.map +1 -0
- package/lib/module/native.js +5 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/specs/NitroCompass.nitro.js +4 -0
- package/lib/module/specs/NitroCompass.nitro.js.map +1 -0
- package/lib/typescript/src/hook.d.ts +49 -0
- package/lib/typescript/src/hook.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/multiplex.d.ts +38 -0
- package/lib/typescript/src/multiplex.d.ts.map +1 -0
- package/lib/typescript/src/native.d.ts +3 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/specs/NitroCompass.nitro.d.ts +176 -0
- package/lib/typescript/src/specs/NitroCompass.nitro.d.ts.map +1 -0
- package/nitro.json +30 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroCompass+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroCompass+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroCompassOnLoad.cpp +60 -0
- package/nitrogen/generated/android/NitroCompassOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JAccuracyQuality.hpp +64 -0
- package/nitrogen/generated/android/c++/JCompassSample.hpp +61 -0
- package/nitrogen/generated/android/c++/JFunc_void_AccuracyQuality.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_CompassSample.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.cpp +143 -0
- package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.hpp +75 -0
- package/nitrogen/generated/android/c++/JPermissionStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/JSensorDiagnostics.hpp +58 -0
- package/nitrogen/generated/android/c++/JSensorKind.hpp +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/AccuracyQuality.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/CompassSample.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_AccuracyQuality.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_CompassSample.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/HybridNitroCompassSpec.kt +118 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/NitroCompassOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/PermissionStatus.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/SensorDiagnostics.kt +51 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/SensorKind.kt +24 -0
- package/nitrogen/generated/ios/NitroCompass+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Bridge.cpp +73 -0
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Bridge.hpp +267 -0
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Umbrella.hpp +61 -0
- package/nitrogen/generated/ios/NitroCompassAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroCompassAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroCompassSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroCompassSpecSwift.hpp +180 -0
- package/nitrogen/generated/ios/swift/AccuracyQuality.swift +48 -0
- package/nitrogen/generated/ios/swift/CompassSample.swift +34 -0
- package/nitrogen/generated/ios/swift/Func_void_AccuracyQuality.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CompassSample.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.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/HybridNitroCompassSpec.swift +67 -0
- package/nitrogen/generated/ios/swift/HybridNitroCompassSpec_cxx.swift +309 -0
- package/nitrogen/generated/ios/swift/PermissionStatus.swift +44 -0
- package/nitrogen/generated/ios/swift/SensorDiagnostics.swift +29 -0
- package/nitrogen/generated/ios/swift/SensorKind.swift +44 -0
- package/nitrogen/generated/shared/c++/AccuracyQuality.hpp +84 -0
- package/nitrogen/generated/shared/c++/CompassSample.hpp +87 -0
- package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.cpp +33 -0
- package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.hpp +87 -0
- package/nitrogen/generated/shared/c++/PermissionStatus.hpp +80 -0
- package/nitrogen/generated/shared/c++/SensorDiagnostics.hpp +84 -0
- package/nitrogen/generated/shared/c++/SensorKind.hpp +80 -0
- package/package.json +136 -0
- package/react-native.config.js +11 -0
- package/src/hook.ts +118 -0
- package/src/index.ts +28 -0
- package/src/multiplex.ts +117 -0
- package/src/native.ts +5 -0
- package/src/specs/NitroCompass.nitro.ts +193 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_AccuracyQuality.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 `(_ quality: AccuracyQuality) -> 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_AccuracyQuality {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrocompass.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ quality: AccuracyQuality) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ quality: AccuracyQuality) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(quality: Int32) -> Void {
|
|
25
|
+
self.closure(margelo.nitro.nitrocompass.AccuracyQuality(rawValue: quality)!)
|
|
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_AccuracyQuality`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_AccuracyQuality>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_AccuracyQuality {
|
|
44
|
+
return Unmanaged<Func_void_AccuracyQuality>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_CompassSample.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 `(_ sample: CompassSample) -> 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_CompassSample {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrocompass.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ sample: CompassSample) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ sample: CompassSample) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(sample: CompassSample) -> Void {
|
|
25
|
+
self.closure(sample)
|
|
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_CompassSample`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_CompassSample>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_CompassSample {
|
|
44
|
+
return Unmanaged<Func_void_CompassSample>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_PermissionStatus.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: PermissionStatus) -> 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_PermissionStatus {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrocompass.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: PermissionStatus) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: PermissionStatus) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: Int32) -> Void {
|
|
25
|
+
self.closure(margelo.nitro.nitrocompass.PermissionStatus(rawValue: 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_PermissionStatus`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_PermissionStatus>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_PermissionStatus {
|
|
44
|
+
return Unmanaged<Func_void_PermissionStatus>.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 `(_ interferenceDetected: 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.nitrocompass.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ interferenceDetected: Bool) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ interferenceDetected: Bool) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(interferenceDetected: Bool) -> Void {
|
|
25
|
+
self.closure(interferenceDetected)
|
|
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.nitrocompass.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,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroCompassSpec.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 ``HybridNitroCompassSpec``
|
|
11
|
+
public protocol HybridNitroCompassSpec_protocol: HybridObject {
|
|
12
|
+
// Properties
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// Methods
|
|
16
|
+
func start(filterDegrees: Double, onHeading: @escaping (_ sample: CompassSample) -> Void) throws -> Void
|
|
17
|
+
func stop() throws -> Void
|
|
18
|
+
func isStarted() throws -> Bool
|
|
19
|
+
func setFilter(degrees: Double) throws -> Void
|
|
20
|
+
func getDiagnostics() throws -> SensorDiagnostics?
|
|
21
|
+
func hasCompass() throws -> Bool
|
|
22
|
+
func getCurrentHeading() throws -> CompassSample?
|
|
23
|
+
func setDeclination(degrees: Double) throws -> Void
|
|
24
|
+
func setOnCalibrationNeeded(onChange: @escaping (_ quality: AccuracyQuality) -> Void) throws -> Void
|
|
25
|
+
func setOnInterferenceDetected(onChange: @escaping (_ interferenceDetected: Bool) -> Void) throws -> Void
|
|
26
|
+
func setPauseOnBackground(enabled: Bool) throws -> Void
|
|
27
|
+
func getPermissionStatus() throws -> PermissionStatus
|
|
28
|
+
func requestPermission() throws -> Promise<PermissionStatus>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public extension HybridNitroCompassSpec_protocol {
|
|
32
|
+
/// Default implementation of ``HybridObject.toString``
|
|
33
|
+
func toString() -> String {
|
|
34
|
+
return "[HybridObject NitroCompass]"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// See ``HybridNitroCompassSpec``
|
|
39
|
+
open class HybridNitroCompassSpec_base {
|
|
40
|
+
private weak var cxxWrapper: HybridNitroCompassSpec_cxx? = nil
|
|
41
|
+
public init() { }
|
|
42
|
+
public func getCxxWrapper() -> HybridNitroCompassSpec_cxx {
|
|
43
|
+
#if DEBUG
|
|
44
|
+
guard self is any HybridNitroCompassSpec else {
|
|
45
|
+
fatalError("`self` is not a `HybridNitroCompassSpec`! Did you accidentally inherit from `HybridNitroCompassSpec_base` instead of `HybridNitroCompassSpec`?")
|
|
46
|
+
}
|
|
47
|
+
#endif
|
|
48
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
49
|
+
return cxxWrapper
|
|
50
|
+
} else {
|
|
51
|
+
let cxxWrapper = HybridNitroCompassSpec_cxx(self as! any HybridNitroCompassSpec)
|
|
52
|
+
self.cxxWrapper = cxxWrapper
|
|
53
|
+
return cxxWrapper
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A Swift base-protocol representing the NitroCompass HybridObject.
|
|
60
|
+
* Implement this protocol to create Swift-based instances of NitroCompass.
|
|
61
|
+
* ```swift
|
|
62
|
+
* class HybridNitroCompass : HybridNitroCompassSpec {
|
|
63
|
+
* // ...
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
public typealias HybridNitroCompassSpec = HybridNitroCompassSpec_protocol & HybridNitroCompassSpec_base
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroCompassSpec_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 HybridNitroCompassSpec 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 HybridNitroCompassSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::nitrocompass::bridge::swift`)
|
|
22
|
+
* from `NitroCompass-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.nitrocompass.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridNitroCompassSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridNitroCompassSpec
|
|
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_HybridNitroCompassSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridNitroCompassSpec_cxx` that wraps the given `HybridNitroCompassSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridNitroCompassSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridNitroCompassSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridNitroCompassSpec() -> any HybridNitroCompassSpec {
|
|
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 `HybridNitroCompassSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridNitroCompassSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroCompassSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridNitroCompassSpec_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<HybridNitroCompassSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroCompassSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridNitroCompassSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNitroCompassSpec_(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: HybridNitroCompassSpec_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 start(filterDegrees: Double, onHeading: bridge.Func_void_CompassSample) -> bridge.Result_void_ {
|
|
129
|
+
do {
|
|
130
|
+
try self.__implementation.start(filterDegrees: filterDegrees, onHeading: { () -> (CompassSample) -> Void in
|
|
131
|
+
let __wrappedFunction = bridge.wrap_Func_void_CompassSample(onHeading)
|
|
132
|
+
return { (__sample: CompassSample) -> Void in
|
|
133
|
+
__wrappedFunction.call(__sample)
|
|
134
|
+
}
|
|
135
|
+
}())
|
|
136
|
+
return bridge.create_Result_void_()
|
|
137
|
+
} catch (let __error) {
|
|
138
|
+
let __exceptionPtr = __error.toCpp()
|
|
139
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@inline(__always)
|
|
144
|
+
public final func stop() -> bridge.Result_void_ {
|
|
145
|
+
do {
|
|
146
|
+
try self.__implementation.stop()
|
|
147
|
+
return bridge.create_Result_void_()
|
|
148
|
+
} catch (let __error) {
|
|
149
|
+
let __exceptionPtr = __error.toCpp()
|
|
150
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@inline(__always)
|
|
155
|
+
public final func isStarted() -> bridge.Result_bool_ {
|
|
156
|
+
do {
|
|
157
|
+
let __result = try self.__implementation.isStarted()
|
|
158
|
+
let __resultCpp = __result
|
|
159
|
+
return bridge.create_Result_bool_(__resultCpp)
|
|
160
|
+
} catch (let __error) {
|
|
161
|
+
let __exceptionPtr = __error.toCpp()
|
|
162
|
+
return bridge.create_Result_bool_(__exceptionPtr)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@inline(__always)
|
|
167
|
+
public final func setFilter(degrees: Double) -> bridge.Result_void_ {
|
|
168
|
+
do {
|
|
169
|
+
try self.__implementation.setFilter(degrees: degrees)
|
|
170
|
+
return bridge.create_Result_void_()
|
|
171
|
+
} catch (let __error) {
|
|
172
|
+
let __exceptionPtr = __error.toCpp()
|
|
173
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@inline(__always)
|
|
178
|
+
public final func getDiagnostics() -> bridge.Result_std__optional_SensorDiagnostics__ {
|
|
179
|
+
do {
|
|
180
|
+
let __result = try self.__implementation.getDiagnostics()
|
|
181
|
+
let __resultCpp = { () -> bridge.std__optional_SensorDiagnostics_ in
|
|
182
|
+
if let __unwrappedValue = __result {
|
|
183
|
+
return bridge.create_std__optional_SensorDiagnostics_(__unwrappedValue)
|
|
184
|
+
} else {
|
|
185
|
+
return .init()
|
|
186
|
+
}
|
|
187
|
+
}()
|
|
188
|
+
return bridge.create_Result_std__optional_SensorDiagnostics__(__resultCpp)
|
|
189
|
+
} catch (let __error) {
|
|
190
|
+
let __exceptionPtr = __error.toCpp()
|
|
191
|
+
return bridge.create_Result_std__optional_SensorDiagnostics__(__exceptionPtr)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@inline(__always)
|
|
196
|
+
public final func hasCompass() -> bridge.Result_bool_ {
|
|
197
|
+
do {
|
|
198
|
+
let __result = try self.__implementation.hasCompass()
|
|
199
|
+
let __resultCpp = __result
|
|
200
|
+
return bridge.create_Result_bool_(__resultCpp)
|
|
201
|
+
} catch (let __error) {
|
|
202
|
+
let __exceptionPtr = __error.toCpp()
|
|
203
|
+
return bridge.create_Result_bool_(__exceptionPtr)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@inline(__always)
|
|
208
|
+
public final func getCurrentHeading() -> bridge.Result_std__optional_CompassSample__ {
|
|
209
|
+
do {
|
|
210
|
+
let __result = try self.__implementation.getCurrentHeading()
|
|
211
|
+
let __resultCpp = { () -> bridge.std__optional_CompassSample_ in
|
|
212
|
+
if let __unwrappedValue = __result {
|
|
213
|
+
return bridge.create_std__optional_CompassSample_(__unwrappedValue)
|
|
214
|
+
} else {
|
|
215
|
+
return .init()
|
|
216
|
+
}
|
|
217
|
+
}()
|
|
218
|
+
return bridge.create_Result_std__optional_CompassSample__(__resultCpp)
|
|
219
|
+
} catch (let __error) {
|
|
220
|
+
let __exceptionPtr = __error.toCpp()
|
|
221
|
+
return bridge.create_Result_std__optional_CompassSample__(__exceptionPtr)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@inline(__always)
|
|
226
|
+
public final func setDeclination(degrees: Double) -> bridge.Result_void_ {
|
|
227
|
+
do {
|
|
228
|
+
try self.__implementation.setDeclination(degrees: degrees)
|
|
229
|
+
return bridge.create_Result_void_()
|
|
230
|
+
} catch (let __error) {
|
|
231
|
+
let __exceptionPtr = __error.toCpp()
|
|
232
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@inline(__always)
|
|
237
|
+
public final func setOnCalibrationNeeded(onChange: bridge.Func_void_AccuracyQuality) -> bridge.Result_void_ {
|
|
238
|
+
do {
|
|
239
|
+
try self.__implementation.setOnCalibrationNeeded(onChange: { () -> (AccuracyQuality) -> Void in
|
|
240
|
+
let __wrappedFunction = bridge.wrap_Func_void_AccuracyQuality(onChange)
|
|
241
|
+
return { (__quality: AccuracyQuality) -> Void in
|
|
242
|
+
__wrappedFunction.call(__quality.rawValue)
|
|
243
|
+
}
|
|
244
|
+
}())
|
|
245
|
+
return bridge.create_Result_void_()
|
|
246
|
+
} catch (let __error) {
|
|
247
|
+
let __exceptionPtr = __error.toCpp()
|
|
248
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@inline(__always)
|
|
253
|
+
public final func setOnInterferenceDetected(onChange: bridge.Func_void_bool) -> bridge.Result_void_ {
|
|
254
|
+
do {
|
|
255
|
+
try self.__implementation.setOnInterferenceDetected(onChange: { () -> (Bool) -> Void in
|
|
256
|
+
let __wrappedFunction = bridge.wrap_Func_void_bool(onChange)
|
|
257
|
+
return { (__interferenceDetected: Bool) -> Void in
|
|
258
|
+
__wrappedFunction.call(__interferenceDetected)
|
|
259
|
+
}
|
|
260
|
+
}())
|
|
261
|
+
return bridge.create_Result_void_()
|
|
262
|
+
} catch (let __error) {
|
|
263
|
+
let __exceptionPtr = __error.toCpp()
|
|
264
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@inline(__always)
|
|
269
|
+
public final func setPauseOnBackground(enabled: Bool) -> bridge.Result_void_ {
|
|
270
|
+
do {
|
|
271
|
+
try self.__implementation.setPauseOnBackground(enabled: enabled)
|
|
272
|
+
return bridge.create_Result_void_()
|
|
273
|
+
} catch (let __error) {
|
|
274
|
+
let __exceptionPtr = __error.toCpp()
|
|
275
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@inline(__always)
|
|
280
|
+
public final func getPermissionStatus() -> bridge.Result_PermissionStatus_ {
|
|
281
|
+
do {
|
|
282
|
+
let __result = try self.__implementation.getPermissionStatus()
|
|
283
|
+
let __resultCpp = __result
|
|
284
|
+
return bridge.create_Result_PermissionStatus_(__resultCpp)
|
|
285
|
+
} catch (let __error) {
|
|
286
|
+
let __exceptionPtr = __error.toCpp()
|
|
287
|
+
return bridge.create_Result_PermissionStatus_(__exceptionPtr)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@inline(__always)
|
|
292
|
+
public final func requestPermission() -> bridge.Result_std__shared_ptr_Promise_PermissionStatus___ {
|
|
293
|
+
do {
|
|
294
|
+
let __result = try self.__implementation.requestPermission()
|
|
295
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionStatus__ in
|
|
296
|
+
let __promise = bridge.create_std__shared_ptr_Promise_PermissionStatus__()
|
|
297
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionStatus__(__promise)
|
|
298
|
+
__result
|
|
299
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
300
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
301
|
+
return __promise
|
|
302
|
+
}()
|
|
303
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__resultCpp)
|
|
304
|
+
} catch (let __error) {
|
|
305
|
+
let __exceptionPtr = __error.toCpp()
|
|
306
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__exceptionPtr)
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PermissionStatus.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 `PermissionStatus`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias PermissionStatus = margelo.nitro.nitrocompass.PermissionStatus
|
|
12
|
+
|
|
13
|
+
public extension PermissionStatus {
|
|
14
|
+
/**
|
|
15
|
+
* Get a PermissionStatus 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 "granted":
|
|
21
|
+
self = .granted
|
|
22
|
+
case "denied":
|
|
23
|
+
self = .denied
|
|
24
|
+
case "unknown":
|
|
25
|
+
self = .unknown
|
|
26
|
+
default:
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the String value this PermissionStatus represents.
|
|
33
|
+
*/
|
|
34
|
+
var stringValue: String {
|
|
35
|
+
switch self {
|
|
36
|
+
case .granted:
|
|
37
|
+
return "granted"
|
|
38
|
+
case .denied:
|
|
39
|
+
return "denied"
|
|
40
|
+
case .unknown:
|
|
41
|
+
return "unknown"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SensorDiagnostics.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 `SensorDiagnostics`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias SensorDiagnostics = margelo.nitro.nitrocompass.SensorDiagnostics
|
|
14
|
+
|
|
15
|
+
public extension SensorDiagnostics {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrocompass.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `SensorDiagnostics`.
|
|
20
|
+
*/
|
|
21
|
+
init(sensor: SensorKind) {
|
|
22
|
+
self.init(sensor)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var sensor: SensorKind {
|
|
27
|
+
return self.__sensor
|
|
28
|
+
}
|
|
29
|
+
}
|