@kingstinct/react-native-healthkit 11.0.0 → 11.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 (53) hide show
  1. package/README.md +2 -2
  2. package/ios/ElectrocardiogramModule.swift +210 -0
  3. package/ios/QuantityTypeModule.swift +52 -15
  4. package/lib/commonjs/healthkit.ios.js +6 -2
  5. package/lib/commonjs/healthkit.js +10 -2
  6. package/lib/commonjs/modules.js +2 -1
  7. package/lib/commonjs/specs/ElectrocardiogramModule.nitro.js +2 -0
  8. package/lib/commonjs/types/ElectrocardiogramSample.js +2 -0
  9. package/lib/module/healthkit.ios.js +5 -1
  10. package/lib/module/healthkit.js +8 -0
  11. package/lib/module/modules.js +1 -0
  12. package/lib/module/specs/ElectrocardiogramModule.nitro.js +1 -0
  13. package/lib/module/types/ElectrocardiogramSample.js +1 -0
  14. package/lib/typescript/healthkit.d.ts +2 -0
  15. package/lib/typescript/healthkit.ios.d.ts +4 -0
  16. package/lib/typescript/modules.d.ts +2 -0
  17. package/lib/typescript/specs/ElectrocardiogramModule.nitro.d.ts +8 -0
  18. package/lib/typescript/types/ElectrocardiogramSample.d.ts +39 -0
  19. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +33 -0
  20. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +176 -0
  21. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp +29 -0
  22. package/nitrogen/generated/ios/ReactNativeHealthkitAutolinking.mm +8 -0
  23. package/nitrogen/generated/ios/ReactNativeHealthkitAutolinking.swift +15 -0
  24. package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.cpp +11 -0
  25. package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.hpp +152 -0
  26. package/nitrogen/generated/ios/swift/ECGQueryOptionsWithAnchor.swift +179 -0
  27. package/nitrogen/generated/ios/swift/ECGQueryOptionsWithSortOrder.swift +184 -0
  28. package/nitrogen/generated/ios/swift/ElectrocardiogramClassification.swift +60 -0
  29. package/nitrogen/generated/ios/swift/ElectrocardiogramLead.swift +40 -0
  30. package/nitrogen/generated/ios/swift/ElectrocardiogramSample.swift +298 -0
  31. package/nitrogen/generated/ios/swift/ElectrocardiogramSamplesWithAnchorResponse.swift +81 -0
  32. package/nitrogen/generated/ios/swift/ElectrocardiogramSymptomsStatus.swift +44 -0
  33. package/nitrogen/generated/ios/swift/ElectrocardiogramVoltage.swift +57 -0
  34. package/nitrogen/generated/ios/swift/Func_void_ElectrocardiogramSamplesWithAnchorResponse.swift +47 -0
  35. package/nitrogen/generated/ios/swift/Func_void_std__vector_ElectrocardiogramSample_.swift +47 -0
  36. package/nitrogen/generated/ios/swift/HybridElectrocardiogramModuleSpec.swift +50 -0
  37. package/nitrogen/generated/ios/swift/HybridElectrocardiogramModuleSpec_cxx.swift +162 -0
  38. package/nitrogen/generated/shared/c++/ECGQueryOptionsWithAnchor.hpp +101 -0
  39. package/nitrogen/generated/shared/c++/ECGQueryOptionsWithSortOrder.hpp +100 -0
  40. package/nitrogen/generated/shared/c++/ElectrocardiogramClassification.hpp +96 -0
  41. package/nitrogen/generated/shared/c++/ElectrocardiogramLead.hpp +76 -0
  42. package/nitrogen/generated/shared/c++/ElectrocardiogramSample.hpp +135 -0
  43. package/nitrogen/generated/shared/c++/ElectrocardiogramSamplesWithAnchorResponse.hpp +81 -0
  44. package/nitrogen/generated/shared/c++/ElectrocardiogramSymptomsStatus.hpp +80 -0
  45. package/nitrogen/generated/shared/c++/ElectrocardiogramVoltage.hpp +76 -0
  46. package/nitrogen/generated/shared/c++/HybridElectrocardiogramModuleSpec.cpp +22 -0
  47. package/nitrogen/generated/shared/c++/HybridElectrocardiogramModuleSpec.hpp +76 -0
  48. package/package.json +1 -1
  49. package/src/healthkit.ios.ts +9 -0
  50. package/src/healthkit.ts +16 -0
  51. package/src/modules.ts +6 -0
  52. package/src/specs/ElectrocardiogramModule.nitro.ts +18 -0
  53. package/src/types/ElectrocardiogramSample.ts +60 -0
