muscle-body-map 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jaseb Meza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,266 @@
1
- # Temporary Holding Version
1
+ # muscle-body-map
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An interactive map of the human body's muscles for **React** and **React Native** (Expo included).
4
+ Color each muscle by how hard it works, and hover or tap it to see its name and effort.
5
+
6
+ **[Live examples →](https://hawkbt.github.io/muscle-body-map/)**
7
+
8
+ - **28 muscle regions** on the front and back of the body, each with a left and a right side.
9
+ - **Effort as color:** give a muscle a value from 0 to 100 and it gets a step of your color scale.
10
+ - **Tooltip** on hover, keyboard focus or tap, showing the name, the percentage and the color. Turn it off or draw your own.
11
+ - **Upper body, lower body or the whole body**, for exercises that only use one part.
12
+ - **Your colors:** any scale, a dark or light theme, or a fixed color per muscle.
13
+ - **Small, no dependencies:** about 13 kB, plain SVG, typed with TypeScript.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install muscle-body-map
19
+ # or
20
+ yarn add muscle-body-map
21
+ # or
22
+ pnpm add muscle-body-map
23
+ ```
24
+
25
+ React Native also needs `react-native-svg` (Expo: `npx expo install react-native-svg`).
26
+
27
+ ## Quick start
28
+
29
+ ### React (web)
30
+
31
+ ```tsx
32
+ import { Body } from "muscle-body-map/react";
33
+
34
+ const benchPress = [
35
+ { slug: "middle-chest", value: 95 },
36
+ { slug: "upper-chest", value: 70 },
37
+ { slug: "triceps", value: 60 },
38
+ { slug: "anterior-deltoid", value: 55 },
39
+ ];
40
+
41
+ export function ExerciseMuscles() {
42
+ return (
43
+ <div style={{ display: "flex", gap: 16 }}>
44
+ <Body data={benchPress} side="front" />
45
+ <Body data={benchPress} side="back" />
46
+ </div>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### React Native / Expo
52
+
53
+ ```tsx
54
+ import { Body } from "muscle-body-map/native";
55
+
56
+ export function ExerciseMuscles() {
57
+ return <Body data={[{ slug: "biceps", value: 80 }]} scale={0.8} />;
58
+ }
59
+ ```
60
+
61
+ Both components take the same props. The only differences: on the web you size it with `className` or `style` and get `onBodyPartHover`; on a phone the tooltip opens on tap.
62
+
63
+ ## How it works
64
+
65
+ You pass `data`, a list of the muscles to color. Muscles not in the list stay neutral.
66
+
67
+ ```ts
68
+ type BodyPartData = {
69
+ slug: MuscleSlug; // which muscle, e.g. "biceps" (full list below)
70
+ value?: number; // effort from 0 to 100: picks the color and shows as "85%"
71
+ intensity?: number; // or pick a step of the color scale yourself: 1, 2, 3...
72
+ color?: string; // or give a fixed color
73
+ side?: "left" | "right"; // only color one side of the body
74
+ };
75
+ ```
76
+
77
+ When more than one is set, `color` wins over `intensity`, and `intensity` wins over `value`.
78
+
79
+ With the default 4-color scale, `value` maps like this:
80
+
81
+ | value | 1–25 | 26–50 | 51–75 | 76–100 |
82
+ |---|---|---|---|---|
83
+ | color | lime `#adf129` | amber `#ffb330` | orange `#f97430` | red `#f22a36` |
84
+
85
+ With a scale of `n` colors, each step covers `100 / n`.
86
+
87
+ ## Props
88
+
89
+ | Prop | Type | Default | What it does |
90
+ |---|---|---|---|
91
+ | `data` | `BodyPartData[]` | required | The muscles to color. |
92
+ | `side` | `"front" \| "back"` | `"front"` | Which side of the body to draw. |
93
+ | `view` | `"full" \| "upper" \| "lower"` | `"full"` | Draw the whole body, or crop to the upper or lower body. |
94
+ | `colors` | `string[]` | lime → red | The effort scale, light to heavy. Any number of colors. |
95
+ | `theme` | `"dark" \| "light"` | `"dark"` | Neutral colors for a dark or a light page. |
96
+ | `fill` | `string` | from theme | Color of muscles that aren't worked. |
97
+ | `outline` | `string` | from theme | Color of the body (head, hands, joints). |
98
+ | `stroke` | `string` | from theme | Lines between muscles. |
99
+ | `strokeWidth` | `number` | `0.5` | Width of those lines. |
100
+ | `activeStroke` | `string` | from theme | Outline of the hovered, tapped or active muscle. |
101
+ | `border` | `string` | `"none"` | A line around the whole body. |
102
+ | `tooltip` | `boolean \| (info) => ReactNode` | `true` | Show the tooltip, hide it with `false`, or render your own. |
103
+ | `labels` | `Partial<Record<MuscleSlug, string>>` | English names | Rename muscles, for example to translate them. |
104
+ | `activePart` | `MuscleSlug \| null` | the hovered one | Outline a muscle yourself. |
105
+ | `hiddenParts` | `MuscleSlug[]` | `[]` | Muscles not to draw. |
106
+ | `onBodyPartPress` | `(slug, half) => void` | | Called when a muscle is clicked or tapped. |
107
+ | `onBodyPartHover` | `(slug \| null) => void` | | Web only. Called when the pointer or keyboard focus moves. |
108
+ | `scale` | `number` | `1` | Size: the full body is 200 × 420 times `scale`. |
109
+ | `className`, `style` | | | Web: on the wrapper; set a width and the height follows. Native: `style` only. |
110
+
111
+ ## Examples
112
+
113
+ ### Only the upper or lower body
114
+
115
+ ```tsx
116
+ <Body data={squat} view="lower" side="back" />
117
+ ```
118
+
119
+ `upper` goes from the head to the hands; `lower` from the hips to the feet. Muscles mostly outside the
120
+ view are left out, so they can't be tapped by accident.
121
+
122
+ ### Your own colors
123
+
124
+ ```tsx
125
+ // Four blues from light to heavy, on a white page
126
+ <Body data={data} theme="light" colors={["#bae6fd", "#38bdf8", "#0284c7", "#075985"]} />
127
+
128
+ // Two steps are fine too
129
+ <Body data={data} colors={["#fde68a", "#dc2626"]} />
130
+
131
+ // Fixed colors, no scale
132
+ <Body data={[{ slug: "biceps", color: "#e11d48" }, { slug: "triceps", color: "#2563eb" }]} />
133
+ ```
134
+
135
+ ### Pick muscles (no tooltip)
136
+
137
+ ```tsx
138
+ const [selected, setSelected] = useState<MuscleSlug[]>([]);
139
+
140
+ <Body
141
+ data={selected.map((slug) => ({ slug, color: "#adf129" }))}
142
+ tooltip={false}
143
+ onBodyPartPress={(slug) =>
144
+ setSelected((list) => (list.includes(slug) ? list.filter((s) => s !== slug) : [...list, slug]))
145
+ }
146
+ />
147
+ ```
148
+
149
+ ### Your own tooltip
150
+
151
+ The function gets everything about the muscle under the pointer:
152
+
153
+ ```ts
154
+ type TooltipInfo = {
155
+ slug: MuscleSlug;
156
+ label: string; // "Biceps", or your own label
157
+ half: "left" | "right"; // which side of the body
158
+ worked: boolean;
159
+ value?: number; // what you passed, 0–100
160
+ intensity?: number; // the color step, 1-based
161
+ levels: number; // how many colors the scale has
162
+ color: string; // the muscle's color
163
+ };
164
+ ```
165
+
166
+ ```tsx
167
+ <Body
168
+ data={data}
169
+ tooltip={(info) => (
170
+ <div className="my-tooltip">
171
+ {info.label}: {info.worked ? `${info.value}%` : "rest"}
172
+ </div>
173
+ )}
174
+ />
175
+ ```
176
+
177
+ ### Translated names
178
+
179
+ ```tsx
180
+ <Body data={data} labels={{ biceps: "Bíceps", quadriceps: "Cuádriceps" }} />
181
+ ```
182
+
183
+ ### A legend
184
+
185
+ The scale is exported, so a legend uses the same colors:
186
+
187
+ ```tsx
188
+ import { DEFAULT_COLORS } from "muscle-body-map";
189
+
190
+ <div style={{ display: "flex", height: 6, width: 120 }}>
191
+ {DEFAULT_COLORS.map((c) => <span key={c} style={{ flex: 1, background: c }} />)}
192
+ </div>
193
+ ```
194
+
195
+ ## Muscles
196
+
197
+ | `slug` | Name | Shown on | In view |
198
+ |---|---|---|---|
199
+ | `trapezius` | Trapezius | front, back | upper |
200
+ | `upper-chest` | Upper Chest | front | upper |
201
+ | `middle-chest` | Middle Chest | front | upper |
202
+ | `lower-chest` | Lower Chest | front | upper |
203
+ | `serratus-anterior` | Serratus Anterior | front | upper |
204
+ | `latissimus-dorsi` | Latissimus Dorsi | front, back | upper |
205
+ | `rhomboids` | Rhomboids | back | upper |
206
+ | `lower-back` | Lower Back | back | upper |
207
+ | `anterior-deltoid` | Anterior Deltoid | front | upper |
208
+ | `lateral-deltoid` | Lateral Deltoid | front, back | upper |
209
+ | `posterior-deltoid` | Posterior Deltoid | back | upper |
210
+ | `rotator-cuff` | Rotator Cuff | back | upper |
211
+ | `biceps` | Biceps | front | upper |
212
+ | `brachialis` | Brachialis | front | upper |
213
+ | `brachioradialis` | Brachioradialis | front, back | upper |
214
+ | `triceps` | Triceps | back | upper |
215
+ | `forearms` | Forearms | front, back | upper |
216
+ | `rectus-abdominis` | Rectus Abdominis | front | upper |
217
+ | `obliques` | Obliques | front, back | upper |
218
+ | `hip-flexors` | Hip Flexors | front | upper, lower |
219
+ | `gluteus-maximus` | Gluteus Maximus | back | upper, lower |
220
+ | `gluteus-medius` | Gluteus Medius | back | upper, lower |
221
+ | `quadriceps` | Quadriceps | front | lower |
222
+ | `hamstrings` | Hamstrings | back | lower |
223
+ | `adductors` | Adductors | front, back | upper, lower |
224
+ | `abductors` | Abductors | front | upper, lower |
225
+ | `calves` | Calves | front, back | lower |
226
+ | `tibialis-anterior` | Tibialis Anterior | front | lower |
227
+
228
+ "Chest" is three regions (`upper-chest`, `middle-chest`, `lower-chest`) and "shoulders" three deltoids,
229
+ so you can show which part of the muscle an exercise hits. Color all three for the whole muscle.
230
+
231
+ ## Without React
232
+
233
+ The main entry has the drawing as plain data, for other frameworks or for drawing it yourself:
234
+
235
+ ```ts
236
+ import { BODY_PARTS, BODY_OUTLINE, BODY_VIEWBOX, MUSCLE_LABELS, describePart } from "muscle-body-map";
237
+
238
+ BODY_PARTS.front; // [{ slug: "biceps", path: { left: ["M…Z"], right: ["M…Z"] } }, …] SVG path strings
239
+ ```
240
+
241
+ Also exported: `MUSCLE_SLUGS`, `DEFAULT_COLORS`, `THEMES`, `BODY_VIEWS`, `levelFromValue`,
242
+ `tooltipDetail`, `partAnchor`, `partInView` and all the types.
243
+
244
+ ## Accessibility
245
+
246
+ On the web every muscle is a button you can reach with Tab. Its tooltip opens on focus, and Enter
247
+ or Space presses it. The default scale changes in lightness as well as hue, so its steps can be told
248
+ apart without color vision (this is tested). If you use your own scale, do the same, and add a legend
249
+ or a text list next to the map.
250
+
251
+ ## Contributing
252
+
253
+ ```bash
254
+ pnpm install
255
+ pnpm demo # live examples at http://localhost:5173, served from the source
256
+ pnpm test # unit tests
257
+ pnpm typecheck
258
+ pnpm build # writes dist/
259
+ ```
260
+
261
+ The muscle shapes live in `src/shapes.ts`. Each one is drawn once as a list of points on one side
262
+ of the body, mirrored to the other side, and smoothed into a curve.
263
+
264
+ ## License
265
+
266
+ [MIT](./LICENSE)
package/dist/core.d.ts ADDED
@@ -0,0 +1,116 @@
1
+ export type BodySide = "front" | "back";
2
+ export type BodyHalf = "left" | "right";
3
+ /** Every muscle region on the map, with its English name. */
4
+ export declare const MUSCLE_LABELS: {
5
+ readonly trapezius: "Trapezius";
6
+ readonly "upper-chest": "Upper Chest";
7
+ readonly "middle-chest": "Middle Chest";
8
+ readonly "lower-chest": "Lower Chest";
9
+ readonly "serratus-anterior": "Serratus Anterior";
10
+ readonly "latissimus-dorsi": "Latissimus Dorsi";
11
+ readonly rhomboids: "Rhomboids";
12
+ readonly "lower-back": "Lower Back";
13
+ readonly "anterior-deltoid": "Anterior Deltoid";
14
+ readonly "lateral-deltoid": "Lateral Deltoid";
15
+ readonly "posterior-deltoid": "Posterior Deltoid";
16
+ readonly "rotator-cuff": "Rotator Cuff";
17
+ readonly biceps: "Biceps";
18
+ readonly brachialis: "Brachialis";
19
+ readonly brachioradialis: "Brachioradialis";
20
+ readonly triceps: "Triceps";
21
+ readonly forearms: "Forearms";
22
+ readonly "rectus-abdominis": "Rectus Abdominis";
23
+ readonly obliques: "Obliques";
24
+ readonly "hip-flexors": "Hip Flexors";
25
+ readonly "gluteus-maximus": "Gluteus Maximus";
26
+ readonly "gluteus-medius": "Gluteus Medius";
27
+ readonly quadriceps: "Quadriceps";
28
+ readonly hamstrings: "Hamstrings";
29
+ readonly adductors: "Adductors";
30
+ readonly abductors: "Abductors";
31
+ readonly calves: "Calves";
32
+ readonly "tibialis-anterior": "Tibialis Anterior";
33
+ };
34
+ export type MuscleSlug = keyof typeof MUSCLE_LABELS;
35
+ export declare const MUSCLE_SLUGS: MuscleSlug[];
36
+ /** Light → heavy. Adjacent steps also differ in lightness, so they read without color vision (tested). */
37
+ export declare const DEFAULT_COLORS: readonly ["#adf129", "#ffb330", "#f97430", "#f22a36"];
38
+ export declare const BODY_WIDTH = 200;
39
+ export declare const BODY_HEIGHT = 420;
40
+ export declare const BODY_VIEWBOX = "0 0 200 420";
41
+ export type BodyTheme = {
42
+ /** Muscles that are not worked. */
43
+ fill: string;
44
+ /** The silhouette (head, hands, feet, joints). */
45
+ outline: string;
46
+ /** Lines between muscles. */
47
+ stroke: string;
48
+ /** Outline of the hovered, tapped or active muscle. */
49
+ activeStroke: string;
50
+ /** A line around the whole body, or "none". */
51
+ border: string;
52
+ tooltipBackground: string;
53
+ tooltipText: string;
54
+ tooltipMuted: string;
55
+ };
56
+ export declare const THEMES: {
57
+ readonly dark: {
58
+ readonly fill: "#2e2e33";
59
+ readonly outline: "#222226";
60
+ readonly stroke: "#0d0d0f";
61
+ readonly activeStroke: "#fafafa";
62
+ readonly border: "none";
63
+ readonly tooltipBackground: "#18181b";
64
+ readonly tooltipText: "#fafafa";
65
+ readonly tooltipMuted: "#a1a1aa";
66
+ };
67
+ readonly light: {
68
+ readonly fill: "#d4d4d8";
69
+ readonly outline: "#e4e4e7";
70
+ readonly stroke: "#ffffff";
71
+ readonly activeStroke: "#18181b";
72
+ readonly border: "none";
73
+ readonly tooltipBackground: "#ffffff";
74
+ readonly tooltipText: "#18181b";
75
+ readonly tooltipMuted: "#71717a";
76
+ };
77
+ };
78
+ export type ThemeName = keyof typeof THEMES;
79
+ export type BodyPart = {
80
+ slug: MuscleSlug;
81
+ path: {
82
+ left?: string[];
83
+ right?: string[];
84
+ };
85
+ };
86
+ /** One worked muscle. Give `value` (0–100 %) or `intensity` (a step of `colors`), or a fixed `color`. */
87
+ export type BodyPartData = {
88
+ slug: MuscleSlug;
89
+ /** How hard the muscle works, 0–100. Picks the color step and shows as a percentage in the tooltip. */
90
+ value?: number;
91
+ /** 1-based step of the `colors` scale. Wins over `value` for the color. */
92
+ intensity?: number;
93
+ /** A fixed color. Wins over `value` and `intensity`. */
94
+ color?: string;
95
+ /** Only color one half of the body. */
96
+ side?: BodyHalf;
97
+ };
98
+ /** What a tooltip knows about a muscle. */
99
+ export type TooltipInfo = {
100
+ slug: MuscleSlug;
101
+ label: string;
102
+ half: BodyHalf;
103
+ worked: boolean;
104
+ value?: number;
105
+ intensity?: number;
106
+ levels: number;
107
+ color: string;
108
+ };
109
+ /** How much of the body to draw. Upper ends below the hands; lower starts at the hips. */
110
+ export type BodyView = "full" | "upper" | "lower";
111
+ /** Vertical crop of each view, in viewBox units. */
112
+ export declare const BODY_VIEWS: Record<BodyView, {
113
+ y: number;
114
+ height: number;
115
+ }>;
116
+ export declare const viewBoxOf: (view: BodyView) => string;
package/dist/core.js ADDED
@@ -0,0 +1,66 @@
1
+ /** Every muscle region on the map, with its English name. */
2
+ export const MUSCLE_LABELS = {
3
+ trapezius: "Trapezius",
4
+ "upper-chest": "Upper Chest",
5
+ "middle-chest": "Middle Chest",
6
+ "lower-chest": "Lower Chest",
7
+ "serratus-anterior": "Serratus Anterior",
8
+ "latissimus-dorsi": "Latissimus Dorsi",
9
+ rhomboids: "Rhomboids",
10
+ "lower-back": "Lower Back",
11
+ "anterior-deltoid": "Anterior Deltoid",
12
+ "lateral-deltoid": "Lateral Deltoid",
13
+ "posterior-deltoid": "Posterior Deltoid",
14
+ "rotator-cuff": "Rotator Cuff",
15
+ biceps: "Biceps",
16
+ brachialis: "Brachialis",
17
+ brachioradialis: "Brachioradialis",
18
+ triceps: "Triceps",
19
+ forearms: "Forearms",
20
+ "rectus-abdominis": "Rectus Abdominis",
21
+ obliques: "Obliques",
22
+ "hip-flexors": "Hip Flexors",
23
+ "gluteus-maximus": "Gluteus Maximus",
24
+ "gluteus-medius": "Gluteus Medius",
25
+ quadriceps: "Quadriceps",
26
+ hamstrings: "Hamstrings",
27
+ adductors: "Adductors",
28
+ abductors: "Abductors",
29
+ calves: "Calves",
30
+ "tibialis-anterior": "Tibialis Anterior",
31
+ };
32
+ export const MUSCLE_SLUGS = Object.keys(MUSCLE_LABELS);
33
+ /** Light → heavy. Adjacent steps also differ in lightness, so they read without color vision (tested). */
34
+ export const DEFAULT_COLORS = ["#adf129", "#ffb330", "#f97430", "#f22a36"];
35
+ export const BODY_WIDTH = 200;
36
+ export const BODY_HEIGHT = 420;
37
+ export const BODY_VIEWBOX = `0 0 ${BODY_WIDTH} ${BODY_HEIGHT}`;
38
+ export const THEMES = {
39
+ dark: {
40
+ fill: "#2e2e33",
41
+ outline: "#222226",
42
+ stroke: "#0d0d0f",
43
+ activeStroke: "#fafafa",
44
+ border: "none",
45
+ tooltipBackground: "#18181b",
46
+ tooltipText: "#fafafa",
47
+ tooltipMuted: "#a1a1aa",
48
+ },
49
+ light: {
50
+ fill: "#d4d4d8",
51
+ outline: "#e4e4e7",
52
+ stroke: "#ffffff",
53
+ activeStroke: "#18181b",
54
+ border: "none",
55
+ tooltipBackground: "#ffffff",
56
+ tooltipText: "#18181b",
57
+ tooltipMuted: "#71717a",
58
+ },
59
+ };
60
+ /** Vertical crop of each view, in viewBox units. */
61
+ export const BODY_VIEWS = {
62
+ full: { y: 0, height: BODY_HEIGHT },
63
+ upper: { y: 0, height: 250 },
64
+ lower: { y: 180, height: BODY_HEIGHT - 180 },
65
+ };
66
+ export const viewBoxOf = (view) => `0 ${BODY_VIEWS[view].y} ${BODY_WIDTH} ${BODY_VIEWS[view].height}`;
@@ -0,0 +1,18 @@
1
+ import { type BodyHalf, type BodyPartData, type BodySide, type BodyTheme, type BodyView, type MuscleSlug, type ThemeName, type TooltipInfo } from "./core.js";
2
+ export * from "./core.js";
3
+ export { BODY_BACK, BODY_FRONT, BODY_OUTLINE, BODY_PARTS } from "./shapes.js";
4
+ /** 0–100 → a 1-based step of an `levels`-step scale; 0 or less is not worked. */
5
+ export declare function levelFromValue(value: number, levels: number): number;
6
+ /** Everything a component needs to draw and describe one half of one muscle. */
7
+ export declare function describePart(data: readonly BodyPartData[], slug: MuscleSlug, half: BodyHalf, colors: readonly string[], fill: string, labels?: Partial<Record<MuscleSlug, string>>): TooltipInfo;
8
+ /** The tooltip's second line: "85%", "Level 3 of 4", "Worked" or "Not worked". */
9
+ export declare function tooltipDetail(info: TooltipInfo): string;
10
+ /** Top centre of a muscle half, in viewBox units: where its tooltip points. */
11
+ export declare function partAnchor(side: BodySide, slug: MuscleSlug, half: BodyHalf): {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ /** True when at least two thirds of the muscle's height is inside the view, so a sliver at the crop line isn't tappable. */
16
+ export declare function partInView(side: BodySide, slug: MuscleSlug, view: BodyView): boolean;
17
+ /** A theme preset with any given colors on top (undefined props keep the preset's value). */
18
+ export declare function resolveTheme(name: ThemeName, overrides?: Partial<BodyTheme>): BodyTheme;
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
1
+ import { BODY_HEIGHT, BODY_WIDTH, BODY_VIEWS, MUSCLE_LABELS, THEMES } from "./core.js";
2
+ import { BODY_PARTS } from "./shapes.js";
3
+ export * from "./core.js";
4
+ export { BODY_BACK, BODY_FRONT, BODY_OUTLINE, BODY_PARTS } from "./shapes.js";
5
+ /** 0–100 → a 1-based step of an `levels`-step scale; 0 or less is not worked. */
6
+ export function levelFromValue(value, levels) {
7
+ if (!(value > 0) || levels < 1)
8
+ return 0;
9
+ return Math.min(levels, Math.ceil((Math.min(value, 100) / 100) * levels));
10
+ }
11
+ /** Everything a component needs to draw and describe one half of one muscle. */
12
+ export function describePart(data, slug, half, colors, fill, labels = {}) {
13
+ const part = data.find((p) => p.slug === slug && (!p.side || p.side === half));
14
+ const levels = colors.length;
15
+ const intensity = part?.intensity ?? (part?.value != null ? levelFromValue(part.value, levels) : undefined);
16
+ const step = intensity ? colors[Math.min(Math.max(intensity, 1), levels) - 1] : undefined;
17
+ const color = part?.color ?? step ?? fill;
18
+ return {
19
+ slug,
20
+ label: labels[slug] ?? MUSCLE_LABELS[slug],
21
+ half,
22
+ worked: color !== fill,
23
+ value: part?.value,
24
+ intensity: intensity || undefined,
25
+ levels,
26
+ color,
27
+ };
28
+ }
29
+ /** The tooltip's second line: "85%", "Level 3 of 4", "Worked" or "Not worked". */
30
+ export function tooltipDetail(info) {
31
+ if (!info.worked)
32
+ return "Not worked";
33
+ if (info.value != null)
34
+ return `${Math.round(info.value)}%`;
35
+ if (info.intensity)
36
+ return `Level ${Math.min(info.intensity, info.levels)} of ${info.levels}`;
37
+ return "Worked";
38
+ }
39
+ const bounds = new Map();
40
+ function boundsOf(side, slug, half) {
41
+ const key = `${side}:${slug}:${half ?? "both"}`;
42
+ const cached = bounds.get(key);
43
+ if (cached)
44
+ return cached;
45
+ const path = BODY_PARTS[side].find((p) => p.slug === slug)?.path ?? {};
46
+ const paths = half ? (path[half] ?? []) : [...(path.left ?? []), ...(path.right ?? [])];
47
+ const nums = paths.join(" ").match(/-?\d+(\.\d+)?/g)?.map(Number) ?? [];
48
+ const box = { minX: BODY_WIDTH, maxX: 0, minY: BODY_HEIGHT, maxY: 0 };
49
+ for (let i = 0; i + 1 < nums.length; i += 2) {
50
+ box.minX = Math.min(box.minX, nums[i]);
51
+ box.maxX = Math.max(box.maxX, nums[i]);
52
+ box.minY = Math.min(box.minY, nums[i + 1]);
53
+ box.maxY = Math.max(box.maxY, nums[i + 1]);
54
+ }
55
+ bounds.set(key, box);
56
+ return box;
57
+ }
58
+ /** Top centre of a muscle half, in viewBox units: where its tooltip points. */
59
+ export function partAnchor(side, slug, half) {
60
+ const box = boundsOf(side, slug, half);
61
+ return { x: (box.minX + box.maxX) / 2, y: box.minY };
62
+ }
63
+ /** True when at least two thirds of the muscle's height is inside the view, so a sliver at the crop line isn't tappable. */
64
+ export function partInView(side, slug, view) {
65
+ const { minY, maxY } = boundsOf(side, slug);
66
+ const { y, height } = BODY_VIEWS[view];
67
+ const visible = Math.min(maxY, y + height) - Math.max(minY, y);
68
+ return maxY > minY && visible >= ((maxY - minY) * 2) / 3;
69
+ }
70
+ /** A theme preset with any given colors on top (undefined props keep the preset's value). */
71
+ export function resolveTheme(name, overrides = {}) {
72
+ const set = Object.entries(overrides).filter(([, v]) => v !== undefined);
73
+ return { ...THEMES[name], ...Object.fromEntries(set) };
74
+ }
@@ -0,0 +1,33 @@
1
+ import { type ReactNode } from "react";
2
+ import { type StyleProp, type ViewStyle } from "react-native";
3
+ import { type BodyHalf, type BodyPartData, type BodySide, type BodyView, type MuscleSlug, type ThemeName, type TooltipInfo } from "./index.js";
4
+ export type { BodyHalf, BodyPartData, BodySide, BodyView, MuscleSlug, TooltipInfo };
5
+ export type BodyProps = {
6
+ /** The muscles to color. Muscles not listed use `fill`. */
7
+ data: readonly BodyPartData[];
8
+ side?: BodySide;
9
+ /** Draw the whole body (default), only the upper body, or only the lower body. */
10
+ view?: BodyView;
11
+ /** The intensity scale, light → heavy. Any number of steps. */
12
+ colors?: readonly string[];
13
+ /** Preset for the neutral colors. Any of the props below override it. */
14
+ theme?: ThemeName;
15
+ fill?: string;
16
+ outline?: string;
17
+ stroke?: string;
18
+ strokeWidth?: number;
19
+ activeStroke?: string;
20
+ border?: string;
21
+ /** Show a tooltip when a muscle is tapped (default), hide it (`false`), or render your own. */
22
+ tooltip?: boolean | ((info: TooltipInfo) => ReactNode);
23
+ /** Rename muscles, for example to translate them. */
24
+ labels?: Partial<Record<MuscleSlug, string>>;
25
+ /** Outline this muscle. Defaults to the tapped one. */
26
+ activePart?: MuscleSlug | null;
27
+ hiddenParts?: readonly MuscleSlug[];
28
+ onBodyPartPress?: (slug: MuscleSlug, half: BodyHalf) => void;
29
+ /** Width is 200 points times `scale`; height follows the view (420 for the full body). Default 1. */
30
+ scale?: number;
31
+ style?: StyleProp<ViewStyle>;
32
+ };
33
+ export declare function Body({ data, side, view, colors, theme, tooltip, labels, activePart, hiddenParts, onBodyPartPress, scale, strokeWidth, style, ...overrides }: BodyProps): import("react").JSX.Element;
package/dist/native.js ADDED
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Text, View } from "react-native";
4
+ import { G, Path, Svg } from "react-native-svg";
5
+ import { BODY_OUTLINE, BODY_PARTS, BODY_VIEWS, BODY_WIDTH, DEFAULT_COLORS, describePart, partAnchor, partInView, resolveTheme, tooltipDetail, viewBoxOf, } from "./index.js";
6
+ const HALVES = ["left", "right"];
7
+ export function Body({ data, side = "front", view = "full", colors = DEFAULT_COLORS, theme = "dark", tooltip = true, labels, activePart, hiddenParts = [], onBodyPartPress, scale = 1, strokeWidth = 0.5, style, ...overrides }) {
8
+ const t = resolveTheme(theme, overrides);
9
+ const crop = BODY_VIEWS[view];
10
+ const [shown, setShown] = useState(null);
11
+ const [tooltipWidth, setTooltipWidth] = useState(0);
12
+ const active = activePart === undefined ? shown?.slug : activePart;
13
+ const width = BODY_WIDTH * scale;
14
+ const press = (slug, half) => {
15
+ setShown((current) => (current?.slug === slug && current.half === half ? null : { slug, half }));
16
+ onBodyPartPress?.(slug, half);
17
+ };
18
+ const info = shown ? describePart(data, shown.slug, shown.half, colors, t.fill, labels) : null;
19
+ const anchor = shown ? partAnchor(side, shown.slug, shown.half) : null;
20
+ return (_jsxs(View, { style: [{ width, height: crop.height * scale }, style], children: [_jsxs(Svg, { viewBox: viewBoxOf(view), width: width, height: crop.height * scale, children: [t.border !== "none" ? BODY_OUTLINE.map((d) => _jsx(Path, { d: d, fill: "none", stroke: t.border, strokeWidth: 2 }, `b${d}`)) : null, BODY_OUTLINE.map((d) => (_jsx(Path, { d: d, fill: t.outline, onPress: () => setShown(null) }, d))), BODY_PARTS[side]
21
+ .filter((part) => !hiddenParts.includes(part.slug) && partInView(side, part.slug, view))
22
+ .map(({ slug, path }) => {
23
+ const isActive = active === slug;
24
+ return (_jsx(G, { stroke: isActive ? t.activeStroke : t.stroke, strokeWidth: isActive ? strokeWidth * 2.4 : strokeWidth, children: HALVES.flatMap((half) => (path[half] ?? []).map((d) => {
25
+ const part = describePart(data, slug, half, colors, t.fill, labels);
26
+ return (_jsx(Path, { d: d, fill: part.color, onPress: () => press(slug, half), accessible: true, accessibilityLabel: `${part.label}, ${tooltipDetail(part)}` }, d));
27
+ })) }, slug));
28
+ })] }), tooltip && info && anchor ? (_jsx(View, { pointerEvents: "none", onLayout: (event) => setTooltipWidth(event.nativeEvent.layout.width), style: {
29
+ position: "absolute",
30
+ // Centred over the muscle, kept inside the body's width; hidden until measured.
31
+ left: Math.min(Math.max(anchor.x * scale - tooltipWidth / 2, 0), Math.max(width - tooltipWidth, 0)),
32
+ top: Math.max((anchor.y - crop.y) * scale - 32, 0),
33
+ opacity: tooltipWidth ? 1 : 0,
34
+ }, children: typeof tooltip === "function" ? tooltip(info) : _jsx(DefaultTooltip, { info: info, theme: t }) })) : null] }));
35
+ }
36
+ function DefaultTooltip({ info, theme }) {
37
+ return (_jsxs(View, { style: {
38
+ flexDirection: "row",
39
+ alignItems: "center",
40
+ gap: 6,
41
+ paddingVertical: 5,
42
+ paddingHorizontal: 9,
43
+ borderRadius: 8,
44
+ backgroundColor: theme.tooltipBackground,
45
+ shadowColor: "#000",
46
+ shadowOpacity: 0.25,
47
+ shadowRadius: 8,
48
+ elevation: 4,
49
+ }, children: [_jsx(View, { style: { width: 10, height: 10, borderRadius: 3, backgroundColor: info.color } }), _jsx(Text, { style: { color: theme.tooltipText, fontSize: 12, fontWeight: "500" }, children: info.label }), _jsx(Text, { style: { color: theme.tooltipMuted, fontSize: 12, fontVariant: ["tabular-nums"] }, children: tooltipDetail(info) })] }));
50
+ }
@@ -0,0 +1,34 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ import { type BodyHalf, type BodyPartData, type BodySide, type BodyView, type MuscleSlug, type ThemeName, type TooltipInfo } from "./index.js";
3
+ export type { BodyHalf, BodyPartData, BodySide, BodyView, MuscleSlug, TooltipInfo };
4
+ export type BodyProps = {
5
+ /** The muscles to color. Muscles not listed use `fill`. */
6
+ data: readonly BodyPartData[];
7
+ side?: BodySide;
8
+ /** Draw the whole body (default), only the upper body, or only the lower body. */
9
+ view?: BodyView;
10
+ /** The intensity scale, light → heavy. Any number of steps. */
11
+ colors?: readonly string[];
12
+ /** Preset for the neutral colors. Any of the props below override it. */
13
+ theme?: ThemeName;
14
+ fill?: string;
15
+ outline?: string;
16
+ stroke?: string;
17
+ strokeWidth?: number;
18
+ activeStroke?: string;
19
+ border?: string;
20
+ /** Show a tooltip on hover, focus or tap (default), hide it (`false`), or render your own. */
21
+ tooltip?: boolean | ((info: TooltipInfo) => ReactNode);
22
+ /** Rename muscles, for example to translate them. */
23
+ labels?: Partial<Record<MuscleSlug, string>>;
24
+ /** Outline this muscle. Defaults to the one under the pointer. */
25
+ activePart?: MuscleSlug | null;
26
+ hiddenParts?: readonly MuscleSlug[];
27
+ onBodyPartPress?: (slug: MuscleSlug, half: BodyHalf) => void;
28
+ onBodyPartHover?: (slug: MuscleSlug | null) => void;
29
+ /** Width in px is `200 × scale` (height follows), unless `className` or `style` set a width. Default 1. */
30
+ scale?: number;
31
+ className?: string;
32
+ style?: CSSProperties;
33
+ };
34
+ export declare function Body({ data, side, view, colors, theme, tooltip, labels, activePart, hiddenParts, onBodyPartPress, onBodyPartHover, scale, strokeWidth, className, style, ...overrides }: BodyProps): import("react").JSX.Element;
package/dist/react.js ADDED
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { BODY_OUTLINE, BODY_PARTS, BODY_VIEWS, BODY_WIDTH, DEFAULT_COLORS, describePart, partAnchor, partInView, resolveTheme, tooltipDetail, viewBoxOf, } from "./index.js";
4
+ const HALVES = ["left", "right"];
5
+ export function Body({ data, side = "front", view = "full", colors = DEFAULT_COLORS, theme = "dark", tooltip = true, labels, activePart, hiddenParts = [], onBodyPartPress, onBodyPartHover, scale = 1, strokeWidth = 0.5, className, style, ...overrides }) {
6
+ const t = resolveTheme(theme, overrides);
7
+ const crop = BODY_VIEWS[view];
8
+ const [hovered, setHovered] = useState(null);
9
+ const [pinned, setPinned] = useState(null);
10
+ const shown = hovered ?? pinned;
11
+ const active = activePart === undefined ? shown?.slug : activePart;
12
+ const hover = (next) => {
13
+ setHovered(next);
14
+ onBodyPartHover?.(next?.slug ?? null);
15
+ };
16
+ const press = (slug, half) => {
17
+ setPinned((current) => (current?.slug === slug && current.half === half ? null : { slug, half }));
18
+ onBodyPartPress?.(slug, half);
19
+ };
20
+ const info = shown ? describePart(data, shown.slug, shown.half, colors, t.fill, labels) : null;
21
+ const anchor = shown ? partAnchor(side, shown.slug, shown.half) : null;
22
+ return (_jsxs("div", { className: className, style: { position: "relative", display: "inline-block", ...style }, children: [_jsxs("svg", { viewBox: viewBoxOf(view), width: BODY_WIDTH * scale, height: crop.height * scale, role: "group", "aria-label": side === "front" ? "Body, front" : "Body, back", style: { display: "block", width: "100%", height: "auto" }, children: [t.border !== "none" ? BODY_OUTLINE.map((d) => _jsx("path", { d: d, fill: "none", stroke: t.border, strokeWidth: 2 }, `b${d}`)) : null, BODY_OUTLINE.map((d) => (_jsx("path", { d: d, fill: t.outline, onClick: () => setPinned(null) }, d))), BODY_PARTS[side]
23
+ .filter((part) => !hiddenParts.includes(part.slug) && partInView(side, part.slug, view))
24
+ .map(({ slug, path }) => {
25
+ const isActive = active === slug;
26
+ const firstHalf = path.left?.length ? "left" : "right";
27
+ return (_jsx("g", { role: "button", tabIndex: 0, "aria-label": describePart(data, slug, firstHalf, colors, t.fill, labels).label, "aria-pressed": isActive, stroke: isActive ? t.activeStroke : t.stroke, strokeWidth: isActive ? strokeWidth * 2.4 : strokeWidth, style: { cursor: "pointer", outline: "none" }, onFocus: () => hover({ slug, half: firstHalf }), onBlur: () => hover(null), onKeyDown: (event) => {
28
+ if (event.key !== "Enter" && event.key !== " ")
29
+ return;
30
+ event.preventDefault();
31
+ press(slug, firstHalf);
32
+ }, children: HALVES.flatMap((half) => (path[half] ?? []).map((d) => (_jsx("path", { d: d, fill: describePart(data, slug, half, colors, t.fill, labels).color,
33
+ // Touch fires enter/leave around every tap, so only a mouse hovers; a tap pins instead.
34
+ onPointerEnter: (event) => event.pointerType === "mouse" && hover({ slug, half }), onPointerLeave: (event) => event.pointerType === "mouse" && hover(null), onClick: () => press(slug, half) }, d)))) }, slug));
35
+ })] }), tooltip && info && anchor ? (_jsx("div", { role: "tooltip", style: {
36
+ position: "absolute",
37
+ left: `${(anchor.x / BODY_WIDTH) * 100}%`,
38
+ top: `${((anchor.y - crop.y) / crop.height) * 100}%`,
39
+ transform: "translate(-50%, calc(-100% - 6px))",
40
+ pointerEvents: "none",
41
+ whiteSpace: "nowrap",
42
+ zIndex: 1,
43
+ }, children: typeof tooltip === "function" ? tooltip(info) : _jsx(DefaultTooltip, { info: info, theme: t }) })) : null] }));
44
+ }
45
+ function DefaultTooltip({ info, theme }) {
46
+ return (_jsxs("div", { style: {
47
+ display: "flex",
48
+ alignItems: "center",
49
+ gap: 6,
50
+ padding: "5px 9px",
51
+ borderRadius: 8,
52
+ background: theme.tooltipBackground,
53
+ color: theme.tooltipText,
54
+ boxShadow: "0 2px 10px rgba(0,0,0,.25)",
55
+ font: "500 12px/1.3 system-ui, sans-serif",
56
+ }, children: [_jsx("span", { "aria-hidden": true, style: { width: 10, height: 10, borderRadius: 3, background: info.color, flexShrink: 0 } }), _jsx("span", { children: info.label }), _jsx("span", { style: { color: theme.tooltipMuted, fontVariantNumeric: "tabular-nums" }, children: tooltipDetail(info) })] }));
57
+ }
@@ -0,0 +1,6 @@
1
+ import { type BodyPart, type BodySide } from "./core.js";
2
+ export declare const BODY_FRONT: BodyPart[];
3
+ export declare const BODY_BACK: BodyPart[];
4
+ export declare const BODY_PARTS: Record<BodySide, BodyPart[]>;
5
+ /** Neutral silhouette (head, neck, hands, feet, knees show through); the same for both views. */
6
+ export declare const BODY_OUTLINE: string[];
package/dist/shapes.js ADDED
@@ -0,0 +1,116 @@
1
+ import { BODY_WIDTH } from "./core.js";
2
+ const round = (n) => Math.round(n * 10) / 10;
3
+ /** Closed Catmull-Rom spline through x,y pairs; repeating a pair makes a sharp corner. */
4
+ function smooth(p) {
5
+ const n = p.length / 2;
6
+ const at = (i) => {
7
+ const k = ((i % n) + n) % n;
8
+ return [p[k * 2], p[k * 2 + 1]];
9
+ };
10
+ let d = `M${p[0]},${p[1]}`;
11
+ for (let i = 0; i < n; i++) {
12
+ const [p0, p1, p2, p3] = [at(i - 1), at(i), at(i + 1), at(i + 2)];
13
+ const c = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6, p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];
14
+ d += `C${c.map(round).join(",")},${p2[0]},${p2[1]}`;
15
+ }
16
+ return `${d}Z`;
17
+ }
18
+ const mirror = (p) => p.map((v, i) => (i % 2 ? v : round(BODY_WIDTH - v)));
19
+ // The shapes were drawn on a narrower figure; widening about the centre line gives athletic proportions.
20
+ const widen = (p) => p.map((v, i) => (i % 2 ? v : round(100 + (v - 100) * 1.2)));
21
+ const draw = (p) => smooth(widen(p));
22
+ /** Half outline (centre line down the outside and back) → one symmetric shape. */
23
+ function symmetric(half) {
24
+ const pairs = [];
25
+ for (let i = 0; i < half.length; i += 2)
26
+ pairs.push([half[i], half[i + 1]]);
27
+ return [...half, ...pairs.reverse().flatMap(([x, y]) => [BODY_WIDTH - x, y])];
28
+ }
29
+ // Every shape is drawn once at x > 100 and mirrored. Front: that half is the body's left; back: its right.
30
+ const FRONT = {
31
+ trapezius: [[109.5, 59, 112.5, 66.5, 125, 71, 136, 74.5, 122, 75.5, 109.5, 73]],
32
+ "anterior-deltoid": [[136, 79, 145, 78, 147, 90, 146.4, 102, 143.5, 112, 139.8, 102, 136.6, 91]],
33
+ "lateral-deltoid": [[147.6, 78.6, 152.5, 82.5, 155, 94, 154, 106, 149.4, 114, 148.6, 102, 149, 90]],
34
+ "upper-chest": [[102, 80.5, 102, 80.5, 118, 79.2, 133, 79.6, 134.4, 89, 131.5, 95, 119, 89.5, 102, 88, 102, 88]],
35
+ "middle-chest": [[102, 90.5, 102, 90.5, 118.5, 92, 130.5, 97.5, 136.5, 103.5, 131, 106, 118, 104, 102, 103.5, 102, 103.5]],
36
+ "lower-chest": [[102, 106, 102, 106, 117, 106.5, 130, 108.5, 135, 107, 131, 113.5, 122, 118, 110, 118, 102, 115.5, 102, 115.5]],
37
+ "serratus-anterior": [
38
+ [125.5, 118.5, 131.5, 115.5, 132.5, 120, 127, 123],
39
+ [125, 125.5, 132, 123, 132, 128, 126.5, 130.5],
40
+ [125, 133, 131, 131, 130.5, 136, 126, 138],
41
+ ],
42
+ "latissimus-dorsi": [[134.5, 110, 136.3, 116, 134.8, 129, 132.3, 141, 133.2, 128, 134.2, 118]],
43
+ "rectus-abdominis": [
44
+ [102, 122, 113, 121, 115, 125, 115, 132, 102, 132.5],
45
+ [102, 135.5, 115, 135, 115.5, 146, 102, 146.5],
46
+ [102, 149.5, 115.5, 149, 115, 160.5, 102, 161],
47
+ [102, 164, 115, 163.5, 114, 179, 109, 195, 102, 203.5],
48
+ ],
49
+ obliques: [[118, 123, 123.5, 125.5, 123.5, 139, 130.5, 141.5, 130, 152, 130, 161, 131, 173, 133, 186, 124, 195, 112, 204.5, 111, 197, 116.5, 180, 117.8, 160, 117.8, 140]],
50
+ "hip-flexors": [[127.5, 197.5, 119, 203.5, 110.5, 209, 112.5, 218, 117, 228, 122, 215, 127.5, 205]],
51
+ abductors: [[133.5, 190.5, 136, 202, 136.5, 216, 134.5, 232, 131.8, 220, 129.8, 207, 130.2, 196]],
52
+ adductors: [[103, 216, 108.5, 212.5, 110.5, 221, 115.5, 232, 113.5, 246, 108.5, 252, 105.2, 262, 103.6, 246, 102.7, 230]],
53
+ quadriceps: [
54
+ [126, 210, 128.4, 225, 127.2, 250, 123.8, 275, 121, 292, 116.8, 292, 114.8, 272, 116.2, 250, 120, 230, 123.5, 215],
55
+ [131.2, 224, 134.8, 237, 135.6, 256, 133.5, 276, 130, 292, 125.5, 299, 123.6, 292, 126.4, 276, 129.2, 252, 130.6, 236],
56
+ [110.8, 255, 113, 270, 115, 288, 115, 299, 110.5, 302.5, 107.8, 292, 107.3, 276, 108.4, 263],
57
+ ],
58
+ "tibialis-anterior": [[121.5, 316, 127, 329, 127.4, 350, 123.5, 372, 120.2, 386, 118.6, 370, 118.6, 346, 119.2, 326]],
59
+ calves: [
60
+ [111, 318, 115, 325, 116.2, 345, 114.6, 366, 112.6, 379, 110.6, 360, 110, 338],
61
+ [129.3, 319, 131.6, 332, 130.6, 352, 127.4, 374, 129, 351, 129.6, 334],
62
+ ],
63
+ biceps: [[140.6, 113, 146, 115.5, 149, 126, 150, 138, 148.5, 148, 144.5, 150, 142, 140, 140.4, 126]],
64
+ brachialis: [[150.8, 119, 153.6, 128, 155.6, 145, 152.3, 149.5, 151.6, 138, 150.8, 128]],
65
+ brachioradialis: [[154, 152, 158.6, 152.6, 160.8, 165, 162.4, 180, 162.8, 192, 160.3, 196, 158.2, 182, 155.6, 166]],
66
+ forearms: [[144.6, 152.6, 151.6, 153, 153.6, 166, 156, 183, 158.5, 198.5, 163, 199, 163.8, 209, 156, 210.5, 151.5, 192, 147.3, 170]],
67
+ };
68
+ const BACK = {
69
+ trapezius: [[101.3, 53, 101.3, 53, 107, 55.5, 110.5, 64, 120, 70, 139, 76, 131, 79.8, 121, 84, 111, 92, 106.5, 108, 103.6, 128, 101.3, 142, 101.3, 142]],
70
+ "posterior-deltoid": [[127.5, 87.5, 133.5, 83, 140, 79.5, 145.5, 79.3, 146.5, 90, 146, 102, 143.5, 112, 139, 104.5, 134, 96]],
71
+ "lateral-deltoid": [[147.6, 78.6, 152.5, 82.5, 155, 94, 154, 106, 149.4, 114, 148.6, 102, 149, 90]],
72
+ rhomboids: [[113.2, 94, 116.8, 97.5, 117.6, 110, 114, 118, 109.3, 112, 110, 101]],
73
+ "rotator-cuff": [[119.8, 90.5, 126, 91, 132.5, 98.5, 137.3, 106, 134.5, 111.5, 127, 114, 120.2, 111, 119.3, 100]],
74
+ "latissimus-dorsi": [[110.5, 121, 118, 116.5, 127, 117.5, 135, 114, 134.6, 123, 131.6, 139, 127.6, 153, 122, 162, 114.5, 156.5, 107.3, 147, 105.8, 133]],
75
+ "lower-back": [[101.5, 146.5, 101.5, 146.5, 106, 150.5, 111.5, 160.5, 114, 172, 113.2, 185, 108.5, 192, 101.5, 195, 101.5, 195]],
76
+ obliques: [[117.5, 165.5, 125, 162.5, 128.6, 168, 130.6, 178, 127.2, 184, 119, 181.5, 116.6, 174]],
77
+ "gluteus-medius": [[117.6, 187, 127, 186.6, 132.6, 192, 135, 204, 130.5, 205.2, 123.5, 199.6, 118, 194]],
78
+ "gluteus-maximus": [[102, 199, 110, 196.2, 120, 202, 129, 208.6, 134, 217.5, 132, 230, 124, 238, 112, 238.5, 103.6, 232, 101.8, 215]],
79
+ hamstrings: [
80
+ [121.5, 242.5, 130, 241.5, 133.5, 255, 132.5, 275, 129, 292, 126, 300.5, 122.8, 290, 121.4, 270, 121, 255],
81
+ [109.2, 243, 118.8, 243, 118.6, 256, 119, 272, 119.4, 288, 114.5, 300.5, 111, 290, 109, 272, 108.4, 256],
82
+ ],
83
+ adductors: [[103.5, 238, 106.8, 242, 106.2, 256, 107, 273, 105.6, 270, 103.8, 254]],
84
+ calves: [
85
+ [111.2, 312.5, 118.6, 313.5, 119.2, 330, 118.6, 345, 115.6, 352.5, 111.6, 346, 110.2, 330],
86
+ [121.2, 313.5, 128, 312.5, 130, 328, 129, 343, 125, 350.5, 121.6, 346, 121.2, 330],
87
+ [112.2, 354.5, 120.2, 358.5, 128.3, 352.5, 127.3, 367, 123, 386, 117.2, 386, 112.8, 371],
88
+ ],
89
+ triceps: [
90
+ [139.6, 110.5, 143.6, 114, 146, 125, 146.6, 138, 145, 146.5, 142.5, 140, 140.6, 126],
91
+ [148.6, 116.5, 153, 114.5, 154.6, 126, 155.2, 138, 152.2, 146.5, 148.8, 140, 148.2, 127],
92
+ ],
93
+ brachioradialis: [[156.6, 150.5, 159.2, 153.5, 161.6, 165, 162.8, 178, 160.8, 185, 159.2, 172, 157.2, 160]],
94
+ forearms: [[144.6, 153, 154, 152.2, 156, 163, 157.8, 176, 159.6, 188.5, 163, 196.5, 163.8, 209, 156, 210.5, 151.5, 192, 147.3, 170]],
95
+ };
96
+ function parts(shapes, drawn) {
97
+ const other = drawn === "left" ? "right" : "left";
98
+ return Object.entries(shapes).map(([slug, list]) => ({
99
+ slug,
100
+ path: { [drawn]: list.map(draw), [other]: list.map((s) => draw(mirror(s))) },
101
+ }));
102
+ }
103
+ export const BODY_FRONT = parts(FRONT, "left");
104
+ export const BODY_BACK = parts(BACK, "right");
105
+ export const BODY_PARTS = { front: BODY_FRONT, back: BODY_BACK };
106
+ const ARM = [140, 76, 148, 78, 154.5, 88, 155.5, 106, 156.5, 126, 158, 150, 163, 165, 165, 185, 166, 212, 155, 214, 149.5, 190, 145, 168, 142.5, 150, 138.5, 128, 136.5, 106, 134, 90];
107
+ const HAND = [155, 212, 166, 211, 170, 222, 170, 236, 166.5, 247, 161, 248.5, 156.5, 239, 154, 226];
108
+ const LEG = [134, 192, 138, 225, 137.5, 256, 134, 285, 130.5, 308, 132.5, 335, 130.5, 360, 124, 396, 113, 396, 109.5, 360, 108.5, 335, 109.5, 310, 105.5, 280, 101.5, 245, 100.8, 216];
109
+ const FOOT = [112.5, 393, 124.5, 393, 127.5, 405, 128.5, 412.5, 118.5, 415, 109.5, 413, 110.5, 403];
110
+ /** Neutral silhouette (head, neck, hands, feet, knees show through); the same for both views. */
111
+ export const BODY_OUTLINE = [
112
+ draw(symmetric([100, 8, 111, 11.5, 116.5, 24, 115.5, 40, 109, 54, 100, 58.5])),
113
+ draw(symmetric([100, 46, 109, 48, 110, 64, 116, 72, 100, 76])),
114
+ draw(symmetric([100, 62, 109, 62, 113, 68, 128, 73, 142, 79, 140, 95, 137.5, 108, 134.5, 128, 132, 146, 131.5, 160, 133, 176, 135, 192, 135, 208, 118, 214, 100, 217])),
115
+ ...[ARM, HAND, LEG, FOOT].flatMap((s) => [draw(s), draw(mirror(s))]),
116
+ ];
package/package.json CHANGED
@@ -1,6 +1,88 @@
1
1
  {
2
2
  "name": "muscle-body-map",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Interactive map of the human body's muscles for React and React Native. Color muscles by how hard they work, with tooltips that show the name and the effort.",
5
+ "keywords": [
6
+ "muscle",
7
+ "muscles",
8
+ "body",
9
+ "body map",
10
+ "anatomy",
11
+ "fitness",
12
+ "workout",
13
+ "exercise",
14
+ "heatmap",
15
+ "svg",
16
+ "react",
17
+ "react-native",
18
+ "expo"
19
+ ],
20
+ "license": "MIT",
21
+ "author": "Jaseb Meza",
22
+ "homepage": "https://hawkbt.github.io/muscle-body-map/",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/hawkbt/muscle-body-map.git"
26
+ },
27
+ "bugs": "https://github.com/hawkbt/muscle-body-map/issues",
28
+ "type": "module",
29
+ "sideEffects": false,
30
+ "packageManager": "pnpm@12.23.0",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./react": {
37
+ "types": "./dist/react.d.ts",
38
+ "default": "./dist/react.js"
39
+ },
40
+ "./native": {
41
+ "types": "./dist/native.d.ts",
42
+ "default": "./dist/native.js"
43
+ },
44
+ "./package.json": "./package.json"
45
+ },
46
+ "main": "./dist/index.js",
47
+ "types": "./dist/index.d.ts",
48
+ "files": [
49
+ "dist"
50
+ ],
51
+ "scripts": {
52
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
53
+ "test": "node --import tsx --test \"src/**/*.test.ts\" \"src/**/*.test.tsx\"",
54
+ "typecheck": "tsc --noEmit",
55
+ "demo": "vite examples/web",
56
+ "demo:build": "vite build examples/web",
57
+ "prepublishOnly": "pnpm typecheck && pnpm test && pnpm build"
58
+ },
59
+ "peerDependencies": {
60
+ "react": ">=18",
61
+ "react-native": ">=0.72",
62
+ "react-native-svg": ">=13"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "react": {
66
+ "optional": true
67
+ },
68
+ "react-native": {
69
+ "optional": true
70
+ },
71
+ "react-native-svg": {
72
+ "optional": true
73
+ }
74
+ },
75
+ "devDependencies": {
76
+ "@types/node": "^24.19.4",
77
+ "@types/react": "^19.3.3",
78
+ "@types/react-dom": "^19.3.0",
79
+ "@vitejs/plugin-react": "^6.3.0",
80
+ "react": ">=18",
81
+ "react-dom": "^19.3.1",
82
+ "react-native": ">=0.72",
83
+ "react-native-svg": ">=13",
84
+ "tsx": "^4.23.15",
85
+ "typescript": "5.9.3",
86
+ "vite": "^8.4.0"
87
+ }
88
+ }