@esmirnov.ai/sperm-lab 0.0.0-stage → 0.4.2

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.
@@ -0,0 +1,211 @@
1
+ .sl-lab {
2
+ --sl-surface: #dfe5dc;
3
+ --sl-ink: #303832;
4
+ --sl-accent: #785448;
5
+ --sl-paper: #eff2ed;
6
+ --sl-rule: color-mix(in oklch, var(--sl-ink) 22%, transparent);
7
+ --sl-track: color-mix(in oklch, var(--sl-ink) 28%, var(--sl-surface));
8
+ --sl-sage: #6f897c;
9
+ --sl-clay: #a67769;
10
+ --sl-damage: #b82735;
11
+ container: sperm-lab / inline-size;
12
+ width: 100%; min-width: 0; color: var(--sl-ink);
13
+ font: 14px/1.55 Arial, Helvetica, sans-serif; color-scheme: light;
14
+ }
15
+ .sl-lab, .sl-lab * { box-sizing: border-box; }
16
+ .sl-lab :is(button, input, select) { color: inherit; font: inherit; }
17
+ .sl-lab :is(button, input, canvas, a, summary):focus-visible { outline: 2px solid var(--sl-accent); outline-offset: 3px; }
18
+ .sl-lab button { min-height: 44px; padding: 8px 10px; border: 1px solid var(--sl-rule); border-radius: 4px; background: transparent; cursor: pointer; font-size: 12px; }
19
+ .sl-lab button:hover { background: color-mix(in oklch, var(--sl-ink) 6%, transparent); }
20
+ .sl-lab button:disabled { opacity: .4; cursor: default; }
21
+ .sl-lab p { max-width: 72ch; }
22
+ .sl-lab h2, .sl-lab h3 { color: inherit; letter-spacing: normal; }
23
+ .sl-intro-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 20px; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--sl-rule); }
24
+ .sl-intro-line p { margin: 0; font-size: 13px; }
25
+ .sl-intro-line strong { font-weight: 600; }
26
+ .sl-intro-line > span { font-size: 11px; opacity: .75; }
27
+ .sl-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); grid-template-areas: "left field right" "left readouts right" "catalog catalog catalog" "inspector inspector inspector"; align-items: start; gap: 20px 24px; }
28
+ .sl-controls { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
29
+ .sl-controls-left { grid-area: left; }
30
+ .sl-controls-right { grid-area: right; }
31
+ .sl-factor-group { min-width: 0; border: 0; padding: 0; margin: 0; }
32
+ .sl-factor-group + .sl-factor-group { padding-top: 16px; border-top: 1px solid var(--sl-rule); }
33
+ .sl-factor-group legend { width: 100%; padding: 0; margin-bottom: 8px; font-size: 13px; line-height: 1.5; font-weight: 600; }
34
+ .sl-factor + .sl-factor { margin-top: 12px; }
35
+ .sl-factor-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; }
36
+ .sl-factor-row label { grid-column: 1; grid-row: 1; font-size: 13px; line-height: 18px; overflow-wrap: normal; }
37
+ .sl-factor-row input[type="range"] { grid-column: 1 / -1; grid-row: 2; appearance: none; -webkit-appearance: none; display: block; width: 100%; min-width: 0; height: 44px; padding: 0; margin: 0; border: 0; background: transparent; accent-color: var(--sl-accent); cursor: pointer; }
38
+ .sl-factor-row input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: linear-gradient(to right, var(--sl-accent) 0 var(--sl-progress), var(--sl-track) var(--sl-progress) 100%); }
39
+ .sl-factor-row input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: var(--sl-track); }
40
+ .sl-factor-row input[type="range"]::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--sl-accent); }
41
+ .sl-factor-row input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin-top: -6px; border: 0; border-radius: 50%; background: var(--sl-accent); }
42
+ .sl-factor-row input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--sl-accent); }
43
+ .sl-factor-row output { grid-column: 2; grid-row: 1; font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; text-align: right; opacity: .8; }
44
+ .sl-factor-help { min-width: 0; }
45
+ .sl-factor-help summary { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 26px; width: 100%; cursor: pointer; font-size: 10px; color: var(--sl-accent); list-style: none; }
46
+ .sl-factor-help summary::-webkit-details-marker { display: none; }
47
+ .sl-factor-help summary span { text-decoration: underline; text-underline-offset: 3px; }
48
+ .sl-factor-help summary svg { width: 14px; height: 14px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.3; }
49
+ .sl-factor-help[open] summary svg { transform: rotate(180deg); }
50
+ .sl-factor-help p { margin: 7px 0 0; font-size: 11px; line-height: 1.6; }
51
+ .sl-factor-help .sl-evidence { color: var(--sl-accent); font-family: "Courier New", Courier, monospace; font-size: 10px; }
52
+ .sl-help-timescale { opacity: .8; }
53
+ .sl-factor-help ul { margin: 8px 0 0; padding: 0; list-style: none; }
54
+ .sl-factor-help a { display: inline-flex; align-items: center; min-height: 32px; font-size: 10px; line-height: 1.5; color: var(--sl-accent); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
55
+ .sl-field { grid-area: field; min-width: 0; }
56
+ .sl-sample-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; padding-bottom: 9px; border-bottom: 1px solid var(--sl-rule); }
57
+ .sl-sample-bar > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
58
+ .sl-sample-bar h2 { margin: 0; font-size: 14px; line-height: 1.5; font-weight: 600; }
59
+ .sl-sample-bar span { font-size: 10px; opacity: .75; }
60
+ .sl-concentration { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 9px; margin-top: 10px; }
61
+ .sl-concentration > span { font-size: 11px; }
62
+ .sl-concentration output { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
63
+ .sl-concentration small { flex-basis: 100%; font-size: 10px; line-height: 1.5; opacity: .75; }
64
+ .sl-teaching-population { margin: 7px 0 0; font-size: 10px; line-height: 1.6; opacity: .8; }
65
+ .sl-actions { display: flex; gap: 4px; }
66
+ .sl-actions button { border: 0; padding-inline: 8px; }
67
+ .sl-actions .sl-explore { border: 1px solid var(--sl-rule); }
68
+ .sl-actions .sl-explore[aria-pressed="true"] { color: var(--sl-accent); background: color-mix(in oklch, var(--sl-clay) 14%, transparent); }
69
+ .sl-canvas-wrap { position: relative; width: 100%; aspect-ratio: 1.35; min-height: 300px; max-height: 480px; }
70
+ .sl-canvas-wrap canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: pan-y pinch-zoom; }
71
+ .sl-canvas-wrap canvas:active { cursor: grabbing; }
72
+ .sl-canvas-wrap canvas:focus-visible { outline-offset: -4px; }
73
+ .sl-canvas-wrap[data-popup="true"] { min-height: max(300px, var(--sl-popup-min-height, 0px)); max-height: none; }
74
+ .sl-popup-connector { position: absolute; inset: 0; z-index: 2; display: block; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
75
+ .sl-popup-connector line { stroke: var(--sl-accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .65; }
76
+ .sl-cell-popup { position: absolute; top: 0; left: 0; z-index: 3; width: 260px; max-width: calc(100% - 16px); padding: 0 12px 8px; border: 1px solid var(--sl-rule); border-radius: 4px; background: var(--sl-paper); color: var(--sl-ink); visibility: hidden; }
77
+ .sl-cell-popup > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
78
+ .sl-cell-popup h3 { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.4; }
79
+ .sl-cell-popup .sl-popup-close { display: grid; place-items: center; min-width: 44px; min-height: 44px; margin-right: -8px; padding: 8px; border: 0; }
80
+ .sl-popup-close svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
81
+ .sl-popup-details dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0; }
82
+ .sl-popup-details dt { font-size: 9px; line-height: 1.4; opacity: .75; }
83
+ .sl-popup-details dd { margin: 2px 0 0; font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
84
+ .sl-popup-traits { display: grid; gap: 8px; padding: 10px 0 0; margin: 10px 0 0; border-top: 1px solid var(--sl-rule); list-style: none; }
85
+ .sl-popup-traits strong, .sl-popup-traits span { display: block; }
86
+ .sl-popup-traits strong { font-size: 10px; font-weight: 600; line-height: 1.4; }
87
+ .sl-popup-traits span { margin-top: 2px; font-size: 10px; line-height: 1.5; }
88
+ .sl-popup-healthy { margin: 12px 0 0; font-size: 11px; line-height: 1.5; }
89
+ .sl-cell-popup .sl-popup-anatomy { min-height: 44px; margin-top: 7px; padding: 7px 0; border: 0; color: var(--sl-accent); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
90
+ .sl-canvas-help { margin: 6px 0 0; font-size: 11px; line-height: 1.6; }
91
+ .sl-sample-tools { display: flex; flex-wrap: wrap; gap: 5px 7px; margin-top: 10px; }
92
+ .sl-sample-tools button { flex: 1 1 auto; padding-inline: 8px; font-size: 11px; }
93
+ .sl-display { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 7px; }
94
+ .sl-display label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 11px; cursor: pointer; }
95
+ .sl-display input { width: 15px; height: 15px; margin: 0; accent-color: var(--sl-accent); }
96
+ .sl-overlay-note, .sl-model-note { margin: 2px 0 0; font-size: 10px; line-height: 1.6; opacity: .8; }
97
+ .sl-readouts { grid-area: readouts; min-width: 0; padding-top: 16px; border-top: 1px solid var(--sl-rule); }
98
+ .sl-readouts h2, .sl-inspector h2, .sl-mechanisms h2 { margin: 0; font-size: 14px; line-height: 1.5; font-weight: 600; }
99
+ .sl-readouts dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 10px 0 0; }
100
+ .sl-readouts dt { font-size: 10px; opacity: .75; overflow-wrap: anywhere; }
101
+ .sl-readouts dd { margin: 3px 0 0; font-size: 14px; font-variant-numeric: tabular-nums; }
102
+ .sl-readouts h3 { margin: 17px 0 0; font-size: 12px; line-height: 1.5; font-weight: 600; }
103
+ .sl-legend-help { margin: 5px 0 0; font-size: 10px; opacity: .8; }
104
+ .sl-catalog { grid-area: catalog; min-width: 0; padding-top: 17px; border-top: 1px solid var(--sl-rule); }
105
+ .sl-catalog h2 { margin: 0; font-size: 14px; line-height: 1.5; font-weight: 600; }
106
+ .sl-catalog header > p { margin: 7px 0 0; font-size: 11px; line-height: 1.6; }
107
+ .sl-defect-catalog { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 24px; margin-top: 12px; }
108
+ .sl-defect-catalog button { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 82px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--sl-rule); border-radius: 0; text-align: left; }
109
+ .sl-specimen-thumbnail { flex: 0 0 96px; width: 96px; height: 42px; overflow: visible; }
110
+ .sl-specimen-thumbnail :is(path, ellipse) { vector-effect: non-scaling-stroke; }
111
+ .sl-specimen-thumbnail .sl-anatomy-tail { stroke-width: .85; }
112
+ .sl-specimen-thumbnail .sl-anatomy-head { stroke-width: .8; }
113
+ .sl-specimen-thumbnail .sl-anatomy-midpiece-smooth { stroke-width: 1.1; }
114
+ .sl-specimen-thumbnail .sl-anatomy-midpiece-injury { stroke-width: 1.2; }
115
+ .sl-specimen-thumbnail .sl-anatomy-fork path { stroke-width: .85; }
116
+ .sl-specimen-thumbnail .sl-chromatin-fragments { stroke-width: .85; }
117
+ .sl-defect-catalog [data-defect="thick-midpiece"] .sl-anatomy-midpiece-smooth { stroke-width: 2; }
118
+ .sl-dna-thumbnail .sl-chromatin-fragments { stroke-width: 1.2; }
119
+ .sl-catalog-copy { min-width: 0; flex: 1; }
120
+ .sl-catalog-copy strong { display: block; font-size: 12px; font-weight: 600; line-height: 1.45; }
121
+ .sl-catalog-copy > span { display: block; margin-top: 4px; font-size: 10px; line-height: 1.5; opacity: .8; }
122
+ .sl-defect-catalog button > b { align-self: start; margin-top: 2px; font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 400; }
123
+ .sl-defect-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 8px; margin-top: 8px; }
124
+ .sl-defect-legend button { display: flex; align-items: center; gap: 5px; border: 0; border-bottom: 1px solid var(--sl-rule); border-radius: 0; padding: 7px 0; text-align: left; font-size: 10px; }
125
+ .sl-defect-legend svg { flex-shrink: 0; width: 25px; height: 22px; fill: none; stroke: var(--sl-clay); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
126
+ .sl-defect-legend b { margin-left: auto; font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; }
127
+ .sl-inspector { grid-area: inspector; min-width: 0; padding-top: 18px; border-top: 1px solid var(--sl-rule); }
128
+ .sl-inspector > header { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
129
+ .sl-inspector > header p { margin: 0; font-size: 12px; opacity: .8; }
130
+ .sl-inspector-content { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: center; margin-top: 10px; }
131
+ .sl-anatomy { display: block; width: 100%; max-width: 650px; color: var(--sl-ink); overflow: visible; }
132
+ .sl-anatomy text { fill: currentColor; font: 12px Arial, Helvetica, sans-serif; }
133
+ .sl-anatomy .sl-diagram-caption { font-size: 9px; opacity: .7; }
134
+ .sl-anatomy-lines { fill: none; stroke: var(--sl-rule); stroke-width: 1; }
135
+ .sl-anatomy-tail { fill: none; stroke: var(--sl-ink); stroke-width: 1.6; stroke-linecap: round; }
136
+ .sl-anatomy-head { fill: var(--sl-paper); stroke: var(--sl-ink); stroke-width: 2; }
137
+ .sl-anatomy-fork { fill: none; stroke: var(--sl-sage); stroke-width: 3; }
138
+ .sl-anatomy-midpiece-smooth { fill: none; stroke: var(--sl-sage); stroke-linecap: round; }
139
+ .sl-anatomy-midpiece-injury { fill: none; stroke: var(--sl-damage); stroke-width: 6.5; stroke-linecap: round; }
140
+ .sl-acrosomal-cap { fill: var(--sl-sage); opacity: .12; }
141
+ .sl-compact-nucleus { fill: var(--sl-ink); }
142
+ .sl-nucleus-mass { opacity: .22; }
143
+ .sl-chromatin-speck { opacity: .35; }
144
+ .sl-chromatin-fragments { fill: none; stroke: var(--sl-damage); stroke-width: 1.8; stroke-linecap: round; }
145
+ .sl-anatomy-midpiece { fill: var(--sl-sage); }
146
+ .sl-anatomy-midpiece-outline { fill: none; stroke: var(--sl-sage); stroke-width: 1.3; }
147
+ .sl-anatomy-damaged-midpiece { fill: none; stroke: var(--sl-clay); stroke-width: 2; stroke-linecap: round; }
148
+ .sl-mitochondria { fill: none; stroke: var(--sl-paper); stroke-width: 1.2; }
149
+ .sl-anatomy-dna { fill: none; stroke: var(--sl-ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
150
+ .sl-anatomy-rung { stroke-width: 1.1; opacity: .8; }
151
+ .sl-anatomy-dna-damaged { stroke: var(--sl-clay); }
152
+ .sl-dna-break { fill: none; stroke: var(--sl-clay); stroke-width: 2.5; }
153
+ .sl-lab .sl-trait-damage { stroke: var(--sl-damage); }
154
+ .sl-cell-facts dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
155
+ .sl-cell-facts dt { font-size: 10px; opacity: .75; }
156
+ .sl-cell-facts dd { margin: 3px 0 0; font-size: 12px; }
157
+ .sl-cell-facts p { margin: 12px 0 0; font-size: 12px; line-height: 1.65; }
158
+ .sl-anatomy-sources { margin: 8px 0 0; font-size: 10px; line-height: 1.6; opacity: .8; }
159
+ .sl-anatomy-sources a { display: inline-flex; align-items: center; min-height: 44px; color: var(--sl-accent); text-decoration: underline; text-underline-offset: 3px; }
160
+ .sl-status { min-height: 1.7em; margin: 20px 0 0; color: var(--sl-accent); font-size: 12px; }
161
+ .sl-mechanisms { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--sl-rule); }
162
+ .sl-mechanisms > p { margin: 10px 0 0; font-size: 12px; line-height: 1.7; }
163
+ .sl-mechanisms > ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 32px; margin: 15px 0 0; padding: 0; list-style: none; }
164
+ .sl-mechanisms li { font-size: 12px; line-height: 1.65; }
165
+ .sl-mechanisms li strong, .sl-mechanisms li span, .sl-mechanisms li small { display: block; }
166
+ .sl-mechanisms li strong { font-size: 12px; font-weight: 600; }
167
+ .sl-mechanisms li span { margin-top: 4px; }
168
+ .sl-mechanisms li small { margin-top: 5px; color: var(--sl-accent); font-size: 10px; }
169
+ .sl-prepared-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--sl-rule); }
170
+ .sl-prepared-note p { margin: 0; font-size: 11px; }
171
+ .sl-prepared-note button { margin-top: 3px; padding-inline: 0; border: 0; text-decoration: underline; text-underline-offset: 3px; }
172
+ @container sperm-lab (max-width: 1000px) {
173
+ .sl-workbench { grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); gap: 18px 18px; }
174
+ .sl-canvas-wrap { min-height: 280px; }
175
+ .sl-defect-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
176
+ }
177
+ @container sperm-lab (max-width: 800px) {
178
+ .sl-workbench { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "field field" "readouts readouts" "catalog catalog" "inspector inspector" "left right"; gap: 22px; }
179
+ .sl-defect-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
180
+ .sl-controls { padding-top: 18px; border-top: 1px solid var(--sl-rule); }
181
+ .sl-factor-row input[type="range"] { min-height: 44px; }
182
+ .sl-factor-help summary { min-height: 36px; }
183
+ .sl-canvas-wrap { min-height: 300px; max-height: 450px; aspect-ratio: 1.6; }
184
+ .sl-defect-legend { grid-template-columns: repeat(3, minmax(0, 1fr)); }
185
+ .sl-inspector-content { gap: 18px; }
186
+ }
187
+ @container sperm-lab (max-width: 560px) {
188
+ .sl-workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "field" "readouts" "catalog" "inspector" "left" "right"; }
189
+ .sl-defect-catalog { grid-template-columns: minmax(0, 1fr); }
190
+ .sl-canvas-wrap { min-height: 270px; max-height: 360px; aspect-ratio: 1.15; }
191
+ .sl-factor-help summary { min-height: 38px; font-size: 11px; }
192
+ .sl-factor-help p, .sl-factor-help a { font-size: 12px; }
193
+ .sl-factor-help a { min-height: 44px; }
194
+ .sl-display { gap: 4px 14px; }
195
+ .sl-display label { min-height: 44px; }
196
+ .sl-defect-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
197
+ .sl-inspector-content { grid-template-columns: minmax(0, 1fr); gap: 12px; }
198
+ .sl-cell-facts dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
199
+ .sl-mechanisms > ul { grid-template-columns: minmax(0, 1fr); }
200
+ }
201
+ @container sperm-lab (max-width: 330px) {
202
+ .sl-readouts dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
203
+ .sl-sample-tools button { font-size: 10px; }
204
+ }
205
+ @media (pointer: coarse) { .sl-factor-row input[type="range"], .sl-factor-help summary { min-height: 44px; } }
206
+ @media (forced-colors: active) {
207
+ .sl-lab { --sl-ink: CanvasText; --sl-accent: LinkText; --sl-rule: CanvasText; }
208
+ .sl-canvas-wrap { border: 1px solid CanvasText; }
209
+ .sl-factor-row input[type="range"] { appearance: auto; -webkit-appearance: auto; }
210
+ }
211
+ @media print { .sl-lab canvas, .sl-actions, .sl-sample-tools, .sl-factor-row input { display: none; } }
package/docs/API.md ADDED
@@ -0,0 +1,234 @@
1
+ # API
2
+
3
+ ## Entry points
4
+
5
+ | Import | Content |
6
+ | --- | --- |
7
+ | `@esmirnov.ai/sperm-lab` | React component and component types. |
8
+ | `@esmirnov.ai/sperm-lab/react` | Alias for the React entry. |
9
+ | `@esmirnov.ai/sperm-lab/core` | Simulation, factors, geometry, metrics, and prepared samples. |
10
+ | `@esmirnov.ai/sperm-lab/styles.css` | Scoped component styles. |
11
+ | `@esmirnov.ai/sperm-lab/package.json` | Package metadata. |
12
+
13
+ The core entry does not import React or use browser globals.
14
+ The React entry keeps its client directive for compatible frameworks.
15
+
16
+ ## React component
17
+
18
+ ```tsx
19
+ import { SpermLab } from "@esmirnov.ai/sperm-lab";
20
+ import "@esmirnov.ai/sperm-lab/styles.css";
21
+
22
+ <SpermLab
23
+ seed={42}
24
+ count={48}
25
+ initialFactors={{ smoking: 0.5, heat: 0.3 }}
26
+ className="my-lab"
27
+ onMetrics={metrics => console.log(metrics.total, metrics.multiHead)}
28
+ />
29
+ ```
30
+
31
+ | Property | Purpose |
32
+ | --- | --- |
33
+ | `seed` | Select a reproducible synthetic population. |
34
+ | `count` | Set the requested number of cells. |
35
+ | `initialFactors` | Set independent initial factor strengths from 0 to 1. |
36
+ | `initialFactor` | Preserve the older single-factor default for compatibility. |
37
+ | `teachingPopulation` | Keep a matching example for every catalog category. The default is `true`. |
38
+ | `className` | Add a class to the component root. |
39
+ | `style` | Add styles or custom properties to the component root. |
40
+ | `onMetrics` | Receive the counts after a population or prepared sample changes. |
41
+
42
+ `seed`, `count`, `initialFactors`, `initialFactor`, and `teachingPopulation` apply when the component mounts.
43
+ Later changes to those properties do not replace the sample.
44
+ Use a React `key` to remount the component with new defaults.
45
+
46
+ The default seed is 42 and the default requested count is 48.
47
+ With the teaching population, the component bounds the requested count between 18 and 120 cells.
48
+ Without it, the component bounds the requested count between 8 and 120 cells.
49
+ Factor values can change the actual population size.
50
+ The teaching mode keeps at least 18 cells.
51
+ The core accepts requested counts from 1 to 160 before that teaching floor.
52
+
53
+ All factor strengths default to zero.
54
+ `initialFactors` takes precedence over `initialFactor`.
55
+ The older `initialFactor` option starts that factor at a strength of 0.65.
56
+ All 12 native factor sliders remain visible.
57
+ Each slider changes its own value in the combined sample.
58
+
59
+ `onMetrics` receives one `Metrics` object after the initial mount and population changes.
60
+ It does not run for every animation frame.
61
+ React development mode can repeat effects.
62
+
63
+ The component includes its own controls, sources, sample, and inspection view.
64
+ The host owns its header, footer, and page introduction.
65
+ The canvas keeps its background transparent.
66
+
67
+ The component respects reduced-motion preferences.
68
+ It stops automatic motion when its document is hidden or the component leaves the viewport.
69
+ Use the component controls to pause or resume motion.
70
+
71
+ ## Live inspection and concentration
72
+
73
+ The component draws defects directly in the live sample.
74
+ Explore selects a moving swimmer and opens its details.
75
+ If a cell is already selected, Explore keeps that selection.
76
+ Select Explore again to dismiss the popup.
77
+ Select a visible head, midpiece, or tail to inspect its cell.
78
+ A nonmodal detail popup tracks the selected cell during motion.
79
+ The popup shows movement, vitality, head, tail, midpiece, and DNA traits.
80
+ DNA details obey the DNA overlay control.
81
+
82
+ Escape, the close button, and an empty-space click dismiss the popup.
83
+ Enter on the focused canvas selects the next cell and opens its details.
84
+ Next swimmer selects the next cell with a button.
85
+ The canvas blocks the browser context menu.
86
+ Tab reaches the popup controls.
87
+ Full anatomy dismisses the popup and scrolls to the larger diagram.
88
+ Popup motion obeys pause and reduced-motion preferences.
89
+
90
+ The Concentration readout uses `Metrics.total` with the unit `cells / model field`.
91
+ It updates after a factor change prepares a new population.
92
+ The readout describes synthetic density without clinical units or reference thresholds.
93
+ `onMetrics` continues to report population changes rather than every motion frame.
94
+
95
+ The component uses internal rendered geometry for pointer selection.
96
+ The public `findCell` function remains a center-based query in normalized model coordinates.
97
+ The internal renderer helpers do not change the public package entry points.
98
+
99
+ ## Damage color
100
+
101
+ The component uses `--sl-damage` for DNA fragmentation and defect accents.
102
+ The default value is red `#b82735`.
103
+ The internal renderer reads this color into its optional `SpermPalette.damage` field.
104
+
105
+ ```css
106
+ .my-lab.sl-lab {
107
+ --sl-damage: #b82735;
108
+ }
109
+ ```
110
+
111
+ ## Core functions
112
+
113
+ ```ts
114
+ createSimulation({ seed, count, factors: { smoking: 0.5, heat: 0.3 }, teachingPopulation: true });
115
+ stepSimulation(sample, dt, flow);
116
+ getMetrics(sample);
117
+ getTailPoints(cell, sample.time, 0);
118
+ getTailPoints(cell, sample.time, 1);
119
+ findCell(sample, x, y);
120
+ createDefectSimulation({ seed, count });
121
+ createChallengeSimulation("hidden-dna", { seed, count });
122
+ ```
123
+
124
+ Positions use normalized coordinates from 0 to 1.
125
+ Time steps use seconds for the motion model only.
126
+ The model bounds long or invalid time steps.
127
+ Each factor value uses a relative scale from 0 to 1.
128
+ Unspecified factor values resolve to zero.
129
+
130
+ `resolveFactors(settings)` returns a complete map of factor values.
131
+ It clamps finite values to the range from 0 to 1.
132
+ Invalid numeric values become zero.
133
+ Unknown factor identifiers cause a `RangeError`.
134
+ `getActiveFactors(sample)` returns the factor records with positive strengths.
135
+
136
+ Create a new simulation when the factor combination changes.
137
+ The core also accepts the older `factor` and `intensity` options.
138
+ The `factors` map takes precedence over those options.
139
+
140
+ The core defaults `teachingPopulation` to `false`.
141
+ Set it to `true` to keep a matching example for every catalog category.
142
+ Factor controls still affect the sample through illustrative channels.
143
+ The model preserves the required catalog trait while other traits can change.
144
+ A cell can match more than one catalog category.
145
+
146
+ The `progress` option represents an illustrative development stage from 0 to 1.
147
+ The React component uses progress 1 with the current factor settings.
148
+ It does not represent a fixed number of days.
149
+ A zero progress value removes the illustrative factor effects.
150
+ Teaching catalog examples remain available.
151
+
152
+ `stepSimulation` changes motion in place.
153
+ It does not change vitality, shape, or DNA damage.
154
+ An optional current has `x`, `y`, `dx`, `dy`, and `strength` fields.
155
+
156
+ `getMetrics` returns integer counts for the sample.
157
+ The counts include `total`, `motile`, `progressive`, `alive`, `typical`, and `dnaDamaged`.
158
+ They also include `multiHead`, `multiTail`, `midpieceDamaged`, `headDefects`, `tailDefects`, `slow`, `immotile`, and `nonprogressive`.
159
+ `isSlow` identifies a motile cell slower than `SLOW_SPEED_THRESHOLD` in the model.
160
+
161
+ `Metrics.immotile` includes all cells without active propulsion, including nonviable cells.
162
+ The catalog identifier `immotile` selects a cell that remains alive without active propulsion.
163
+ A current can move an immotile cell without changing its movement class.
164
+
165
+ `typical` counts cells with a typical head and tail outline in this model.
166
+ Midpiece injury and DNA damage remain separate properties.
167
+ It is not a WHO strict morphology score.
168
+ Those counts and thresholds describe the synthetic sample only.
169
+ They are not clinical reference limits.
170
+
171
+ ## Cell geometry
172
+
173
+ `ANATOMY_SOURCES` contains the references for morphology and sperm metabolism.
174
+ Each cell includes `headCount`, `tailCount`, `headShape`, `tailShape`, and `midpieceShape`.
175
+ The independent injury fields are `midpieceDamage` and `dnaDamage`.
176
+ The older `headDefect`, `tailDefect`, and `morphology` fields remain available.
177
+
178
+ | Field | Values |
179
+ | --- | --- |
180
+ | `headCount` | `1` or `2`. |
181
+ | `tailCount` | `0`, `1`, `2`, or `3`. |
182
+ | `headShape` | `typical`, `small`, `large`, `tapered`, `round`, or `irregular`. |
183
+ | `tailShape` | `typical`, `bent`, `coiled`, `short`, `absent`, or `irregular`. |
184
+ | `midpieceShape` | `typical`, `bent`, or `thick`. |
185
+ | `dnaFragmentation` | `0`, `3`, `4`, `5`, or `6` symbolic pieces. |
186
+
187
+ DNA pieces are display symbols rather than measured molecular fragments.
188
+ `getTailPoints` returns normalized points for a renderer.
189
+ Use tail indexes from zero to `tailCount - 1`.
190
+ If `tailCount` is zero, draw no tail.
191
+ `findCell` returns a nearby cell or `undefined`.
192
+
193
+ ## Teaching catalog
194
+
195
+ `DEFECT_CATALOG` describes 18 selected morphology, injury, and movement examples.
196
+ `cellMatchesDefect(cell, id)` identifies a matching cell.
197
+ `getDefectCounts(sample)` returns integer counts indexed by the catalog identifiers.
198
+ `getCellDefects(cell)` returns every catalog record that matches the cell.
199
+ `MORPHOLOGY_SOURCES` contains the structural references.
200
+ A prepared example carries its catalog identifier in `cell.example`.
201
+
202
+ `createDefectSimulation` makes a prepared sample with at least 18 cells.
203
+ The sample guarantees an example for every catalog identifier.
204
+ It identifies itself with `fixture: "defect-examples"`.
205
+ The examples do not represent population frequencies or the effect of a particular lifestyle factor.
206
+
207
+ The catalog identifiers are:
208
+
209
+ ```ts
210
+ "double-head", "small-head", "large-head", "tapered-head", "round-head",
211
+ "double-tail", "triple-tail", "bent-tail", "coiled-tail", "short-tail", "absent-tail",
212
+ "bent-midpiece", "thick-midpiece", "midpiece-damage", "dna-fragmentation",
213
+ "slow", "immotile", "nonprogressive"
214
+ ```
215
+
216
+ Prepared challenge identifiers remain `hidden-dna`, `immotile-alive`, and `circling`.
217
+ Each prepared sample includes a target for its teaching task.
218
+
219
+ ## Factors
220
+
221
+ `FACTORS` contains all 12 factor records.
222
+ Each record includes its identifier, title, summary, mechanism, timescale, evidence label, limits, and source links.
223
+
224
+ The factor identifiers are:
225
+
226
+ ```ts
227
+ type FactorId =
228
+ | "exercise" | "endurance" | "cycling" | "smoking"
229
+ | "alcohol" | "stress" | "sleep" | "heat"
230
+ | "fever" | "metabolic" | "androgens" | "pesticides";
231
+ ```
232
+
233
+ Use the emitted TypeScript declarations for the complete public types.
234
+ Read the [model guide](MODEL.md) before you change the factor rules.
package/docs/DEPLOY.md ADDED
@@ -0,0 +1,76 @@
1
+ # Release and deployment
2
+
3
+ ## Prepare the package
4
+
5
+ 1. Install the locked development dependencies.
6
+
7
+ ```sh
8
+ npm ci
9
+ ```
10
+
11
+ 2. Run the release tests.
12
+
13
+ ```sh
14
+ npm test
15
+ npm run typecheck
16
+ npm run test:package
17
+ npm run build:demo
18
+ ```
19
+
20
+ 3. Examine the demo on desktop and phone widths.
21
+ 4. Examine all 12 factors and their source links.
22
+ 5. Examine pointer input, keyboard input, reduced motion, and pause behavior.
23
+ 6. Examine the archive before publication.
24
+
25
+ ```sh
26
+ npm pack --dry-run
27
+ ```
28
+
29
+ The archive includes `dist`, the license, the README, and the guides.
30
+ It excludes development dependencies, local output, and secrets.
31
+ Commit `dist` with its source.
32
+
33
+ ## Publish to npm
34
+
35
+ Use the npm account that owns the package.
36
+ Complete the npm authentication prompt when the registry requests it.
37
+
38
+ ```sh
39
+ npm whoami
40
+ npm publish --access public
41
+ npm view @esmirnov.ai/sperm-lab version dist.shasum
42
+ ```
43
+
44
+ Use a new version for every later publication.
45
+ Create a matching Git tag after the public package passes a clean installation.
46
+ The CI workflow examines Node.js 22.12 and Node.js 24.
47
+
48
+ ## Deploy the standalone demo
49
+
50
+ ```sh
51
+ npm run build:demo
52
+ ```
53
+
54
+ Deploy the contents of `demo-dist` to a static host.
55
+ The demo uses relative asset paths.
56
+ The demo does not need a backend, database, or server function.
57
+
58
+ ## Integrate with the personal site
59
+
60
+ Install a fixed public package version in `me-landing`.
61
+
62
+ ```sh
63
+ npm install --save-exact @esmirnov.ai/sperm-lab@0.4.1
64
+ ```
65
+
66
+ Use the shared experiment page at `/sperm-lab/`.
67
+ Keep the package component and stylesheet as imports.
68
+ Keep the simulation source in this repository.
69
+
70
+ The Labs index uses a static preview from the headless model.
71
+ The Projects science tab uses the same text format as the other projects.
72
+ The homepage and top-bar structure remain consistent with the existing site.
73
+
74
+ Run the site build and release verifier before deployment.
75
+ Deploy only the generated public output through the site's Firebase Hosting command.
76
+ Examine the public lab, preview, package link, and source link after deployment.