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.
package/README.md CHANGED
@@ -1,40 +1,25 @@
1
+ ![react-native-workouts-banner](./public/react-native-workouts-banner.png)
2
+
1
3
  # react-native-workouts
2
4
 
3
- React Native Expo module for Apple WorkoutKit - create, preview, and sync custom
5
+ πŸ‹οΈβ€β™€οΈ React Native Expo module for Apple WorkoutKit β€” create, preview, and sync
4
6
  workouts to Apple Watch.
5
7
 
6
8
  ## Features
7
9
 
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
10
+ - ✨ Create custom interval workouts (warmup, blocks, cooldown, alerts)
11
+ - 🎯 Create single-goal workouts (distance / time / energy)
12
+ - πŸƒβ€β™‚οΈ Create pacer workouts (pace / speed targets)
13
+ - 🧩 Create multisport Swim / Bike / Run workouts
14
+ - πŸ‘€ Preview with Apple’s system UI (includes β€œAdd to Watch” / β€œSend to Watch”)
15
+ - ⌚️ Schedule & sync to the Apple Watch Workout app
16
+ - 🧠 Hooks-first API + stateful `WorkoutPlan` handle (Expo Shared Object)
17
+ - βœ… Full TypeScript support
33
18
 
34
19
  ## Requirements
35
20
 
36
- - iOS 17.0+
37
- - Expo SDK 54+
21
+ - iOS 17.0+ **at runtime** (WorkoutKit)
22
+ - Tested with Expo SDK 54+
38
23
  - Apple Watch paired with iPhone (for workout sync)
39
24
 
40
25
  ## Installation
@@ -43,18 +28,8 @@ workouts to Apple Watch.
43
28
  npm install react-native-workouts
44
29
  # or
45
30
  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
- }
31
+ # or
32
+ pnpm add react-native-workouts
58
33
  ```
59
34
 
60
35
  ### Info.plist Configuration
@@ -70,174 +45,191 @@ Add the following keys to your Info.plist for HealthKit access:
70
45
 
71
46
  ## Usage
72
47
 
73
- ### Authorization
48
+ ### πŸ” Authorization (hook)
74
49
 
75
- Before scheduling workouts, you need to request authorization:
50
+ Before previewing/scheduling, request authorization (HealthKit / WorkoutKit):
76
51
 
77
52
  ```typescript
78
- import ReactNativeWorkouts from "react-native-workouts";
53
+ import { useWorkoutAuthorization } from "react-native-workouts";
79
54
 
80
- // Check current authorization status
81
- const status = await ReactNativeWorkouts.getAuthorizationStatus();
82
- // Returns: 'authorized' | 'notDetermined' | 'denied' | 'unknown'
55
+ export function MyScreen() {
56
+ const { status, request, isLoading, error } = useWorkoutAuthorization();
83
57
 
84
- // Request authorization
85
- const newStatus = await ReactNativeWorkouts.requestAuthorization();
58
+ // status: 'authorized' | 'notDetermined' | 'denied' | 'unknown' | null
59
+ // request(): prompts the system dialog (if needed) and returns the new status
60
+
61
+ return null;
62
+ }
86
63
  ```
87
64
 
88
- ### Custom Interval Workout
65
+ ### πŸš€ Quick start (hooks-first `WorkoutPlan`)
89
66
 
90
- Create complex interval workouts with warmup, multiple blocks, and cooldown:
67
+ Hooks create a **stateful `WorkoutPlan` shared object** (Expo Shared Object).
68
+ You call methods on the plan:
69
+
70
+ - `plan.preview()` β€” opens Apple’s workout preview UI (includes β€œAdd/Send to
71
+ Watch”)
72
+ - `plan.scheduleAndSync(date)` β€” schedules using Apple’s `WorkoutScheduler`
73
+ (this is what syncs it to the Watch)
74
+ - `plan.export()` β€” returns `{ id, kind, config }` so you can persist/share and
75
+ recreate later
91
76
 
92
77
  ```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