@@ -0,0 +1,135 @@
1
+ ///
2
+ /// ElectrocardiogramSample.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 `Device` to properly resolve imports.
22
+ namespace margelo::nitro::healthkit { struct Device; }
23
+ // Forward declaration of `ElectrocardiogramClassification` to properly resolve imports.
24
+ namespace margelo::nitro::healthkit { enum class ElectrocardiogramClassification; }
25
+ // Forward declaration of `ElectrocardiogramSymptomsStatus` to properly resolve imports.
26
+ namespace margelo::nitro::healthkit { enum class ElectrocardiogramSymptomsStatus; }
27
+ // Forward declaration of `ElectrocardiogramVoltage` to properly resolve imports.
28
+ namespace margelo::nitro::healthkit { struct ElectrocardiogramVoltage; }
29
+ // Forward declaration of `AnyMap` to properly resolve imports.
30
+ namespace NitroModules { class AnyMap; }
31
+ // Forward declaration of `SourceRevision` to properly resolve imports.
32
+ namespace margelo::nitro::healthkit { struct SourceRevision; }
33
+
34
+ #include <string>
35
+ #include "Device.hpp"
36
+ #include <optional>
37
+ #include <chrono>
38
+ #include "ElectrocardiogramClassification.hpp"
39
+ #include "ElectrocardiogramSymptomsStatus.hpp"
40
+ #include "ElectrocardiogramVoltage.hpp"
41
+ #include <vector>
42
+ #include <NitroModules/AnyMap.hpp>
43
+ #include "SourceRevision.hpp"
44
+
45
+ namespace margelo::nitro::healthkit {
46
+
47
+ /**
48
+ * A struct which can be represented as a JavaScript object (ElectrocardiogramSample).
49
+ */
50
+ struct ElectrocardiogramSample {
51
+ public:
52
+ std::string uuid SWIFT_PRIVATE;
53
+ std::optional<Device> device SWIFT_PRIVATE;
54
+ std::chrono::system_clock::time_point startDate SWIFT_PRIVATE;
55
+ std::chrono::system_clock::time_point endDate SWIFT_PRIVATE;
56
+ ElectrocardiogramClassification classification SWIFT_PRIVATE;
57
+ ElectrocardiogramSymptomsStatus symptomsStatus SWIFT_PRIVATE;
58
+ std::optional<double> averageHeartRateBpm SWIFT_PRIVATE;
59
+ std::optional<double> samplingFrequencyHz SWIFT_PRIVATE;
60
+ double numberOfVoltageMeasurements SWIFT_PRIVATE;
61
+ std::optional<std::string> algorithmVersion SWIFT_PRIVATE;
62
+ std::optional<std::vector<ElectrocardiogramVoltage>> voltages SWIFT_PRIVATE;
63
+ std::optional<std::shared_ptr<AnyMap>> metadata SWIFT_PRIVATE;
64
+ std::optional<SourceRevision> sourceRevision SWIFT_PRIVATE;
65
+
66
+ public:
67
+ ElectrocardiogramSample() = default;
68
+ explicit ElectrocardiogramSample(std::string uuid, std::optional<Device> device, std::chrono::system_clock::time_point startDate, std::chrono::system_clock::time_point endDate, ElectrocardiogramClassification classification, ElectrocardiogramSymptomsStatus symptomsStatus, std::optional<double> averageHeartRateBpm, std::optional<double> samplingFrequencyHz, double numberOfVoltageMeasurements, std::optional<std::string> algorithmVersion, std::optional<std::vector<ElectrocardiogramVoltage>> voltages, std::optional<std::shared_ptr<AnyMap>> metadata, std::optional<SourceRevision> sourceRevision): uuid(uuid), device(device), startDate(startDate), endDate(endDate), classification(classification), symptomsStatus(symptomsStatus), averageHeartRateBpm(averageHeartRateBpm), samplingFrequencyHz(samplingFrequencyHz), numberOfVoltageMeasurements(numberOfVoltageMeasurements), algorithmVersion(algorithmVersion), voltages(voltages), metadata(metadata), sourceRevision(sourceRevision) {}
69
+ };
70
+
71
+ } // namespace margelo::nitro::healthkit
72
+
73
+ namespace margelo::nitro {
74
+
75
+ // C++ ElectrocardiogramSample <> JS ElectrocardiogramSample (object)
76
+ template <>
77
+ struct JSIConverter<margelo::nitro::healthkit::ElectrocardiogramSample> final {
78
+ static inline margelo::nitro::healthkit::ElectrocardiogramSample fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
79
+ jsi::Object obj = arg.asObject(runtime);
80
+ return margelo::nitro::healthkit::ElectrocardiogramSample(
81
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "uuid")),
82
+ JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::fromJSI(runtime, obj.getProperty(runtime, "device")),
83
+ JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "startDate")),
84
+ JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "endDate")),
85
+ JSIConverter<margelo::nitro::healthkit::ElectrocardiogramClassification>::fromJSI(runtime, obj.getProperty(runtime, "classification")),
86
+ JSIConverter<margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus>::fromJSI(runtime, obj.getProperty(runtime, "symptomsStatus")),
87
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "averageHeartRateBpm")),
88
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "samplingFrequencyHz")),
89
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "numberOfVoltageMeasurements")),
90
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "algorithmVersion")),
91
+ JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::ElectrocardiogramVoltage>>>::fromJSI(runtime, obj.getProperty(runtime, "voltages")),
92
+ JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::fromJSI(runtime, obj.getProperty(runtime, "metadata")),
93
+ JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::fromJSI(runtime, obj.getProperty(runtime, "sourceRevision"))
94
+ );
95
+ }
96
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::ElectrocardiogramSample& arg) {
97
+ jsi::Object obj(runtime);
98
+ obj.setProperty(runtime, "uuid", JSIConverter<std::string>::toJSI(runtime, arg.uuid));
99
+ obj.setProperty(runtime, "device", JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::toJSI(runtime, arg.device));
100
+ obj.setProperty(runtime, "startDate", JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.startDate));
101
+ obj.setProperty(runtime, "endDate", JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.endDate));
102
+ obj.setProperty(runtime, "classification", JSIConverter<margelo::nitro::healthkit::ElectrocardiogramClassification>::toJSI(runtime, arg.classification));
103
+ obj.setProperty(runtime, "symptomsStatus", JSIConverter<margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus>::toJSI(runtime, arg.symptomsStatus));
104
+ obj.setProperty(runtime, "averageHeartRateBpm", JSIConverter<std::optional<double>>::toJSI(runtime, arg.averageHeartRateBpm));
105
+ obj.setProperty(runtime, "samplingFrequencyHz", JSIConverter<std::optional<double>>::toJSI(runtime, arg.samplingFrequencyHz));
106
+ obj.setProperty(runtime, "numberOfVoltageMeasurements", JSIConverter<double>::toJSI(runtime, arg.numberOfVoltageMeasurements));
107
+ obj.setProperty(runtime, "algorithmVersion", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.algorithmVersion));
108
+ obj.setProperty(runtime, "voltages", JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::ElectrocardiogramVoltage>>>::toJSI(runtime, arg.voltages));
109
+ obj.setProperty(runtime, "metadata", JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::toJSI(runtime, arg.metadata));
110
+ obj.setProperty(runtime, "sourceRevision", JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::toJSI(runtime, arg.sourceRevision));
111
+ return obj;
112
+ }
113
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
114
+ if (!value.isObject()) {
115
+ return false;
116
+ }
117
+ jsi::Object obj = value.getObject(runtime);
118
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "uuid"))) return false;
119
+ if (!JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::canConvert(runtime, obj.getProperty(runtime, "device"))) return false;
120
+ if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, "startDate"))) return false;
121
+ if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, "endDate"))) return false;
122
+ if (!JSIConverter<margelo::nitro::healthkit::ElectrocardiogramClassification>::canConvert(runtime, obj.getProperty(runtime, "classification"))) return false;
123
+ if (!JSIConverter<margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus>::canConvert(runtime, obj.getProperty(runtime, "symptomsStatus"))) return false;
124
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "averageHeartRateBpm"))) return false;
125
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "samplingFrequencyHz"))) return false;
126
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "numberOfVoltageMeasurements"))) return false;
127
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "algorithmVersion"))) return false;
128
+ if (!JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::ElectrocardiogramVoltage>>>::canConvert(runtime, obj.getProperty(runtime, "voltages"))) return false;
129
+ if (!JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::canConvert(runtime, obj.getProperty(runtime, "metadata"))) return false;
130
+ if (!JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::canConvert(runtime, obj.getProperty(runtime, "sourceRevision"))) return false;
131
+ return true;
132
+ }
133
+ };
134
+
135
+ } // namespace margelo::nitro
@@ -0,0 +1,81 @@
1
+ ///
2
+ /// ElectrocardiogramSamplesWithAnchorResponse.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 `ElectrocardiogramSample` to properly resolve imports.
22
+ namespace margelo::nitro::healthkit { struct ElectrocardiogramSample; }
23
+ // Forward declaration of `DeletedSample` to properly resolve imports.
24
+ namespace margelo::nitro::healthkit { struct DeletedSample; }
25
+
26
+ #include "ElectrocardiogramSample.hpp"
27
+ #include <vector>
28
+ #include "DeletedSample.hpp"
29
+ #include <string>
30
+
31
+ namespace margelo::nitro::healthkit {
32
+
33
+ /**
34
+ * A struct which can be represented as a JavaScript object (ElectrocardiogramSamplesWithAnchorResponse).
35
+ */
36
+ struct ElectrocardiogramSamplesWithAnchorResponse {
37
+ public:
38
+ std::vector<ElectrocardiogramSample> samples SWIFT_PRIVATE;
39
+ std::vector<DeletedSample> deletedSamples SWIFT_PRIVATE;
40
+ std::string newAnchor SWIFT_PRIVATE;
41
+
42
+ public:
43
+ ElectrocardiogramSamplesWithAnchorResponse() = default;
44
+ explicit ElectrocardiogramSamplesWithAnchorResponse(std::vector<ElectrocardiogramSample> samples, std::vector<DeletedSample> deletedSamples, std::string newAnchor): samples(samples), deletedSamples(deletedSamples), newAnchor(newAnchor) {}
45
+ };
46
+
47
+ } // namespace margelo::nitro::healthkit
48
+
49
+ namespace margelo::nitro {
50
+
51
+ // C++ ElectrocardiogramSamplesWithAnchorResponse <> JS ElectrocardiogramSamplesWithAnchorResponse (object)
52
+ template <>
53
+ struct JSIConverter<margelo::nitro::healthkit::ElectrocardiogramSamplesWithAnchorResponse> final {
54
+ static inline margelo::nitro::healthkit::ElectrocardiogramSamplesWithAnchorResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
55
+ jsi::Object obj = arg.asObject(runtime);
56
+ return margelo::nitro::healthkit::ElectrocardiogramSamplesWithAnchorResponse(
57
+ JSIConverter<std::vector<margelo::nitro::healthkit::ElectrocardiogramSample>>::fromJSI(runtime, obj.getProperty(runtime, "samples")),
58
+ JSIConverter<std::vector<margelo::nitro::healthkit::DeletedSample>>::fromJSI(runtime, obj.getProperty(runtime, "deletedSamples")),
59
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "newAnchor"))
60
+ );
61
+ }
62
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::ElectrocardiogramSamplesWithAnchorResponse& arg) {
63
+ jsi::Object obj(runtime);
64
+ obj.setProperty(runtime, "samples", JSIConverter<std::vector<margelo::nitro::healthkit::ElectrocardiogramSample>>::toJSI(runtime, arg.samples));
65
+ obj.setProperty(runtime, "deletedSamples", JSIConverter<std::vector<margelo::nitro::healthkit::DeletedSample>>::toJSI(runtime, arg.deletedSamples));
66
+ obj.setProperty(runtime, "newAnchor", JSIConverter<std::string>::toJSI(runtime, arg.newAnchor));
67
+ return obj;
68
+ }
69
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
70
+ if (!value.isObject()) {
71
+ return false;
72
+ }
73
+ jsi::Object obj = value.getObject(runtime);
74
+ if (!JSIConverter<std::vector<margelo::nitro::healthkit::ElectrocardiogramSample>>::canConvert(runtime, obj.getProperty(runtime, "samples"))) return false;
75
+ if (!JSIConverter<std::vector<margelo::nitro::healthkit::DeletedSample>>::canConvert(runtime, obj.getProperty(runtime, "deletedSamples"))) return false;
76
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "newAnchor"))) return false;
77
+ return true;
78
+ }
79
+ };
80
+
81
+ } // namespace margelo::nitro
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// ElectrocardiogramSymptomsStatus.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/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::healthkit {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (ElectrocardiogramSymptomsStatus).
30
+ */
31
+ enum class ElectrocardiogramSymptomsStatus {
32
+ NOTSET SWIFT_NAME(notset) = 0,
33
+ NONE SWIFT_NAME(none) = 1,
34
+ PRESENT SWIFT_NAME(present) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::healthkit
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ ElectrocardiogramSymptomsStatus <> JS ElectrocardiogramSymptomsStatus (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus> final {
44
+ static inline margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("notSet"): return margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus::NOTSET;
48
+ case hashString("none"): return margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus::NONE;
49
+ case hashString("present"): return margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus::PRESENT;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ElectrocardiogramSymptomsStatus - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus::NOTSET: return JSIConverter<std::string>::toJSI(runtime, "notSet");
57
+ case margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
58
+ case margelo::nitro::healthkit::ElectrocardiogramSymptomsStatus::PRESENT: return JSIConverter<std::string>::toJSI(runtime, "present");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert ElectrocardiogramSymptomsStatus to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("notSet"):
71
+ case hashString("none"):
72
+ case hashString("present"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// ElectrocardiogramVoltage.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 `ElectrocardiogramLead` to properly resolve imports.
22
+ namespace margelo::nitro::healthkit { enum class ElectrocardiogramLead; }
23
+
24
+ #include "ElectrocardiogramLead.hpp"
25
+
26
+ namespace margelo::nitro::healthkit {
27
+
28
+ /**
29
+ * A struct which can be represented as a JavaScript object (ElectrocardiogramVoltage).
30
+ */
31
+ struct ElectrocardiogramVoltage {
32
+ public:
33
+ double timeSinceSampleStart SWIFT_PRIVATE;
34
+ double voltage SWIFT_PRIVATE;
35
+ ElectrocardiogramLead lead SWIFT_PRIVATE;
36
+
37
+ public:
38
+ ElectrocardiogramVoltage() = default;
39
+ explicit ElectrocardiogramVoltage(double timeSinceSampleStart, double voltage, ElectrocardiogramLead lead): timeSinceSampleStart(timeSinceSampleStart), voltage(voltage), lead(lead) {}
40
+ };
41
+
42
+ } // namespace margelo::nitro::healthkit
43
+
44
+ namespace margelo::nitro {
45
+
46
+ // C++ ElectrocardiogramVoltage <> JS ElectrocardiogramVoltage (object)
47
+ template <>
48
+ struct JSIConverter<margelo::nitro::healthkit::ElectrocardiogramVoltage> final {
49
+ static inline margelo::nitro::healthkit::ElectrocardiogramVoltage fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
50
+ jsi::Object obj = arg.asObject(runtime);
51
+ return margelo::nitro::healthkit::ElectrocardiogramVoltage(
52
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "timeSinceSampleStart")),
53
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "voltage")),
54
+ JSIConverter<margelo::nitro::healthkit::ElectrocardiogramLead>::fromJSI(runtime, obj.getProperty(runtime, "lead"))
55
+ );
56
+ }
57
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::ElectrocardiogramVoltage& arg) {
58
+ jsi::Object obj(runtime);
59
+ obj.setProperty(runtime, "timeSinceSampleStart", JSIConverter<double>::toJSI(runtime, arg.timeSinceSampleStart));
60
+ obj.setProperty(runtime, "voltage", JSIConverter<double>::toJSI(runtime, arg.voltage));
61
+ obj.setProperty(runtime, "lead", JSIConverter<margelo::nitro::healthkit::ElectrocardiogramLead>::toJSI(runtime, arg.lead));
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<double>::canConvert(runtime, obj.getProperty(runtime, "timeSinceSampleStart"))) return false;
70
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "voltage"))) return false;
71
+ if (!JSIConverter<margelo::nitro::healthkit::ElectrocardiogramLead>::canConvert(runtime, obj.getProperty(runtime, "lead"))) return false;
72
+ return true;
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// HybridElectrocardiogramModuleSpec.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 "HybridElectrocardiogramModuleSpec.hpp"
9
+
10
+ namespace margelo::nitro::healthkit {
11
+
12
+ void HybridElectrocardiogramModuleSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("queryElectrocardiogramSamples", &HybridElectrocardiogramModuleSpec::queryElectrocardiogramSamples);
18
+ prototype.registerHybridMethod("queryElectrocardiogramSamplesWithAnchor", &HybridElectrocardiogramModuleSpec::queryElectrocardiogramSamplesWithAnchor);
19
+ });
20
+ }
21
+
22
+ } // namespace margelo::nitro::healthkit
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// HybridElectrocardiogramModuleSpec.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 `ElectrocardiogramSample` to properly resolve imports.
17
+ namespace margelo::nitro::healthkit { struct ElectrocardiogramSample; }
18
+ // Forward declaration of `ECGQueryOptionsWithSortOrder` to properly resolve imports.
19
+ namespace margelo::nitro::healthkit { struct ECGQueryOptionsWithSortOrder; }
20
+ // Forward declaration of `ElectrocardiogramSamplesWithAnchorResponse` to properly resolve imports.
21
+ namespace margelo::nitro::healthkit { struct ElectrocardiogramSamplesWithAnchorResponse; }
22
+ // Forward declaration of `ECGQueryOptionsWithAnchor` to properly resolve imports.
23
+ namespace margelo::nitro::healthkit { struct ECGQueryOptionsWithAnchor; }
24
+
25
+ #include "ElectrocardiogramSample.hpp"
26
+ #include <vector>
27
+ #include <NitroModules/Promise.hpp>
28
+ #include "ECGQueryOptionsWithSortOrder.hpp"
29
+ #include <optional>
30
+ #include "ElectrocardiogramSamplesWithAnchorResponse.hpp"
31
+ #include "ECGQueryOptionsWithAnchor.hpp"
32
+
33
+ namespace margelo::nitro::healthkit {
34
+
35
+ using namespace margelo::nitro;
36
+
37
+ /**
38
+ * An abstract base class for `ElectrocardiogramModule`
39
+ * Inherit this class to create instances of `HybridElectrocardiogramModuleSpec` in C++.
40
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
41
+ * @example
42
+ * ```cpp
43
+ * class HybridElectrocardiogramModule: public HybridElectrocardiogramModuleSpec {
44
+ * public:
45
+ * HybridElectrocardiogramModule(...): HybridObject(TAG) { ... }
46
+ * // ...
47
+ * };
48
+ * ```
49
+ */
50
+ class HybridElectrocardiogramModuleSpec: public virtual HybridObject {
51
+ public:
52
+ // Constructor
53
+ explicit HybridElectrocardiogramModuleSpec(): HybridObject(TAG) { }
54
+
55
+ // Destructor
56
+ ~HybridElectrocardiogramModuleSpec() override = default;
57
+
58
+ public:
59
+ // Properties
60
+
61
+
62
+ public:
63
+ // Methods
64
+ virtual std::shared_ptr<Promise<std::vector<ElectrocardiogramSample>>> queryElectrocardiogramSamples(const std::optional<ECGQueryOptionsWithSortOrder>& options) = 0;
65
+ virtual std::shared_ptr<Promise<ElectrocardiogramSamplesWithAnchorResponse>> queryElectrocardiogramSamplesWithAnchor(const ECGQueryOptionsWithAnchor& options) = 0;
66
+
67
+ protected:
68
+ // Hybrid Setup
69
+ void loadHybridMethods() override;
70
+
71
+ protected:
72
+ // Tag for logging
73
+ static constexpr auto TAG = "ElectrocardiogramModule";
74
+ };
75
+
76
+ } // namespace margelo::nitro::healthkit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -12,6 +12,7 @@ import {
12
12
  Characteristics,
