react-native-workouts 0.1.0 → 0.2.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeWorkouts.types.js","sourceRoot":"","sources":["../src/ReactNativeWorkouts.types.ts"],"names":[],"mappings":"AAAA,gBAAgB","sourcesContent":["// Authorization\n\nexport type AuthorizationStatus =\n | 'authorized'\n | 'notDetermined'\n | 'denied'\n | 'unknown';\n\n// Activity Types\n\nexport type ActivityType =\n | 'running'\n | 'cycling'\n | 'walking'\n | 'hiking'\n | 'swimming'\n | 'rowing'\n | 'elliptical'\n | 'stairClimbing'\n | 'highIntensityIntervalTraining'\n | 'yoga'\n | 'functionalStrengthTraining'\n | 'traditionalStrengthTraining'\n | 'dance'\n | 'jumpRope'\n | 'coreTraining'\n | 'pilates'\n | 'kickboxing'\n | 'stairs'\n | 'stepTraining'\n | 'wheelchairRunPace'\n | 'wheelchairWalkPace';\n\nexport type LocationType = 'indoor' | 'outdoor';\n\n// Units\n\nexport type DistanceUnit =\n | 'meters'\n | 'm'\n | 'kilometers'\n | 'km'\n | 'miles'\n | 'mi'\n | 'yards'\n | 'yd'\n | 'feet'\n | 'ft';\n\nexport type TimeUnit =\n | 'seconds'\n | 's'\n | 'sec'\n | 'minutes'\n | 'min'\n | 'hours'\n | 'h'\n | 'hr';\n\nexport type EnergyUnit =\n | 'kilocalories'\n | 'kcal'\n | 'cal'\n | 'kilojoules'\n | 'kj';\n\nexport type SpeedUnit =\n | 'metersPerSecond'\n | 'mps'\n | 'm/s'\n | 'kilometersPerHour'\n | 'kph'\n | 'km/h'\n | 'milesPerHour'\n | 'mph';\n\nexport type PaceUnit =\n | 'minutesPerKilometer'\n | 'min/km'\n | 'minutesPerMile'\n | 'min/mi';\n\n// Goals\n\nexport interface OpenGoal {\n type: 'open';\n}\n\nexport interface DistanceGoal {\n type: 'distance';\n value: number;\n unit?: DistanceUnit;\n}\n\nexport interface TimeGoal {\n type: 'time';\n value: number;\n unit?: TimeUnit;\n}\n\nexport interface EnergyGoal {\n type: 'energy';\n value: number;\n unit?: EnergyUnit;\n}\n\nexport type WorkoutGoal = OpenGoal | DistanceGoal | TimeGoal | EnergyGoal;\n\n// Alerts\n\nexport interface HeartRateZoneAlert {\n type: 'heartRate';\n zone: number;\n}\n\nexport interface HeartRateRangeAlert {\n type: 'heartRate';\n min: number;\n max: number;\n}\n\nexport interface PaceAlert {\n type: 'pace';\n min: number;\n max: number;\n unit?: PaceUnit;\n}\n\nexport interface SpeedAlert {\n type: 'speed';\n min: number;\n max: number;\n unit?: SpeedUnit;\n}\n\nexport interface CadenceAlert {\n type: 'cadence';\n min: number;\n max: number;\n}\n\nexport interface PowerAlert {\n type: 'power';\n min: number;\n max: number;\n}\n\nexport type WorkoutAlert =\n | HeartRateZoneAlert\n | HeartRateRangeAlert\n | PaceAlert\n | SpeedAlert\n | CadenceAlert\n | PowerAlert;\n\n// Workout Steps\n\nexport type StepPurpose = 'work' | 'recovery';\n\nexport interface WorkoutStep {\n goal?: WorkoutGoal;\n alert?: WorkoutAlert;\n}\n\nexport interface IntervalStep {\n purpose: StepPurpose;\n goal?: WorkoutGoal;\n alert?: WorkoutAlert;\n}\n\nexport interface IntervalBlock {\n iterations?: number;\n steps: IntervalStep[];\n}\n\n// Workout Configurations\n\nexport interface CustomWorkoutConfig {\n activityType: ActivityType;\n locationType?: LocationType;\n displayName?: string;\n warmup?: WorkoutStep;\n blocks: IntervalBlock[];\n cooldown?: WorkoutStep;\n}\n\nexport interface SingleGoalWorkoutConfig {\n activityType: ActivityType;\n locationType?: LocationType;\n displayName?: string;\n goal: WorkoutGoal;\n}\n\nexport interface PacerTarget {\n type: 'speed' | 'pace';\n value: number;\n unit?: SpeedUnit | PaceUnit;\n}\n\nexport interface PacerWorkoutConfig {\n activityType: ActivityType;\n locationType?: LocationType;\n displayName?: string;\n target: PacerTarget;\n}\n\n// Date Components\n\nexport interface DateComponents {\n year?: number;\n month?: number;\n day?: number;\n hour?: number;\n minute?: number;\n}\n\n// Results\n\nexport interface WorkoutValidationResult {\n valid: boolean;\n displayName: string;\n}\n\nexport interface ScheduleResult {\n success: boolean;\n id: string;\n}\n\nexport interface ScheduledWorkout {\n id: string;\n date: DateComponents;\n}\n\n// Module Events\n\nexport interface AuthorizationChangeEvent {\n status: AuthorizationStatus;\n}\n\nexport type ReactNativeWorkoutsModuleEvents = {\n onAuthorizationChange: (event: AuthorizationChangeEvent) => void;\n};\n"]}
1
+ {"version":3,"file":"ReactNativeWorkouts.types.js","sourceRoot":"","sources":["../src/ReactNativeWorkouts.types.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * WorkoutKit authorization state as seen by Apple's `WorkoutScheduler`.\n */\n\nexport type AuthorizationStatus =\n | \"authorized\"\n | \"notDetermined\"\n | \"denied\"\n | \"unknown\";\n\n// Shared Objects\n\nimport type { SharedObject } from \"expo\";\n\n// Activity Types\n\n/**\n * Supported workout activity types exposed by this package.\n *\n * Note: these map to HealthKit `HKWorkoutActivityType` values.\n */\nexport type ActivityType =\n | \"running\"\n | \"cycling\"\n | \"walking\"\n | \"hiking\"\n | \"swimming\"\n | \"rowing\"\n | \"elliptical\"\n | \"stairClimbing\"\n | \"highIntensityIntervalTraining\"\n | \"yoga\"\n | \"functionalStrengthTraining\"\n | \"traditionalStrengthTraining\"\n | \"dance\"\n | \"jumpRope\"\n | \"coreTraining\"\n | \"pilates\"\n | \"kickboxing\"\n | \"stairs\"\n | \"stepTraining\"\n | \"wheelchairRunPace\"\n | \"wheelchairWalkPace\";\n\nexport type LocationType = \"indoor\" | \"outdoor\";\n\n// Units\n\nexport type DistanceUnit =\n | \"meters\"\n | \"m\"\n | \"kilometers\"\n | \"km\"\n | \"miles\"\n | \"mi\"\n | \"yards\"\n | \"yd\"\n | \"feet\"\n | \"ft\";\n\nexport type TimeUnit =\n | \"seconds\"\n | \"s\"\n | \"sec\"\n | \"minutes\"\n | \"min\"\n | \"hours\"\n | \"h\"\n | \"hr\";\n\nexport type EnergyUnit =\n | \"kilocalories\"\n | \"kcal\"\n | \"cal\"\n | \"kilojoules\"\n | \"kj\";\n\nexport type SpeedUnit =\n | \"metersPerSecond\"\n | \"mps\"\n | \"m/s\"\n | \"kilometersPerHour\"\n | \"kph\"\n | \"km/h\"\n | \"milesPerHour\"\n | \"mph\";\n\nexport type PaceUnit =\n | \"minutesPerKilometer\"\n | \"min/km\"\n | \"minutesPerMile\"\n | \"min/mi\";\n\n// Goals\n\nexport interface OpenGoal {\n type: \"open\";\n}\n\nexport interface DistanceGoal {\n type: \"distance\";\n value: number;\n unit?: DistanceUnit;\n}\n\nexport interface TimeGoal {\n type: \"time\";\n value: number;\n unit?: TimeUnit;\n}\n\nexport interface EnergyGoal {\n type: \"energy\";\n value: number;\n unit?: EnergyUnit;\n}\n\nexport type WorkoutGoal = OpenGoal | DistanceGoal | TimeGoal | EnergyGoal;\n\n// Alerts\n\nexport interface HeartRateZoneAlert {\n type: \"heartRate\";\n zone: number;\n}\n\nexport interface HeartRateRangeAlert {\n type: \"heartRate\";\n min: number;\n max: number;\n}\n\nexport interface PaceAlert {\n type: \"pace\";\n min: number;\n max: number;\n unit?: PaceUnit;\n}\n\nexport interface SpeedAlert {\n type: \"speed\";\n min: number;\n max: number;\n unit?: SpeedUnit;\n}\n\nexport interface CadenceAlert {\n type: \"cadence\";\n min: number;\n max: number;\n}\n\nexport interface PowerAlert {\n type: \"power\";\n min: number;\n max: number;\n}\n\nexport type WorkoutAlert =\n | HeartRateZoneAlert\n | HeartRateRangeAlert\n | PaceAlert\n | SpeedAlert\n | CadenceAlert\n | PowerAlert;\n\n// Workout Steps\n\nexport type StepPurpose = \"work\" | \"recovery\";\n\nexport interface WorkoutStep {\n goal?: WorkoutGoal;\n alert?: WorkoutAlert;\n}\n\nexport interface IntervalStep {\n purpose: StepPurpose;\n goal?: WorkoutGoal;\n alert?: WorkoutAlert;\n}\n\nexport interface IntervalBlock {\n iterations?: number;\n steps: IntervalStep[];\n}\n\n// Workout Configurations\n\nexport interface CustomWorkoutConfig {\n /**\n * Activity type (running, cycling, etc).\n */\n activityType: ActivityType;\n /**\n * Indoor/outdoor (where applicable). Defaults to `\"outdoor\"` when omitted.\n */\n locationType?: LocationType;\n /**\n * Display name used by the system (where supported by WorkoutKit).\n */\n displayName?: string;\n warmup?: WorkoutStep;\n blocks: IntervalBlock[];\n cooldown?: WorkoutStep;\n}\n\nexport interface SingleGoalWorkoutConfig {\n activityType: ActivityType;\n locationType?: LocationType;\n /**\n * Optional label for your app/back-end. WorkoutKit may not display this for all workout kinds.\n */\n displayName?: string;\n goal: WorkoutGoal;\n}\n\nexport interface PacerTarget {\n type: \"speed\" | \"pace\";\n value: number;\n unit?: SpeedUnit | PaceUnit;\n}\n\nexport interface PacerWorkoutConfig {\n activityType: ActivityType;\n locationType?: LocationType;\n /**\n * Optional label for your app/back-end. WorkoutKit may not display this for all workout kinds.\n */\n displayName?: string;\n target: PacerTarget;\n}\n\nexport type SwimBikeRunActivityType = \"swimming\" | \"cycling\" | \"running\";\n\nexport interface SwimBikeRunActivityConfig {\n type: SwimBikeRunActivityType;\n /**\n * For running/cycling: `\"indoor\" | \"outdoor\"`.\n * For swimming: `\"indoor\"` means pool, `\"outdoor\"` means open water.\n */\n locationType?: LocationType;\n}\n\nexport interface SwimBikeRunWorkoutConfig {\n /**\n * Display name shown by the system for multisport workouts.\n */\n displayName?: string;\n /**\n * Ordered list of activities (e.g. swim -> bike -> run).\n */\n activities: SwimBikeRunActivityConfig[];\n}\n\n// Date Components\n\nexport interface DateComponents {\n year?: number;\n month?: number;\n day?: number;\n hour?: number;\n minute?: number;\n}\n\n// Results\n\nexport interface WorkoutValidationResult {\n valid: boolean;\n displayName: string;\n}\n\nexport interface ScheduleResult {\n success: boolean;\n id: string;\n}\n\nexport interface ScheduledWorkout {\n id: string;\n date: DateComponents;\n}\n\n// Module Events\n\nexport interface AuthorizationChangeEvent {\n status: AuthorizationStatus;\n}\n\nexport type ReactNativeWorkoutsModuleEvents = {\n onAuthorizationChange: (event: AuthorizationChangeEvent) => void;\n};\n\nexport type WorkoutPlanKind = \"custom\" | \"singleGoal\" | \"pacer\" | \"swimBikeRun\";\n\nexport interface WorkoutPlanExport {\n /**\n * UUID of the underlying `WorkoutPlan` instance.\n *\n * This is useful for debugging/logging and for matching the ID returned by `plan.scheduleAndSync`.\n */\n id: string;\n kind: WorkoutPlanKind;\n /**\n * The original config used to create the plan.\n *\n * Use this to persist/share the plan in your own backend and recreate the plan later.\n */\n config: unknown;\n}\n\nexport declare class WorkoutPlan extends SharedObject<{}> {\n /**\n * UUID of this plan instance.\n */\n readonly id: string;\n /**\n * Which kind of workout this plan represents.\n */\n readonly kind: WorkoutPlanKind;\n\n /**\n * Shows Apple's system Workout preview modal (includes “Add to Watch / Send to Watch” UX).\n */\n preview(): Promise<boolean>;\n\n /**\n * Schedules the plan using Apple's `WorkoutScheduler`.\n *\n * This is the mechanism that syncs the plan to the Apple Watch Workout app.\n */\n scheduleAndSync(date: DateComponents): Promise<ScheduleResult>;\n\n /**\n * Returns `{ id, kind, config }` for storing/sharing the plan in your own backend.\n *\n * This does NOT export a system-importable file — it's a JSON payload you can use to recreate\n * the plan via the `create*WorkoutPlan(...)` factories.\n */\n export(): WorkoutPlanExport;\n}\n"]}
@@ -1,18 +1,92 @@
1
- import { NativeModule } from 'expo';
2
- import type { ReactNativeWorkoutsModuleEvents, AuthorizationStatus, ActivityType, LocationType, CustomWorkoutConfig, SingleGoalWorkoutConfig, PacerWorkoutConfig, DateComponents, WorkoutValidationResult, ScheduleResult, ScheduledWorkout } from './ReactNativeWorkouts.types';
1
+ import { NativeModule } from "expo";
2
+ import type { ActivityType, AuthorizationStatus, CustomWorkoutConfig, DateComponents, LocationType, PacerWorkoutConfig, ReactNativeWorkoutsModuleEvents, ScheduledWorkout, ScheduleResult, SingleGoalWorkoutConfig, SwimBikeRunWorkoutConfig, WorkoutPlan, WorkoutValidationResult } from "./ReactNativeWorkouts.types";
3
3
  declare class ReactNativeWorkoutsModule extends NativeModule<ReactNativeWorkoutsModuleEvents> {
4
+ /**
5
+ * Whether Health data is available on this device.
6
+ * On iOS simulators this is typically `false`.
7
+ */
4
8
  readonly isAvailable: boolean;
9
+ /**
10
+ * Returns the current WorkoutKit authorization status.
11
+ */
5
12
  getAuthorizationStatus(): Promise<AuthorizationStatus>;
13
+ /**
14
+ * Prompts the user for WorkoutKit authorization (if needed).
15
+ */
6
16
  requestAuthorization(): Promise<AuthorizationStatus>;
17
+ /**
18
+ * Returns whether a given goal type is supported for the provided activity + location.
19
+ */
7
20
  supportsGoal(activityType: ActivityType, locationType: LocationType, goalType: string): Promise<boolean>;
21
+ /**
22
+ * Validates a custom workout config. (Legacy name: this does not persist anything.)
23
+ */
8
24
  createCustomWorkout(config: CustomWorkoutConfig): Promise<WorkoutValidationResult>;
25
+ /**
26
+ * Previews a custom workout via Apple's system modal.
27
+ */
28
+ previewWorkout(config: CustomWorkoutConfig): Promise<boolean>;
29
+ /**
30
+ * Schedules a custom workout (syncs it to the Apple Watch Workout app).
31
+ *
32
+ * Prefer using `useCustomWorkout(...)` + `plan.scheduleAndSync(...)` for new code.
33
+ */
9
34
  scheduleWorkout(config: CustomWorkoutConfig, date: DateComponents): Promise<ScheduleResult>;
35
+ /**
36
+ * Validates a single-goal workout config. (Legacy name: this does not persist anything.)
37
+ */
10
38
  createSingleGoalWorkout(config: SingleGoalWorkoutConfig): Promise<WorkoutValidationResult>;
39
+ /**
40
+ * Previews a single-goal workout via Apple's system modal.
41
+ */
42
+ previewSingleGoalWorkout(config: SingleGoalWorkoutConfig): Promise<boolean>;
43
+ /**
44
+ * Schedules a single-goal workout (syncs it to the Apple Watch Workout app).
45
+ *
46
+ * Prefer using `useSingleGoalWorkout(...)` + `plan.scheduleAndSync(...)` for new code.
47
+ */
11
48
  scheduleSingleGoalWorkout(config: SingleGoalWorkoutConfig, date: DateComponents): Promise<ScheduleResult>;
49
+ /**
50
+ * Validates a pacer workout config. (Legacy name: this does not persist anything.)
51
+ */
12
52
  createPacerWorkout(config: PacerWorkoutConfig): Promise<WorkoutValidationResult>;
53
+ /**
54
+ * Previews a pacer workout via Apple's system modal.
55
+ */
56
+ previewPacerWorkout(config: PacerWorkoutConfig): Promise<boolean>;
57
+ /**
58
+ * Schedules a pacer workout (syncs it to the Apple Watch Workout app).
59
+ *
60
+ * Prefer using `usePacerWorkout(...)` + `plan.scheduleAndSync(...)` for new code.
61
+ */
13
62
  schedulePacerWorkout(config: PacerWorkoutConfig, date: DateComponents): Promise<ScheduleResult>;
63
+ /**
64
+ * Creates a stateful `WorkoutPlan` shared object (recommended API for new code).
65
+ */
66
+ createCustomWorkoutPlan(config: CustomWorkoutConfig): Promise<WorkoutPlan>;
67
+ /**
68
+ * Creates a stateful `WorkoutPlan` shared object (recommended API for new code).
69
+ */
70
+ createSingleGoalWorkoutPlan(config: SingleGoalWorkoutConfig): Promise<WorkoutPlan>;
71
+ /**
72
+ * Creates a stateful `WorkoutPlan` shared object (recommended API for new code).
73
+ */
74
+ createPacerWorkoutPlan(config: PacerWorkoutConfig): Promise<WorkoutPlan>;
75
+ /**
76
+ * Creates a stateful multisport `WorkoutPlan` shared object (recommended API for new code).
77
+ */
78
+ createSwimBikeRunWorkoutPlan(config: SwimBikeRunWorkoutConfig): Promise<WorkoutPlan>;
79
+ /**
80
+ * Lists scheduled workouts created by this app.
81
+ */
14
82
  getScheduledWorkouts(): Promise<ScheduledWorkout[]>;
83
+ /**
84
+ * Removes a scheduled workout by ID.
85
+ */
15
86
  removeScheduledWorkout(id: string): Promise<boolean>;
87
+ /**
88
+ * Removes all scheduled workouts created by this app.
89
+ */
16
90
  removeAllScheduledWorkouts(): Promise<boolean>;
17
91
  getSupportedActivityTypes(): ActivityType[];
18
92
  getSupportedGoalTypes(): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeWorkoutsModule.d.ts","sourceRoot":"","sources":["../src/ReactNativeWorkoutsModule.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AC;IACnC;;OAEG;IACH,wBAAwB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC;IAC3E;;;;OAIG;IACH,yBAAyB,CACvB,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC;IAG1B;;OAEG;IACH,kBAAkB,CAChB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,uBAAuB,CAAC;IACnC;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IACjE;;;;OAIG;IACH,oBAAoB,CAClB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC;IAG1B;;OAEG;IACH,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IAC1E;;OAEG;IACH,2BAA2B,CACzB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,WAAW,CAAC;IACvB;;OAEG;IACH,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IACxE;;OAEG;IACH,4BAA4B,CAC1B,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,WAAW,CAAC;IAGvB;;OAEG;IACH,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IACnD;;OAEG;IACH,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IACpD;;OAEG;IACH,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC;IAG9C,yBAAyB,IAAI,YAAY,EAAE;IAC3C,qBAAqB,IAAI,MAAM,EAAE;IACjC,yBAAyB,IAAI,YAAY,EAAE;CAC5C;;AAED,wBAEE"}
@@ -1,3 +1,3 @@
1
- import { requireNativeModule } from 'expo';
2
- export default requireNativeModule('ReactNativeWorkouts');
1
+ import { requireNativeModule } from "expo";
2
+ export default requireNativeModule("ReactNativeWorkouts");
3
3
  //# sourceMappingURL=ReactNativeWorkoutsModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeWorkoutsModule.js","sourceRoot":"","sources":["../src/ReactNativeWorkoutsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAqEzD,eAAe,mBAAmB,CAChC,qBAAqB,CACtB,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\n\nimport type {\n ReactNativeWorkoutsModuleEvents,\n AuthorizationStatus,\n ActivityType,\n LocationType,\n CustomWorkoutConfig,\n SingleGoalWorkoutConfig,\n PacerWorkoutConfig,\n DateComponents,\n WorkoutValidationResult,\n ScheduleResult,\n ScheduledWorkout,\n} from './ReactNativeWorkouts.types';\n\ndeclare class ReactNativeWorkoutsModule extends NativeModule<ReactNativeWorkoutsModuleEvents> {\n // Constants\n readonly isAvailable: boolean;\n\n // Authorization\n getAuthorizationStatus(): Promise<AuthorizationStatus>;\n requestAuthorization(): Promise<AuthorizationStatus>;\n\n // Validation\n supportsGoal(\n activityType: ActivityType,\n locationType: LocationType,\n goalType: string\n ): Promise<boolean>;\n\n // Custom Workouts\n createCustomWorkout(\n config: CustomWorkoutConfig\n ): Promise<WorkoutValidationResult>;\n scheduleWorkout(\n config: CustomWorkoutConfig,\n date: DateComponents\n ): Promise<ScheduleResult>;\n\n // Single Goal Workouts\n createSingleGoalWorkout(\n config: SingleGoalWorkoutConfig\n ): Promise<WorkoutValidationResult>;\n scheduleSingleGoalWorkout(\n config: SingleGoalWorkoutConfig,\n date: DateComponents\n ): Promise<ScheduleResult>;\n\n // Pacer Workouts\n createPacerWorkout(\n config: PacerWorkoutConfig\n ): Promise<WorkoutValidationResult>;\n schedulePacerWorkout(\n config: PacerWorkoutConfig,\n date: DateComponents\n ): Promise<ScheduleResult>;\n\n // Scheduled Workouts Management\n getScheduledWorkouts(): Promise<ScheduledWorkout[]>;\n removeScheduledWorkout(id: string): Promise<boolean>;\n removeAllScheduledWorkouts(): Promise<boolean>;\n\n // Utility\n getSupportedActivityTypes(): ActivityType[];\n getSupportedGoalTypes(): string[];\n getSupportedLocationTypes(): LocationType[];\n}\n\nexport default requireNativeModule<ReactNativeWorkoutsModule>(\n 'ReactNativeWorkouts'\n);\n"]}
1
+ {"version":3,"file":"ReactNativeWorkoutsModule.js","sourceRoot":"","sources":["../src/ReactNativeWorkoutsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAwJzD,eAAe,mBAAmB,CAChC,qBAAqB,CACtB,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\nimport type {\n ActivityType,\n AuthorizationStatus,\n CustomWorkoutConfig,\n DateComponents,\n LocationType,\n PacerWorkoutConfig,\n ReactNativeWorkoutsModuleEvents,\n ScheduledWorkout,\n ScheduleResult,\n SingleGoalWorkoutConfig,\n SwimBikeRunWorkoutConfig,\n WorkoutPlan,\n WorkoutValidationResult,\n} from \"./ReactNativeWorkouts.types\";\n\ndeclare class ReactNativeWorkoutsModule\n extends NativeModule<ReactNativeWorkoutsModuleEvents> {\n // Constants\n /**\n * Whether Health data is available on this device.\n * On iOS simulators this is typically `false`.\n */\n readonly isAvailable: boolean;\n\n // Authorization\n /**\n * Returns the current WorkoutKit authorization status.\n */\n getAuthorizationStatus(): Promise<AuthorizationStatus>;\n /**\n * Prompts the user for WorkoutKit authorization (if needed).\n */\n requestAuthorization(): Promise<AuthorizationStatus>;\n\n // Validation\n /**\n * Returns whether a given goal type is supported for the provided activity + location.\n */\n supportsGoal(\n activityType: ActivityType,\n locationType: LocationType,\n goalType: string,\n ): Promise<boolean>;\n\n // Custom Workouts\n /**\n * Validates a custom workout config. (Legacy name: this does not persist anything.)\n */\n createCustomWorkout(\n config: CustomWorkoutConfig,\n ): Promise<WorkoutValidationResult>;\n /**\n * Previews a custom workout via Apple's system modal.\n */\n previewWorkout(config: CustomWorkoutConfig): Promise<boolean>;\n /**\n * Schedules a custom workout (syncs it to the Apple Watch Workout app).\n *\n * Prefer using `useCustomWorkout(...)` + `plan.scheduleAndSync(...)` for new code.\n */\n scheduleWorkout(\n config: CustomWorkoutConfig,\n date: DateComponents,\n ): Promise<ScheduleResult>;\n\n // Single Goal Workouts\n /**\n * Validates a single-goal workout config. (Legacy name: this does not persist anything.)\n */\n createSingleGoalWorkout(\n config: SingleGoalWorkoutConfig,\n ): Promise<WorkoutValidationResult>;\n /**\n * Previews a single-goal workout via Apple's system modal.\n */\n previewSingleGoalWorkout(config: SingleGoalWorkoutConfig): Promise<boolean>;\n /**\n * Schedules a single-goal workout (syncs it to the Apple Watch Workout app).\n *\n * Prefer using `useSingleGoalWorkout(...)` + `plan.scheduleAndSync(...)` for new code.\n */\n scheduleSingleGoalWorkout(\n config: SingleGoalWorkoutConfig,\n date: DateComponents,\n ): Promise<ScheduleResult>;\n\n // Pacer Workouts\n /**\n * Validates a pacer workout config. (Legacy name: this does not persist anything.)\n */\n createPacerWorkout(\n config: PacerWorkoutConfig,\n ): Promise<WorkoutValidationResult>;\n /**\n * Previews a pacer workout via Apple's system modal.\n */\n previewPacerWorkout(config: PacerWorkoutConfig): Promise<boolean>;\n /**\n * Schedules a pacer workout (syncs it to the Apple Watch Workout app).\n *\n * Prefer using `usePacerWorkout(...)` + `plan.scheduleAndSync(...)` for new code.\n */\n schedulePacerWorkout(\n config: PacerWorkoutConfig,\n date: DateComponents,\n ): Promise<ScheduleResult>;\n\n // Shared WorkoutPlan factories (object-oriented API)\n /**\n * Creates a stateful `WorkoutPlan` shared object (recommended API for new code).\n */\n createCustomWorkoutPlan(config: CustomWorkoutConfig): Promise<WorkoutPlan>;\n /**\n * Creates a stateful `WorkoutPlan` shared object (recommended API for new code).\n */\n createSingleGoalWorkoutPlan(\n config: SingleGoalWorkoutConfig,\n ): Promise<WorkoutPlan>;\n /**\n * Creates a stateful `WorkoutPlan` shared object (recommended API for new code).\n */\n createPacerWorkoutPlan(config: PacerWorkoutConfig): Promise<WorkoutPlan>;\n /**\n * Creates a stateful multisport `WorkoutPlan` shared object (recommended API for new code).\n */\n createSwimBikeRunWorkoutPlan(\n config: SwimBikeRunWorkoutConfig,\n ): Promise<WorkoutPlan>;\n\n // Scheduled Workouts Management\n /**\n * Lists scheduled workouts created by this app.\n */\n getScheduledWorkouts(): Promise<ScheduledWorkout[]>;\n /**\n * Removes a scheduled workout by ID.\n */\n removeScheduledWorkout(id: string): Promise<boolean>;\n /**\n * Removes all scheduled workouts created by this app.\n */\n removeAllScheduledWorkouts(): Promise<boolean>;\n\n // Utility\n getSupportedActivityTypes(): ActivityType[];\n getSupportedGoalTypes(): string[];\n getSupportedLocationTypes(): LocationType[];\n}\n\nexport default requireNativeModule<ReactNativeWorkoutsModule>(\n \"ReactNativeWorkouts\",\n);\n"]}
@@ -0,0 +1,70 @@
1
+ import type { AuthorizationStatus, CustomWorkoutConfig, DateComponents, PacerWorkoutConfig, ScheduledWorkout, SingleGoalWorkoutConfig, SwimBikeRunWorkoutConfig, WorkoutPlan } from "./ReactNativeWorkouts.types";
2
+ type UseWorkoutPlanResult = {
3
+ /**
4
+ * A stateful `WorkoutPlan` shared object, or `null` when config is null/invalid.
5
+ */
6
+ plan: WorkoutPlan | null;
7
+ /**
8
+ * `true` while the hook is (re)creating the plan in native.
9
+ */
10
+ isLoading: boolean;
11
+ /**
12
+ * Any error that occurred while creating the plan.
13
+ */
14
+ error: Error | null;
15
+ };
16
+ export declare function useCustomWorkout(config: CustomWorkoutConfig | null): UseWorkoutPlanResult;
17
+ export declare function useSingleGoalWorkout(config: SingleGoalWorkoutConfig | null): UseWorkoutPlanResult;
18
+ export declare function usePacerWorkout(config: PacerWorkoutConfig | null): UseWorkoutPlanResult;
19
+ export declare function useSwimBikeRunWorkout(config: SwimBikeRunWorkoutConfig | null): UseWorkoutPlanResult;
20
+ export type UseWorkoutAuthorizationResult = {
21
+ /**
22
+ * Current authorization status (fetched on mount).
23
+ */
24
+ status: AuthorizationStatus | null;
25
+ isLoading: boolean;
26
+ error: Error | null;
27
+ /**
28
+ * Re-reads the authorization status.
29
+ */
30
+ refresh: () => Promise<AuthorizationStatus>;
31
+ /**
32
+ * Prompts for authorization (if needed) and returns the new status.
33
+ */
34
+ request: () => Promise<AuthorizationStatus>;
35
+ };
36
+ /**
37
+ * Hook to read/request WorkoutKit authorization.
38
+ */
39
+ export declare function useWorkoutAuthorization(): UseWorkoutAuthorizationResult;
40
+ export type UseScheduledWorkoutsResult = {
41
+ workouts: ScheduledWorkout[];
42
+ isLoading: boolean;
43
+ error: Error | null;
44
+ /**
45
+ * Reloads scheduled workouts from native.
46
+ */
47
+ reload: () => Promise<ScheduledWorkout[]>;
48
+ /**
49
+ * Removes all scheduled workouts created by this app.
50
+ */
51
+ removeAll: () => Promise<void>;
52
+ /**
53
+ * Removes a single scheduled workout by ID.
54
+ */
55
+ remove: (id: string) => Promise<void>;
56
+ /**
57
+ * Schedules (syncs) a plan for the given date components, then reloads the list.
58
+ *
59
+ * Under the hood this calls `plan.scheduleAndSync(date)`.
60
+ */
61
+ schedule: (plan: WorkoutPlan, date: DateComponents) => Promise<{
62
+ id: string;
63
+ }>;
64
+ };
65
+ /**
66
+ * Hook to manage scheduled workouts.
67
+ */
68
+ export declare function useScheduledWorkouts(): UseScheduledWorkoutsResult;
69
+ export {};
70
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,WAAW,EACd,MAAM,6BAA6B,CAAC;AAErC,KAAK,oBAAoB,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB;;OAEG;IAC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IAAI,EAAE,cAAc,KACnB,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,0BAA0B,CA2EjE"}
package/build/hooks.js ADDED
@@ -0,0 +1,194 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import ReactNativeWorkouts from "./ReactNativeWorkoutsModule";
3
+ function useWorkoutPlan(config, createPlan) {
4
+ const [plan, setPlan] = useState(null);
5
+ const [isLoading, setIsLoading] = useState(false);
6
+ const [error, setError] = useState(null);
7
+ const planRef = useRef(null);
8
+ // We want to recreate the plan when the config meaningfully changes.
9
+ // Consumers should keep config stable (useMemo) for best results.
10
+ const configKey = useMemo(() => JSON.stringify(config ?? null), [config]);
11
+ useEffect(() => {
12
+ let cancelled = false;
13
+ const run = async () => {
14
+ if (!config) {
15
+ setPlan(null);
16
+ planRef.current?.release();
17
+ planRef.current = null;
18
+ setError(null);
19
+ setIsLoading(false);
20
+ return;
21
+ }
22
+ setIsLoading(true);
23
+ setError(null);
24
+ try {
25
+ const nextPlan = await createPlan(config);
26
+ if (cancelled) {
27
+ // If the effect already cleaned up, ensure we don't leak the native object.
28
+ nextPlan.release();
29
+ return;
30
+ }
31
+ planRef.current?.release();
32
+ planRef.current = nextPlan;
33
+ setPlan(nextPlan);
34
+ }
35
+ catch (e) {
36
+ if (!cancelled) {
37
+ setPlan(null);
38
+ planRef.current?.release();
39
+ planRef.current = null;
40
+ setError(e instanceof Error ? e : new Error(String(e)));
41
+ }
42
+ }
43
+ finally {
44
+ if (!cancelled) {
45
+ setIsLoading(false);
46
+ }
47
+ }
48
+ };
49
+ void run();
50
+ return () => {
51
+ cancelled = true;
52
+ planRef.current?.release();
53
+ planRef.current = null;
54
+ };
55
+ }, [configKey, createPlan]);
56
+ return { plan, isLoading, error };
57
+ }
58
+ export function useCustomWorkout(config) {
59
+ return useWorkoutPlan(config, ReactNativeWorkouts.createCustomWorkoutPlan);
60
+ }
61
+ export function useSingleGoalWorkout(config) {
62
+ return useWorkoutPlan(config, ReactNativeWorkouts.createSingleGoalWorkoutPlan);
63
+ }
64
+ export function usePacerWorkout(config) {
65
+ return useWorkoutPlan(config, ReactNativeWorkouts.createPacerWorkoutPlan);
66
+ }
67
+ export function useSwimBikeRunWorkout(config) {
68
+ return useWorkoutPlan(config, ReactNativeWorkouts.createSwimBikeRunWorkoutPlan);
69
+ }
70
+ /**
71
+ * Hook to read/request WorkoutKit authorization.
72
+ */
73
+ export function useWorkoutAuthorization() {
74
+ const [status, setStatus] = useState(null);
75
+ const [isLoading, setIsLoading] = useState(false);
76
+ const [error, setError] = useState(null);
77
+ const refresh = useCallback(async () => {
78
+ setIsLoading(true);
79
+ setError(null);
80
+ try {
81
+ const next = await ReactNativeWorkouts.getAuthorizationStatus();
82
+ setStatus(next);
83
+ return next;
84
+ }
85
+ catch (e) {
86
+ const err = e instanceof Error ? e : new Error(String(e));
87
+ setError(err);
88
+ throw err;
89
+ }
90
+ finally {
91
+ setIsLoading(false);
92
+ }
93
+ }, []);
94
+ const request = useCallback(async () => {
95
+ setIsLoading(true);
96
+ setError(null);
97
+ try {
98
+ const next = await ReactNativeWorkouts.requestAuthorization();
99
+ setStatus(next);
100
+ return next;
101
+ }
102
+ catch (e) {
103
+ const err = e instanceof Error ? e : new Error(String(e));
104
+ setError(err);
105
+ throw err;
106
+ }
107
+ finally {
108
+ setIsLoading(false);
109
+ }
110
+ }, []);
111
+ useEffect(() => {
112
+ void refresh();
113
+ }, [refresh]);
114
+ return { status, isLoading, error, refresh, request };
115
+ }
116
+ /**
117
+ * Hook to manage scheduled workouts.
118
+ */
119
+ export function useScheduledWorkouts() {
120
+ const [workouts, setWorkouts] = useState([]);
121
+ const [isLoading, setIsLoading] = useState(false);
122
+ const [error, setError] = useState(null);
123
+ const reload = useCallback(async () => {
124
+ setIsLoading(true);
125
+ setError(null);
126
+ try {
127
+ const next = await ReactNativeWorkouts.getScheduledWorkouts();
128
+ setWorkouts(next);
129
+ return next;
130
+ }
131
+ catch (e) {
132
+ const err = e instanceof Error ? e : new Error(String(e));
133
+ setError(err);
134
+ throw err;
135
+ }
136
+ finally {
137
+ setIsLoading(false);
138
+ }
139
+ }, []);
140
+ const removeAll = useCallback(async () => {
141
+ setIsLoading(true);
142
+ setError(null);
143
+ try {
144
+ await ReactNativeWorkouts.removeAllScheduledWorkouts();
145
+ setWorkouts([]);
146
+ }
147
+ catch (e) {
148
+ const err = e instanceof Error ? e : new Error(String(e));
149
+ setError(err);
150
+ throw err;
151
+ }
152
+ finally {
153
+ setIsLoading(false);
154
+ }
155
+ }, []);
156
+ const remove = useCallback(async (id) => {
157
+ setIsLoading(true);
158
+ setError(null);
159
+ try {
160
+ await ReactNativeWorkouts.removeScheduledWorkout(id);
161
+ setWorkouts((prev) => prev.filter((w) => w.id !== id));
162
+ }
163
+ catch (e) {
164
+ const err = e instanceof Error ? e : new Error(String(e));
165
+ setError(err);
166
+ throw err;
167
+ }
168
+ finally {
169
+ setIsLoading(false);
170
+ }
171
+ }, []);
172
+ const schedule = useCallback(async (plan, date) => {
173
+ setIsLoading(true);
174
+ setError(null);
175
+ try {
176
+ const result = await plan.scheduleAndSync(date);
177
+ await reload();
178
+ return { id: result.id };
179
+ }
180
+ catch (e) {
181
+ const err = e instanceof Error ? e : new Error(String(e));
182
+ setError(err);
183
+ throw err;
184
+ }
185
+ finally {
186
+ setIsLoading(false);
187
+ }
188
+ }, [reload]);
189
+ useEffect(() => {
190
+ void reload();
191
+ }, [reload]);
192
+ return { workouts, isLoading, error, reload, removeAll, remove, schedule };
193
+ }
194
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,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EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC/E,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport ReactNativeWorkouts from \"./ReactNativeWorkoutsModule\";\nimport type {\n AuthorizationStatus,\n CustomWorkoutConfig,\n DateComponents,\n PacerWorkoutConfig,\n ScheduledWorkout,\n SingleGoalWorkoutConfig,\n SwimBikeRunWorkoutConfig,\n WorkoutPlan,\n} from \"./ReactNativeWorkouts.types\";\n\ntype UseWorkoutPlanResult = {\n /**\n * A stateful `WorkoutPlan` shared object, or `null` when config is null/invalid.\n */\n plan: WorkoutPlan | null;\n /**\n * `true` while the hook is (re)creating the plan in native.\n */\n isLoading: boolean;\n /**\n * Any error that occurred while creating the plan.\n */\n error: Error | null;\n};\n\nfunction useWorkoutPlan<TConfig>(\n config: TConfig | null | undefined,\n createPlan: (config: TConfig) => Promise<WorkoutPlan>,\n): UseWorkoutPlanResult {\n const [plan, setPlan] = useState<WorkoutPlan | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const planRef = useRef<WorkoutPlan | null>(null);\n\n // We want to recreate the plan when the config meaningfully changes.\n // Consumers should keep config stable (useMemo) for best results.\n const configKey = useMemo(() => JSON.stringify(config ?? null), [config]);\n\n useEffect(() => {\n let cancelled = false;\n\n const run = async () => {\n if (!config) {\n setPlan(null);\n planRef.current?.release();\n planRef.current = null;\n setError(null);\n setIsLoading(false);\n return;\n }\n\n setIsLoading(true);\n setError(null);\n\n try {\n const nextPlan = await createPlan(config);\n if (cancelled) {\n // If the effect already cleaned up, ensure we don't leak the native object.\n nextPlan.release();\n return;\n }\n\n planRef.current?.release();\n planRef.current = nextPlan;\n setPlan(nextPlan);\n } catch (e) {\n if (!cancelled) {\n setPlan(null);\n planRef.current?.release();\n planRef.current = null;\n setError(e instanceof Error ? e : new Error(String(e)));\n }\n } finally {\n if (!cancelled) {\n setIsLoading(false);\n }\n }\n };\n\n void run();\n\n return () => {\n cancelled = true;\n planRef.current?.release();\n planRef.current = null;\n };\n }, [configKey, createPlan]);\n\n return { plan, isLoading, error };\n}\n\nexport function useCustomWorkout(\n config: CustomWorkoutConfig | null,\n): UseWorkoutPlanResult {\n return useWorkoutPlan(config, ReactNativeWorkouts.createCustomWorkoutPlan);\n}\n\nexport function useSingleGoalWorkout(\n config: SingleGoalWorkoutConfig | null,\n): UseWorkoutPlanResult {\n return useWorkoutPlan(\n config,\n ReactNativeWorkouts.createSingleGoalWorkoutPlan,\n );\n}\n\nexport function usePacerWorkout(\n config: PacerWorkoutConfig | null,\n): UseWorkoutPlanResult {\n return useWorkoutPlan(config, ReactNativeWorkouts.createPacerWorkoutPlan);\n}\n\nexport function useSwimBikeRunWorkout(\n config: SwimBikeRunWorkoutConfig | null,\n): UseWorkoutPlanResult {\n return useWorkoutPlan(\n config,\n ReactNativeWorkouts.createSwimBikeRunWorkoutPlan,\n );\n}\n\nexport type UseWorkoutAuthorizationResult = {\n /**\n * Current authorization status (fetched on mount).\n */\n status: AuthorizationStatus | null;\n isLoading: boolean;\n error: Error | null;\n /**\n * Re-reads the authorization status.\n */\n refresh: () => Promise<AuthorizationStatus>;\n /**\n * Prompts for authorization (if needed) and returns the new status.\n */\n request: () => Promise<AuthorizationStatus>;\n};\n\n/**\n * Hook to read/request WorkoutKit authorization.\n */\nexport function useWorkoutAuthorization(): UseWorkoutAuthorizationResult {\n const [status, setStatus] = useState<AuthorizationStatus | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const next = await ReactNativeWorkouts.getAuthorizationStatus();\n setStatus(next);\n return next;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsLoading(false);\n }\n }, []);\n\n const request = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const next = await ReactNativeWorkouts.requestAuthorization();\n setStatus(next);\n return next;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsLoading(false);\n }\n }, []);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n return { status, isLoading, error, refresh, request };\n}\n\nexport type UseScheduledWorkoutsResult = {\n workouts: ScheduledWorkout[];\n isLoading: boolean;\n error: Error | null;\n /**\n * Reloads scheduled workouts from native.\n */\n reload: () => Promise<ScheduledWorkout[]>;\n /**\n * Removes all scheduled workouts created by this app.\n */\n removeAll: () => Promise<void>;\n /**\n * Removes a single scheduled workout by ID.\n */\n remove: (id: string) => Promise<void>;\n /**\n * Schedules (syncs) a plan for the given date components, then reloads the list.\n *\n * Under the hood this calls `plan.scheduleAndSync(date)`.\n */\n schedule: (\n plan: WorkoutPlan,\n date: DateComponents,\n ) => Promise<{ id: string }>;\n};\n\n/**\n * Hook to manage scheduled workouts.\n */\nexport function useScheduledWorkouts(): UseScheduledWorkoutsResult {\n const [workouts, setWorkouts] = useState<ScheduledWorkout[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const reload = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const next = await ReactNativeWorkouts.getScheduledWorkouts();\n setWorkouts(next);\n return next;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsLoading(false);\n }\n }, []);\n\n const removeAll = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n await ReactNativeWorkouts.removeAllScheduledWorkouts();\n setWorkouts([]);\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsLoading(false);\n }\n }, []);\n\n const remove = useCallback(async (id: string) => {\n setIsLoading(true);\n setError(null);\n try {\n await ReactNativeWorkouts.removeScheduledWorkout(id);\n setWorkouts((prev) => prev.filter((w) => w.id !== id));\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsLoading(false);\n }\n }, []);\n\n const schedule = useCallback(\n async (plan: WorkoutPlan, date: DateComponents) => {\n setIsLoading(true);\n setError(null);\n try {\n const result = await plan.scheduleAndSync(date);\n await reload();\n return { id: result.id };\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsLoading(false);\n }\n },\n [reload],\n );\n\n useEffect(() => {\n void reload();\n }, [reload]);\n\n return { workouts, isLoading, error, reload, removeAll, remove, schedule };\n}\n"]}
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { default } from './ReactNativeWorkoutsModule';
2
- export * from './ReactNativeWorkouts.types';
1
+ export { default } from "./ReactNativeWorkoutsModule";
2
+ export * from "./ReactNativeWorkouts.types";
3
+ export * from "./hooks";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC"}
package/build/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export { default } from './ReactNativeWorkoutsModule';
2
- export * from './ReactNativeWorkouts.types';
1
+ export { default } from "./ReactNativeWorkoutsModule";
2
+ export * from "./ReactNativeWorkouts.types";
3
+ export * from "./hooks";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,cAAc,6BAA6B,CAAC","sourcesContent":["export { default } from './ReactNativeWorkoutsModule';\nexport * from './ReactNativeWorkouts.types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC","sourcesContent":["export { default } from \"./ReactNativeWorkoutsModule\";\nexport * from \"./ReactNativeWorkouts.types\";\nexport * from \"./hooks\";\n"]}
@@ -1,6 +1,10 @@
1
1
  {
2
- "platforms": ["ios"],
3
- "ios": {
4
- "modules": ["ReactNativeWorkoutsModule"]
2
+ "platforms": [
3
+ "apple"
4
+ ],
5
+ "apple": {
6
+ "modules": [
7
+ "ReactNativeWorkoutsModule"
8
+ ]
5
9
  }
6
- }
10
+ }
@@ -11,7 +11,10 @@ Pod::Spec.new do |s|
11
11
  s.author = package['author']
12
12
  s.homepage = package['homepage']
13
13
  s.platforms = {
14
- :ios => '17.0'
14
+ # The module APIs require iOS 17+ at runtime (WorkoutKit), but we keep the
15
+ # deployment target lower so apps can still build with e.g. iOS 15 targets.
16
+ # Calls on iOS < 17 will throw a descriptive "Unavailable" error.
17
+ :ios => '15.1'
15
18
  }
16
19
  s.swift_version = '5.9'
17
20
  s.source = { git: 'https://github.com/Janjiran/react-native-workouts' }
@@ -19,7 +22,10 @@ Pod::Spec.new do |s|
19
22
 
20
23
  s.dependency 'ExpoModulesCore'
21
24
 
22
- s.frameworks = 'WorkoutKit', 'HealthKit'
25
+ # HealthKit exists on older iOS versions, keep it strongly linked.
26
+ s.frameworks = 'HealthKit'
27
+ # WorkoutKit does NOT exist on iOS < 17; weak-link it so the app can still load.
28
+ s.weak_frameworks = 'WorkoutKit'
23
29
 
24
30
  s.pod_target_xcconfig = {
25
31
  'DEFINES_MODULE' => 'YES',