react-native-smkit-ui
Version:
React Native library for SMKit UI - Advanced fitness assessments and workout programs with AI-powered motion detection and real-time performance tracking
278 lines (257 loc) • 9.81 kB
JavaScript
/**
* Enum representing assessment types.
* @enum {string}
*/
export let AssessmentTypes = /*#__PURE__*/function (AssessmentTypes) {
AssessmentTypes["Fitness"] = "fitness";
AssessmentTypes["Custom"] = "custom";
AssessmentTypes["Body360"] = "body360";
return AssessmentTypes;
}({});
/**
* Enum representing UI elements that can be displayed during workouts.
* @enum {string}
*/
export let UIElement = /*#__PURE__*/function (UIElement) {
UIElement["RepsCounter"] = "repsCounter";
UIElement["Timer"] = "timer";
UIElement["GaugeOfMotion"] = "gaugeOfMotion";
return UIElement;
}({});
/**
* Enum representing body zones targeted in workouts.
* @enum {string}
*/
export let BodyZone = /*#__PURE__*/function (BodyZone) {
BodyZone["UpperBody"] = "UpperBody";
BodyZone["LowerBody"] = "LowerBody";
BodyZone["FullBody"] = "FullBody";
return BodyZone;
}({});
/**
* Enum representing workout difficulty levels.
* @enum {string}
*/
export let WorkoutDifficulty = /*#__PURE__*/function (WorkoutDifficulty) {
WorkoutDifficulty["LowDifficulty"] = "LowDifficulty";
WorkoutDifficulty["MidDifficulty"] = "MidDifficulty";
WorkoutDifficulty["HighDifficulty"] = "HighDifficulty";
return WorkoutDifficulty;
}({});
/**
* Enum representing workout durations.
* @enum {string}
*/
export let WorkoutDuration = /*#__PURE__*/function (WorkoutDuration) {
WorkoutDuration["Short"] = "Short";
WorkoutDuration["Long"] = "Long";
return WorkoutDuration;
}({});
/**
* Enum representing different types of scoring methods.
* @enum {string}
*/
export let ScoringType = /*#__PURE__*/function (ScoringType) {
ScoringType["Rom"] = "rom";
ScoringType["Time"] = "time";
ScoringType["Reps"] = "reps";
return ScoringType;
}({});
/**
* Enum representing gender options for user data.
* @enum {string}
*/
export let Gender = /*#__PURE__*/function (Gender) {
Gender["Female"] = "Female";
Gender["Male"] = "Male";
Gender["Other"] = "Rather not say";
return Gender;
}({});
export let Language = /*#__PURE__*/function (Language) {
Language["English"] = "en";
Language["Hebrew"] = "he";
return Language;
}({});
/**
* Enum representing the exercise rep counter prefrence.
* @enum {string}
*/
export let CounterPreferences = /*#__PURE__*/function (CounterPreferences) {
CounterPreferences["Default"] = "Default";
CounterPreferences["PerfectOnly"] = "PerfectOnly";
return CounterPreferences;
}({});
/**
* Enum representing the workout couser type.
* @enum {string}
*/
export let EndExercisePreferences = /*#__PURE__*/function (EndExercisePreferences) {
EndExercisePreferences["Default"] = "Default";
//on timer end
EndExercisePreferences["TargetBased"] = "TargetBased"; //on target reached
return EndExercisePreferences;
}({});
/**
* Class representing a workout.
*/
export class SMWorkout {
/**
* @param {string | null} id - Unique identifier for the workout.
* @param {string | null} name - Name of the workout.
* @param {string | null} workoutIntro - URL for workout intro sound.
* @param {string | null} soundtrack - URL for soundtrack.
* @param {SMExercise[]} exercises - List of exercises included in the workout.
* @param {string | null} getInFrame - URL for body cal get in frame sound.
* @param {string | null} bodycalFinished - URL for body cal finished sound.
* @param {string | null} workoutClosure - URL for workout closure sound.
*/
constructor(id, name, workoutIntro, soundtrack, exercises, getInFrame, bodycalFinished, workoutClosure) {
this.id = id || null;
this.name = name || null;
this.workoutIntro = workoutIntro || null;
this.soundtrack = soundtrack || null;
this.exercises = exercises;
this.getInFrame = getInFrame || null;
this.bodycalFinished = bodycalFinished || null;
this.workoutClosure = workoutClosure || null;
}
toJson() {
return JSON.stringify({
id: this.id,
name: this.name,
workoutIntro: this.workoutIntro,
soundtrack: this.soundtrack,
exercises: this.exercises,
getInFrame: this.getInFrame,
bodycalFinished: this.bodycalFinished,
workoutClosure: this.workoutClosure
});
}
}
/**
* Class representing an exercise in a workout.
*/
export class SMExercise {
/**
* @param {string | null} prettyName - Name of the exercise.
* @param {number | null} totalSeconds - Duration of the exercise in seconds.
* @param {string | null} videoInstruction - Video instruction URL.
* @param {string | null} exerciseIntro - URL for exercise intro sound.
* @param {UIElement[] | null} uiElements - List of UI elements for this exercise.
* @param {string} detector - Name of the detector for tracking exercise movement.
* @param {string | null} exerciseClosure - URL for exercise closer sound.
* @param {SMScoringParams | null} scoringParams - Parameters for exercise scoring.
*/
constructor(prettyName, totalSeconds, videoInstruction, exerciseIntro, uiElements, detector, exerciseClosure, scoringParams) {
this.prettyName = prettyName || null;
this.totalSeconds = totalSeconds || null;
this.videoInstruction = videoInstruction || null;
this.exerciseIntro = exerciseIntro || null;
this.uiElements = uiElements || null;
this.detector = detector;
this.exerciseClosure = exerciseClosure || null;
this.scoringParams = scoringParams || null;
}
}
/**
* Class representing an exercise in an assessment.
*/
export class SMAssessmentExercise extends SMExercise {
/**
* @param {string | null} prettyName - Name of the exercise.
* @param {number | null} totalSeconds - Duration of the exercise in seconds.
* @param {string | null} videoInstruction - Video instruction URL.
* @param {string | null} exerciseIntro - URL for exercise intro sound.
* @param {UIElement[] | null} uiElements - List of UI elements for this exercise.
* @param {string} detector - Name of the detector for tracking exercise movement.
* @param {string | null} exerciseClosure - URL for exercise closer sound.
* @param {SMScoringParams | null} scoringParams - Parameters for exercise scoring.
* @param {string | null} closureFailedSound - Applicable only for ClouserTarget.TargetBased, URL for exercise closure sound If you did not reach clouser target.
* @param {string | null} summaryTitle - Title for the exercise summary.
* @param {string | null} summarySubTitle - Subtitle for the exercise summary.
* @param {string | null} summaryMainMetricTitle - Main metric title in the summary.
* @param {string | null} summaryMainMetricSubTitle - Main metric subtitle in the summary.
*/
constructor(prettyName, totalSeconds, videoInstruction, exerciseIntro, uiElements, detector, exerciseClosure, scoringParams, closureFailedSound, summaryTitle, summarySubTitle, summaryMainMetricTitle, summaryMainMetricSubTitle) {
// Call the constructor of the parent class (SMExercise)
super(prettyName, totalSeconds, videoInstruction, exerciseIntro, uiElements, detector, exerciseClosure, scoringParams);
// Set additional properties specific to SMAssessmentExercise
this.closureFailedSound = closureFailedSound || null;
this.summaryTitle = summaryTitle || null;
this.summarySubTitle = summarySubTitle || null;
this.summaryMainMetricTitle = summaryMainMetricTitle || null;
this.summaryMainMetricSubTitle = summaryMainMetricSubTitle || null;
}
}
/**
* Class representing scoring parameters for an exercise.
*/
export class SMScoringParams {
/**
* @param {ScoringType | null} type - Type of scoring (e.g., ROM, time, reps).
* @param {number | null} scoreFactor - Factor to adjust the score.
* @param {number | null} targetTime - Target time for time-based scoring.
* @param {number | null} targetReps - Target reps for rep-based scoring.
* @param {string | null} targetRom - Range of motion target for ROM-based scoring.
* @param {string[] | null} passCriteria - List of criteria required to pass.
*/
constructor(type, scoreFactor, targetTime, targetReps, targetRom, passCriteria) {
this.type = type || null;
this.scoreFactor = scoreFactor || null;
this.targetTime = targetTime || null;
this.targetReps = targetReps || null;
this.targetRom = targetRom || null;
this.passCriteria = passCriteria || null;
}
}
/**
* Class representing the configuration for a workout program.
*/
export class WorkoutConfig {
/**
* @param {number} week - Week number in the program.
* @param {BodyZone} bodyZone - Targeted body zone for the workout.
* @param {WorkoutDifficulty} difficultyLevel - Difficulty level of the workout.
* @param {WorkoutDuration} workoutDuration - Duration of the workout.
* @param {Language} language - The session language
* @param {string} programID - Unique identifier for the workout program.
*/
constructor(week, bodyZone, difficultyLevel, workoutDuration, language, programID) {
this.week = week;
this.bodyZone = bodyZone;
this.difficultyLevel = difficultyLevel;
this.workoutDuration = workoutDuration;
this.language = language;
this.programID = programID;
}
toJson() {
return JSON.stringify({
week: this.week,
bodyZone: this.bodyZone,
difficultyLevel: this.difficultyLevel,
workoutDuration: this.workoutDuration,
language: this.language,
programID: this.programID
});
}
}
/**
* Class representing user data.
*/
export class UserData {
/**
* @param {Gender} gender - User's gender.
* @param {number} age - User's age.
*/
constructor(gender, age) {
this.gender = gender;
this.age = age;
}
toJson() {
return JSON.stringify({
gender: this.gender,
age: this.age
});
}
}
//# sourceMappingURL=SMWorkout.js.map