@real-music-packages/web-core 0.36.2 → 0.38.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.
@@ -0,0 +1,140 @@
1
+ import { N as NotationLayout } from './notationGeometry-54fFq5yU.js';
2
+ import './promo.js';
3
+
4
+ interface CreateSvgNotationPlayerOpts {
5
+ /** Element the player's content is mounted into. Takes NATURAL content
6
+ * height (the whole score, page-flow layout) — the host must not clip a
7
+ * fixed height; the PAGE scrolls the score, there is no internal camera. */
8
+ host: HTMLElement;
9
+ /** MusicXML to engrave. Ignored when `rendered` (the test seam) is set. */
10
+ musicXml: string;
11
+ /** Distinct note onsets (ms) the playhead locks to — same contract as
12
+ * `CreateNotationPlayerOpts.onsetsMs` in notationPlayer.ts. */
13
+ onsetsMs: number[];
14
+ /** Per-onset engraved column positions, 1:1 with the DEDUPED/sorted
15
+ * `onsetsMs` — same semantics as the canvas player's `noteCols`. */
16
+ noteCols?: number[];
17
+ /** Playhead line color. Default `'#2f6f4f'`. */
18
+ playheadColor?: string;
19
+ /** Initial OSMD zoom (a pure post-layout visual scale — see
20
+ * `svgNotationLayout`'s doc). Default 1 (OSMD's own default — the
21
+ * engraving fits the host's own width at normal note size). */
22
+ zoom?: number;
23
+ /**
24
+ * Advanced / test seam: a pre-built `NotationLayout`, bypassing the real
25
+ * OSMD SVG engrave (`musicXml` is still required by the type but is
26
+ * ignored when this is set). Mirrors `CreateNotationPlayerOpts.rendered` in
27
+ * notationPlayer.ts for the identical reason: real OSMD *rendering* needs
28
+ * actual browser canvas glyph metrics (for its line-breaking pass) even
29
+ * when the SVG backend is selected — headless/jsdom can't fully provide
30
+ * that — so this is how this module stays unit-testable in Node. Not
31
+ * needed in a real browser host. When set, `setZoom`/`resize` update the
32
+ * tracked zoom/width but perform no real re-engrave (there is nothing to
33
+ * re-engrave).
34
+ */
35
+ rendered?: NotationLayout;
36
+ }
37
+ interface SvgNotationPlayer {
38
+ /** Resolves once the engraving is in the DOM and ready to draw. `setTime`/
39
+ * click hit-testing are safe to call before this resolves (no-op until
40
+ * ready, same contract as the canvas player). */
41
+ readonly ready: Promise<void>;
42
+ /** Drive the playhead for absolute playback time `tMs`. Caller owns the
43
+ * audio clock + rAF loop. */
44
+ setTime(tMs: number): void;
45
+ /** Re-engrave at a new OSMD zoom (systems reflow). The scroll position is
46
+ * restored afterward so the content that was centered in the viewport
47
+ * before the reflow is still centered after it. */
48
+ setZoom(z: number): Promise<void>;
49
+ /** Re-measure the host and reflow to match its current width, with the
50
+ * same scroll-position preservation as `setZoom`. Call on host resize /
51
+ * orientation change. */
52
+ resize(): Promise<void>;
53
+ /** Register a measure-click handler (measure index, matching
54
+ * `ScoreNote.measure`/the engraved index). Returns an unsubscribe fn. */
55
+ onMeasureClick(cb: (measureIndex: number) => void): () => void;
56
+ /** Tear down: removes the mounted DOM (engraving + playhead overlay) from
57
+ * `host`, and drops every listener this instance added (click, window
58
+ * scroll) and pending async work (a token guard drops any in-flight
59
+ * reflow's effects). Idempotent. */
60
+ destroy(): void;
61
+ }
62
+ interface SvgNotationLayoutOpts {
63
+ /** CSS px per OSMD unit at zoom 1 — OSMD's own exported `unitInPixels`
64
+ * constant (see the derivation above). REQUIRED, no default: the point is
65
+ * to FORCE the real call site to source this from the live
66
+ * `opensheetmusicdisplay` import
67
+ * (`const { unitInPixels } = await import('opensheetmusicdisplay')`)
68
+ * rather than this module assuming a value that could drift across OSMD
69
+ * versions. Tests pin it explicitly. */
70
+ unitInPixels: number;
71
+ }
72
+ /**
73
+ * Pure SVG-backend geometry extractor — builds the SAME `NotationLayout`
74
+ * shape the canvas path's `notationLayout()` does (measure column boxes +
75
+ * system rows + a `rect` vertical band), but read directly from OSMD's
76
+ * `GraphicalMusicSheet` in SVG/CSS px space (see the unit-conversion doc
77
+ * above) instead of a rasterized bitmap. Rebuild on every render (zoom /
78
+ * resize / new score) — cheap, pure array/object mapping, no DOM reads.
79
+ *
80
+ * `osmd` is duck-typed `any` — same contract as promo.ts's
81
+ * `extractGeometry(osmd: any, ...)` — so tests can pass a plain fixture
82
+ * object shaped like the minimal slice of a real `OpenSheetMusicDisplay`
83
+ * instance this function reads (`{ Zoom, GraphicSheet: { MusicPages,
84
+ * MeasureList } }`) without needing a real browser OSMD render (see
85
+ * `CreateSvgNotationPlayerOpts.rendered`'s doc for why headless can't do a
86
+ * real one).
87
+ *
88
+ * `rect` spans the FULL engraved page (top-aligned, `dy = 0`) — there is no
89
+ * follow-camera crop in this component (the whole score is always in the
90
+ * DOM; the PAGE scrolls it) — matching the canvas scroll-mode's `flowLayout`
91
+ * in spirit. `vstackAudioPlayheadLine` only reads `rect.dy`/`rect.dh` to
92
+ * clamp the playhead into the drawn band, so this is a correct, minimal
93
+ * `rect` for that consumer.
94
+ */
95
+ declare function svgNotationLayout(osmd: any, opts: SvgNotationLayoutOpts): NotationLayout;
96
+ /**
97
+ * Pure reflow position-preservation math: given the OLD layout (before a
98
+ * `setZoom`/`resize` re-engrave), the NEW layout (after it), and an anchor
99
+ * point `(anchorX, anchorY)` in the OLD layout's coordinate space (typically
100
+ * "whatever content sat at the vertical center of the viewport" — see the
101
+ * call site), return the vertical delta (new px minus old px) to add to the
102
+ * window's scroll position so that SAME content stays in the SAME on-screen
103
+ * position across the reflow.
104
+ *
105
+ * Deliberately NOT playhead interpolation: it's a one-shot "where did this
106
+ * content move to" lookup built from two existing, reused primitives —
107
+ * `hitTestMeasureAt` (which measure box contains/is nearest the anchor) and
108
+ * `measureColumnsFromLayout` (that same measure's box in each layout) — plus
109
+ * a linear fraction-within-the-box preservation so an anchor near the bottom
110
+ * of a tall measure box stays near the bottom after reflow, not snapped to
111
+ * the box's top edge. Returns 0 when the anchor measure can't be resolved in
112
+ * either layout (e.g. an empty layout) — a safe no-op scroll.
113
+ */
114
+ declare function computeReflowScrollDelta(oldLayout: NotationLayout, newLayout: NotationLayout, anchorX: number, anchorY: number): number;
115
+ /** Tolerance, px, for "close enough" to count as the same position (float/
116
+ * sub-pixel scroll settling noise). */
117
+ declare const PROGRAMMATIC_SCROLL_EPSILON_PX = 2;
118
+ /**
119
+ * True while `y` lies within `[min(start,target), max(start,target)]`
120
+ * (± `epsilon`) — i.e. anywhere along the straight-line path of a
121
+ * `window.scrollTo({top: target, behavior:'smooth'})` call issued from
122
+ * `start`. A scroll event reporting a position outside this span cannot be a
123
+ * frame of that animation.
124
+ */
125
+ declare function isWithinProgrammaticScroll(y: number, start: number, target: number, epsilon?: number): boolean;
126
+ /** True once `y` has settled at (within `epsilon` of) the programmatic
127
+ * scroll's target — the animation is complete, so tracking can be cleared. */
128
+ declare function hasReachedProgrammaticTarget(y: number, target: number, epsilon?: number): boolean;
129
+ /** Engrave-width ceiling, CSS px (design doc §"Render": "cap ~1200px, the
130
+ * 0.36.2 rule" — the same reasoning as notationPlayer.ts's
131
+ * `MAX_ENGRAVE_WIDTH`, restated here rather than imported since the two
132
+ * players' constants are independently tunable, and this one is spec'd to a
133
+ * slightly different value). */
134
+ declare const MAX_ENGRAVE_WIDTH_SVG = 1200;
135
+ /** Build a live, interactive SVG (vector) notation player. See the module doc
136
+ * + `docs/superpowers/specs/2026-08-11-svg-notation-player-design.md` (in
137
+ * stave-web-sightread) for the full design. */
138
+ declare function createSvgNotationPlayer(opts: CreateSvgNotationPlayerOpts): SvgNotationPlayer;
139
+
140
+ export { type CreateSvgNotationPlayerOpts, MAX_ENGRAVE_WIDTH_SVG, PROGRAMMATIC_SCROLL_EPSILON_PX, type SvgNotationLayoutOpts, type SvgNotationPlayer, computeReflowScrollDelta, createSvgNotationPlayer, hasReachedProgrammaticTarget, isWithinProgrammaticScroll, svgNotationLayout };
@@ -0,0 +1,316 @@
1
+ import {
2
+ distinctOnsets,
3
+ hitTestMeasureAt,
4
+ measureColumnsFromLayout,
5
+ vstackAudioPlayheadLine
6
+ } from "./chunk-BHRDISMU.js";
7
+ import "./chunk-HXTRNE74.js";
8
+
9
+ // src/notationPlayerSvg.ts
10
+ var EMPTY_LAYOUT = {
11
+ src: { x: 0, y: 0, w: 0, h: 0 },
12
+ rect: { dx: 0, dy: 0, dw: 0, dh: 0 },
13
+ systems: [],
14
+ measures: []
15
+ };
16
+ function svgNotationLayout(osmd, opts) {
17
+ try {
18
+ const zoom = typeof osmd?.Zoom === "number" && osmd.Zoom > 0 ? osmd.Zoom : typeof osmd?.zoom === "number" && osmd.zoom > 0 ? osmd.zoom : 1;
19
+ const f = opts.unitInPixels * zoom;
20
+ const graphic = osmd?.GraphicSheet;
21
+ const page = graphic?.MusicPages?.[0];
22
+ const pageSize = page?.PositionAndShape?.Size;
23
+ const musicSystems = page?.MusicSystems ?? [];
24
+ if (!(pageSize?.width > 0) || !(pageSize?.height > 0) || !musicSystems.length) return EMPTY_LAYOUT;
25
+ const toBox = (pas) => {
26
+ const p = pas?.AbsolutePosition;
27
+ const sz = pas?.Size;
28
+ if (!p || !sz) return null;
29
+ return { x: p.x * f, y: p.y * f, w: sz.width * f, h: sz.height * f };
30
+ };
31
+ const systems = musicSystems.map((s) => toBox(s?.PositionAndShape)).filter((b) => !!b && b.w > 1 && b.h > 1).sort((a, b) => a.y - b.y);
32
+ if (!systems.length) return EMPTY_LAYOUT;
33
+ const measureList = graphic?.MeasureList ?? [];
34
+ const measures = [];
35
+ measureList.forEach((staves, index) => {
36
+ (staves ?? []).forEach((m, staff) => {
37
+ const box = toBox(m?.PositionAndShape);
38
+ if (box && box.w > 1 && box.h > 1) {
39
+ const seX = (m?.staffEntries ?? [])[0]?.PositionAndShape?.AbsolutePosition?.x;
40
+ const noteStartX = typeof seX === "number" ? seX * f : box.x;
41
+ measures.push({ index, staff, box, noteStartX });
42
+ }
43
+ });
44
+ });
45
+ const dw = pageSize.width * f;
46
+ const dh = pageSize.height * f;
47
+ return {
48
+ src: { x: 0, y: 0, w: dw, h: dh },
49
+ rect: { dx: 0, dy: 0, dw, dh },
50
+ systems,
51
+ measures
52
+ };
53
+ } catch {
54
+ return EMPTY_LAYOUT;
55
+ }
56
+ }
57
+ function computeReflowScrollDelta(oldLayout, newLayout, anchorX, anchorY) {
58
+ const idx = hitTestMeasureAt(oldLayout, anchorX, anchorY);
59
+ if (idx == null) return 0;
60
+ const oldIndices = [...new Set(oldLayout.measures.map((m) => m.index))].sort((a, b) => a - b);
61
+ const newIndices = [...new Set(newLayout.measures.map((m) => m.index))].sort((a, b) => a - b);
62
+ const oi = oldIndices.indexOf(idx);
63
+ const ni = newIndices.indexOf(idx);
64
+ if (oi < 0 || ni < 0) return 0;
65
+ const oldCols = measureColumnsFromLayout(oldLayout.measures);
66
+ const newCols = measureColumnsFromLayout(newLayout.measures);
67
+ const oldBox = oldCols[oi];
68
+ const newBox = newCols[ni];
69
+ if (!oldBox || !newBox) return 0;
70
+ const fracY = oldBox.h > 0 ? (anchorY - oldBox.y) / oldBox.h : 0;
71
+ const newAnchorY = newBox.y + fracY * newBox.h;
72
+ return newAnchorY - anchorY;
73
+ }
74
+ var PROGRAMMATIC_SCROLL_EPSILON_PX = 2;
75
+ function isWithinProgrammaticScroll(y, start, target, epsilon = PROGRAMMATIC_SCROLL_EPSILON_PX) {
76
+ const lo = Math.min(start, target) - epsilon;
77
+ const hi = Math.max(start, target) + epsilon;
78
+ return y >= lo && y <= hi;
79
+ }
80
+ function hasReachedProgrammaticTarget(y, target, epsilon = PROGRAMMATIC_SCROLL_EPSILON_PX) {
81
+ return Math.abs(y - target) <= epsilon;
82
+ }
83
+ var DEFAULT_PLAYHEAD_COLOR = "#2f6f4f";
84
+ var MAX_ENGRAVE_WIDTH_SVG = 1200;
85
+ var MIN_ENGRAVE_WIDTH_SVG = 280;
86
+ var SEEK_DISCONTINUITY_MS = 400;
87
+ function nowMs() {
88
+ return typeof performance !== "undefined" ? performance.now() : Date.now();
89
+ }
90
+ function createSvgNotationPlayer(opts) {
91
+ const { host, musicXml, onsetsMs, noteCols } = opts;
92
+ const playheadColor = opts.playheadColor ?? DEFAULT_PLAYHEAD_COLOR;
93
+ const onsets = distinctOnsets(onsetsMs.map((onsetMs) => ({ onsetMs })));
94
+ const root = document.createElement("div");
95
+ root.style.position = "relative";
96
+ root.style.width = "100%";
97
+ root.style.touchAction = "pan-y pinch-zoom";
98
+ host.appendChild(root);
99
+ const svgHost = document.createElement("div");
100
+ root.appendChild(svgHost);
101
+ const playheadEl = document.createElement("div");
102
+ playheadEl.style.position = "absolute";
103
+ playheadEl.style.left = "0px";
104
+ playheadEl.style.top = "0px";
105
+ playheadEl.style.width = "2px";
106
+ playheadEl.style.height = "0px";
107
+ playheadEl.style.background = playheadColor;
108
+ playheadEl.style.opacity = "0";
109
+ playheadEl.style.pointerEvents = "none";
110
+ root.appendChild(playheadEl);
111
+ let osmd = null;
112
+ let currentLayout = null;
113
+ let currentZoom = opts.zoom ?? 1;
114
+ let unitInPixelsConst = 10;
115
+ let lastEngravedWidthPx = 0;
116
+ let destroyed = false;
117
+ let lastTMs = 0;
118
+ let rebuildToken = 0;
119
+ function desiredEngraveWidthPx() {
120
+ const w = host.clientWidth || 0;
121
+ return Math.max(MIN_ENGRAVE_WIDTH_SVG, Math.min(w || MAX_ENGRAVE_WIDTH_SVG, MAX_ENGRAVE_WIDTH_SVG));
122
+ }
123
+ function renderPlayhead(tMs) {
124
+ lastTMs = tMs;
125
+ if (!currentLayout) return;
126
+ const nBars = currentLayout.measures.length ? Math.max(...currentLayout.measures.map((m) => m.index)) + 1 : 0;
127
+ const line = vstackAudioPlayheadLine(currentLayout, onsets, tMs, nBars, noteCols);
128
+ if (!line) {
129
+ playheadEl.style.opacity = "0";
130
+ return;
131
+ }
132
+ playheadEl.style.opacity = String(line.alpha);
133
+ playheadEl.style.left = `${line.x}px`;
134
+ playheadEl.style.top = `${line.y0}px`;
135
+ playheadEl.style.height = `${Math.max(0, line.y1 - line.y0)}px`;
136
+ maybeAutoFollow();
137
+ }
138
+ let autoFollowSuspended = false;
139
+ let programmaticStart = null;
140
+ let programmaticTarget = null;
141
+ let followRafPending = false;
142
+ let lastWallMs = null;
143
+ let lastMusicMs = 0;
144
+ function onWindowScroll() {
145
+ if (programmaticTarget != null && programmaticStart != null) {
146
+ const y = window.scrollY;
147
+ if (isWithinProgrammaticScroll(y, programmaticStart, programmaticTarget)) {
148
+ if (hasReachedProgrammaticTarget(y, programmaticTarget)) {
149
+ programmaticStart = null;
150
+ programmaticTarget = null;
151
+ }
152
+ return;
153
+ }
154
+ }
155
+ autoFollowSuspended = true;
156
+ programmaticStart = null;
157
+ programmaticTarget = null;
158
+ }
159
+ const hasWindow = typeof window !== "undefined" && typeof window.addEventListener === "function";
160
+ if (hasWindow) window.addEventListener("scroll", onWindowScroll, { passive: true });
161
+ function detectDiscontinuity(tMs) {
162
+ const now = nowMs();
163
+ if (lastWallMs != null) {
164
+ const dtMusic = tMs - lastMusicMs;
165
+ const dtWall = now - lastWallMs;
166
+ if (dtMusic < 0 || Math.abs(dtMusic - dtWall) > SEEK_DISCONTINUITY_MS) autoFollowSuspended = false;
167
+ } else {
168
+ autoFollowSuspended = false;
169
+ }
170
+ lastWallMs = now;
171
+ lastMusicMs = tMs;
172
+ }
173
+ function maybeAutoFollow() {
174
+ if (autoFollowSuspended || followRafPending) return;
175
+ if (typeof window === "undefined" || typeof window.requestAnimationFrame !== "function") return;
176
+ followRafPending = true;
177
+ window.requestAnimationFrame(() => {
178
+ followRafPending = false;
179
+ if (destroyed || autoFollowSuspended) return;
180
+ if (typeof playheadEl.getBoundingClientRect !== "function") return;
181
+ const rect = playheadEl.getBoundingClientRect();
182
+ const vh = window.innerHeight;
183
+ if (!(vh > 0)) return;
184
+ if (rect.top >= vh * 0.25 && rect.top <= vh * 0.75) return;
185
+ const start = window.scrollY;
186
+ const target = Math.max(0, start + rect.top - vh / 2);
187
+ programmaticStart = start;
188
+ programmaticTarget = target;
189
+ window.scrollTo({ top: target, left: window.scrollX, behavior: "smooth" });
190
+ });
191
+ }
192
+ function setTime(tMs) {
193
+ if (destroyed) return;
194
+ detectDiscontinuity(tMs);
195
+ renderPlayhead(tMs);
196
+ }
197
+ async function initialEngrave() {
198
+ if (opts.rendered) {
199
+ currentLayout = opts.rendered;
200
+ lastEngravedWidthPx = desiredEngraveWidthPx();
201
+ renderPlayhead(lastTMs);
202
+ return;
203
+ }
204
+ const { OpenSheetMusicDisplay, unitInPixels } = await import("opensheetmusicdisplay");
205
+ unitInPixelsConst = unitInPixels;
206
+ if (destroyed) return;
207
+ const widthPx = desiredEngraveWidthPx();
208
+ svgHost.style.width = `${widthPx}px`;
209
+ const inst = new OpenSheetMusicDisplay(svgHost, {
210
+ backend: "svg",
211
+ autoResize: false,
212
+ drawTitle: false,
213
+ drawSubtitle: false,
214
+ drawComposer: false,
215
+ drawLyricist: false,
216
+ drawPartNames: false
217
+ });
218
+ await inst.load(musicXml);
219
+ if (destroyed) return;
220
+ inst.Zoom = currentZoom;
221
+ inst.render();
222
+ if (destroyed) return;
223
+ osmd = inst;
224
+ lastEngravedWidthPx = widthPx;
225
+ currentLayout = svgNotationLayout(inst, { unitInPixels: unitInPixelsConst });
226
+ renderPlayhead(lastTMs);
227
+ }
228
+ const ready = initialEngrave();
229
+ async function reflow(newZoom) {
230
+ if (destroyed) return;
231
+ const widthPx = desiredEngraveWidthPx();
232
+ if (widthPx === lastEngravedWidthPx && newZoom === currentZoom) return;
233
+ if (opts.rendered || !osmd) {
234
+ currentZoom = newZoom;
235
+ return;
236
+ }
237
+ const myToken = ++rebuildToken;
238
+ const oldLayout = currentLayout;
239
+ const hasWin = typeof window !== "undefined";
240
+ let anchorY = null;
241
+ const anchorX = widthPx / 2;
242
+ if (hasWin && typeof root.getBoundingClientRect === "function") {
243
+ const r = root.getBoundingClientRect();
244
+ anchorY = window.innerHeight / 2 - r.top;
245
+ }
246
+ svgHost.style.width = `${widthPx}px`;
247
+ osmd.Zoom = newZoom;
248
+ osmd.updateGraphic();
249
+ osmd.render();
250
+ if (destroyed || myToken !== rebuildToken) return;
251
+ lastEngravedWidthPx = widthPx;
252
+ currentZoom = newZoom;
253
+ currentLayout = svgNotationLayout(osmd, { unitInPixels: unitInPixelsConst });
254
+ if (oldLayout && anchorY != null && hasWin) {
255
+ const delta = computeReflowScrollDelta(oldLayout, currentLayout, anchorX, anchorY);
256
+ if (Number.isFinite(delta) && Math.abs(delta) > 0.5) {
257
+ window.scrollTo({ top: Math.max(0, window.scrollY + delta), left: window.scrollX, behavior: "auto" });
258
+ }
259
+ }
260
+ if (!destroyed) renderPlayhead(lastTMs);
261
+ }
262
+ const clickListeners = [];
263
+ function onRootClick(e) {
264
+ if (!currentLayout) return;
265
+ const rect = root.getBoundingClientRect();
266
+ const mx = e.clientX - rect.left;
267
+ const my = e.clientY - rect.top;
268
+ const idx = hitTestMeasureAt(currentLayout, mx, my);
269
+ if (idx != null) for (const cb of clickListeners) cb(idx);
270
+ }
271
+ root.addEventListener("click", onRootClick);
272
+ return {
273
+ ready,
274
+ setTime,
275
+ async setZoom(z) {
276
+ await ready;
277
+ await reflow(z);
278
+ },
279
+ async resize() {
280
+ await ready;
281
+ await reflow(currentZoom);
282
+ },
283
+ onMeasureClick(cb) {
284
+ clickListeners.push(cb);
285
+ return () => {
286
+ const i = clickListeners.indexOf(cb);
287
+ if (i >= 0) clickListeners.splice(i, 1);
288
+ };
289
+ },
290
+ destroy() {
291
+ if (destroyed) return;
292
+ destroyed = true;
293
+ rebuildToken++;
294
+ root.removeEventListener("click", onRootClick);
295
+ if (hasWindow) window.removeEventListener("scroll", onWindowScroll);
296
+ clickListeners.length = 0;
297
+ try {
298
+ osmd?.clear?.();
299
+ } catch {
300
+ }
301
+ osmd = null;
302
+ currentLayout = null;
303
+ if (root.parentNode === host) host.removeChild(root);
304
+ }
305
+ };
306
+ }
307
+ export {
308
+ MAX_ENGRAVE_WIDTH_SVG,
309
+ PROGRAMMATIC_SCROLL_EPSILON_PX,
310
+ computeReflowScrollDelta,
311
+ createSvgNotationPlayer,
312
+ hasReachedProgrammaticTarget,
313
+ isWithinProgrammaticScroll,
314
+ svgNotationLayout
315
+ };
316
+ //# sourceMappingURL=notationPlayerSvg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/notationPlayerSvg.ts"],"sourcesContent":["// createSvgNotationPlayer — the SVG (vector) sibling of `createNotationPlayer`\n// (src/notationPlayer.ts). Same job (a live, caller-driven notation +\n// gliding-playhead widget), different medium: OSMD's native SVG backend\n// instead of a rasterized canvas. See\n// docs — stave-web-sightread's\n// docs/superpowers/specs/2026-08-11-svg-notation-player-design.md — for the\n// full design rationale (why: vectors don't blur on pinch/browser zoom, no\n// canvas-area cap, no raster tiling needed for full-score scroll).\n//\n// THE CANVAS MODULE IS NOT MODIFIED OR IMPORTED FOR ITS OSMD/RASTER PATH —\n// this is a parallel component. What IS reused, verbatim, no new math:\n// - `vstackAudioPlayheadLine` (scene/notationGeometry.ts) — the exact same\n// onset-anchored, carriage-return playhead interpolation the canvas path\n// uses. It operates purely on a `NotationLayout` (measure column boxes +\n// a vertical clamp band) — it does not care whether those boxes came from\n// a canvas raster or live SVG DOM geometry, so THIS module's job is only\n// to produce a `NotationLayout` in SVG/CSS px space (see\n// `svgNotationLayout` below) and everything downstream is identical.\n// - `hitTestMeasureAt` (scene/notationGeometry.ts, moved there in 0.38.0\n// specifically so this module never has a build-time edge into\n// notationPlayer.ts's canvas/raster implementation) — the exact same pure\n// point-in-measure-box hit-test, reused for click-to-seek.\n// - `distinctOnsets`, `measureColumnsFromLayout` — small pure helpers,\n// reused as-is.\n//\n// WHAT'S NEW (not a re-derivation of any of the above):\n// - `svgNotationLayout` — an SVG-backend geometry extractor, the SVG\n// counterpart to promo.ts's canvas-only `extractGeometry`. See its own\n// doc comment for the unit-conversion derivation.\n// - `computeReflowScrollDelta` — zoom/resize position-preservation math\n// (not playhead interpolation; a one-shot \"where did this same content\n// move to\" lookup using the existing hit-test + column helpers).\n// - `isWithinProgrammaticScroll` / `hasReachedProgrammaticTarget` — the\n// improved auto-follow discriminator (design doc §4): unlike the canvas\n// scroll-mode player's fixed 600ms \"programmatic scroll\" grace window,\n// this compares the ACTUAL scroll position against the EXACT target this\n// component itself requested, so classification is correct regardless of\n// how long a smooth-scroll animation takes (no grace-window race).\n//\n// IMPORT PATH: subpath-only — `@real-music-packages/web-core/notationPlayerSvg`\n// — not re-exported from the root barrel (same reasoning as notationPlayer.ts:\n// the root barrel is theory-only/zero-dependency).\n\nimport {\n vstackAudioPlayheadLine,\n measureColumnsFromLayout,\n distinctOnsets,\n hitTestMeasureAt,\n type NotationLayout,\n} from './scene/notationGeometry';\nimport type { Box, StaffMeasureBox } from './promo';\n\nexport interface CreateSvgNotationPlayerOpts {\n /** Element the player's content is mounted into. Takes NATURAL content\n * height (the whole score, page-flow layout) — the host must not clip a\n * fixed height; the PAGE scrolls the score, there is no internal camera. */\n host: HTMLElement;\n /** MusicXML to engrave. Ignored when `rendered` (the test seam) is set. */\n musicXml: string;\n /** Distinct note onsets (ms) the playhead locks to — same contract as\n * `CreateNotationPlayerOpts.onsetsMs` in notationPlayer.ts. */\n onsetsMs: number[];\n /** Per-onset engraved column positions, 1:1 with the DEDUPED/sorted\n * `onsetsMs` — same semantics as the canvas player's `noteCols`. */\n noteCols?: number[];\n /** Playhead line color. Default `'#2f6f4f'`. */\n playheadColor?: string;\n /** Initial OSMD zoom (a pure post-layout visual scale — see\n * `svgNotationLayout`'s doc). Default 1 (OSMD's own default — the\n * engraving fits the host's own width at normal note size). */\n zoom?: number;\n /**\n * Advanced / test seam: a pre-built `NotationLayout`, bypassing the real\n * OSMD SVG engrave (`musicXml` is still required by the type but is\n * ignored when this is set). Mirrors `CreateNotationPlayerOpts.rendered` in\n * notationPlayer.ts for the identical reason: real OSMD *rendering* needs\n * actual browser canvas glyph metrics (for its line-breaking pass) even\n * when the SVG backend is selected — headless/jsdom can't fully provide\n * that — so this is how this module stays unit-testable in Node. Not\n * needed in a real browser host. When set, `setZoom`/`resize` update the\n * tracked zoom/width but perform no real re-engrave (there is nothing to\n * re-engrave).\n */\n rendered?: NotationLayout;\n}\n\nexport interface SvgNotationPlayer {\n /** Resolves once the engraving is in the DOM and ready to draw. `setTime`/\n * click hit-testing are safe to call before this resolves (no-op until\n * ready, same contract as the canvas player). */\n readonly ready: Promise<void>;\n /** Drive the playhead for absolute playback time `tMs`. Caller owns the\n * audio clock + rAF loop. */\n setTime(tMs: number): void;\n /** Re-engrave at a new OSMD zoom (systems reflow). The scroll position is\n * restored afterward so the content that was centered in the viewport\n * before the reflow is still centered after it. */\n setZoom(z: number): Promise<void>;\n /** Re-measure the host and reflow to match its current width, with the\n * same scroll-position preservation as `setZoom`. Call on host resize /\n * orientation change. */\n resize(): Promise<void>;\n /** Register a measure-click handler (measure index, matching\n * `ScoreNote.measure`/the engraved index). Returns an unsubscribe fn. */\n onMeasureClick(cb: (measureIndex: number) => void): () => void;\n /** Tear down: removes the mounted DOM (engraving + playhead overlay) from\n * `host`, and drops every listener this instance added (click, window\n * scroll) and pending async work (a token guard drops any in-flight\n * reflow's effects). Idempotent. */\n destroy(): void;\n}\n\n// ─── svgNotationLayout — the SVG-backend geometry extractor ───────────────\n//\n// UNIT CONVERSION — derived, not guessed (verified against the vendored\n// opensheetmusicdisplay + vexflow source, not just its .d.ts comments, which\n// are stale here — see below):\n//\n// 1. `GraphicalMusicSheet` (`osmd.GraphicSheet`) positions\n// (`PositionAndShape.AbsolutePosition`/`.Size`) are in backend-agnostic\n// \"OSMD units\" — the SAME object model promo.ts's canvas-only\n// `extractGeometry` reads (`osmd.GraphicSheet.MusicPages[0].MusicSystems`,\n// `.MeasureList`). Whichever backend (canvas/svg) was requested, this\n// layer is identical.\n// 2. OSMD's Vexflow draw layer (`VexFlowMusicSheetDrawer`) converts an OSMD\n// unit value to a \"raw\" Vexflow/SVG px value via an EXPORTED constant,\n// `unitInPixels` (currently 10 — NOT `EngravingRules.unit`, which is a\n// different, unrelated field that is NOT the px-per-unit factor despite\n// what its .d.ts comment implies; confirmed by reading the actual\n// compiled source, not trusting the stale doc comment). This raw value\n// is written directly into each SVG element's own coordinate attributes\n// — it does NOT yet include `zoom`.\n// 3. `osmd.Zoom` (current zoom) is applied SEPARATELY, at the SVG-backend\n// level, via a `viewBox` trick (`vexflow/src/svgcontext.js`'s\n// `scale(x,y)`): the `<svg>` element's `width`/`height` ATTRIBUTES are\n// set to the FINAL (zoomed) CSS px size, while its `viewBox` spans\n// `width/zoom .. height/zoom` — i.e. the RAW (unzoomed, step-2) content\n// coordinates. The browser therefore maps that raw coordinate space onto\n// the final CSS px box by exactly `zoom`.\n// Net result: `cssPx = unitValue * unitInPixels * zoom`. Both factors are\n// read from the live library/instance (never a hardcoded literal `10` or an\n// assumed zoom) — see `SvgNotationLayoutOpts.unitInPixels`'s doc — so a\n// future OSMD version changing either is picked up automatically, which is\n// exactly the \"10 units/staff-space assumptions have version drift\" risk\n// the design doc calls out.\n//\n// This mirrors, in spirit, promo.ts's canvas `extractGeometry` self-\n// calibration (`canvas.width / (contentRight+contentLeft)`, chosen there\n// specifically because a naive formula broke on overflowed layouts) — the SVG\n// backend doesn't have that raster-overflow failure mode (there is no\n// backing-store to overflow; the viewBox IS the content, always), so the\n// derived formula above is exact, not an approximation.\n\nexport interface SvgNotationLayoutOpts {\n /** CSS px per OSMD unit at zoom 1 — OSMD's own exported `unitInPixels`\n * constant (see the derivation above). REQUIRED, no default: the point is\n * to FORCE the real call site to source this from the live\n * `opensheetmusicdisplay` import\n * (`const { unitInPixels } = await import('opensheetmusicdisplay')`)\n * rather than this module assuming a value that could drift across OSMD\n * versions. Tests pin it explicitly. */\n unitInPixels: number;\n}\n\nconst EMPTY_LAYOUT: NotationLayout = {\n src: { x: 0, y: 0, w: 0, h: 0 },\n rect: { dx: 0, dy: 0, dw: 0, dh: 0 },\n systems: [],\n measures: [],\n};\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Pure SVG-backend geometry extractor — builds the SAME `NotationLayout`\n * shape the canvas path's `notationLayout()` does (measure column boxes +\n * system rows + a `rect` vertical band), but read directly from OSMD's\n * `GraphicalMusicSheet` in SVG/CSS px space (see the unit-conversion doc\n * above) instead of a rasterized bitmap. Rebuild on every render (zoom /\n * resize / new score) — cheap, pure array/object mapping, no DOM reads.\n *\n * `osmd` is duck-typed `any` — same contract as promo.ts's\n * `extractGeometry(osmd: any, ...)` — so tests can pass a plain fixture\n * object shaped like the minimal slice of a real `OpenSheetMusicDisplay`\n * instance this function reads (`{ Zoom, GraphicSheet: { MusicPages,\n * MeasureList } }`) without needing a real browser OSMD render (see\n * `CreateSvgNotationPlayerOpts.rendered`'s doc for why headless can't do a\n * real one).\n *\n * `rect` spans the FULL engraved page (top-aligned, `dy = 0`) — there is no\n * follow-camera crop in this component (the whole score is always in the\n * DOM; the PAGE scrolls it) — matching the canvas scroll-mode's `flowLayout`\n * in spirit. `vstackAudioPlayheadLine` only reads `rect.dy`/`rect.dh` to\n * clamp the playhead into the drawn band, so this is a correct, minimal\n * `rect` for that consumer.\n */\nexport function svgNotationLayout(osmd: any, opts: SvgNotationLayoutOpts): NotationLayout {\n try {\n const zoom =\n typeof osmd?.Zoom === 'number' && osmd.Zoom > 0\n ? osmd.Zoom\n : typeof osmd?.zoom === 'number' && osmd.zoom > 0\n ? osmd.zoom\n : 1;\n const f = opts.unitInPixels * zoom;\n\n const graphic: any = osmd?.GraphicSheet;\n const page: any = graphic?.MusicPages?.[0];\n const pageSize = page?.PositionAndShape?.Size;\n const musicSystems: any[] = page?.MusicSystems ?? [];\n if (!(pageSize?.width > 0) || !(pageSize?.height > 0) || !musicSystems.length) return EMPTY_LAYOUT;\n\n const toBox = (pas: any): Box | null => {\n const p = pas?.AbsolutePosition;\n const sz = pas?.Size;\n if (!p || !sz) return null;\n return { x: p.x * f, y: p.y * f, w: sz.width * f, h: sz.height * f };\n };\n\n const systems: Box[] = musicSystems\n .map((s) => toBox(s?.PositionAndShape))\n .filter((b): b is Box => !!b && b.w > 1 && b.h > 1)\n .sort((a, b) => a.y - b.y);\n if (!systems.length) return EMPTY_LAYOUT;\n\n const measureList: any[][] = graphic?.MeasureList ?? [];\n const measures: StaffMeasureBox[] = [];\n measureList.forEach((staves, index) => {\n (staves ?? []).forEach((m: any, staff: number) => {\n const box = toBox(m?.PositionAndShape);\n if (box && box.w > 1 && box.h > 1) {\n const seX = (m?.staffEntries ?? [])[0]?.PositionAndShape?.AbsolutePosition?.x;\n const noteStartX = typeof seX === 'number' ? seX * f : box.x;\n measures.push({ index, staff, box, noteStartX });\n }\n });\n });\n\n const dw = pageSize.width * f;\n const dh = pageSize.height * f;\n return {\n src: { x: 0, y: 0, w: dw, h: dh },\n rect: { dx: 0, dy: 0, dw, dh },\n systems,\n measures,\n };\n } catch {\n return EMPTY_LAYOUT;\n }\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n// ─── Zoom/resize position preservation (pure, unit-tested) ────────────────\n\n/**\n * Pure reflow position-preservation math: given the OLD layout (before a\n * `setZoom`/`resize` re-engrave), the NEW layout (after it), and an anchor\n * point `(anchorX, anchorY)` in the OLD layout's coordinate space (typically\n * \"whatever content sat at the vertical center of the viewport\" — see the\n * call site), return the vertical delta (new px minus old px) to add to the\n * window's scroll position so that SAME content stays in the SAME on-screen\n * position across the reflow.\n *\n * Deliberately NOT playhead interpolation: it's a one-shot \"where did this\n * content move to\" lookup built from two existing, reused primitives —\n * `hitTestMeasureAt` (which measure box contains/is nearest the anchor) and\n * `measureColumnsFromLayout` (that same measure's box in each layout) — plus\n * a linear fraction-within-the-box preservation so an anchor near the bottom\n * of a tall measure box stays near the bottom after reflow, not snapped to\n * the box's top edge. Returns 0 when the anchor measure can't be resolved in\n * either layout (e.g. an empty layout) — a safe no-op scroll.\n */\nexport function computeReflowScrollDelta(\n oldLayout: NotationLayout,\n newLayout: NotationLayout,\n anchorX: number,\n anchorY: number,\n): number {\n const idx = hitTestMeasureAt(oldLayout, anchorX, anchorY);\n if (idx == null) return 0;\n\n const oldIndices = [...new Set(oldLayout.measures.map((m) => m.index))].sort((a, b) => a - b);\n const newIndices = [...new Set(newLayout.measures.map((m) => m.index))].sort((a, b) => a - b);\n const oi = oldIndices.indexOf(idx);\n const ni = newIndices.indexOf(idx);\n if (oi < 0 || ni < 0) return 0;\n\n const oldCols = measureColumnsFromLayout(oldLayout.measures);\n const newCols = measureColumnsFromLayout(newLayout.measures);\n const oldBox = oldCols[oi];\n const newBox = newCols[ni];\n if (!oldBox || !newBox) return 0;\n\n const fracY = oldBox.h > 0 ? (anchorY - oldBox.y) / oldBox.h : 0;\n const newAnchorY = newBox.y + fracY * newBox.h;\n return newAnchorY - anchorY;\n}\n\n// ─── Auto-follow discriminator (design doc §4) ─────────────────────────────\n//\n// The canvas scroll-mode player (notationPlayer.ts's `createScrollPlayer`)\n// discriminates \"our own programmatic scroll\" from \"a manual user scroll\" via\n// a fixed 600ms grace window after every `scrollIntoView` call. That has a\n// real failure mode (flagged in the canvas module's own review): a\n// longer-than-600ms smooth-scroll animation's LATER frames land after the\n// window closes and get misread as manual, suspending auto-follow mid-\n// animation; conversely a genuinely fast manual scroll DURING the window can\n// slip through unsuspended.\n//\n// Fix: compare against the EXACT target position this component itself\n// requested, not elapsed time. We control the scroll call ourselves\n// (`window.scrollTo({top, behavior:'smooth'})`, not `element.scrollIntoView`,\n// specifically so we know the target precisely) — every intermediate frame of\n// OUR OWN smooth-scroll animation reports a `window.scrollY` somewhere on the\n// straight line between where we started and where we're headed; it can never\n// overshoot or reverse past that. A scroll event reporting a position OUTSIDE\n// that span can therefore only be a manual scroll, and is classified as such\n// immediately, independent of animation duration.\n\n/** Tolerance, px, for \"close enough\" to count as the same position (float/\n * sub-pixel scroll settling noise). */\nexport const PROGRAMMATIC_SCROLL_EPSILON_PX = 2;\n\n/**\n * True while `y` lies within `[min(start,target), max(start,target)]`\n * (± `epsilon`) — i.e. anywhere along the straight-line path of a\n * `window.scrollTo({top: target, behavior:'smooth'})` call issued from\n * `start`. A scroll event reporting a position outside this span cannot be a\n * frame of that animation.\n */\nexport function isWithinProgrammaticScroll(\n y: number,\n start: number,\n target: number,\n epsilon: number = PROGRAMMATIC_SCROLL_EPSILON_PX,\n): boolean {\n const lo = Math.min(start, target) - epsilon;\n const hi = Math.max(start, target) + epsilon;\n return y >= lo && y <= hi;\n}\n\n/** True once `y` has settled at (within `epsilon` of) the programmatic\n * scroll's target — the animation is complete, so tracking can be cleared. */\nexport function hasReachedProgrammaticTarget(\n y: number,\n target: number,\n epsilon: number = PROGRAMMATIC_SCROLL_EPSILON_PX,\n): boolean {\n return Math.abs(y - target) <= epsilon;\n}\n\n// ─── createSvgNotationPlayer ────────────────────────────────────────────────\n\nconst DEFAULT_PLAYHEAD_COLOR = '#2f6f4f';\n/** Engrave-width ceiling, CSS px (design doc §\"Render\": \"cap ~1200px, the\n * 0.36.2 rule\" — the same reasoning as notationPlayer.ts's\n * `MAX_ENGRAVE_WIDTH`, restated here rather than imported since the two\n * players' constants are independently tunable, and this one is spec'd to a\n * slightly different value). */\nexport const MAX_ENGRAVE_WIDTH_SVG = 1200;\n/** Floor so a not-yet-laid-out / zero-width host never engraves at 0px. */\nconst MIN_ENGRAVE_WIDTH_SVG = 280;\n/** Same re-arm rule as the canvas scroll player's discontinuity detector —\n * control-flow bookkeeping (not playhead/geometry math), copied verbatim. */\nconst SEEK_DISCONTINUITY_MS = 400;\n\nfunction nowMs(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n\n/** Build a live, interactive SVG (vector) notation player. See the module doc\n * + `docs/superpowers/specs/2026-08-11-svg-notation-player-design.md` (in\n * stave-web-sightread) for the full design. */\nexport function createSvgNotationPlayer(opts: CreateSvgNotationPlayerOpts): SvgNotationPlayer {\n const { host, musicXml, onsetsMs, noteCols } = opts;\n const playheadColor = opts.playheadColor ?? DEFAULT_PLAYHEAD_COLOR;\n const onsets = distinctOnsets(onsetsMs.map((onsetMs) => ({ onsetMs })));\n\n const root = document.createElement('div');\n root.style.position = 'relative';\n root.style.width = '100%';\n // Let the browser's native pinch-zoom AND vertical page-scroll gestures\n // through — the \"optical zoom is free\" half of the design (§5): vectors\n // stay crisp at any pinch/browser-zoom level, and this component adds\n // nothing to make that work beyond not blocking the gesture.\n root.style.touchAction = 'pan-y pinch-zoom';\n host.appendChild(root);\n\n const svgHost = document.createElement('div');\n root.appendChild(svgHost);\n\n const playheadEl = document.createElement('div');\n playheadEl.style.position = 'absolute';\n playheadEl.style.left = '0px';\n playheadEl.style.top = '0px';\n playheadEl.style.width = '2px';\n playheadEl.style.height = '0px';\n playheadEl.style.background = playheadColor;\n playheadEl.style.opacity = '0';\n playheadEl.style.pointerEvents = 'none';\n root.appendChild(playheadEl);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let osmd: any = null;\n let currentLayout: NotationLayout | null = null;\n let currentZoom = opts.zoom ?? 1;\n let unitInPixelsConst = 10; // overwritten by the real import before first use (rendered-seam path never reads it)\n let lastEngravedWidthPx = 0;\n let destroyed = false;\n let lastTMs = 0;\n // Stale-table guard (design doc §\"Known risks\" — \"Overlay drift on\n // reflow\"): each async re-engrave captures its own token; if a NEWER\n // reflow starts before an older one's `await` resolves, the older one's\n // completion is a no-op instead of clobbering the newer geometry.\n let rebuildToken = 0;\n\n function desiredEngraveWidthPx(): number {\n const w = host.clientWidth || 0;\n return Math.max(MIN_ENGRAVE_WIDTH_SVG, Math.min(w || MAX_ENGRAVE_WIDTH_SVG, MAX_ENGRAVE_WIDTH_SVG));\n }\n\n // ─── Playhead ──────────────────────────────────────────────────────────\n\n function renderPlayhead(tMs: number): void {\n lastTMs = tMs;\n if (!currentLayout) return;\n const nBars = currentLayout.measures.length\n ? Math.max(...currentLayout.measures.map((m) => m.index)) + 1\n : 0;\n const line = vstackAudioPlayheadLine(currentLayout, onsets, tMs, nBars, noteCols);\n if (!line) {\n playheadEl.style.opacity = '0';\n return;\n }\n playheadEl.style.opacity = String(line.alpha);\n playheadEl.style.left = `${line.x}px`;\n playheadEl.style.top = `${line.y0}px`;\n playheadEl.style.height = `${Math.max(0, line.y1 - line.y0)}px`;\n maybeAutoFollow();\n }\n\n // ─── Auto-follow (target-position discriminator — see the module doc) ────\n\n let autoFollowSuspended = false;\n let programmaticStart: number | null = null;\n let programmaticTarget: number | null = null;\n let followRafPending = false;\n let lastWallMs: number | null = null;\n let lastMusicMs = 0;\n\n function onWindowScroll(): void {\n if (programmaticTarget != null && programmaticStart != null) {\n const y = window.scrollY;\n if (isWithinProgrammaticScroll(y, programmaticStart, programmaticTarget)) {\n if (hasReachedProgrammaticTarget(y, programmaticTarget)) {\n programmaticStart = null;\n programmaticTarget = null;\n }\n return; // still (or just finished) our own scroll — don't suspend\n }\n }\n autoFollowSuspended = true;\n programmaticStart = null;\n programmaticTarget = null;\n }\n const hasWindow = typeof window !== 'undefined' && typeof window.addEventListener === 'function';\n if (hasWindow) window.addEventListener('scroll', onWindowScroll, { passive: true });\n\n function detectDiscontinuity(tMs: number): void {\n const now = nowMs();\n if (lastWallMs != null) {\n const dtMusic = tMs - lastMusicMs;\n const dtWall = now - lastWallMs;\n if (dtMusic < 0 || Math.abs(dtMusic - dtWall) > SEEK_DISCONTINUITY_MS) autoFollowSuspended = false;\n } else {\n autoFollowSuspended = false;\n }\n lastWallMs = now;\n lastMusicMs = tMs;\n }\n\n function maybeAutoFollow(): void {\n if (autoFollowSuspended || followRafPending) return;\n if (typeof window === 'undefined' || typeof window.requestAnimationFrame !== 'function') return;\n followRafPending = true;\n window.requestAnimationFrame(() => {\n followRafPending = false;\n if (destroyed || autoFollowSuspended) return;\n if (typeof playheadEl.getBoundingClientRect !== 'function') return;\n const rect = playheadEl.getBoundingClientRect();\n const vh = window.innerHeight;\n if (!(vh > 0)) return;\n if (rect.top >= vh * 0.25 && rect.top <= vh * 0.75) return; // comfortably in view\n const start = window.scrollY;\n const target = Math.max(0, start + rect.top - vh / 2);\n programmaticStart = start;\n programmaticTarget = target;\n window.scrollTo({ top: target, left: window.scrollX, behavior: 'smooth' });\n });\n }\n\n // ─── setTime ───────────────────────────────────────────────────────────\n\n function setTime(tMs: number): void {\n if (destroyed) return;\n detectDiscontinuity(tMs);\n renderPlayhead(tMs);\n }\n\n // ─── Engrave / reflow ──────────────────────────────────────────────────\n\n async function initialEngrave(): Promise<void> {\n if (opts.rendered) {\n currentLayout = opts.rendered;\n lastEngravedWidthPx = desiredEngraveWidthPx();\n renderPlayhead(lastTMs);\n return;\n }\n // Literal dynamic import — consumers' bundlers must statically see the\n // specifier (same reasoning as promo.ts/notationPlayer.ts); a caller\n // that only ever uses the `rendered` test seam never pulls OSMD in.\n const { OpenSheetMusicDisplay, unitInPixels } = await import('opensheetmusicdisplay');\n unitInPixelsConst = unitInPixels;\n if (destroyed) return;\n\n const widthPx = desiredEngraveWidthPx();\n svgHost.style.width = `${widthPx}px`;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const inst: any = new OpenSheetMusicDisplay(svgHost, {\n backend: 'svg',\n autoResize: false,\n drawTitle: false,\n drawSubtitle: false,\n drawComposer: false,\n drawLyricist: false,\n drawPartNames: false,\n });\n await inst.load(musicXml);\n if (destroyed) return;\n inst.Zoom = currentZoom;\n inst.render();\n if (destroyed) return;\n\n osmd = inst;\n lastEngravedWidthPx = widthPx;\n currentLayout = svgNotationLayout(inst, { unitInPixels: unitInPixelsConst });\n renderPlayhead(lastTMs);\n }\n\n const ready = initialEngrave();\n\n /** Re-engrave at `newZoom` and the host's CURRENT width, preserving the\n * scroll position of whatever content is centered in the viewport right\n * now. Shared by both `setZoom` and `resize` (resize just passes the\n * unchanged `currentZoom`). No-op when neither the width nor the zoom\n * actually changed, or when using the `rendered` test seam (nothing to\n * re-engrave). */\n async function reflow(newZoom: number): Promise<void> {\n if (destroyed) return;\n const widthPx = desiredEngraveWidthPx();\n if (widthPx === lastEngravedWidthPx && newZoom === currentZoom) return;\n if (opts.rendered || !osmd) {\n currentZoom = newZoom;\n return;\n }\n\n const myToken = ++rebuildToken;\n const oldLayout = currentLayout;\n const hasWin = typeof window !== 'undefined';\n let anchorY: number | null = null;\n const anchorX = widthPx / 2;\n if (hasWin && typeof root.getBoundingClientRect === 'function') {\n const r = root.getBoundingClientRect();\n anchorY = window.innerHeight / 2 - r.top;\n }\n\n svgHost.style.width = `${widthPx}px`;\n osmd.Zoom = newZoom;\n // Re-run layout (not just a redraw): a width change must re-flow which\n // measures land on which system, and — since we can't be certain a pure\n // zoom change never affects line-breaking on every OSMD version — this is\n // called unconditionally rather than gated to the width-only case.\n osmd.updateGraphic();\n osmd.render();\n if (destroyed || myToken !== rebuildToken) return;\n\n lastEngravedWidthPx = widthPx;\n currentZoom = newZoom;\n currentLayout = svgNotationLayout(osmd, { unitInPixels: unitInPixelsConst });\n\n if (oldLayout && anchorY != null && hasWin) {\n const delta = computeReflowScrollDelta(oldLayout, currentLayout, anchorX, anchorY);\n if (Number.isFinite(delta) && Math.abs(delta) > 0.5) {\n window.scrollTo({ top: Math.max(0, window.scrollY + delta), left: window.scrollX, behavior: 'auto' });\n }\n }\n if (!destroyed) renderPlayhead(lastTMs);\n }\n\n // ─── Click-to-seek ─────────────────────────────────────────────────────\n\n const clickListeners: Array<(measureIndex: number) => void> = [];\n function onRootClick(e: MouseEvent): void {\n if (!currentLayout) return;\n const rect = root.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n const idx = hitTestMeasureAt(currentLayout, mx, my);\n if (idx != null) for (const cb of clickListeners) cb(idx);\n }\n root.addEventListener('click', onRootClick);\n\n return {\n ready,\n setTime,\n async setZoom(z: number): Promise<void> {\n await ready;\n await reflow(z);\n },\n async resize(): Promise<void> {\n await ready;\n await reflow(currentZoom);\n },\n onMeasureClick(cb: (measureIndex: number) => void): () => void {\n clickListeners.push(cb);\n return () => {\n const i = clickListeners.indexOf(cb);\n if (i >= 0) clickListeners.splice(i, 1);\n };\n },\n destroy(): void {\n if (destroyed) return;\n destroyed = true;\n rebuildToken++;\n root.removeEventListener('click', onRootClick);\n if (hasWindow) window.removeEventListener('scroll', onWindowScroll);\n clickListeners.length = 0;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n try { (osmd as any)?.clear?.(); } catch { /* best-effort */ }\n osmd = null;\n currentLayout = null;\n if (root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IACF;AAAA,IACA,UAAgB;AACd,UAAI,UAAW;AACf,kBAAY;AACZ;AACA,WAAK,oBAAoB,SAAS,WAAW;AAC7C,UAAI,UAAW,QAAO,oBAAoB,UAAU,cAAc;AAClE,qBAAe,SAAS;AAExB,UAAI;AAAE,QAAC,MAAc,QAAQ;AAAA,MAAG,QAAQ;AAAA,MAAoB;AAC5D,aAAO;AACP,sBAAgB;AAChB,UAAI,KAAK,eAAe,KAAM,MAAK,YAAY,IAAI;AAAA,IACrD;AAAA,EACF;AACF;","names":[]}
@@ -2,8 +2,8 @@ import { A as AudioClock, S as Score, a as LayerFactory, R as RenderCtx, b as Sc
2
2
  export { L as Layer, d as SpectrumInput, e as SpectrumProps, W as WaveformInput, f as WaveformProps, s as scoreFromMusicXML, g as spectrumFactory, w as waveformFactory } from '../waveform-DdSMAbYQ.js';
3
3
  import { PromoTheme, RecordOpts, Scene, SafeBox } from '../video.js';
4
4
  import { RenderedNotation, Box } from '../promo.js';
5
- import { N as NotationLayout } from '../notationGeometry-CyYXJrUH.js';
6
- export { F as FOLLOW_BARS, a as FOLLOW_PAD, b as NotationLayoutOpts, c as NotationRect, P as PlayheadLine, d as audioPlayheadLine, e as cropAroundBox, f as cubicEaseInOut, g as distinctMeasureIndices, h as distinctOnsets, i as firstMeasureBox, j as followBoxAt, k as followWindowStart, l as lerpBox, m as measureColumnsFromLayout, n as measureCount, o as measureSpanBox, p as measureSystemMap, q as notationLayout, r as playheadLine, s as systemBox, v as vstackAudioPlayheadLine, t as vstackFollowBox } from '../notationGeometry-CyYXJrUH.js';
5
+ import { N as NotationLayout } from '../notationGeometry-54fFq5yU.js';
6
+ export { F as FOLLOW_BARS, a as FOLLOW_PAD, b as NotationLayoutOpts, c as NotationRect, P as PlayheadLine, d as audioPlayheadLine, e as cropAroundBox, f as cubicEaseInOut, g as distinctMeasureIndices, h as distinctOnsets, i as firstMeasureBox, j as followBoxAt, k as followWindowStart, m as lerpBox, n as measureColumnsFromLayout, o as measureCount, p as measureSpanBox, q as measureSystemMap, r as notationLayout, s as playheadLine, t as systemBox, v as vstackAudioPlayheadLine, u as vstackFollowBox } from '../notationGeometry-54fFq5yU.js';
7
7
 
8
8
  /** One scheduled audio event, in seconds RELATIVE to the schedule start. */
9
9
  interface AudioEvent {
@@ -9,6 +9,13 @@ import {
9
9
  noteNameToIndex,
10
10
  pitchClass
11
11
  } from "../chunk-GORQ5YMR.js";
12
+ import {
13
+ getNotationEngraving,
14
+ notationFactory,
15
+ scrollCursorFactory,
16
+ setFollowLayoutProvider,
17
+ setNotationEngraving
18
+ } from "../chunk-QGKDKXX2.js";
12
19
  import {
13
20
  FOLLOW_BARS,
14
21
  FOLLOW_PAD,
@@ -20,22 +27,17 @@ import {
20
27
  firstMeasureBox,
21
28
  followBoxAt,
22
29
  followWindowStart,
23
- getNotationEngraving,
24
30
  lerpBox,
25
31
  measureColumnsFromLayout,
26
32
  measureCount,
27
33
  measureSpanBox,
28
34
  measureSystemMap,
29
- notationFactory,
30
35
  notationLayout,
31
36
  playheadLine,
32
- scrollCursorFactory,
33
- setFollowLayoutProvider,
34
- setNotationEngraving,
35
37
  systemBox,
36
38
  vstackAudioPlayheadLine,
37
39
  vstackFollowBox
38
- } from "../chunk-4565POLG.js";
40
+ } from "../chunk-BHRDISMU.js";
39
41
  import {
40
42
  ctaScene,
41
43
  drawSafeGuides,