@kingstinct/react-native-healthkit 4.1.1 → 4.4.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.m +15 -10
- package/ios/ReactNativeHealthkit.swift +365 -177
- package/lib/commonjs/index.ios.js +104 -106
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +11 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +25 -1
- 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 +104 -106
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +4 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +20 -1
- 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 +142 -108
- package/lib/typescript/src/types.d.ts +80 -78
- package/package.json +25 -39
- package/src/index.ios.tsx +260 -264
- package/src/index.tsx +14 -13
- package/src/native-types.ts +213 -179
- package/src/types.ts +106 -100
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- 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
|
@@ -36,9 +36,9 @@ Object.keys(_types).forEach(function (key) {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
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); }
|
|
40
40
|
|
|
41
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
42
42
|
|
|
43
43
|
const getPreferredUnit = async type => {
|
|
44
44
|
const [unit] = await getPreferredUnits([type]);
|
|
@@ -68,22 +68,16 @@ function deserializeWorkout(sample) {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
const deserializCategorySample = sample => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
};
|
|
71
|
+
const deserializCategorySample = sample => ({ ...sample,
|
|
72
|
+
startDate: new Date(sample.startDate),
|
|
73
|
+
endDate: new Date(sample.endDate)
|
|
74
|
+
});
|
|
77
75
|
|
|
78
|
-
const serializeDate = date =>
|
|
79
|
-
return date ? date.toISOString() : new Date(0).toISOString();
|
|
80
|
-
};
|
|
76
|
+
const serializeDate = date => date ? date.toISOString() : new Date(0).toISOString();
|
|
81
77
|
|
|
82
78
|
const prepareOptions = options => {
|
|
83
|
-
var _options$ascending;
|
|
84
|
-
|
|
85
79
|
const limit = !options.limit || options.limit === Infinity ? 0 : options.limit;
|
|
86
|
-
const ascending =
|
|
80
|
+
const ascending = options.ascending ?? limit === 0;
|
|
87
81
|
const from = serializeDate(options.from);
|
|
88
82
|
const to = serializeDate(options.to);
|
|
89
83
|
return {
|
|
@@ -101,20 +95,52 @@ const queryQuantitySamples = async (identifier, options) => {
|
|
|
101
95
|
return quantitySamples.map(deserializeSample);
|
|
102
96
|
};
|
|
103
97
|
|
|
98
|
+
async function getPreferredUnitsTyped(options) {
|
|
99
|
+
let energyUnit = options === null || options === void 0 ? void 0 : options.energyUnit;
|
|
100
|
+
let distanceUnit = options === null || options === void 0 ? void 0 : options.distanceUnit;
|
|
101
|
+
|
|
102
|
+
if (!energyUnit || !distanceUnit) {
|
|
103
|
+
const units = await _nativeTypes.default.getPreferredUnits([_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning, _nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned]);
|
|
104
|
+
|
|
105
|
+
if (!energyUnit) {
|
|
106
|
+
energyUnit = units[_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!distanceUnit) {
|
|
110
|
+
distanceUnit = units[_nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!energyUnit) {
|
|
115
|
+
energyUnit = _nativeTypes.HKUnit.Kilocalories;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!distanceUnit) {
|
|
119
|
+
distanceUnit = _nativeTypes.HKUnit.Meters;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
energyUnit,
|
|
124
|
+
distanceUnit
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
104
128
|
const subscribeToChanges = async (identifier, callback) => {
|
|
105
|
-
const subscription = _nativeTypes.EventEmitter.addListener('onChange',
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
const subscription = _nativeTypes.EventEmitter.addListener('onChange', _ref => {
|
|
130
|
+
let {
|
|
131
|
+
typeIdentifier
|
|
132
|
+
} = _ref;
|
|
133
|
+
|
|
108
134
|
if (typeIdentifier === identifier) {
|
|
109
135
|
callback();
|
|
110
136
|
}
|
|
111
137
|
});
|
|
112
138
|
|
|
113
|
-
const queryId = await _nativeTypes.default.subscribeToObserverQuery(identifier).catch(error => {
|
|
139
|
+
const queryId = await _nativeTypes.default.subscribeToObserverQuery(identifier).catch(async error => {
|
|
114
140
|
subscription.remove();
|
|
115
141
|
return Promise.reject(error);
|
|
116
142
|
});
|
|
117
|
-
return () => {
|
|
143
|
+
return async () => {
|
|
118
144
|
subscription.remove();
|
|
119
145
|
return _nativeTypes.default.unsubscribeQuery(queryId);
|
|
120
146
|
};
|
|
@@ -123,7 +149,7 @@ const subscribeToChanges = async (identifier, callback) => {
|
|
|
123
149
|
const getMostRecentQuantitySample = async (identifier, unit) => {
|
|
124
150
|
const samples = await queryQuantitySamples(identifier, {
|
|
125
151
|
limit: 1,
|
|
126
|
-
unit
|
|
152
|
+
unit
|
|
127
153
|
});
|
|
128
154
|
return samples[0];
|
|
129
155
|
};
|
|
@@ -138,23 +164,26 @@ function useMostRecentWorkout(options) {
|
|
|
138
164
|
energyUnit,
|
|
139
165
|
distanceUnit
|
|
140
166
|
} = await getPreferredUnitsTyped(options);
|
|
141
|
-
cancelSubscription = await subscribeToChanges('HKWorkoutTypeIdentifier', () => {
|
|
142
|
-
getMostRecentWorkout({
|
|
167
|
+
cancelSubscription = await subscribeToChanges('HKWorkoutTypeIdentifier', async () => {
|
|
168
|
+
const w = await getMostRecentWorkout({
|
|
143
169
|
energyUnit,
|
|
144
170
|
distanceUnit
|
|
145
|
-
})
|
|
171
|
+
});
|
|
172
|
+
setWorkout(w);
|
|
146
173
|
});
|
|
147
174
|
};
|
|
148
175
|
|
|
149
|
-
init();
|
|
176
|
+
void init();
|
|
150
177
|
return () => {
|
|
151
|
-
|
|
178
|
+
var _cancelSubscription;
|
|
179
|
+
|
|
180
|
+
void ((_cancelSubscription = cancelSubscription) === null || _cancelSubscription === void 0 ? void 0 : _cancelSubscription());
|
|
152
181
|
};
|
|
153
182
|
}, [options]);
|
|
154
183
|
return workout;
|
|
155
184
|
}
|
|
156
185
|
|
|
157
|
-
const getMostRecentCategorySample = async
|
|
186
|
+
const getMostRecentCategorySample = async identifier => {
|
|
158
187
|
const samples = await queryCategorySamples(identifier, {
|
|
159
188
|
limit: 1,
|
|
160
189
|
ascending: false
|
|
@@ -162,15 +191,6 @@ const getMostRecentCategorySample = async (identifier) => {
|
|
|
162
191
|
return samples[0];
|
|
163
192
|
};
|
|
164
193
|
|
|
165
|
-
function useMostRecentCategorySample(identifier) {
|
|
166
|
-
const [category, setCategory] = (0, _react.useState)(null);
|
|
167
|
-
const updater = (0, _react.useCallback)(() => {
|
|
168
|
-
getMostRecentCategorySample(identifier).then(setCategory);
|
|
169
|
-
}, [identifier]);
|
|
170
|
-
useSubscribeToChanges(identifier, updater);
|
|
171
|
-
return category;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
194
|
function useSubscribeToChanges(identifier, onChange) {
|
|
175
195
|
(0, _react.useEffect)(() => {
|
|
176
196
|
let cancelSubscription;
|
|
@@ -179,13 +199,24 @@ function useSubscribeToChanges(identifier, onChange) {
|
|
|
179
199
|
cancelSubscription = await subscribeToChanges(identifier, onChange);
|
|
180
200
|
};
|
|
181
201
|
|
|
182
|
-
init();
|
|
202
|
+
void init();
|
|
183
203
|
return () => {
|
|
184
|
-
|
|
204
|
+
var _cancelSubscription2;
|
|
205
|
+
|
|
206
|
+
void ((_cancelSubscription2 = cancelSubscription) === null || _cancelSubscription2 === void 0 ? void 0 : _cancelSubscription2());
|
|
185
207
|
};
|
|
186
208
|
}, [identifier, onChange]);
|
|
187
209
|
}
|
|
188
210
|
|
|
211
|
+
function useMostRecentCategorySample(identifier) {
|
|
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
|
+
|
|
189
220
|
function useMostRecentQuantitySample(identifier, unit) {
|
|
190
221
|
const [lastSample, setLastSample] = (0, _react.useState)(null);
|
|
191
222
|
(0, _react.useEffect)(() => {
|
|
@@ -193,22 +224,23 @@ function useMostRecentQuantitySample(identifier, unit) {
|
|
|
193
224
|
|
|
194
225
|
const init = async () => {
|
|
195
226
|
const actualUnit = await ensureUnit(identifier, unit);
|
|
196
|
-
cancelSubscription = await subscribeToChanges(identifier, () => {
|
|
197
|
-
getMostRecentQuantitySample(identifier, actualUnit)
|
|
198
|
-
|
|
199
|
-
});
|
|
227
|
+
cancelSubscription = await subscribeToChanges(identifier, async () => {
|
|
228
|
+
const value = await getMostRecentQuantitySample(identifier, actualUnit);
|
|
229
|
+
setLastSample(value);
|
|
200
230
|
});
|
|
201
231
|
};
|
|
202
232
|
|
|
203
|
-
init();
|
|
233
|
+
void init();
|
|
204
234
|
return () => {
|
|
205
|
-
|
|
235
|
+
var _cancelSubscription3;
|
|
236
|
+
|
|
237
|
+
void ((_cancelSubscription3 = cancelSubscription) === null || _cancelSubscription3 === void 0 ? void 0 : _cancelSubscription3());
|
|
206
238
|
};
|
|
207
239
|
}, [identifier, unit]);
|
|
208
240
|
return lastSample;
|
|
209
241
|
}
|
|
210
242
|
|
|
211
|
-
const saveQuantitySample = (identifier, unit, value, options) => {
|
|
243
|
+
const saveQuantitySample = async (identifier, unit, value, options) => {
|
|
212
244
|
const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
|
|
213
245
|
const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
|
|
214
246
|
const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
|
|
@@ -233,17 +265,14 @@ const queryStatisticsForQuantity = async (identifier, options, from, to, unit) =
|
|
|
233
265
|
return response;
|
|
234
266
|
};
|
|
235
267
|
|
|
236
|
-
const requestAuthorization = (read
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
[cur]: true
|
|
245
|
-
};
|
|
246
|
-
}, {});
|
|
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
|
+
}), {});
|
|
247
276
|
return _nativeTypes.default.requestAuthorization(writePermissions, readPermissions);
|
|
248
277
|
};
|
|
249
278
|
|
|
@@ -252,17 +281,14 @@ const getDateOfBirth = async () => {
|
|
|
252
281
|
return new Date(dateOfBirth);
|
|
253
282
|
};
|
|
254
283
|
|
|
255
|
-
const getRequestStatusForAuthorization = (read
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
[cur]: true
|
|
264
|
-
};
|
|
265
|
-
}, {});
|
|
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
|
+
}), {});
|
|
266
292
|
return _nativeTypes.default.getRequestStatusForAuthorization(writePermissions, readPermissions);
|
|
267
293
|
};
|
|
268
294
|
|
|
@@ -272,36 +298,6 @@ const queryCategorySamples = async (identifier, options) => {
|
|
|
272
298
|
return results.map(deserializCategorySample);
|
|
273
299
|
};
|
|
274
300
|
|
|
275
|
-
async function getPreferredUnitsTyped(options) {
|
|
276
|
-
let energyUnit = options === null || options === void 0 ? void 0 : options.energyUnit;
|
|
277
|
-
let distanceUnit = options === null || options === void 0 ? void 0 : options.distanceUnit;
|
|
278
|
-
|
|
279
|
-
if (!energyUnit || !distanceUnit) {
|
|
280
|
-
const units = await _nativeTypes.default.getPreferredUnits([_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning, _nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned]);
|
|
281
|
-
|
|
282
|
-
if (!energyUnit) {
|
|
283
|
-
energyUnit = units[_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning];
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (!distanceUnit) {
|
|
287
|
-
distanceUnit = units[_nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned];
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (!energyUnit) {
|
|
292
|
-
energyUnit = _nativeTypes.HKUnit.Kilocalories;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (!distanceUnit) {
|
|
296
|
-
distanceUnit = _nativeTypes.HKUnit.Meters;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return {
|
|
300
|
-
energyUnit,
|
|
301
|
-
distanceUnit
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
|
|
305
301
|
const queryWorkouts = async options => {
|
|
306
302
|
const {
|
|
307
303
|
energyUnit,
|
|
@@ -322,7 +318,7 @@ const getMostRecentWorkout = async options => {
|
|
|
322
318
|
return workouts[0];
|
|
323
319
|
};
|
|
324
320
|
|
|
325
|
-
function saveCategorySample(identifier, value, options) {
|
|
321
|
+
async function saveCategorySample(identifier, value, options) {
|
|
326
322
|
const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
|
|
327
323
|
const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
|
|
328
324
|
const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
|
|
@@ -334,13 +330,12 @@ const getPreferredUnits = async identifiers => {
|
|
|
334
330
|
return identifiers.map(i => units[i]);
|
|
335
331
|
};
|
|
336
332
|
|
|
337
|
-
const buildUnitWithPrefix = (prefix, unit) => {
|
|
338
|
-
return `${prefix}${unit}`;
|
|
339
|
-
};
|
|
333
|
+
const buildUnitWithPrefix = (prefix, unit) => `${prefix}${unit}`;
|
|
340
334
|
|
|
341
335
|
function deserializeCorrelation(s) {
|
|
342
336
|
return { ...s,
|
|
343
337
|
objects: s.objects.map(o => {
|
|
338
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
344
339
|
// @ts-ignore
|
|
345
340
|
if (o.quantity !== undefined) {
|
|
346
341
|
return deserializeSample(o);
|
|
@@ -369,25 +364,27 @@ const saveCorrelationSample = async (typeIdentifier, samples, options) => {
|
|
|
369
364
|
return _nativeTypes.default.saveCorrelationSample(typeIdentifier, samples, start, end, ensureMetadata(options === null || options === void 0 ? void 0 : options.metadata));
|
|
370
365
|
};
|
|
371
366
|
|
|
372
|
-
const saveWorkoutSample = (typeIdentifier, quantities, _start, options) => {
|
|
367
|
+
const saveWorkoutSample = async (typeIdentifier, quantities, _start, options) => {
|
|
373
368
|
const start = _start.toISOString();
|
|
374
369
|
|
|
375
370
|
const end = ((options === null || options === void 0 ? void 0 : options.end) || new Date()).toISOString();
|
|
376
371
|
return _nativeTypes.default.saveWorkoutSample(typeIdentifier, quantities, start, end, ensureMetadata(options === null || options === void 0 ? void 0 : options.metadata));
|
|
377
372
|
};
|
|
378
373
|
|
|
374
|
+
const getWorkoutRoutes = async workoutUUID => _nativeTypes.default.getWorkoutRoutes(workoutUUID);
|
|
375
|
+
|
|
379
376
|
const Healthkit = {
|
|
380
|
-
authorizationStatusFor: _nativeTypes.default.authorizationStatusFor,
|
|
381
|
-
isHealthDataAvailable: _nativeTypes.default.isHealthDataAvailable,
|
|
377
|
+
authorizationStatusFor: _nativeTypes.default.authorizationStatusFor.bind(_nativeTypes.default),
|
|
378
|
+
isHealthDataAvailable: _nativeTypes.default.isHealthDataAvailable.bind(_nativeTypes.default),
|
|
382
379
|
buildUnitWithPrefix,
|
|
383
380
|
disableAllBackgroundDelivery: _nativeTypes.default.disableAllBackgroundDelivery,
|
|
384
381
|
disableBackgroundDelivery: _nativeTypes.default.disableBackgroundDelivery,
|
|
385
382
|
enableBackgroundDelivery: _nativeTypes.default.enableBackgroundDelivery,
|
|
386
383
|
// simple convenience getters
|
|
387
|
-
getBiologicalSex: _nativeTypes.default.getBiologicalSex,
|
|
388
|
-
getFitzpatrickSkinType: _nativeTypes.default.getFitzpatrickSkinType,
|
|
384
|
+
getBiologicalSex: _nativeTypes.default.getBiologicalSex.bind(_nativeTypes.default),
|
|
385
|
+
getFitzpatrickSkinType: _nativeTypes.default.getFitzpatrickSkinType.bind(_nativeTypes.default),
|
|
389
386
|
getWheelchairUse: _nativeTypes.default.getWheelchairUse,
|
|
390
|
-
getBloodType: _nativeTypes.default.getBloodType,
|
|
387
|
+
getBloodType: _nativeTypes.default.getBloodType.bind(_nativeTypes.default),
|
|
391
388
|
getDateOfBirth,
|
|
392
389
|
getMostRecentQuantitySample,
|
|
393
390
|
getMostRecentCategorySample,
|
|
@@ -395,6 +392,7 @@ const Healthkit = {
|
|
|
395
392
|
getPreferredUnit,
|
|
396
393
|
getPreferredUnits,
|
|
397
394
|
getRequestStatusForAuthorization,
|
|
395
|
+
getWorkoutRoutes,
|
|
398
396
|
// query methods
|
|
399
397
|
queryCategorySamples,
|
|
400
398
|
queryCorrelationSamples,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ios.tsx"],"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","subscribeToChanges","callback","subscription","EventEmitter","addListener","typeIdentifier","queryId","subscribeToObserverQuery","catch","error","remove","Promise","reject","unsubscribeQuery","getMostRecentQuantitySample","samples","useMostRecentWorkout","workout","setWorkout","cancelSubscription","init","energyUnit","distanceUnit","getPreferredUnitsTyped","getMostRecentWorkout","then","getMostRecentCategorySample","queryCategorySamples","useMostRecentCategorySample","category","setCategory","updater","useSubscribeToChanges","onChange","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","units","HKQuantityTypeIdentifier","distanceWalkingRunning","activeEnergyBurned","HKUnit","Kilocalories","Meters","queryWorkouts","workouts","queryWorkoutSamples","saveCategorySample","identifiers","i","buildUnitWithPrefix","prefix","deserializeCorrelation","s","objects","o","quantity","undefined","ensureMetadata","queryCorrelationSamples","correlations","saveCorrelationSample","saveWorkoutSample","quantities","_start","Healthkit","authorizationStatusFor","isHealthDataAvailable","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType"],"mappings":";;;;;;;;AAAA;;AACA;;AA0kBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AADA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AAjiBA,MAAMA,gBAAoC,GAAG,MAAOC,IAAP,IAAgB;AAC3D,QAAM,CAACC,IAAD,IAAS,MAAMC,iBAAiB,CAAC,CAACF,IAAD,CAAD,CAAtC;AACA,SAAOC,IAAP;AACD,CAHD;;AAKA,MAAME,UAAU,GAAG,OACjBH,IADiB,EAEjBI,YAFiB,KAGd;AACH,MAAIA,YAAJ,EAAkB;AAChB,WAAOA,YAAP;AACD;;AACD,QAAMH,IAAI,GAAG,MAAMI,qBAAOH,iBAAP,CAAyB,CAACF,IAAD,CAAzB,CAAnB;AACA,SAAOC,IAAI,CAACD,IAAD,CAAX;AACD,CATD;;AAWA,SAASM,iBAAT,CAIEC,MAJF,EAKwC;AACtC,SAAO,EACL,GAAGA,MADE;AAELC,IAAAA,SAAS,EAAE,IAAIC,IAAJ,CAASF,MAAM,CAACC,SAAhB,CAFN;AAGLE,IAAAA,OAAO,EAAE,IAAID,IAAJ,CAASF,MAAM,CAACG,OAAhB;AAHJ,GAAP;AAKD;;AAED,SAASC,kBAAT,CACEJ,MADF,EAEiC;AAC/B,SAAO,EACL,GAAGA,MADE;AAELC,IA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\nimport Native, {\n EventEmitter,\n HKCategorySampleRaw,\n HKCategoryTypeIdentifier,\n HKCategoryValueForIdentifier,\n HKCharacteristicTypeIdentifier,\n HKCorrelationRaw,\n HKCorrelationTypeIdentifier,\n HKQuantitySampleRaw,\n HKQuantityTypeIdentifier,\n HKSampleTypeIdentifier,\n HKUnit,\n HKUnitSI,\n HKUnitSIPrefix,\n HKWorkoutRaw,\n MetadataMapperForCategoryIdentifier,\n} from './native-types';\nimport type {\n GenericQueryOptions,\n GetMostRecentCategorySampleFn,\n GetMostRecentQuantitySampleFn,\n GetMostRecentWorkoutFn,\n GetPreferredUnitFn,\n GetPreferredUnitsFn,\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 return {\n ...sample,\n startDate: new Date(sample.startDate),\n endDate: new Date(sample.endDate),\n };\n};\n\nconst serializeDate = (date?: Date | null): string => {\n return date ? date.toISOString() : new Date(0).toISOString();\n};\n\nconst prepareOptions = (options: GenericQueryOptions) => {\n const limit =\n !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 { limit, ascending, from, to };\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\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 (error) => {\n subscription.remove();\n return Promise.reject(error);\n }\n );\n\n return () => {\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: unit,\n });\n return samples[0];\n};\n\nfunction useMostRecentWorkout<\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(options?: { energyUnit?: TEnergy; 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 () => {\n getMostRecentWorkout({ energyUnit, distanceUnit }).then(setWorkout);\n }\n );\n };\n init();\n return () => {\n cancelSubscription && 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 useMostRecentCategorySample<\n TCategory extends HKCategoryTypeIdentifier\n>(identifier: TCategory) {\n const [category, setCategory] = useState<HKCategorySample<TCategory> | null>(\n null\n );\n const updater = useCallback(() => {\n getMostRecentCategorySample(identifier).then(setCategory);\n }, [identifier]);\n\n useSubscribeToChanges(identifier, updater);\n\n return category;\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 init();\n\n return () => {\n cancelSubscription && cancelSubscription();\n };\n }, [identifier, onChange]);\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, () => {\n getMostRecentQuantitySample(identifier, actualUnit).then((value) => {\n setLastSample(value);\n });\n });\n };\n init();\n\n return () => {\n cancelSubscription && cancelSubscription();\n };\n }, [identifier, unit]);\n\n return lastSample;\n}\n\nconst saveQuantitySample: SaveQuantitySampleFn = (\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 {\n mostRecentQuantityDateInterval,\n ...rawResponse\n } = 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 = (\n read: (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],\n write: HKSampleTypeIdentifier[] = []\n): Promise<boolean> => {\n const readPermissions = read.reduce((obj, cur) => {\n return { ...obj, [cur]: true };\n }, {});\n\n const writePermissions = write.reduce((obj, cur) => {\n return { ...obj, [cur]: true };\n }, {});\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 = (\n read: (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],\n write: HKSampleTypeIdentifier[] = []\n) => {\n const readPermissions = read.reduce((obj, cur) => {\n return { ...obj, [cur]: true };\n }, {});\n\n const writePermissions = write.reduce((obj, cur) => {\n return { ...obj, [cur]: true };\n }, {});\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\nasync function getPreferredUnitsTyped<\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(options?: { energyUnit?: TEnergy; 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 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\nfunction saveCategorySample<T extends HKCategoryTypeIdentifier>(\n identifier: T,\n value: HKCategoryValueForIdentifier<T>,\n options?: {\n start?: Date;\n end?: Date;\n 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) => {\n return `${prefix}${unit}` as HKUnit;\n};\n\nfunction deserializeCorrelation<\n TIdentifier extends HKCorrelationTypeIdentifier\n>(s: HKCorrelationRaw<TIdentifier>): HKCorrelation<TIdentifier> {\n return {\n ...s,\n objects: s.objects.map((o) => {\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 = (\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 Healthkit: ReactNativeHealthkit = {\n authorizationStatusFor: Native.authorizationStatusFor,\n\n isHealthDataAvailable: Native.isHealthDataAvailable,\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,\n getFitzpatrickSkinType: Native.getFitzpatrickSkinType,\n getWheelchairUse: Native.getWheelchairUse,\n getBloodType: Native.getBloodType,\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\nexport * from './types';\nexport * from './native-types';\n\nexport default Healthkit;\n"]}
|
|
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"],"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 HKCategorySampleRaw,\n HKCategoryTypeIdentifier,\n HKCategoryValueForIdentifier,\n HKCharacteristicTypeIdentifier,\n HKCorrelationRaw,\n HKCorrelationTypeIdentifier,\n HKQuantitySampleRaw,\n HKSampleTypeIdentifier,\n HKUnitSI,\n HKUnitSIPrefix,\n HKWorkoutRaw,\n MetadataMapperForCategoryIdentifier,\n ReadPermissions,\n WritePermissions,\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 (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],\n write: readonly HKSampleTypeIdentifier[] = [],\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 (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],\n write: readonly HKSampleTypeIdentifier[] = [],\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\nexport * from './native-types'\nexport * from './types'\n\nexport default Healthkit\n"],"mappings":";;;;;;;;AAAA;;AAEA;;AAokBA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;AAvhBA,MAAMA,gBAAoC,GAAG,MAAOC,IAAP,IAAgB;EAC3D,MAAM,CAACC,IAAD,IAAS,MAAMC,iBAAiB,CAAC,CAACF,IAAD,CAAD,CAAtC;EACA,OAAOC,IAAP;AACD,CAHD;;AAKA,MAAME,UAAU,GAAG,OACjBH,IADiB,EAEjBI,YAFiB,KAGd;EACH,IAAIA,YAAJ,EAAkB;IAChB,OAAOA,YAAP;EACD;;EACD,MAAMH,IAAI,GAAG,MAAMI,oBAAA,CAAOH,iBAAP,CAAyB,CAACF,IAAD,CAAzB,CAAnB;EACA,OAAOC,IAAI,CAACD,IAAD,CAAX;AACD,CATD;;AAWA,SAASM,iBAAT,CAIEC,MAJF,EAKwC;EACtC,OAAO,EACL,GAAGA,MADE;IAELC,SAAS,EAAE,IAAIC,IAAJ,CAASF,MAAM,CAACC,SAAhB,CAFN;IAGLE,OAAO,EAAE,IAAID,IAAJ,CAASF,MAAM,CAACG,OAAhB;EAHJ,CAAP;AAKD;;AAED,SAASC,kBAAT,CACEJ,MADF,EAEiC;EAC/B,OAAO,EACL,GAAGA,MADE;IAELC,SAAS,EAAE,IAAIC,IAAJ,CAASF,MAAM,CAACC,SAAhB,CAFN;IAGLE,OAAO,EAAE,IAAID,IAAJ,CAASF,MAAM,CAACG,OAAhB;EAHJ,CAAP;AAKD;;AAED,MAAME,wBAAwB,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KtCoG,mBALsC;EAOtCqB,4BAA4B,EAAEzH,oBAAA,CAAOyH,4BAPC;EAQtCC,yBAAyB,EAAE1H,oBAAA,CAAO0H,yBARI;EAStCC,wBAAwB,EAAE3H,oBAAA,CAAO2H,wBATK;EAWtC;EACAC,gBAAgB,EAAE5H,oBAAA,CAAO4H,gBAAP,CAAwBL,IAAxB,CAA6BvH,oBAA7B,CAZoB;EAatC6H,sBAAsB,EAAE7H,oBAAA,CAAO6H,sBAAP,CAA8BN,IAA9B,CAAmCvH,oBAAnC,CAbc;EActC8H,gBAAgB,EAAE9H,oBAAA,CAAO8H,gBAda;EAetCC,YAAY,EAAE/H,oBAAA,CAAO+H,YAAP,CAAoBR,IAApB,CAAyBvH,oBAAzB,CAfwB;EAgBtC0F,cAhBsC;EAkBtC3C,2BAlBsC;EAmBtCW,2BAnBsC;EAoBtCD,oBApBsC;EAsBtC/D,gBAtBsC;EAuBtCG,iBAvBsC;EAwBtC+F,gCAxBsC;EA0BtCuB,gBA1BsC;EA4BtC;EACAxD,oBA7BsC;EA8BtCkD,uBA9BsC;EA+BtC3F,oBA/BsC;EAgCtC2D,0BAhCsC;EAiCtCiB,aAjCsC;EAmCtCZ,oBAnCsC;EAqCtC;EACAe,kBAtCsC;EAuCtCc,qBAvCsC;EAwCtCtC,kBAxCsC;EAyCtCuC,iBAzCsC;EA2CtC;EACA/E,kBA5CsC;EA8CtC;EACA6B,2BA/CsC;EAiDtCM,2BAjDsC;EAkDtCnB,oBAlDsC;EAoDtCW;AApDsC,CAAxC;eA0DeyD,S"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -8,34 +8,34 @@ exports.default = void 0;
|
|
|
8
8
|
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _nativeTypes = require("./native-types");
|
|
12
12
|
|
|
13
|
-
Object.keys(
|
|
13
|
+
Object.keys(_nativeTypes).forEach(function (key) {
|
|
14
14
|
if (key === "default" || key === "__esModule") return;
|
|
15
15
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
-
if (key in exports && exports[key] ===
|
|
16
|
+
if (key in exports && exports[key] === _nativeTypes[key]) return;
|
|
17
17
|
Object.defineProperty(exports, key, {
|
|
18
18
|
enumerable: true,
|
|
19
19
|
get: function () {
|
|
20
|
-
return
|
|
20
|
+
return _nativeTypes[key];
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var _types = require("./types");
|
|
26
26
|
|
|
27
|
-
Object.keys(
|
|
27
|
+
Object.keys(_types).forEach(function (key) {
|
|
28
28
|
if (key === "default" || key === "__esModule") return;
|
|
29
29
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
30
|
-
if (key in exports && exports[key] ===
|
|
30
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
31
31
|
Object.defineProperty(exports, key, {
|
|
32
32
|
enumerable: true,
|
|
33
33
|
get: function () {
|
|
34
|
-
return
|
|
34
|
+
return _types[key];
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
-
const notAvailableError =
|
|
38
|
+
const notAvailableError = `Platform "${_reactNative.Platform.OS}" not supported, use isHealthDataAvailable to check for availability before using it`;
|
|
39
39
|
|
|
40
40
|
const UnavailableFn = () => {
|
|
41
41
|
throw new Error(notAvailableError);
|
|
@@ -58,7 +58,8 @@ const Healthkit = {
|
|
|
58
58
|
getPreferredUnits: UnavailableFn,
|
|
59
59
|
getRequestStatusForAuthorization: UnavailableFn,
|
|
60
60
|
getWheelchairUse: UnavailableFn,
|
|
61
|
-
|
|
61
|
+
getWorkoutRoutes: UnavailableFn,
|
|
62
|
+
isHealthDataAvailable: async () => Promise.resolve(false),
|
|
62
63
|
queryCategorySamples: UnavailableFn,
|
|
63
64
|
queryCorrelationSamples: UnavailableFn,
|
|
64
65
|
queryQuantitySamples: UnavailableFn,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["notAvailableError","Platform","OS","UnavailableFn","Error","Healthkit","authorizationStatusFor","buildUnitWithPrefix","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getBloodType","getDateOfBirth","getFitzpatrickSkinType","getMostRecentCategorySample","getMostRecentQuantitySample","getMostRecentWorkout","getPreferredUnit","getPreferredUnits","getRequestStatusForAuthorization","getWheelchairUse","getWorkoutRoutes","isHealthDataAvailable","Promise","resolve","queryCategorySamples","queryCorrelationSamples","queryQuantitySamples","queryStatisticsForQuantity","queryWorkouts","requestAuthorization","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges"],"sources":["index.tsx"],"sourcesContent":["import { Platform } from 'react-native'\n\nimport type { ReactNativeHealthkit } from './types'\n\nconst notAvailableError = `Platform \"${\n Platform.OS\n}\" not supported, use isHealthDataAvailable to check for availability before using it`\n\nconst UnavailableFn = () => {\n throw new Error(notAvailableError)\n}\n\nconst Healthkit: ReactNativeHealthkit = {\n authorizationStatusFor: UnavailableFn,\n buildUnitWithPrefix: UnavailableFn,\n disableAllBackgroundDelivery: UnavailableFn,\n disableBackgroundDelivery: UnavailableFn,\n enableBackgroundDelivery: UnavailableFn,\n getBiologicalSex: UnavailableFn,\n getBloodType: UnavailableFn,\n getDateOfBirth: UnavailableFn,\n getFitzpatrickSkinType: UnavailableFn,\n getMostRecentCategorySample: UnavailableFn,\n getMostRecentQuantitySample: UnavailableFn,\n getMostRecentWorkout: UnavailableFn,\n getPreferredUnit: UnavailableFn,\n getPreferredUnits: UnavailableFn,\n getRequestStatusForAuthorization: UnavailableFn,\n getWheelchairUse: UnavailableFn,\n getWorkoutRoutes: UnavailableFn,\n isHealthDataAvailable: async () => Promise.resolve(false),\n queryCategorySamples: UnavailableFn,\n queryCorrelationSamples: UnavailableFn,\n queryQuantitySamples: UnavailableFn,\n queryStatisticsForQuantity: UnavailableFn,\n queryWorkouts: UnavailableFn,\n requestAuthorization: UnavailableFn,\n saveCategorySample: UnavailableFn,\n saveCorrelationSample: UnavailableFn,\n saveQuantitySample: UnavailableFn,\n saveWorkoutSample: UnavailableFn,\n subscribeToChanges: UnavailableFn,\n useMostRecentCategorySample: UnavailableFn,\n useMostRecentQuantitySample: UnavailableFn,\n useMostRecentWorkout: UnavailableFn,\n useSubscribeToChanges: UnavailableFn,\n}\n\nexport * from './native-types'\nexport * from './types'\n\nexport default Healthkit\n"],"mappings":";;;;;;;;AAAA;;AAgDA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AA7CA,MAAMA,iBAAiB,GAAI,aACzBC,qBAAA,CAASC,EACV,sFAFD;;AAIA,MAAMC,aAAa,GAAG,MAAM;EAC1B,MAAM,IAAIC,KAAJ,CAAUJ,iBAAV,CAAN;AACD,CAFD;;AAIA,MAAMK,SAA+B,GAAG;EACtCC,sBAAsB,EAAEH,aADc;EAEtCI,mBAAmB,EAAEJ,aAFiB;EAGtCK,4BAA4B,EAAEL,aAHQ;EAItCM,yBAAyB,EAAEN,aAJW;EAKtCO,wBAAwB,EAAEP,aALY;EAMtCQ,gBAAgB,EAAER,aANoB;EAOtCS,YAAY,EAAET,aAPwB;EAQtCU,cAAc,EAAEV,aARsB;EAStCW,sBAAsB,EAAEX,aATc;EAUtCY,2BAA2B,EAAEZ,aAVS;EAWtCa,2BAA2B,EAAEb,aAXS;EAYtCc,oBAAoB,EAAEd,aAZgB;EAatCe,gBAAgB,EAAEf,aAboB;EActCgB,iBAAiB,EAAEhB,aAdmB;EAetCiB,gCAAgC,EAAEjB,aAfI;EAgBtCkB,gBAAgB,EAAElB,aAhBoB;EAiBtCmB,gBAAgB,EAAEnB,aAjBoB;EAkBtCoB,qBAAqB,EAAE,YAAYC,OAAO,CAACC,OAAR,CAAgB,KAAhB,CAlBG;EAmBtCC,oBAAoB,EAAEvB,aAnBgB;EAoBtCwB,uBAAuB,EAAExB,aApBa;EAqBtCyB,oBAAoB,EAAEzB,aArBgB;EAsBtC0B,0BAA0B,EAAE1B,aAtBU;EAuBtC2B,aAAa,EAAE3B,aAvBuB;EAwBtC4B,oBAAoB,EAAE5B,aAxBgB;EAyBtC6B,kBAAkB,EAAE7B,aAzBkB;EA0BtC8B,qBAAqB,EAAE9B,aA1Be;EA2BtC+B,kBAAkB,EAAE/B,aA3BkB;EA4BtCgC,iBAAiB,EAAEhC,aA5BmB;EA6BtCiC,kBAAkB,EAAEjC,aA7BkB;EA8BtCkC,2BAA2B,EAAElC,aA9BS;EA+BtCmC,2BAA2B,EAAEnC,aA/BS;EAgCtCoC,oBAAoB,EAAEpC,aAhCgB;EAiCtCqC,qBAAqB,EAAErC;AAjCe,CAAxC;eAuCeE,S"}
|
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.
|
|
6
|
+
exports.default = exports.HKWorkoutTypeIdentifier = exports.HKWorkoutRouteTypeIdentifier = exports.HKWorkoutActivityType = exports.HKWheelchairUse = exports.HKWeatherCondition = exports.HKUpdateFrequency = exports.HKUnitSIPrefix = exports.HKUnitSI = exports.HKUnit = exports.HKStatisticsOptions = exports.HKQuantityTypeIdentifier = exports.HKInsulinDeliveryReason = exports.HKHeartRateMotionContext = exports.HKFitzpatrickSkinType = exports.HKDataTypeIdentifierHeartbeatSeries = exports.HKCorrelationTypeIdentifier = exports.HKCharacteristicTypeIdentifier = exports.HKCategoryValueSleepAnalysis = exports.HKCategoryValueSeverity = exports.HKCategoryValuePresence = exports.HKCategoryValueOvulationTestResult = exports.HKCategoryValueNotApplicable = exports.HKCategoryValueMenstrualFlow = exports.HKCategoryValueCervicalMucusQuality = exports.HKCategoryValueAppleStandHour = exports.HKCategoryValueAppetiteChanges = exports.HKCategoryTypeIdentifier = exports.HKBloodType = exports.HKBiologicalSex = exports.HKAuthorizationStatus = exports.HKAuthorizationRequestStatus = exports.HKAudiogramTypeIdentifier = exports.EventEmitter = void 0;
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
+
const HKWorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier';
|
|
11
|
+
exports.HKWorkoutTypeIdentifier = HKWorkoutTypeIdentifier;
|
|
12
|
+
const HKAudiogramTypeIdentifier = 'HKAudiogramTypeIdentifier';
|
|
13
|
+
exports.HKAudiogramTypeIdentifier = HKAudiogramTypeIdentifier;
|
|
14
|
+
const HKWorkoutRouteTypeIdentifier = 'HKWorkoutRouteTypeIdentifier';
|
|
15
|
+
exports.HKWorkoutRouteTypeIdentifier = HKWorkoutRouteTypeIdentifier;
|
|
16
|
+
const HKDataTypeIdentifierHeartbeatSeries = 'HKDataTypeIdentifierHeartbeatSeries';
|
|
17
|
+
exports.HKDataTypeIdentifierHeartbeatSeries = HKDataTypeIdentifierHeartbeatSeries;
|
|
10
18
|
let HKHeartRateMotionContext;
|
|
11
19
|
exports.HKHeartRateMotionContext = HKHeartRateMotionContext;
|
|
12
20
|
|
|
@@ -248,6 +256,13 @@ exports.HKQuantityTypeIdentifier = HKQuantityTypeIdentifier;
|
|
|
248
256
|
HKQuantityTypeIdentifier["dietaryPotassium"] = "HKQuantityTypeIdentifierDietaryPotassium";
|
|
249
257
|
HKQuantityTypeIdentifier["dietaryCaffeine"] = "HKQuantityTypeIdentifierDietaryCaffeine";
|
|
250
258
|
HKQuantityTypeIdentifier["dietaryWater"] = "HKQuantityTypeIdentifierDietaryWater";
|
|
259
|
+
HKQuantityTypeIdentifier["sixMinuteWalkTestDistance"] = "HKQuantityTypeIdentifierSixMinuteWalkTestDistance";
|
|
260
|
+
HKQuantityTypeIdentifier["walkingSpeed"] = "HKQuantityTypeIdentifierWalkingSpeed";
|
|
261
|
+
HKQuantityTypeIdentifier["walkingStepLength"] = "HKQuantityTypeIdentifierWalkingStepLength";
|
|
262
|
+
HKQuantityTypeIdentifier["walkingAsymmetryPercentage"] = "HKQuantityTypeIdentifierWalkingAsymmetryPercentage";
|
|
263
|
+
HKQuantityTypeIdentifier["walkingDoubleSupportPercentage"] = "HKQuantityTypeIdentifierWalkingDoubleSupportPercentage";
|
|
264
|
+
HKQuantityTypeIdentifier["stairAscentSpeed"] = "HKQuantityTypeIdentifierStairAscentSpeed";
|
|
265
|
+
HKQuantityTypeIdentifier["stairDescentSpeed"] = "HKQuantityTypeIdentifierStairDescentSpeed";
|
|
251
266
|
HKQuantityTypeIdentifier["uvExposure"] = "HKQuantityTypeIdentifierUvExposure";
|
|
252
267
|
})(HKQuantityTypeIdentifier || (exports.HKQuantityTypeIdentifier = HKQuantityTypeIdentifier = {}));
|
|
253
268
|
|
|
@@ -260,6 +275,15 @@ exports.HKAuthorizationRequestStatus = HKAuthorizationRequestStatus;
|
|
|
260
275
|
HKAuthorizationRequestStatus[HKAuthorizationRequestStatus["unnecessary"] = 2] = "unnecessary";
|
|
261
276
|
})(HKAuthorizationRequestStatus || (exports.HKAuthorizationRequestStatus = HKAuthorizationRequestStatus = {}));
|
|
262
277
|
|
|
278
|
+
let HKAuthorizationStatus;
|
|
279
|
+
exports.HKAuthorizationStatus = HKAuthorizationStatus;
|
|
280
|
+
|
|
281
|
+
(function (HKAuthorizationStatus) {
|
|
282
|
+
HKAuthorizationStatus[HKAuthorizationStatus["notDetermined"] = 0] = "notDetermined";
|
|
283
|
+
HKAuthorizationStatus[HKAuthorizationStatus["sharingDenied"] = 1] = "sharingDenied";
|
|
284
|
+
HKAuthorizationStatus[HKAuthorizationStatus["sharingAuthorized"] = 2] = "sharingAuthorized";
|
|
285
|
+
})(HKAuthorizationStatus || (exports.HKAuthorizationStatus = HKAuthorizationStatus = {}));
|
|
286
|
+
|
|
263
287
|
let HKBloodType;
|
|
264
288
|
exports.HKBloodType = HKBloodType;
|
|
265
289
|
|