- },
78
+ import { useMemo } from "react";
79
+ import {
80
+ type CustomWorkoutConfig,
81
+ useCustomWorkout,
82
+ useWorkoutAuthorization,
83
+ } from "react-native-workouts";
84
+
85
+ export function MyWorkoutScreen() {
86
+ const { status, request } = useWorkoutAuthorization();
87
+
88
+ const config = useMemo<CustomWorkoutConfig>(
89
+ () => ({
90
+ activityType: "running",
91
+ locationType: "outdoor",
92
+ displayName: "Morning Intervals",
93
+ warmup: { goal: { type: "time", value: 5, unit: "minutes" } },
94
+ blocks: [
112
95
  {
113
- purpose: "recovery",
114
- goal: { type: "time", value: 90, unit: "seconds" },
96
+ iterations: 4,
97
+ steps: [
98
+ {
99
+ purpose: "work",
100
+ goal: { type: "distance", value: 400, unit: "meters" },
101
+ alert: { type: "pace", min: 4, max: 5, unit: "min/km" },
102
+ },
103
+ {
104
+ purpose: "recovery",
105
+ goal: { type: "time", value: 90, unit: "seconds" },
106
+ },
107
+ ],
115
108
  },
116
109
  ],
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
110
+ cooldown: { goal: { type: "time", value: 5, unit: "minutes" } },
111
+ }),
112
+ [],
113
+ );
114
+
115
+ const { plan, isLoading, error } = useCustomWorkout(config);
116
+
117
+ const preview = async () => {
118
+ if (!plan) return;
119
+ if (status !== "authorized") await request();
120
+ await plan.preview();
121
+ };
122
+
123
+ const scheduleTomorrowMorning = async () => {
124
+ if (!plan) return;
125
+ if (status !== "authorized") await request();
126
+ await plan.scheduleAndSync({
127
+ year: 2026,
128
+ month: 1,
129
+ day: 12,
130
+ hour: 7,
131
+ minute: 0,
132
+ });
133
+ };
134
+
135
+ return null;
136
+ }
141
137
  ```
142
138
 
143
- ### Single Goal Workout
144
-
145
- Create simple goal-based workouts:
139
+ ### 🎯 Single goal workouts (hook)
146
140
 
147
141
  ```typescript
148
- import ReactNativeWorkouts from "react-native-workouts";
142
+ import { useMemo } from "react";
149
143
  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);
144
+ import { useSingleGoalWorkout } from "react-native-workouts";
145
+
146
+ export function FiveKScreen() {
147
+ const config = useMemo<SingleGoalWorkoutConfig>(
148
+ () => ({
149
+ activityType: "running",
150
+ locationType: "outdoor",
151
+ displayName: "5K Run",
152
+ goal: { type: "distance", value: 5, unit: "kilometers" },
153
+ }),
154
+ [],
155
+ );
156
+
157
+ const { plan } = useSingleGoalWorkout(config);
158
+ return null;
159
+ }
175
160
  ```
176
161
 
177
- ### Pacer Workout
178
-
179
- Create pace-based workouts:
162
+ ### πŸƒβ€β™‚οΈ Pacer workouts (hook)
180
163
 
181
164
  ```typescript
182
- import ReactNativeWorkouts from "react-native-workouts";
165
+ import { useMemo } from "react";
183
166
  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);
167
+ import { usePacerWorkout } from "react-native-workouts";
168
+
169
+ export function TempoRunScreen() {
170
+ const config = useMemo<PacerWorkoutConfig>(
171
+ () => ({
172
+ activityType: "running",
173
+ locationType: "outdoor",
174
+ displayName: "Tempo Run",
175
+ target: { type: "pace", value: 5, unit: "min/km" },
176
+ }),
177
+ [],
178
+ );
179
+
180
+ const { plan } = usePacerWorkout(config);
181
+ return null;
182
+ }
197
183
  ```
198
184
 
199
- ### Managing Scheduled Workouts
185
+ ### 🧩 Swim / Bike / Run (multisport) (hook)
200
186
 
201
187
  ```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);
