@kingstinct/react-native-healthkit 7.2.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/Constants.swift +1 -1
- package/ios/ReactNativeHealthkit.m +2 -1
- package/ios/ReactNativeHealthkit.swift +108 -54
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +5 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +3 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +3 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +3 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/commonjs/index.js +475 -82
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.native.js +251 -0
- package/lib/commonjs/index.native.js.map +1 -0
- package/lib/commonjs/index.web.js +17 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/jest.setup.js +2 -1
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js +5 -5
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/utils/ensureTotals.js +12 -0
- package/lib/commonjs/utils/ensureTotals.js.map +1 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js +14 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/commonjs/utils/saveCategorySample.js +4 -0
- package/lib/commonjs/utils/saveCategorySample.js.map +1 -1
- package/lib/commonjs/utils/saveWorkoutSample.js +2 -1
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
- package/lib/module/hooks/useHealthkitAuthorization.js +5 -0
- package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/module/hooks/useMostRecentCategorySample.js +3 -0
- package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentQuantitySample.js +3 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentWorkout.js +3 -0
- package/lib/module/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/module/index.js +195 -80
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.native.js +136 -0
- package/lib/module/index.native.js.map +1 -0
- package/lib/module/index.web.js +2 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/jest.setup.js +2 -1
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js +3 -3
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/utils/ensureTotals.js +5 -0
- package/lib/module/utils/ensureTotals.js.map +1 -0
- package/lib/module/utils/getWorkoutPlanById.js +6 -0
- package/lib/module/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/module/utils/saveCategorySample.js +4 -0
- package/lib/module/utils/saveCategorySample.js.map +1 -1
- package/lib/module/utils/saveWorkoutSample.js +2 -1
- package/lib/module/utils/saveWorkoutSample.js.map +1 -1
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +5 -0
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +3 -0
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +3 -0
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +3 -0
- package/lib/typescript/src/index.d.ts +155 -27
- package/lib/typescript/src/index.native.d.ts +29 -0
- package/lib/typescript/src/index.web.d.ts +1 -0
- package/lib/typescript/src/native-types.d.ts +82 -75
- package/lib/typescript/src/utils/ensureTotals.d.ts +2 -0
- package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +5 -0
- package/lib/typescript/src/utils/saveCategorySample.d.ts +4 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +4 -0
- package/package.json +1 -1
- package/src/hooks/useHealthkitAuthorization.ts +5 -0
- package/src/hooks/useMostRecentCategorySample.ts +3 -0
- package/src/hooks/useMostRecentQuantitySample.ts +3 -0
- package/src/hooks/useMostRecentWorkout.ts +3 -0
- package/src/index.native.tsx +201 -0
- package/src/index.tsx +269 -91
- package/src/index.web.tsx +1 -0
- package/src/jest.setup.ts +2 -1
- package/src/native-types.ts +143 -116
- package/src/utils/ensureTotals.ts +5 -0
- package/src/utils/getWorkoutPlanById.ts +7 -0
- package/src/utils/saveCategorySample.ts +4 -0
- package/src/utils/saveWorkoutSample.ts +6 -0
- package/lib/commonjs/index.ios.js +0 -213
- package/lib/commonjs/index.ios.js.map +0 -1
- package/lib/module/index.ios.js +0 -191
- package/lib/module/index.ios.js.map +0 -1
- package/lib/typescript/src/index.ios.d.ts +0 -141
- package/src/index.ios.tsx +0 -217
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ensureMetadata","_interopRequireDefault","require","_nativeTypes","obj","__esModule","default","saveWorkoutSample","typeIdentifier","quantities","_start","options","start","toISOString","end","Date","Native","map","quantity","startDate","endDate","rest","updatedQuantity","metadata","ensureMetadata","_default","exports"],"sources":["saveWorkoutSample.ts"],"sourcesContent":["import ensureMetadata from './ensureMetadata'\nimport Native from '../native-types'\n\nimport type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types'\nimport type { HKQuantitySampleForSaving } from '../types'\n\nasync function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(\n typeIdentifier: TIdentifier,\n quantities: readonly HKQuantitySampleForSaving[],\n _start: Date,\n options?: {\n readonly end?: Date;\n readonly metadata?: HKWorkoutMetadata;\n },\n) {\n const start = _start.toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveWorkoutSample(\n typeIdentifier,\n quantities.map((quantity) => {\n const { startDate, endDate, ...rest } = quantity\n const updatedQuantity = {\n ...rest,\n ...(startDate && { startDate: startDate.toISOString() }),\n ...(endDate && { endDate: endDate.toISOString() }),\n }\n return { ...updatedQuantity, metadata: ensureMetadata(quantity.metadata) }\n }),\n start,\n end,\n ensureMetadata(options?.metadata),\n )\n}\n\nexport default saveWorkoutSample\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,
|
|
1
|
+
{"version":3,"names":["_ensureMetadata","_interopRequireDefault","require","_ensureTotals","_nativeTypes","obj","__esModule","default","saveWorkoutSample","typeIdentifier","quantities","_start","options","start","toISOString","end","Date","Native","map","quantity","startDate","endDate","rest","updatedQuantity","metadata","ensureMetadata","ensureTotals","totals","_default","exports"],"sources":["saveWorkoutSample.ts"],"sourcesContent":["import ensureMetadata from './ensureMetadata'\nimport ensureTotals from './ensureTotals'\nimport Native from '../native-types'\n\nimport type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types'\nimport type { HKQuantitySampleForSaving } from '../types'\n\nasync function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(\n typeIdentifier: TIdentifier,\n quantities: readonly HKQuantitySampleForSaving[],\n _start: Date,\n options?: {\n readonly end?: Date;\n readonly totals?: {\n readonly distance?: number;\n readonly energyBurned?: number;\n }\n readonly metadata?: HKWorkoutMetadata;\n },\n) {\n const start = _start.toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveWorkoutSample(\n typeIdentifier,\n quantities.map((quantity) => {\n const { startDate, endDate, ...rest } = quantity\n const updatedQuantity = {\n ...rest,\n ...(startDate && { startDate: startDate.toISOString() }),\n ...(endDate && { endDate: endDate.toISOString() }),\n }\n return { ...updatedQuantity, metadata: ensureMetadata(quantity.metadata) }\n }),\n start,\n end,\n ensureTotals(options?.totals),\n ensureMetadata(options?.metadata),\n )\n}\n\nexport default saveWorkoutSample\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,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RequestStatusForAuthorization from '../utils/getRequestStatusForAuthorization';
|
|
3
3
|
import requestAuthorization from '../utils/requestAuthorization';
|
|
4
|
+
/**
|
|
5
|
+
* @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.
|
|
6
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
7
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
8
|
+
*/
|
|
4
9
|
const useHealthkitAuthorization = (read, write) => {
|
|
5
10
|
const [status, setStatus] = useState(null);
|
|
6
11
|
const readMemo = useRef(read);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useRef","useState","getRequestStatusForAuthorization","requestAuthorization","useHealthkitAuthorization","read","write","status","setStatus","readMemo","writeMemo","current","refreshAuthStatus","auth","request"],"sources":["useHealthkitAuthorization.ts"],"sourcesContent":["import {\n useCallback, useEffect, useRef, useState,\n} from 'react'\n\nimport getRequestStatusForAuthorization from '../utils/getRequestStatusForAuthorization'\nimport requestAuthorization from '../utils/requestAuthorization'\n\nimport type { HealthkitReadAuthorization, HealthkitWriteAuthorization, HKAuthorizationRequestStatus } from '../native-types'\n\nconst useHealthkitAuthorization = (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => {\n const [status, setStatus] = useState<HKAuthorizationRequestStatus | null>(null)\n\n const readMemo = useRef(read)\n const writeMemo = useRef(write)\n\n useEffect(() => {\n readMemo.current = read\n writeMemo.current = write\n }, [read, write])\n\n const refreshAuthStatus = useCallback(async () => {\n const auth = await getRequestStatusForAuthorization(readMemo.current, writeMemo.current)\n\n setStatus(auth)\n return auth\n }, [])\n\n const request = useCallback(async () => {\n await requestAuthorization(readMemo.current, writeMemo.current)\n return refreshAuthStatus()\n }, [refreshAuthStatus])\n\n useEffect(() => {\n void refreshAuthStatus()\n }, [refreshAuthStatus])\n\n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useCallback","useEffect","useRef","useState","getRequestStatusForAuthorization","requestAuthorization","useHealthkitAuthorization","read","write","status","setStatus","readMemo","writeMemo","current","refreshAuthStatus","auth","request"],"sources":["useHealthkitAuthorization.ts"],"sourcesContent":["import {\n useCallback, useEffect, useRef, useState,\n} from 'react'\n\nimport getRequestStatusForAuthorization from '../utils/getRequestStatusForAuthorization'\nimport requestAuthorization from '../utils/requestAuthorization'\n\nimport type { HealthkitReadAuthorization, HealthkitWriteAuthorization, HKAuthorizationRequestStatus } from '../native-types'\n\n/**\n * @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}\n */\nconst useHealthkitAuthorization = (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => {\n const [status, setStatus] = useState<HKAuthorizationRequestStatus | null>(null)\n\n const readMemo = useRef(read)\n const writeMemo = useRef(write)\n\n useEffect(() => {\n readMemo.current = read\n writeMemo.current = write\n }, [read, write])\n\n const refreshAuthStatus = useCallback(async () => {\n const auth = await getRequestStatusForAuthorization(readMemo.current, writeMemo.current)\n\n setStatus(auth)\n return auth\n }, [])\n\n const request = useCallback(async () => {\n await requestAuthorization(readMemo.current, writeMemo.current)\n return refreshAuthStatus()\n }, [refreshAuthStatus])\n\n useEffect(() => {\n void refreshAuthStatus()\n }, [refreshAuthStatus])\n\n return [status, request] as const\n}\n\nexport default useHealthkitAuthorization\n"],"mappings":"AAAA,SACEA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QACnC,OAAO;AAEd,OAAOC,gCAAgC,MAAM,2CAA2C;AACxF,OAAOC,oBAAoB,MAAM,+BAA+B;AAIhE;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAGA,CAACC,IAA2C,EAAEC,KAA8C,KAAK;EACjI,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGP,QAAQ,CAAsC,IAAI,CAAC;EAE/E,MAAMQ,QAAQ,GAAGT,MAAM,CAACK,IAAI,CAAC;EAC7B,MAAMK,SAAS,GAAGV,MAAM,CAACM,KAAK,CAAC;EAE/BP,SAAS,CAAC,MAAM;IACdU,QAAQ,CAACE,OAAO,GAAGN,IAAI;IACvBK,SAAS,CAACC,OAAO,GAAGL,KAAK;EAC3B,CAAC,EAAE,CAACD,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEjB,MAAMM,iBAAiB,GAAGd,WAAW,CAAC,YAAY;IAChD,MAAMe,IAAI,GAAG,MAAMX,gCAAgC,CAACO,QAAQ,CAACE,OAAO,EAAED,SAAS,CAACC,OAAO,CAAC;IAExFH,SAAS,CAACK,IAAI,CAAC;IACf,OAAOA,IAAI;EACb,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,OAAO,GAAGhB,WAAW,CAAC,YAAY;IACtC,MAAMK,oBAAoB,CAACM,QAAQ,CAACE,OAAO,EAAED,SAAS,CAACC,OAAO,CAAC;IAC/D,OAAOC,iBAAiB,CAAC,CAAC;EAC5B,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;EAEvBb,SAAS,CAAC,MAAM;IACd,KAAKa,iBAAiB,CAAC,CAAC;EAC1B,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;EAEvB,OAAO,CAACL,MAAM,EAAEO,OAAO,CAAC;AAC1B,CAAC;AAED,eAAeV,yBAAyB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react';
|
|
2
2
|
import useSubscribeToChanges from './useSubscribeToChanges';
|
|
3
3
|
import getMostRecentCategorySample from '../utils/getMostRecentCategorySample';
|
|
4
|
+
/**
|
|
5
|
+
* @returns the most recent sample for the given category type.
|
|
6
|
+
*/
|
|
4
7
|
function useMostRecentCategorySample(identifier) {
|
|
5
8
|
const [category, setCategory] = useState(null);
|
|
6
9
|
const updater = useCallback(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useState","useSubscribeToChanges","getMostRecentCategorySample","useMostRecentCategorySample","identifier","category","setCategory","updater","then"],"sources":["useMostRecentCategorySample.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\n\nimport useSubscribeToChanges from './useSubscribeToChanges'\nimport getMostRecentCategorySample from '../utils/getMostRecentCategorySample'\n\nimport type { HKCategoryTypeIdentifier } from '../native-types'\nimport type { HKCategorySample } from '../types'\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\nexport default useMostRecentCategorySample\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAE7C,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,OAAOC,2BAA2B,MAAM,sCAAsC;AAK9E,SAASC,2BAA2BA,CAElCC,UAAqB,EAAE;EACvB,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGN,QAAQ,CACtC,IACF,CAAC;EACD,MAAMO,OAAO,GAAGR,WAAW,CAAC,MAAM;IAChC,KAAKG,2BAA2B,CAACE,UAAU,CAAC,CAACI,IAAI,CAACF,WAAW,CAAC;EAChE,CAAC,EAAE,CAACF,UAAU,CAAC,CAAC;EAEhBH,qBAAqB,CAACG,UAAU,EAAEG,OAAO,CAAC;EAE1C,OAAOF,QAAQ;AACjB;AAEA,eAAeF,2BAA2B"}
|
|
1
|
+
{"version":3,"names":["useCallback","useState","useSubscribeToChanges","getMostRecentCategorySample","useMostRecentCategorySample","identifier","category","setCategory","updater","then"],"sources":["useMostRecentCategorySample.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\n\nimport useSubscribeToChanges from './useSubscribeToChanges'\nimport getMostRecentCategorySample from '../utils/getMostRecentCategorySample'\n\nimport type { HKCategoryTypeIdentifier } from '../native-types'\nimport type { HKCategorySample } from '../types'\n\n/**\n * @returns the most recent sample for the given category type.\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\nexport default useMostRecentCategorySample\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAE7C,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,OAAOC,2BAA2B,MAAM,sCAAsC;AAK9E;AACA;AACA;AACA,SAASC,2BAA2BA,CAElCC,UAAqB,EAAE;EACvB,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGN,QAAQ,CACtC,IACF,CAAC;EACD,MAAMO,OAAO,GAAGR,WAAW,CAAC,MAAM;IAChC,KAAKG,2BAA2B,CAACE,UAAU,CAAC,CAACI,IAAI,CAACF,WAAW,CAAC;EAChE,CAAC,EAAE,CAACF,UAAU,CAAC,CAAC;EAEhBH,qBAAqB,CAACG,UAAU,EAAEG,OAAO,CAAC;EAE1C,OAAOF,QAAQ;AACjB;AAEA,eAAeF,2BAA2B"}
|
|
@@ -2,6 +2,9 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import ensureUnit from '../utils/ensureUnit';
|
|
3
3
|
import getMostRecentQuantitySample from '../utils/getMostRecentQuantitySample';
|
|
4
4
|
import subscribeToChanges from '../utils/subscribeToChanges';
|
|
5
|
+
/**
|
|
6
|
+
* @returns the most recent sample for the given quantity type.
|
|
7
|
+
*/
|
|
5
8
|
function useMostRecentQuantitySample(identifier, unit) {
|
|
6
9
|
const [lastSample, setLastSample] = useState(null);
|
|
7
10
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","ensureUnit","getMostRecentQuantitySample","subscribeToChanges","useMostRecentQuantitySample","identifier","unit","lastSample","setLastSample","cancelSubscription","init","actualUnit","value","_cancelSubscription"],"sources":["useMostRecentQuantitySample.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nimport ensureUnit from '../utils/ensureUnit'\nimport getMostRecentQuantitySample from '../utils/getMostRecentQuantitySample'\nimport subscribeToChanges from '../utils/subscribeToChanges'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\nimport type { HKQuantitySample } from '../types'\n\nfunction useMostRecentQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(identifier: TIdentifier, unit?: TUnit) {\n const [lastSample, setLastSample] = useState<HKQuantitySample<\n TIdentifier\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\nexport default useMostRecentQuantitySample\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,OAAOC,UAAU,MAAM,qBAAqB;AAC5C,OAAOC,2BAA2B,MAAM,sCAAsC;AAC9E,OAAOC,kBAAkB,MAAM,6BAA6B;AAK5D,SAASC,2BAA2BA,CAGlCC,UAAuB,EAAEC,IAAY,EAAE;EACvC,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGR,QAAQ,CAElC,IAAI,CAAC;EAEfD,SAAS,CAAC,MAAM;IACd,IAAIU,kBAAwD;IAE5D,MAAMC,IAAI,GAAG,MAAAA,CAAA,KAAY;MACvB,MAAMC,UAAU,GAAG,MAAMV,UAAU,CAACI,UAAU,EAAEC,IAAI,CAAC;MAErDG,kBAAkB,GAAG,MAAMN,kBAAkB,CAACE,UAAU,EAAE,YAAY;QACpE,MAAMO,KAAK,GAAG,MAAMV,2BAA2B,CAACG,UAAU,EAAEM,UAAU,CAAC;QACvEH,aAAa,CAACI,KAAK,CAAC;MACtB,CAAC,CAAC;IACJ,CAAC;IACD,KAAKF,IAAI,CAAC,CAAC;IAEX,OAAO,MAAM;MAAA,IAAAG,mBAAA;MACX,OAAAA,mBAAA,GAAKJ,kBAAkB,cAAAI,mBAAA,uBAAlBA,mBAAA,CAAqB,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACR,UAAU,EAAEC,IAAI,CAAC,CAAC;EAEtB,OAAOC,UAAU;AACnB;AAEA,eAAeH,2BAA2B"}
|
|
1
|
+
{"version":3,"names":["useEffect","useState","ensureUnit","getMostRecentQuantitySample","subscribeToChanges","useMostRecentQuantitySample","identifier","unit","lastSample","setLastSample","cancelSubscription","init","actualUnit","value","_cancelSubscription"],"sources":["useMostRecentQuantitySample.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nimport ensureUnit from '../utils/ensureUnit'\nimport getMostRecentQuantitySample from '../utils/getMostRecentQuantitySample'\nimport subscribeToChanges from '../utils/subscribeToChanges'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\nimport type { HKQuantitySample } from '../types'\n\n/**\n * @returns the most recent sample for the given quantity type.\n */\nfunction useMostRecentQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(identifier: TIdentifier, unit?: TUnit) {\n const [lastSample, setLastSample] = useState<HKQuantitySample<\n TIdentifier\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\nexport default useMostRecentQuantitySample\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,OAAOC,UAAU,MAAM,qBAAqB;AAC5C,OAAOC,2BAA2B,MAAM,sCAAsC;AAC9E,OAAOC,kBAAkB,MAAM,6BAA6B;AAK5D;AACA;AACA;AACA,SAASC,2BAA2BA,CAGlCC,UAAuB,EAAEC,IAAY,EAAE;EACvC,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGR,QAAQ,CAElC,IAAI,CAAC;EAEfD,SAAS,CAAC,MAAM;IACd,IAAIU,kBAAwD;IAE5D,MAAMC,IAAI,GAAG,MAAAA,CAAA,KAAY;MACvB,MAAMC,UAAU,GAAG,MAAMV,UAAU,CAACI,UAAU,EAAEC,IAAI,CAAC;MAErDG,kBAAkB,GAAG,MAAMN,kBAAkB,CAACE,UAAU,EAAE,YAAY;QACpE,MAAMO,KAAK,GAAG,MAAMV,2BAA2B,CAACG,UAAU,EAAEM,UAAU,CAAC;QACvEH,aAAa,CAACI,KAAK,CAAC;MACtB,CAAC,CAAC;IACJ,CAAC;IACD,KAAKF,IAAI,CAAC,CAAC;IAEX,OAAO,MAAM;MAAA,IAAAG,mBAAA;MACX,OAAAA,mBAAA,GAAKJ,kBAAkB,cAAAI,mBAAA,uBAAlBA,mBAAA,CAAqB,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACR,UAAU,EAAEC,IAAI,CAAC,CAAC;EAEtB,OAAOC,UAAU;AACnB;AAEA,eAAeH,2BAA2B"}
|
|
@@ -2,6 +2,9 @@ import { useEffect, useState, useRef, useCallback } from 'react';
|
|
|
2
2
|
import getMostRecentWorkout from '../utils/getMostRecentWorkout';
|
|
3
3
|
import getPreferredUnitsTyped from '../utils/getPreferredUnitsTyped';
|
|
4
4
|
import subscribeToChanges from '../utils/subscribeToChanges';
|
|
5
|
+
/**
|
|
6
|
+
* @returns the most recent workout sample.
|
|
7
|
+
*/
|
|
5
8
|
function useMostRecentWorkout(options) {
|
|
6
9
|
const [workout, setWorkout] = useState(null);
|
|
7
10
|
const optionsRef = useRef(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","useRef","useCallback","getMostRecentWorkout","getPreferredUnitsTyped","subscribeToChanges","useMostRecentWorkout","options","workout","setWorkout","optionsRef","current","update","energyUnit","distanceUnit","cancelSubscription","init","_cancelSubscription"],"sources":["useMostRecentWorkout.ts"],"sourcesContent":["import {\n useEffect, useState, useRef, useCallback,\n} from 'react'\n\nimport getMostRecentWorkout from '../utils/getMostRecentWorkout'\nimport getPreferredUnitsTyped from '../utils/getPreferredUnitsTyped'\nimport subscribeToChanges from '../utils/subscribeToChanges'\n\nimport type { EnergyUnit, LengthUnit } from '../native-types'\nimport type { HKWorkout } from '../types'\n\nfunction useMostRecentWorkout<\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n>(options?: { readonly energyUnit?: TEnergy; readonly distanceUnit?: TDistance }) {\n const [workout, setWorkout] = useState<HKWorkout<TEnergy, TDistance> | null>(null)\n\n const optionsRef = useRef(options)\n\n useEffect(() => {\n optionsRef.current = options\n }, [options])\n\n const update = useCallback(async () => {\n const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(\n optionsRef.current,\n )\n\n setWorkout(await getMostRecentWorkout({\n energyUnit,\n distanceUnit,\n }))\n }, [])\n\n useEffect(() => {\n void update()\n }, [update])\n\n useEffect(() => {\n let cancelSubscription: (() => Promise<boolean>) | undefined\n\n const init = async () => {\n cancelSubscription = await subscribeToChanges(\n 'HKWorkoutTypeIdentifier',\n update,\n )\n }\n void init()\n\n return () => {\n void cancelSubscription?.()\n }\n }, [update])\n\n return workout\n}\n\nexport default useMostRecentWorkout\n"],"mappings":"AAAA,SACEA,SAAS,EA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3,"names":["useEffect","useState","useRef","useCallback","getMostRecentWorkout","getPreferredUnitsTyped","subscribeToChanges","useMostRecentWorkout","options","workout","setWorkout","optionsRef","current","update","energyUnit","distanceUnit","cancelSubscription","init","_cancelSubscription"],"sources":["useMostRecentWorkout.ts"],"sourcesContent":["import {\n useEffect, useState, useRef, useCallback,\n} from 'react'\n\nimport getMostRecentWorkout from '../utils/getMostRecentWorkout'\nimport getPreferredUnitsTyped from '../utils/getPreferredUnitsTyped'\nimport subscribeToChanges from '../utils/subscribeToChanges'\n\nimport type { EnergyUnit, LengthUnit } from '../native-types'\nimport type { HKWorkout } from '../types'\n\n/**\n * @returns the most recent workout sample.\n */\nfunction useMostRecentWorkout<\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n>(options?: { readonly energyUnit?: TEnergy; readonly distanceUnit?: TDistance }) {\n const [workout, setWorkout] = useState<HKWorkout<TEnergy, TDistance> | null>(null)\n\n const optionsRef = useRef(options)\n\n useEffect(() => {\n optionsRef.current = options\n }, [options])\n\n const update = useCallback(async () => {\n const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(\n optionsRef.current,\n )\n\n setWorkout(await getMostRecentWorkout({\n energyUnit,\n distanceUnit,\n }))\n }, [])\n\n useEffect(() => {\n void update()\n }, [update])\n\n useEffect(() => {\n let cancelSubscription: (() => Promise<boolean>) | undefined\n\n const init = async () => {\n cancelSubscription = await subscribeToChanges(\n 'HKWorkoutTypeIdentifier',\n update,\n )\n }\n void init()\n\n return () => {\n void cancelSubscription?.()\n }\n }, [update])\n\n return workout\n}\n\nexport default useMostRecentWorkout\n"],"mappings":"AAAA,SACEA,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,WAAW,QACnC,OAAO;AAEd,OAAOC,oBAAoB,MAAM,+BAA+B;AAChE,OAAOC,sBAAsB,MAAM,iCAAiC;AACpE,OAAOC,kBAAkB,MAAM,6BAA6B;AAK5D;AACA;AACA;AACA,SAASC,oBAAoBA,CAG3BC,OAA8E,E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13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
queryQuantitySamplesWithAnchor: UnavailableFn(Promise.resolve({
|
|
49
|
-
samples: [],
|
|
50
|
-
deletedSamples: [],
|
|
51
|
-
newAnchor: ''
|
|
52
|
-
})),
|
|
53
|
-
queryStatisticsForQuantity: UnavailableFn(Promise.resolve({
|
|
54
|
-
averageQuantity: undefined,
|
|
55
|
-
maximumQuantity: undefined,
|
|
56
|
-
minimumQuantity: undefined,
|
|
57
|
-
sumQuantity: undefined,
|
|
58
|
-
mostRecentQuantity: undefined,
|
|
59
|
-
mostRecentQuantityDateInterval: undefined,
|
|
60
|
-
duration: undefined
|
|
61
|
-
})),
|
|
62
|
-
queryWorkouts: UnavailableFn(Promise.resolve([])),
|
|
63
|
-
querySources: UnavailableFn(Promise.resolve([])),
|
|
64
|
-
requestAuthorization: UnavailableFn(Promise.resolve(false)),
|
|
65
|
-
deleteQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
66
|
-
deleteSamples: UnavailableFn(Promise.resolve(false)),
|
|
67
|
-
saveCategorySample: UnavailableFn(Promise.resolve(false)),
|
|
68
|
-
saveCorrelationSample: UnavailableFn(Promise.resolve(false)),
|
|
69
|
-
saveQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
70
|
-
saveWorkoutSample: UnavailableFn(Promise.resolve(null)),
|
|
71
|
-
saveWorkoutRoute: UnavailableFn(Promise.resolve(false)),
|
|
72
|
-
subscribeToChanges: UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),
|
|
73
|
-
useMostRecentCategorySample: UnavailableFn(null),
|
|
74
|
-
useMostRecentQuantitySample: UnavailableFn(null),
|
|
75
|
-
useMostRecentWorkout: UnavailableFn(null),
|
|
76
|
-
useSubscribeToChanges: UnavailableFn([null, () => null]),
|
|
77
|
-
useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(HKAuthorizationRequestStatus.unknown)]),
|
|
78
|
-
useIsHealthDataAvailable: () => false,
|
|
79
|
-
canAccessProtectedData: async () => Promise.resolve(false),
|
|
80
|
-
isProtectedDataAvailable: async () => Promise.resolve(false)
|
|
2
|
+
import useHealthkitAuthorization from './hooks/useHealthkitAuthorization';
|
|
3
|
+
import useIsHealthDataAvailable from './hooks/useIsHealthDataAvailable';
|
|
4
|
+
import useMostRecentCategorySample from './hooks/useMostRecentCategorySample';
|
|
5
|
+
import useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample';
|
|
6
|
+
import useMostRecentWorkout from './hooks/useMostRecentWorkout';
|
|
7
|
+
import useSources from './hooks/useSources';
|
|
8
|
+
import useStatisticsForQuantity from './hooks/useStatisticsForQuantity';
|
|
9
|
+
import useSubscribeToChanges from './hooks/useSubscribeToChanges';
|
|
10
|
+
import Native, { HKQuantityTypeIdentifier } from './native-types';
|
|
11
|
+
import deleteQuantitySample from './utils/deleteQuantitySample';
|
|
12
|
+
import deleteSamples from './utils/deleteSamples';
|
|
13
|
+
import getDateOfBirth from './utils/getDateOfBirth';
|
|
14
|
+
import getMostRecentCategorySample from './utils/getMostRecentCategorySample';
|
|
15
|
+
import getMostRecentQuantitySample from './utils/getMostRecentQuantitySample';
|
|
16
|
+
import getMostRecentWorkout from './utils/getMostRecentWorkout';
|
|
17
|
+
import getPreferredUnit from './utils/getPreferredUnit';
|
|
18
|
+
import getPreferredUnits from './utils/getPreferredUnits';
|
|
19
|
+
import getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization';
|
|
20
|
+
import getWorkoutPlanById from './utils/getWorkoutPlanById';
|
|
21
|
+
import queryCategorySamples from './utils/queryCategorySamples';
|
|
22
|
+
import queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor';
|
|
23
|
+
import queryCorrelationSamples from './utils/queryCorrelationSamples';
|
|
24
|
+
import queryHeartbeatSeriesSamples from './utils/queryHeartbeatSeriesSamples';
|
|
25
|
+
import queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesSamplesWithAnchor';
|
|
26
|
+
import queryQuantitySamples from './utils/queryQuantitySamples';
|
|
27
|
+
import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor';
|
|
28
|
+
import querySources from './utils/querySources';
|
|
29
|
+
import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity';
|
|
30
|
+
import queryWorkouts from './utils/queryWorkouts';
|
|
31
|
+
import requestAuthorization from './utils/requestAuthorization';
|
|
32
|
+
import saveCategorySample from './utils/saveCategorySample';
|
|
33
|
+
import saveCorrelationSample from './utils/saveCorrelationSample';
|
|
34
|
+
import saveQuantitySample from './utils/saveQuantitySample';
|
|
35
|
+
import saveWorkoutRoute from './utils/saveWorkoutRoute';
|
|
36
|
+
import saveWorkoutSample from './utils/saveWorkoutSample';
|
|
37
|
+
import subscribeToChanges from './utils/subscribeToChanges';
|
|
38
|
+
const currentMajorVersionIOS = Platform.OS === 'ios' ? parseInt(Platform.Version, 10) : 0;
|
|
39
|
+
const allQuantityTypesList = [...Object.values(HKQuantityTypeIdentifier)];
|
|
40
|
+
const availableQuantityTypes = function () {
|
|
41
|
+
let majorVersionIOS = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : currentMajorVersionIOS;
|
|
42
|
+
if (majorVersionIOS >= 17) {
|
|
43
|
+
return allQuantityTypesList;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// remove types that are not available before iOS 17
|
|
47
|
+
return allQuantityTypesList.filter(type => ![HKQuantityTypeIdentifier.cyclingCadence, HKQuantityTypeIdentifier.cyclingFunctionalThresholdPower, HKQuantityTypeIdentifier.cyclingPower, HKQuantityTypeIdentifier.cyclingSpeed, HKQuantityTypeIdentifier.physicalEffort, HKQuantityTypeIdentifier.timeInDaylight].includes(type));
|
|
81
48
|
};
|
|
49
|
+
const authorizationStatusFor = Native.authorizationStatusFor.bind(Native);
|
|
50
|
+
const isHealthDataAvailable = Native.isHealthDataAvailable.bind(Native);
|
|
51
|
+
// Todo [>8]: Rename to align with Apple function name (isProtectedDataAvailable)
|
|
52
|
+
const canAccessProtectedData = Native.canAccessProtectedData.bind(Native);
|
|
53
|
+
const disableBackgroundDelivery = Native.disableBackgroundDelivery.bind(Native);
|
|
54
|
+
const disableAllBackgroundDelivery = Native.disableAllBackgroundDelivery.bind(Native);
|
|
55
|
+
const enableBackgroundDelivery = Native.enableBackgroundDelivery.bind(Native);
|
|
56
|
+
const getBiologicalSex = Native.getBiologicalSex.bind(Native);
|
|
57
|
+
const getFitzpatrickSkinType = Native.getFitzpatrickSkinType.bind(Native);
|
|
58
|
+
const getWheelchairUse = Native.getWheelchairUse.bind(Native);
|
|
59
|
+
const getBloodType = Native.getBloodType.bind(Native);
|
|
60
|
+
const getWorkoutRoutes = Native.getWorkoutRoutes.bind(Native);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/about_the_healthkit_framework About the HealthKit Framework (Apple Docs)}
|
|
64
|
+
*/
|
|
65
|
+
export default {
|
|
66
|
+
/**
|
|
67
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus authorizationStatus(for:) (Apple Docs) }
|
|
68
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Authorizing access to health data (Apple Docs) }
|
|
69
|
+
*/
|
|
70
|
+
authorizationStatusFor,
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @returns All available quantity types for the current iOS version (currently excluding types that are not available before iOS 17)
|
|
74
|
+
*/
|
|
75
|
+
availableQuantityTypes,
|
|
76
|
+
/**
|
|
77
|
+
* @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.
|
|
78
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable isHealthDataAvailable() (Apple Docs)}
|
|
79
|
+
* @returns {boolean} true if HealthKit is available; otherwise, false.
|
|
80
|
+
*/
|
|
81
|
+
isHealthDataAvailable,
|
|
82
|
+
/**
|
|
83
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}
|
|
84
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
85
|
+
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
86
|
+
*/
|
|
87
|
+
isProtectedDataAvailable: canAccessProtectedData,
|
|
88
|
+
// Todo [>8]: Remove to align with Apple function name (isProtectedDataAvailable)
|
|
89
|
+
/**
|
|
90
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}
|
|
91
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
92
|
+
* @deprecated Use {@link isProtectedDataAvailable} instead. Will be removed in next major version.
|
|
93
|
+
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
94
|
+
*/
|
|
95
|
+
canAccessProtectedData,
|
|
96
|
+
/**
|
|
97
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}
|
|
98
|
+
*/
|
|
99
|
+
disableAllBackgroundDelivery,
|
|
100
|
+
/**
|
|
101
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery disableBackgroundDelivery(for:withCompletion:) (Apple Docs)}
|
|
102
|
+
*/
|
|
103
|
+
disableBackgroundDelivery,
|
|
104
|
+
/**
|
|
105
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery enableBackgroundDelivery(for:frequency:withCompletion:) (Apple Docs)}
|
|
106
|
+
*/
|
|
107
|
+
enableBackgroundDelivery,
|
|
108
|
+
// simple convenience getters
|
|
109
|
+
/**
|
|
110
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614171-biologicalsex biologicalSex() (Apple Docs)}
|
|
111
|
+
*/
|
|
112
|
+
getBiologicalSex,
|
|
113
|
+
/**
|
|
114
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614161-fitzpatrickskintype fitzpatrickSkinType() (Apple Docs)}
|
|
115
|
+
*/
|
|
116
|
+
getFitzpatrickSkinType,
|
|
117
|
+
/**
|
|
118
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648356-wheelchairuse wheelchairUse() (Apple Docs)}
|
|
119
|
+
*/
|
|
120
|
+
getWheelchairUse,
|
|
121
|
+
/**
|
|
122
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614164-bloodtype bloodType() (Apple Docs)}
|
|
123
|
+
*/
|
|
124
|
+
getBloodType,
|
|
125
|
+
/**
|
|
126
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648357-dateofbirthcomponents dateOfBirthComponents() (Apple Docs)}
|
|
127
|
+
*/
|
|
128
|
+
getDateOfBirth,
|
|
129
|
+
getMostRecentQuantitySample,
|
|
130
|
+
getMostRecentCategorySample,
|
|
131
|
+
getMostRecentWorkout,
|
|
132
|
+
/**
|
|
133
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/reading_route_data Reading route data (Apple Docs)}
|
|
134
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}
|
|
135
|
+
*/
|
|
136
|
+
getWorkoutRoutes,
|
|
137
|
+
getWorkoutPlanById,
|
|
138
|
+
getPreferredUnit,
|
|
139
|
+
getPreferredUnits,
|
|
140
|
+
getRequestStatusForAuthorization,
|
|
141
|
+
// query methods
|
|
142
|
+
queryCategorySamples,
|
|
143
|
+
queryCategorySamplesWithAnchor,
|
|
144
|
+
queryCorrelationSamples,
|
|
145
|
+
queryHeartbeatSeriesSamples,
|
|
146
|
+
queryHeartbeatSeriesSamplesWithAnchor,
|
|
147
|
+
queryQuantitySamples,
|
|
148
|
+
queryQuantitySamplesWithAnchor,
|
|
149
|
+
queryStatisticsForQuantity,
|
|
150
|
+
queryWorkouts,
|
|
151
|
+
querySources,
|
|
152
|
+
requestAuthorization,
|
|
153
|
+
// delete methods
|
|
154
|
+
deleteQuantitySample,
|
|
155
|
+
deleteSamples,
|
|
156
|
+
// save methods
|
|
157
|
+
/**
|
|
158
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}
|
|
159
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}
|
|
160
|
+
*/
|
|
161
|
+
saveCategorySample,
|
|
162
|
+
saveCorrelationSample,
|
|
163
|
+
saveQuantitySample,
|
|
164
|
+
saveWorkoutSample,
|
|
165
|
+
saveWorkoutRoute,
|
|
166
|
+
// subscriptions
|
|
167
|
+
subscribeToChanges,
|
|
168
|
+
/**
|
|
169
|
+
* @returns the most recent sample for the given category type.
|
|
170
|
+
*/
|
|
171
|
+
useMostRecentCategorySample,
|
|
172
|
+
/**
|
|
173
|
+
* @returns the most recent sample for the given quantity type.
|
|
174
|
+
*/
|
|
175
|
+
useMostRecentQuantitySample,
|
|
176
|
+
/**
|
|
177
|
+
* @returns the most recent workout sample.
|
|
178
|
+
*/
|
|
179
|
+
useMostRecentWorkout,
|
|
180
|
+
useSubscribeToChanges,
|
|
181
|
+
/**
|
|
182
|
+
* @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.
|
|
183
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs}
|
|
184
|
+
* @returns {boolean | null} true if HealthKit is available; otherwise, false. null while initializing.
|
|
185
|
+
*/
|
|
186
|
+
useIsHealthDataAvailable,
|
|
187
|
+
/**
|
|
188
|
+
* @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.
|
|
189
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
190
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
191
|
+
*/
|
|
192
|
+
useHealthkitAuthorization,
|
|
193
|
+
useSources,
|
|
194
|
+
useStatisticsForQuantity
|
|
195
|
+
};
|
|
196
|
+
const isProtectedDataAvailable = canAccessProtectedData;
|
|
197
|
+
export { authorizationStatusFor, availableQuantityTypes, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutRoutes, isHealthDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, queryStatisticsForQuantity, queryWorkouts, querySources, requestAuthorization, deleteQuantitySample, deleteSamples, getWorkoutPlanById, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutSample, saveWorkoutRoute, subscribeToChanges, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSubscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, useSources, useStatisticsForQuantity, canAccessProtectedData, isProtectedDataAvailable };
|
|
82
198
|
export * from './types';
|
|
83
|
-
export default Healthkit;
|
|
84
199
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","HKAuthorizationRequestStatus","HKAuthorizationStatus","HKBiologicalSex","HKBloodType","HKFitzpatrickSkinType","HKUnits","HKWheelchairUse","notAvailableError","OS","hasWarned","UnavailableFn","retVal","console","warn","Healthkit","authorizationStatusFor","Promise","resolve","notDetermined","availableQuantityTypes","disableAllBackgroundDelivery","disableBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","notSet","getBloodType","getDateOfBirth","Date","getFitzpatrickSkinType","getMostRecentCategorySample","getMostRecentQuantitySample","getMostRecentWorkout","getPreferredUnit","Count","getPreferredUnits","getRequestStatusForAuthorization","unknown","getWheelchairUse","getWorkoutRoutes","isHealthDataAvailable","queryCategorySamples","queryCategorySamplesWithAnchor","samples","deletedSamples","newAnchor","queryCorrelationSamples","queryHeartbeatSeriesSamples","queryHeartbeatSeriesSamplesWithAnchor","queryQuantitySamples","queryQuantitySamplesWithAnchor","queryStatisticsForQuantity","averageQuantity","undefined","maximumQuantity","minimumQuantity","sumQuantity","mostRecentQuantity","mostRecentQuantityDateInterval","duration","queryWorkouts","querySources","requestAuthorization","deleteQuantitySample","deleteSamples","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","saveWorkoutRoute","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges","useHealthkitAuthorization","useIsHealthDataAvailable","canAccessProtectedData","isProtectedDataAvailable"],"sources":["index.tsx"],"sourcesContent":["import { Platform } from 'react-native'\n\nimport {\n HKAuthorizationRequestStatus, HKAuthorizationStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnits, HKWheelchairUse,\n} from './native-types'\n\nimport type ReactNativeHealthkit from './index.ios'\nimport type { QueryCategorySamplesFn } from './utils/queryCategorySamples'\nimport type { QueryQuantitySamplesFn } from './utils/queryQuantitySamples'\n\nconst notAvailableError = `[@kingstinct/react-native-healthkit] Platform \"${\n Platform.OS\n}\" not supported`\n\nlet hasWarned = false\n\nfunction UnavailableFn<T = unknown>(retVal: T) {\n return () => {\n if (!hasWarned) {\n // eslint-disable-next-line no-console\n console.warn(notAvailableError)\n hasWarned = true\n }\n return retVal\n }\n}\n\nconst Healthkit = {\n authorizationStatusFor: UnavailableFn(Promise.resolve(HKAuthorizationStatus.notDetermined)),\n availableQuantityTypes: UnavailableFn([]),\n disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),\n getBiologicalSex: UnavailableFn(Promise.resolve(HKBiologicalSex.notSet)),\n getBloodType: UnavailableFn(Promise.resolve(HKBloodType.notSet)),\n getDateOfBirth: UnavailableFn(Promise.resolve(new Date(0))),\n getFitzpatrickSkinType: UnavailableFn(Promise.resolve(HKFitzpatrickSkinType.notSet)),\n getMostRecentCategorySample: UnavailableFn(Promise.resolve(null)),\n getMostRecentQuantitySample: UnavailableFn(Promise.resolve(null)),\n getMostRecentWorkout: UnavailableFn(Promise.resolve(null)),\n getPreferredUnit: UnavailableFn(Promise.resolve(HKUnits.Count)),\n getPreferredUnits: UnavailableFn(Promise.resolve([])),\n getRequestStatusForAuthorization: UnavailableFn(Promise.resolve(HKAuthorizationRequestStatus.unknown)),\n getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),\n getWorkoutRoutes: UnavailableFn(Promise.resolve([])),\n isHealthDataAvailable: async () => Promise.resolve(false),\n queryCategorySamples: UnavailableFn(Promise.resolve([])) as unknown as QueryCategorySamplesFn,\n queryCategorySamplesWithAnchor: UnavailableFn(Promise.resolve({\n samples: [],\n deletedSamples: [],\n newAnchor: '',\n })),\n queryCorrelationSamples: UnavailableFn(Promise.resolve([])),\n queryHeartbeatSeriesSamples: UnavailableFn(Promise.resolve([])),\n queryHeartbeatSeriesSamplesWithAnchor: UnavailableFn(Promise.resolve({\n samples: [],\n deletedSamples: [],\n newAnchor: '',\n })),\n queryQuantitySamples: UnavailableFn(Promise.resolve([])) as unknown as QueryQuantitySamplesFn,\n queryQuantitySamplesWithAnchor: UnavailableFn(Promise.resolve({\n samples: [],\n deletedSamples: [],\n newAnchor: '',\n })),\n queryStatisticsForQuantity: UnavailableFn(Promise.resolve({\n averageQuantity: undefined,\n maximumQuantity: undefined,\n minimumQuantity: undefined,\n sumQuantity: undefined,\n mostRecentQuantity: undefined,\n mostRecentQuantityDateInterval: undefined,\n duration: undefined,\n })),\n queryWorkouts: UnavailableFn(Promise.resolve([])),\n querySources: UnavailableFn(Promise.resolve([])),\n requestAuthorization: UnavailableFn(Promise.resolve(false)),\n deleteQuantitySample: UnavailableFn(Promise.resolve(false)),\n deleteSamples: UnavailableFn(Promise.resolve(false)),\n saveCategorySample: UnavailableFn(Promise.resolve(false)),\n saveCorrelationSample: UnavailableFn(Promise.resolve(false)),\n saveQuantitySample: UnavailableFn(Promise.resolve(false)),\n saveWorkoutSample: UnavailableFn(Promise.resolve(null)),\n saveWorkoutRoute: UnavailableFn(Promise.resolve(false)),\n subscribeToChanges: UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),\n useMostRecentCategorySample: UnavailableFn(null),\n useMostRecentQuantitySample: UnavailableFn(null),\n useMostRecentWorkout: UnavailableFn(null),\n useSubscribeToChanges: UnavailableFn([null, () => null]),\n useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(HKAuthorizationRequestStatus.unknown)] as const),\n useIsHealthDataAvailable: () => false,\n canAccessProtectedData: async () => Promise.resolve(false),\n isProtectedDataAvailable: async () => Promise.resolve(false),\n} as typeof ReactNativeHealthkit\n\nexport * from './types'\n\nexport default Healthkit as typeof ReactNativeHealthkit\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SACEC,4BAA4B,EAAEC,qBAAqB,EAAEC,eAAe,EAAEC,WAAW,EAAEC,qBAAqB,EAAEC,OAAO,EAAEC,eAAe,QAC7H,gBAAgB;AAMvB,MAAMC,iBAAiB,GAAI,kDACzBR,QAAQ,CAACS,EACV,iBAAgB;AAEjB,IAAIC,SAAS,GAAG,KAAK;AAErB,SAASC,aAAaA,CAAcC,MAAS,EAAE;EAC7C,OAAO,MAAM;IACX,IAAI,CAACF,SAAS,EAAE;MACd;MACAG,OAAO,CAACC,IAAI,CAACN,iBAAiB,CAAC;MAC/BE,SAAS,GAAG,IAAI;IAClB;IACA,OAAOE,MAAM;EACf,CAAC;AACH;AAEA,MAAMG,SAAS,GAAG;EAChBC,sBAAsB,EAAEL,aAAa,CAACM,OAAO,CAACC,OAAO,CAAChB,qBAAqB,CAACiB,aAAa,CAAC,CAAC;EAC3FC,sBAAsB,EAAET,aAAa,CAAC,EAAE,CAAC;EACzCU,4BAA4B,EAAEV,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC,CAAC;EACnEI,yBAAyB,EAAEX,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC,CAAC;EAChEK,wBAAwB,EAAEZ,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC,CAAC;EAC/DM,gBAAgB,EAAEb,aAAa,CAACM,OAAO,CAACC,OAAO,CAACf,eAAe,CAACsB,MAAM,CAAC,CAAC;EACxEC,YAAY,EAAEf,aAAa,CAACM,OAAO,CAACC,OAAO,CAACd,WAAW,CAACqB,MAAM,CAAC,CAAC;EAChEE,cAAc,EAAEhB,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,IAAI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AAC,KAAK,CAAC,CAAC;EAC5DiD,kBAAkB,EAAExD,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC,CAAC;EACzDkD,iBAAiB,EAAEzD,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC,CAAC;EACvDmD,gBAAgB,EAAE1D,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC,CAAC;EACvDoD,kBAAkB,EAAE3D,aAAa,CAACM,OAAO,CAACC,OAAO,CAAC,YAAYD,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACtFqD,2BAA2B,EAAE5D,aAAa,CAAC,IAAI,CAAC;EAChD6D,2BAA2B,EAAE7D,aAAa,CAAC,IAAI,CAAC;EAChD8D,oBAAoB,EAAE9D,aAAa,CAAC,IAAI,CAAC;EACzC+D,qBAAqB,EAAE/D,aAAa,CAAC,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC;EACxDgE,yBAAyB,EAAEhE,aAAa,CAAC,CAAC,IAAI,EAAE,YAAYM,OAAO,CAACC,OAAO,CAACjB,4BAA4B,CAACoC,OAAO,CAAC,CAAU,CAAC;EAC5HuC,wBAAwB,EAAEA,CAAA,KAAM,KAAK;EACrCC,sBAAsB,EAAE,MAAAA,CAAA,KAAY5D,OAAO,CAACC,OAAO,CAAC,KAAK,CAAC;EAC1D4D,wBAAwB,EAAE,MAAAA,CAAA,KAAY7D,OAAO,CAACC,OAAO,CAAC,KAAK;AAC7D,CAAgC;AAEhC,cAAc,SAAS;AAEvB,eAAeH,SAAS"}
|
|
1
|
+
{"version":3,"names":["Platform","useHealthkitAuthorization","useIsHealthDataAvailable","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSources","useStatisticsForQuantity","useSubscribeToChanges","Native","HKQuantityTypeIdentifier","deleteQuantitySample","deleteSamples","getDateOfBirth","getMostRecentCategorySample","getMostRecentQuantitySample","getMostRecentWorkout","getPreferredUnit","getPreferredUnits","getRequestStatusForAuthorization","getWorkoutPlanById","queryCategorySamples","queryCategorySamplesWithAnchor","queryCorrelationSamples","queryHeartbeatSeriesSamples","queryHeartbeatSeriesSamplesWithAnchor","queryQuantitySamples","queryQuantitySamplesWithAnchor","querySources","queryStatisticsForQuantity","queryWorkouts","requestAuthorization","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutRoute","saveWorkoutSample","subscribeToChanges","currentMajorVersionIOS","OS","parseInt","Version","allQuantityTypesList","Object","values","availableQuantityTypes","majorVersionIOS","arguments","length","undefined","filter","type","cyclingCadence","cyclingFunctionalThresholdPower","cyclingPower","cyclingSpeed","physicalEffort","timeInDaylight","includes","authorizationStatusFor","bind","isHealthDataAvailable","canAccessProtectedData","disableBackgroundDelivery","disableAllBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType","getWorkoutRoutes","isProtectedDataAvailable"],"sources":["index.tsx"],"sourcesContent":["import { Platform } from 'react-native'\n\nimport useHealthkitAuthorization from './hooks/useHealthkitAuthorization'\nimport useIsHealthDataAvailable from './hooks/useIsHealthDataAvailable'\nimport useMostRecentCategorySample from './hooks/useMostRecentCategorySample'\nimport useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample'\nimport useMostRecentWorkout from './hooks/useMostRecentWorkout'\nimport useSources from './hooks/useSources'\nimport useStatisticsForQuantity from './hooks/useStatisticsForQuantity'\nimport useSubscribeToChanges from './hooks/useSubscribeToChanges'\nimport Native, { HKQuantityTypeIdentifier } from './native-types'\nimport deleteQuantitySample from './utils/deleteQuantitySample'\nimport deleteSamples from './utils/deleteSamples'\nimport getDateOfBirth from './utils/getDateOfBirth'\nimport getMostRecentCategorySample from './utils/getMostRecentCategorySample'\nimport getMostRecentQuantitySample from './utils/getMostRecentQuantitySample'\nimport getMostRecentWorkout from './utils/getMostRecentWorkout'\nimport getPreferredUnit from './utils/getPreferredUnit'\nimport getPreferredUnits from './utils/getPreferredUnits'\nimport getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'\nimport getWorkoutPlanById from './utils/getWorkoutPlanById'\nimport queryCategorySamples from './utils/queryCategorySamples'\nimport queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor'\nimport queryCorrelationSamples from './utils/queryCorrelationSamples'\nimport queryHeartbeatSeriesSamples from './utils/queryHeartbeatSeriesSamples'\nimport queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesSamplesWithAnchor'\nimport queryQuantitySamples from './utils/queryQuantitySamples'\nimport queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor'\nimport querySources from './utils/querySources'\nimport queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'\nimport queryWorkouts from './utils/queryWorkouts'\nimport requestAuthorization from './utils/requestAuthorization'\nimport saveCategorySample from './utils/saveCategorySample'\nimport saveCorrelationSample from './utils/saveCorrelationSample'\nimport saveQuantitySample from './utils/saveQuantitySample'\nimport saveWorkoutRoute from './utils/saveWorkoutRoute'\nimport saveWorkoutSample from './utils/saveWorkoutSample'\nimport subscribeToChanges from './utils/subscribeToChanges'\n\nconst currentMajorVersionIOS = Platform.OS === 'ios' ? parseInt(Platform.Version, 10) : 0\n\nconst allQuantityTypesList = [...Object.values(HKQuantityTypeIdentifier)]\n\nconst availableQuantityTypes = (majorVersionIOS = currentMajorVersionIOS) => {\n if (majorVersionIOS >= 17) {\n return allQuantityTypesList\n }\n\n // remove types that are not available before iOS 17\n return allQuantityTypesList.filter((type) => ![\n HKQuantityTypeIdentifier.cyclingCadence,\n HKQuantityTypeIdentifier.cyclingFunctionalThresholdPower,\n HKQuantityTypeIdentifier.cyclingPower,\n HKQuantityTypeIdentifier.cyclingSpeed,\n HKQuantityTypeIdentifier.physicalEffort,\n HKQuantityTypeIdentifier.timeInDaylight,\n ].includes(type))\n}\n\nconst authorizationStatusFor = Native.authorizationStatusFor.bind(Native)\nconst isHealthDataAvailable = Native.isHealthDataAvailable.bind(Native)\n// Todo [>8]: Rename to align with Apple function name (isProtectedDataAvailable)\nconst canAccessProtectedData = Native.canAccessProtectedData.bind(Native)\nconst disableBackgroundDelivery = Native.disableBackgroundDelivery.bind(Native)\nconst disableAllBackgroundDelivery = Native.disableAllBackgroundDelivery.bind(Native)\nconst enableBackgroundDelivery = Native.enableBackgroundDelivery.bind(Native)\nconst getBiologicalSex = Native.getBiologicalSex.bind(Native)\nconst getFitzpatrickSkinType = Native.getFitzpatrickSkinType.bind(Native)\nconst getWheelchairUse = Native.getWheelchairUse.bind(Native)\nconst getBloodType = Native.getBloodType.bind(Native)\nconst getWorkoutRoutes = Native.getWorkoutRoutes.bind(Native)\n\n/**\n * @see {@link https://developer.apple.com/documentation/healthkit/about_the_healthkit_framework About the HealthKit Framework (Apple Docs)}\n */\nexport default {\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus authorizationStatus(for:) (Apple Docs) }\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Authorizing access to health data (Apple Docs) }\n */\n authorizationStatusFor,\n\n /**\n *\n * @returns All available quantity types for the current iOS version (currently excluding types that are not available before iOS 17)\n */\n availableQuantityTypes,\n\n /**\n * @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable isHealthDataAvailable() (Apple Docs)}\n * @returns {boolean} true if HealthKit is available; otherwise, false.\n */\n isHealthDataAvailable,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}\n * @returns {boolean} A Boolean value that indicates whether content protection is active.\n */\n isProtectedDataAvailable: canAccessProtectedData,\n\n // Todo [>8]: Remove to align with Apple function name (isProtectedDataAvailable)\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}\n * @deprecated Use {@link isProtectedDataAvailable} instead. Will be removed in next major version.\n * @returns {boolean} A Boolean value that indicates whether content protection is active.\n */\n canAccessProtectedData,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}\n */\n disableAllBackgroundDelivery,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery disableBackgroundDelivery(for:withCompletion:) (Apple Docs)}\n */\n disableBackgroundDelivery,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery enableBackgroundDelivery(for:frequency:withCompletion:) (Apple Docs)}\n */\n enableBackgroundDelivery,\n\n // simple convenience getters\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614171-biologicalsex biologicalSex() (Apple Docs)}\n */\n getBiologicalSex,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614161-fitzpatrickskintype fitzpatrickSkinType() (Apple Docs)}\n */\n getFitzpatrickSkinType,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648356-wheelchairuse wheelchairUse() (Apple Docs)}\n */\n getWheelchairUse,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614164-bloodtype bloodType() (Apple Docs)}\n */\n getBloodType,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648357-dateofbirthcomponents dateOfBirthComponents() (Apple Docs)}\n */\n getDateOfBirth,\n\n getMostRecentQuantitySample,\n getMostRecentCategorySample,\n getMostRecentWorkout,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/reading_route_data Reading route data (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}\n */\n getWorkoutRoutes,\n getWorkoutPlanById,\n\n getPreferredUnit,\n getPreferredUnits,\n getRequestStatusForAuthorization,\n\n // query methods\n queryCategorySamples,\n queryCategorySamplesWithAnchor,\n queryCorrelationSamples,\n queryHeartbeatSeriesSamples,\n queryHeartbeatSeriesSamplesWithAnchor,\n queryQuantitySamples,\n queryQuantitySamplesWithAnchor,\n queryStatisticsForQuantity,\n queryWorkouts,\n querySources,\n\n requestAuthorization,\n\n // delete methods\n deleteQuantitySample,\n deleteSamples,\n\n // save methods\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}\n */\n saveCategorySample,\n saveCorrelationSample,\n saveQuantitySample,\n saveWorkoutSample,\n saveWorkoutRoute,\n\n // subscriptions\n subscribeToChanges,\n\n /**\n * @returns the most recent sample for the given category type.\n */\n useMostRecentCategorySample,\n /**\n * @returns the most recent sample for the given quantity type.\n */\n useMostRecentQuantitySample,\n /**\n * @returns the most recent workout sample.\n */\n useMostRecentWorkout,\n useSubscribeToChanges,\n /**\n * @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs}\n * @returns {boolean | null} true if HealthKit is available; otherwise, false. null while initializing.\n */\n useIsHealthDataAvailable,\n /**\n * @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}\n */\n useHealthkitAuthorization,\n useSources,\n useStatisticsForQuantity,\n}\n\nconst isProtectedDataAvailable = canAccessProtectedData\n\nexport {\n authorizationStatusFor,\n availableQuantityTypes,\n disableAllBackgroundDelivery,\n disableBackgroundDelivery,\n enableBackgroundDelivery,\n getBiologicalSex,\n getBloodType,\n getDateOfBirth,\n getFitzpatrickSkinType,\n getMostRecentCategorySample,\n getMostRecentQuantitySample,\n getMostRecentWorkout,\n getPreferredUnit,\n getPreferredUnits,\n getRequestStatusForAuthorization,\n getWheelchairUse,\n getWorkoutRoutes,\n isHealthDataAvailable,\n queryCategorySamples,\n queryCategorySamplesWithAnchor,\n queryCorrelationSamples,\n queryHeartbeatSeriesSamples,\n queryHeartbeatSeriesSamplesWithAnchor,\n queryQuantitySamples,\n queryQuantitySamplesWithAnchor,\n queryStatisticsForQuantity,\n queryWorkouts,\n querySources,\n requestAuthorization,\n deleteQuantitySample,\n deleteSamples,\n getWorkoutPlanById,\n saveCategorySample,\n saveCorrelationSample,\n saveQuantitySample,\n saveWorkoutSample,\n saveWorkoutRoute,\n subscribeToChanges,\n useMostRecentCategorySample,\n useMostRecentQuantitySample,\n useMostRecentWorkout,\n useSubscribeToChanges,\n useHealthkitAuthorization,\n useIsHealthDataAvailable,\n useSources,\n useStatisticsForQuantity,\n canAccessProtectedData,\n isProtectedDataAvailable,\n}\n\nexport * from './types'\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAOC,yBAAyB,MAAM,mCAAmC;AACzE,OAAOC,wBAAwB,MAAM,kCAAkC;AACvE,OAAOC,2BAA2B,MAAM,qCAAqC;AAC7E,OAAOC,2BAA2B,MAAM,qCAAqC;AAC7E,OAAOC,oBAAoB,MAAM,8BAA8B;AAC/D,OAAOC,UAAU,MAAM,oBAAoB;AAC3C,OAAOC,wBAAwB,MAAM,kCAAkC;AACvE,OAAOC,qBA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B;EAEhB;EACAE,kBAAkB;EAElB;AACF;AACA;EACElC,2BAA2B;EAC3B;AACF;AACA;EACEC,2BAA2B;EAC3B;AACF;AACA;EACEC,oBAAoB;EACpBG,qBAAqB;EACrB;AACF;AACA;AACA;AACA;EACEN,wBAAwB;EACxB;AACF;AACA;AACA;AACA;EACED,yBAAyB;EACzBK,UAAU;EACVC;AACF,CAAC;AAED,MAAMgE,wBAAwB,GAAGT,sBAAsB;AAEvD,SACEH,sBAAsB,EACtBd,sBAAsB,EACtBmB,4BAA4B,EAC5BD,yBAAyB,EACzBE,wBAAwB,EACxBC,gBAAgB,EAChBG,YAAY,EACZxD,cAAc,EACdsD,sBAAsB,EACtBrD,2BAA2B,EAC3BC,2BAA2B,EAC3BC,oBAAoB,EACpBC,gBAAgB,EAChBC,iBAAiB,EACjBC,gCAAgC,EAChCiD,gBAAgB,EAChBE,gBAAgB,EAChBT,qBAAqB,EACrBxC,oBAAoB,EACpBC,8BAA8B,EAC9BC,uBAAuB,EACvBC,2BAA2B,EAC3BC,qCAAqC,EACrCC,oBAAoB,EACpBC,8BAA8B,EAC9BE,0BAA0B,EAC1BC,aAAa,EACbF,YAAY,EACZG,oBAAoB,EACpBpB,oBAAoB,EACpBC,aAAa,EACbQ,kBAAkB,EAClBY,kBAAkB,EAClBC,qBAAqB,EACrBC,kBAAkB,EAClBE,iBAAiB,EACjBD,gBAAgB,EAChBE,kBAAkB,EAClBlC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,oBAAoB,EACpBG,qBAAqB,EACrBP,yBAAyB,EACzBC,wBAAwB,EACxBI,UAAU,EACVC,wBAAwB,EACxBuD,sBAAsB,EACtBS,wBAAwB;AAG1B,cAAc,SAAS"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { HKAuthorizationRequestStatus, HKAuthorizationStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnits, HKWheelchairUse } from './native-types';
|
|
3
|
+
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${Platform.OS}" not supported`;
|
|
4
|
+
let hasWarned = false;
|
|
5
|
+
function UnavailableFn(retVal) {
|
|
6
|
+
return () => {
|
|
7
|
+
if (!hasWarned) {
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.warn(notAvailableError);
|
|
10
|
+
hasWarned = true;
|
|
11
|
+
}
|
|
12
|
+
return retVal;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const authorizationStatusFor = UnavailableFn(Promise.resolve(HKAuthorizationStatus.notDetermined)),
|
|
16
|
+
availableQuantityTypes = UnavailableFn([]),
|
|
17
|
+
disableAllBackgroundDelivery = UnavailableFn(Promise.resolve(false)),
|
|
18
|
+
disableBackgroundDelivery = UnavailableFn(Promise.resolve(false)),
|
|
19
|
+
enableBackgroundDelivery = UnavailableFn(Promise.resolve(false)),
|
|
20
|
+
getBiologicalSex = UnavailableFn(Promise.resolve(HKBiologicalSex.notSet)),
|
|
21
|
+
getBloodType = UnavailableFn(Promise.resolve(HKBloodType.notSet)),
|
|
22
|
+
getDateOfBirth = UnavailableFn(Promise.resolve(new Date(0))),
|
|
23
|
+
getFitzpatrickSkinType = UnavailableFn(Promise.resolve(HKFitzpatrickSkinType.notSet)),
|
|
24
|
+
getMostRecentCategorySample = UnavailableFn(Promise.resolve(null)),
|
|
25
|
+
getMostRecentQuantitySample = UnavailableFn(Promise.resolve(null)),
|
|
26
|
+
getMostRecentWorkout = UnavailableFn(Promise.resolve(null)),
|
|
27
|
+
getPreferredUnit = UnavailableFn(Promise.resolve(HKUnits.Count)),
|
|
28
|
+
getPreferredUnits = UnavailableFn(Promise.resolve([])),
|
|
29
|
+
getRequestStatusForAuthorization = UnavailableFn(Promise.resolve(HKAuthorizationRequestStatus.unknown)),
|
|
30
|
+
getWheelchairUse = UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),
|
|
31
|
+
getWorkoutRoutes = UnavailableFn(Promise.resolve([])),
|
|
32
|
+
isHealthDataAvailable = async () => Promise.resolve(false),
|
|
33
|
+
useSources = UnavailableFn(null),
|
|
34
|
+
useStatisticsForQuantity = UnavailableFn(null),
|
|
35
|
+
queryCategorySamples = UnavailableFn(Promise.resolve([])),
|
|
36
|
+
queryCategorySamplesWithAnchor = UnavailableFn(Promise.resolve({
|
|
37
|
+
samples: [],
|
|
38
|
+
deletedSamples: [],
|
|
39
|
+
newAnchor: ''
|
|
40
|
+
})),
|
|
41
|
+
queryCorrelationSamples = UnavailableFn(Promise.resolve([])),
|
|
42
|
+
queryHeartbeatSeriesSamples = UnavailableFn(Promise.resolve([])),
|
|
43
|
+
queryHeartbeatSeriesSamplesWithAnchor = UnavailableFn(Promise.resolve({
|
|
44
|
+
samples: [],
|
|
45
|
+
deletedSamples: [],
|
|
46
|
+
newAnchor: ''
|
|
47
|
+
})),
|
|
48
|
+
queryQuantitySamples = UnavailableFn(Promise.resolve([])),
|
|
49
|
+
queryQuantitySamplesWithAnchor = UnavailableFn(Promise.resolve({
|
|
50
|
+
samples: [],
|
|
51
|
+
deletedSamples: [],
|
|
52
|
+
newAnchor: ''
|
|
53
|
+
})),
|
|
54
|
+
queryStatisticsForQuantity = UnavailableFn(Promise.resolve({
|
|
55
|
+
averageQuantity: undefined,
|
|
56
|
+
maximumQuantity: undefined,
|
|
57
|
+
minimumQuantity: undefined,
|
|
58
|
+
sumQuantity: undefined,
|
|
59
|
+
mostRecentQuantity: undefined,
|
|
60
|
+
mostRecentQuantityDateInterval: undefined,
|
|
61
|
+
duration: undefined
|
|
62
|
+
})),
|
|
63
|
+
queryWorkouts = UnavailableFn(Promise.resolve([])),
|
|
64
|
+
querySources = UnavailableFn(Promise.resolve([])),
|
|
65
|
+
requestAuthorization = UnavailableFn(Promise.resolve(false)),
|
|
66
|
+
deleteQuantitySample = UnavailableFn(Promise.resolve(false)),
|
|
67
|
+
deleteSamples = UnavailableFn(Promise.resolve(false)),
|
|
68
|
+
getWorkoutPlanById = UnavailableFn(Promise.resolve(null)),
|
|
69
|
+
saveCategorySample = UnavailableFn(Promise.resolve(false)),
|
|
70
|
+
saveCorrelationSample = UnavailableFn(Promise.resolve(false)),
|
|
71
|
+
saveQuantitySample = UnavailableFn(Promise.resolve(false)),
|
|
72
|
+
saveWorkoutSample = UnavailableFn(Promise.resolve(null)),
|
|
73
|
+
saveWorkoutRoute = UnavailableFn(Promise.resolve(false)),
|
|
74
|
+
subscribeToChanges = UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),
|
|
75
|
+
useMostRecentCategorySample = UnavailableFn(null),
|
|
76
|
+
useMostRecentQuantitySample = UnavailableFn(null),
|
|
77
|
+
useMostRecentWorkout = UnavailableFn(null),
|
|
78
|
+
useSubscribeToChanges = UnavailableFn([null, () => null]),
|
|
79
|
+
useHealthkitAuthorization = UnavailableFn([null, async () => Promise.resolve(HKAuthorizationRequestStatus.unknown)]),
|
|
80
|
+
useIsHealthDataAvailable = () => false,
|
|
81
|
+
canAccessProtectedData = async () => Promise.resolve(false),
|
|
82
|
+
isProtectedDataAvailable = async () => Promise.resolve(false);
|
|
83
|
+
const Healthkit = {
|
|
84
|
+
authorizationStatusFor,
|
|
85
|
+
availableQuantityTypes,
|
|
86
|
+
useSources,
|
|
87
|
+
useStatisticsForQuantity,
|
|
88
|
+
disableAllBackgroundDelivery,
|
|
89
|
+
disableBackgroundDelivery,
|
|
90
|
+
enableBackgroundDelivery,
|
|
91
|
+
getBiologicalSex,
|
|
92
|
+
getBloodType,
|
|
93
|
+
getDateOfBirth,
|
|
94
|
+
getFitzpatrickSkinType,
|
|
95
|
+
getMostRecentCategorySample,
|
|
96
|
+
getMostRecentQuantitySample,
|
|
97
|
+
getMostRecentWorkout,
|
|
98
|
+
getPreferredUnit,
|
|
99
|
+
getPreferredUnits,
|
|
100
|
+
getRequestStatusForAuthorization,
|
|
101
|
+
getWheelchairUse,
|
|
102
|
+
getWorkoutRoutes,
|
|
103
|
+
isHealthDataAvailable,
|
|
104
|
+
queryCategorySamples,
|
|
105
|
+
queryCategorySamplesWithAnchor,
|
|
106
|
+
queryCorrelationSamples,
|
|
107
|
+
queryHeartbeatSeriesSamples,
|
|
108
|
+
queryHeartbeatSeriesSamplesWithAnchor,
|
|
109
|
+
queryQuantitySamples,
|
|
110
|
+
queryQuantitySamplesWithAnchor,
|
|
111
|
+
queryStatisticsForQuantity,
|
|
112
|
+
queryWorkouts,
|
|
113
|
+
querySources,
|
|
114
|
+
requestAuthorization,
|
|
115
|
+
deleteQuantitySample,
|
|
116
|
+
deleteSamples,
|
|
117
|
+
getWorkoutPlanById,
|
|
118
|
+
saveCategorySample,
|
|
119
|
+
saveCorrelationSample,
|
|
120
|
+
saveQuantitySample,
|
|
121
|
+
saveWorkoutSample,
|
|
122
|
+
saveWorkoutRoute,
|
|
123
|
+
subscribeToChanges,
|
|
124
|
+
useMostRecentCategorySample,
|
|
125
|
+
useMostRecentQuantitySample,
|
|
126
|
+
useMostRecentWorkout,
|
|
127
|
+
useSubscribeToChanges,
|
|
128
|
+
useHealthkitAuthorization,
|
|
129
|
+
useIsHealthDataAvailable,
|
|
130
|
+
canAccessProtectedData,
|
|
131
|
+
isProtectedDataAvailable
|
|
132
|
+
};
|
|
133
|
+
export { authorizationStatusFor, availableQuantityTypes, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, useSources, useStatisticsForQuantity, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutRoutes, isHealthDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, queryStatisticsForQuantity, queryWorkouts, querySources, requestAuthorization, deleteQuantitySample, deleteSamples, getWorkoutPlanById, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutSample, saveWorkoutRoute, subscribeToChanges, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSubscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, canAccessProtectedData, isProtectedDataAvailable };
|
|
134
|
+
export * from './types';
|
|
135
|
+
export default Healthkit;
|
|
136
|
+
//# sourceMappingURL=index.native.js.map
|