@kingstinct/react-native-healthkit 5.3.0 → 6.0.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/README.md +59 -18
- package/ios/ReactNativeHealthkit.m +7 -0
- package/ios/ReactNativeHealthkit.swift +155 -31
- package/lib/commonjs/hooks/useSources.js +28 -0
- package/lib/commonjs/hooks/useSources.js.map +1 -0
- package/lib/commonjs/index.ios.js +3 -0
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +11 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest.setup.js +1 -0
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -1
- package/lib/commonjs/utils/deserializeSample.js +2 -2
- package/lib/commonjs/utils/deserializeSample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +1 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/prepareOptions.js +4 -2
- package/lib/commonjs/utils/prepareOptions.js.map +1 -1
- package/lib/commonjs/utils/queryCategorySamples.js +6 -2
- package/lib/commonjs/utils/queryCategorySamples.js.map +1 -1
- package/lib/commonjs/utils/queryQuantitySamples.js +6 -2
- package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -1
- package/lib/commonjs/utils/querySources.js +19 -0
- package/lib/commonjs/utils/querySources.js.map +1 -0
- package/lib/commonjs/utils/serializeDate.js +1 -1
- package/lib/commonjs/utils/serializeDate.js.map +1 -1
- package/lib/commonjs/utils/serializeDate.test.js +1 -1
- package/lib/commonjs/utils/serializeDate.test.js.map +1 -1
- package/lib/module/hooks/useSources.js +17 -0
- package/lib/module/hooks/useSources.js.map +1 -0
- package/lib/module/index.ios.js +2 -0
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest.setup.js +1 -0
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +0 -14
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/deserializeCorrelation.js +2 -2
- package/lib/module/utils/deserializeCorrelation.js.map +1 -1
- package/lib/module/utils/deserializeSample.js +2 -2
- package/lib/module/utils/deserializeSample.js.map +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/module/utils/getMostRecentQuantitySample.js +1 -1
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/module/utils/prepareOptions.js +4 -2
- package/lib/module/utils/prepareOptions.js.map +1 -1
- package/lib/module/utils/queryCategorySamples.js +6 -2
- package/lib/module/utils/queryCategorySamples.js.map +1 -1
- package/lib/module/utils/queryQuantitySamples.js +7 -3
- package/lib/module/utils/queryQuantitySamples.js.map +1 -1
- package/lib/module/utils/querySources.js +9 -0
- package/lib/module/utils/querySources.js.map +1 -0
- package/lib/module/utils/serializeDate.js +1 -1
- package/lib/module/utils/serializeDate.js.map +1 -1
- package/lib/module/utils/serializeDate.test.js +1 -1
- package/lib/module/utils/serializeDate.test.js.map +1 -1
- package/lib/typescript/src/hooks/useSources.d.ts +3 -0
- package/lib/typescript/src/index.ios.d.ts +1 -0
- package/lib/typescript/src/native-types.d.ts +22 -2
- package/lib/typescript/src/types.d.ts +1 -0
- package/lib/typescript/src/utils/deserializeSample.d.ts +2 -2
- package/lib/typescript/src/utils/prepareOptions.d.ts +1 -0
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +7 -2
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -2
- package/lib/typescript/src/utils/querySources.d.ts +4 -0
- package/package.json +2 -1
- package/src/hooks/useSources.ts +28 -0
- package/src/index.ios.tsx +2 -0
- package/src/index.tsx +12 -3
- package/src/jest.setup.ts +1 -0
- package/src/native-types.ts +34 -5
- package/src/types.ts +1 -134
- package/src/utils/deserializeCorrelation.ts +2 -2
- package/src/utils/deserializeSample.ts +2 -2
- package/src/utils/getMostRecentCategorySample.ts +1 -1
- package/src/utils/getMostRecentQuantitySample.ts +1 -1
- package/src/utils/prepareOptions.ts +6 -3
- package/src/utils/queryCategorySamples.ts +15 -4
- package/src/utils/queryQuantitySamples.ts +16 -5
- package/src/utils/querySources.ts +21 -0
- package/src/utils/serializeDate.test.ts +1 -1
- package/src/utils/serializeDate.ts +3 -1
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/ReactNativeHealthkit.xcodeproj/xcuserdata/robertherber.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/README.md
CHANGED
|
@@ -21,15 +21,34 @@ This library is provided as-is without any warranty and is not affiliated with A
|
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
|
-
###
|
|
24
|
+
### Expo Managed Workflow (easiest - with config plugin)
|
|
25
|
+
Usage with Expo is possible - just keep in mind it will not work in Expo Go and [you'll need to roll your own Dev Client](https://docs.expo.dev/development/getting-started/).
|
|
26
|
+
|
|
25
27
|
1. `yarn add @kingstinct/react-native-healthkit` (or `npm install @kingstinct/react-native-healthkit`)
|
|
26
|
-
2.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
2. Update your app.json with the config plugin:
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"expo": {
|
|
32
|
+
"plugins": ["@kingstinct/react-native-healthkit"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
this will give you defaults that make the app build without any further configuration. If you want, you can override the defaults:
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"expo": {
|
|
40
|
+
"plugins": ["@kingstinct/react-native-healthkit", {
|
|
41
|
+
"NSHealthShareUsageDescription": "Your own custom usage description",
|
|
42
|
+
"NSHealthUpdateUsageDescription": false, // if you have no plans to update data, you can skip adding it to your info.plist
|
|
43
|
+
"background": false // if you have no plans to use it in background mode, skip adding it to the entitlements
|
|
44
|
+
}]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
3. Build a new Dev Client
|
|
49
|
+
4. During runtime check and request permissions with `requestAuthorization`. Failing to request authorization, or requesting a permission you haven't requested yet, will result in the app crashing.
|
|
31
50
|
|
|
32
|
-
### Expo Managed Workflow
|
|
51
|
+
### Expo Managed Workflow (manual)
|
|
33
52
|
Usage with Expo is possible - just keep in mind it will not work in Expo Go and [you'll need to roll your own Dev Client](https://docs.expo.dev/development/getting-started/).
|
|
34
53
|
|
|
35
54
|
1. `yarn add @kingstinct/react-native-healthkit` (or `npm install @kingstinct/react-native-healthkit`)
|
|
@@ -39,12 +58,12 @@ Usage with Expo is possible - just keep in mind it will not work in Expo Go and
|
|
|
39
58
|
"expo": {
|
|
40
59
|
"ios": {
|
|
41
60
|
"infoPlist": {
|
|
42
|
-
"NSHealthShareUsageDescription": "<< your usage description here >>",
|
|
43
|
-
"NSHealthUpdateUsageDescription": "<< your usage description here >>"
|
|
61
|
+
"NSHealthShareUsageDescription": "<< your usage description here >>", // (optional) if you want to read healthkit data
|
|
62
|
+
"NSHealthUpdateUsageDescription": "<< your usage description here >>" // (optional) if you want to write healthkit data
|
|
44
63
|
},
|
|
45
64
|
"entitlements": {
|
|
46
|
-
"com.apple.developer.healthkit": true,
|
|
47
|
-
"com.apple.developer.healthkit.background-delivery": true
|
|
65
|
+
"com.apple.developer.healthkit": true, // required to use healthkit
|
|
66
|
+
"com.apple.developer.healthkit.background-delivery": true // (optional) if you want to use background delivery
|
|
48
67
|
}
|
|
49
68
|
}
|
|
50
69
|
}
|
|
@@ -53,6 +72,14 @@ Usage with Expo is possible - just keep in mind it will not work in Expo Go and
|
|
|
53
72
|
3. Build a new Dev Client
|
|
54
73
|
4. During runtime check and request permissions with `requestAuthorization`. Failing to request authorization, or requesting a permission you haven't requested yet, will result in the app crashing.
|
|
55
74
|
|
|
75
|
+
### Native or Expo Bare Workflow
|
|
76
|
+
1. `yarn add @kingstinct/react-native-healthkit` (or `npm install @kingstinct/react-native-healthkit`)
|
|
77
|
+
2. `npx pod-install`
|
|
78
|
+
3. Set `NSHealthUpdateUsageDescription` and `NSHealthShareUsageDescription` in your `Info.plist`
|
|
79
|
+
4. Enable the HealthKit capability for the project in Xcode.
|
|
80
|
+
5. Since this package is using Swift you might also need to add a bridging header in your project if you haven't already, you can [find more about that in the official React Native docs](https://reactnative.dev/docs/native-modules-ios#exporting-swift)
|
|
81
|
+
6. During runtime check and request permissions with `requestAuthorization`. Failing to request authorization, or requesting a permission you haven't requested yet, will result in the app crashing.
|
|
82
|
+
|
|
56
83
|
## Usage
|
|
57
84
|
|
|
58
85
|
Some hook examples:
|
|
@@ -62,9 +89,12 @@ import { HKQuantityTypeIdentifier, useHealthkitAuthorization } from '@kingstinct
|
|
|
62
89
|
const [authorizationStatus, requestAuthorization] = useHealthkitAuthorization([HKQuantityTypeIdentifier.bloodGlucose])
|
|
63
90
|
|
|
64
91
|
// make sure that you've requested authorization before requesting data, otherwise your app will crash
|
|
65
|
-
import { useMostRecentQuantitySample, HKQuantityTypeIdentifier } from '@kingstinct/react-native-healthkit';
|
|
92
|
+
import { useMostRecentQuantitySample, HKQuantityTypeIdentifier, useMostRecentCategorySample } from '@kingstinct/react-native-healthkit';
|
|
66
93
|
|
|
67
94
|
const mostRecentBloodGlucoseSample = useMostRecentQuantitySample(HKQuantityTypeIdentifier.bloodGlucose)
|
|
95
|
+
const lastBodyFatSample = useMostRecentQuantitySample(HKQuantityTypeIdentifier.bodyFatPercentage)
|
|
96
|
+
const lastMindfulSession = useMostRecentCategorySample(HKCategoryTypeIdentifier.mindfulSession)
|
|
97
|
+
const lastWorkout = useMostRecentWorkout()
|
|
68
98
|
```
|
|
69
99
|
|
|
70
100
|
Some imperative examples:
|
|
@@ -104,14 +134,21 @@ Some imperative examples:
|
|
|
104
134
|
},
|
|
105
135
|
}
|
|
106
136
|
);
|
|
137
|
+
```
|
|
107
138
|
|
|
139
|
+
### HealthKit Anchors (breaking change in 6.0)
|
|
140
|
+
In 6.0 you can use HealthKit anchors to get changes and deleted items which is very useful for syncing. This is a breaking change - but a very easy one to handle that TypeScript should help you with. Most queries now return an object containing samples which is what was returned as only an array before. In addition you also get deletedSamples and a newAnchor you can use for more advanced use cases, example:
|
|
141
|
+
```TypeScript
|
|
142
|
+
const { newAnchor, samples, deletedSamples } = await queryQuantitySamples(HKQuantityTypeIdentifier.stepCount, {
|
|
143
|
+
limit: 2,
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const nextResult = await queryQuantitySamples(HKQuantityTypeIdentifier.stepCount, {
|
|
147
|
+
limit: 2,
|
|
148
|
+
anchor: newAnchor,
|
|
149
|
+
})
|
|
108
150
|
|
|
109
|
-
|
|
110
|
-
const lastBodyFatSample = HealthKit.useMostRecentQuantitySample(HKQuantityTypeIdentifier.bodyFatPercentage);
|
|
111
|
-
const lastMindfulSession = Healthkit.useMostRecentCategorySample(
|
|
112
|
-
HKCategoryTypeIdentifier.mindfulSession
|
|
113
|
-
);
|
|
114
|
-
const lastWorkout = Healthkit.useMostRecentWorkout();
|
|
151
|
+
// etc..
|
|
115
152
|
```
|
|
116
153
|
|
|
117
154
|
## A note on Apple Documentation
|
|
@@ -122,6 +159,10 @@ We're striving to do as straight a mapping as possible to the Native Libraries.
|
|
|
122
159
|
|
|
123
160
|
For accessing Clinical Records use old version (3.x) or use specific branch ""
|
|
124
161
|
|
|
162
|
+
## Android alternatives
|
|
163
|
+
|
|
164
|
+
For a similar library for Android, check out [react-native-health-connect](https://github.com/matinzd/react-native-health-connect/) that works with the new Health Connect. For Google Fit [react-native-google-fit](https://www.npmjs.com/package/react-native-google-fit) seems to be the most popular option, and and another possible option is to work directly with the Google Fit REST API which I've some experience with.
|
|
165
|
+
|
|
125
166
|
## Contributing
|
|
126
167
|
|
|
127
168
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
@@ -104,6 +104,7 @@ RCT_EXTERN_METHOD(queryCategorySamples:(NSString)typeIdentifier
|
|
|
104
104
|
to:(NSDate)to
|
|
105
105
|
limit:(NSInteger)limit
|
|
106
106
|
ascending:(BOOL)ascending
|
|
107
|
+
anchor:(NSString)anchor
|
|
107
108
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
108
109
|
reject:(RCTPromiseRejectBlock)reject
|
|
109
110
|
)
|
|
@@ -139,6 +140,12 @@ RCT_EXTERN_METHOD(queryQuantitySamples:(NSString)typeIdentifier
|
|
|
139
140
|
to:(NSDate)to
|
|
140
141
|
limit:(NSInteger)limit
|
|
141
142
|
ascending:(BOOL)ascending
|
|
143
|
+
anchor:(NSString)anchor
|
|
144
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
145
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
RCT_EXTERN_METHOD(querySources:(NSString)typeIdentifier
|
|
142
149
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
143
150
|
reject:(RCTPromiseRejectBlock)reject
|
|
144
151
|
)
|
|
@@ -253,6 +253,13 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
253
253
|
"sourceRevision": self.serializeSourceRevision(_sourceRevision: sample.sourceRevision) as Any,
|
|
254
254
|
]
|
|
255
255
|
}
|
|
256
|
+
|
|
257
|
+
func serializeDeletedSample(sample: HKDeletedObject) -> NSDictionary {
|
|
258
|
+
return [
|
|
259
|
+
"uuid": sample.uuid.uuidString,
|
|
260
|
+
"metadata": self.serializeMetadata(metadata: sample.metadata)
|
|
261
|
+
]
|
|
262
|
+
}
|
|
256
263
|
|
|
257
264
|
func serializeCategorySample(sample: HKCategorySample) -> NSDictionary {
|
|
258
265
|
let endDate = _dateFormatter.string(from: sample.endDate)
|
|
@@ -269,6 +276,14 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
269
276
|
"sourceRevision": self.serializeSourceRevision(_sourceRevision: sample.sourceRevision) as Any,
|
|
270
277
|
]
|
|
271
278
|
}
|
|
279
|
+
|
|
280
|
+
func serializeSource(source: HKSource) -> NSDictionary {
|
|
281
|
+
|
|
282
|
+
return [
|
|
283
|
+
"bundleIdentifier": source.bundleIdentifier,
|
|
284
|
+
"name": source.name
|
|
285
|
+
]
|
|
286
|
+
}
|
|
272
287
|
|
|
273
288
|
@objc(getBiologicalSex:withRejecter:)
|
|
274
289
|
func getBiologicalSex(resolve: @escaping RCTPromiseResolveBlock,reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
@@ -866,6 +881,7 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
866
881
|
guard let device = _device else {
|
|
867
882
|
return nil;
|
|
868
883
|
}
|
|
884
|
+
|
|
869
885
|
return [
|
|
870
886
|
"name": device.name,
|
|
871
887
|
"firmwareVersion": device.firmwareVersion,
|
|
@@ -874,6 +890,7 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
874
890
|
"manufacturer": device.manufacturer,
|
|
875
891
|
"model": device.model,
|
|
876
892
|
"softwareVersion": device.softwareVersion,
|
|
893
|
+
"udiDeviceIdentifier": device.udiDeviceIdentifier
|
|
877
894
|
]
|
|
878
895
|
}
|
|
879
896
|
|
|
@@ -966,9 +983,49 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
966
983
|
store.execute(q);
|
|
967
984
|
}
|
|
968
985
|
|
|
986
|
+
func serializeAnchor(anchor: HKQueryAnchor?) -> String? {
|
|
987
|
+
guard let anch = anchor else {
|
|
988
|
+
return nil
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
let data = NSKeyedArchiver.archivedData(withRootObject: anch)
|
|
992
|
+
let encoded = data.base64EncodedString();
|
|
993
|
+
|
|
994
|
+
return encoded;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
func base64StringToHKQueryAnchor(base64String: String) -> HKQueryAnchor? {
|
|
998
|
+
// Step 1: Decode the base64 string to a Data object
|
|
999
|
+
guard let data = Data(base64Encoded: base64String) else {
|
|
1000
|
+
print("Error: Invalid base64 string")
|
|
1001
|
+
return nil
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// Step 2: Use NSKeyedUnarchiver to unarchive the data and create an HKQueryAnchor object
|
|
1005
|
+
do {
|
|
1006
|
+
let unarchiver = try NSKeyedUnarchiver(forReadingFrom: data)
|
|
1007
|
+
unarchiver.requiresSecureCoding = true
|
|
1008
|
+
let anchor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data)
|
|
1009
|
+
|
|
1010
|
+
return anchor as? HKQueryAnchor
|
|
1011
|
+
} catch {
|
|
1012
|
+
print("Error: Unable to unarchive HKQueryAnchor object: \(error)")
|
|
1013
|
+
return nil
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
969
1016
|
|
|
970
|
-
|
|
971
|
-
|
|
1017
|
+
@objc(queryQuantitySamples:unitString:from:to:limit:ascending:anchor:resolve:reject:)
|
|
1018
|
+
func queryQuantitySamples(
|
|
1019
|
+
typeIdentifier: String,
|
|
1020
|
+
unitString: String,
|
|
1021
|
+
from: Date,
|
|
1022
|
+
to: Date,
|
|
1023
|
+
limit: Int,
|
|
1024
|
+
ascending: Bool,
|
|
1025
|
+
anchor: String,
|
|
1026
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1027
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1028
|
+
) -> Void {
|
|
972
1029
|
guard let store = _store else {
|
|
973
1030
|
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil);
|
|
974
1031
|
}
|
|
@@ -984,25 +1041,39 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
984
1041
|
let predicate = from != nil || to != nil ? HKQuery.predicateForSamples(withStart: from, end: to, options: [HKQueryOptions.strictEndDate, HKQueryOptions.strictStartDate]) : nil;
|
|
985
1042
|
|
|
986
1043
|
let limit = limit == 0 ? HKObjectQueryNoLimit : limit;
|
|
987
|
-
|
|
988
|
-
let
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1044
|
+
|
|
1045
|
+
let actualAnchor = anchor.isEmpty ? nil : base64StringToHKQueryAnchor(base64String: anchor)
|
|
1046
|
+
|
|
1047
|
+
let q = HKAnchoredObjectQuery(
|
|
1048
|
+
type: sampleType,
|
|
1049
|
+
predicate: predicate,
|
|
1050
|
+
anchor: actualAnchor,
|
|
1051
|
+
limit: limit
|
|
1052
|
+
) { (
|
|
1053
|
+
query: HKAnchoredObjectQuery,
|
|
1054
|
+
s: [HKSample]?,
|
|
1055
|
+
deletedSamples: [HKDeletedObject]?,
|
|
1056
|
+
newAnchor: HKQueryAnchor?,
|
|
1057
|
+
error: Error?
|
|
1058
|
+
) in
|
|
1059
|
+
guard let err = error else {
|
|
1060
|
+
guard let samples = s else {
|
|
1061
|
+
return resolve([]);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
return resolve([
|
|
1065
|
+
"samples": samples.map({ sample in
|
|
1066
|
+
let serialized = self.serializeQuantitySample(sample: sample as! HKQuantitySample, unit: HKUnit.init(from: unitString))
|
|
1067
|
+
|
|
1068
|
+
return serialized
|
|
1069
|
+
}) as Any,
|
|
1070
|
+
"deletedSamples": deletedSamples?.map({ sample in
|
|
1071
|
+
return self.serializeDeletedSample(sample: sample)
|
|
1072
|
+
}) as Any,
|
|
1073
|
+
"newAnchor": self.serializeAnchor(anchor: newAnchor) as Any
|
|
1074
|
+
]);
|
|
1075
|
+
}
|
|
1076
|
+
reject(GENERIC_ERROR, err.localizedDescription, err);
|
|
1006
1077
|
}
|
|
1007
1078
|
|
|
1008
1079
|
store.execute(q);
|
|
@@ -1019,8 +1090,8 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
1019
1090
|
return reject(TYPE_IDENTIFIER_ERROR, typeIdentifier, nil);
|
|
1020
1091
|
}
|
|
1021
1092
|
|
|
1022
|
-
let from = from.timeIntervalSince1970
|
|
1023
|
-
let to = to.timeIntervalSince1970
|
|
1093
|
+
let from = from.timeIntervalSince1970 >= 0 ? from : nil;
|
|
1094
|
+
let to = to.timeIntervalSince1970 >= 0 ? to : nil;
|
|
1024
1095
|
|
|
1025
1096
|
let predicate = from != nil || to != nil ? HKQuery.predicateForSamples(withStart: from, end: to, options: [HKQueryOptions.strictEndDate, HKQueryOptions.strictStartDate]) : nil;
|
|
1026
1097
|
|
|
@@ -1074,8 +1145,8 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
1074
1145
|
store.execute(q);
|
|
1075
1146
|
}
|
|
1076
1147
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1148
|
+
@objc(queryCategorySamples:from:to:limit:ascending:anchor:resolve:reject:)
|
|
1149
|
+
func queryCategorySamples(typeIdentifier: String, from: Date, to: Date, limit: Int, ascending: Bool, anchor: String, resolve: @escaping RCTPromiseResolveBlock,reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1079
1150
|
guard let store = _store else {
|
|
1080
1151
|
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil);
|
|
1081
1152
|
}
|
|
@@ -1091,17 +1162,69 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
1091
1162
|
let predicate = from != nil || to != nil ? HKQuery.predicateForSamples(withStart: from, end: to, options: [HKQueryOptions.strictEndDate, HKQueryOptions.strictStartDate]) : nil;
|
|
1092
1163
|
|
|
1093
1164
|
let limit = limit == 0 ? HKObjectQueryNoLimit : limit;
|
|
1165
|
+
|
|
1166
|
+
let q = HKAnchoredObjectQuery(
|
|
1167
|
+
type: sampleType,
|
|
1168
|
+
predicate: predicate,
|
|
1169
|
+
anchor: anchor != "" ? base64StringToHKQueryAnchor(base64String: anchor) : nil,
|
|
1170
|
+
limit: limit
|
|
1171
|
+
) { (
|
|
1172
|
+
query: HKAnchoredObjectQuery,
|
|
1173
|
+
s: [HKSample]?,
|
|
1174
|
+
deletedSamples: [HKDeletedObject]?,
|
|
1175
|
+
newAnchor: HKQueryAnchor?,
|
|
1176
|
+
error: Error?
|
|
1177
|
+
) in
|
|
1178
|
+
guard let err = error else {
|
|
1179
|
+
guard let samples = s else {
|
|
1180
|
+
return resolve([]);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
let arr: NSMutableArray = [];
|
|
1184
|
+
|
|
1185
|
+
for s in samples {
|
|
1186
|
+
if let sample = s as? HKCategorySample {
|
|
1187
|
+
let serialized = self.serializeCategorySample(sample: sample);
|
|
1094
1188
|
|
|
1095
|
-
|
|
1189
|
+
arr.add(serialized)
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
return resolve([
|
|
1194
|
+
"samples": arr,
|
|
1195
|
+
"deletedSamples": deletedSamples?.map({ sample in
|
|
1196
|
+
return self.serializeDeletedSample(sample: sample)
|
|
1197
|
+
}) as Any,
|
|
1198
|
+
"newAnchor": self.serializeAnchor(anchor: newAnchor) as Any
|
|
1199
|
+
]);
|
|
1200
|
+
}
|
|
1201
|
+
reject(GENERIC_ERROR, err.localizedDescription, err);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
store.execute(q);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
@objc(querySources:resolve:reject:)
|
|
1208
|
+
func querySources(typeIdentifier: String, resolve: @escaping RCTPromiseResolveBlock,reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1209
|
+
|
|
1210
|
+
guard let store = _store else {
|
|
1211
|
+
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
guard let type = objectTypeFromString(typeIdentifier: typeIdentifier) else {
|
|
1215
|
+
return reject(TYPE_IDENTIFIER_ERROR, typeIdentifier, nil);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
let query = HKSourceQuery(sampleType: type as! HKSampleType, samplePredicate: nil) { (query: HKSourceQuery, source: Set<HKSource>?, error: Error?) in
|
|
1096
1219
|
guard let err = error else {
|
|
1097
|
-
guard let
|
|
1220
|
+
guard let sources = source else {
|
|
1098
1221
|
return resolve([]);
|
|
1099
1222
|
}
|
|
1100
1223
|
let arr: NSMutableArray = [];
|
|
1101
1224
|
|
|
1102
|
-
for s in
|
|
1103
|
-
if let
|
|
1104
|
-
let serialized = self.
|
|
1225
|
+
for s in sources {
|
|
1226
|
+
if let source = s as? HKSource {
|
|
1227
|
+
let serialized = self.serializeSource(source: source);
|
|
1105
1228
|
|
|
1106
1229
|
arr.add(serialized)
|
|
1107
1230
|
}
|
|
@@ -1110,9 +1233,10 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
1110
1233
|
return resolve(arr);
|
|
1111
1234
|
}
|
|
1112
1235
|
reject(GENERIC_ERROR, err.localizedDescription, err);
|
|
1236
|
+
|
|
1113
1237
|
}
|
|
1114
1238
|
|
|
1115
|
-
store.execute(
|
|
1239
|
+
store.execute(query);
|
|
1116
1240
|
}
|
|
1117
1241
|
|
|
1118
1242
|
@objc(requestAuthorization:read:resolve:withRejecter:)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _querySources = _interopRequireDefault(require("../utils/querySources"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function useSources(identifier) {
|
|
15
|
+
const [result, setResult] = (0, _react.useState)(null);
|
|
16
|
+
const update = (0, _react.useCallback)(async () => {
|
|
17
|
+
const res = await (0, _querySources.default)(identifier);
|
|
18
|
+
setResult(res);
|
|
19
|
+
}, [identifier]);
|
|
20
|
+
(0, _react.useEffect)(() => {
|
|
21
|
+
void update();
|
|
22
|
+
}, [update]);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var _default = useSources;
|
|
27
|
+
exports.default = _default;
|
|
28
|
+
//# sourceMappingURL=useSources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSources","identifier","result","setResult","useState","update","useCallback","res","querySources","useEffect"],"sources":["useSources.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nimport querySources from '../utils/querySources'\n\nimport type {\n HKCategoryTypeIdentifier,\n HKQuantityTypeIdentifier,\n HKSource,\n} from '../native-types'\n\nfunction useSources<\n TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier\n>(identifier: TIdentifier) {\n const [result, setResult] = useState<readonly HKSource[] | null>(null)\n\n const update = useCallback(async () => {\n const res = await querySources(identifier)\n setResult(res)\n }, [identifier])\n\n useEffect(() => {\n void update()\n }, [update])\n\n return result\n}\n\nexport default useSources\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAQA,SAASA,UAAT,CAEEC,UAFF,EAE2B;EACzB,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAqC,IAArC,CAA5B;EAEA,MAAMC,MAAM,GAAG,IAAAC,kBAAA,EAAY,YAAY;IACrC,MAAMC,GAAG,GAAG,MAAM,IAAAC,qBAAA,EAAaP,UAAb,CAAlB;IACAE,SAAS,CAACI,GAAD,CAAT;EACD,CAHc,EAGZ,CAACN,UAAD,CAHY,CAAf;EAKA,IAAAQ,gBAAA,EAAU,MAAM;IACd,KAAKJ,MAAM,EAAX;EACD,CAFD,EAEG,CAACA,MAAD,CAFH;EAIA,OAAOH,MAAP;AACD;;eAEcF,U"}
|
|
@@ -44,6 +44,8 @@ var _queryCorrelationSamples = _interopRequireDefault(require("./utils/queryCorr
|
|
|
44
44
|
|
|
45
45
|
var _queryQuantitySamples = _interopRequireDefault(require("./utils/queryQuantitySamples"));
|
|
46
46
|
|
|
47
|
+
var _querySources = _interopRequireDefault(require("./utils/querySources"));
|
|
48
|
+
|
|
47
49
|
var _queryStatisticsForQuantity = _interopRequireDefault(require("./utils/queryStatisticsForQuantity"));
|
|
48
50
|
|
|
49
51
|
var _queryWorkouts = _interopRequireDefault(require("./utils/queryWorkouts"));
|
|
@@ -102,6 +104,7 @@ const Healthkit = {
|
|
|
102
104
|
queryQuantitySamples: _queryQuantitySamples.default,
|
|
103
105
|
queryStatisticsForQuantity: _queryStatisticsForQuantity.default,
|
|
104
106
|
queryWorkouts: _queryWorkouts.default,
|
|
107
|
+
querySources: _querySources.default,
|
|
105
108
|
requestAuthorization: _requestAuthorization.default,
|
|
106
109
|
// delete methods
|
|
107
110
|
deleteQuantitySample: _deleteQuantitySample.default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Healthkit","authorizationStatusFor","Native","bind","isHealthDataAvailable","canAccessProtectedData","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType","getWorkoutRoutes","getDateOfBirth","getMostRecentQuantitySample","getMostRecentCategorySample","getMostRecentWorkout","getPreferredUnit","getPreferredUnits","getRequestStatusForAuthorization","queryCategorySamples","queryCorrelationSamples","queryQuantitySamples","queryStatisticsForQuantity","queryWorkouts","requestAuthorization","deleteQuantitySample","deleteSamples","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges","useIsHealthDataAvailable","useHealthkitAuthorization"],"sources":["index.ios.tsx"],"sourcesContent":["import useHealthkitAuthorization from './hooks/useHealthkitAuthorization'\nimport useIsHealthDataAvailable from './hooks/useIsHealthDataAvailable'\nimport useMostRecentCategorySample from './hooks/useMostRecentCategorySample'\nimport useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample'\nimport useMostRecentWorkout from './hooks/useMostRecentWorkout'\nimport useSubscribeToChanges from './hooks/useSubscribeToChanges'\nimport Native from './native-types'\nimport deleteQuantitySample from './utils/deleteQuantitySample'\nimport deleteSamples from './utils/deleteSamples'\nimport getDateOfBirth from './utils/getDateOfBirth'\nimport getMostRecentCategorySample from './utils/getMostRecentCategorySample'\nimport getMostRecentQuantitySample from './utils/getMostRecentQuantitySample'\nimport getMostRecentWorkout from './utils/getMostRecentWorkout'\nimport getPreferredUnit from './utils/getPreferredUnit'\nimport getPreferredUnits from './utils/getPreferredUnits'\nimport getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'\nimport queryCategorySamples from './utils/queryCategorySamples'\nimport queryCorrelationSamples from './utils/queryCorrelationSamples'\nimport queryQuantitySamples from './utils/queryQuantitySamples'\nimport queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'\nimport queryWorkouts from './utils/queryWorkouts'\nimport requestAuthorization from './utils/requestAuthorization'\nimport saveCategorySample from './utils/saveCategorySample'\nimport saveCorrelationSample from './utils/saveCorrelationSample'\nimport saveQuantitySample from './utils/saveQuantitySample'\nimport saveWorkoutSample from './utils/saveWorkoutSample'\nimport subscribeToChanges from './utils/subscribeToChanges'\n\nconst Healthkit = {\n authorizationStatusFor: Native.authorizationStatusFor.bind(Native),\n\n isHealthDataAvailable: Native.isHealthDataAvailable.bind(Native),\n canAccessProtectedData: Native.canAccessProtectedData.bind(Native),\n\n disableAllBackgroundDelivery:\n Native.disableAllBackgroundDelivery.bind(Native),\n disableBackgroundDelivery: Native.disableBackgroundDelivery.bind(Native),\n enableBackgroundDelivery: Native.enableBackgroundDelivery.bind(Native),\n\n // simple convenience getters\n getBiologicalSex: Native.getBiologicalSex.bind(Native),\n getFitzpatrickSkinType: Native.getFitzpatrickSkinType.bind(Native),\n getWheelchairUse: Native.getWheelchairUse.bind(Native),\n getBloodType: Native.getBloodType.bind(Native),\n\n getWorkoutRoutes: Native.getWorkoutRoutes.bind(Native),\n\n getDateOfBirth,\n\n getMostRecentQuantitySample,\n getMostRecentCategorySample,\n getMostRecentWorkout,\n\n getPreferredUnit,\n getPreferredUnits,\n getRequestStatusForAuthorization,\n\n // query methods\n queryCategorySamples,\n queryCorrelationSamples,\n queryQuantitySamples,\n queryStatisticsForQuantity,\n queryWorkouts,\n\n requestAuthorization,\n\n // delete methods\n deleteQuantitySample,\n deleteSamples,\n\n // save methods\n saveCategorySample,\n saveCorrelationSample,\n saveQuantitySample,\n saveWorkoutSample,\n\n // subscriptions\n subscribeToChanges,\n\n // hooks\n useMostRecentCategorySample,\n\n useMostRecentQuantitySample,\n useMostRecentWorkout,\n\n useSubscribeToChanges,\n\n useIsHealthDataAvailable,\n useHealthkitAuthorization,\n}\n\nexport * from './types'\n\nexport default Healthkit\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"names":["Healthkit","authorizationStatusFor","Native","bind","isHealthDataAvailable","canAccessProtectedData","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType","getWorkoutRoutes","getDateOfBirth","getMostRecentQuantitySample","getMostRecentCategorySample","getMostRecentWorkout","getPreferredUnit","getPreferredUnits","getRequestStatusForAuthorization","queryCategorySamples","queryCorrelationSamples","queryQuantitySamples","queryStatisticsForQuantity","queryWorkouts","querySources","requestAuthorization","deleteQuantitySample","deleteSamples","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges","useIsHealthDataAvailable","useHealthkitAuthorization"],"sources":["index.ios.tsx"],"sourcesContent":["import useHealthkitAuthorization from './hooks/useHealthkitAuthorization'\nimport useIsHealthDataAvailable from './hooks/useIsHealthDataAvailable'\nimport useMostRecentCategorySample from './hooks/useMostRecentCategorySample'\nimport useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample'\nimport useMostRecentWorkout from './hooks/useMostRecentWorkout'\nimport useSubscribeToChanges from './hooks/useSubscribeToChanges'\nimport Native from './native-types'\nimport deleteQuantitySample from './utils/deleteQuantitySample'\nimport deleteSamples from './utils/deleteSamples'\nimport getDateOfBirth from './utils/getDateOfBirth'\nimport getMostRecentCategorySample from './utils/getMostRecentCategorySample'\nimport getMostRecentQuantitySample from './utils/getMostRecentQuantitySample'\nimport getMostRecentWorkout from './utils/getMostRecentWorkout'\nimport getPreferredUnit from './utils/getPreferredUnit'\nimport getPreferredUnits from './utils/getPreferredUnits'\nimport getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'\nimport queryCategorySamples from './utils/queryCategorySamples'\nimport queryCorrelationSamples from './utils/queryCorrelationSamples'\nimport queryQuantitySamples from './utils/queryQuantitySamples'\nimport querySources from './utils/querySources'\nimport queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'\nimport queryWorkouts from './utils/queryWorkouts'\nimport requestAuthorization from './utils/requestAuthorization'\nimport saveCategorySample from './utils/saveCategorySample'\nimport saveCorrelationSample from './utils/saveCorrelationSample'\nimport saveQuantitySample from './utils/saveQuantitySample'\nimport saveWorkoutSample from './utils/saveWorkoutSample'\nimport subscribeToChanges from './utils/subscribeToChanges'\n\nconst Healthkit = {\n authorizationStatusFor: Native.authorizationStatusFor.bind(Native),\n\n isHealthDataAvailable: Native.isHealthDataAvailable.bind(Native),\n canAccessProtectedData: Native.canAccessProtectedData.bind(Native),\n\n disableAllBackgroundDelivery:\n Native.disableAllBackgroundDelivery.bind(Native),\n disableBackgroundDelivery: Native.disableBackgroundDelivery.bind(Native),\n enableBackgroundDelivery: Native.enableBackgroundDelivery.bind(Native),\n\n // simple convenience getters\n getBiologicalSex: Native.getBiologicalSex.bind(Native),\n getFitzpatrickSkinType: Native.getFitzpatrickSkinType.bind(Native),\n getWheelchairUse: Native.getWheelchairUse.bind(Native),\n getBloodType: Native.getBloodType.bind(Native),\n\n getWorkoutRoutes: Native.getWorkoutRoutes.bind(Native),\n\n getDateOfBirth,\n\n getMostRecentQuantitySample,\n getMostRecentCategorySample,\n getMostRecentWorkout,\n\n getPreferredUnit,\n getPreferredUnits,\n getRequestStatusForAuthorization,\n\n // query methods\n queryCategorySamples,\n queryCorrelationSamples,\n queryQuantitySamples,\n queryStatisticsForQuantity,\n queryWorkouts,\n querySources,\n\n requestAuthorization,\n\n // delete methods\n deleteQuantitySample,\n deleteSamples,\n\n // save methods\n saveCategorySample,\n saveCorrelationSample,\n saveQuantitySample,\n saveWorkoutSample,\n\n // subscriptions\n subscribeToChanges,\n\n // hooks\n useMostRecentCategorySample,\n\n useMostRecentQuantitySample,\n useMostRecentWorkout,\n\n useSubscribeToChanges,\n\n useIsHealthDataAvailable,\n useHealthkitAuthorization,\n}\n\nexport * from './types'\n\nexport default Healthkit\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;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,0BA1BgB;EA2BhBC,gCAAgC,EAAhCA,yCA3BgB;EA6BhB;EACAC,oBAAoB,EAApBA,6BA9BgB;EA+BhBC,uBAAuB,EAAvBA,gCA/BgB;EAgChBC,oBAAoB,EAApBA,6BAhCgB;EAiChBC,0BAA0B,EAA1BA,mCAjCgB;EAkChBC,aAAa,EAAbA,sBAlCgB;EAmChBC,YAAY,EAAZA,qBAnCgB;EAqChBC,oBAAoB,EAApBA,6BArCgB;EAuChB;EACAC,oBAAoB,EAApBA,6BAxCgB;EAyChBC,aAAa,EAAbA,sBAzCgB;EA2ChB;EACAC,kBAAkB,EAAlBA,2BA5CgB;EA6ChBC,qBAAqB,EAArBA,8BA7CgB;EA8ChBC,kBAAkB,EAAlBA,2BA9CgB;EA+ChBC,iBAAiB,EAAjBA,0BA/CgB;EAiDhB;EACAC,kBAAkB,EAAlBA,2BAlDgB;EAoDhB;EACAC,2BAA2B,EAA3BA,oCArDgB;EAuDhBC,2BAA2B,EAA3BA,oCAvDgB;EAwDhBC,oBAAoB,EAApBA,6BAxDgB;EA0DhBC,qBAAqB,EAArBA,8BA1DgB;EA4DhBC,wBAAwB,EAAxBA,iCA5DgB;EA6DhBC,yBAAyB,EAAzBA;AA7DgB,CAAlB;eAkEexC,S"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -56,9 +56,17 @@ const Healthkit = {
|
|
|
56
56
|
getWheelchairUse: UnavailableFn(Promise.resolve(_nativeTypes.HKWheelchairUse.notSet)),
|
|
57
57
|
getWorkoutRoutes: UnavailableFn(Promise.resolve([])),
|
|
58
58
|
isHealthDataAvailable: async () => Promise.resolve(false),
|
|
59
|
-
queryCategorySamples: UnavailableFn(Promise.resolve(
|
|
59
|
+
queryCategorySamples: UnavailableFn(Promise.resolve({
|
|
60
|
+
samples: [],
|
|
61
|
+
deletedSamples: [],
|
|
62
|
+
newAnchor: ''
|
|
63
|
+
})),
|
|
60
64
|
queryCorrelationSamples: UnavailableFn(Promise.resolve([])),
|
|
61
|
-
queryQuantitySamples: UnavailableFn(Promise.resolve(
|
|
65
|
+
queryQuantitySamples: UnavailableFn(Promise.resolve({
|
|
66
|
+
samples: [],
|
|
67
|
+
deletedSamples: [],
|
|
68
|
+
newAnchor: ''
|
|
69
|
+
})),
|
|
62
70
|
queryStatisticsForQuantity: UnavailableFn(Promise.resolve({
|
|
63
71
|
averageQuantity: undefined,
|
|
64
72
|
maximumQuantity: undefined,
|
|
@@ -69,6 +77,7 @@ const Healthkit = {
|
|
|
69
77
|
duration: undefined
|
|
70
78
|
})),
|
|
71
79
|
queryWorkouts: UnavailableFn(Promise.resolve([])),
|
|
80
|
+
querySources: UnavailableFn(Promise.resolve([])),
|
|
72
81
|
requestAuthorization: UnavailableFn(Promise.resolve(false)),
|
|
73
82
|
deleteQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
74
83
|
deleteSamples: UnavailableFn(Promise.resolve(false)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["notAvailableError","Platform","OS","hasWarned","UnavailableFn","retVal","console","warn","Healthkit","authorizationStatusFor","Promise","resolve","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","HKBiologicalSex","notSet","getBloodType","HKBloodType","getDateOfBirth","Date","getFitzpatrickSkinType","HKFitzpatrickSkinType","getMostRecentCategorySample","getMostRecentQuantitySample","getMostRecentWorkout","getPreferredUnit","HKUnits","Count","getPreferredUnits","getRequestStatusForAuthorization","HKAuthorizationRequestStatus","unknown","getWheelchairUse","HKWheelchairUse","getWorkoutRoutes","isHealthDataAvailable","queryCategorySamples","queryCorrelationSamples","queryQuantitySamples","queryStatisticsForQuantity","averageQuantity","undefined","maximumQuantity","minimumQuantity","sumQuantity","mostRecentQuantity","mostRecentQuantityDateInterval","duration","queryWorkouts","requestAuthorization","deleteQuantitySample","deleteSamples","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges","useHealthkitAuthorization","useIsHealthDataAvailable","canAccessProtectedData"],"sources":["index.tsx"],"sourcesContent":["import { Platform } from 'react-native'\n\nimport {\n HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnits, HKWheelchairUse,\n} from './native-types'\n\nimport type ReactNativeHealthkit from './index.ios'\n\nconst notAvailableError = `[@kingstinct/react-native-healthkit] Platform \"${\n Platform.OS\n}\" not supported`\n\nlet hasWarned = false\n\nfunction UnavailableFn<T = unknown>(retVal: T) {\n return () => {\n if (!hasWarned) {\n // eslint-disable-next-line no-console\n console.warn(notAvailableError)\n hasWarned = true\n }\n return retVal\n }\n}\n\nconst Healthkit: typeof ReactNativeHealthkit = {\n authorizationStatusFor: UnavailableFn(Promise.resolve(false)),\n disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n getBiologicalSex: UnavailableFn(Promise.resolve(HKBiologicalSex.notSet)),\n getBloodType: UnavailableFn(Promise.resolve(HKBloodType.notSet)),\n getDateOfBirth: UnavailableFn(Promise.resolve(new Date(0))),\n getFitzpatrickSkinType: UnavailableFn(Promise.resolve(HKFitzpatrickSkinType.notSet)),\n getMostRecentCategorySample: UnavailableFn(Promise.resolve(null)),\n getMostRecentQuantitySample: UnavailableFn(Promise.resolve(null)),\n getMostRecentWorkout: UnavailableFn(Promise.resolve(null)),\n getPreferredUnit: UnavailableFn(Promise.resolve(HKUnits.Count)),\n getPreferredUnits: UnavailableFn(Promise.resolve([])),\n getRequestStatusForAuthorization: UnavailableFn(Promise.resolve(HKAuthorizationRequestStatus.unknown)),\n getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),\n getWorkoutRoutes: UnavailableFn(Promise.resolve([])),\n isHealthDataAvailable: async () => Promise.resolve(false),\n queryCategorySamples: UnavailableFn(Promise.resolve([])),\n queryCorrelationSamples: UnavailableFn(Promise.resolve([])),\n queryQuantitySamples: UnavailableFn(Promise.resolve([])),\n queryStatisticsForQuantity: UnavailableFn(Promise.resolve({\n averageQuantity: undefined,\n maximumQuantity: undefined,\n minimumQuantity: undefined,\n sumQuantity: undefined,\n mostRecentQuantity: undefined,\n mostRecentQuantityDateInterval: undefined,\n duration: undefined,\n })),\n queryWorkouts: UnavailableFn(Promise.resolve([])),\n requestAuthorization: UnavailableFn(Promise.resolve(false)),\n deleteQuantitySample: UnavailableFn(Promise.resolve(false)),\n deleteSamples: UnavailableFn(Promise.resolve(false)),\n saveCategorySample: UnavailableFn(Promise.resolve(false)),\n saveCorrelationSample: UnavailableFn(Promise.resolve(false)),\n saveQuantitySample: UnavailableFn(Promise.resolve(false)),\n saveWorkoutSample: UnavailableFn(Promise.resolve(false)),\n subscribeToChanges: UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),\n useMostRecentCategorySample: UnavailableFn(null),\n useMostRecentQuantitySample: UnavailableFn(null),\n useMostRecentWorkout: UnavailableFn(null),\n useSubscribeToChanges: UnavailableFn([null, () => null]),\n useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(HKAuthorizationRequestStatus.unknown)] as const),\n useIsHealthDataAvailable: () => false,\n canAccessProtectedData: async () => Promise.resolve(false),\n}\n\nexport * from './types'\n\nexport default Healthkit\n"],"mappings":";;;;;;;;AAAA;;AAEA;;
|
|
1
|
+
{"version":3,"names":["notAvailableError","Platform","OS","hasWarned","UnavailableFn","retVal","console","warn","Healthkit","authorizationStatusFor","Promise","resolve","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","HKBiologicalSex","notSet","getBloodType","HKBloodType","getDateOfBirth","Date","getFitzpatrickSkinType","HKFitzpatrickSkinType","getMostRecentCategorySample","getMostRecentQuantitySample","getMostRecentWorkout","getPreferredUnit","HKUnits","Count","getPreferredUnits","getRequestStatusForAuthorization","HKAuthorizationRequestStatus","unknown","getWheelchairUse","HKWheelchairUse","getWorkoutRoutes","isHealthDataAvailable","queryCategorySamples","samples","deletedSamples","newAnchor","queryCorrelationSamples","queryQuantitySamples","queryStatisticsForQuantity","averageQuantity","undefined","maximumQuantity","minimumQuantity","sumQuantity","mostRecentQuantity","mostRecentQuantityDateInterval","duration","queryWorkouts","querySources","requestAuthorization","deleteQuantitySample","deleteSamples","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges","useHealthkitAuthorization","useIsHealthDataAvailable","canAccessProtectedData"],"sources":["index.tsx"],"sourcesContent":["import { Platform } from 'react-native'\n\nimport {\n HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKQuantityTypeIdentifier, HKUnits, HKWheelchairUse, QueryQuantitySamplesResponseRaw,\n} from './native-types'\n\nimport type ReactNativeHealthkit from './index.ios'\n\nconst notAvailableError = `[@kingstinct/react-native-healthkit] Platform \"${\n Platform.OS\n}\" not supported`\n\nlet hasWarned = false\n\nfunction UnavailableFn<T = unknown>(retVal: T) {\n return () => {\n if (!hasWarned) {\n // eslint-disable-next-line no-console\n console.warn(notAvailableError)\n hasWarned = true\n }\n return retVal\n }\n}\n\nconst Healthkit: typeof ReactNativeHealthkit = {\n authorizationStatusFor: UnavailableFn(Promise.resolve(false)),\n disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n getBiologicalSex: UnavailableFn(Promise.resolve(HKBiologicalSex.notSet)),\n getBloodType: UnavailableFn(Promise.resolve(HKBloodType.notSet)),\n getDateOfBirth: UnavailableFn(Promise.resolve(new Date(0))),\n getFitzpatrickSkinType: UnavailableFn(Promise.resolve(HKFitzpatrickSkinType.notSet)),\n getMostRecentCategorySample: UnavailableFn(Promise.resolve(null)),\n getMostRecentQuantitySample: UnavailableFn(Promise.resolve(null)),\n getMostRecentWorkout: UnavailableFn(Promise.resolve(null)),\n getPreferredUnit: UnavailableFn(Promise.resolve(HKUnits.Count)),\n getPreferredUnits: UnavailableFn(Promise.resolve([])),\n getRequestStatusForAuthorization: UnavailableFn(Promise.resolve(HKAuthorizationRequestStatus.unknown)),\n getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),\n getWorkoutRoutes: UnavailableFn(Promise.resolve([])),\n isHealthDataAvailable: async () => Promise.resolve(false),\n queryCategorySamples: UnavailableFn(Promise.resolve({\n samples: [],\n deletedSamples: [],\n newAnchor: '',\n })),\n queryCorrelationSamples: UnavailableFn(Promise.resolve([])),\n queryQuantitySamples: UnavailableFn(Promise.resolve({\n samples: [],\n deletedSamples: [],\n newAnchor: '',\n })),\n queryStatisticsForQuantity: UnavailableFn(Promise.resolve({\n averageQuantity: undefined,\n maximumQuantity: undefined,\n minimumQuantity: undefined,\n sumQuantity: undefined,\n mostRecentQuantity: undefined,\n mostRecentQuantityDateInterval: undefined,\n duration: undefined,\n })),\n queryWorkouts: UnavailableFn(Promise.resolve([])),\n querySources: UnavailableFn(Promise.resolve([])),\n requestAuthorization: UnavailableFn(Promise.resolve(false)),\n deleteQuantitySample: UnavailableFn(Promise.resolve(false)),\n deleteSamples: UnavailableFn(Promise.resolve(false)),\n saveCategorySample: UnavailableFn(Promise.resolve(false)),\n saveCorrelationSample: UnavailableFn(Promise.resolve(false)),\n saveQuantitySample: UnavailableFn(Promise.resolve(false)),\n saveWorkoutSample: UnavailableFn(Promise.resolve(false)),\n subscribeToChanges: UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),\n useMostRecentCategorySample: UnavailableFn(null),\n useMostRecentQuantitySample: UnavailableFn(null),\n useMostRecentWorkout: UnavailableFn(null),\n useSubscribeToChanges: UnavailableFn([null, () => null]),\n useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(HKAuthorizationRequestStatus.unknown)] as const),\n useIsHealthDataAvailable: () => false,\n canAccessProtectedData: async () => Promise.resolve(false),\n}\n\nexport * from './types'\n\nexport default Healthkit\n"],"mappings":";;;;;;;;AAAA;;AAEA;;AAgFA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AA1EA,MAAMA,iBAAiB,GAAI,kDACzBC,qBAAA,CAASC,EACV,iBAFD;AAIA,IAAIC,SAAS,GAAG,KAAhB;;AAEA,SAASC,aAAT,CAAoCC,MAApC,EAA+C;EAC7C,OAAO,MAAM;IACX,IAAI,CAACF,SAAL,EAAgB;MACd;MACAG,OAAO,CAACC,IAAR,CAAaP,iBAAb;MACAG,SAAS,GAAG,IAAZ;IACD;;IACD,OAAOE,MAAP;EACD,CAPD;AAQD;;AAED,MAAMG,SAAsC,GAAG;EAC7CC,sBAAsB,EAAEL,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgB,KAAhB,CAAD,CADQ;EAE7CC,4BAA4B,EAAER,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgB,KAAhB,CAAD,CAFE;EAG7CE,yBAAyB,EAAET,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgB,KAAhB,CAAD,CAHK;EAI7CG,wBAAwB,EAAEV,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgB,KAAhB,CAAD,CAJM;EAK7CI,gBAAgB,EAAEX,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgBK,4BAAA,CAAgBC,MAAhC,CAAD,CALc;EAM7CC,YAAY,EAAEd,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgBQ,wBAAA,CAAYF,MAA5B,CAAD,CANkB;EAO7CG,cAAc,EAAEhB,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgB,IAAIU,IAAJ,CAAS,CAAT,CAAhB,CAAD,CAPgB;EAQ7CC,sBAAsB,EAAElB,aAAa,CAACM,OAAO,CAACC,OAAR,CAAgBY,kCAAA,CAAsBN,MAAtC,CAA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,aAAa,CAAC,IAAD,CAjDG;EAkD7C6D,oBAAoB,EAAE7D,aAAa,CAAC,IAAD,CAlDU;EAmD7C8D,qBAAqB,EAAE9D,aAAa,CAAC,CAAC,IAAD,EAAO,MAAM,IAAb,CAAD,CAnDS;EAoD7C+D,yBAAyB,EAAE/D,aAAa,CAAC,CAAC,IAAD,EAAO,YAAYM,OAAO,CAACC,OAAR,CAAgBqB,yCAAA,CAA6BC,OAA7C,CAAnB,CAAD,CApDK;EAqD7CmC,wBAAwB,EAAE,MAAM,KArDa;EAsD7CC,sBAAsB,EAAE,YAAY3D,OAAO,CAACC,OAAR,CAAgB,KAAhB;AAtDS,CAA/C;eA2DeH,S"}
|
|
@@ -25,6 +25,7 @@ const mockModule = {
|
|
|
25
25
|
queryCategorySamples: jest.fn(),
|
|
26
26
|
queryCorrelationSamples: jest.fn(),
|
|
27
27
|
queryQuantitySamples: jest.fn(),
|
|
28
|
+
querySources: jest.fn(),
|
|
28
29
|
queryStatisticsForQuantity: jest.fn(),
|
|
29
30
|
queryWorkoutSamples: jest.fn(),
|
|
30
31
|
saveCategorySample: jest.fn(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["mockModule","isHealthDataAvailable","jest","fn","addListener","removeListeners","authorizationStatusFor","requestAuthorization","saveQuantitySample","deleteQuantitySample","deleteSamples","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getBloodType","getDateOfBirth","getFitzpatrickSkinType","getPreferredUnits","getRequestStatusForAuthorization","getWheelchairUse","getWorkoutRoutes","queryCategorySamples","queryCorrelationSamples","queryQuantitySamples","queryStatisticsForQuantity","queryWorkoutSamples","saveCategorySample","saveCorrelationSample","saveWorkoutSample","subscribeToObserverQuery","unsubscribeQuery","canAccessProtectedData","NativeModules","ReactNativeHealthkit"],"sources":["jest.setup.ts"],"sourcesContent":["import { NativeModule, NativeModules } from 'react-native'\n\nimport type Native from './native-types'\n\nconst mockModule: (NativeModule & typeof Native) = {\n isHealthDataAvailable: jest.fn(),\n addListener: jest.fn(),\n removeListeners: jest.fn(),\n authorizationStatusFor: jest.fn(),\n requestAuthorization: jest.fn(),\n saveQuantitySample: jest.fn(),\n deleteQuantitySample: jest.fn(),\n deleteSamples: jest.fn(),\n disableAllBackgroundDelivery: jest.fn(),\n disableBackgroundDelivery: jest.fn(),\n enableBackgroundDelivery: jest.fn(),\n getBiologicalSex: jest.fn(),\n getBloodType: jest.fn(),\n getDateOfBirth: jest.fn(),\n getFitzpatrickSkinType: jest.fn(),\n getPreferredUnits: jest.fn(),\n getRequestStatusForAuthorization: jest.fn(),\n getWheelchairUse: jest.fn(),\n getWorkoutRoutes: jest.fn(),\n queryCategorySamples: jest.fn(),\n queryCorrelationSamples: jest.fn(),\n queryQuantitySamples: jest.fn(),\n queryStatisticsForQuantity: jest.fn(),\n queryWorkoutSamples: jest.fn(),\n saveCategorySample: jest.fn(),\n saveCorrelationSample: jest.fn(),\n saveWorkoutSample: jest.fn(),\n subscribeToObserverQuery: jest.fn(),\n unsubscribeQuery: jest.fn(),\n canAccessProtectedData: jest.fn(),\n}\n\nNativeModules.ReactNativeHealthkit = mockModule\n"],"mappings":";;AAAA;;AAIA,MAAMA,UAA0C,GAAG;EACjDC,qBAAqB,EAAEC,IAAI,CAACC,EAAL,EAD0B;EAEjDC,WAAW,EAAEF,IAAI,CAACC,EAAL,EAFoC;EAGjDE,eAAe,EAAEH,IAAI,CAACC,EAAL,EAHgC;EAIjDG,sBAAsB,EAAEJ,IAAI,CAACC,EAAL,EAJyB;EAKjDI,oBAAoB,EAAEL,IAAI,CAACC,EAAL,EAL2B;EAMjDK,kBAAkB,EAAEN,IAAI,CAACC,EAAL,EAN6B;EAOjDM,oBAAoB,EAAEP,IAAI,CAACC,EAAL,EAP2B;EAQjDO,aAAa,EAAER,IAAI,CAACC,EAAL,EARkC;EASjDQ,4BAA4B,EAAET,IAAI,CAACC,EAAL,EATmB;EAUjDS,yBAAyB,EAAEV,IAAI,CAACC,EAAL,EAVsB;EAWjDU,wBAAwB,EAAEX,IAAI,CAACC,EAAL,EAXuB;EAYjDW,gBAAgB,EAAEZ,IAAI,CAACC,EAAL,EAZ+B;EAajDY,YAAY,EAAEb,IAAI,CAACC,EAAL,EAbmC;EAcjDa,cAAc,EAAEd,IAAI,CAACC,EAAL,EAdiC;EAejDc,sBAAsB,EAAEf,IAAI,CAACC,EAAL,EAfyB;EAgBjDe,iBAAiB,EAAEhB,IAAI,CAACC,EAAL,EAhB8B;EAiBjDgB,gCAAgC,EAAEjB,IAAI,CAACC,EAAL,EAjBe;EAkBjDiB,gBAAgB,EAAElB,IAAI,CAACC,EAAL,EAlB+B;EAmBjDkB,gBAAgB,EAAEnB,IAAI,CAACC,EAAL,EAnB+B;EAoBjDmB,oBAAoB,EAAEpB,IAAI,CAACC,EAAL,EApB2B;EAqBjDoB,uBAAuB,EAAErB,IAAI,CAACC,EAAL,EArBwB;EAsBjDqB,oBAAoB,EAAEtB,IAAI,CAACC,EAAL,EAtB2B;EAuBjDsB,
|
|
1
|
+
{"version":3,"names":["mockModule","isHealthDataAvailable","jest","fn","addListener","removeListeners","authorizationStatusFor","requestAuthorization","saveQuantitySample","deleteQuantitySample","deleteSamples","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getBloodType","getDateOfBirth","getFitzpatrickSkinType","getPreferredUnits","getRequestStatusForAuthorization","getWheelchairUse","getWorkoutRoutes","queryCategorySamples","queryCorrelationSamples","queryQuantitySamples","querySources","queryStatisticsForQuantity","queryWorkoutSamples","saveCategorySample","saveCorrelationSample","saveWorkoutSample","subscribeToObserverQuery","unsubscribeQuery","canAccessProtectedData","NativeModules","ReactNativeHealthkit"],"sources":["jest.setup.ts"],"sourcesContent":["import { NativeModule, NativeModules } from 'react-native'\n\nimport type Native from './native-types'\n\nconst mockModule: (NativeModule & typeof Native) = {\n isHealthDataAvailable: jest.fn(),\n addListener: jest.fn(),\n removeListeners: jest.fn(),\n authorizationStatusFor: jest.fn(),\n requestAuthorization: jest.fn(),\n saveQuantitySample: jest.fn(),\n deleteQuantitySample: jest.fn(),\n deleteSamples: jest.fn(),\n disableAllBackgroundDelivery: jest.fn(),\n disableBackgroundDelivery: jest.fn(),\n enableBackgroundDelivery: jest.fn(),\n getBiologicalSex: jest.fn(),\n getBloodType: jest.fn(),\n getDateOfBirth: jest.fn(),\n getFitzpatrickSkinType: jest.fn(),\n getPreferredUnits: jest.fn(),\n getRequestStatusForAuthorization: jest.fn(),\n getWheelchairUse: jest.fn(),\n getWorkoutRoutes: jest.fn(),\n queryCategorySamples: jest.fn(),\n queryCorrelationSamples: jest.fn(),\n queryQuantitySamples: jest.fn(),\n querySources: jest.fn(),\n queryStatisticsForQuantity: jest.fn(),\n queryWorkoutSamples: jest.fn(),\n saveCategorySample: jest.fn(),\n saveCorrelationSample: jest.fn(),\n saveWorkoutSample: jest.fn(),\n subscribeToObserverQuery: jest.fn(),\n unsubscribeQuery: jest.fn(),\n canAccessProtectedData: jest.fn(),\n}\n\nNativeModules.ReactNativeHealthkit = mockModule\n"],"mappings":";;AAAA;;AAIA,MAAMA,UAA0C,GAAG;EACjDC,qBAAqB,EAAEC,IAAI,CAACC,EAAL,EAD0B;EAEjDC,WAAW,EAAEF,IAAI,CAACC,EAAL,EAFoC;EAGjDE,eAAe,EAAEH,IAAI,CAACC,EAAL,EAHgC;EAIjDG,sBAAsB,EAAEJ,IAAI,CAACC,EAAL,EAJyB;EAKjDI,oBAAoB,EAAEL,IAAI,CAACC,EAAL,EAL2B;EAMjDK,kBAAkB,EAAEN,IAAI,CAACC,EAAL,EAN6B;EAOjDM,oBAAoB,EAAEP,IAAI,CAACC,EAAL,EAP2B;EAQjDO,aAAa,EAAER,IAAI,CAACC,EAAL,EARkC;EASjDQ,4BAA4B,EAAET,IAAI,CAACC,EAAL,EATmB;EAUjDS,yBAAyB,EAAEV,IAAI,CAACC,EAAL,EAVsB;EAWjDU,wBAAwB,EAAEX,IAAI,CAAC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