13
13
  Core,
14
14
  CorrelationTypes,
15
+ Electrocardiograms,
15
16
  HeartbeatSeries,
16
17
  QuantityTypes,
17
18
  StateOfMind,
@@ -110,6 +111,12 @@ export const queryHeartbeatSeriesSamples =
110
111
  HeartbeatSeries.queryHeartbeatSeriesSamples.bind(HeartbeatSeries)
111
112
  export const queryHeartbeatSeriesSamplesWithAnchor =
112
113
  HeartbeatSeries.queryHeartbeatSeriesSamplesWithAnchor.bind(HeartbeatSeries)
114
+ export const queryElectrocardiogramSamples =
115
+ Electrocardiograms.queryElectrocardiogramSamples.bind(Electrocardiograms)
116
+ export const queryElectrocardiogramSamplesWithAnchor =
117
+ Electrocardiograms.queryElectrocardiogramSamplesWithAnchor.bind(
118
+ Electrocardiograms,
119
+ )
113
120
  export const queryQuantitySamples =
114
121
  QuantityTypes.queryQuantitySamples.bind(QuantityTypes)
115
122
  export const queryQuantitySamplesWithAnchor =
@@ -194,6 +201,8 @@ export default {
194
201
  queryCorrelationSamples,
195
202
  queryHeartbeatSeriesSamples,
196
203
  queryHeartbeatSeriesSamplesWithAnchor,
204
+ queryElectrocardiogramSamples,
205
+ queryElectrocardiogramSamplesWithAnchor,
197
206
  queryQuantitySamples,
198
207
  queryQuantitySamplesWithAnchor,
199
208
  queryStatisticsForQuantity,
package/src/healthkit.ts CHANGED
@@ -231,6 +231,20 @@ export const queryHeartbeatSeriesSamplesWithAnchor = UnavailableFnFromModule(
231
231
  }),
