@kingstinct/react-native-healthkit 13.3.1 → 13.4.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/ios/WorkoutProxy.swift +3 -2
- package/lib/typescript/types/Workouts.d.ts +2 -0
- package/nitrogen/generated/ios/c++/HybridWorkoutProxySpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/swift/WorkoutEvent.swift +20 -2
- package/nitrogen/generated/shared/c++/WorkoutEvent.hpp +8 -2
- package/package.json +1 -1
- package/src/types/Workouts.ts +2 -0
package/ios/WorkoutProxy.swift
CHANGED
|
@@ -498,7 +498,8 @@ class WorkoutProxy: HybridWorkoutProxySpec {
|
|
|
498
498
|
return WorkoutEvent(
|
|
499
499
|
type: type,
|
|
500
500
|
startDate: event.dateInterval.start,
|
|
501
|
-
endDate: event.dateInterval.end
|
|
501
|
+
endDate: event.dateInterval.end,
|
|
502
|
+
metadata: serializeMetadata(event.metadata)
|
|
502
503
|
)
|
|
503
504
|
}
|
|
504
505
|
warnWithPrefix(
|
|
@@ -554,4 +555,4 @@ class WorkoutProxy: HybridWorkoutProxySpec {
|
|
|
554
555
|
return try await getSerializedWorkoutLocations(workout: self.workout)
|
|
555
556
|
}
|
|
556
557
|
}
|
|
557
|
-
}
|
|
558
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules';
|
|
1
2
|
import type { WorkoutProxy } from '../specs/WorkoutProxy.nitro';
|
|
2
3
|
import type { BaseSample, ComparisonPredicateOperator } from '../types';
|
|
3
4
|
import type { Quantity } from './QuantityType';
|
|
@@ -93,6 +94,7 @@ export interface WorkoutEvent {
|
|
|
93
94
|
readonly type: WorkoutEventType;
|
|
94
95
|
readonly startDate: Date;
|
|
95
96
|
readonly endDate: Date;
|
|
97
|
+
readonly metadata?: AnyMap;
|
|
96
98
|
}
|
|
97
99
|
export declare enum WorkoutEventType {
|
|
98
100
|
pause = 1,
|
|
@@ -61,6 +61,7 @@ namespace margelo::nitro::healthkit { enum class QuantityTypeIdentifier; }
|
|
|
61
61
|
#include <vector>
|
|
62
62
|
#include "WorkoutEventType.hpp"
|
|
63
63
|
#include <chrono>
|
|
64
|
+
#include <NitroModules/AnyMap.hpp>
|
|
64
65
|
#include "WorkoutActivity.hpp"
|
|
65
66
|
#include "SampleType.hpp"
|
|
66
67
|
#include "WeatherCondition.hpp"
|
|
@@ -70,7 +71,6 @@ namespace margelo::nitro::healthkit { enum class QuantityTypeIdentifier; }
|
|
|
70
71
|
#include <memory>
|
|
71
72
|
#include "HybridSourceProxySpec.hpp"
|
|
72
73
|
#include "Device.hpp"
|
|
73
|
-
#include <NitroModules/AnyMap.hpp>
|
|
74
74
|
#include "WorkoutSample.hpp"
|
|
75
75
|
#include <NitroModules/Promise.hpp>
|
|
76
76
|
#include "LocationForSaving.hpp"
|
|
@@ -18,8 +18,14 @@ public extension WorkoutEvent {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `WorkoutEvent`.
|
|
20
20
|
*/
|
|
21
|
-
init(type: WorkoutEventType, startDate: Date, endDate: Date) {
|
|
22
|
-
self.init(type, startDate.toCpp(), endDate.toCpp())
|
|
21
|
+
init(type: WorkoutEventType, startDate: Date, endDate: Date, metadata: AnyMap?) {
|
|
22
|
+
self.init(type, startDate.toCpp(), endDate.toCpp(), { () -> bridge.std__optional_std__shared_ptr_AnyMap__ in
|
|
23
|
+
if let __unwrappedValue = metadata {
|
|
24
|
+
return bridge.create_std__optional_std__shared_ptr_AnyMap__(__unwrappedValue.cppPart)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}())
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
@inline(__always)
|
|
@@ -36,4 +42,16 @@ public extension WorkoutEvent {
|
|
|
36
42
|
var endDate: Date {
|
|
37
43
|
return Date(fromChrono: self.__endDate)
|
|
38
44
|
}
|
|
45
|
+
|
|
46
|
+
@inline(__always)
|
|
47
|
+
var metadata: AnyMap? {
|
|
48
|
+
return { () -> AnyMap? in
|
|
49
|
+
if bridge.has_value_std__optional_std__shared_ptr_AnyMap__(self.__metadata) {
|
|
50
|
+
let __unwrapped = bridge.get_std__optional_std__shared_ptr_AnyMap__(self.__metadata)
|
|
51
|
+
return AnyMap(withCppPart: __unwrapped)
|
|
52
|
+
} else {
|
|
53
|
+
return nil
|
|
54
|
+
}
|
|
55
|
+
}()
|
|
56
|
+
}
|
|
39
57
|
}
|
|
@@ -33,6 +33,8 @@ namespace margelo::nitro::healthkit { enum class WorkoutEventType; }
|
|
|
33
33
|
|
|
34
34
|
#include "WorkoutEventType.hpp"
|
|
35
35
|
#include <chrono>
|
|
36
|
+
#include <NitroModules/AnyMap.hpp>
|
|
37
|
+
#include <optional>
|
|
36
38
|
|
|
37
39
|
namespace margelo::nitro::healthkit {
|
|
38
40
|
|
|
@@ -44,10 +46,11 @@ namespace margelo::nitro::healthkit {
|
|
|
44
46
|
WorkoutEventType type SWIFT_PRIVATE;
|
|
45
47
|
std::chrono::system_clock::time_point startDate SWIFT_PRIVATE;
|
|
46
48
|
std::chrono::system_clock::time_point endDate SWIFT_PRIVATE;
|
|
49
|
+
std::optional<std::shared_ptr<AnyMap>> metadata SWIFT_PRIVATE;
|
|
47
50
|
|
|
48
51
|
public:
|
|
49
52
|
WorkoutEvent() = default;
|
|
50
|
-
explicit WorkoutEvent(WorkoutEventType type, std::chrono::system_clock::time_point startDate, std::chrono::system_clock::time_point endDate): type(type), startDate(startDate), endDate(endDate) {}
|
|
53
|
+
explicit WorkoutEvent(WorkoutEventType type, std::chrono::system_clock::time_point startDate, std::chrono::system_clock::time_point endDate, std::optional<std::shared_ptr<AnyMap>> metadata): type(type), startDate(startDate), endDate(endDate), metadata(metadata) {}
|
|
51
54
|
|
|
52
55
|
public:
|
|
53
56
|
friend bool operator==(const WorkoutEvent& lhs, const WorkoutEvent& rhs) = default;
|
|
@@ -65,7 +68,8 @@ namespace margelo::nitro {
|
|
|
65
68
|
return margelo::nitro::healthkit::WorkoutEvent(
|
|
66
69
|
JSIConverter<margelo::nitro::healthkit::WorkoutEventType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
|
|
67
70
|
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate"))),
|
|
68
|
-
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate")))
|
|
71
|
+
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate"))),
|
|
72
|
+
JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata")))
|
|
69
73
|
);
|
|
70
74
|
}
|
|
71
75
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutEvent& arg) {
|
|
@@ -73,6 +77,7 @@ namespace margelo::nitro {
|
|
|
73
77
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<margelo::nitro::healthkit::WorkoutEventType>::toJSI(runtime, arg.type));
|
|
74
78
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "startDate"), JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.startDate));
|
|
75
79
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "endDate"), JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.endDate));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "metadata"), JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::toJSI(runtime, arg.metadata));
|
|
76
81
|
return obj;
|
|
77
82
|
}
|
|
78
83
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -86,6 +91,7 @@ namespace margelo::nitro {
|
|
|
86
91
|
if (!JSIConverter<margelo::nitro::healthkit::WorkoutEventType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
|
|
87
92
|
if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate")))) return false;
|
|
88
93
|
if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate")))) return false;
|
|
94
|
+
if (!JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata")))) return false;
|
|
89
95
|
return true;
|
|
90
96
|
}
|
|
91
97
|
};
|
package/package.json
CHANGED
package/src/types/Workouts.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules'
|
|
1
2
|
import type { WorkoutProxy } from '../specs/WorkoutProxy.nitro'
|
|
2
3
|
import type { BaseSample, ComparisonPredicateOperator } from '../types'
|
|
3
4
|
import type { Quantity } from './QuantityType'
|
|
@@ -95,6 +96,7 @@ export interface WorkoutEvent {
|
|
|
95
96
|
readonly type: WorkoutEventType
|
|
96
97
|
readonly startDate: Date
|
|
97
98
|
readonly endDate: Date
|
|
99
|
+
readonly metadata?: AnyMap
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
export enum WorkoutEventType {
|