hevy-shared 1.0.1036 → 1.0.1038
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/built/geography.d.ts +1 -0
- package/built/geography.js +15 -0
- package/built/index.d.ts +1 -0
- package/built/index.js +1 -0
- package/built/tests/geography.test.d.ts +1 -0
- package/built/tests/geography.test.js +25 -0
- package/built/workout/publicWorkout.d.ts +1 -3
- package/built/workout/userWorkout.d.ts +1 -22
- package/built/workout/workout.d.ts +1 -22
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const distanceMBetween: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.distanceMBetween = void 0;
|
|
4
|
+
const haversineDistance = (lat1, lon1, lat2, lon2) => {
|
|
5
|
+
const R = 6371;
|
|
6
|
+
const dLat = ((lat2 - lat1) * Math.PI) / 180;
|
|
7
|
+
const dLon = ((lon2 - lon1) * Math.PI) / 180;
|
|
8
|
+
const a = Math.sin(dLat / 2) ** 2 +
|
|
9
|
+
Math.cos((lat1 * Math.PI) / 180) *
|
|
10
|
+
Math.cos((lat2 * Math.PI) / 180) *
|
|
11
|
+
Math.sin(dLon / 2) ** 2;
|
|
12
|
+
return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
13
|
+
};
|
|
14
|
+
const distanceMBetween = (lat1, lon1, lat2, lon2) => Math.round(haversineDistance(lat1, lon1, lat2, lon2) * 1000);
|
|
15
|
+
exports.distanceMBetween = distanceMBetween;
|
package/built/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './hevyTrainer';
|
|
|
29
29
|
export * from './translations';
|
|
30
30
|
export * from './exerciseLocaleUtils';
|
|
31
31
|
export * from './getVolumeComparison';
|
|
32
|
+
export * from './geography';
|
|
32
33
|
export type WeightUnit = 'kg' | 'lbs';
|
|
33
34
|
export declare const isWeightUnit: (x: string) => x is WeightUnit;
|
|
34
35
|
export type DistanceUnit = 'kilometers' | 'miles';
|
package/built/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __exportStar(require("./hevyTrainer"), exports);
|
|
|
41
41
|
__exportStar(require("./translations"), exports);
|
|
42
42
|
__exportStar(require("./exerciseLocaleUtils"), exports);
|
|
43
43
|
__exportStar(require("./getVolumeComparison"), exports);
|
|
44
|
+
__exportStar(require("./geography"), exports);
|
|
44
45
|
const isWeightUnit = (x) => {
|
|
45
46
|
return x === 'kg' || x === 'lbs';
|
|
46
47
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const geography_1 = require("../geography");
|
|
13
|
+
describe('Geography utils', () => {
|
|
14
|
+
describe('distanceMBetween', () => {
|
|
15
|
+
it('Calculates the distance between two sets of coordinates', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
expect((0, geography_1.distanceMBetween)(51.001, 52, 51, 52)).toBe(111);
|
|
17
|
+
expect((0, geography_1.distanceMBetween)(51.002, 52, 51, 52)).toBe(222);
|
|
18
|
+
expect((0, geography_1.distanceMBetween)(50.999, 52, 51, 52)).toBe(111);
|
|
19
|
+
expect((0, geography_1.distanceMBetween)(51.01, 52, 51, 52)).toBe(1112);
|
|
20
|
+
expect((0, geography_1.distanceMBetween)(51.04, 52, 51, 52)).toBe(4448);
|
|
21
|
+
expect((0, geography_1.distanceMBetween)(51.035, 52.035, 51, 52)).toBe(4598);
|
|
22
|
+
expect((0, geography_1.distanceMBetween)(50.965, 51.965, 51, 52)).toBe(4599);
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DistanceUnit,
|
|
1
|
+
import { DistanceUnit, ExerciseType, MuscleGroup, RPE, SetPersonalRecordType, SetType, WeightUnit } from '..';
|
|
2
2
|
export declare const isPublicWorkout: (x: any) => x is PublicWorkout;
|
|
3
3
|
export interface PublicWorkout {
|
|
4
4
|
type: 'public';
|
|
@@ -39,11 +39,9 @@ export interface PublicWorkoutExercise {
|
|
|
39
39
|
superset_id: number | null;
|
|
40
40
|
rest_seconds: number | null;
|
|
41
41
|
notes: string;
|
|
42
|
-
priority: number;
|
|
43
42
|
muscle_group: MuscleGroup;
|
|
44
43
|
other_muscles: MuscleGroup[];
|
|
45
44
|
exercise_type: ExerciseType;
|
|
46
|
-
equipment_category: Equipment;
|
|
47
45
|
url?: string;
|
|
48
46
|
media_type?: string;
|
|
49
47
|
custom_exercise_image_url?: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExerciseType, MuscleGroup, PreviewWorkoutLike, RPE, SetPersonalRecordType, SetType, WorkoutBiometrics, WorkoutComment, WorkoutMedia } from '..';
|
|
2
2
|
export interface UserWorkout {
|
|
3
3
|
id: string;
|
|
4
4
|
short_id: string | null;
|
|
@@ -6,13 +6,9 @@ export interface UserWorkout {
|
|
|
6
6
|
name: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
like_count: number;
|
|
9
|
-
/** @deprecated 2.3.4 */
|
|
10
|
-
like_images: string[];
|
|
11
9
|
preview_workout_likes: PreviewWorkoutLike[];
|
|
12
10
|
comment_count: number;
|
|
13
11
|
comments: WorkoutComment[];
|
|
14
|
-
/** @deprecated 1.28.13 */
|
|
15
|
-
image_urls?: string[];
|
|
16
12
|
media: WorkoutMedia[];
|
|
17
13
|
is_liked_by_user: boolean;
|
|
18
14
|
start_time: number;
|
|
@@ -60,17 +56,10 @@ export interface UserWorkoutExercise {
|
|
|
60
56
|
superset_id: number | null;
|
|
61
57
|
rest_seconds: number | null;
|
|
62
58
|
notes: string;
|
|
63
|
-
priority: number;
|
|
64
59
|
muscle_group: MuscleGroup;
|
|
65
60
|
other_muscles: MuscleGroup[];
|
|
66
61
|
exercise_type: ExerciseType;
|
|
67
|
-
equipment_category: Equipment;
|
|
68
|
-
url?: string;
|
|
69
|
-
media_type?: string;
|
|
70
|
-
custom_exercise_image_url?: string | null;
|
|
71
62
|
thumbnail_url?: string | null;
|
|
72
|
-
manual_tag?: string;
|
|
73
|
-
aka?: string;
|
|
74
63
|
/**
|
|
75
64
|
* for exercises with two dumbbells
|
|
76
65
|
*
|
|
@@ -96,16 +85,6 @@ export interface UserWorkoutExerciseSet {
|
|
|
96
85
|
duration_seconds?: number | null;
|
|
97
86
|
custom_metric?: number | null;
|
|
98
87
|
rpe?: RPE | null;
|
|
99
|
-
/**
|
|
100
|
-
* @deprecated 1.29.17 -
|
|
101
|
-
* we can only set this to `best_weight`, `best_reps`, `best_duration` or
|
|
102
|
-
* `best_distance`. sending anything else would cause older clients to crash.
|
|
103
|
-
* newer clients will ignore this field and use the `prs` field instead.
|
|
104
|
-
*/
|
|
105
|
-
personalRecords?: Array<{
|
|
106
|
-
type: 'best_weight' | 'best_reps' | 'best_duration' | 'best_distance';
|
|
107
|
-
value: number;
|
|
108
|
-
}>;
|
|
109
88
|
prs: {
|
|
110
89
|
type: SetPersonalRecordType;
|
|
111
90
|
value: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExerciseType, MuscleGroup, PreviewWorkoutLike, RPE, SetPersonalRecordType, SetType, WorkoutBiometrics, WorkoutComment, WorkoutMedia } from '..';
|
|
2
2
|
export interface OwnedWorkout {
|
|
3
3
|
id: string;
|
|
4
4
|
short_id: string | null;
|
|
@@ -6,13 +6,9 @@ export interface OwnedWorkout {
|
|
|
6
6
|
name: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
like_count: number;
|
|
9
|
-
/** @deprecated 2.3.4 */
|
|
10
|
-
like_images: string[];
|
|
11
9
|
preview_workout_likes: PreviewWorkoutLike[];
|
|
12
10
|
comment_count: number;
|
|
13
11
|
comments: WorkoutComment[];
|
|
14
|
-
/** @deprecated 1.28.13 */
|
|
15
|
-
image_urls?: string[];
|
|
16
12
|
media: WorkoutMedia[];
|
|
17
13
|
is_liked_by_user: boolean;
|
|
18
14
|
start_time: number;
|
|
@@ -55,17 +51,10 @@ export interface OwnedWorkoutExercise {
|
|
|
55
51
|
superset_id: number | null;
|
|
56
52
|
rest_seconds: number | null;
|
|
57
53
|
notes: string;
|
|
58
|
-
priority: number;
|
|
59
54
|
muscle_group: MuscleGroup;
|
|
60
55
|
other_muscles: MuscleGroup[];
|
|
61
56
|
exercise_type: ExerciseType;
|
|
62
|
-
equipment_category: Equipment;
|
|
63
|
-
url?: string;
|
|
64
|
-
media_type?: string;
|
|
65
|
-
custom_exercise_image_url?: string | null;
|
|
66
57
|
thumbnail_url?: string | null;
|
|
67
|
-
manual_tag?: string;
|
|
68
|
-
aka?: string;
|
|
69
58
|
/**
|
|
70
59
|
* for exercises with two dumbbells
|
|
71
60
|
*
|
|
@@ -91,16 +80,6 @@ export interface OwnedWorkoutExerciseSet {
|
|
|
91
80
|
duration_seconds?: number | null;
|
|
92
81
|
custom_metric?: number | null;
|
|
93
82
|
rpe?: RPE | null;
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated 1.29.17 -
|
|
96
|
-
* we can only set this to `best_weight`, `best_reps`, `best_duration` or
|
|
97
|
-
* `best_distance`. sending anything else would cause older clients to crash.
|
|
98
|
-
* newer clients will ignore this field and use the `prs` field instead.
|
|
99
|
-
*/
|
|
100
|
-
personalRecords?: Array<{
|
|
101
|
-
type: 'best_weight' | 'best_reps' | 'best_duration' | 'best_distance';
|
|
102
|
-
value: number;
|
|
103
|
-
}>;
|
|
104
83
|
prs: {
|
|
105
84
|
type: SetPersonalRecordType;
|
|
106
85
|
value: number;
|