From 22e4d0d00c96b3ad8b8729a24130e17ad806bfd0 Mon Sep 17 00:00:00 2001 From: Andrew Zey Date: Tue, 29 Oct 2024 21:05:20 -0500 Subject: [PATCH 1/2] Bridgeless architecture support for lazy loaded functions --- index.js | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 06e5105d..b8795404 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,104 @@ import { Activities, Observers, Permissions, Units } from './src/constants' -const { AppleHealthKit } = require('react-native').NativeModules +const NativeModules = require('react-native').NativeModules + +export const HealthKit = { + initHealthKit: NativeModules.AppleHealthKit.initHealthKit, + isAvailable: NativeModules.AppleHealthKit.isAvailable, + getBiologicalSex: NativeModules.AppleHealthKit.getBiologicalSex, + getBloodType: NativeModules.AppleHealthKit.getBloodType, + getDateOfBirth: NativeModules.AppleHealthKit.getDateOfBirth, + getLatestWeight: NativeModules.AppleHealthKit.getLatestWeight, + getWeightSamples: NativeModules.AppleHealthKit.getWeightSamples, + saveWeight: NativeModules.AppleHealthKit.saveWeight, + getLatestHeight: NativeModules.AppleHealthKit.getLatestHeight, + getHeightSamples: NativeModules.AppleHealthKit.getHeightSamples, + saveHeight: NativeModules.AppleHealthKit.saveHeight, + getLatestWaistCircumference: NativeModules.AppleHealthKit.getLatestWaistCircumference, + getWaistCircumferenceSamples: NativeModules.AppleHealthKit.getWaistCircumferenceSamples, + saveWaistCircumference: NativeModules.AppleHealthKit.saveWaistCircumference, + getLatestPeakFlow: NativeModules.AppleHealthKit.getLatestPeakFlow, + getPeakFlowSamples: NativeModules.AppleHealthKit.getPeakFlowSamples, + savePeakFlow: NativeModules.AppleHealthKit.savePeakFlow, + saveLeanBodyMass: NativeModules.AppleHealthKit.saveLeanBodyMass, + getLatestBmi: NativeModules.AppleHealthKit.getLatestBmi, + getBmiSamples: NativeModules.AppleHealthKit.getBmiSamples, + saveBmi: NativeModules.AppleHealthKit.saveBmi, + getLatestBodyFatPercentage: NativeModules.AppleHealthKit.getLatestBodyFatPercentage, + getBodyFatPercentageSamples: NativeModules.AppleHealthKit.getBodyFatPercentageSamples, + getLatestLeanBodyMass: NativeModules.AppleHealthKit.getLatestLeanBodyMass, + getLeanBodyMassSamples: NativeModules.AppleHealthKit.getLeanBodyMassSamples, + getStepCount: NativeModules.AppleHealthKit.getStepCount, + getSamples: NativeModules.AppleHealthKit.getSamples, + getAnchoredWorkouts: NativeModules.AppleHealthKit.getAnchoredWorkouts, + getDailyStepCountSamples: NativeModules.AppleHealthKit.getDailyStepCountSamples, + saveSteps: NativeModules.AppleHealthKit.saveSteps, + saveWalkingRunningDistance: NativeModules.AppleHealthKit.saveWalkingRunningDistance, + getDistanceWalkingRunning: NativeModules.AppleHealthKit.getDistanceWalkingRunning, + getDailyDistanceWalkingRunningSamples: NativeModules.AppleHealthKit.getDailyDistanceWalkingRunningSamples, + getDistanceCycling: NativeModules.AppleHealthKit.getDistanceCycling, + getDailyDistanceCyclingSamples: NativeModules.AppleHealthKit.getDailyDistanceCyclingSamples, + getFlightsClimbed: NativeModules.AppleHealthKit.getFlightsClimbed, + getDailyFlightsClimbedSamples: NativeModules.AppleHealthKit.getDailyFlightsClimbedSamples, + getEnergyConsumedSamples: NativeModules.AppleHealthKit.getEnergyConsumedSamples, + getProteinSamples: NativeModules.AppleHealthKit.getProteinSamples, + getFiberSamples: NativeModules.AppleHealthKit.getFiberSamples, + getTotalFatSamples: NativeModules.AppleHealthKit.getTotalFatSamples, + saveFood: NativeModules.AppleHealthKit.saveFood, + saveWater: NativeModules.AppleHealthKit.saveWater, + getWater: NativeModules.AppleHealthKit.getWater, + saveHeartRateSample: NativeModules.AppleHealthKit.saveHeartRateSample, + getWaterSamples: NativeModules.AppleHealthKit.getWaterSamples, + getHeartRateSamples: NativeModules.AppleHealthKit.getHeartRateSamples, + getRestingHeartRate: NativeModules.AppleHealthKit.getRestingHeartRate, + getWalkingHeartRateAverage: NativeModules.AppleHealthKit.getWalkingHeartRateAverage, + getActiveEnergyBurned: NativeModules.AppleHealthKit.getActiveEnergyBurned, + getBasalEnergyBurned: NativeModules.AppleHealthKit.getBasalEnergyBurned, + getAppleExerciseTime: NativeModules.AppleHealthKit.getAppleExerciseTime, + getAppleStandTime: NativeModules.AppleHealthKit.getAppleStandTime, + getVo2MaxSamples: NativeModules.AppleHealthKit.getVo2MaxSamples, + getBodyTemperatureSamples: NativeModules.AppleHealthKit.getBodyTemperatureSamples, + getBloodPressureSamples: NativeModules.AppleHealthKit.getBloodPressureSamples, + getRespiratoryRateSamples: NativeModules.AppleHealthKit.getRespiratoryRateSamples, + getHeartRateVariabilitySamples: NativeModules.AppleHealthKit.getHeartRateVariabilitySamples, + getHeartbeatSeriesSamples: NativeModules.AppleHealthKit.getHeartbeatSeriesSamples, + getRestingHeartRateSamples: NativeModules.AppleHealthKit.getRestingHeartRateSamples, + getBloodGlucoseSamples: NativeModules.AppleHealthKit.getBloodGlucoseSamples, + getCarbohydratesSamples: NativeModules.AppleHealthKit.getCarbohydratesSamples, + saveBloodGlucoseSample: NativeModules.AppleHealthKit.saveBloodGlucoseSample, + saveCarbohydratesSample: NativeModules.AppleHealthKit.saveCarbohydratesSample, + deleteBloodGlucoseSample: NativeModules.AppleHealthKit.deleteBloodGlucoseSample, + deleteCarbohydratesSample: NativeModules.AppleHealthKit.deleteCarbohydratesSample, + getSleepSamples: NativeModules.AppleHealthKit.getSleepSamples, + getInfo: NativeModules.AppleHealthKit.getInfo, + getMindfulSession: NativeModules.AppleHealthKit.getMindfulSession, + saveMindfulSession: NativeModules.AppleHealthKit.saveMindfulSession, + getWorkoutRouteSamples: NativeModules.AppleHealthKit.getWorkoutRouteSamples, + saveWorkout: NativeModules.AppleHealthKit.saveWorkout, + getAuthStatus: NativeModules.AppleHealthKit.getAuthStatus, + getLatestBloodAlcoholContent: NativeModules.AppleHealthKit.getLatestBloodAlcoholContent, + getBloodAlcoholContentSamples: NativeModules.AppleHealthKit.getBloodAlcoholContentSamples, + saveBloodAlcoholContent: NativeModules.AppleHealthKit.saveBloodAlcoholContent, + getDistanceSwimming: NativeModules.AppleHealthKit.getDistanceSwimming, + getDailyDistanceSwimmingSamples: NativeModules.AppleHealthKit.getDailyDistanceSwimmingSamples, + getOxygenSaturationSamples: NativeModules.AppleHealthKit.getOxygenSaturationSamples, + getElectrocardiogramSamples: NativeModules.AppleHealthKit.getElectrocardiogramSamples, + saveBodyFatPercentage: NativeModules.AppleHealthKit.saveBodyFatPercentage, + saveBodyTemperature: NativeModules.AppleHealthKit.saveBodyTemperature, + getEnvironmentalAudioExposure: NativeModules.AppleHealthKit.getEnvironmentalAudioExposure, + getHeadphoneAudioExposure: NativeModules.AppleHealthKit.getHeadphoneAudioExposure, + getClinicalRecords: NativeModules.AppleHealthKit.getClinicalRecords, + getActivitySummary: NativeModules.AppleHealthKit.getActivitySummary, + getInsulinDeliverySamples: NativeModules.AppleHealthKit.getInsulinDeliverySamples, + saveInsulinDeliverySample: NativeModules.AppleHealthKit.saveInsulinDeliverySample, + deleteInsulinDeliverySample: NativeModules.AppleHealthKit.deleteInsulinDeliverySample, -export const HealthKit = Object.assign({}, AppleHealthKit, { Constants: { Activities, Observers, Permissions, Units, }, -}) +} module.exports = HealthKit From 83864900bf90c8f966c27d6484ce80900d13501f Mon Sep 17 00:00:00 2001 From: Andrew Zey Date: Thu, 31 Oct 2024 17:41:42 -0500 Subject: [PATCH 2/2] Update index.js for bridgeless architecture compatibility --- index.js | 180 +++++++++++++++++++++++++++---------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/index.js b/index.js index b8795404..cb45201e 100644 --- a/index.js +++ b/index.js @@ -1,97 +1,97 @@ import { Activities, Observers, Permissions, Units } from './src/constants' -const NativeModules = require('react-native').NativeModules +const { AppleHealthKit } = require('react-native').NativeModules export const HealthKit = { - initHealthKit: NativeModules.AppleHealthKit.initHealthKit, - isAvailable: NativeModules.AppleHealthKit.isAvailable, - getBiologicalSex: NativeModules.AppleHealthKit.getBiologicalSex, - getBloodType: NativeModules.AppleHealthKit.getBloodType, - getDateOfBirth: NativeModules.AppleHealthKit.getDateOfBirth, - getLatestWeight: NativeModules.AppleHealthKit.getLatestWeight, - getWeightSamples: NativeModules.AppleHealthKit.getWeightSamples, - saveWeight: NativeModules.AppleHealthKit.saveWeight, - getLatestHeight: NativeModules.AppleHealthKit.getLatestHeight, - getHeightSamples: NativeModules.AppleHealthKit.getHeightSamples, - saveHeight: NativeModules.AppleHealthKit.saveHeight, - getLatestWaistCircumference: NativeModules.AppleHealthKit.getLatestWaistCircumference, - getWaistCircumferenceSamples: NativeModules.AppleHealthKit.getWaistCircumferenceSamples, - saveWaistCircumference: NativeModules.AppleHealthKit.saveWaistCircumference, - getLatestPeakFlow: NativeModules.AppleHealthKit.getLatestPeakFlow, - getPeakFlowSamples: NativeModules.AppleHealthKit.getPeakFlowSamples, - savePeakFlow: NativeModules.AppleHealthKit.savePeakFlow, - saveLeanBodyMass: NativeModules.AppleHealthKit.saveLeanBodyMass, - getLatestBmi: NativeModules.AppleHealthKit.getLatestBmi, - getBmiSamples: NativeModules.AppleHealthKit.getBmiSamples, - saveBmi: NativeModules.AppleHealthKit.saveBmi, - getLatestBodyFatPercentage: NativeModules.AppleHealthKit.getLatestBodyFatPercentage, - getBodyFatPercentageSamples: NativeModules.AppleHealthKit.getBodyFatPercentageSamples, - getLatestLeanBodyMass: NativeModules.AppleHealthKit.getLatestLeanBodyMass, - getLeanBodyMassSamples: NativeModules.AppleHealthKit.getLeanBodyMassSamples, - getStepCount: NativeModules.AppleHealthKit.getStepCount, - getSamples: NativeModules.AppleHealthKit.getSamples, - getAnchoredWorkouts: NativeModules.AppleHealthKit.getAnchoredWorkouts, - getDailyStepCountSamples: NativeModules.AppleHealthKit.getDailyStepCountSamples, - saveSteps: NativeModules.AppleHealthKit.saveSteps, - saveWalkingRunningDistance: NativeModules.AppleHealthKit.saveWalkingRunningDistance, - getDistanceWalkingRunning: NativeModules.AppleHealthKit.getDistanceWalkingRunning, - getDailyDistanceWalkingRunningSamples: NativeModules.AppleHealthKit.getDailyDistanceWalkingRunningSamples, - getDistanceCycling: NativeModules.AppleHealthKit.getDistanceCycling, - getDailyDistanceCyclingSamples: NativeModules.AppleHealthKit.getDailyDistanceCyclingSamples, - getFlightsClimbed: NativeModules.AppleHealthKit.getFlightsClimbed, - getDailyFlightsClimbedSamples: NativeModules.AppleHealthKit.getDailyFlightsClimbedSamples, - getEnergyConsumedSamples: NativeModules.AppleHealthKit.getEnergyConsumedSamples, - getProteinSamples: NativeModules.AppleHealthKit.getProteinSamples, - getFiberSamples: NativeModules.AppleHealthKit.getFiberSamples, - getTotalFatSamples: NativeModules.AppleHealthKit.getTotalFatSamples, - saveFood: NativeModules.AppleHealthKit.saveFood, - saveWater: NativeModules.AppleHealthKit.saveWater, - getWater: NativeModules.AppleHealthKit.getWater, - saveHeartRateSample: NativeModules.AppleHealthKit.saveHeartRateSample, - getWaterSamples: NativeModules.AppleHealthKit.getWaterSamples, - getHeartRateSamples: NativeModules.AppleHealthKit.getHeartRateSamples, - getRestingHeartRate: NativeModules.AppleHealthKit.getRestingHeartRate, - getWalkingHeartRateAverage: NativeModules.AppleHealthKit.getWalkingHeartRateAverage, - getActiveEnergyBurned: NativeModules.AppleHealthKit.getActiveEnergyBurned, - getBasalEnergyBurned: NativeModules.AppleHealthKit.getBasalEnergyBurned, - getAppleExerciseTime: NativeModules.AppleHealthKit.getAppleExerciseTime, - getAppleStandTime: NativeModules.AppleHealthKit.getAppleStandTime, - getVo2MaxSamples: NativeModules.AppleHealthKit.getVo2MaxSamples, - getBodyTemperatureSamples: NativeModules.AppleHealthKit.getBodyTemperatureSamples, - getBloodPressureSamples: NativeModules.AppleHealthKit.getBloodPressureSamples, - getRespiratoryRateSamples: NativeModules.AppleHealthKit.getRespiratoryRateSamples, - getHeartRateVariabilitySamples: NativeModules.AppleHealthKit.getHeartRateVariabilitySamples, - getHeartbeatSeriesSamples: NativeModules.AppleHealthKit.getHeartbeatSeriesSamples, - getRestingHeartRateSamples: NativeModules.AppleHealthKit.getRestingHeartRateSamples, - getBloodGlucoseSamples: NativeModules.AppleHealthKit.getBloodGlucoseSamples, - getCarbohydratesSamples: NativeModules.AppleHealthKit.getCarbohydratesSamples, - saveBloodGlucoseSample: NativeModules.AppleHealthKit.saveBloodGlucoseSample, - saveCarbohydratesSample: NativeModules.AppleHealthKit.saveCarbohydratesSample, - deleteBloodGlucoseSample: NativeModules.AppleHealthKit.deleteBloodGlucoseSample, - deleteCarbohydratesSample: NativeModules.AppleHealthKit.deleteCarbohydratesSample, - getSleepSamples: NativeModules.AppleHealthKit.getSleepSamples, - getInfo: NativeModules.AppleHealthKit.getInfo, - getMindfulSession: NativeModules.AppleHealthKit.getMindfulSession, - saveMindfulSession: NativeModules.AppleHealthKit.saveMindfulSession, - getWorkoutRouteSamples: NativeModules.AppleHealthKit.getWorkoutRouteSamples, - saveWorkout: NativeModules.AppleHealthKit.saveWorkout, - getAuthStatus: NativeModules.AppleHealthKit.getAuthStatus, - getLatestBloodAlcoholContent: NativeModules.AppleHealthKit.getLatestBloodAlcoholContent, - getBloodAlcoholContentSamples: NativeModules.AppleHealthKit.getBloodAlcoholContentSamples, - saveBloodAlcoholContent: NativeModules.AppleHealthKit.saveBloodAlcoholContent, - getDistanceSwimming: NativeModules.AppleHealthKit.getDistanceSwimming, - getDailyDistanceSwimmingSamples: NativeModules.AppleHealthKit.getDailyDistanceSwimmingSamples, - getOxygenSaturationSamples: NativeModules.AppleHealthKit.getOxygenSaturationSamples, - getElectrocardiogramSamples: NativeModules.AppleHealthKit.getElectrocardiogramSamples, - saveBodyFatPercentage: NativeModules.AppleHealthKit.saveBodyFatPercentage, - saveBodyTemperature: NativeModules.AppleHealthKit.saveBodyTemperature, - getEnvironmentalAudioExposure: NativeModules.AppleHealthKit.getEnvironmentalAudioExposure, - getHeadphoneAudioExposure: NativeModules.AppleHealthKit.getHeadphoneAudioExposure, - getClinicalRecords: NativeModules.AppleHealthKit.getClinicalRecords, - getActivitySummary: NativeModules.AppleHealthKit.getActivitySummary, - getInsulinDeliverySamples: NativeModules.AppleHealthKit.getInsulinDeliverySamples, - saveInsulinDeliverySample: NativeModules.AppleHealthKit.saveInsulinDeliverySample, - deleteInsulinDeliverySample: NativeModules.AppleHealthKit.deleteInsulinDeliverySample, + initHealthKit: AppleHealthKit.initHealthKit, + isAvailable: AppleHealthKit.isAvailable, + getBiologicalSex: AppleHealthKit.getBiologicalSex, + getBloodType: AppleHealthKit.getBloodType, + getDateOfBirth: AppleHealthKit.getDateOfBirth, + getLatestWeight: AppleHealthKit.getLatestWeight, + getWeightSamples: AppleHealthKit.getWeightSamples, + saveWeight: AppleHealthKit.saveWeight, + getLatestHeight: AppleHealthKit.getLatestHeight, + getHeightSamples: AppleHealthKit.getHeightSamples, + saveHeight: AppleHealthKit.saveHeight, + getLatestWaistCircumference: AppleHealthKit.getLatestWaistCircumference, + getWaistCircumferenceSamples: AppleHealthKit.getWaistCircumferenceSamples, + saveWaistCircumference: AppleHealthKit.saveWaistCircumference, + getLatestPeakFlow: AppleHealthKit.getLatestPeakFlow, + getPeakFlowSamples: AppleHealthKit.getPeakFlowSamples, + savePeakFlow: AppleHealthKit.savePeakFlow, + saveLeanBodyMass: AppleHealthKit.saveLeanBodyMass, + getLatestBmi: AppleHealthKit.getLatestBmi, + getBmiSamples: AppleHealthKit.getBmiSamples, + saveBmi: AppleHealthKit.saveBmi, + getLatestBodyFatPercentage: AppleHealthKit.getLatestBodyFatPercentage, + getBodyFatPercentageSamples: AppleHealthKit.getBodyFatPercentageSamples, + getLatestLeanBodyMass: AppleHealthKit.getLatestLeanBodyMass, + getLeanBodyMassSamples: AppleHealthKit.getLeanBodyMassSamples, + getStepCount: AppleHealthKit.getStepCount, + getSamples: AppleHealthKit.getSamples, + getAnchoredWorkouts: AppleHealthKit.getAnchoredWorkouts, + getDailyStepCountSamples: AppleHealthKit.getDailyStepCountSamples, + saveSteps: AppleHealthKit.saveSteps, + saveWalkingRunningDistance: AppleHealthKit.saveWalkingRunningDistance, + getDistanceWalkingRunning: AppleHealthKit.getDistanceWalkingRunning, + getDailyDistanceWalkingRunningSamples: AppleHealthKit.getDailyDistanceWalkingRunningSamples, + getDistanceCycling: AppleHealthKit.getDistanceCycling, + getDailyDistanceCyclingSamples: AppleHealthKit.getDailyDistanceCyclingSamples, + getFlightsClimbed: AppleHealthKit.getFlightsClimbed, + getDailyFlightsClimbedSamples: AppleHealthKit.getDailyFlightsClimbedSamples, + getEnergyConsumedSamples: AppleHealthKit.getEnergyConsumedSamples, + getProteinSamples: AppleHealthKit.getProteinSamples, + getFiberSamples: AppleHealthKit.getFiberSamples, + getTotalFatSamples: AppleHealthKit.getTotalFatSamples, + saveFood: AppleHealthKit.saveFood, + saveWater: AppleHealthKit.saveWater, + getWater: AppleHealthKit.getWater, + saveHeartRateSample: AppleHealthKit.saveHeartRateSample, + getWaterSamples: AppleHealthKit.getWaterSamples, + getHeartRateSamples: AppleHealthKit.getHeartRateSamples, + getRestingHeartRate: AppleHealthKit.getRestingHeartRate, + getWalkingHeartRateAverage: AppleHealthKit.getWalkingHeartRateAverage, + getActiveEnergyBurned: AppleHealthKit.getActiveEnergyBurned, + getBasalEnergyBurned: AppleHealthKit.getBasalEnergyBurned, + getAppleExerciseTime: AppleHealthKit.getAppleExerciseTime, + getAppleStandTime: AppleHealthKit.getAppleStandTime, + getVo2MaxSamples: AppleHealthKit.getVo2MaxSamples, + getBodyTemperatureSamples: AppleHealthKit.getBodyTemperatureSamples, + getBloodPressureSamples: AppleHealthKit.getBloodPressureSamples, + getRespiratoryRateSamples: AppleHealthKit.getRespiratoryRateSamples, + getHeartRateVariabilitySamples: AppleHealthKit.getHeartRateVariabilitySamples, + getHeartbeatSeriesSamples: AppleHealthKit.getHeartbeatSeriesSamples, + getRestingHeartRateSamples: AppleHealthKit.getRestingHeartRateSamples, + getBloodGlucoseSamples: AppleHealthKit.getBloodGlucoseSamples, + getCarbohydratesSamples: AppleHealthKit.getCarbohydratesSamples, + saveBloodGlucoseSample: AppleHealthKit.saveBloodGlucoseSample, + saveCarbohydratesSample: AppleHealthKit.saveCarbohydratesSample, + deleteBloodGlucoseSample: AppleHealthKit.deleteBloodGlucoseSample, + deleteCarbohydratesSample: AppleHealthKit.deleteCarbohydratesSample, + getSleepSamples: AppleHealthKit.getSleepSamples, + getInfo: AppleHealthKit.getInfo, + getMindfulSession: AppleHealthKit.getMindfulSession, + saveMindfulSession: AppleHealthKit.saveMindfulSession, + getWorkoutRouteSamples: AppleHealthKit.getWorkoutRouteSamples, + saveWorkout: AppleHealthKit.saveWorkout, + getAuthStatus: AppleHealthKit.getAuthStatus, + getLatestBloodAlcoholContent: AppleHealthKit.getLatestBloodAlcoholContent, + getBloodAlcoholContentSamples: AppleHealthKit.getBloodAlcoholContentSamples, + saveBloodAlcoholContent: AppleHealthKit.saveBloodAlcoholContent, + getDistanceSwimming: AppleHealthKit.getDistanceSwimming, + getDailyDistanceSwimmingSamples: AppleHealthKit.getDailyDistanceSwimmingSamples, + getOxygenSaturationSamples: AppleHealthKit.getOxygenSaturationSamples, + getElectrocardiogramSamples: AppleHealthKit.getElectrocardiogramSamples, + saveBodyFatPercentage: AppleHealthKit.saveBodyFatPercentage, + saveBodyTemperature: AppleHealthKit.saveBodyTemperature, + getEnvironmentalAudioExposure: AppleHealthKit.getEnvironmentalAudioExposure, + getHeadphoneAudioExposure: AppleHealthKit.getHeadphoneAudioExposure, + getClinicalRecords: AppleHealthKit.getClinicalRecords, + getActivitySummary: AppleHealthKit.getActivitySummary, + getInsulinDeliverySamples: AppleHealthKit.getInsulinDeliverySamples, + saveInsulinDeliverySample: AppleHealthKit.saveInsulinDeliverySample, + deleteInsulinDeliverySample: AppleHealthKit.deleteInsulinDeliverySample, Constants: { Activities,