188
+ import { useMemo } from "react";
189
+ import type { SwimBikeRunWorkoutConfig } from "react-native-workouts";
190
+ import { useSwimBikeRunWorkout } from "react-native-workouts";
191
+
192
+ export function TriathlonScreen() {
193
+ const config = useMemo<SwimBikeRunWorkoutConfig>(
194
+ () => ({
195
+ displayName: "Sprint Triathlon",
196
+ activities: [
197
+ { type: "swimming", locationType: "indoor" },
198
+ { type: "cycling", locationType: "outdoor" },
199
+ { type: "running", locationType: "outdoor" },
200
+ ],
201
+ }),
202
+ [],
203
+ );
207
204
 
208
- // Remove all scheduled workouts
209
- await ReactNativeWorkouts.removeAllScheduledWorkouts();
205
+ const { plan } = useSwimBikeRunWorkout(config);
206
+ return null;
207
+ }
210
208
  ```
211
209
 
212
- ### Check Goal Support
210
+ ### πŸ“¦ Persist / share a plan (`plan.export()`)
213
211
 
214
- Verify if a goal type is supported for an activity:
212
+ `plan.export()` does **not** export a `.workout` file.
215
213
 
216
- ```typescript
217
- const supported = await ReactNativeWorkouts.supportsGoal(
218
- "swimming",
219
- "indoor",
220
- "distance",
221
- );
222
- ```
214
+ It returns a small JSON payload you can store in your backend and later
215
+ recreate:
223
216
 
224
- ### Utility Functions
217
+ - `id`: UUID of the `WorkoutPlan` instance
218
+ - `kind`: `"custom" | "singleGoal" | "pacer" | "swimBikeRun"`
219
+ - `config`: the original config used to create the plan
225
220
 
226
- ```typescript
227
- // Get all supported activity types
228
- const activities = ReactNativeWorkouts.getSupportedActivityTypes();
229
- // ['running', 'cycling', 'walking', 'hiking', ...]
221
+ ### πŸ“… Managing scheduled workouts (hook)
230
222
 
231
- // Get supported goal types
232
- const goals = ReactNativeWorkouts.getSupportedGoalTypes();
233
- // ['open', 'distance', 'time', 'energy']
223
+ ```typescript
224
+ import { useScheduledWorkouts } from "react-native-workouts";
234
225
 
235
- // Get supported location types
236
- const locations = ReactNativeWorkouts.getSupportedLocationTypes();
237
- // ['indoor', 'outdoor']
226
+ export function ScheduledWorkoutsScreen() {
227
+ const { workouts, remove, removeAll, schedule, isLoading, error } =
228
+ useScheduledWorkouts();
238
229
 
239
- // Check if HealthKit is available
240
- const available = ReactNativeWorkouts.isAvailable;
230
+ // schedule(plan, date) calls plan.scheduleAndSync(date) and reloads the list
231
+ return null;
232
+ }
241
233
  ```
242
234
 
243
235
  ## API Reference
@@ -333,10 +325,22 @@ type PaceUnit = "minutesPerKilometer" | "min/km" | "minutesPerMile" | "min/mi";
333
325
 
334
326
  - Swimming workouts do not support custom intervals, use SingleGoalWorkout
335
327
  instead
336
- - Not all activity types support all goal types - use `supportsGoal()` to check
337
328
  - Scheduled workouts appear in the Workout app on Apple Watch and Fitness app on
338
329
  iPhone
339
330
  - Workouts display your app's icon and name in the Workout app
331
+ - The preview APIs use Apple’s system UI (`workoutPreview`) and require iOS 17+
332
+
333
+ ### Deployment target note
334
+
335
+ This library is built on Apple's `WorkoutKit` (introduced in iOS 17). To avoid
336
+ forcing apps to raise their deployment target just to install the package, the
337
+ iOS native code:
338
+
339
+ - **weak-links** `WorkoutKit`
340
+ - gates all exported APIs behind `#available(iOS 17.0, *)`
341
+
342
+ On **iOS < 17**, calling any WorkoutKit API will reject/throw with an
343
+ `Unavailable` error.
340
344
 
341
345
  ## License
342
346
 
package/app.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "plugins": []
3
+ }
@@ -1,63 +1,72 @@
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';
1
+ /**
2
+ * WorkoutKit authorization state as seen by Apple's `WorkoutScheduler`.
3
+ */
4
+ export type AuthorizationStatus = "authorized" | "notDetermined" | "denied" | "unknown";
5
+ import type { SharedObject } from "expo";
6
+ /**
7
+ * Supported workout activity types exposed by this package.
8
+ *
9
+ * Note: these map to HealthKit `HKWorkoutActivityType` values.
10
+ */
11
+ export type ActivityType = "running" | "cycling" | "walking" | "hiking" | "swimming" | "rowing" | "elliptical" | "stairClimbing" | "highIntensityIntervalTraining" | "yoga" | "functionalStrengthTraining" | "traditionalStrengthTraining" | "dance" | "jumpRope" | "coreTraining" | "pilates" | "kickboxing" | "stairs" | "stepTraining" | "wheelchairRunPace" | "wheelchairWalkPace";
12
+ export type LocationType = "indoor" | "outdoor";
13
+ export type DistanceUnit = "meters" | "m" | "kilometers" | "km" | "miles" | "mi" | "yards" | "yd" | "feet" | "ft";
14
+ export type TimeUnit = "seconds" | "s" | "sec" | "minutes" | "min" | "hours" | "h" | "hr";
15
+ export type EnergyUnit = "kilocalories" | "kcal" | "cal" | "kilojoules" | "kj";
16
+ export type SpeedUnit = "metersPerSecond" | "mps" | "m/s" | "kilometersPerHour" | "kph" | "km/h" | "milesPerHour" | "mph";
17
+ export type PaceUnit = "minutesPerKilometer" | "min/km" | "minutesPerMile" | "min/mi";
9
18
  export interface OpenGoal {
10
- type: 'open';
19
+ type: "open";
11
20
  }
