@sency/react-native-smkit-ui 2.0.1 → 2.0.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/src/index.tsx CHANGED
@@ -31,25 +31,36 @@ export function configure(key: string): Promise<string> {
31
31
  * start an assessment session.
32
32
  *
33
33
  * @param {SMWorkoutLibrary.AssessmentTypes} type - The type of assessment to start.
34
- * @param {boolean} [showSummary=true] - Determines if the summary should be shown after assessment completion.
34
+ * @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
35
35
  * @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment session, or `null` if no user data is provided.
36
- * @param {boolean} [forceShowUserDataScreen=false] - Forces the display of the user data screen even if user data is provided.
36
+ * @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
37
37
  * @param {string} customAssessmentID - A unique identifier for a custom assessment session.
38
+ * @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
38
39
  * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating whether the assessment finished.
39
40
  */
40
41
  export function startAssessment(
41
42
  type: SMWorkoutLibrary.AssessmentTypes,
42
- showSummary: boolean = true,
43
+ showSummary: boolean,
43
44
  userData: SMWorkoutLibrary.UserData | null,
44
- forceShowUserDataScreen: boolean = false,
45
- customAssessmentID: string
45
+ forceShowUserDataScreen: boolean,
46
+ customAssessmentID: string,
47
+ modifications: string | null
46
48
  ): Promise<{ summary: string; didFinish: boolean }> {
49
+ const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
50
+ // Ensure modifications is explicitly null (not undefined) for React Native bridge
51
+ // Convert empty string to null, but ensure we always pass a value (even if null)
52
+ const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
53
+
54
+ // Call native method - React Native legacy bridge automatically handles promise conversion
55
+ // IMPORTANT: Always pass all 6 arguments, even if null
56
+ // React Native bridge counts arguments, so we must pass modifications even when null
47
57
  return SMKitUIManager.startAssessment(
48
- type,
58
+ String(type),
49
59
  showSummary,
50
- userData?.toJson(),
60
+ userDataJson ?? null,
51
61
  forceShowUserDataScreen,
52
- customAssessmentID
62
+ customAssessmentID || '',
63
+ modificationsJson ?? null
53
64
  );
54
65
  }
55
66
 
@@ -57,12 +68,18 @@ export function startAssessment(
57
68
  * Starts a custom workout session.
58
69
  *
59
70
  * @param {SMWorkoutLibrary.SMWorkout} workout - The custom workout configuration.
71
+ * @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
60
72
  * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the workout session finished.
61
73
  */
62
74
  export function startCustomWorkout(
63
- workout: SMWorkoutLibrary.SMWorkout
75
+ workout: SMWorkoutLibrary.SMWorkout,
76
+ modifications: string | null
64
77
  ): Promise<{ summary: string; didFinish: boolean }> {
65
- return SMKitUIManager.startCustomWorkout(workout.toJson());
78
+ const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
79
+ return SMKitUIManager.startCustomWorkout(
80
+ workout.toJson(),
81
+ modificationsJson
82
+ );
66
83
  }
67
84
 
68
85
  /**
@@ -70,21 +87,26 @@ export function startCustomWorkout(
70
87
  *
71
88
  * @param {SMWorkoutLibrary.SMWorkout} assessment - The assessment configuration for the session.
72
89
  * @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment, or `null` if no user data is provided.
73
- * @param {boolean} [forceShowUserDataScreen=false] - Forces the display of the user data screen even if user data is provided.
74
- * @param {boolean} [showSummary=true] - Determines if the summary should be shown after assessment completion.
90
+ * @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
91
+ * @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
92
+ * @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
75
93
  * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the assessment finished.
76
94
  */
77
95
  export function startCustomAssessment(
78
96
  assessment: SMWorkoutLibrary.SMWorkout,
79
97
  userData: SMWorkoutLibrary.UserData | null,
80
- forceShowUserDataScreen: boolean = false,
81
- showSummary: boolean = true
98
+ forceShowUserDataScreen: boolean,
99
+ showSummary: boolean,
100
+ modifications: string | null
82
101
  ): Promise<{ summary: string; didFinish: boolean }> {
102
+ const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
103
+ const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
83
104
  return SMKitUIManager.startCustomAssessment(
84
105
  assessment.toJson(),
85
- userData?.toJson(),
106
+ userDataJson,
86
107
  forceShowUserDataScreen,
87
- showSummary
108
+ showSummary,
109
+ modificationsJson
88
110
  );
89
111
  }
90
112
 
@@ -92,12 +114,18 @@ export function startCustomAssessment(
92
114
  * Starts a workout program using the provided workout configuration.
93
115
  *
94
116
  * @param {SMWorkoutLibrary.WorkoutConfig} workoutConfig - The configuration for the workout program.
117
+ * @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
95
118
  * @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the workout program finished.
96
119
  */
97
120
  export function startWorkoutProgram(
98
- workoutConfig: SMWorkoutLibrary.WorkoutConfig
121
+ workoutConfig: SMWorkoutLibrary.WorkoutConfig,
122
+ modifications: string | null
99
123
  ): Promise<{ summary: string; didFinish: boolean }> {
100
- return SMKitUIManager.startWorkoutProgram(workoutConfig.toJson());
124
+ const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
125
+ return SMKitUIManager.startWorkoutProgram(
126
+ workoutConfig.toJson(),
127
+ modificationsJson
128
+ );
101
129
  }
102
130
 
103
131
  /**