react-native-workouts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['universe/native', 'universe/web'],
4
+ ignorePatterns: ['build'],
5
+ };
package/README.md ADDED
@@ -0,0 +1,343 @@
1
+ # react-native-workouts
2
+
3
+ React Native Expo module for Apple WorkoutKit - create, preview, and sync custom
4
+ workouts to Apple Watch.
5
+
6
+ ## Features
7
+
8
+ - Create custom interval workouts with warmup, work/recovery intervals, and
9
+ cooldown
10
+ - Create single-goal workouts (distance, time, or energy based)
11
+ - Create pacer workouts with speed or pace targets
12
+ - Schedule workouts to sync with Apple Watch Workout app
13
+ - Full TypeScript support with comprehensive type definitions
14
+ - Supports all major workout activity types
15
+
16
+ ## API Features
17
+
18
+ ### Workout Creation
19
+
20
+ - **Custom Workouts** - Complex interval workouts with warmup, blocks
21
+ (iterations, work/recovery steps), cooldown, and alerts
22
+ - **Single Goal Workouts** - Simple distance, time, or energy-based workouts
23
+ - **Pacer Workouts** - Speed or pace target workouts
24
+
25
+ ### Scheduling
26
+
27
+ - **scheduleWorkout()** - Schedule custom workouts to Apple Watch
28
+ - **scheduleSingleGoalWorkout()** - Schedule single goal workouts
29
+ - **schedulePacerWorkout()** - Schedule pacer workouts
30
+ - **getScheduledWorkouts()** - List all scheduled workouts
31
+ - **removeScheduledWorkout(id)** - Remove specific workout
32
+ - **removeAllScheduledWorkouts()** - Clear all scheduled workouts
33
+
34
+ ## Requirements
35
+
36
+ - iOS 17.0+
37
+ - Expo SDK 54+
38
+ - Apple Watch paired with iPhone (for workout sync)
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install react-native-workouts
44
+ # or
45
+ yarn add react-native-workouts
46
+ ```
47
+
48
+ ### Expo Configuration
49
+
50
+ Add the module to your app.json:
51
+
52
+ ```json
53
+ {
54
+ "expo": {
55
+ "plugins": ["react-native-workouts"]
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### Info.plist Configuration
61
+
62
+ Add the following keys to your Info.plist for HealthKit access:
63
+
64
+ ```xml
65
+ <key>NSHealthShareUsageDescription</key>
66
+ <string>This app needs access to health data to sync workouts.</string>
67
+ <key>NSHealthUpdateUsageDescription</key>
68
+ <string>This app needs to write workout data.</string>
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ ### Authorization
74
+
75
+ Before scheduling workouts, you need to request authorization:
76
+
77
+ ```typescript
78
+ import ReactNativeWorkouts from "react-native-workouts";
79
+
80
+ // Check current authorization status
81
+ const status = await ReactNativeWorkouts.getAuthorizationStatus();
82
+ // Returns: 'authorized' | 'notDetermined' | 'denied' | 'unknown'
83
+
84
+ // Request authorization
85
+ const newStatus = await ReactNativeWorkouts.requestAuthorization();
86
+ ```
87
+
88
+ ### Custom Interval Workout
89
+
90
+ Create complex interval workouts with warmup, multiple blocks, and cooldown:
91
+
92
+ ```typescript
93
+ import ReactNativeWorkouts from "react-native-workouts";
94
+ import type { CustomWorkoutConfig } from "react-native-workouts";
95
+
96
+ const workout: CustomWorkoutConfig = {
97
+ activityType: "running",
98
+ locationType: "outdoor",
99
+ displayName: "Morning Intervals",
100
+ warmup: {
101
+ goal: { type: "time", value: 5, unit: "minutes" },
102
+ },
103
+ blocks: [
104
+ {
105
+ iterations: 4,
106
+ steps: [
107
+ {
108
+ purpose: "work",
109
+ goal: { type: "distance", value: 400, unit: "meters" },
110
+ alert: { type: "pace", min: 4, max: 5, unit: "min/km" },
111
+ },
112
+ {
113
+ purpose: "recovery",
114
+ goal: { type: "time", value: 90, unit: "seconds" },
115
+ },
116
+ ],
117
+ },
118
+ ],
119
+ cooldown: {
120
+ goal: { type: "time", value: 5, unit: "minutes" },
121
+ },
122
+ };
123
+
124
+ // Validate the workout
125
+ const result = await ReactNativeWorkouts.createCustomWorkout(workout);
126
+ console.log(result.valid); // true
127
+
128
+ // Schedule for tomorrow at 7 AM
129
+ const tomorrow = new Date();
130
+ tomorrow.setDate(tomorrow.getDate() + 1);
131
+
132
+ const scheduleResult = await ReactNativeWorkouts.scheduleWorkout(workout, {
133
+ year: tomorrow.getFullYear(),
134
+ month: tomorrow.getMonth() + 1,
135
+ day: tomorrow.getDate(),
136
+ hour: 7,
137
+ minute: 0,
138
+ });
139
+
140
+ console.log(scheduleResult.id); // UUID of scheduled workout
141
+ ```
142
+
143
+ ### Single Goal Workout
144
+
145
+ Create simple goal-based workouts:
146
+
147
+ ```typescript
148
+ import ReactNativeWorkouts from "react-native-workouts";
149
+ import type { SingleGoalWorkoutConfig } from "react-native-workouts";
150
+
151
+ // 5K run
152
+ const fiveK: SingleGoalWorkoutConfig = {
153
+ activityType: "running",
154
+ locationType: "outdoor",
155
+ displayName: "5K Run",
156
+ goal: { type: "distance", value: 5, unit: "kilometers" },
157
+ };
158
+
159
+ // 30 minute cycling session
160
+ const cycling: SingleGoalWorkoutConfig = {
161
+ activityType: "cycling",
162
+ locationType: "indoor",
163
+ displayName: "30 Min Ride",
164
+ goal: { type: "time", value: 30, unit: "minutes" },
165
+ };
166
+
167
+ // 500 calorie workout
168
+ const calorieBurn: SingleGoalWorkoutConfig = {
169
+ activityType: "highIntensityIntervalTraining",
170
+ displayName: "Calorie Burner",
171
+ goal: { type: "energy", value: 500, unit: "kilocalories" },
172
+ };
173
+
174
+ await ReactNativeWorkouts.createSingleGoalWorkout(fiveK);
175
+ ```
176
+
177
+ ### Pacer Workout
178
+
179
+ Create pace-based workouts:
180
+
181
+ ```typescript
182
+ import ReactNativeWorkouts from "react-native-workouts";
183
+ import type { PacerWorkoutConfig } from "react-native-workouts";
184
+
185
+ const pacerWorkout: PacerWorkoutConfig = {
186
+ activityType: "running",
187
+ locationType: "outdoor",
188
+ displayName: "Tempo Run",
189
+ target: {
190
+ type: "pace",
191
+ value: 5, // 5 minutes per kilometer
192
+ unit: "min/km",
193
+ },
194
+ };
195
+
196
+ await ReactNativeWorkouts.createPacerWorkout(pacerWorkout);
197
+ ```
198
+
199
+ ### Managing Scheduled Workouts
200
+
201
+ ```typescript
202
+ // Get all scheduled workouts
203
+ const workouts = await ReactNativeWorkouts.getScheduledWorkouts();
204
+
205
+ // Remove a specific workout
206
+ await ReactNativeWorkouts.removeScheduledWorkout(workouts[0].id);
207
+
208
+ // Remove all scheduled workouts
209
+ await ReactNativeWorkouts.removeAllScheduledWorkouts();
210
+ ```
211
+
212
+ ### Check Goal Support
213
+
214
+ Verify if a goal type is supported for an activity:
215
+
216
+ ```typescript
217
+ const supported = await ReactNativeWorkouts.supportsGoal(
218
+ "swimming",
219
+ "indoor",
220
+ "distance",
221
+ );
222
+ ```
223
+
224
+ ### Utility Functions
225
+
226
+ ```typescript
227
+ // Get all supported activity types
228
+ const activities = ReactNativeWorkouts.getSupportedActivityTypes();
229
+ // ['running', 'cycling', 'walking', 'hiking', ...]
230
+
231
+ // Get supported goal types
232
+ const goals = ReactNativeWorkouts.getSupportedGoalTypes();
233
+ // ['open', 'distance', 'time', 'energy']
234
+
235
+ // Get supported location types
236
+ const locations = ReactNativeWorkouts.getSupportedLocationTypes();
237
+ // ['indoor', 'outdoor']
238
+
239
+ // Check if HealthKit is available
240
+ const available = ReactNativeWorkouts.isAvailable;
241
+ ```
242
+
243
+ ## API Reference
244
+
245
+ ### Types
246
+
247
+ #### Activity Types
248
+
249
+ ```typescript
250
+ type ActivityType =
251
+ | "running"
252
+ | "cycling"
253
+ | "walking"
254
+ | "hiking"
255
+ | "swimming"
256
+ | "rowing"
257
+ | "elliptical"
258
+ | "stairClimbing"
259
+ | "highIntensityIntervalTraining"
260
+ | "yoga"
261
+ | "functionalStrengthTraining"
262
+ | "traditionalStrengthTraining"
263
+ | "dance"
264
+ | "jumpRope"
265
+ | "coreTraining"
266
+ | "pilates"
267
+ | "kickboxing"
268
+ | "stairs"
269
+ | "stepTraining"
270
+ | "wheelchairRunPace"
271
+ | "wheelchairWalkPace";
272
+ ```
273
+
274
+ #### Goal Types
275
+
276
+ ```typescript
277
+ type WorkoutGoal =
278
+ | { type: "open" }
279
+ | { type: "distance"; value: number; unit?: DistanceUnit }
280
+ | { type: "time"; value: number; unit?: TimeUnit }
281
+ | { type: "energy"; value: number; unit?: EnergyUnit };
282
+ ```
283
+
284
+ #### Alert Types
285
+
286
+ ```typescript
287
+ type WorkoutAlert =
288
+ | { type: "heartRate"; zone: number }
289
+ | { type: "heartRate"; min: number; max: number }
290
+ | { type: "pace"; min: number; max: number; unit?: PaceUnit }
291
+ | { type: "speed"; min: number; max: number; unit?: SpeedUnit }
292
+ | { type: "cadence"; min: number; max: number }
293
+ | { type: "power"; min: number; max: number };
294
+ ```
295
+
296
+ #### Units
297
+
298
+ ```typescript
299
+ type DistanceUnit =
300
+ | "meters"
301
+ | "m"
302
+ | "kilometers"
303
+ | "km"
304
+ | "miles"
305
+ | "mi"
306
+ | "yards"
307
+ | "yd"
308
+ | "feet"
309
+ | "ft";
310
+ type TimeUnit =
311
+ | "seconds"
312
+ | "s"
313
+ | "sec"
314
+ | "minutes"
315
+ | "min"
316
+ | "hours"
317
+ | "h"
318
+ | "hr";
319
+ type EnergyUnit = "kilocalories" | "kcal" | "cal" | "kilojoules" | "kj";
320
+ type SpeedUnit =
321
+ | "metersPerSecond"
322
+ | "mps"
323
+ | "m/s"
324
+ | "kilometersPerHour"
325
+ | "kph"
326
+ | "km/h"
327
+ | "milesPerHour"
328
+ | "mph";
329
+ type PaceUnit = "minutesPerKilometer" | "min/km" | "minutesPerMile" | "min/mi";
330
+ ```
331
+
332
+ ## Notes
333
+
334
+ - Swimming workouts do not support custom intervals, use SingleGoalWorkout
335
+ instead
336
+ - Not all activity types support all goal types - use `supportsGoal()` to check
337
+ - Scheduled workouts appear in the Workout app on Apple Watch and Fitness app on
338
+ iPhone
339
+ - Workouts display your app's icon and name in the Workout app
340
+
341
+ ## License
342
+
343
+ MIT
@@ -0,0 +1,124 @@
1
+ export type AuthorizationStatus = 'authorized' | 'notDetermined' | 'denied' | 'unknown';
2
+ export type ActivityType = 'running' | 'cycling' | 'walking' | 'hiking' | 'swimming' | 'rowing' | 'elliptical' | 'stairClimbing' | 'highIntensityIntervalTraining' | 'yoga' | 'functionalStrengthTraining' | 'traditionalStrengthTraining' | 'dance' | 'jumpRope' | 'coreTraining' | 'pilates' | 'kickboxing' | 'stairs' | 'stepTraining' | 'wheelchairRunPace' | 'wheelchairWalkPace';
3
+ export type LocationType = 'indoor' | 'outdoor';
4
+ export type DistanceUnit = 'meters' | 'm' | 'kilometers' | 'km' | 'miles' | 'mi' | 'yards' | 'yd' | 'feet' | 'ft';
5
+ export type TimeUnit = 'seconds' | 's' | 'sec' | 'minutes' | 'min' | 'hours' | 'h' | 'hr';
6
+ export type EnergyUnit = 'kilocalories' | 'kcal' | 'cal' | 'kilojoules' | 'kj';
7
+ export type SpeedUnit = 'metersPerSecond' | 'mps' | 'm/s' | 'kilometersPerHour' | 'kph' | 'km/h' | 'milesPerHour' | 'mph';
8
+ export type PaceUnit = 'minutesPerKilometer' | 'min/km' | 'minutesPerMile' | 'min/mi';
9
+ export interface OpenGoal {
10
+ type: 'open';
11
+ }
12
+ export interface DistanceGoal {
13
+ type: 'distance';
14
+ value: number;
15
+ unit?: DistanceUnit;
16
+ }
17
+ export interface TimeGoal {
18
+ type: 'time';
19
+ value: number;
20
+ unit?: TimeUnit;
21
+ }
22
+ export interface EnergyGoal {
23
+ type: 'energy';
24
+ value: number;
25
+ unit?: EnergyUnit;
26
+ }
27
+ export type WorkoutGoal = OpenGoal | DistanceGoal | TimeGoal | EnergyGoal;
28
+ export interface HeartRateZoneAlert {
29
+ type: 'heartRate';
30
+ zone: number;
31
+ }
32
+ export interface HeartRateRangeAlert {
33
+ type: 'heartRate';
34
+ min: number;
35
+ max: number;
36
+ }
37
+ export interface PaceAlert {
38
+ type: 'pace';
39
+ min: number;
40
+ max: number;
41
+ unit?: PaceUnit;
42
+ }
43
+ export interface SpeedAlert {
44
+ type: 'speed';
45
+ min: number;
46
+ max: number;
47
+ unit?: SpeedUnit;
48
+ }
49
+ export interface CadenceAlert {
50
+ type: 'cadence';
51
+ min: number;
52
+ max: number;
53
+ }
54
+ export interface PowerAlert {
55
+ type: 'power';
56
+ min: number;
57
+ max: number;
58
+ }
59
+ export type WorkoutAlert = HeartRateZoneAlert | HeartRateRangeAlert | PaceAlert | SpeedAlert | CadenceAlert | PowerAlert;
60
+ export type StepPurpose = 'work' | 'recovery';
61
+ export interface WorkoutStep {
62
+ goal?: WorkoutGoal;
63
+ alert?: WorkoutAlert;
64
+ }
65
+ export interface IntervalStep {
66
+ purpose: StepPurpose;
67
+ goal?: WorkoutGoal;
68
+ alert?: WorkoutAlert;
69
+ }
70
+ export interface IntervalBlock {
71
+ iterations?: number;
72
+ steps: IntervalStep[];
73
+ }
74
+ export interface CustomWorkoutConfig {
75
+ activityType: ActivityType;
76
+ locationType?: LocationType;
77
+ displayName?: string;
78
+ warmup?: WorkoutStep;
79
+ blocks: IntervalBlock[];
80
+ cooldown?: WorkoutStep;
81
+ }
82
+ export interface SingleGoalWorkoutConfig {
83
+ activityType: ActivityType;
84
+ locationType?: LocationType;
85
+ displayName?: string;
86
+ goal: WorkoutGoal;
87
+ }
88
+ export interface PacerTarget {
89
+ type: 'speed' | 'pace';
90
+ value: number;
91
+ unit?: SpeedUnit | PaceUnit;
92
+ }
93
+ export interface PacerWorkoutConfig {
94
+ activityType: ActivityType;
95
+ locationType?: LocationType;
96
+ displayName?: string;
97
+ target: PacerTarget;
98
+ }
99
+ export interface DateComponents {
100
+ year?: number;
101
+ month?: number;
102
+ day?: number;
103
+ hour?: number;
104
+ minute?: number;
105
+ }
106
+ export interface WorkoutValidationResult {
107
+ valid: boolean;
108
+ displayName: string;
109
+ }
110
+ export interface ScheduleResult {
111
+ success: boolean;
112
+ id: string;
113
+ }
114
+ export interface ScheduledWorkout {
115
+ id: string;
116
+ date: DateComponents;
117
+ }
118
+ export interface AuthorizationChangeEvent {
119
+ status: AuthorizationStatus;
120
+ }
121
+ export type ReactNativeWorkoutsModuleEvents = {
122
+ onAuthorizationChange: (event: AuthorizationChangeEvent) => void;
123
+ };
124
+ //# sourceMappingURL=ReactNativeWorkouts.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNativeWorkouts.types.d.ts","sourceRoot":"","sources":["../src/ReactNativeWorkouts.types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAC3B,YAAY,GACZ,eAAe,GACf,QAAQ,GACR,SAAS,CAAC;AAId,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,eAAe,GACf,+BAA+B,GAC/B,MAAM,GACN,4BAA4B,GAC5B,6BAA6B,GAC7B,OAAO,GACP,UAAU,GACV,cAAc,GACd,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,cAAc,GACd,mBAAmB,GACnB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAIhD,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,GAAG,GACH,YAAY,GACZ,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,MAAM,GACN,IAAI,CAAC;AAET,MAAM,MAAM,QAAQ,GAChB,SAAS,GACT,GAAG,GACH,KAAK,GACL,SAAS,GACT,KAAK,GACL,OAAO,GACP,GAAG,GACH,IAAI,CAAC;AAET,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,MAAM,GACN,KAAK,GACL,YAAY,GACZ,IAAI,CAAC;AAET,MAAM,MAAM,SAAS,GACjB,iBAAiB,GACjB,KAAK,GACL,KAAK,GACL,mBAAmB,GACnB,KAAK,GACL,MAAM,GACN,cAAc,GACd,KAAK,CAAC;AAEV,MAAM,MAAM,QAAQ,GAChB,qBAAqB,GACrB,QAAQ,GACR,gBAAgB,GAChB,QAAQ,CAAC;AAIb,MAAM,WAAW,QAAQ;IAC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CACrB;AAID,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;CACtB;AAID,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,qBAAqB,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;CAClE,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Authorization
2
+ export {};
3
+ //# sourceMappingURL=ReactNativeWorkouts.types.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,23 @@
1
+ import { NativeModule } from 'expo';
2
+ import type { ReactNativeWorkoutsModuleEvents, AuthorizationStatus, ActivityType, LocationType, CustomWorkoutConfig, SingleGoalWorkoutConfig, PacerWorkoutConfig, DateComponents, WorkoutValidationResult, ScheduleResult, ScheduledWorkout } from './ReactNativeWorkouts.types';
3
+ declare class ReactNativeWorkoutsModule extends NativeModule<ReactNativeWorkoutsModuleEvents> {
4
+ readonly isAvailable: boolean;
5
+ getAuthorizationStatus(): Promise<AuthorizationStatus>;
6
+ requestAuthorization(): Promise<AuthorizationStatus>;
7
+ supportsGoal(activityType: ActivityType, locationType: LocationType, goalType: string): Promise<boolean>;
8
+ createCustomWorkout(config: CustomWorkoutConfig): Promise<WorkoutValidationResult>;
9
+ scheduleWorkout(config: CustomWorkoutConfig, date: DateComponents): Promise<ScheduleResult>;
10
+ createSingleGoalWorkout(config: SingleGoalWorkoutConfig): Promise<WorkoutValidationResult>;
11
+ scheduleSingleGoalWorkout(config: SingleGoalWorkoutConfig, date: DateComponents): Promise<ScheduleResult>;
12
+ createPacerWorkout(config: PacerWorkoutConfig): Promise<WorkoutValidationResult>;
13
+ schedulePacerWorkout(config: PacerWorkoutConfig, date: DateComponents): Promise<ScheduleResult>;
14
+ getScheduledWorkouts(): Promise<ScheduledWorkout[]>;
15
+ removeScheduledWorkout(id: string): Promise<boolean>;
16
+ removeAllScheduledWorkouts(): Promise<boolean>;
17
+ getSupportedActivityTypes(): ActivityType[];
18
+ getSupportedGoalTypes(): string[];
19
+ getSupportedLocationTypes(): LocationType[];
20
+ }
21
+ declare const _default: ReactNativeWorkoutsModule;
22
+ export default _default;
23
+ //# sourceMappingURL=ReactNativeWorkoutsModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNativeWorkoutsModule.d.ts","sourceRoot":"","sources":["../src/ReactNativeWorkoutsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,KAAK,EACV,+BAA+B,EAC/B,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,OAAO,yBAA0B,SAAQ,YAAY,CAAC,+BAA+B,CAAC;IAE3F,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAG9B,sBAAsB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IACtD,oBAAoB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAGpD,YAAY,CACV,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC;IAGnB,mBAAmB,CACjB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,uBAAuB,CAAC;IACnC,eAAe,CACb,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC;IAG1B,uBAAuB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC;IACnC,yBAAyB,CACvB,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC;IAG1B,kBAAkB,CAChB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,uBAAuB,CAAC;IACnC,oBAAoB,CAClB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC;IAG1B,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IACnD,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IACpD,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC;IAG9C,yBAAyB,IAAI,YAAY,EAAE;IAC3C,qBAAqB,IAAI,MAAM,EAAE;IACjC,yBAAyB,IAAI,YAAY,EAAE;CAC5C;;AAED,wBAEE"}
@@ -0,0 +1,3 @@
1
+ import { requireNativeModule } from 'expo';
2
+ export default requireNativeModule('ReactNativeWorkouts');
3
+ //# sourceMappingURL=ReactNativeWorkoutsModule.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,3 @@
1
+ export { default } from './ReactNativeWorkoutsModule';
2
+ export * from './ReactNativeWorkouts.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
package/build/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { default } from './ReactNativeWorkoutsModule';
2
+ export * from './ReactNativeWorkouts.types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,6 @@
1
+ {
2
+ "platforms": ["ios"],
3
+ "ios": {
4
+ "modules": ["ReactNativeWorkoutsModule"]
5
+ }
6
+ }
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'ReactNativeWorkouts'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.description = package['description']
10
+ s.license = package['license']
11
+ s.author = package['author']
12
+ s.homepage = package['homepage']
13
+ s.platforms = {
14
+ :ios => '17.0'
15
+ }
16
+ s.swift_version = '5.9'
17
+ s.source = { git: 'https://github.com/Janjiran/react-native-workouts' }
18
+ s.static_framework = true
19
+
20
+ s.dependency 'ExpoModulesCore'
21
+
22
+ s.frameworks = 'WorkoutKit', 'HealthKit'
23
+
24
+ s.pod_target_xcconfig = {
25
+ 'DEFINES_MODULE' => 'YES',
26
+ }
27
+
28
+ s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
29
+ end