12
21
  export interface DistanceGoal {
13
- type: 'distance';
22
+ type: "distance";
14
23
  value: number;
15
24
  unit?: DistanceUnit;
16
25
  }
17
26
  export interface TimeGoal {
18
- type: 'time';
27
+ type: "time";
19
28
  value: number;
20
29
  unit?: TimeUnit;
21
30
  }
22
31
  export interface EnergyGoal {
23
- type: 'energy';
32
+ type: "energy";
24
33
  value: number;
25
34
  unit?: EnergyUnit;
26
35
  }
27
36
  export type WorkoutGoal = OpenGoal | DistanceGoal | TimeGoal | EnergyGoal;
28
37
  export interface HeartRateZoneAlert {
29
- type: 'heartRate';
38
+ type: "heartRate";
30
39
  zone: number;
31
40
  }
32
41
  export interface HeartRateRangeAlert {
33
- type: 'heartRate';
42
+ type: "heartRate";
34
43
  min: number;
35
44
  max: number;
36
45
  }
37
46
  export interface PaceAlert {
38
- type: 'pace';
47
+ type: "pace";
39
48
  min: number;
40
49
  max: number;
41
50
  unit?: PaceUnit;
42
51
  }
43
52
  export interface SpeedAlert {
44
- type: 'speed';
53
+ type: "speed";
45
54
  min: number;
46
55
  max: number;
47
56
  unit?: SpeedUnit;
48
57
  }
49
58
  export interface CadenceAlert {
50
- type: 'cadence';
59
+ type: "cadence";
51
60
  min: number;
52
61
  max: number;
53
62
  }
54
63
  export interface PowerAlert {
55
- type: 'power';
64
+ type: "power";
56
65
  min: number;
57
66
  max: number;
58
67
  }
59
68
  export type WorkoutAlert = HeartRateZoneAlert | HeartRateRangeAlert | PaceAlert | SpeedAlert | CadenceAlert | PowerAlert;
