@kingstinct/react-native-healthkit 4.3.0 → 4.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/ReactNativeHealthkit.swift +2 -2
- package/lib/commonjs/index.ios.js +123 -104
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +50 -37
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +127 -106
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.ios.js +124 -105
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +51 -37
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +118 -103
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/native-types.d.ts +452 -217
- package/lib/typescript/src/types.d.ts +85 -83
- package/package.json +21 -35
- package/src/index.ios.tsx +299 -273
- package/src/index.tsx +63 -46
- package/src/native-types.ts +310 -301
- package/src/types.ts +113 -107
package/src/index.tsx
CHANGED
|
@@ -1,52 +1,69 @@
|
|
|
1
|
-
import { Platform } from 'react-native'
|
|
2
|
-
import type { ReactNativeHealthkit } from './types';
|
|
1
|
+
import { Platform } from 'react-native'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'" not supported, use isHealthDataAvailable to check for availability before using it';
|
|
3
|
+
import {
|
|
4
|
+
HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnit, HKWheelchairUse,
|
|
5
|
+
} from './native-types'
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import type { ReactNativeHealthkit } from './types'
|
|
8
|
+
|
|
9
|
+
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${
|
|
10
|
+
Platform.OS
|
|
11
|
+
}" not supported`
|
|
12
|
+
|
|
13
|
+
function UnavailableFn<T = unknown>(retVal: T) {
|
|
14
|
+
return () => {
|
|
15
|
+
console.warn(notAvailableError)
|
|
16
|
+
return retVal
|
|
17
|
+
}
|
|
18
|
+
}
|
|
12
19
|
|
|
13
20
|
const Healthkit: ReactNativeHealthkit = {
|
|
14
|
-
authorizationStatusFor: UnavailableFn,
|
|
15
|
-
buildUnitWithPrefix: UnavailableFn,
|
|
16
|
-
disableAllBackgroundDelivery: UnavailableFn,
|
|
17
|
-
disableBackgroundDelivery: UnavailableFn,
|
|
18
|
-
enableBackgroundDelivery: UnavailableFn,
|
|
19
|
-
getBiologicalSex: UnavailableFn,
|
|
20
|
-
getBloodType: UnavailableFn,
|
|
21
|
-
getDateOfBirth: UnavailableFn,
|
|
22
|
-
getFitzpatrickSkinType: UnavailableFn,
|
|
23
|
-
getMostRecentCategorySample: UnavailableFn,
|
|
24
|
-
getMostRecentQuantitySample: UnavailableFn,
|
|
25
|
-
getMostRecentWorkout: UnavailableFn,
|
|
26
|
-
getPreferredUnit: UnavailableFn,
|
|
27
|
-
getPreferredUnits: UnavailableFn,
|
|
28
|
-
getRequestStatusForAuthorization: UnavailableFn,
|
|
29
|
-
getWheelchairUse: UnavailableFn,
|
|
30
|
-
getWorkoutRoutes: UnavailableFn,
|
|
31
|
-
isHealthDataAvailable: () => Promise.resolve(false),
|
|
32
|
-
queryCategorySamples: UnavailableFn,
|
|
33
|
-
queryCorrelationSamples: UnavailableFn,
|
|
34
|
-
queryQuantitySamples: UnavailableFn,
|
|
35
|
-
queryStatisticsForQuantity: UnavailableFn
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
21
|
+
authorizationStatusFor: UnavailableFn(Promise.resolve(false)),
|
|
22
|
+
buildUnitWithPrefix: UnavailableFn(HKUnit.Atmospheres),
|
|
23
|
+
disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
24
|
+
disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
25
|
+
enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
26
|
+
getBiologicalSex: UnavailableFn(Promise.resolve(HKBiologicalSex.notSet)),
|
|
27
|
+
getBloodType: UnavailableFn(Promise.resolve(HKBloodType.notSet)),
|
|
28
|
+
getDateOfBirth: UnavailableFn(Promise.resolve(new Date(0))),
|
|
29
|
+
getFitzpatrickSkinType: UnavailableFn(Promise.resolve(HKFitzpatrickSkinType.notSet)),
|
|
30
|
+
getMostRecentCategorySample: UnavailableFn(Promise.resolve(null)),
|
|
31
|
+
getMostRecentQuantitySample: UnavailableFn(Promise.resolve(null)),
|
|
32
|
+
getMostRecentWorkout: UnavailableFn(Promise.resolve(null)),
|
|
33
|
+
getPreferredUnit: UnavailableFn(Promise.resolve(HKUnit.Atmospheres)),
|
|
34
|
+
getPreferredUnits: UnavailableFn(Promise.resolve([])),
|
|
35
|
+
getRequestStatusForAuthorization: UnavailableFn(Promise.resolve(HKAuthorizationRequestStatus.unknown)),
|
|
36
|
+
getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),
|
|
37
|
+
getWorkoutRoutes: UnavailableFn(Promise.resolve([])),
|
|
38
|
+
isHealthDataAvailable: async () => Promise.resolve(false),
|
|
39
|
+
queryCategorySamples: UnavailableFn(Promise.resolve([])),
|
|
40
|
+
queryCorrelationSamples: UnavailableFn(Promise.resolve([])),
|
|
41
|
+
queryQuantitySamples: UnavailableFn(Promise.resolve([])),
|
|
42
|
+
queryStatisticsForQuantity: UnavailableFn(Promise.resolve({
|
|
43
|
+
averageQuantity: undefined,
|
|
44
|
+
maximumQuantity: undefined,
|
|
45
|
+
minimumQuantity: undefined,
|
|
46
|
+
sumQuantity: undefined,
|
|
47
|
+
mostRecentQuantity: undefined,
|
|
48
|
+
mostRecentQuantityDateInterval: undefined,
|
|
49
|
+
duration: undefined,
|
|
50
|
+
})),
|
|
51
|
+
queryWorkouts: UnavailableFn(Promise.resolve([])),
|
|
52
|
+
requestAuthorization: UnavailableFn(Promise.resolve(false)),
|
|
53
|
+
saveCategorySample: UnavailableFn(Promise.resolve(false)),
|
|
54
|
+
saveCorrelationSample: UnavailableFn(Promise.resolve(false)),
|
|
55
|
+
saveQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
56
|
+
saveWorkoutSample: UnavailableFn(Promise.resolve(false)),
|
|
57
|
+
subscribeToChanges: UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),
|
|
58
|
+
useMostRecentCategorySample: UnavailableFn(null),
|
|
59
|
+
useMostRecentQuantitySample: UnavailableFn(null),
|
|
60
|
+
useMostRecentWorkout: UnavailableFn(null),
|
|
61
|
+
useSubscribeToChanges: UnavailableFn([null, () => null]),
|
|
62
|
+
useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(null)] as const),
|
|
63
|
+
useIsHealthDataAvailable: UnavailableFn(false),
|
|
64
|
+
}
|
|
48
65
|
|
|
49
|
-
export * from './native-types'
|
|
50
|
-
export * from './types'
|
|
66
|
+
export * from './native-types'
|
|
67
|
+
export * from './types'
|
|
51
68
|
|
|
52
|
-
export default Healthkit
|
|
69
|
+
export default Healthkit
|