232
232
  )
233
233
 
234
+ export const queryElectrocardiogramSamples = UnavailableFnFromModule(
235
+ 'queryElectrocardiogramSamples',
236
+ Promise.resolve([]),
237
+ )
238
+
239
+ export const queryElectrocardiogramSamplesWithAnchor = UnavailableFnFromModule(
240
+ 'queryElectrocardiogramSamplesWithAnchor',
241
+ Promise.resolve({
242
+ samples: [],
243
+ deletedSamples: [],
244
+ newAnchor: '',
245
+ }),
246
+ )
247
+
234
248
  // WorkoutsModule functions
235
249
  export const queryWorkoutSamples = UnavailableFnFromModule(
236
250
  'queryWorkoutSamples',
@@ -388,6 +402,8 @@ const HealthkitModule = {
388
402
  queryCorrelationSamples,
389
403
  queryHeartbeatSeriesSamples,
390
404
  queryHeartbeatSeriesSamplesWithAnchor,
405
+ queryElectrocardiogramSamples,
406
+ queryElectrocardiogramSamplesWithAnchor,
391
407
  queryQuantitySamples,
392
408
  queryQuantitySamplesWithAnchor,
393
409
  queryStatisticsForQuantity,
package/src/modules.ts CHANGED
@@ -6,6 +6,7 @@ import type {
6
6
  import type { CharacteristicTypeModule } from './specs/CharacteristicTypeModule.nitro'
7
7
  import type { CoreModule } from './specs/CoreModule.nitro'
8
8
  import type { CorrelationTypeModule } from './specs/CorrelationTypeModule.nitro'
9
+ import type { ElectrocardiogramModule } from './specs/ElectrocardiogramModule.nitro'
9
10
  import type { HeartbeatSeriesModule } from './specs/HeartbeatSeriesModule.nitro'
10
11
  import type { QuantityTypeModule } from './specs/QuantityTypeModule.nitro'
11
12
  import type { StateOfMindModule } from './specs/StateOfMindModule.nitro'
@@ -34,6 +35,11 @@ export const CorrelationTypes =
34
35
  'CorrelationTypeModule',
35
36
  )
36
37
 
38
+ export const Electrocardiograms =
39
+ NitroModules.createHybridObject<ElectrocardiogramModule>(
40
+ 'ElectrocardiogramModule',
41
+ )
42
+
37
43
  export const HeartbeatSeries =
38
44
  NitroModules.createHybridObject<HeartbeatSeriesModule>(
39
45
  'HeartbeatSeriesModule',
@@ -0,0 +1,18 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules'
2
+ import type {
3
+ ECGQueryOptionsWithAnchor,
4
+ ECGQueryOptionsWithSortOrder,
5
+ ElectrocardiogramSample,
6
+ ElectrocardiogramSamplesWithAnchorResponse,
7
+ } from '../types/ElectrocardiogramSample'
8
+
9
+ export interface ElectrocardiogramModule
10
+ extends HybridObject<{ ios: 'swift' }> {
11
+ queryElectrocardiogramSamples(
12
+ options?: ECGQueryOptionsWithSortOrder,
13
+ ): Promise<readonly ElectrocardiogramSample[]>
14
+
15
+ queryElectrocardiogramSamplesWithAnchor(
16
+ options: ECGQueryOptionsWithAnchor,
17
+ ): Promise<ElectrocardiogramSamplesWithAnchorResponse>
18
+ }
@@ -0,0 +1,60 @@
1
+ import type { AnyMap } from 'react-native-nitro-modules'
2
+ import type {
3
+ QueryOptionsWithAnchor,
4
+ QueryOptionsWithSortOrder,
5
+ } from '../types/QueryOptions'
6
+ import type { Device } from './Device'
7
+ import type { DeletedSample } from './Shared'
8
+ import type { SourceRevision } from './Source'
9
+
10
+ // Enums mirror HealthKit; keep the union literal names stable.
11
+ export type ElectrocardiogramClassification =
12
+ | 'notSet'
13
+ | 'sinusRhythm'
14
+ | 'atrialFibrillation'
15
+ | 'inconclusiveLowHeartRate'
16
+ | 'inconclusiveHighHeartRate'
17
+ | 'inconclusivePoorReading'
18
+ | 'inconclusiveOther'
19
+
20
+ export type ElectrocardiogramSymptomsStatus = 'notSet' | 'none' | 'present'
21
+ export type ElectrocardiogramLead = 'appleWatchSimilarToLeadI' | 'unknown'
22
+
23
+ export interface ElectrocardiogramVoltage {
24
+ readonly timeSinceSampleStart: number // seconds
25
+ readonly voltage: number // volts
26
+ readonly lead: ElectrocardiogramLead
27
+ }
28
+
29
+ export interface ElectrocardiogramSample {
30
+ readonly uuid: string
31
+ readonly device?: Device
32
+ readonly startDate: Date
33
+ readonly endDate: Date
34
+
35
+ readonly classification: ElectrocardiogramClassification
36
+ readonly symptomsStatus: ElectrocardiogramSymptomsStatus
37
+
38
+ readonly averageHeartRateBpm?: number // HKQuantity (count/min)
39
+ readonly samplingFrequencyHz?: number // HKQuantity (Hz)
40
+ readonly numberOfVoltageMeasurements: number
41
+ readonly algorithmVersion?: string
42
+ readonly voltages?: readonly ElectrocardiogramVoltage[]
43
+
44
+ readonly metadata?: AnyMap
45
+ readonly sourceRevision?: SourceRevision
46
+ }
47
+
48
+ export interface ElectrocardiogramSamplesWithAnchorResponse {
49
+ readonly samples: readonly ElectrocardiogramSample[]
50
+ readonly deletedSamples: readonly DeletedSample[]
51
+ readonly newAnchor: string
52
+ }
53
+
54
+ export interface ECGQueryOptionsWithSortOrder
55
+ extends QueryOptionsWithSortOrder {
56
+ readonly includeVoltages?: boolean // default false
57
+ }
58
+ export interface ECGQueryOptionsWithAnchor extends QueryOptionsWithAnchor {
59
+ readonly includeVoltages: boolean // require explicit choice
60
+ }