60
- export type StepPurpose = 'work' | 'recovery';
69
+ export type StepPurpose = "work" | "recovery";
61
70
  export interface WorkoutStep {
62
71
  goal?: WorkoutGoal;
63
72
  alert?: WorkoutAlert;
@@ -72,8 +81,17 @@ export interface IntervalBlock {
72
81
  steps: IntervalStep[];
73
82
  }
74
83
  export interface CustomWorkoutConfig {
84
+ /**
85
+ * Activity type (running, cycling, etc).
86
+ */
75
87
  activityType: ActivityType;
88
+ /**
89
+ * Indoor/outdoor (where applicable). Defaults to `"outdoor"` when omitted.
90
+ */
76
91
  locationType?: LocationType;
92
+ /**
93
+ * Display name used by the system (where supported by WorkoutKit).
94
+ */
77
95
  displayName?: string;
78
96
  warmup?: WorkoutStep;
79
97
  blocks: IntervalBlock[];
@@ -82,20 +100,45 @@ export interface CustomWorkoutConfig {
82
100
  export interface SingleGoalWorkoutConfig {
83
101
  activityType: ActivityType;
84
102
  locationType?: LocationType;
103
+ /**
104
+ * Optional label for your app/back-end. WorkoutKit may not display this for all workout kinds.
105
+ */
85
106
  displayName?: string;
86
107
  goal: WorkoutGoal;
87
108
  }
88
109
  export interface PacerTarget {
89
- type: 'speed' | 'pace';
110
+ type: "speed" | "pace";
90
111
  value: number;
91
112
  unit?: SpeedUnit | PaceUnit;
92
113
  }
93
114
  export interface PacerWorkoutConfig {
94
115
  activityType: ActivityType;
95
116
  locationType?: LocationType;
117
+ /**
118
+ * Optional label for your app/back-end. WorkoutKit may not display this for all workout kinds.
119
+ */
96
120
  displayName?: string;
97
121
  target: PacerTarget;
98
122
  }
123
+ export type SwimBikeRunActivityType = "swimming" | "cycling" | "running";
124
+ export interface SwimBikeRunActivityConfig {
125
+ type: SwimBikeRunActivityType;
126
+ /**
127
+ * For running/cycling: `"indoor" | "outdoor"`.
128
+ * For swimming: `"indoor"` means pool, `"outdoor"` means open water.
129
+ */
130
+ locationType?: LocationType;
131
+ }
132
+ export interface SwimBikeRunWorkoutConfig {
133
+ /**
134
+ * Display name shown by the system for multisport workouts.
135
+ */
136
+ displayName?: string;
137
+ /**
138
+ * Ordered list of activities (e.g. swim -> bike -> run).
139
+ */
140
+ activities: SwimBikeRunActivityConfig[];
141
+ }
99
142
  export interface DateComponents {
100
143
  year?: number;
101
144
  month?: number;
@@ -121,4 +164,47 @@ export interface AuthorizationChangeEvent {
121
164
  export type ReactNativeWorkoutsModuleEvents = {
122
165
  onAuthorizationChange: (event: AuthorizationChangeEvent) => void;
123
166
  };
167
+ export type WorkoutPlanKind = "custom" | "singleGoal" | "pacer" | "swimBikeRun";
168
+ export interface WorkoutPlanExport {
169
+ /**
170
+ * UUID of the underlying `WorkoutPlan` instance.
171
+ *
172
+ * This is useful for debugging/logging and for matching the ID returned by `plan.scheduleAndSync`.
173
+ */
174
+ id: string;
175
+ kind: WorkoutPlanKind;
176
+ /**
177
+ * The original config used to create the plan.
178
+ *
179
+ * Use this to persist/share the plan in your own backend and recreate the plan later.
180
+ */
181
+ config: unknown;
182
+ }
183
+ export declare class WorkoutPlan extends SharedObject<{}> {
184
+ /**
185
+ * UUID of this plan instance.
186
+ */
187
+ readonly id: string;
188
+ /**
189
+ * Which kind of workout this plan represents.
190
+ */
191
+ readonly kind: WorkoutPlanKind;
192
+ /**
193
+ * Shows Apple's system Workout preview modal (includes β€œAdd to Watch / Send to Watch” UX).
194
+ */
195
+ preview(): Promise<boolean>;
196
+ /**
197
+ * Schedules the plan using Apple's `WorkoutScheduler`.
198
+ *
199
+ * This is the mechanism that syncs the plan to the Apple Watch Workout app.
200
+ */
201
+ scheduleAndSync(date: DateComponents): Promise<ScheduleResult>;
202
+ /**
203
+ * Returns `{ id, kind, config }` for storing/sharing the plan in your own backend.
204
+ *
205
+ * This does NOT export a system-importable file β€” it's a JSON payload you can use to recreate
206
+ * the plan via the `create*WorkoutPlan(...)` factories.
207
+ */
208
+ export(): WorkoutPlanExport;
209
+ }
124
210
  //# sourceMappingURL=ReactNativeWorkouts.types.d.ts.map
@@ -1 +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,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AC;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"}
1
+ {"version":3,"file":"ReactNativeWorkouts.types.d.ts","sourceRoot":"","sources":["../src/ReactNativeWorkouts.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,mBAAmB,GAC3B,YAAY,GACZ,eAAe,GACf,QAAQ,GACR,SAAS,CAAC;AAId,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIzC;;;;GAIG;AACH,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,mBA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QAAQ,GAAG,YAAY,GAAG,OAAO,GAAG,aAAa,CAAC;AAEhF,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,eAAe,CAAC;IACtB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,YAAY,CAAC,EAAE,CAAC;IACvD;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAE3B;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAE9D;;;;;OAKG;IACH,MAAM,IAAI,iBAAiB;CAC5B"}
@@ -1,3 +1,5 @@
1
- // Authorization
1
+ /**
2
+ * WorkoutKit authorization state as seen by Apple's `WorkoutScheduler`.
3
+ */
2
4
  export {};
3
5
  //# sourceMappingURL=ReactNativeWorkouts.types.js.map