@kingstinct/react-native-healthkit 4.2.0 → 4.4.1
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 +1 -1
- package/ios/ReactNativeHealthkit.m +6 -1
- package/ios/ReactNativeHealthkit.swift +365 -176
- package/lib/commonjs/index.ios.js +129 -105
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +58 -44
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +136 -106
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/example/App.js +197 -0
- package/lib/index.ios.js +310 -0
- package/lib/index.js +44 -0
- package/lib/module/index.ios.js +130 -106
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +52 -37
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +127 -104
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/native-types.js +447 -0
- package/lib/src/index.ios.js +314 -0
- package/lib/src/index.js +45 -0
- package/lib/src/native-types.js +453 -0
- package/lib/src/types.js +1 -0
- package/lib/types.js +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.ios.d.ts +1 -1
- package/lib/typescript/src/native-types.d.ts +458 -205
- package/lib/typescript/src/types.d.ts +87 -81
- package/package.json +21 -35
- package/src/index.ios.tsx +303 -269
- package/src/index.tsx +63 -45
- package/src/native-types.ts +318 -290
- package/src/types.ts +120 -105
- package/.DS_Store +0 -0
- package/.circleci/config.yml +0 -98
- package/.editorconfig +0 -15
- package/.gitattributes +0 -3
- package/.github/workflows/main.yml +0 -32
- package/.gitignore +0 -60
- package/CONTRIBUTING.md +0 -184
- package/babel.config.js +0 -3
- package/example-expo/.expo/README.md +0 -15
- package/example-expo/.expo/devices.json +0 -8
- package/example-expo/.expo/packager-info.json +0 -5
- package/example-expo/.expo/settings.json +0 -9
- package/example-expo/.expo-shared/assets.json +0 -4
- package/example-expo/.gitignore +0 -14
- package/example-expo/App.tsx +0 -376
- package/example-expo/app.json +0 -43
- package/example-expo/assets/adaptive-icon.png +0 -0
- package/example-expo/assets/favicon.png +0 -0
- package/example-expo/assets/icon.png +0 -0
- package/example-expo/assets/splash.png +0 -0
- package/example-expo/babel.config.js +0 -8
- package/example-expo/build-1653040579600.ipa +0 -0
- package/example-expo/build-1653041063216.ipa +0 -0
- package/example-expo/eas.json +0 -18
- package/example-expo/package.json +0 -32
- package/example-expo/tsconfig.json +0 -6
- package/example-expo/yarn.lock +0 -6857
- package/lib/typescript/example-expo/App.d.ts +0 -3
- package/lib/typescript/src/__tests__/index.test.d.ts +0 -0
- package/src/__tests__/index.test.tsx +0 -1
- package/tsconfig.json +0 -27
- package/yarn.lock +0 -10241
package/src/index.tsx
CHANGED
|
@@ -1,51 +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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
+
}
|
|
47
65
|
|
|
48
|
-
export * from './types'
|
|
49
|
-
export * from './
|
|
66
|
+
export * from './native-types'
|
|
67
|
+
export * from './types'
|
|
50
68
|
|
|
51
|
-
export default Healthkit
|
|
69
|
+
export default Healthkit
|