@kingstinct/react-native-healthkit 9.0.7 → 9.0.8

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 (33) hide show
  1. package/ios/CategoryTypeModule.swift +18 -21
  2. package/ios/CorrelationTypeModule.swift +18 -18
  3. package/ios/HeartbeatSeriesModule.swift +32 -32
  4. package/ios/QuantityTypeModule.swift +56 -57
  5. package/ios/Serializers.swift +12 -16
  6. package/ios/StateOfMindModule.swift +17 -17
  7. package/ios/WorkoutsModule.swift +59 -110
  8. package/lib/typescript/specs/WorkoutsModule.nitro.d.ts +3 -0
  9. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +3 -44
  10. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +24 -124
  11. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp +0 -14
  12. package/package.json +2 -2
  13. package/src/specs/WorkoutsModule.nitro.ts +3 -0
  14. package/ios/WorkoutSessionModule.swift +0 -182
  15. package/lib/commonjs/specs/WorkoutSessionModule.nitro.js +0 -19
  16. package/lib/module/specs/WorkoutSessionModule.nitro.js +0 -16
  17. package/lib/typescript/specs/WorkoutSessionModule.nitro.d.ts +0 -47
  18. package/nitrogen/generated/ios/c++/HybridWorkoutSessionModuleSpecSwift.cpp +0 -11
  19. package/nitrogen/generated/ios/c++/HybridWorkoutSessionModuleSpecSwift.hpp +0 -107
  20. package/nitrogen/generated/ios/swift/Func_void_WorkoutEventType.swift +0 -46
  21. package/nitrogen/generated/ios/swift/Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point.swift +0 -46
  22. package/nitrogen/generated/ios/swift/Func_void_std__vector_RemoteSessionSharableData_.swift +0 -46
  23. package/nitrogen/generated/ios/swift/HybridWorkoutSessionModuleSpec.swift +0 -49
  24. package/nitrogen/generated/ios/swift/HybridWorkoutSessionModuleSpec_cxx.swift +0 -133
  25. package/nitrogen/generated/ios/swift/RemoteSessionSharableData.swift +0 -46
  26. package/nitrogen/generated/ios/swift/WorkoutSessionMirroringStartHandlerOptions.swift +0 -118
  27. package/nitrogen/generated/ios/swift/WorkoutSessionState.swift +0 -56
  28. package/nitrogen/generated/shared/c++/HybridWorkoutSessionModuleSpec.cpp +0 -22
  29. package/nitrogen/generated/shared/c++/HybridWorkoutSessionModuleSpec.hpp +0 -68
  30. package/nitrogen/generated/shared/c++/RemoteSessionSharableData.hpp +0 -75
  31. package/nitrogen/generated/shared/c++/WorkoutSessionMirroringStartHandlerOptions.hpp +0 -92
  32. package/nitrogen/generated/shared/c++/WorkoutSessionState.hpp +0 -68
  33. package/src/specs/WorkoutSessionModule.nitro.ts +0 -71
