@kingstinct/react-native-healthkit 4.4.4 → 5.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 +1 -1
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/ReactNativeHealthkit.xcodeproj/xcuserdata/robertherber.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +41 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -0
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +29 -0
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +27 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +43 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js +60 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -0
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +35 -0
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -0
- package/lib/commonjs/hooks/useSubscribeToChanges.js +37 -0
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -0
- package/lib/commonjs/index.ios.js +66 -394
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +9 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +249 -78
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js +13 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +15 -0
- package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -0
- package/lib/commonjs/utils/deserializeCorrelation.js +32 -0
- package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -0
- package/lib/commonjs/utils/deserializeSample.js +17 -0
- package/lib/commonjs/utils/deserializeSample.js.map +1 -0
- package/lib/commonjs/utils/deserializeWorkout.js +17 -0
- package/lib/commonjs/utils/deserializeWorkout.js.map +1 -0
- package/lib/commonjs/utils/ensureMetadata.js +14 -0
- package/lib/commonjs/utils/ensureMetadata.js.map +1 -0
- package/lib/commonjs/utils/ensureUnit.js +23 -0
- package/lib/commonjs/utils/ensureUnit.js.map +1 -0
- package/lib/commonjs/utils/getDateOfBirth.js +19 -0
- package/lib/commonjs/utils/getDateOfBirth.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentCategorySample.js +22 -0
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +22 -0
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentWorkout.js +24 -0
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnit.js +19 -0
- package/lib/commonjs/utils/getPreferredUnit.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnits.js +19 -0
- package/lib/commonjs/utils/getPreferredUnits.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +46 -0
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -0
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +25 -0
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -0
- package/lib/commonjs/utils/prepareOptions.js +27 -0
- package/lib/commonjs/utils/prepareOptions.js.map +1 -0
- package/lib/commonjs/utils/queryCategorySamples.js +24 -0
- package/lib/commonjs/utils/queryCategorySamples.js.map +1 -0
- package/lib/commonjs/utils/queryCorrelationSamples.js +24 -0
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -0
- package/lib/commonjs/utils/queryQuantitySamples.js +27 -0
- package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -0
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +34 -0
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -0
- package/lib/commonjs/utils/queryWorkouts.js +30 -0
- package/lib/commonjs/utils/queryWorkouts.js.map +1 -0
- package/lib/commonjs/utils/requestAuthorization.js +25 -0
- package/lib/commonjs/utils/requestAuthorization.js.map +1 -0
- package/lib/commonjs/utils/saveCategorySample.js +21 -0
- package/lib/commonjs/utils/saveCategorySample.js.map +1 -0
- package/lib/commonjs/utils/saveCorrelationSample.js +24 -0
- package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -0
- package/lib/commonjs/utils/saveQuantitySample.js +21 -0
- package/lib/commonjs/utils/saveQuantitySample.js.map +1 -0
- package/lib/commonjs/utils/saveWorkoutSample.js +25 -0
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -0
- package/lib/commonjs/utils/serializeDate.js +12 -0
- package/lib/commonjs/utils/serializeDate.js.map +1 -0
- package/lib/commonjs/utils/subscribeToChanges.js +37 -0
- package/lib/commonjs/utils/subscribeToChanges.js.map +1 -0
- package/lib/module/hooks/useHealthkitAuthorization.js +29 -0
- package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -0
- package/lib/module/hooks/useIsHealthDataAvailable.js +18 -0
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -0
- package/lib/module/hooks/useMostRecentCategorySample.js +15 -0
- package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js +30 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -0
- package/lib/module/hooks/useMostRecentWorkout.js +47 -0
- package/lib/module/hooks/useMostRecentWorkout.js.map +1 -0
- package/lib/module/hooks/useStatisticsForQuantity.js +23 -0
- package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -0
- package/lib/module/hooks/useSubscribeToChanges.js +26 -0
- package/lib/module/hooks/useSubscribeToChanges.js.map +1 -0
- package/lib/module/index.ios.js +32 -370
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +10 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +232 -74
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +15 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/deserializeCategorySample.js +7 -0
- package/lib/module/utils/deserializeCategorySample.js.map +1 -0
- package/lib/module/utils/deserializeCorrelation.js +21 -0
- package/lib/module/utils/deserializeCorrelation.js.map +1 -0
- package/lib/module/utils/deserializeSample.js +9 -0
- package/lib/module/utils/deserializeSample.js.map +1 -0
- package/lib/module/utils/deserializeWorkout.js +9 -0
- package/lib/module/utils/deserializeWorkout.js.map +1 -0
- package/lib/module/utils/ensureMetadata.js +6 -0
- package/lib/module/utils/ensureMetadata.js.map +1 -0
- package/lib/module/utils/ensureUnit.js +13 -0
- package/lib/module/utils/ensureUnit.js.map +1 -0
- package/lib/module/utils/getDateOfBirth.js +9 -0
- package/lib/module/utils/getDateOfBirth.js.map +1 -0
- package/lib/module/utils/getMostRecentCategorySample.js +12 -0
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -0
- package/lib/module/utils/getMostRecentQuantitySample.js +12 -0
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -0
- package/lib/module/utils/getMostRecentWorkout.js +14 -0
- package/lib/module/utils/getMostRecentWorkout.js.map +1 -0
- package/lib/module/utils/getPreferredUnit.js +9 -0
- package/lib/module/utils/getPreferredUnit.js.map +1 -0
- package/lib/module/utils/getPreferredUnits.js +9 -0
- package/lib/module/utils/getPreferredUnits.js.map +1 -0
- package/lib/module/utils/getPreferredUnitsTyped.js +34 -0
- package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -0
- package/lib/module/utils/getRequestStatusForAuthorization.js +15 -0
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -0
- package/lib/module/utils/prepareOptions.js +17 -0
- package/lib/module/utils/prepareOptions.js.map +1 -0
- package/lib/module/utils/queryCategorySamples.js +12 -0
- package/lib/module/utils/queryCategorySamples.js.map +1 -0
- package/lib/module/utils/queryCorrelationSamples.js +12 -0
- package/lib/module/utils/queryCorrelationSamples.js.map +1 -0
- package/lib/module/utils/queryQuantitySamples.js +14 -0
- package/lib/module/utils/queryQuantitySamples.js.map +1 -0
- package/lib/module/utils/queryStatisticsForQuantity.js +23 -0
- package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -0
- package/lib/module/utils/queryWorkouts.js +17 -0
- package/lib/module/utils/queryWorkouts.js.map +1 -0
- package/lib/module/utils/requestAuthorization.js +15 -0
- package/lib/module/utils/requestAuthorization.js.map +1 -0
- package/lib/module/utils/saveCategorySample.js +11 -0
- package/lib/module/utils/saveCategorySample.js.map +1 -0
- package/lib/module/utils/saveCorrelationSample.js +13 -0
- package/lib/module/utils/saveCorrelationSample.js.map +1 -0
- package/lib/module/utils/saveQuantitySample.js +11 -0
- package/lib/module/utils/saveQuantitySample.js.map +1 -0
- package/lib/module/utils/saveWorkoutSample.js +14 -0
- package/lib/module/utils/saveWorkoutSample.js.map +1 -0
- package/lib/module/utils/serializeDate.js +4 -0
- package/lib/module/utils/serializeDate.js.map +1 -0
- package/lib/module/utils/subscribeToChanges.js +25 -0
- package/lib/module/utils/subscribeToChanges.js.map +1 -0
- package/lib/typescript/example-expo/App.d.ts +2 -0
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +3 -0
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +2 -0
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +4 -0
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +4 -0
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +7 -0
- package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +4 -0
- package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +3 -0
- package/lib/typescript/src/index.d.ts +2 -3
- package/lib/typescript/src/index.ios.d.ts +48 -3
- package/lib/typescript/src/native-types.d.ts +235 -70
- package/lib/typescript/src/types.d.ts +14 -90
- package/lib/typescript/src/utils/deserializeCategorySample.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeCorrelation.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeSample.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeWorkout.d.ts +4 -0
- package/lib/typescript/src/utils/ensureMetadata.d.ts +2 -0
- package/lib/typescript/src/utils/ensureUnit.d.ts +3 -0
- package/lib/typescript/src/utils/getDateOfBirth.d.ts +2 -0
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +3 -0
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +3 -0
- package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +5 -0
- package/lib/typescript/src/utils/getPreferredUnit.d.ts +4 -0
- package/lib/typescript/src/utils/getPreferredUnits.d.ts +4 -0
- package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +9 -0
- package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +3 -0
- package/lib/typescript/src/utils/prepareOptions.d.ts +8 -0
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +5 -0
- package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +5 -0
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -0
- package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +14 -0
- package/lib/typescript/src/utils/queryWorkouts.d.ts +4 -0
- package/lib/typescript/src/utils/requestAuthorization.d.ts +3 -0
- package/lib/typescript/src/utils/saveCategorySample.d.ts +7 -0
- package/lib/typescript/src/utils/saveCorrelationSample.d.ts +8 -0
- package/lib/typescript/src/utils/saveQuantitySample.d.ts +7 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +7 -0
- package/lib/typescript/src/utils/serializeDate.d.ts +2 -0
- package/lib/typescript/src/utils/subscribeToChanges.d.ts +3 -0
- package/package.json +17 -6
- package/src/hooks/useHealthkitAuthorization.ts +39 -0
- package/src/hooks/useIsHealthDataAvailable.ts +17 -0
- package/src/hooks/useMostRecentCategorySample.ts +24 -0
- package/src/hooks/useMostRecentQuantitySample.ts +39 -0
- package/src/hooks/useMostRecentWorkout.ts +60 -0
- package/src/hooks/useStatisticsForQuantity.ts +42 -0
- package/src/hooks/useSubscribeToChanges.ts +31 -0
- package/src/index.ios.tsx +36 -569
- package/src/index.tsx +12 -9
- package/src/native-types.ts +323 -93
- package/src/types.ts +41 -152
- package/src/utils/deserializeCategorySample.ts +12 -0
- package/src/utils/deserializeCorrelation.ts +28 -0
- package/src/utils/deserializeSample.ts +17 -0
- package/src/utils/deserializeWorkout.ts +14 -0
- package/src/utils/ensureMetadata.ts +5 -0
- package/src/utils/ensureUnit.ts +19 -0
- package/src/utils/getDateOfBirth.ts +8 -0
- package/src/utils/getMostRecentCategorySample.ts +18 -0
- package/src/utils/getMostRecentQuantitySample.ts +19 -0
- package/src/utils/getMostRecentWorkout.ts +27 -0
- package/src/utils/getPreferredUnit.ts +14 -0
- package/src/utils/getPreferredUnits.ts +14 -0
- package/src/utils/getPreferredUnitsTyped.ts +38 -0
- package/src/utils/getRequestStatusForAuthorization.ts +21 -0
- package/src/utils/prepareOptions.ts +15 -0
- package/src/utils/queryCategorySamples.ts +29 -0
- package/src/utils/queryCorrelationSamples.ts +29 -0
- package/src/utils/queryQuantitySamples.ts +36 -0
- package/src/utils/queryStatisticsForQuantity.ts +38 -0
- package/src/utils/queryWorkouts.ts +28 -0
- package/src/utils/requestAuthorization.ts +18 -0
- package/src/utils/saveCategorySample.ts +27 -0
- package/src/utils/saveCorrelationSample.ts +34 -0
- package/src/utils/saveQuantitySample.ts +29 -0
- package/src/utils/saveWorkoutSample.ts +28 -0
- package/src/utils/serializeDate.ts +3 -0
- package/src/utils/subscribeToChanges.ts +32 -0
|
@@ -6,440 +6,112 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {};
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _useHealthkitAuthorization = _interopRequireDefault(require("./hooks/useHealthkitAuthorization"));
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _useIsHealthDataAvailable = _interopRequireDefault(require("./hooks/useIsHealthDataAvailable"));
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
if (key === "default" || key === "__esModule") return;
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
-
if (key in exports && exports[key] === _nativeTypes[key]) return;
|
|
17
|
-
Object.defineProperty(exports, key, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _nativeTypes[key];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
var _types = require("./types");
|
|
26
|
-
|
|
27
|
-
Object.keys(_types).forEach(function (key) {
|
|
28
|
-
if (key === "default" || key === "__esModule") return;
|
|
29
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
30
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
31
|
-
Object.defineProperty(exports, key, {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _types[key];
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
var _useMostRecentCategorySample = _interopRequireDefault(require("./hooks/useMostRecentCategorySample"));
|
|
40
14
|
|
|
41
|
-
|
|
15
|
+
var _useMostRecentQuantitySample = _interopRequireDefault(require("./hooks/useMostRecentQuantitySample"));
|
|
42
16
|
|
|
43
|
-
|
|
44
|
-
const [unit] = await getPreferredUnits([type]);
|
|
45
|
-
return unit;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const ensureUnit = async (type, providedUnit) => {
|
|
49
|
-
if (providedUnit) {
|
|
50
|
-
return providedUnit;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const unit = await _nativeTypes.default.getPreferredUnits([type]);
|
|
54
|
-
return unit[type];
|
|
55
|
-
};
|
|
17
|
+
var _useMostRecentWorkout = _interopRequireDefault(require("./hooks/useMostRecentWorkout"));
|
|
56
18
|
|
|
57
|
-
|
|
58
|
-
return { ...sample,
|
|
59
|
-
startDate: new Date(sample.startDate),
|
|
60
|
-
endDate: new Date(sample.endDate)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
19
|
+
var _useSubscribeToChanges = _interopRequireDefault(require("./hooks/useSubscribeToChanges"));
|
|
63
20
|
|
|
64
|
-
|
|
65
|
-
return { ...sample,
|
|
66
|
-
startDate: new Date(sample.startDate),
|
|
67
|
-
endDate: new Date(sample.endDate)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
21
|
+
var _nativeTypes = _interopRequireDefault(require("./native-types"));
|
|
70
22
|
|
|
71
|
-
|
|
72
|
-
startDate: new Date(sample.startDate),
|
|
73
|
-
endDate: new Date(sample.endDate)
|
|
74
|
-
});
|
|
23
|
+
var _getDateOfBirth = _interopRequireDefault(require("./utils/getDateOfBirth"));
|
|
75
24
|
|
|
76
|
-
|
|
25
|
+
var _getMostRecentCategorySample = _interopRequireDefault(require("./utils/getMostRecentCategorySample"));
|
|
77
26
|
|
|
78
|
-
|
|
79
|
-
const limit = !options.limit || options.limit === Infinity ? 0 : options.limit;
|
|
80
|
-
const ascending = options.ascending ?? limit === 0;
|
|
81
|
-
const from = serializeDate(options.from);
|
|
82
|
-
const to = serializeDate(options.to);
|
|
83
|
-
return {
|
|
84
|
-
limit,
|
|
85
|
-
ascending,
|
|
86
|
-
from,
|
|
87
|
-
to
|
|
88
|
-
};
|
|
89
|
-
};
|
|
27
|
+
var _getMostRecentQuantitySample = _interopRequireDefault(require("./utils/getMostRecentQuantitySample"));
|
|
90
28
|
|
|
91
|
-
|
|
92
|
-
const unit = await ensureUnit(identifier, options.unit);
|
|
93
|
-
const opts = prepareOptions(options);
|
|
94
|
-
const quantitySamples = await _nativeTypes.default.queryQuantitySamples(identifier, unit, opts.from, opts.to, opts.limit, opts.ascending);
|
|
95
|
-
return quantitySamples.map(deserializeSample);
|
|
96
|
-
};
|
|
29
|
+
var _getMostRecentWorkout = _interopRequireDefault(require("./utils/getMostRecentWorkout"));
|
|
97
30
|
|
|
98
|
-
|
|
99
|
-
let energyUnit = options === null || options === void 0 ? void 0 : options.energyUnit;
|
|
100
|
-
let distanceUnit = options === null || options === void 0 ? void 0 : options.distanceUnit;
|
|
31
|
+
var _getPreferredUnit = _interopRequireDefault(require("./utils/getPreferredUnit"));
|
|
101
32
|
|
|
102
|
-
|
|
103
|
-
const units = await _nativeTypes.default.getPreferredUnits([_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning, _nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned]);
|
|
33
|
+
var _getPreferredUnits = _interopRequireDefault(require("./utils/getPreferredUnits"));
|
|
104
34
|
|
|
105
|
-
|
|
106
|
-
energyUnit = units[_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning];
|
|
107
|
-
}
|
|
35
|
+
var _getRequestStatusForAuthorization = _interopRequireDefault(require("./utils/getRequestStatusForAuthorization"));
|
|
108
36
|
|
|
109
|
-
|
|
110
|
-
distanceUnit = units[_nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
37
|
+
var _queryCategorySamples = _interopRequireDefault(require("./utils/queryCategorySamples"));
|
|
113
38
|
|
|
114
|
-
|
|
115
|
-
energyUnit = _nativeTypes.HKUnit.Kilocalories;
|
|
116
|
-
}
|
|
39
|
+
var _queryCorrelationSamples = _interopRequireDefault(require("./utils/queryCorrelationSamples"));
|
|
117
40
|
|
|
118
|
-
|
|
119
|
-
distanceUnit = _nativeTypes.HKUnit.Meters;
|
|
120
|
-
}
|
|
41
|
+
var _queryQuantitySamples = _interopRequireDefault(require("./utils/queryQuantitySamples"));
|
|
121
42
|
|
|
122
|
-
|
|
123
|
-
energyUnit,
|
|
124
|
-
distanceUnit
|
|
125
|
-
};
|
|
126
|
-
}
|
|
43
|
+
var _queryStatisticsForQuantity = _interopRequireDefault(require("./utils/queryStatisticsForQuantity"));
|
|
127
44
|
|
|
128
|
-
|
|
129
|
-
const subscription = _nativeTypes.EventEmitter.addListener('onChange', _ref => {
|
|
130
|
-
let {
|
|
131
|
-
typeIdentifier
|
|
132
|
-
} = _ref;
|
|
45
|
+
var _queryWorkouts = _interopRequireDefault(require("./utils/queryWorkouts"));
|
|
133
46
|
|
|
134
|
-
|
|
135
|
-
callback();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
47
|
+
var _requestAuthorization = _interopRequireDefault(require("./utils/requestAuthorization"));
|
|
138
48
|
|
|
139
|
-
|
|
140
|
-
subscription.remove();
|
|
141
|
-
return Promise.reject(error);
|
|
142
|
-
});
|
|
143
|
-
return async () => {
|
|
144
|
-
subscription.remove();
|
|
145
|
-
return _nativeTypes.default.unsubscribeQuery(queryId);
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const getMostRecentQuantitySample = async (identifier, unit) => {
|
|
150
|
-
const samples = await queryQuantitySamples(identifier, {
|
|
151
|
-
limit: 1,
|
|
152
|
-
unit
|
|
153
|
-
});
|
|
154
|
-
return samples[0];
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
function useMostRecentWorkout(options) {
|
|
158
|
-
const [workout, setWorkout] = (0, _react.useState)(null);
|
|
159
|
-
(0, _react.useEffect)(() => {
|
|
160
|
-
let cancelSubscription;
|
|
161
|
-
|
|
162
|
-
const init = async () => {
|
|
163
|
-
const {
|
|
164
|
-
energyUnit,
|
|
165
|
-
distanceUnit
|
|
166
|
-
} = await getPreferredUnitsTyped(options);
|
|
167
|
-
cancelSubscription = await subscribeToChanges('HKWorkoutTypeIdentifier', async () => {
|
|
168
|
-
const w = await getMostRecentWorkout({
|
|
169
|
-
energyUnit,
|
|
170
|
-
distanceUnit
|
|
171
|
-
});
|
|
172
|
-
setWorkout(w);
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
void init();
|
|
177
|
-
return () => {
|
|
178
|
-
var _cancelSubscription;
|
|
179
|
-
|
|
180
|
-
void ((_cancelSubscription = cancelSubscription) === null || _cancelSubscription === void 0 ? void 0 : _cancelSubscription());
|
|
181
|
-
};
|
|
182
|
-
}, [options]);
|
|
183
|
-
return workout;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const getMostRecentCategorySample = async identifier => {
|
|
187
|
-
const samples = await queryCategorySamples(identifier, {
|
|
188
|
-
limit: 1,
|
|
189
|
-
ascending: false
|
|
190
|
-
});
|
|
191
|
-
return samples[0];
|
|
192
|
-
};
|
|
49
|
+
var _saveCategorySample = _interopRequireDefault(require("./utils/saveCategorySample"));
|
|
193
50
|
|
|
194
|
-
|
|
195
|
-
(0, _react.useEffect)(() => {
|
|
196
|
-
let cancelSubscription;
|
|
51
|
+
var _saveCorrelationSample = _interopRequireDefault(require("./utils/saveCorrelationSample"));
|
|
197
52
|
|
|
198
|
-
|
|
199
|
-
cancelSubscription = await subscribeToChanges(identifier, onChange);
|
|
200
|
-
};
|
|
53
|
+
var _saveQuantitySample = _interopRequireDefault(require("./utils/saveQuantitySample"));
|
|
201
54
|
|
|
202
|
-
|
|
203
|
-
return () => {
|
|
204
|
-
var _cancelSubscription2;
|
|
55
|
+
var _saveWorkoutSample = _interopRequireDefault(require("./utils/saveWorkoutSample"));
|
|
205
56
|
|
|
206
|
-
|
|
207
|
-
};
|
|
208
|
-
}, [identifier, onChange]);
|
|
209
|
-
}
|
|
57
|
+
var _subscribeToChanges = _interopRequireDefault(require("./utils/subscribeToChanges"));
|
|
210
58
|
|
|
211
|
-
|
|
212
|
-
const [category, setCategory] = (0, _react.useState)(null);
|
|
213
|
-
const updater = (0, _react.useCallback)(() => {
|
|
214
|
-
void getMostRecentCategorySample(identifier).then(setCategory);
|
|
215
|
-
}, [identifier]);
|
|
216
|
-
useSubscribeToChanges(identifier, updater);
|
|
217
|
-
return category;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function useMostRecentQuantitySample(identifier, unit) {
|
|
221
|
-
const [lastSample, setLastSample] = (0, _react.useState)(null);
|
|
222
|
-
(0, _react.useEffect)(() => {
|
|
223
|
-
let cancelSubscription;
|
|
224
|
-
|
|
225
|
-
const init = async () => {
|
|
226
|
-
const actualUnit = await ensureUnit(identifier, unit);
|
|
227
|
-
cancelSubscription = await subscribeToChanges(identifier, async () => {
|
|
228
|
-
const value = await getMostRecentQuantitySample(identifier, actualUnit);
|
|
229
|
-
setLastSample(value);
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
void init();
|
|
234
|
-
return () => {
|
|
235
|
-
var _cancelSubscription3;
|
|
236
|
-
|
|
237
|
-
void ((_cancelSubscription3 = cancelSubscription) === null || _cancelSubscription3 === void 0 ? void 0 : _cancelSubscription3());
|
|
238
|
-
};
|
|
239
|
-
}, [identifier, unit]);
|
|
240
|
-
return lastSample;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const saveQuantitySample = async (identifier, unit, value, options) => {
|
|
244
|
-
const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
|
|
245
|
-
const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
|
|
246
|
-
const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
|
|
247
|
-
return _nativeTypes.default.saveQuantitySample(identifier, unit, value, start.toISOString(), end.toISOString(), metadata);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
const queryStatisticsForQuantity = async (identifier, options, from, to, unit) => {
|
|
251
|
-
const actualUnit = await ensureUnit(identifier, unit);
|
|
252
|
-
const toDate = to || new Date();
|
|
253
|
-
const {
|
|
254
|
-
mostRecentQuantityDateInterval,
|
|
255
|
-
...rawResponse
|
|
256
|
-
} = await _nativeTypes.default.queryStatisticsForQuantity(identifier, actualUnit, from.toISOString(), toDate.toISOString(), options);
|
|
257
|
-
const response = { ...rawResponse,
|
|
258
|
-
...(mostRecentQuantityDateInterval ? {
|
|
259
|
-
mostRecentQuantityDateInterval: {
|
|
260
|
-
from: new Date(mostRecentQuantityDateInterval.from),
|
|
261
|
-
to: new Date(mostRecentQuantityDateInterval.to)
|
|
262
|
-
}
|
|
263
|
-
} : {})
|
|
264
|
-
};
|
|
265
|
-
return response;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const requestAuthorization = async function (read) {
|
|
269
|
-
let write = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
270
|
-
const readPermissions = read.reduce((obj, cur) => ({ ...obj,
|
|
271
|
-
[cur]: true
|
|
272
|
-
}), {});
|
|
273
|
-
const writePermissions = write.reduce((obj, cur) => ({ ...obj,
|
|
274
|
-
[cur]: true
|
|
275
|
-
}), {});
|
|
276
|
-
return _nativeTypes.default.requestAuthorization(writePermissions, readPermissions);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
const getDateOfBirth = async () => {
|
|
280
|
-
const dateOfBirth = await _nativeTypes.default.getDateOfBirth();
|
|
281
|
-
return new Date(dateOfBirth);
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
const getRequestStatusForAuthorization = async function (read) {
|
|
285
|
-
let write = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
286
|
-
const readPermissions = read.reduce((obj, cur) => ({ ...obj,
|
|
287
|
-
[cur]: true
|
|
288
|
-
}), {});
|
|
289
|
-
const writePermissions = write.reduce((obj, cur) => ({ ...obj,
|
|
290
|
-
[cur]: true
|
|
291
|
-
}), {});
|
|
292
|
-
return _nativeTypes.default.getRequestStatusForAuthorization(writePermissions, readPermissions);
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
const queryCategorySamples = async (identifier, options) => {
|
|
296
|
-
const opts = prepareOptions(options);
|
|
297
|
-
const results = await _nativeTypes.default.queryCategorySamples(identifier, opts.from, opts.to, opts.limit, opts.ascending);
|
|
298
|
-
return results.map(deserializCategorySample);
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
const queryWorkouts = async options => {
|
|
302
|
-
const {
|
|
303
|
-
energyUnit,
|
|
304
|
-
distanceUnit
|
|
305
|
-
} = await getPreferredUnitsTyped(options);
|
|
306
|
-
const opts = prepareOptions(options);
|
|
307
|
-
const workouts = await _nativeTypes.default.queryWorkoutSamples(energyUnit, distanceUnit, opts.from, opts.to, opts.limit, opts.ascending);
|
|
308
|
-
return workouts.map(deserializeWorkout);
|
|
309
|
-
};
|
|
59
|
+
var _types = require("./types");
|
|
310
60
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
61
|
+
Object.keys(_types).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
64
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _types[key];
|
|
69
|
+
}
|
|
317
70
|
});
|
|
318
|
-
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
async function saveCategorySample(identifier, value, options) {
|
|
322
|
-
const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
|
|
323
|
-
const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
|
|
324
|
-
const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
|
|
325
|
-
return _nativeTypes.default.saveCategorySample(identifier, value, start.toISOString(), end.toISOString(), metadata || {});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const getPreferredUnits = async identifiers => {
|
|
329
|
-
const units = await _nativeTypes.default.getPreferredUnits(identifiers);
|
|
330
|
-
return identifiers.map(i => units[i]);
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
const buildUnitWithPrefix = (prefix, unit) => `${prefix}${unit}`;
|
|
334
|
-
|
|
335
|
-
function deserializeCorrelation(s) {
|
|
336
|
-
return { ...s,
|
|
337
|
-
objects: s.objects.map(o => {
|
|
338
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
339
|
-
// @ts-ignore
|
|
340
|
-
if (o.quantity !== undefined) {
|
|
341
|
-
return deserializeSample(o);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return deserializCategorySample(o);
|
|
345
|
-
}),
|
|
346
|
-
endDate: new Date(s.endDate),
|
|
347
|
-
startDate: new Date(s.startDate)
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function ensureMetadata(metadata) {
|
|
352
|
-
return metadata || {};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const queryCorrelationSamples = async (typeIdentifier, options) => {
|
|
356
|
-
const opts = prepareOptions(options);
|
|
357
|
-
const correlations = await _nativeTypes.default.queryCorrelationSamples(typeIdentifier, opts.from, opts.to);
|
|
358
|
-
return correlations.map(deserializeCorrelation);
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
const saveCorrelationSample = async (typeIdentifier, samples, options) => {
|
|
362
|
-
const start = ((options === null || options === void 0 ? void 0 : options.start) || new Date()).toISOString();
|
|
363
|
-
const end = ((options === null || options === void 0 ? void 0 : options.end) || new Date()).toISOString();
|
|
364
|
-
return _nativeTypes.default.saveCorrelationSample(typeIdentifier, samples, start, end, ensureMetadata(options === null || options === void 0 ? void 0 : options.metadata));
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
const saveWorkoutSample = async (typeIdentifier, quantities, _start, options) => {
|
|
368
|
-
const start = _start.toISOString();
|
|
369
|
-
|
|
370
|
-
const end = ((options === null || options === void 0 ? void 0 : options.end) || new Date()).toISOString();
|
|
371
|
-
return _nativeTypes.default.saveWorkoutSample(typeIdentifier, quantities, start, end, ensureMetadata(options === null || options === void 0 ? void 0 : options.metadata));
|
|
372
|
-
};
|
|
71
|
+
});
|
|
373
72
|
|
|
374
|
-
|
|
73
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
375
74
|
|
|
376
75
|
const Healthkit = {
|
|
377
76
|
authorizationStatusFor: _nativeTypes.default.authorizationStatusFor.bind(_nativeTypes.default),
|
|
378
77
|
isHealthDataAvailable: _nativeTypes.default.isHealthDataAvailable.bind(_nativeTypes.default),
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
enableBackgroundDelivery: _nativeTypes.default.enableBackgroundDelivery,
|
|
78
|
+
disableAllBackgroundDelivery: _nativeTypes.default.disableAllBackgroundDelivery.bind(_nativeTypes.default),
|
|
79
|
+
disableBackgroundDelivery: _nativeTypes.default.disableBackgroundDelivery.bind(_nativeTypes.default),
|
|
80
|
+
enableBackgroundDelivery: _nativeTypes.default.enableBackgroundDelivery.bind(_nativeTypes.default),
|
|
383
81
|
// simple convenience getters
|
|
384
82
|
getBiologicalSex: _nativeTypes.default.getBiologicalSex.bind(_nativeTypes.default),
|
|
385
83
|
getFitzpatrickSkinType: _nativeTypes.default.getFitzpatrickSkinType.bind(_nativeTypes.default),
|
|
386
|
-
getWheelchairUse: _nativeTypes.default.getWheelchairUse,
|
|
84
|
+
getWheelchairUse: _nativeTypes.default.getWheelchairUse.bind(_nativeTypes.default),
|
|
387
85
|
getBloodType: _nativeTypes.default.getBloodType.bind(_nativeTypes.default),
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
86
|
+
getWorkoutRoutes: _nativeTypes.default.getWorkoutRoutes.bind(_nativeTypes.default),
|
|
87
|
+
getDateOfBirth: _getDateOfBirth.default,
|
|
88
|
+
getMostRecentQuantitySample: _getMostRecentQuantitySample.default,
|
|
89
|
+
getMostRecentCategorySample: _getMostRecentCategorySample.default,
|
|
90
|
+
getMostRecentWorkout: _getMostRecentWorkout.default,
|
|
91
|
+
getPreferredUnit: _getPreferredUnit.default,
|
|
92
|
+
getPreferredUnits: _getPreferredUnits.default,
|
|
93
|
+
getRequestStatusForAuthorization: _getRequestStatusForAuthorization.default,
|
|
396
94
|
// query methods
|
|
397
|
-
queryCategorySamples,
|
|
398
|
-
queryCorrelationSamples,
|
|
399
|
-
queryQuantitySamples,
|
|
400
|
-
queryStatisticsForQuantity,
|
|
401
|
-
queryWorkouts,
|
|
402
|
-
requestAuthorization,
|
|
95
|
+
queryCategorySamples: _queryCategorySamples.default,
|
|
96
|
+
queryCorrelationSamples: _queryCorrelationSamples.default,
|
|
97
|
+
queryQuantitySamples: _queryQuantitySamples.default,
|
|
98
|
+
queryStatisticsForQuantity: _queryStatisticsForQuantity.default,
|
|
99
|
+
queryWorkouts: _queryWorkouts.default,
|
|
100
|
+
requestAuthorization: _requestAuthorization.default,
|
|
403
101
|
// save methods
|
|
404
|
-
saveCategorySample,
|
|
405
|
-
saveCorrelationSample,
|
|
406
|
-
saveQuantitySample,
|
|
407
|
-
saveWorkoutSample,
|
|
102
|
+
saveCategorySample: _saveCategorySample.default,
|
|
103
|
+
saveCorrelationSample: _saveCorrelationSample.default,
|
|
104
|
+
saveQuantitySample: _saveQuantitySample.default,
|
|
105
|
+
saveWorkoutSample: _saveWorkoutSample.default,
|
|
408
106
|
// subscriptions
|
|
409
|
-
subscribeToChanges,
|
|
107
|
+
subscribeToChanges: _subscribeToChanges.default,
|
|
410
108
|
// hooks
|
|
411
|
-
useMostRecentCategorySample,
|
|
412
|
-
useMostRecentQuantitySample,
|
|
413
|
-
useMostRecentWorkout,
|
|
414
|
-
useSubscribeToChanges,
|
|
415
|
-
useIsHealthDataAvailable:
|
|
416
|
-
|
|
417
|
-
(0, _react.useEffect)(() => {
|
|
418
|
-
const init = async () => {
|
|
419
|
-
const res = await _nativeTypes.default.isHealthDataAvailable();
|
|
420
|
-
setIsAvailable(res);
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
void init();
|
|
424
|
-
}, []);
|
|
425
|
-
return isAvailable;
|
|
426
|
-
},
|
|
427
|
-
useHealthkitAuthorization: (read, write) => {
|
|
428
|
-
const [status, setStatus] = (0, _react.useState)(null);
|
|
429
|
-
const refreshAuthStatus = (0, _react.useCallback)(async () => {
|
|
430
|
-
const auth = await getRequestStatusForAuthorization(read, write);
|
|
431
|
-
setStatus(auth);
|
|
432
|
-
return auth;
|
|
433
|
-
}, []);
|
|
434
|
-
const request = (0, _react.useCallback)(async () => {
|
|
435
|
-
await requestAuthorization(read, write);
|
|
436
|
-
return refreshAuthStatus();
|
|
437
|
-
}, []);
|
|
438
|
-
(0, _react.useEffect)(() => {
|
|
439
|
-
void refreshAuthStatus();
|
|
440
|
-
}, []);
|
|
441
|
-
return [status, request];
|
|
442
|
-
}
|
|
109
|
+
useMostRecentCategorySample: _useMostRecentCategorySample.default,
|
|
110
|
+
useMostRecentQuantitySample: _useMostRecentQuantitySample.default,
|
|
111
|
+
useMostRecentWorkout: _useMostRecentWorkout.default,
|
|
112
|
+
useSubscribeToChanges: _useSubscribeToChanges.default,
|
|
113
|
+
useIsHealthDataAvailable: _useIsHealthDataAvailable.default,
|
|
114
|
+
useHealthkitAuthorization: _useHealthkitAuthorization.default
|
|
443
115
|
};
|
|
444
116
|
var _default = Healthkit;
|
|
445
117
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getPreferredUnit","type","unit","getPreferredUnits","ensureUnit","providedUnit","Native","deserializeSample","sample","startDate","Date","endDate","deserializeWorkout","deserializCategorySample","serializeDate","date","toISOString","prepareOptions","options","limit","Infinity","ascending","from","to","queryQuantitySamples","identifier","opts","quantitySamples","map","getPreferredUnitsTyped","energyUnit","distanceUnit","units","HKQuantityTypeIdentifier","distanceWalkingRunning","activeEnergyBurned","HKUnit","Kilocalories","Meters","subscribeToChanges","callback","subscription","EventEmitter","addListener","typeIdentifier","queryId","subscribeToObserverQuery","catch","error","remove","Promise","reject","unsubscribeQuery","getMostRecentQuantitySample","samples","useMostRecentWorkout","workout","setWorkout","useState","useEffect","cancelSubscription","init","w","getMostRecentWorkout","getMostRecentCategorySample","queryCategorySamples","useSubscribeToChanges","onChange","useMostRecentCategorySample","category","setCategory","updater","useCallback","then","useMostRecentQuantitySample","lastSample","setLastSample","actualUnit","value","saveQuantitySample","start","end","metadata","queryStatisticsForQuantity","toDate","mostRecentQuantityDateInterval","rawResponse","response","requestAuthorization","read","write","readPermissions","reduce","obj","cur","writePermissions","getDateOfBirth","dateOfBirth","getRequestStatusForAuthorization","results","queryWorkouts","workouts","queryWorkoutSamples","saveCategorySample","identifiers","i","buildUnitWithPrefix","prefix","deserializeCorrelation","s","objects","o","quantity","undefined","ensureMetadata","queryCorrelationSamples","correlations","saveCorrelationSample","saveWorkoutSample","quantities","_start","getWorkoutRoutes","workoutUUID","Healthkit","authorizationStatusFor","bind","isHealthDataAvailable","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType","useIsHealthDataAvailable","isAvailable","setIsAvailable","res","useHealthkitAuthorization","status","setStatus","refreshAuthStatus","auth","request"],"sources":["index.ios.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nimport Native, {\n EventEmitter,\n HKQuantityTypeIdentifier,\n HKUnit,\n} from './native-types'\n\nimport type {\n HealthkitReadAuthorization,\n HealthkitWriteAuthorization,\n HKAuthorizationRequestStatus,\n HKCategorySampleRaw,\n HKCategoryValueForIdentifier,\n HKCorrelationRaw,\n HKCorrelationTypeIdentifier,\n HKQuantitySampleRaw,\n HKUnitSI,\n HKUnitSIPrefix,\n HKWorkoutRaw,\n MetadataMapperForCategoryIdentifier,\n ReadPermissions,\n WritePermissions,\n HKSampleTypeIdentifier,\n HKCategoryTypeIdentifier,\n} from './native-types'\nimport type {\n GenericQueryOptions,\n GetMostRecentCategorySampleFn,\n GetMostRecentQuantitySampleFn,\n GetMostRecentWorkoutFn,\n GetPreferredUnitFn,\n GetPreferredUnitsFn,\n GetWorkoutRoutesFn,\n HKCategorySample,\n HKCorrelation,\n HKQuantitySample,\n HKWorkout,\n QueryCategorySamplesFn,\n QueryCorrelationSamplesFn,\n QueryQuantitySamplesFn,\n QueryStatisticsForQuantityFn,\n QueryWorkoutsFn,\n ReactNativeHealthkit,\n SaveCorrelationSampleFn,\n SaveQuantitySampleFn,\n SaveWorkoutSampleFn,\n SubscribeToChangesFn,\n} from './types'\n\nconst getPreferredUnit: GetPreferredUnitFn = async (type) => {\n const [unit] = await getPreferredUnits([type])\n return unit\n}\n\nconst ensureUnit = async <TUnit extends HKUnit>(\n type: HKQuantityTypeIdentifier,\n providedUnit?: TUnit,\n) => {\n if (providedUnit) {\n return providedUnit\n }\n const unit = await Native.getPreferredUnits([type])\n return unit[type] as TUnit\n}\n\nfunction deserializeSample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends HKUnit\n>(\n sample: HKQuantitySampleRaw<TIdentifier, TUnit>,\n): HKQuantitySample<TIdentifier, TUnit> {\n return {\n ...sample,\n startDate: new Date(sample.startDate),\n endDate: new Date(sample.endDate),\n }\n}\n\nfunction deserializeWorkout<TEnergy extends HKUnit, TDistance extends HKUnit>(\n sample: HKWorkoutRaw<TEnergy, TDistance>,\n): HKWorkout<TEnergy, TDistance> {\n return {\n ...sample,\n startDate: new Date(sample.startDate),\n endDate: new Date(sample.endDate),\n }\n}\n\nconst deserializCategorySample = <T extends HKCategoryTypeIdentifier>(\n sample: HKCategorySampleRaw<T>,\n): HKCategorySample<T> => ({\n ...sample,\n startDate: new Date(sample.startDate),\n endDate: new Date(sample.endDate),\n})\n\nconst serializeDate = (date?: Date | null): string => (date ? date.toISOString() : new Date(0).toISOString())\n\nconst prepareOptions = (options: GenericQueryOptions) => {\n const limit = !options.limit || options.limit === Infinity ? 0 : options.limit\n const ascending = options.ascending ?? limit === 0\n const from = serializeDate(options.from)\n const to = serializeDate(options.to)\n return {\n limit, ascending, from, to,\n }\n}\n\nconst queryQuantitySamples: QueryQuantitySamplesFn = async (\n identifier,\n options,\n) => {\n const unit = await ensureUnit(identifier, options.unit)\n const opts = prepareOptions(options)\n\n const quantitySamples = await Native.queryQuantitySamples(\n identifier,\n unit,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n )\n\n return quantitySamples.map(deserializeSample)\n}\n\nasync function getPreferredUnitsTyped<\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(options?: { readonly energyUnit?: TEnergy; readonly distanceUnit?: TDistance }) {\n let energyUnit = options?.energyUnit\n let distanceUnit = options?.distanceUnit\n if (!energyUnit || !distanceUnit) {\n const units = await Native.getPreferredUnits([\n HKQuantityTypeIdentifier.distanceWalkingRunning,\n HKQuantityTypeIdentifier.activeEnergyBurned,\n ])\n if (!energyUnit) {\n energyUnit = units[HKQuantityTypeIdentifier.distanceWalkingRunning] as\n | TEnergy\n | undefined\n }\n if (!distanceUnit) {\n distanceUnit = units[HKQuantityTypeIdentifier.activeEnergyBurned] as\n | TDistance\n | undefined\n }\n }\n if (!energyUnit) {\n energyUnit = HKUnit.Kilocalories as TEnergy\n }\n if (!distanceUnit) {\n distanceUnit = HKUnit.Meters as TDistance\n }\n return { energyUnit, distanceUnit }\n}\n\nconst subscribeToChanges: SubscribeToChangesFn = async (\n identifier,\n callback,\n) => {\n const subscription = EventEmitter.addListener(\n 'onChange',\n ({ typeIdentifier }) => {\n if (typeIdentifier === identifier) {\n callback()\n }\n },\n )\n\n const queryId = await Native.subscribeToObserverQuery(identifier).catch(\n async (error) => {\n subscription.remove()\n return Promise.reject(error)\n },\n )\n\n return async () => {\n subscription.remove()\n return Native.unsubscribeQuery(queryId)\n }\n}\n\nconst getMostRecentQuantitySample: GetMostRecentQuantitySampleFn = async (\n identifier,\n unit,\n) => {\n const samples = await queryQuantitySamples(identifier, {\n limit: 1,\n unit,\n })\n return samples[0]\n}\n\nfunction useMostRecentWorkout<\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(options?: { readonly energyUnit?: TEnergy; readonly distanceUnit?: TDistance }) {\n const [workout, setWorkout] = useState<HKWorkout<TEnergy, TDistance> | null>(\n null,\n )\n useEffect(() => {\n let cancelSubscription: (() => Promise<boolean>) | undefined\n\n const init = async () => {\n const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(\n options,\n )\n\n cancelSubscription = await subscribeToChanges(\n 'HKWorkoutTypeIdentifier',\n async () => {\n const w = await getMostRecentWorkout({ energyUnit, distanceUnit })\n setWorkout(w)\n },\n )\n }\n void init()\n return () => {\n void cancelSubscription?.()\n }\n }, [options])\n return workout\n}\n\nconst getMostRecentCategorySample: GetMostRecentCategorySampleFn = async (\n identifier,\n) => {\n const samples = await queryCategorySamples(identifier, {\n limit: 1,\n ascending: false,\n })\n\n return samples[0]\n}\n\nfunction useSubscribeToChanges<TIdentifier extends HKSampleTypeIdentifier>(\n identifier: TIdentifier,\n onChange: () => void,\n): void {\n useEffect(() => {\n let cancelSubscription: (() => Promise<boolean>) | undefined\n\n const init = async () => {\n cancelSubscription = await subscribeToChanges(identifier, onChange)\n }\n void init()\n\n return () => {\n void cancelSubscription?.()\n }\n }, [identifier, onChange])\n}\n\nfunction useMostRecentCategorySample<\n TCategory extends HKCategoryTypeIdentifier\n>(identifier: TCategory) {\n const [category, setCategory] = useState<HKCategorySample<TCategory> | null>(\n null,\n )\n const updater = useCallback(() => {\n void getMostRecentCategorySample(identifier).then(setCategory)\n }, [identifier])\n\n useSubscribeToChanges(identifier, updater)\n\n return category\n}\n\nfunction useMostRecentQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends HKUnit = HKUnit\n>(identifier: TIdentifier, unit?: TUnit) {\n const [lastSample, setLastSample] = useState<HKQuantitySample<\n TIdentifier,\n TUnit\n > | null>(null)\n\n useEffect(() => {\n let cancelSubscription: (() => Promise<boolean>) | undefined\n\n const init = async () => {\n const actualUnit = await ensureUnit(identifier, unit)\n\n cancelSubscription = await subscribeToChanges(identifier, async () => {\n const value = await getMostRecentQuantitySample(identifier, actualUnit)\n setLastSample(value)\n })\n }\n void init()\n\n return () => {\n void cancelSubscription?.()\n }\n }, [identifier, unit])\n\n return lastSample\n}\n\nconst saveQuantitySample: SaveQuantitySampleFn = async (\n identifier,\n unit,\n value,\n options,\n) => {\n const start = options?.start || options?.end || new Date()\n const end = options?.end || options?.start || new Date()\n const metadata = options?.metadata || {}\n\n return Native.saveQuantitySample(\n identifier,\n unit,\n value,\n start.toISOString(),\n end.toISOString(),\n metadata,\n )\n}\n\nconst queryStatisticsForQuantity: QueryStatisticsForQuantityFn = async (\n identifier,\n options,\n from,\n to,\n unit,\n) => {\n const actualUnit = await ensureUnit(identifier, unit)\n const toDate = to || new Date()\n const { mostRecentQuantityDateInterval, ...rawResponse } = await Native.queryStatisticsForQuantity(\n identifier,\n actualUnit,\n from.toISOString(),\n toDate.toISOString(),\n options,\n )\n\n const response = {\n ...rawResponse,\n ...(mostRecentQuantityDateInterval\n ? {\n mostRecentQuantityDateInterval: {\n from: new Date(mostRecentQuantityDateInterval.from),\n to: new Date(mostRecentQuantityDateInterval.to),\n },\n }\n : {}),\n }\n\n return response\n}\n\nconst requestAuthorization = async (\n read: readonly HealthkitReadAuthorization[],\n write: readonly HealthkitWriteAuthorization[] = [],\n): Promise<boolean> => {\n const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)\n\n const writePermissions = write.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as WritePermissions)\n\n return Native.requestAuthorization(writePermissions, readPermissions)\n}\n\nconst getDateOfBirth = async () => {\n const dateOfBirth = await Native.getDateOfBirth()\n return new Date(dateOfBirth)\n}\n\nconst getRequestStatusForAuthorization = async (\n read: readonly HealthkitReadAuthorization[],\n write: readonly HealthkitWriteAuthorization[] = [],\n) => {\n const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)\n\n const writePermissions = write.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as WritePermissions)\n\n return Native.getRequestStatusForAuthorization(\n writePermissions,\n readPermissions,\n )\n}\n\nconst queryCategorySamples: QueryCategorySamplesFn = async (\n identifier,\n options,\n) => {\n const opts = prepareOptions(options)\n const results = await Native.queryCategorySamples(\n identifier,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n )\n\n return results.map(deserializCategorySample)\n}\n\nconst queryWorkouts: QueryWorkoutsFn = async (options) => {\n const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(options)\n const opts = prepareOptions(options)\n\n const workouts = await Native.queryWorkoutSamples(\n energyUnit,\n distanceUnit,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n )\n\n return workouts.map(deserializeWorkout)\n}\n\nconst getMostRecentWorkout: GetMostRecentWorkoutFn = async (options) => {\n const workouts = await queryWorkouts({\n limit: 1,\n ascending: false,\n energyUnit: options?.energyUnit,\n distanceUnit: options?.distanceUnit,\n })\n\n return workouts[0]\n}\n\nasync function saveCategorySample<T extends HKCategoryTypeIdentifier>(\n identifier: T,\n value: HKCategoryValueForIdentifier<T>,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForCategoryIdentifier<T>;\n },\n) {\n const start = options?.start || options?.end || new Date()\n const end = options?.end || options?.start || new Date()\n const metadata = options?.metadata || {}\n\n return Native.saveCategorySample(\n identifier,\n value,\n start.toISOString(),\n end.toISOString(),\n metadata || {},\n )\n}\n\nconst getPreferredUnits: GetPreferredUnitsFn = async (identifiers) => {\n const units = await Native.getPreferredUnits(identifiers)\n return identifiers.map((i) => units[i])\n}\n\nconst buildUnitWithPrefix = (prefix: HKUnitSIPrefix, unit: HKUnitSI) => `${prefix}${unit}` as HKUnit\n\nfunction deserializeCorrelation<\n TIdentifier extends HKCorrelationTypeIdentifier\n>(s: HKCorrelationRaw<TIdentifier>): HKCorrelation<TIdentifier> {\n return {\n ...s,\n objects: s.objects.map((o) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (o.quantity !== undefined) {\n return deserializeSample(o as HKQuantitySampleRaw)\n }\n\n return deserializCategorySample(o as HKCategorySampleRaw)\n }),\n endDate: new Date(s.endDate),\n startDate: new Date(s.startDate),\n }\n}\n\nfunction ensureMetadata<TMetadata>(metadata?: TMetadata) {\n return metadata || ({} as TMetadata)\n}\n\nconst queryCorrelationSamples: QueryCorrelationSamplesFn = async (\n typeIdentifier,\n options,\n) => {\n const opts = prepareOptions(options)\n const correlations = await Native.queryCorrelationSamples(\n typeIdentifier,\n opts.from,\n opts.to,\n )\n\n return correlations.map(deserializeCorrelation)\n}\n\nconst saveCorrelationSample: SaveCorrelationSampleFn = async (\n typeIdentifier,\n samples,\n options,\n) => {\n const start = (options?.start || new Date()).toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveCorrelationSample(\n typeIdentifier,\n samples,\n start,\n end,\n ensureMetadata(options?.metadata),\n )\n}\n\nconst saveWorkoutSample: SaveWorkoutSampleFn = async (\n typeIdentifier,\n quantities,\n _start,\n options,\n) => {\n const start = _start.toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveWorkoutSample(\n typeIdentifier,\n quantities,\n start,\n end,\n ensureMetadata(options?.metadata),\n )\n}\n\nconst getWorkoutRoutes: GetWorkoutRoutesFn = async (workoutUUID: string) => Native.getWorkoutRoutes(workoutUUID)\n\nconst Healthkit: ReactNativeHealthkit = {\n authorizationStatusFor: Native.authorizationStatusFor.bind(Native),\n\n isHealthDataAvailable: Native.isHealthDataAvailable.bind(Native),\n\n buildUnitWithPrefix,\n\n disableAllBackgroundDelivery: Native.disableAllBackgroundDelivery,\n disableBackgroundDelivery: Native.disableBackgroundDelivery,\n enableBackgroundDelivery: Native.enableBackgroundDelivery,\n\n // simple convenience getters\n getBiologicalSex: Native.getBiologicalSex.bind(Native),\n getFitzpatrickSkinType: Native.getFitzpatrickSkinType.bind(Native),\n getWheelchairUse: Native.getWheelchairUse,\n getBloodType: Native.getBloodType.bind(Native),\n getDateOfBirth,\n\n getMostRecentQuantitySample,\n getMostRecentCategorySample,\n getMostRecentWorkout,\n\n getPreferredUnit,\n getPreferredUnits,\n getRequestStatusForAuthorization,\n\n getWorkoutRoutes,\n\n // query methods\n queryCategorySamples,\n queryCorrelationSamples,\n queryQuantitySamples,\n queryStatisticsForQuantity,\n queryWorkouts,\n\n requestAuthorization,\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 const [isAvailable, setIsAvailable] = useState<boolean | null>(null)\n useEffect(() => {\n const init = async () => {\n const res = await Native.isHealthDataAvailable()\n setIsAvailable(res)\n }\n void init()\n }, [])\n return isAvailable\n },\n useHealthkitAuthorization: (read, write) => {\n const [status, setStatus] = useState<HKAuthorizationRequestStatus | null>(null)\n const refreshAuthStatus = useCallback(async () => {\n const auth = await getRequestStatusForAuthorization(read, write)\n setStatus(auth)\n return auth\n }, [])\n\n const request = useCallback(async () => {\n await requestAuthorization(read, write)\n return refreshAuthStatus()\n }, [])\n\n useEffect(() => {\n void refreshAuthStatus()\n }, [])\n\n return [status, request]\n },\n}\n\nexport * from './native-types'\nexport * from './types'\n\nexport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C,IAA9C,CAA5B;IACA,MAAMmF,iBAAiB,GAAG,IAAArE,kBAAA,EAAY,YAAY;MAChD,MAAMsE,IAAI,GAAG,MAAM5C,gCAAgC,CAACT,IAAD,EAAOC,KAAP,CAAnD;MACAkD,SAAS,CAACE,IAAD,CAAT;MACA,OAAOA,IAAP;IACD,CAJyB,EAIvB,EAJuB,CAA1B;IAMA,MAAMC,OAAO,GAAG,IAAAvE,kBAAA,EAAY,YAAY;MACtC,MAAMgB,oBAAoB,CAACC,IAAD,EAAOC,KAAP,CAA1B;MACA,OAAOmD,iBAAiB,EAAxB;IACD,CAHe,EAGb,EAHa,CAAhB;IAKA,IAAAlF,gBAAA,EAAU,MAAM;MACd,KAAKkF,iBAAiB,EAAtB;IACD,CAFD,EAEG,EAFH;IAIA,OAAO,CAACF,MAAD,EAASI,OAAT,CAAP;EACD;AAnFqC,CAAxC;eAyFepB,S"}
|
|
1
|
+
{"version":3,"names":["Healthkit","authorizationStatusFor","Native","bind","isHealthDataAvailable","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType","getWorkoutRoutes","getDateOfBirth","getMostRecentQuantitySample","getMostRecentCategorySample","getMostRecentWorkout","getPreferredUnit","getPreferredUnits","getRequestStatusForAuthorization","queryCategorySamples","queryCorrelationSamples","queryQuantitySamples","queryStatisticsForQuantity","queryWorkouts","requestAuthorization","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 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\n disableAllBackgroundDelivery: 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 // 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;;AA2DA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;AAzDA,MAAMA,SAAS,GAAG;EAChBC,sBAAsB,EAAEC,oBAAA,CAAOD,sBAAP,CAA8BE,IAA9B,CAAmCD,oBAAnC,CADR;EAGhBE,qBAAqB,EAAEF,oBAAA,CAAOE,qBAAP,CAA6BD,IAA7B,CAAkCD,oBAAlC,CAHP;EAKhBG,4BAA4B,EAAEH,oBAAA,CAAOG,4BAAP,CAAoCF,IAApC,CAAyCD,oBAAzC,CALd;EAMhBI,yBAAyB,EAAEJ,oBAAA,CAAOI,yBAAP,CAAiCH,IAAjC,CAAsCD,oBAAtC,CANX;EAOhBK,wBAAwB,EAAEL,oBAAA,CAAOK,wBAAP,CAAgCJ,IAAhC,CAAqCD,oBAArC,CAPV;EAShB;EACAM,gBAAgB,EAAEN,oBAAA,CAAOM,gBAAP,CAAwBL,IAAxB,CAA6BD,oBAA7B,CAVF;EAWhBO,sBAAsB,EAAEP,oBAAA,CAAOO,sBAAP,CAA8BN,IAA9B,CAAmCD,oBAAnC,CAXR;EAYhBQ,gBAAgB,EAAER,oBAAA,CAAOQ,gBAAP,CAAwBP,IAAxB,CAA6BD,oBAA7B,CAZF;EAahBS,YAAY,EAAET,oBAAA,CAAOS,YAAP,CAAoBR,IAApB,CAAyBD,oBAAzB,CAbE;EAehBU,gBAAgB,EAAEV,oBAAA,CAAOU,gBAAP,CAAwBT,IAAxB,CAA6BD,oBAA7B,CAfF;EAiBhBW,cAAc,EAAdA,uBAjBgB;EAmBhBC,2BAA2B,EAA3BA,oCAnBgB;EAoBhBC,2BAA2B,EAA3BA,oCApBgB;EAqBhBC,oBAAoB,EAApBA,6BArBgB;EAuBhBC,gBAAgB,EAAhBA,yBAvBgB;EAwBhBC,iBAAiB,EAAjBA,0BAxBgB;EAyBhBC,gCAAgC,EAAhCA,yCAzBgB;EA2BhB;EACAC,oBAAoB,EAApBA,6BA5BgB;EA6BhBC,uBAAuB,EAAvBA,gCA7BgB;EA8BhBC,oBAAoB,EAApBA,6BA9BgB;EA+BhBC,0BAA0B,EAA1BA,mCA/BgB;EAgChBC,aAAa,EAAbA,sBAhCgB;EAkChBC,oBAAoB,EAApBA,6BAlCgB;EAoChB;EACAC,kBAAkB,EAAlBA,2BArCgB;EAsChBC,qBAAqB,EAArBA,8BAtCgB;EAuChBC,kBAAkB,EAAlBA,2BAvCgB;EAwChBC,iBAAiB,EAAjBA,0BAxCgB;EA0ChB;EACAC,kBAAkB,EAAlBA,2BA3CgB;EA6ChB;EACAC,2BAA2B,EAA3BA,oCA9CgB;EAgDhBC,2BAA2B,EAA3BA,oCAhDgB;EAiDhBC,oBAAoB,EAApBA,6BAjDgB;EAmDhBC,qBAAqB,EAArBA,8BAnDgB;EAqDhBC,wBAAwB,EAAxBA,iCArDgB;EAsDhBC,yBAAyB,EAAzBA;AAtDgB,CAAlB;eA2DepC,S"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -10,18 +10,6 @@ var _reactNative = require("react-native");
|
|
|
10
10
|
|
|
11
11
|
var _nativeTypes = require("./native-types");
|
|
12
12
|
|
|
13
|
-
Object.keys(_nativeTypes).forEach(function (key) {
|
|
14
|
-
if (key === "default" || key === "__esModule") return;
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
-
if (key in exports && exports[key] === _nativeTypes[key]) return;
|
|
17
|
-
Object.defineProperty(exports, key, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _nativeTypes[key];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
13
|
var _types = require("./types");
|
|
26
14
|
|
|
27
15
|
Object.keys(_types).forEach(function (key) {
|
|
@@ -36,17 +24,21 @@ Object.keys(_types).forEach(function (key) {
|
|
|
36
24
|
});
|
|
37
25
|
});
|
|
38
26
|
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${_reactNative.Platform.OS}" not supported`;
|
|
27
|
+
let hasWarned = false;
|
|
39
28
|
|
|
40
29
|
function UnavailableFn(retVal) {
|
|
41
30
|
return () => {
|
|
42
|
-
|
|
31
|
+
if (!hasWarned) {
|
|
32
|
+
console.warn(notAvailableError);
|
|
33
|
+
hasWarned = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
43
36
|
return retVal;
|
|
44
37
|
};
|
|
45
38
|
}
|
|
46
39
|
|
|
47
40
|
const Healthkit = {
|
|
48
41
|
authorizationStatusFor: UnavailableFn(Promise.resolve(false)),
|
|
49
|
-
buildUnitWithPrefix: UnavailableFn(_nativeTypes.HKUnit.Atmospheres),
|
|
50
42
|
disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
51
43
|
disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
52
44
|
enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
@@ -57,7 +49,7 @@ const Healthkit = {
|
|
|
57
49
|
getMostRecentCategorySample: UnavailableFn(Promise.resolve(null)),
|
|
58
50
|
getMostRecentQuantitySample: UnavailableFn(Promise.resolve(null)),
|
|
59
51
|
getMostRecentWorkout: UnavailableFn(Promise.resolve(null)),
|
|
60
|
-
getPreferredUnit: UnavailableFn(Promise.resolve(_nativeTypes.
|
|
52
|
+
getPreferredUnit: UnavailableFn(Promise.resolve(_nativeTypes.HKUnits.Count)),
|
|
61
53
|
getPreferredUnits: UnavailableFn(Promise.resolve([])),
|
|
62
54
|
getRequestStatusForAuthorization: UnavailableFn(Promise.resolve(_nativeTypes.HKAuthorizationRequestStatus.unknown)),
|
|
63
55
|
getWheelchairUse: UnavailableFn(Promise.resolve(_nativeTypes.HKWheelchairUse.notSet)),
|
|
@@ -86,8 +78,8 @@ const Healthkit = {
|
|
|
86
78
|
useMostRecentQuantitySample: UnavailableFn(null),
|
|
87
79
|
useMostRecentWorkout: UnavailableFn(null),
|
|
88
80
|
useSubscribeToChanges: UnavailableFn([null, () => null]),
|
|
89
|
-
useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(
|
|
90
|
-
useIsHealthDataAvailable:
|
|
81
|
+
useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(_nativeTypes.HKAuthorizationRequestStatus.unknown)]),
|
|
82
|
+
useIsHealthDataAvailable: () => false
|
|
91
83
|
};
|
|
92
84
|
var _default = Healthkit;
|
|
93
85
|
exports.default = _default;
|