@kingstinct/react-native-healthkit 9.0.6 → 9.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/CharacteristicTypeModule.swift +36 -21
- package/lib/commonjs/healthkit.js +225 -0
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +1 -1
- package/lib/commonjs/index.js +6 -209
- package/lib/module/healthkit.js +203 -0
- package/lib/module/hooks/useStatisticsForQuantity.js +1 -1
- package/lib/module/index.js +3 -203
- package/lib/typescript/healthkit.d.ts +69 -0
- package/lib/typescript/{index.ios.d.ts → healthkit.ios.d.ts} +11 -11
- package/lib/typescript/hooks/useHealthkitAuthorization.d.ts +1 -1
- package/lib/typescript/index.d.ts +3 -69
- package/lib/typescript/specs/CategoryTypeModule.nitro.d.ts +1 -1
- package/lib/typescript/specs/CharacteristicTypeModule.nitro.d.ts +2 -2
- package/lib/typescript/specs/CoreModule.nitro.d.ts +3 -3
- package/lib/typescript/types/Shared.d.ts +3 -3
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +4 -4
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +30 -30
- package/nitrogen/generated/ios/c++/HybridCharacteristicTypeModuleSpecSwift.hpp +3 -2
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__chrono__system_clock__time_point_.swift +52 -0
- package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec.swift +2 -2
- package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec_cxx.swift +23 -11
- package/nitrogen/generated/shared/c++/HybridCharacteristicTypeModuleSpec.hpp +3 -2
- package/package.json +1 -1
- package/src/healthkit.ts +422 -0
- package/src/hooks/useHealthkitAuthorization.ts +2 -2
- package/src/hooks/useStatisticsForQuantity.ts +1 -3
- package/src/index.ts +3 -419
- package/src/specs/CategoryTypeModule.nitro.ts +1 -1
- package/src/specs/CharacteristicTypeModule.nitro.ts +2 -2
- package/src/specs/CoreModule.nitro.ts +5 -5
- package/src/test-setup.ts +0 -1
- package/src/types/QueryOptions.ts +3 -3
- package/src/types/Shared.ts +6 -8
- package/nitrogen/generated/ios/swift/Func_void_std__chrono__system_clock__time_point.swift +0 -46
- /package/lib/commonjs/{index.ios.js → healthkit.ios.js} +0 -0
- /package/lib/module/{index.ios.js → healthkit.ios.js} +0 -0
- /package/src/{index.ios.ts → healthkit.ios.ts} +0 -0
package/src/index.ts
CHANGED
|
@@ -1,421 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import HealthKit from './healthkit'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// These types are expected to be available via the './types' export.
|
|
5
|
-
// You might need to adjust the import path or ensure these types are correctly exported from './types'
|
|
3
|
+
export * from './healthkit'
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
// It assumes that index.ios.ts exports a default object matching the Healthkit native module structure.
|
|
9
|
-
import type ReactNativeHealthkit from './index.ios'
|
|
10
|
-
import type { WorkoutProxy } from './specs/WorkoutProxy.nitro'
|
|
11
|
-
import { AuthorizationRequestStatus, AuthorizationStatus } from './types/Auth'
|
|
12
|
-
import type {
|
|
13
|
-
CategorySampleTyped,
|
|
14
|
-
CategorySamplesWithAnchorResponseTyped,
|
|
15
|
-
} from './types/CategoryType'
|
|
16
|
-
import type { CategoryTypeIdentifier } from './types/CategoryTypeIdentifier'
|
|
17
|
-
import {
|
|
18
|
-
BiologicalSex,
|
|
19
|
-
BloodType,
|
|
20
|
-
FitzpatrickSkinType,
|
|
21
|
-
WheelchairUse,
|
|
22
|
-
} from './types/Characteristics'
|
|
23
|
-
import type { QuantitySample } from './types/QuantitySample'
|
|
24
|
-
export * from './types'
|
|
25
|
-
|
|
26
|
-
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${Platform.OS}" not supported. HealthKit is only available on iOS.`
|
|
27
|
-
|
|
28
|
-
let hasWarned = false
|
|
29
|
-
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
function UnavailableFnFromModule<
|
|
32
|
-
TKey extends keyof typeof ReactNativeHealthkit,
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
35
|
-
T extends Function = (typeof ReactNativeHealthkit)[TKey],
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
>(fn: TKey, defaultValue: ReturnType<T>): T {
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
return () => {
|
|
40
|
-
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
41
|
-
console.warn(notAvailableError)
|
|
42
|
-
hasWarned = true
|
|
43
|
-
}
|
|
44
|
-
return defaultValue
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// --- Mock Implementations for exported functions ---
|
|
49
|
-
|
|
50
|
-
// CoreModule functions
|
|
51
|
-
export const authorizationStatusFor = UnavailableFnFromModule(
|
|
52
|
-
'authorizationStatusFor',
|
|
53
|
-
AuthorizationStatus.notDetermined,
|
|
54
|
-
)
|
|
55
|
-
export const disableAllBackgroundDelivery = UnavailableFnFromModule(
|
|
56
|
-
'disableAllBackgroundDelivery',
|
|
57
|
-
Promise.resolve(false),
|
|
58
|
-
)
|
|
59
|
-
export const disableBackgroundDelivery = UnavailableFnFromModule(
|
|
60
|
-
'disableBackgroundDelivery',
|
|
61
|
-
Promise.resolve(false),
|
|
62
|
-
)
|
|
63
|
-
export const enableBackgroundDelivery = UnavailableFnFromModule(
|
|
64
|
-
'enableBackgroundDelivery',
|
|
65
|
-
Promise.resolve(false),
|
|
66
|
-
)
|
|
67
|
-
export const getPreferredUnits = UnavailableFnFromModule(
|
|
68
|
-
'getPreferredUnits',
|
|
69
|
-
Promise.resolve([]),
|
|
70
|
-
)
|
|
71
|
-
export const getRequestStatusForAuthorization = UnavailableFnFromModule(
|
|
72
|
-
'getRequestStatusForAuthorization',
|
|
73
|
-
Promise.resolve(AuthorizationRequestStatus.unknown),
|
|
74
|
-
)
|
|
75
|
-
export const isHealthDataAvailable = UnavailableFnFromModule(
|
|
76
|
-
'isHealthDataAvailable',
|
|
77
|
-
false,
|
|
78
|
-
) // Original was synchronous
|
|
79
|
-
export const isHealthDataAvailableAsync = UnavailableFnFromModule(
|
|
80
|
-
'isHealthDataAvailableAsync',
|
|
81
|
-
Promise.resolve(false),
|
|
82
|
-
) // Added for consistency if needed
|
|
83
|
-
export const querySources = UnavailableFnFromModule(
|
|
84
|
-
'querySources',
|
|
85
|
-
Promise.resolve([]),
|
|
86
|
-
)
|
|
87
|
-
export const requestAuthorization = UnavailableFnFromModule(
|
|
88
|
-
'requestAuthorization',
|
|
89
|
-
Promise.resolve(false),
|
|
90
|
-
)
|
|
91
|
-
export const deleteObjects = UnavailableFnFromModule(
|
|
92
|
-
'deleteObjects',
|
|
93
|
-
Promise.resolve(0),
|
|
94
|
-
)
|
|
95
|
-
export const subscribeToChanges = UnavailableFnFromModule(
|
|
96
|
-
'subscribeToChanges',
|
|
97
|
-
'dummy-query-uuid',
|
|
98
|
-
) // Mocking the observer query UUID
|
|
99
|
-
export const isProtectedDataAvailable = UnavailableFnFromModule(
|
|
100
|
-
'isProtectedDataAvailable',
|
|
101
|
-
false,
|
|
102
|
-
)
|
|
103
|
-
export const isObjectTypeAvailable = UnavailableFnFromModule(
|
|
104
|
-
'isObjectTypeAvailable',
|
|
105
|
-
false,
|
|
106
|
-
)
|
|
107
|
-
export const isObjectTypeAvailableAsync = UnavailableFnFromModule(
|
|
108
|
-
'isObjectTypeAvailableAsync',
|
|
109
|
-
Promise.resolve(false),
|
|
110
|
-
)
|
|
111
|
-
export const areObjectTypesAvailable = UnavailableFnFromModule(
|
|
112
|
-
'areObjectTypesAvailable',
|
|
113
|
-
{},
|
|
114
|
-
)
|
|
115
|
-
export const areObjectTypesAvailableAsync = UnavailableFnFromModule(
|
|
116
|
-
'areObjectTypesAvailableAsync',
|
|
117
|
-
Promise.resolve({}),
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
// CharacteristicTypeModule functions
|
|
121
|
-
export const getBiologicalSex = UnavailableFnFromModule(
|
|
122
|
-
'getBiologicalSex',
|
|
123
|
-
BiologicalSex.notSet,
|
|
124
|
-
)
|
|
125
|
-
export const getBloodType = UnavailableFnFromModule(
|
|
126
|
-
'getBloodType',
|
|
127
|
-
BloodType.notSet,
|
|
128
|
-
)
|
|
129
|
-
export const getDateOfBirth = UnavailableFnFromModule(
|
|
130
|
-
'getDateOfBirth',
|
|
131
|
-
new Date(0),
|
|
132
|
-
) // Assuming string for date
|
|
133
|
-
export const getFitzpatrickSkinType = UnavailableFnFromModule(
|
|
134
|
-
'getFitzpatrickSkinType',
|
|
135
|
-
FitzpatrickSkinType.notSet,
|
|
136
|
-
)
|
|
137
|
-
export const getWheelchairUse = UnavailableFnFromModule(
|
|
138
|
-
'getWheelchairUse',
|
|
139
|
-
WheelchairUse.notSet,
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
// QuantityTypeModule functions
|
|
143
|
-
export const queryQuantitySamples = UnavailableFnFromModule(
|
|
144
|
-
'queryQuantitySamples',
|
|
145
|
-
Promise.resolve([]),
|
|
146
|
-
)
|
|
147
|
-
export const queryQuantitySamplesWithAnchor = UnavailableFnFromModule(
|
|
148
|
-
'queryQuantitySamplesWithAnchor',
|
|
149
|
-
Promise.resolve({
|
|
150
|
-
samples: [],
|
|
151
|
-
deletedSamples: [],
|
|
152
|
-
newAnchor: '',
|
|
153
|
-
}),
|
|
154
|
-
)
|
|
155
|
-
export const queryStatisticsForQuantity = UnavailableFnFromModule(
|
|
156
|
-
'queryStatisticsForQuantity',
|
|
157
|
-
Promise.resolve({}),
|
|
158
|
-
)
|
|
159
|
-
export const queryStatisticsCollectionForQuantity = UnavailableFnFromModule(
|
|
160
|
-
'queryStatisticsCollectionForQuantity',
|
|
161
|
-
Promise.resolve([]),
|
|
162
|
-
)
|
|
163
|
-
export const saveQuantitySample = UnavailableFnFromModule(
|
|
164
|
-
'saveQuantitySample',
|
|
165
|
-
Promise.resolve(false),
|
|
166
|
-
)
|
|
167
|
-
export const isQuantityCompatibleWithUnit = UnavailableFnFromModule(
|
|
168
|
-
'isQuantityCompatibleWithUnit',
|
|
169
|
-
false,
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
// CategoryTypeModule functions
|
|
173
|
-
export function queryCategorySamples<T extends CategoryTypeIdentifier>(
|
|
174
|
-
categoryTypeIdentifier: T,
|
|
175
|
-
): Promise<CategorySampleTyped<T>[]> {
|
|
176
|
-
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
177
|
-
console.warn(notAvailableError)
|
|
178
|
-
hasWarned = true
|
|
179
|
-
}
|
|
180
|
-
return Promise.resolve([])
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export function queryCategorySamplesWithAnchor<
|
|
184
|
-
T extends CategoryTypeIdentifier,
|
|
185
|
-
>(
|
|
186
|
-
categoryTypeIdentifier: T,
|
|
187
|
-
): Promise<CategorySamplesWithAnchorResponseTyped<T>> {
|
|
188
|
-
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
189
|
-
console.warn(notAvailableError)
|
|
190
|
-
hasWarned = true
|
|
191
|
-
}
|
|
192
|
-
return Promise.resolve({
|
|
193
|
-
samples: [],
|
|
194
|
-
deletedSamples: [],
|
|
195
|
-
newAnchor: '',
|
|
196
|
-
})
|
|
197
|
-
}
|
|
198
|
-
export const saveCategorySample = UnavailableFnFromModule(
|
|
199
|
-
'saveCategorySample',
|
|
200
|
-
Promise.resolve(false),
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
// CorrelationTypeModule functions
|
|
204
|
-
export const queryCorrelationSamples = UnavailableFnFromModule(
|
|
205
|
-
'queryCorrelationSamples',
|
|
206
|
-
Promise.resolve([]),
|
|
207
|
-
)
|
|
208
|
-
export const saveCorrelationSample = UnavailableFnFromModule(
|
|
209
|
-
'saveCorrelationSample',
|
|
210
|
-
Promise.resolve(false),
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
// HeartbeatSeriesModule functions
|
|
214
|
-
export const queryHeartbeatSeriesSamples = UnavailableFnFromModule(
|
|
215
|
-
'queryHeartbeatSeriesSamples',
|
|
216
|
-
Promise.resolve([]),
|
|
217
|
-
)
|
|
218
|
-
export const queryHeartbeatSeriesSamplesWithAnchor = UnavailableFnFromModule(
|
|
219
|
-
'queryHeartbeatSeriesSamplesWithAnchor',
|
|
220
|
-
Promise.resolve({
|
|
221
|
-
samples: [],
|
|
222
|
-
deletedSamples: [],
|
|
223
|
-
newAnchor: '',
|
|
224
|
-
}),
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
// WorkoutsModule functions
|
|
228
|
-
export const queryWorkoutSamples = UnavailableFnFromModule(
|
|
229
|
-
'queryWorkoutSamples',
|
|
230
|
-
Promise.resolve([]),
|
|
231
|
-
)
|
|
232
|
-
export const queryWorkoutSamplesWithAnchor = UnavailableFnFromModule(
|
|
233
|
-
'queryWorkoutSamplesWithAnchor',
|
|
234
|
-
Promise.resolve({
|
|
235
|
-
workouts: [],
|
|
236
|
-
deletedSamples: [],
|
|
237
|
-
newAnchor: '',
|
|
238
|
-
}),
|
|
239
|
-
)
|
|
240
|
-
export const saveWorkoutSample = UnavailableFnFromModule(
|
|
241
|
-
'saveWorkoutSample',
|
|
242
|
-
Promise.resolve(''),
|
|
243
|
-
)
|
|
244
|
-
export const startWatchApp = UnavailableFnFromModule(
|
|
245
|
-
'startWatchApp',
|
|
246
|
-
Promise.resolve(false),
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
// StateOfMindModule functions
|
|
250
|
-
export const queryStateOfMindSamples = UnavailableFnFromModule(
|
|
251
|
-
'queryStateOfMindSamples',
|
|
252
|
-
Promise.resolve([]),
|
|
253
|
-
)
|
|
254
|
-
export const saveStateOfMindSample = UnavailableFnFromModule(
|
|
255
|
-
'saveStateOfMindSample',
|
|
256
|
-
Promise.resolve(false),
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
// Utility functions (from original export list)
|
|
260
|
-
export function getMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
261
|
-
identifier: T,
|
|
262
|
-
): Promise<CategorySampleTyped<T> | undefined> {
|
|
263
|
-
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
264
|
-
console.warn(notAvailableError)
|
|
265
|
-
hasWarned = true
|
|
266
|
-
}
|
|
267
|
-
return Promise.resolve(undefined)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export const getMostRecentQuantitySample = UnavailableFnFromModule(
|
|
271
|
-
'getMostRecentQuantitySample',
|
|
272
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
273
|
-
Promise.resolve(undefined as any as QuantitySample),
|
|
274
|
-
)
|
|
275
|
-
export const getMostRecentWorkout = UnavailableFnFromModule(
|
|
276
|
-
'getMostRecentWorkout',
|
|
277
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
278
|
-
Promise.resolve(undefined as any as WorkoutProxy),
|
|
279
|
-
)
|
|
280
|
-
export const getPreferredUnit = UnavailableFnFromModule(
|
|
281
|
-
'getPreferredUnit',
|
|
282
|
-
Promise.resolve('count'),
|
|
283
|
-
) // Defaulting to 'count'
|
|
284
|
-
|
|
285
|
-
// Hooks (from original export list)
|
|
286
|
-
export function useMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
287
|
-
categoryTypeIdentifier: T,
|
|
288
|
-
): CategorySampleTyped<T> | undefined {
|
|
289
|
-
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
290
|
-
console.warn(notAvailableError)
|
|
291
|
-
hasWarned = true
|
|
292
|
-
}
|
|
293
|
-
return undefined
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export const useMostRecentQuantitySample = UnavailableFnFromModule(
|
|
297
|
-
'useMostRecentQuantitySample',
|
|
298
|
-
undefined,
|
|
299
|
-
)
|
|
300
|
-
export const useMostRecentWorkout = UnavailableFnFromModule(
|
|
301
|
-
'useMostRecentWorkout',
|
|
302
|
-
undefined,
|
|
303
|
-
)
|
|
304
|
-
export const useSubscribeToChanges = UnavailableFnFromModule(
|
|
305
|
-
'useSubscribeToChanges',
|
|
306
|
-
undefined,
|
|
307
|
-
) // Mocking callback structure
|
|
308
|
-
export const useHealthkitAuthorization = UnavailableFnFromModule(
|
|
309
|
-
'useHealthkitAuthorization',
|
|
310
|
-
[
|
|
311
|
-
AuthorizationRequestStatus.unknown,
|
|
312
|
-
() => Promise.resolve(AuthorizationRequestStatus.unknown),
|
|
313
|
-
] as const,
|
|
314
|
-
)
|
|
315
|
-
export const useIsHealthDataAvailable = UnavailableFnFromModule(
|
|
316
|
-
'useIsHealthDataAvailable',
|
|
317
|
-
false,
|
|
318
|
-
)
|
|
319
|
-
export const useSources = UnavailableFnFromModule('useSources', null)
|
|
320
|
-
export const useStatisticsForQuantity = UnavailableFnFromModule(
|
|
321
|
-
'useStatisticsForQuantity',
|
|
322
|
-
null,
|
|
323
|
-
)
|
|
324
|
-
|
|
325
|
-
export const getBiologicalSexAsync = UnavailableFnFromModule(
|
|
326
|
-
'getBiologicalSexAsync',
|
|
327
|
-
Promise.resolve(BiologicalSex.notSet),
|
|
328
|
-
)
|
|
329
|
-
export const getBloodTypeAsync = UnavailableFnFromModule(
|
|
330
|
-
'getBloodTypeAsync',
|
|
331
|
-
Promise.resolve(BloodType.notSet),
|
|
332
|
-
)
|
|
333
|
-
export const getDateOfBirthAsync = UnavailableFnFromModule(
|
|
334
|
-
'getDateOfBirthAsync',
|
|
335
|
-
Promise.resolve(new Date(0)),
|
|
336
|
-
) // Assuming string for date
|
|
337
|
-
export const getFitzpatrickSkinTypeAsync = UnavailableFnFromModule(
|
|
338
|
-
'getFitzpatrickSkinTypeAsync',
|
|
339
|
-
Promise.resolve(FitzpatrickSkinType.notSet),
|
|
340
|
-
)
|
|
341
|
-
export const getWheelchairUseAsync = UnavailableFnFromModule(
|
|
342
|
-
'getWheelchairUseAsync',
|
|
343
|
-
Promise.resolve(WheelchairUse.notSet),
|
|
344
|
-
)
|
|
345
|
-
|
|
346
|
-
export const unsubscribeQueries = UnavailableFnFromModule(
|
|
347
|
-
'unsubscribeQueries',
|
|
348
|
-
0,
|
|
349
|
-
)
|
|
350
|
-
|
|
351
|
-
// --- Default Export ---
|
|
352
|
-
// This attempts to match the structure of the default export from index.ios.ts
|
|
353
|
-
const HealthkitModule = {
|
|
354
|
-
// All named exports are also part of the default export object
|
|
355
|
-
authorizationStatusFor,
|
|
356
|
-
isObjectTypeAvailable,
|
|
357
|
-
unsubscribeQueries,
|
|
358
|
-
isObjectTypeAvailableAsync,
|
|
359
|
-
areObjectTypesAvailable,
|
|
360
|
-
areObjectTypesAvailableAsync,
|
|
361
|
-
isQuantityCompatibleWithUnit,
|
|
362
|
-
disableAllBackgroundDelivery,
|
|
363
|
-
disableBackgroundDelivery,
|
|
364
|
-
enableBackgroundDelivery,
|
|
365
|
-
getBiologicalSex,
|
|
366
|
-
getBloodType,
|
|
367
|
-
getDateOfBirth,
|
|
368
|
-
getFitzpatrickSkinType,
|
|
369
|
-
getMostRecentCategorySample,
|
|
370
|
-
getMostRecentQuantitySample,
|
|
371
|
-
getMostRecentWorkout,
|
|
372
|
-
getPreferredUnits,
|
|
373
|
-
getPreferredUnit,
|
|
374
|
-
getRequestStatusForAuthorization,
|
|
375
|
-
getWheelchairUse,
|
|
376
|
-
isHealthDataAvailable,
|
|
377
|
-
isHealthDataAvailableAsync,
|
|
378
|
-
queryCategorySamples,
|
|
379
|
-
queryCategorySamplesWithAnchor,
|
|
380
|
-
queryCorrelationSamples,
|
|
381
|
-
queryHeartbeatSeriesSamples,
|
|
382
|
-
queryHeartbeatSeriesSamplesWithAnchor,
|
|
383
|
-
queryQuantitySamples,
|
|
384
|
-
queryQuantitySamplesWithAnchor,
|
|
385
|
-
queryStatisticsForQuantity,
|
|
386
|
-
queryStatisticsCollectionForQuantity,
|
|
387
|
-
queryWorkoutSamples,
|
|
388
|
-
queryWorkoutSamplesWithAnchor,
|
|
389
|
-
querySources,
|
|
390
|
-
requestAuthorization,
|
|
391
|
-
deleteObjects,
|
|
392
|
-
saveCategorySample,
|
|
393
|
-
saveCorrelationSample,
|
|
394
|
-
saveQuantitySample,
|
|
395
|
-
saveWorkoutSample,
|
|
396
|
-
subscribeToChanges,
|
|
397
|
-
startWatchApp,
|
|
398
|
-
isProtectedDataAvailable,
|
|
399
|
-
queryStateOfMindSamples,
|
|
400
|
-
saveStateOfMindSample,
|
|
401
|
-
|
|
402
|
-
// Hooks
|
|
403
|
-
useMostRecentCategorySample,
|
|
404
|
-
useMostRecentQuantitySample,
|
|
405
|
-
useMostRecentWorkout,
|
|
406
|
-
useSubscribeToChanges,
|
|
407
|
-
useHealthkitAuthorization,
|
|
408
|
-
useIsHealthDataAvailable,
|
|
409
|
-
useSources,
|
|
410
|
-
useStatisticsForQuantity,
|
|
411
|
-
getBiologicalSexAsync,
|
|
412
|
-
getBloodTypeAsync,
|
|
413
|
-
getDateOfBirthAsync,
|
|
414
|
-
getFitzpatrickSkinTypeAsync,
|
|
415
|
-
getWheelchairUseAsync,
|
|
416
|
-
} as Omit<typeof ReactNativeHealthkit, 'default'>
|
|
417
|
-
|
|
418
|
-
export default {
|
|
419
|
-
...HealthkitModule,
|
|
420
|
-
default: HealthkitModule,
|
|
421
|
-
} as typeof ReactNativeHealthkit
|
|
5
|
+
export default HealthKit
|
|
@@ -2,9 +2,9 @@ import type { AnyMap, HybridObject } from 'react-native-nitro-modules'
|
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
CategorySample,
|
|
5
|
-
CategorySampleTyped,
|
|
6
5
|
CategorySamplesWithAnchorResponse,
|
|
7
6
|
CategorySamplesWithAnchorResponseTyped,
|
|
7
|
+
CategorySampleTyped,
|
|
8
8
|
CategoryValueForIdentifier,
|
|
9
9
|
MetadataForCategoryIdentifier,
|
|
10
10
|
} from '../types/CategoryType'
|
|
@@ -9,13 +9,13 @@ import type {
|
|
|
9
9
|
export interface CharacteristicTypeModule
|
|
10
10
|
extends HybridObject<{ ios: 'swift' }> {
|
|
11
11
|
getBloodType(): BloodType
|
|
12
|
-
getDateOfBirth(): Date
|
|
12
|
+
getDateOfBirth(): Date | null
|
|
13
13
|
getBiologicalSex(): BiologicalSex
|
|
14
14
|
getFitzpatrickSkinType(): FitzpatrickSkinType
|
|
15
15
|
getWheelchairUse(): WheelchairUse
|
|
16
16
|
|
|
17
17
|
getBloodTypeAsync(): Promise<BloodType>
|
|
18
|
-
getDateOfBirthAsync(): Promise<Date>
|
|
18
|
+
getDateOfBirthAsync(): Promise<Date | null>
|
|
19
19
|
getBiologicalSexAsync(): Promise<BiologicalSex>
|
|
20
20
|
getFitzpatrickSkinTypeAsync(): Promise<FitzpatrickSkinType>
|
|
21
21
|
getWheelchairUseAsync(): Promise<WheelchairUse>
|
|
@@ -75,15 +75,15 @@ export interface CoreModule extends HybridObject<{ ios: 'swift' }> {
|
|
|
75
75
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
|
|
76
76
|
*/
|
|
77
77
|
getRequestStatusForAuthorization(
|
|
78
|
-
toShare: SampleTypeIdentifierWriteable[],
|
|
79
|
-
toRead: ObjectTypeIdentifier[],
|
|
78
|
+
toShare: readonly SampleTypeIdentifierWriteable[],
|
|
79
|
+
toRead: readonly ObjectTypeIdentifier[],
|
|
80
80
|
): Promise<AuthorizationRequestStatus>
|
|
81
81
|
/**
|
|
82
82
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
|
|
83
83
|
*/
|
|
84
84
|
requestAuthorization(
|
|
85
|
-
toShare: SampleTypeIdentifierWriteable[],
|
|
86
|
-
toRead: ObjectTypeIdentifier[],
|
|
85
|
+
toShare: readonly SampleTypeIdentifierWriteable[],
|
|
86
|
+
toRead: readonly ObjectTypeIdentifier[],
|
|
87
87
|
): Promise<boolean>
|
|
88
88
|
|
|
89
89
|
deleteObjects(
|
|
@@ -94,7 +94,7 @@ export interface CoreModule extends HybridObject<{ ios: 'swift' }> {
|
|
|
94
94
|
isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier): boolean
|
|
95
95
|
|
|
96
96
|
areObjectTypesAvailable(
|
|
97
|
-
objectTypeIdentifiers: ObjectTypeIdentifier[],
|
|
97
|
+
objectTypeIdentifiers: readonly ObjectTypeIdentifier[],
|
|
98
98
|
): Record<string, boolean>
|
|
99
99
|
|
|
100
100
|
areObjectTypesAvailableAsync(
|
package/src/test-setup.ts
CHANGED
|
@@ -32,16 +32,16 @@ export type PredicateFromWorkout = {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// Computes and flattens object types
|
|
35
|
-
// biome-ignore lint/complexity/noBannedTypes:
|
|
35
|
+
// biome-ignore lint/complexity/noBannedTypes: it works
|
|
36
36
|
type ComputeRaw<A> = A extends Function ? A : { [K in keyof A]: A[K] } & {}
|
|
37
37
|
|
|
38
38
|
// Gets all keys from a union of objects
|
|
39
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
39
|
+
// biome-ignore lint/suspicious/noExplicitAny: it works
|
|
40
40
|
type AllKeys<U> = U extends any ? keyof U : never
|
|
41
41
|
|
|
42
42
|
// The core: for each member U in the union,
|
|
43
43
|
// add `?: never` for any key that exists in other union members.
|
|
44
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
44
|
+
// biome-ignore lint/suspicious/noExplicitAny: it works
|
|
45
45
|
type _Strict<U, UAll extends U = U> = U extends any
|
|
46
46
|
? ComputeRaw<
|
|
47
47
|
U & {
|
package/src/types/Shared.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules'
|
|
1
2
|
import type {
|
|
2
3
|
CategoryTypeIdentifier,
|
|
3
4
|
CategoryTypeIdentifierWriteable,
|
|
4
5
|
} from './CategoryTypeIdentifier'
|
|
5
|
-
import type {
|
|
6
|
-
QuantityTypeIdentifier,
|
|
7
|
-
QuantityTypeIdentifierWriteable,
|
|
8
|
-
} from './QuantityTypeIdentifier'
|
|
9
|
-
|
|
6
|
+
import type { CharacteristicTypeIdentifier } from './Characteristics'
|
|
10
7
|
import type {
|
|
11
8
|
HeartbeatSeriesTypeIdentifier,
|
|
12
9
|
StateOfMindTypeIdentifier,
|
|
13
10
|
WorkoutRouteTypeIdentifier,
|
|
14
11
|
WorkoutTypeIdentifier,
|
|
15
12
|
} from './Constants'
|
|
16
|
-
|
|
17
|
-
import type { AnyMap } from 'react-native-nitro-modules'
|
|
18
|
-
import type { CharacteristicTypeIdentifier } from './Characteristics'
|
|
19
13
|
import type { CorrelationTypeIdentifier } from './CorrelationType'
|
|
14
|
+
import type {
|
|
15
|
+
QuantityTypeIdentifier,
|
|
16
|
+
QuantityTypeIdentifierWriteable,
|
|
17
|
+
} from './QuantityTypeIdentifier'
|
|
20
18
|
|
|
21
19
|
export interface GenericMetadata {
|
|
22
20
|
readonly HKExternalUUID?: string
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_void_std__chrono__system_clock__time_point.swift
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
import NitroModules
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Wraps a Swift `(_ value: Date) -> Void` as a class.
|
|
12
|
-
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
-
*/
|
|
14
|
-
public final class Func_void_std__chrono__system_clock__time_point {
|
|
15
|
-
public typealias bridge = margelo.nitro.healthkit.bridge.swift
|
|
16
|
-
|
|
17
|
-
private let closure: (_ value: Date) -> Void
|
|
18
|
-
|
|
19
|
-
public init(_ closure: @escaping (_ value: Date) -> Void) {
|
|
20
|
-
self.closure = closure
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@inline(__always)
|
|
24
|
-
public func call(value: margelo.nitro.chrono_time) -> Void {
|
|
25
|
-
self.closure(Date(fromChrono: value))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
-
* This acquires one additional strong reference on the object!
|
|
31
|
-
*/
|
|
32
|
-
@inline(__always)
|
|
33
|
-
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
-
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Casts an unsafe pointer to a `Func_void_std__chrono__system_clock__time_point`.
|
|
39
|
-
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__chrono__system_clock__time_point>`.
|
|
40
|
-
* This removes one strong reference from the object!
|
|
41
|
-
*/
|
|
42
|
-
@inline(__always)
|
|
43
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__chrono__system_clock__time_point {
|
|
44
|
-
return Unmanaged<Func_void_std__chrono__system_clock__time_point>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|