@@ -1,133 +0,0 @@
1
- ///
2
- /// HybridWorkoutSessionModuleSpec_cxx.swift
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- import Foundation
9
- import NitroModules
10
-
11
- /**
12
- * A class implementation that bridges HybridWorkoutSessionModuleSpec 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
- public class HybridWorkoutSessionModuleSpec_cxx {
21
- /**
22
- * The Swift <> C++ bridge's namespace (`margelo::nitro::healthkit::bridge::swift`)
23
- * from `ReactNativeHealthkit-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.healthkit.bridge.swift
27
-
28
- /**
29
- * Holds an instance of the `HybridWorkoutSessionModuleSpec` Swift protocol.
30
- */
31
- private var __implementation: any HybridWorkoutSessionModuleSpec
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_margelo__nitro__healthkit__HybridWorkoutSessionModuleSpec_
37
-
38
- /**
39
- * Create a new `HybridWorkoutSessionModuleSpec_cxx` that wraps the given `HybridWorkoutSessionModuleSpec`.
40
- * All properties and methods bridge to C++ types.
41
- */
42
- public init(_ implementation: any HybridWorkoutSessionModuleSpec) {
43
- self.__implementation = implementation
44
- self.__cxxPart = .init()
45
- /* no base class */
46
- }
47
-
48
- /**
49
- * Get the actual `HybridWorkoutSessionModuleSpec` instance this class wraps.
50
- */
51
- @inline(__always)
52
- public func getHybridWorkoutSessionModuleSpec() -> any HybridWorkoutSessionModuleSpec {
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 `HybridWorkoutSessionModuleSpec_cxx`.
66
- * The pointer has to be a retained opaque `Unmanaged<HybridWorkoutSessionModuleSpec_cxx>`.
67
- * This removes one strong reference from the object!
68
- */
69
- public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridWorkoutSessionModuleSpec_cxx {
70
- return Unmanaged<HybridWorkoutSessionModuleSpec_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<margelo::nitro::healthkit::HybridWorkoutSessionModuleSpec>`.
76
- */
77
- public func getCxxPart() -> bridge.std__shared_ptr_margelo__nitro__healthkit__HybridWorkoutSessionModuleSpec_ {
78
- let cachedCxxPart = self.__cxxPart.lock()
79
- if cachedCxxPart.__convertToBool() {
80
- return cachedCxxPart
81
- } else {
82
- let newCxxPart = bridge.create_std__shared_ptr_margelo__nitro__healthkit__HybridWorkoutSessionModuleSpec_(self.toUnsafe())
83
- __cxxPart = bridge.weakify_std__shared_ptr_margelo__nitro__healthkit__HybridWorkoutSessionModuleSpec_(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
- // Properties
100
-
101
-
102
- // Methods
103
- @inline(__always)
104
- public final func startWatchAppWithWorkoutConfiguration(workoutConfiguration: WorkoutConfiguration) -> bridge.Result_std__shared_ptr_Promise_bool___ {
105
- do {
106
- let __result = try self.__implementation.startWatchAppWithWorkoutConfiguration(workoutConfiguration: workoutConfiguration)
107
- let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
108
- let __promise = bridge.create_std__shared_ptr_Promise_bool__()
109
- let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
110
- __result
111
- .then({ __result in __promiseHolder.resolve(__result) })
112
- .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
113
- return __promise
114
- }()
115
- return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
116
- } catch (let __error) {
117
- let __exceptionPtr = __error.toCpp()
118
- return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
119
- }
120
- }
121
-
122
- @inline(__always)
123
- public final func workoutSessionMirroringStartHandler(options: WorkoutSessionMirroringStartHandlerOptions) -> bridge.Result_bool_ {
124
- do {
125
- let __result = try self.__implementation.workoutSessionMirroringStartHandler(options: options)
126
- let __resultCpp = __result
127
- return bridge.create_Result_bool_(__resultCpp)
128
- } catch (let __error) {
129
- let __exceptionPtr = __error.toCpp()
130
- return bridge.create_Result_bool_(__exceptionPtr)
131
- }
132
- }
133
- }
@@ -1,46 +0,0 @@
1
- ///
2
- /// RemoteSessionSharableData.swift
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- import NitroModules
9
-
10
- /**
11
- * Represents an instance of `RemoteSessionSharableData`, backed by a C++ struct.
12
- */
13
- public typealias RemoteSessionSharableData = margelo.nitro.healthkit.RemoteSessionSharableData
14
-
15
- public extension RemoteSessionSharableData {
16
- private typealias bridge = margelo.nitro.healthkit.bridge.swift
17
-
18
- /**
19
- * Create a new instance of `RemoteSessionSharableData`.
20
- */
21
- init(type: String, payload: AnyMapHolder) {
22
- self.init(std.string(type), payload.cppPart)
23
- }
24
-
25
- var type: String {
26
- @inline(__always)
27
- get {
28
- return String(self.__type)
29
- }
30
- @inline(__always)
31
- set {
32
- self.__type = std.string(newValue)
33
- }
34
- }
35
-
36
- var payload: AnyMapHolder {
37
- @inline(__always)
38
- get {
39
- return AnyMapHolder(withCppPart: self.__payload)
40
- }
41
- @inline(__always)
42
- set {
43
- self.__payload = newValue.cppPart
44
- }
45
- }
46
- }
@@ -1,118 +0,0 @@
1
- ///
2
- /// WorkoutSessionMirroringStartHandlerOptions.swift
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- import NitroModules
9
-
10
- /**
11
- * Represents an instance of `WorkoutSessionMirroringStartHandlerOptions`, backed by a C++ struct.
12
- */
13
- public typealias WorkoutSessionMirroringStartHandlerOptions = margelo.nitro.healthkit.WorkoutSessionMirroringStartHandlerOptions
14
-
15
- public extension WorkoutSessionMirroringStartHandlerOptions {
16
- private typealias bridge = margelo.nitro.healthkit.bridge.swift
17
-
18
- /**
19
- * Create a new instance of `WorkoutSessionMirroringStartHandlerOptions`.
20
- */
21
- init(onError: @escaping (_ errorMessage: String) -> Void, onStateChange: @escaping (_ toState: WorkoutSessionState, _ fromState: WorkoutSessionState, _ date: Date) -> Void, onDataReceived: @escaping (_ data: [RemoteSessionSharableData]) -> Void, onEventReceived: @escaping (_ type: WorkoutEventType) -> Void) {
22
- self.init({ () -> bridge.Func_void_std__string in
23
- let __closureWrapper = Func_void_std__string(onError)
24
- return bridge.create_Func_void_std__string(__closureWrapper.toUnsafe())
25
- }(), { () -> bridge.Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point in
26
- let __closureWrapper = Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point(onStateChange)
27
- return bridge.create_Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point(__closureWrapper.toUnsafe())
28
- }(), { () -> bridge.Func_void_std__vector_RemoteSessionSharableData_ in
29
- let __closureWrapper = Func_void_std__vector_RemoteSessionSharableData_(onDataReceived)
30
- return bridge.create_Func_void_std__vector_RemoteSessionSharableData_(__closureWrapper.toUnsafe())
31
- }(), { () -> bridge.Func_void_WorkoutEventType in
32
- let __closureWrapper = Func_void_WorkoutEventType(onEventReceived)
33
- return bridge.create_Func_void_WorkoutEventType(__closureWrapper.toUnsafe())
34
- }())
35
- }
36
-
37
- var onError: (_ errorMessage: String) -> Void {
38
- @inline(__always)
39
- get {
40
- return { () -> (String) -> Void in
41
- let __wrappedFunction = bridge.wrap_Func_void_std__string(self.__onError)
42
- return { (__errorMessage: String) -> Void in
43
- __wrappedFunction.call(std.string(__errorMessage))
44
- }
45
- }()
46
- }
47
- @inline(__always)
48
- set {
49
- self.__onError = { () -> bridge.Func_void_std__string in
50
- let __closureWrapper = Func_void_std__string(newValue)
51
- return bridge.create_Func_void_std__string(__closureWrapper.toUnsafe())
52
- }()
53
- }
54
- }
55
-
56
- var onStateChange: (_ toState: WorkoutSessionState, _ fromState: WorkoutSessionState, _ date: Date) -> Void {
57
- @inline(__always)
58
- get {
59
- return { () -> (WorkoutSessionState, WorkoutSessionState, Date) -> Void in
60
- let __wrappedFunction = bridge.wrap_Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point(self.__onStateChange)
61
- return { (__toState: WorkoutSessionState, __fromState: WorkoutSessionState, __date: Date) -> Void in
62
- __wrappedFunction.call(__toState.rawValue, __fromState.rawValue, __date.toCpp())
63
- }
64
- }()
65
- }
66
- @inline(__always)
67
- set {
68
- self.__onStateChange = { () -> bridge.Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point in
69
- let __closureWrapper = Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point(newValue)
70
- return bridge.create_Func_void_WorkoutSessionState_WorkoutSessionState_std__chrono__system_clock__time_point(__closureWrapper.toUnsafe())
71
- }()
72
- }
73
- }
74
-
75
- var onDataReceived: (_ data: [RemoteSessionSharableData]) -> Void {
76
- @inline(__always)
77
- get {
78
- return { () -> ([RemoteSessionSharableData]) -> Void in
79
- let __wrappedFunction = bridge.wrap_Func_void_std__vector_RemoteSessionSharableData_(self.__onDataReceived)
80
- return { (__data: [RemoteSessionSharableData]) -> Void in
81
- __wrappedFunction.call({ () -> bridge.std__vector_RemoteSessionSharableData_ in
82
- var __vector = bridge.create_std__vector_RemoteSessionSharableData_(__data.count)
83
- for __item in __data {
84
- __vector.push_back(__item)
85
- }
86
- return __vector
87
- }())
88
- }
89
- }()
90
- }
91
- @inline(__always)
92
- set {
93
- self.__onDataReceived = { () -> bridge.Func_void_std__vector_RemoteSessionSharableData_ in
94
- let __closureWrapper = Func_void_std__vector_RemoteSessionSharableData_(newValue)
95
- return bridge.create_Func_void_std__vector_RemoteSessionSharableData_(__closureWrapper.toUnsafe())
96
- }()
97
- }
98
- }
99
-
100
- var onEventReceived: (_ type: WorkoutEventType) -> Void {
101
- @inline(__always)
102
- get {
103
- return { () -> (WorkoutEventType) -> Void in
104
- let __wrappedFunction = bridge.wrap_Func_void_WorkoutEventType(self.__onEventReceived)
105
- return { (__type: WorkoutEventType) -> Void in
106
- __wrappedFunction.call(__type.rawValue)
107
- }
108
- }()
109
- }
110
- @inline(__always)
111
- set {
112
- self.__onEventReceived = { () -> bridge.Func_void_WorkoutEventType in
113
- let __closureWrapper = Func_void_WorkoutEventType(newValue)
114
- return bridge.create_Func_void_WorkoutEventType(__closureWrapper.toUnsafe())
115
- }()
116
- }
117
- }
118
- }
@@ -1,56 +0,0 @@
1
- ///
2
- /// WorkoutSessionState.swift
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- /**
9
- * Represents the JS enum `WorkoutSessionState`, backed by a C++ enum.
10
- */
11
- public typealias WorkoutSessionState = margelo.nitro.healthkit.WorkoutSessionState
12
-
13
- public extension WorkoutSessionState {
14
- /**
15
- * Get a WorkoutSessionState 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 "NotStarted":
21
- self = .notstarted
22
- case "Running":
23
- self = .running
24
- case "Ended":
25
- self = .ended
26
- case "Paused":
27
- self = .paused
28
- case "Prepared":
29
- self = .prepared
30
- case "Stopped":
31
- self = .stopped
32
- default:
33
- return nil
34
- }
35
- }
36
-
37
- /**
38
- * Get the String value this WorkoutSessionState represents.
39
- */
40
- var stringValue: String {
41
- switch self {
42
- case .notstarted:
43
- return "NotStarted"
44
- case .running:
45
- return "Running"
46
- case .ended:
47
- return "Ended"
48
- case .paused:
49
- return "Paused"
50
- case .prepared:
51
- return "Prepared"
52
- case .stopped:
53
- return "Stopped"
54
- }
55
- }
56
- }
@@ -1,22 +0,0 @@
1
- ///
2
- /// HybridWorkoutSessionModuleSpec.cpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #include "HybridWorkoutSessionModuleSpec.hpp"
9
-
10
- namespace margelo::nitro::healthkit {
11
-
12
- void HybridWorkoutSessionModuleSpec::loadHybridMethods() {
13
- // load base methods/properties
14
- HybridObject::loadHybridMethods();
15
- // load custom methods/properties
16
- registerHybrids(this, [](Prototype& prototype) {
17
- prototype.registerHybridMethod("startWatchAppWithWorkoutConfiguration", &HybridWorkoutSessionModuleSpec::startWatchAppWithWorkoutConfiguration);
18
- prototype.registerHybridMethod("workoutSessionMirroringStartHandler", &HybridWorkoutSessionModuleSpec::workoutSessionMirroringStartHandler);
19
- });
20
- }
21
-
22
- } // namespace margelo::nitro::healthkit
@@ -1,68 +0,0 @@
1
- ///
2
- /// HybridWorkoutSessionModuleSpec.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #if __has_include(<NitroModules/HybridObject.hpp>)
11
- #include <NitroModules/HybridObject.hpp>
12
- #else
13
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
- #endif
15
-
16
- // Forward declaration of `WorkoutConfiguration` to properly resolve imports.
17
- namespace margelo::nitro::healthkit { struct WorkoutConfiguration; }
18
- // Forward declaration of `WorkoutSessionMirroringStartHandlerOptions` to properly resolve imports.
19
- namespace margelo::nitro::healthkit { struct WorkoutSessionMirroringStartHandlerOptions; }
20
-
21
- #include <NitroModules/Promise.hpp>
22
- #include "WorkoutConfiguration.hpp"
23
- #include "WorkoutSessionMirroringStartHandlerOptions.hpp"
24
-
25
- namespace margelo::nitro::healthkit {
26
-
27
- using namespace margelo::nitro;
28
-
29
- /**
30
- * An abstract base class for `WorkoutSessionModule`
31
- * Inherit this class to create instances of `HybridWorkoutSessionModuleSpec` in C++.
32
- * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
33
- * @example
34
- * ```cpp
35
- * class HybridWorkoutSessionModule: public HybridWorkoutSessionModuleSpec {
36
- * public:
37
- * HybridWorkoutSessionModule(...): HybridObject(TAG) { ... }
38
- * // ...
39
- * };
40
- * ```
41
- */
42
- class HybridWorkoutSessionModuleSpec: public virtual HybridObject {
43
- public:
44
- // Constructor
45
- explicit HybridWorkoutSessionModuleSpec(): HybridObject(TAG) { }
46
-
47
- // Destructor
48
- ~HybridWorkoutSessionModuleSpec() override = default;
49
-
50
- public:
51
- // Properties
52
-
53
-
54
- public:
55
- // Methods
56
- virtual std::shared_ptr<Promise<bool>> startWatchAppWithWorkoutConfiguration(const WorkoutConfiguration& workoutConfiguration) = 0;
57
- virtual bool workoutSessionMirroringStartHandler(const WorkoutSessionMirroringStartHandlerOptions& options) = 0;
58
-
59
- protected:
60
- // Hybrid Setup
61
- void loadHybridMethods() override;
62
-
63
- protected:
64
- // Tag for logging
65
- static constexpr auto TAG = "WorkoutSessionModule";
66
- };
67
-
68
- } // namespace margelo::nitro::healthkit
@@ -1,75 +0,0 @@
1
- ///
2
- /// RemoteSessionSharableData.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 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
-
21
- // Forward declaration of `AnyMap` to properly resolve imports.
22
- namespace NitroModules { class AnyMap; }
23
-
24
- #include <string>
25
- #include <NitroModules/AnyMap.hpp>
26
-
27
- namespace margelo::nitro::healthkit {
28
-
29
- /**
30
- * A struct which can be represented as a JavaScript object (RemoteSessionSharableData).
31
- */
32
- struct RemoteSessionSharableData {
33
- public:
34
- std::string type SWIFT_PRIVATE;
35
- std::shared_ptr<AnyMap> payload SWIFT_PRIVATE;
36
-
37
- public:
38
- RemoteSessionSharableData() = default;
39
- explicit RemoteSessionSharableData(std::string type, std::shared_ptr<AnyMap> payload): type(type), payload(payload) {}
40
- };
41
-
42
- } // namespace margelo::nitro::healthkit
43
-
44
- namespace margelo::nitro {
45
-
46
- using namespace margelo::nitro::healthkit;
47
-
48
- // C++ RemoteSessionSharableData <> JS RemoteSessionSharableData (object)
49
- template <>
50
- struct JSIConverter<RemoteSessionSharableData> final {
51
- static inline RemoteSessionSharableData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
52
- jsi::Object obj = arg.asObject(runtime);
53
- return RemoteSessionSharableData(
54
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "type")),
55
- JSIConverter<std::shared_ptr<AnyMap>>::fromJSI(runtime, obj.getProperty(runtime, "payload"))
56
- );
57
- }
58
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const RemoteSessionSharableData& arg) {
59
- jsi::Object obj(runtime);
60
- obj.setProperty(runtime, "type", JSIConverter<std::string>::toJSI(runtime, arg.type));
61
- obj.setProperty(runtime, "payload", JSIConverter<std::shared_ptr<AnyMap>>::toJSI(runtime, arg.payload));
62
- return obj;
63
- }
64
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
- if (!value.isObject()) {
66
- return false;
67
- }
68
- jsi::Object obj = value.getObject(runtime);
69
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "type"))) return false;
70
- if (!JSIConverter<std::shared_ptr<AnyMap>>::canConvert(runtime, obj.getProperty(runtime, "payload"))) return false;
71
- return true;
72
- }
73
- };
74
-
75
- } // namespace margelo::nitro
@@ -1,92 +0,0 @@
1
- ///
2
- /// WorkoutSessionMirroringStartHandlerOptions.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 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
-
21
- // Forward declaration of `WorkoutSessionState` to properly resolve imports.
22
- namespace margelo::nitro::healthkit { enum class WorkoutSessionState; }
23
- // Forward declaration of `RemoteSessionSharableData` to properly resolve imports.
24
- namespace margelo::nitro::healthkit { struct RemoteSessionSharableData; }
25
- // Forward declaration of `WorkoutEventType` to properly resolve imports.
26
- namespace margelo::nitro::healthkit { enum class WorkoutEventType; }
27
-
28
- #include <functional>
29
- #include <string>
30
- #include "WorkoutSessionState.hpp"
31
- #include <chrono>
32
- #include <vector>
33
- #include "RemoteSessionSharableData.hpp"
34
- #include "WorkoutEventType.hpp"
35
-
36
- namespace margelo::nitro::healthkit {
37
-
38
- /**
39
- * A struct which can be represented as a JavaScript object (WorkoutSessionMirroringStartHandlerOptions).
40
- */
41
- struct WorkoutSessionMirroringStartHandlerOptions {
42
- public:
43
- std::function<void(const std::string& /* errorMessage */)> onError SWIFT_PRIVATE;
44
- std::function<void(WorkoutSessionState /* toState */, WorkoutSessionState /* fromState */, std::chrono::system_clock::time_point /* date */)> onStateChange SWIFT_PRIVATE;
45
- std::function<void(const std::vector<RemoteSessionSharableData>& /* data */)> onDataReceived SWIFT_PRIVATE;
46
- std::function<void(WorkoutEventType /* type */)> onEventReceived SWIFT_PRIVATE;
47
-
48
- public:
49
- WorkoutSessionMirroringStartHandlerOptions() = default;
50
- explicit WorkoutSessionMirroringStartHandlerOptions(std::function<void(const std::string& /* errorMessage */)> onError, std::function<void(WorkoutSessionState /* toState */, WorkoutSessionState /* fromState */, std::chrono::system_clock::time_point /* date */)> onStateChange, std::function<void(const std::vector<RemoteSessionSharableData>& /* data */)> onDataReceived, std::function<void(WorkoutEventType /* type */)> onEventReceived): onError(onError), onStateChange(onStateChange), onDataReceived(onDataReceived), onEventReceived(onEventReceived) {}
51
- };
52
-
53
- } // namespace margelo::nitro::healthkit
54
-
55
- namespace margelo::nitro {
56
-
57
- using namespace margelo::nitro::healthkit;
58
-
59
- // C++ WorkoutSessionMirroringStartHandlerOptions <> JS WorkoutSessionMirroringStartHandlerOptions (object)
60
- template <>
61
- struct JSIConverter<WorkoutSessionMirroringStartHandlerOptions> final {
62
- static inline WorkoutSessionMirroringStartHandlerOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
63
- jsi::Object obj = arg.asObject(runtime);
64
- return WorkoutSessionMirroringStartHandlerOptions(
65
- JSIConverter<std::function<void(const std::string& /* errorMessage */)>>::fromJSI(runtime, obj.getProperty(runtime, "onError")),
66
- JSIConverter<std::function<void(WorkoutSessionState /* toState */, WorkoutSessionState /* fromState */, std::chrono::system_clock::time_point /* date */)>>::fromJSI(runtime, obj.getProperty(runtime, "onStateChange")),
67
- JSIConverter<std::function<void(const std::vector<RemoteSessionSharableData>& /* data */)>>::fromJSI(runtime, obj.getProperty(runtime, "onDataReceived")),
68
- JSIConverter<std::function<void(WorkoutEventType /* type */)>>::fromJSI(runtime, obj.getProperty(runtime, "onEventReceived"))
69
- );
70
- }
71
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutSessionMirroringStartHandlerOptions& arg) {
72
- jsi::Object obj(runtime);
73
- obj.setProperty(runtime, "onError", JSIConverter<std::function<void(const std::string& /* errorMessage */)>>::toJSI(runtime, arg.onError));
74
- obj.setProperty(runtime, "onStateChange", JSIConverter<std::function<void(WorkoutSessionState /* toState */, WorkoutSessionState /* fromState */, std::chrono::system_clock::time_point /* date */)>>::toJSI(runtime, arg.onStateChange));
75
- obj.setProperty(runtime, "onDataReceived", JSIConverter<std::function<void(const std::vector<RemoteSessionSharableData>& /* data */)>>::toJSI(runtime, arg.onDataReceived));
76
- obj.setProperty(runtime, "onEventReceived", JSIConverter<std::function<void(WorkoutEventType /* type */)>>::toJSI(runtime, arg.onEventReceived));
77
- return obj;
78
- }
79
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
80
- if (!value.isObject()) {
81
- return false;
82
- }
83
- jsi::Object obj = value.getObject(runtime);
84
- if (!JSIConverter<std::function<void(const std::string& /* errorMessage */)>>::canConvert(runtime, obj.getProperty(runtime, "onError"))) return false;
85
- if (!JSIConverter<std::function<void(WorkoutSessionState /* toState */, WorkoutSessionState /* fromState */, std::chrono::system_clock::time_point /* date */)>>::canConvert(runtime, obj.getProperty(runtime, "onStateChange"))) return false;
86
- if (!JSIConverter<std::function<void(const std::vector<RemoteSessionSharableData>& /* data */)>>::canConvert(runtime, obj.getProperty(runtime, "onDataReceived"))) return false;
87
- if (!JSIConverter<std::function<void(WorkoutEventType /* type */)>>::canConvert(runtime, obj.getProperty(runtime, "onEventReceived"))) return false;
88
- return true;
89
- }
90
- };
91
-
92
- } // namespace margelo::nitro
@@ -1,68 +0,0 @@
1
- ///
2
- /// WorkoutSessionState.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <cmath>
11
- #if __has_include(<NitroModules/JSIConverter.hpp>)
12
- #include <NitroModules/JSIConverter.hpp>
13
- #else
14
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
15
- #endif
16
- #if __has_include(<NitroModules/NitroDefines.hpp>)
17
- #include <NitroModules/NitroDefines.hpp>
18
- #else
19
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
20
- #endif
21
-
22
- namespace margelo::nitro::healthkit {
23
-
24
- /**
25
- * An enum which can be represented as a JavaScript enum (WorkoutSessionState).
26
- */
27
- enum class WorkoutSessionState {
28
- NOTSTARTED SWIFT_NAME(notstarted) = 1,
29
- RUNNING SWIFT_NAME(running) = 2,
30
- ENDED SWIFT_NAME(ended) = 3,
31
- PAUSED SWIFT_NAME(paused) = 4,
32
- PREPARED SWIFT_NAME(prepared) = 5,
33
- STOPPED SWIFT_NAME(stopped) = 6,
34
- } CLOSED_ENUM;
35
-
36
- } // namespace margelo::nitro::healthkit
37
-
38
- namespace margelo::nitro {
39
-
40
- using namespace margelo::nitro::healthkit;
41
-
42
- // C++ WorkoutSessionState <> JS WorkoutSessionState (enum)
43
- template <>
44
- struct JSIConverter<WorkoutSessionState> final {
45
- static inline WorkoutSessionState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
- int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
47
- return static_cast<WorkoutSessionState>(enumValue);
48
- }
49
- static inline jsi::Value toJSI(jsi::Runtime& runtime, WorkoutSessionState arg) {
50
- int enumValue = static_cast<int>(arg);
51
- return JSIConverter<int>::toJSI(runtime, enumValue);
52
- }
53
- static inline bool canConvert(jsi::Runtime&, const jsi::Value& value) {
54
- if (!value.isNumber()) {
55
- return false;
56
- }
57
- double integer;
58
- double fraction = modf(value.getNumber(), &integer);
59
- if (fraction != 0.0) {
60
- // It is some kind of floating point number - our enums are ints.
61
- return false;
62
- }
63
- // Check if we are within the bounds of the enum.
64
- return integer >= 0 && integer <= 5;
65
- }
66
- };
67
-
68
- } // namespace margelo::nitro