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/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "react-native-workouts",
3
+ "version": "0.1.0",
4
+ "description": "React Native Expo module for Apple WorkoutKit - create, preview, and sync custom workouts to Apple Watch",
5
+ "main": "build/index.js",
6
+ "types": "build/index.d.ts",
7
+ "scripts": {
8
+ "build": "expo-module build",
9
+ "clean": "expo-module clean",
10
+ "lint": "expo-module lint",
11
+ "test": "expo-module test",
12
+ "prepare": "expo-module prepare",
13
+ "prepublishOnly": "expo-module prepublishOnly",
14
+ "expo-module": "expo-module",
15
+ "open:ios": "xed example/ios"
16
+ },
17
+ "keywords": [
18
+ "react-native",
19
+ "expo",
20
+ "workoutkit",
21
+ "apple-watch",
22
+ "fitness",
23
+ "workout",
24
+ "healthkit",
25
+ "ios",
26
+ "custom-workout",
27
+ "interval-training"
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/Janjiran/react-native-workouts.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/Janjiran/react-native-workouts/issues"
35
+ },
36
+ "author": "Jan (Honza) Jiráň <jan.jiran@understudios.org> (https://github.com/Janjiran)",
37
+ "license": "MIT",
38
+ "homepage": "https://github.com/Janjiran/react-native-workouts#readme",
39
+ "os": [
40
+ "darwin"
41
+ ],
42
+ "cpu": [
43
+ "arm64",
44
+ "x64"
45
+ ],
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "dependencies": {},
50
+ "devDependencies": {
51
+ "@types/react": "~19.1.0",
52
+ "expo-module-scripts": "^5.0.8",
53
+ "expo": "^54.0.27",
54
+ "react-native": "0.81.5"
55
+ },
56
+ "peerDependencies": {
57
+ "expo": "*",
58
+ "react": "*",
59
+ "react-native": "*"
60
+ }
61
+ }
@@ -0,0 +1,242 @@
1
+ // Authorization
2
+
3
+ export type AuthorizationStatus =
4
+ | 'authorized'
5
+ | 'notDetermined'
6
+ | 'denied'
7
+ | 'unknown';
8
+
9
+ // Activity Types
10
+
11
+ export type ActivityType =
12
+ | 'running'
13
+ | 'cycling'
14
+ | 'walking'
15
+ | 'hiking'
16
+ | 'swimming'
17
+ | 'rowing'
18
+ | 'elliptical'
19
+ | 'stairClimbing'
20
+ | 'highIntensityIntervalTraining'
21
+ | 'yoga'
22
+ | 'functionalStrengthTraining'
23
+ | 'traditionalStrengthTraining'
24
+ | 'dance'
25
+ | 'jumpRope'
26
+ | 'coreTraining'
27
+ | 'pilates'
28
+ | 'kickboxing'
29
+ | 'stairs'
30
+ | 'stepTraining'
31
+ | 'wheelchairRunPace'
32
+ | 'wheelchairWalkPace';
33
+
34
+ export type LocationType = 'indoor' | 'outdoor';
35
+
36
+ // Units
37
+
38
+ export type DistanceUnit =
39
+ | 'meters'
40
+ | 'm'
41
+ | 'kilometers'
42
+ | 'km'
43
+ | 'miles'
44
+ | 'mi'
45
+ | 'yards'
46
+ | 'yd'
47
+ | 'feet'
48
+ | 'ft';
49
+
50
+ export type TimeUnit =
51
+ | 'seconds'
52
+ | 's'
53
+ | 'sec'
54
+ | 'minutes'
55
+ | 'min'
56
+ | 'hours'
57
+ | 'h'
58
+ | 'hr';
59
+
60
+ export type EnergyUnit =
61
+ | 'kilocalories'
62
+ | 'kcal'
63
+ | 'cal'
64
+ | 'kilojoules'
65
+ | 'kj';
66
+
67
+ export type SpeedUnit =
68
+ | 'metersPerSecond'
69
+ | 'mps'
70
+ | 'm/s'
71
+ | 'kilometersPerHour'
72
+ | 'kph'
73
+ | 'km/h'
74
+ | 'milesPerHour'
75
+ | 'mph';
76
+
77
+ export type PaceUnit =
78
+ | 'minutesPerKilometer'
79
+ | 'min/km'
80
+ | 'minutesPerMile'
81
+ | 'min/mi';
82
+
83
+ // Goals
84
+
85
+ export interface OpenGoal {
86
+ type: 'open';
87
+ }
88
+
89
+ export interface DistanceGoal {
90
+ type: 'distance';
91
+ value: number;
92
+ unit?: DistanceUnit;
93
+ }
94
+
95
+ export interface TimeGoal {
96
+ type: 'time';
97
+ value: number;
98
+ unit?: TimeUnit;
99
+ }
100
+
101
+ export interface EnergyGoal {
102
+ type: 'energy';
103
+ value: number;
104
+ unit?: EnergyUnit;
105
+ }
106
+
107
+ export type WorkoutGoal = OpenGoal | DistanceGoal | TimeGoal | EnergyGoal;
108
+
109
+ // Alerts
110
+
111
+ export interface HeartRateZoneAlert {
112
+ type: 'heartRate';
113
+ zone: number;
114
+ }
115
+
116
+ export interface HeartRateRangeAlert {
117
+ type: 'heartRate';
118
+ min: number;
119
+ max: number;
120
+ }
121
+
122
+ export interface PaceAlert {
123
+ type: 'pace';
124
+ min: number;
125
+ max: number;
126
+ unit?: PaceUnit;
127
+ }
128
+
129
+ export interface SpeedAlert {
130
+ type: 'speed';
131
+ min: number;
132
+ max: number;
133
+ unit?: SpeedUnit;
134
+ }
135
+
136
+ export interface CadenceAlert {
137
+ type: 'cadence';
138
+ min: number;
139
+ max: number;
140
+ }
141
+
142
+ export interface PowerAlert {
143
+ type: 'power';
144
+ min: number;
145
+ max: number;
146
+ }
147
+
148
+ export type WorkoutAlert =
149
+ | HeartRateZoneAlert
150
+ | HeartRateRangeAlert
151
+ | PaceAlert
152
+ | SpeedAlert
153
+ | CadenceAlert
154
+ | PowerAlert;
155
+
156
+ // Workout Steps
157
+
158
+ export type StepPurpose = 'work' | 'recovery';
159
+
160
+ export interface WorkoutStep {
161
+ goal?: WorkoutGoal;
162
+ alert?: WorkoutAlert;
163
+ }
164
+
165
+ export interface IntervalStep {
166
+ purpose: StepPurpose;
167
+ goal?: WorkoutGoal;
168
+ alert?: WorkoutAlert;
169
+ }
170
+
171
+ export interface IntervalBlock {
172
+ iterations?: number;
173
+ steps: IntervalStep[];
174
+ }
175
+
176
+ // Workout Configurations
177
+
178
+ export interface CustomWorkoutConfig {
179
+ activityType: ActivityType;
180
+ locationType?: LocationType;
181
+ displayName?: string;
182
+ warmup?: WorkoutStep;
183
+ blocks: IntervalBlock[];
184
+ cooldown?: WorkoutStep;
185
+ }
186
+
187
+ export interface SingleGoalWorkoutConfig {
188
+ activityType: ActivityType;
189
+ locationType?: LocationType;
190
+ displayName?: string;
191
+ goal: WorkoutGoal;
192
+ }
193
+
194
+ export interface PacerTarget {
195
+ type: 'speed' | 'pace';
196
+ value: number;
197
+ unit?: SpeedUnit | PaceUnit;
198
+ }
199
+
200
+ export interface PacerWorkoutConfig {
201
+ activityType: ActivityType;
202
+ locationType?: LocationType;
203
+ displayName?: string;
204
+ target: PacerTarget;
205
+ }
206
+
207
+ // Date Components
208
+
209
+ export interface DateComponents {
210
+ year?: number;
211
+ month?: number;
212
+ day?: number;
213
+ hour?: number;
214
+ minute?: number;
215
+ }
216
+
217
+ // Results
218
+
219
+ export interface WorkoutValidationResult {
220
+ valid: boolean;
221
+ displayName: string;
222
+ }
223
+
224
+ export interface ScheduleResult {
225
+ success: boolean;
226
+ id: string;
227
+ }
228
+
229
+ export interface ScheduledWorkout {
230
+ id: string;
231
+ date: DateComponents;
232
+ }
233
+
234
+ // Module Events
235
+
236
+ export interface AuthorizationChangeEvent {
237
+ status: AuthorizationStatus;
238
+ }
239
+
240
+ export type ReactNativeWorkoutsModuleEvents = {
241
+ onAuthorizationChange: (event: AuthorizationChangeEvent) => void;
242
+ };
@@ -0,0 +1,72 @@
1
+ import { NativeModule, requireNativeModule } from 'expo';
2
+
3
+ import type {
4
+ ReactNativeWorkoutsModuleEvents,
5
+ AuthorizationStatus,
6
+ ActivityType,
7
+ LocationType,
8
+ CustomWorkoutConfig,
9
+ SingleGoalWorkoutConfig,
10
+ PacerWorkoutConfig,
11
+ DateComponents,
12
+ WorkoutValidationResult,
13
+ ScheduleResult,
14
+ ScheduledWorkout,
15
+ } from './ReactNativeWorkouts.types';
16
+
17
+ declare class ReactNativeWorkoutsModule extends NativeModule<ReactNativeWorkoutsModuleEvents> {
18
+ // Constants
19
+ readonly isAvailable: boolean;
20
+
21
+ // Authorization
22
+ getAuthorizationStatus(): Promise<AuthorizationStatus>;
23
+ requestAuthorization(): Promise<AuthorizationStatus>;
24
+
25
+ // Validation
26
+ supportsGoal(
27
+ activityType: ActivityType,
28
+ locationType: LocationType,
29
+ goalType: string
30
+ ): Promise<boolean>;
31
+
32
+ // Custom Workouts
33
+ createCustomWorkout(
34
+ config: CustomWorkoutConfig
35
+ ): Promise<WorkoutValidationResult>;
36
+ scheduleWorkout(
37
+ config: CustomWorkoutConfig,
38
+ date: DateComponents
39
+ ): Promise<ScheduleResult>;
40
+
41
+ // Single Goal Workouts
42
+ createSingleGoalWorkout(
43
+ config: SingleGoalWorkoutConfig
44
+ ): Promise<WorkoutValidationResult>;
45
+ scheduleSingleGoalWorkout(
46
+ config: SingleGoalWorkoutConfig,
47
+ date: DateComponents
48
+ ): Promise<ScheduleResult>;
49
+
50
+ // Pacer Workouts
51
+ createPacerWorkout(
52
+ config: PacerWorkoutConfig
53
+ ): Promise<WorkoutValidationResult>;
54
+ schedulePacerWorkout(
55
+ config: PacerWorkoutConfig,
56
+ date: DateComponents
57
+ ): Promise<ScheduleResult>;
58
+
59
+ // Scheduled Workouts Management
60
+ getScheduledWorkouts(): Promise<ScheduledWorkout[]>;
61
+ removeScheduledWorkout(id: string): Promise<boolean>;
62
+ removeAllScheduledWorkouts(): Promise<boolean>;
63
+
64
+ // Utility
65
+ getSupportedActivityTypes(): ActivityType[];
66
+ getSupportedGoalTypes(): string[];
67
+ getSupportedLocationTypes(): LocationType[];
68
+ }
69
+
70
+ export default requireNativeModule<ReactNativeWorkoutsModule>(
71
+ 'ReactNativeWorkouts'
72
+ );
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './ReactNativeWorkoutsModule';
2
+ export * from './ReactNativeWorkouts.types';
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ // @generated by expo-module-scripts
2
+ {
3
+ "extends": "expo-module-scripts/tsconfig.base",
4
+ "compilerOptions": {
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__rsc_tests__/*"]
9
+ }