vexflow-native 2.3.1 → 2.5.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/README.md +7 -1
- package/lib/module/base/FontManager.js +41 -27
- package/lib/module/base/FontManager.js.map +1 -1
- package/lib/module/base/VexflowCanvas.js +8 -6
- package/lib/module/base/VexflowCanvas.js.map +1 -1
- package/lib/module/base/VexflowRecordingClone.js +83 -0
- package/lib/module/base/VexflowRecordingClone.js.map +1 -0
- package/lib/module/base/VexflowRecordingContext.js +1 -80
- package/lib/module/base/VexflowRecordingContext.js.map +1 -1
- package/lib/module/base/builtInTextFont.js +21 -0
- package/lib/module/base/builtInTextFont.js.map +1 -0
- package/lib/module/base/cssFontShorthand.js +34 -0
- package/lib/module/base/cssFontShorthand.js.map +1 -0
- package/lib/module/base/fonts/OFL.txt +93 -0
- package/lib/module/base/fonts/academico.js +12 -0
- package/lib/module/base/fonts/academico.js.map +1 -0
- package/lib/module/base/pictureRetirement.js +70 -0
- package/lib/module/base/pictureRetirement.js.map +1 -0
- package/lib/module/base/setupVexflowReactNative.js +1 -36
- package/lib/module/base/setupVexflowReactNative.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/MeasureParser.js +22 -119
- package/lib/module/musicxml/MusicXmlParser/MeasureParser.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/MusicXmlNotes.js +129 -0
- package/lib/module/musicxml/MusicXmlParser/MusicXmlNotes.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/PartParser.js +8 -1
- package/lib/module/musicxml/MusicXmlParser/PartParser.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/Spanners.js +8 -5
- package/lib/module/musicxml/MusicXmlParser/Spanners.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/mappers.js +83 -3
- package/lib/module/musicxml/MusicXmlParser/mappers.js.map +1 -1
- package/lib/module/renderer/Layout/DocumentLayout.js +13 -4
- package/lib/module/renderer/Layout/DocumentLayout.js.map +1 -1
- package/lib/module/renderer/Layout/VerticalSpacing.js +37 -7
- package/lib/module/renderer/Layout/VerticalSpacing.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js +80 -46
- package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +10 -22
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/ScoreScrollbar.js +18 -8
- package/lib/module/renderer/ScoreRenderer/ScoreScrollbar.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/utils.js +42 -88
- package/lib/module/renderer/ScoreRenderer/utils.js.map +1 -1
- package/lib/module/renderer/constants.js +1 -1
- package/lib/module/renderer/layout.js +11 -4
- package/lib/module/renderer/layout.js.map +1 -1
- package/lib/module/renderer/lyrics.js +127 -0
- package/lib/module/renderer/lyrics.js.map +1 -0
- package/lib/module/renderer/measure.js +52 -13
- package/lib/module/renderer/measure.js.map +1 -1
- package/lib/module/renderer/measureBounds.js +5 -0
- package/lib/module/renderer/measureBounds.js.map +1 -1
- package/lib/module/renderer/measureModifiers.js +24 -6
- package/lib/module/renderer/measureModifiers.js.map +1 -1
- package/lib/module/renderer/noteModifiers.js +6 -14
- package/lib/module/renderer/noteModifiers.js.map +1 -1
- package/lib/module/renderer/{fixedNoteSpacing.js → noteSpacing.js} +46 -10
- package/lib/module/renderer/noteSpacing.js.map +1 -0
- package/lib/module/renderer/render.js +41 -21
- package/lib/module/renderer/render.js.map +1 -1
- package/lib/module/renderer/scale.js +8 -1
- package/lib/module/renderer/scale.js.map +1 -1
- package/lib/module/renderer/tempoMark.js +162 -0
- package/lib/module/renderer/tempoMark.js.map +1 -0
- package/lib/module/renderer/useScoreRecording.js +2 -1
- package/lib/module/renderer/useScoreRecording.js.map +1 -1
- package/lib/typescript/src/base/FontManager.d.ts +12 -7
- package/lib/typescript/src/base/FontManager.d.ts.map +1 -1
- package/lib/typescript/src/base/VexflowCanvas.d.ts.map +1 -1
- package/lib/typescript/src/base/VexflowRecordingClone.d.ts +8 -0
- package/lib/typescript/src/base/VexflowRecordingClone.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -1
- package/lib/typescript/src/base/builtInTextFont.d.ts +6 -0
- package/lib/typescript/src/base/builtInTextFont.d.ts.map +1 -0
- package/lib/typescript/src/base/cssFontShorthand.d.ts +3 -0
- package/lib/typescript/src/base/cssFontShorthand.d.ts.map +1 -0
- package/lib/typescript/src/base/fonts/academico.d.ts +5 -0
- package/lib/typescript/src/base/fonts/academico.d.ts.map +1 -0
- package/lib/typescript/src/base/pictureRetirement.d.ts +26 -0
- package/lib/typescript/src/base/pictureRetirement.d.ts.map +1 -0
- package/lib/typescript/src/base/setupVexflowReactNative.d.ts +0 -8
- package/lib/typescript/src/base/setupVexflowReactNative.d.ts.map +1 -1
- package/lib/typescript/src/base/types.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts +4 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlNotes.d.ts +13 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlNotes.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/PartParser.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts +6 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts +7 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts.map +1 -1
- package/lib/typescript/src/renderer/Layout/DocumentLayout.d.ts.map +1 -1
- package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts +6 -0
- package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreScrollbar.d.ts +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreScrollbar.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +14 -11
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts +8 -27
- package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts.map +1 -1
- package/lib/typescript/src/renderer/layout.d.ts +5 -1
- package/lib/typescript/src/renderer/layout.d.ts.map +1 -1
- package/lib/typescript/src/renderer/lyrics.d.ts +42 -0
- package/lib/typescript/src/renderer/lyrics.d.ts.map +1 -0
- package/lib/typescript/src/renderer/measure.d.ts +7 -2
- package/lib/typescript/src/renderer/measure.d.ts.map +1 -1
- package/lib/typescript/src/renderer/measureBounds.d.ts +3 -0
- package/lib/typescript/src/renderer/measureBounds.d.ts.map +1 -1
- package/lib/typescript/src/renderer/measureModifiers.d.ts +14 -4
- package/lib/typescript/src/renderer/measureModifiers.d.ts.map +1 -1
- package/lib/typescript/src/renderer/noteModifiers.d.ts +3 -2
- package/lib/typescript/src/renderer/noteModifiers.d.ts.map +1 -1
- package/lib/typescript/src/renderer/{fixedNoteSpacing.d.ts → noteSpacing.d.ts} +9 -1
- package/lib/typescript/src/renderer/noteSpacing.d.ts.map +1 -0
- package/lib/typescript/src/renderer/render.d.ts.map +1 -1
- package/lib/typescript/src/renderer/scale.d.ts.map +1 -1
- package/lib/typescript/src/renderer/tempoMark.d.ts +21 -0
- package/lib/typescript/src/renderer/tempoMark.d.ts.map +1 -0
- package/lib/typescript/src/renderer/types.d.ts +31 -7
- package/lib/typescript/src/renderer/types.d.ts.map +1 -1
- package/lib/typescript/src/state/types.d.ts +11 -3
- package/lib/typescript/src/state/types.d.ts.map +1 -1
- package/package.json +34 -26
- package/src/base/FontManager.ts +50 -31
- package/src/base/VexflowCanvas.tsx +10 -10
- package/src/base/VexflowRecordingClone.ts +89 -0
- package/src/base/VexflowRecordingContext.ts +8 -81
- package/src/base/builtInTextFont.ts +25 -0
- package/src/base/cssFontShorthand.ts +45 -0
- package/src/base/fonts/OFL.txt +93 -0
- package/src/base/fonts/academico.ts +10 -0
- package/src/base/pictureRetirement.ts +74 -0
- package/src/base/setupVexflowReactNative.ts +1 -49
- package/src/base/types.ts +0 -3
- package/src/musicxml/MusicXmlParser/InternalTypes.ts +5 -0
- package/src/musicxml/MusicXmlParser/MeasureParser.ts +31 -182
- package/src/musicxml/MusicXmlParser/MusicXmlNotes.ts +198 -0
- package/src/musicxml/MusicXmlParser/PartParser.ts +10 -3
- package/src/musicxml/MusicXmlParser/Spanners.ts +11 -8
- package/src/musicxml/MusicXmlParser/mappers.ts +55 -6
- package/src/renderer/Layout/DocumentLayout.ts +12 -3
- package/src/renderer/Layout/VerticalSpacing.ts +46 -13
- package/src/renderer/ScoreRenderer/ScoreOverlayPicture.tsx +127 -66
- package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +8 -23
- package/src/renderer/ScoreRenderer/ScoreScrollbar.tsx +16 -2
- package/src/renderer/ScoreRenderer/types.ts +14 -12
- package/src/renderer/ScoreRenderer/utils.ts +54 -125
- package/src/renderer/constants.ts +1 -1
- package/src/renderer/layout.ts +19 -4
- package/src/renderer/lyrics.ts +163 -0
- package/src/renderer/measure.tsx +70 -12
- package/src/renderer/measureBounds.ts +10 -0
- package/src/renderer/measureModifiers.ts +27 -7
- package/src/renderer/noteModifiers.ts +9 -10
- package/src/renderer/{fixedNoteSpacing.ts → noteSpacing.ts} +60 -9
- package/src/renderer/render.tsx +63 -27
- package/src/renderer/scale.ts +9 -0
- package/src/renderer/tempoMark.ts +224 -0
- package/src/renderer/types.ts +32 -7
- package/src/renderer/useScoreRecording.ts +1 -0
- package/src/state/types.ts +11 -3
- package/lib/module/renderer/fixedNoteSpacing.js.map +0 -1
- package/lib/module/utils.js +0 -44
- package/lib/module/utils.js.map +0 -1
- package/lib/typescript/src/renderer/fixedNoteSpacing.d.ts.map +0 -1
- package/lib/typescript/src/utils.d.ts +0 -1
- package/lib/typescript/src/utils.d.ts.map +0 -1
- package/src/utils.tsx +0 -42
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Skia } from 'react-native-skia';
|
|
4
|
-
import FontManager from "../../base/FontManager.js";
|
|
5
4
|
import { renderVexflowRecordingCommands } from "../../base/VexflowRecordingReplay.js";
|
|
6
5
|
import { isVexflowNativeDebugEnabled } from "../../shared/debug.js";
|
|
7
6
|
import { insets, renderOptions, spacing } from "../constants.js";
|
|
8
7
|
import { createVisibleViewport } from "../viewport.js";
|
|
9
|
-
// The
|
|
10
|
-
// non-hoisted assignments, so
|
|
11
|
-
// that call it.
|
|
8
|
+
// The worklets plugin rewrites 'worklet' function declarations into
|
|
9
|
+
// non-hoisted assignments, so a worklet must precede the worklets calling it.
|
|
12
10
|
export function nowMsWorklet() {
|
|
13
11
|
'worklet';
|
|
14
12
|
|
|
@@ -18,6 +16,8 @@ function nowMs() {
|
|
|
18
16
|
return globalThis.performance?.now?.() ?? Date.now();
|
|
19
17
|
}
|
|
20
18
|
function roundMs(value) {
|
|
19
|
+
'worklet';
|
|
20
|
+
|
|
21
21
|
return Math.round(value * 10) / 10;
|
|
22
22
|
}
|
|
23
23
|
export function withDefaultOptions(options) {
|
|
@@ -42,6 +42,7 @@ export function createScorePicture({
|
|
|
42
42
|
fontManager,
|
|
43
43
|
recordedCommands,
|
|
44
44
|
replayFontManager,
|
|
45
|
+
scoreId,
|
|
45
46
|
styleOverrides
|
|
46
47
|
}) {
|
|
47
48
|
try {
|
|
@@ -52,12 +53,14 @@ export function createScorePicture({
|
|
|
52
53
|
fontManager,
|
|
53
54
|
recordedCommands,
|
|
54
55
|
replayFontManager,
|
|
56
|
+
scoreId,
|
|
55
57
|
styleOverrides
|
|
56
58
|
});
|
|
57
59
|
logScorePictureProfile({
|
|
58
60
|
commandCount: recordedCommands.length,
|
|
59
61
|
contentSize,
|
|
60
|
-
durationMs: nowMs() - start
|
|
62
|
+
durationMs: nowMs() - start,
|
|
63
|
+
scoreId
|
|
61
64
|
});
|
|
62
65
|
return picture;
|
|
63
66
|
} catch (error) {
|
|
@@ -103,19 +106,6 @@ export function createPictureTransform(scrollOffset, rendererType, viewport, con
|
|
|
103
106
|
}
|
|
104
107
|
return transform;
|
|
105
108
|
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Runtime-local lazy FontManager: worklets cannot copy a class instance into
|
|
109
|
-
* a closure, so each runtime constructs its own on first use and keeps it in
|
|
110
|
-
* the slot (slot contents never cross runtimes; only the initial `null` is
|
|
111
|
-
* serialized).
|
|
112
|
-
*/
|
|
113
|
-
export function getOverlayFontManager(slot, fontProvider, defaultFont) {
|
|
114
|
-
'worklet';
|
|
115
|
-
|
|
116
|
-
const state = slot.value;
|
|
117
|
-
return state.manager ??= new FontManager(fontProvider, defaultFont);
|
|
118
|
-
}
|
|
119
109
|
let emptyOverlayPicture = null;
|
|
120
110
|
|
|
121
111
|
/**
|
|
@@ -131,93 +121,57 @@ export function getEmptyOverlayPicture() {
|
|
|
131
121
|
}
|
|
132
122
|
return emptyOverlayPicture;
|
|
133
123
|
}
|
|
124
|
+
export const EMPTY_OVERLAY_PROFILE = {
|
|
125
|
+
windowStartMs: null,
|
|
126
|
+
count: 0,
|
|
127
|
+
totalMs: 0,
|
|
128
|
+
maxMs: 0,
|
|
129
|
+
commandCount: 0
|
|
130
|
+
};
|
|
134
131
|
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
-
* asynchronously, so a retiring picture may still be referenced by the
|
|
138
|
-
* committed Picture node or a commit in flight. Only pictures two
|
|
139
|
-
* supersessions old are disposed. `next === null` marks a frame without an
|
|
140
|
-
* owned picture (none, or the shared blank one), which never enters the ring.
|
|
141
|
-
*/
|
|
142
|
-
export function retirePicture(state, next) {
|
|
143
|
-
'worklet';
|
|
144
|
-
|
|
145
|
-
if (state.prev === next) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (state.prev != null) {
|
|
149
|
-
state.pending.push(state.prev);
|
|
150
|
-
while (state.pending.length > 2) {
|
|
151
|
-
state.pending.shift()?.dispose();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
state.prev = next;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** Disposes the superseded pictures only; the current one stays alive. */
|
|
158
|
-
export function disposeRetiredPictures(state) {
|
|
159
|
-
'worklet';
|
|
160
|
-
|
|
161
|
-
for (const pending of state.pending) {
|
|
162
|
-
pending.dispose();
|
|
163
|
-
}
|
|
164
|
-
state.pending.length = 0;
|
|
165
|
-
}
|
|
166
|
-
export function disposePictures(state) {
|
|
167
|
-
'worklet';
|
|
168
|
-
|
|
169
|
-
disposeRetiredPictures(state);
|
|
170
|
-
state.prev?.dispose();
|
|
171
|
-
state.prev = null;
|
|
172
|
-
}
|
|
173
|
-
export function retireOverlayPicture(disposal, next) {
|
|
132
|
+
/** Logs a non-empty profile window and starts a new one. */
|
|
133
|
+
export function flushOverlayProfile(state, scoreId) {
|
|
174
134
|
'worklet';
|
|
175
135
|
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
// here would never be seen by the UI runtime, so skip tracking entirely
|
|
179
|
-
// (leaks at most one picture per mapper re-creation).
|
|
180
|
-
return;
|
|
136
|
+
if (state.count === 0) {
|
|
137
|
+
return state;
|
|
181
138
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
139
|
+
console.info('[ScoreRenderer] overlay profile', {
|
|
140
|
+
scoreId,
|
|
141
|
+
commandCount: state.commandCount,
|
|
142
|
+
count: state.count,
|
|
143
|
+
totalMs: roundMs(state.totalMs),
|
|
144
|
+
meanMs: roundMs(state.totalMs / state.count),
|
|
145
|
+
maxMs: roundMs(state.maxMs)
|
|
146
|
+
});
|
|
147
|
+
return EMPTY_OVERLAY_PROFILE;
|
|
188
148
|
}
|
|
189
149
|
|
|
190
|
-
/** Throttled (≤1/s)
|
|
191
|
-
export function
|
|
150
|
+
/** Throttled (≤1/s) record timing; the window opens at its first sample. */
|
|
151
|
+
export function addOverlayProfileSample(state, scoreId, commandCount, durationMs, atMs) {
|
|
192
152
|
'worklet';
|
|
193
153
|
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
console.info('[ScoreRenderer] overlay profile', {
|
|
204
|
-
commandCount,
|
|
205
|
-
maxMs: Math.round(stats.maxMs * 10) / 10,
|
|
206
|
-
count: stats.count
|
|
207
|
-
});
|
|
208
|
-
stats.windowStartMs = now;
|
|
209
|
-
stats.maxMs = 0;
|
|
210
|
-
stats.count = 0;
|
|
154
|
+
const windowStartMs = state.windowStartMs ?? atMs;
|
|
155
|
+
const next = {
|
|
156
|
+
windowStartMs,
|
|
157
|
+
count: state.count + 1,
|
|
158
|
+
totalMs: state.totalMs + durationMs,
|
|
159
|
+
maxMs: Math.max(state.maxMs, durationMs),
|
|
160
|
+
commandCount
|
|
161
|
+
};
|
|
162
|
+
return atMs - windowStartMs < 1000 ? next : flushOverlayProfile(next, scoreId);
|
|
211
163
|
}
|
|
212
164
|
function logScorePictureProfile({
|
|
213
165
|
commandCount,
|
|
214
166
|
contentSize,
|
|
215
|
-
durationMs
|
|
167
|
+
durationMs,
|
|
168
|
+
scoreId
|
|
216
169
|
}) {
|
|
217
170
|
if (!isVexflowNativeDebugEnabled()) {
|
|
218
171
|
return;
|
|
219
172
|
}
|
|
220
173
|
console.info('[ScoreRenderer] picture profile', {
|
|
174
|
+
scoreId,
|
|
221
175
|
contentSize,
|
|
222
176
|
commandCount,
|
|
223
177
|
durationMs: roundMs(durationMs)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Skia","
|
|
1
|
+
{"version":3,"names":["Skia","renderVexflowRecordingCommands","isVexflowNativeDebugEnabled","insets","renderOptions","spacing","createVisibleViewport","nowMsWorklet","globalThis","performance","now","nowMs","Date","roundMs","value","Math","round","withDefaultOptions","options","render","createScorePicture","contentSize","defaultFont","fontManager","recordedCommands","replayFontManager","scoreId","styleOverrides","start","picture","createScorePictureWorklet","logScorePictureProfile","commandCount","length","durationMs","error","console","recorder","PictureRecorder","canvas","beginRecording","XYWHRect","width","height","finishRecordingAsPicture","createPictureTransform","scrollOffset","rendererType","viewport","scale","visibleViewport","transform","translateX","x","translateY","y","push","emptyOverlayPicture","getEmptyOverlayPicture","EMPTY_OVERLAY_PROFILE","windowStartMs","count","totalMs","maxMs","flushOverlayProfile","state","info","meanMs","addOverlayProfileSample","atMs","next","max"],"sourceRoot":"../../../../src","sources":["renderer/ScoreRenderer/utils.ts"],"mappings":";;AAAA,SAASA,IAAI,QAA2C,mBAAmB;AAE3E,SAASC,8BAA8B,QAAQ,sCAAmC;AAClF,SAASC,2BAA2B,QAAQ,uBAAoB;AAChE,SAASC,MAAM,EAAEC,aAAa,EAAEC,OAAO,QAAQ,iBAAc;AAQ7D,SAASC,qBAAqB,QAAQ,gBAAa;AAGnD;AACA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAW;EACrC,SAAS;;EAET,OAAOC,UAAU,CAACC,WAAW,EAAEC,GAAG,GAAG,CAAC,IAAI,CAAC;AAC7C;AAEA,SAASC,KAAKA,CAAA,EAAW;EACvB,OAAOH,UAAU,CAACC,WAAW,EAAEC,GAAG,GAAG,CAAC,IAAIE,IAAI,CAACF,GAAG,CAAC,CAAC;AACtD;AA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OAAO,GAAG5B,UAAU;IACnC6B,KAAK,EAAEhD,IAAI,CAACwD,GAAG,CAACN,KAAK,CAACF,KAAK,EAAE7B,UAAU,CAAC;IACxCF;EACF,CAAC;EAED,OAAOqC,IAAI,GAAGT,aAAa,GAAG,IAAI,GAC9BU,IAAI,GACJN,mBAAmB,CAACM,IAAI,EAAE5C,OAAO,CAAC;AACxC;AAEA,SAASK,sBAAsBA,CAAC;EAC9BC,YAAY;EACZX,WAAW;EACXa,UAAU;EACVR;AAMF,CAAC,EAAE;EACD,IAAI,CAACxB,2BAA2B,CAAC,CAAC,EAAE;IAClC;EACF;EAEAkC,OAAO,CAAC8B,IAAI,CAAC,iCAAiC,EAAE;IAC9CxC,OAAO;IACPL,WAAW;IACXW,YAAY;IACZE,UAAU,EAAErB,OAAO,CAACqB,UAAU;EAChC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { getAvailableDocumentWidth, getSystemGap } from "./Layout/LayoutMetrics.js";
|
|
4
4
|
import { layoutDocumentEvenGroup, layoutDocumentGroup, resolveDocumentEvenMeasureWidth } from "./Layout/DocumentLayout.js";
|
|
5
|
-
import { resolveSystemVerticalLayout } from "./Layout/VerticalSpacing.js";
|
|
5
|
+
import { resolveSystemVerticalLayout, resolveVerseBaselines } from "./Layout/VerticalSpacing.js";
|
|
6
6
|
import { buildMeasurementGroups, buildResolvedMeasureStates, resolveGroupStaves } from "./scoreParsing.js";
|
|
7
7
|
export function layoutScore(score, measuredScore, options, rendererType, viewport) {
|
|
8
8
|
const groups = buildGroupLayoutContext(score, measuredScore);
|
|
@@ -68,11 +68,14 @@ function buildGroupLayoutContext(score, measuredScore) {
|
|
|
68
68
|
groupId: measure.groupId,
|
|
69
69
|
measureIndex: measure.measureIndex,
|
|
70
70
|
intrinsicWidth: measure.intrinsicNoteWidth,
|
|
71
|
-
...(measure.
|
|
72
|
-
|
|
71
|
+
...(measure.systemStartModifierWidth ? {
|
|
72
|
+
systemStartModifierWidth: measure.systemStartModifierWidth
|
|
73
73
|
} : {}),
|
|
74
74
|
measureNumbers: measure.measureNumbers,
|
|
75
|
-
staffBounds: measure.staffBounds
|
|
75
|
+
staffBounds: measure.staffBounds,
|
|
76
|
+
...(measure.tempoMarkBaselines ? {
|
|
77
|
+
tempoMarkBaselines: measure.tempoMarkBaselines
|
|
78
|
+
} : {})
|
|
76
79
|
}))
|
|
77
80
|
}));
|
|
78
81
|
}
|
|
@@ -80,6 +83,7 @@ function layoutInfiniteScoreGroup(group, viewport, options) {
|
|
|
80
83
|
const systems = [];
|
|
81
84
|
const measures = [];
|
|
82
85
|
const verticalLayout = resolveSystemVerticalLayout(group.measures, group.staves.length, options.spacing.staffGap);
|
|
86
|
+
const verseBaselines = resolveVerseBaselines(group.measures, group.staves.length);
|
|
83
87
|
const maxIntrinsicWidth = Math.max(...group.measures.map(measure => measure.intrinsicWidth), 0);
|
|
84
88
|
const systemWidth = group.measures.length * maxIntrinsicWidth;
|
|
85
89
|
const origin = {
|
|
@@ -97,6 +101,9 @@ function layoutInfiniteScoreGroup(group, viewport, options) {
|
|
|
97
101
|
width,
|
|
98
102
|
height: verticalLayout.height,
|
|
99
103
|
staffYOffsets: verticalLayout.staffYOffsets,
|
|
104
|
+
...(verseBaselines ? {
|
|
105
|
+
verseBaselines
|
|
106
|
+
} : {}),
|
|
100
107
|
systemIndex: 0
|
|
101
108
|
});
|
|
102
109
|
cursorX += width;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getAvailableDocumentWidth","getSystemGap","layoutDocumentEvenGroup","layoutDocumentGroup","resolveDocumentEvenMeasureWidth","resolveSystemVerticalLayout","buildMeasurementGroups","buildResolvedMeasureStates","resolveGroupStaves","layoutScore","score","measuredScore","options","rendererType","viewport","groups","buildGroupLayoutContext","groupResults","group","push","layoutInfiniteScoreGroup","availableWidth","measuresPerFullLine","equalMeasureWidth","cursorY","y","insets","top","result","x","left","nextY","contentSize","measureContentSize","systems","flatMap","measures","layoutUsesViewportHeight","length","map","groupId","staffGroup","staffIds","staves","resolvedStatesByStaff","staff","filter","measure","sort","right","measureIndex","intrinsicWidth","intrinsicNoteWidth","
|
|
1
|
+
{"version":3,"names":["getAvailableDocumentWidth","getSystemGap","layoutDocumentEvenGroup","layoutDocumentGroup","resolveDocumentEvenMeasureWidth","resolveSystemVerticalLayout","resolveVerseBaselines","buildMeasurementGroups","buildResolvedMeasureStates","resolveGroupStaves","layoutScore","score","measuredScore","options","rendererType","viewport","groups","buildGroupLayoutContext","groupResults","group","push","layoutInfiniteScoreGroup","availableWidth","measuresPerFullLine","equalMeasureWidth","cursorY","y","insets","top","result","x","left","nextY","contentSize","measureContentSize","systems","flatMap","measures","layoutUsesViewportHeight","length","map","groupId","staffGroup","staffIds","staves","resolvedStatesByStaff","staff","filter","measure","sort","right","measureIndex","intrinsicWidth","intrinsicNoteWidth","systemStartModifierWidth","measureNumbers","staffBounds","tempoMarkBaselines","verticalLayout","spacing","staffGap","verseBaselines","maxIntrinsicWidth","Math","max","systemWidth","origin","getInfiniteScoreOriginX","getInfiniteScoreOriginY","cursorX","width","height","staffYOffsets","systemIndex","staffCount","measureIndices","insetContentWidth","visibleTop","visibleBottom","every","maxRight","maxBottom","system","measuredWidth","measuredHeight","bottom"],"sourceRoot":"../../../src","sources":["renderer/layout.ts"],"mappings":";;AACA,SACEA,yBAAyB,EACzBC,YAAY,QACP,2BAAwB;AAC/B,SACEC,uBAAuB,EACvBC,mBAAmB,EACnBC,+BAA+B,QAC1B,4BAAyB;AAChC,SACEC,2BAA2B,EAC3BC,qBAAqB,QAChB,6BAA0B;AAEjC,SACEC,sBAAsB,EACtBC,0BAA0B,EAC1BC,kBAAkB,QAEb,mBAAgB;AAsEvB,OAAO,SAASC,WAAWA,CACzBC,KAAY,EACZC,aAA4B,EAC5BC,OAAqB,EACrBC,YAA0B,EAC1BC,QAAsB,EACL;EACjB,MAAMC,MAAM,GAAGC,uBAAuB,CAAC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-0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Annotation, AnnotationVerticalJustify, BoundingBox, Font, ModifierPosition } from 'vexflow';
|
|
4
|
+
const LYRIC = {
|
|
5
|
+
font: {
|
|
6
|
+
size: 10,
|
|
7
|
+
weight: 'normal'
|
|
8
|
+
},
|
|
9
|
+
/** One staff space between a staff's lowest other ink and the tallest
|
|
10
|
+
* verse-1 letter. */
|
|
11
|
+
verseClearance: 10,
|
|
12
|
+
/** Baseline-to-baseline distance of consecutive verse lines, in ems. */
|
|
13
|
+
verseLineHeightEm: 1.2
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** The verse lines a staff needs: the distinct verses present, in order, and
|
|
17
|
+
* the tallest ascent and descent among their lyrics. */
|
|
18
|
+
|
|
19
|
+
/** Baseline y of each verse line relative to the stave origin, by verse. */
|
|
20
|
+
|
|
21
|
+
/** Undefined verses sort first, as their own verse line. */
|
|
22
|
+
export function verseOf(lyric) {
|
|
23
|
+
return lyric.verse ?? -Infinity;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A lyric reserves its width like any annotation but is drawn on its verse
|
|
28
|
+
* line, which the layout places per system once the staff's other ink is
|
|
29
|
+
* known; until placed it draws nothing and has no ink.
|
|
30
|
+
*/
|
|
31
|
+
export class Lyric extends Annotation {
|
|
32
|
+
constructor(text, verse, textFontFamily) {
|
|
33
|
+
super(text);
|
|
34
|
+
this.verse = verse;
|
|
35
|
+
this.setFont({
|
|
36
|
+
family: textFontFamily,
|
|
37
|
+
...LYRIC.font
|
|
38
|
+
});
|
|
39
|
+
// Neither TOP nor BOTTOM, so `Annotation.format` reserves the lyric's
|
|
40
|
+
// width without stacking it under the note's other marks.
|
|
41
|
+
this.setVerticalJustification(AnnotationVerticalJustify.CENTER);
|
|
42
|
+
}
|
|
43
|
+
setBaselineY(baselineY) {
|
|
44
|
+
this.baselineY = baselineY;
|
|
45
|
+
}
|
|
46
|
+
getBoundingBox() {
|
|
47
|
+
if (this.baselineY !== undefined) {
|
|
48
|
+
return super.getBoundingBox();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Unplaced: empty at the notehead, so it widens no note or staff bounds.
|
|
52
|
+
const note = this.checkAttachedNote();
|
|
53
|
+
return new BoundingBox(note.getAbsoluteX(), note.getYs()[0], 0, 0);
|
|
54
|
+
}
|
|
55
|
+
draw() {
|
|
56
|
+
this.setRendered();
|
|
57
|
+
if (this.baselineY === undefined) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const ctx = this.checkContext();
|
|
61
|
+
const start = this.checkAttachedNote().getModifierStartXY(ModifierPosition.ABOVE, this.checkIndex());
|
|
62
|
+
ctx.openGroup('annotation', this.getAttribute('id'));
|
|
63
|
+
this.x = start.x - this.getWidth() / 2;
|
|
64
|
+
this.y = this.baselineY;
|
|
65
|
+
this.renderText(ctx, 0, 0);
|
|
66
|
+
ctx.closeGroup();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The verse lines of a note's lyrics; undefined without lyrics. */
|
|
71
|
+
export function noteVerseLines(note) {
|
|
72
|
+
return note.getModifiers().filter(modifier => modifier instanceof Lyric).reduce((lines, lyric) => {
|
|
73
|
+
const {
|
|
74
|
+
actualBoundingBoxAscent,
|
|
75
|
+
actualBoundingBoxDescent
|
|
76
|
+
} = lyric.getTextMetrics();
|
|
77
|
+
return mergeVerseLines(lines, {
|
|
78
|
+
verses: [lyric.verse],
|
|
79
|
+
ascent: actualBoundingBoxAscent,
|
|
80
|
+
descent: actualBoundingBoxDescent
|
|
81
|
+
});
|
|
82
|
+
}, undefined);
|
|
83
|
+
}
|
|
84
|
+
export function mergeVerseLines(left, right) {
|
|
85
|
+
if (!left || !right) {
|
|
86
|
+
return left ?? right;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
verses: [...new Set([...left.verses, ...right.verses])].sort((a, b) => a - b),
|
|
90
|
+
ascent: Math.max(left.ascent, right.ascent),
|
|
91
|
+
descent: Math.max(left.descent, right.descent)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* One level line per verse below `contentBottom` (stave-origin space): verse
|
|
97
|
+
* lines in verse order, a line height apart, the first clearing the content.
|
|
98
|
+
* `bottom` is the lowest ink of the last line.
|
|
99
|
+
*/
|
|
100
|
+
export function layoutVerseLines(contentBottom, {
|
|
101
|
+
verses,
|
|
102
|
+
ascent,
|
|
103
|
+
descent
|
|
104
|
+
}) {
|
|
105
|
+
const lineHeight = Font.convertSizeToPixelValue(LYRIC.font.size) * LYRIC.verseLineHeightEm;
|
|
106
|
+
const firstBaseline = contentBottom + LYRIC.verseClearance + ascent;
|
|
107
|
+
const baselines = new Map(verses.map((verse, line) => [verse, firstBaseline + line * lineHeight]));
|
|
108
|
+
return {
|
|
109
|
+
baselines,
|
|
110
|
+
bottom: firstBaseline + (verses.length - 1) * lineHeight + descent
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Places the lyrics of a note, already on its stave, on their verse lines. */
|
|
115
|
+
export function placeLyrics(note, baselines) {
|
|
116
|
+
if (!baselines) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const staveY = note.checkStave().getY();
|
|
120
|
+
note.getModifiers().filter(modifier => modifier instanceof Lyric).forEach(lyric => {
|
|
121
|
+
const baseline = baselines.get(lyric.verse);
|
|
122
|
+
if (baseline !== undefined) {
|
|
123
|
+
lyric.setBaselineY(staveY + baseline);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=lyrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Annotation","AnnotationVerticalJustify","BoundingBox","Font","ModifierPosition","LYRIC","font","size","weight","verseClearance","verseLineHeightEm","verseOf","lyric","verse","Infinity","Lyric","constructor","text","textFontFamily","setFont","family","setVerticalJustification","CENTER","setBaselineY","baselineY","getBoundingBox","undefined","note","checkAttachedNote","getAbsoluteX","getYs","draw","setRendered","ctx","checkContext","start","getModifierStartXY","ABOVE","checkIndex","openGroup","getAttribute","x","getWidth","y","renderText","closeGroup","noteVerseLines","getModifiers","filter","modifier","reduce","lines","actualBoundingBoxAscent","actualBoundingBoxDescent","getTextMetrics","mergeVerseLines","verses","ascent","descent","left","right","Set","sort","a","b","Math","max","layoutVerseLines","contentBottom","lineHeight","convertSizeToPixelValue","firstBaseline","baselines","Map","map","line","bottom","length","placeLyrics","staveY","checkStave","getY","forEach","baseline","get"],"sourceRoot":"../../../src","sources":["renderer/lyrics.ts"],"mappings":";;AAAA,SACEA,UAAU,EACVC,yBAAyB,EACzBC,WAAW,EACXC,IAAI,EACJC,gBAAgB,QACX,SAAS;AAKhB,MAAMC,KAAK,GAAG;EACZC,IAAI,EAAE;IAAEC,IAAI,EAAE,EAAE;IAAEC,MAAM,EAAE;EAAS,CAAC;EACpC;AACF;EACEC,cAAc,EAAE,EAAE;EAClB;EACAC,iBAAiB,EAAE;AACrB,CAAC;;AAED;AACA;;AAOA;;AAGA;AACA,OAAO,SAASC,OAAOA,CAACC,KAAsB,EAAU;EACtD,OAAOA,KAAK,CAACC,KAAK,IAAI,CAACC,QAAQ;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,SAASf,UAAU,CAAC;EAGpCgB,WAAWA,CAACC,IAAY,EAAWJ,KAAa,EAAEK,cAAsB,EAAE;IACxE,KAAK,CAACD,IAAI,CAAC;IAAC,KADqBJ,KAAa,GAAbA,KAAa;IAE9C,IAAI,CAACM,OAAO,CAAC;MAAEC,MAAM,EAAEF,cAAc;MAAE,GAAGb,KAAK,CAACC;IAAK,CAAC,CAAC;IACvD;IACA;IACA,IAAI,CAACe,wBAAwB,CAACpB,yBAAyB,CAACqB,MAAM,CAAC;EACjE;EAEAC,YAAYA,CAACC,SAAiB,EAAE;IAC9B,IA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e,SAAS,GAAG,IAAIC,GAAG,CACvBjB,MAAM,CAACkB,GAAG,CAAC,CAAC7D,KAAK,EAAE8D,IAAI,KAAK,CAAC9D,KAAK,EAAE0D,aAAa,GAAGI,IAAI,GAAGN,UAAU,CAAC,CACxE,CAAC;EAED,OAAO;IACLG,SAAS;IACTI,MAAM,EAAEL,aAAa,GAAG,CAACf,MAAM,CAACqB,MAAM,GAAG,CAAC,IAAIR,UAAU,GAAGX;EAC7D,CAAC;AACH;;AAEA;AACA,OAAO,SAASoB,WAAWA,CAACnD,IAAU,EAAE6C,SAAqC,EAAE;EAC7E,IAAI,CAACA,SAAS,EAAE;IACd;EACF;EAEA,MAAMO,MAAM,GAAGpD,IAAI,CAACqD,UAAU,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;EAEvCtD,IAAI,CACDoB,YAAY,CAAC,CAAC,CACdC,MAAM,CAAEC,QAAQ,IAAKA,QAAQ,YAAYlC,KAAK,CAAC,CAC/CmE,OAAO,CAAEtE,KAAK,IAAK;IAClB,MAAMuE,QAAQ,GAAGX,SAAS,CAACY,GAAG,CAACxE,KAAK,CAACC,KAAK,CAAC;IAE3C,IAAIsE,QAAQ,KAAKzD,SAAS,EAAE;MAC1Bd,KAAK,CAACW,YAAY,CAACwD,MAAM,GAAGI,QAAQ,CAAC;IACvC;EACF,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -4,9 +4,10 @@ import { Formatter, Stave } from 'vexflow';
|
|
|
4
4
|
import { Platform } from 'react-native';
|
|
5
5
|
import { ensureVexflowTextMeasurementCanvas, installVexflowReactNativeFallbacks } from "../base/setupVexflowReactNative.js";
|
|
6
6
|
import { buildResolvedMeasureStates, buildMeasurementGroups, indexAttachmentsByOwner, makeVFVoice, resolveGroupStaves } from "./scoreParsing.js";
|
|
7
|
-
import { applyMeasureModifiers, resolveMeasureModifiers } from "./measureModifiers.js";
|
|
7
|
+
import { alignNoteStarts, applyMeasureModifiers, getFormatReferenceStave, resolveMeasureModifiers } from "./measureModifiers.js";
|
|
8
8
|
import { mergeNoteBounds, mergeY } from "./measureBounds.js";
|
|
9
9
|
import { applyStaffLines } from "./stave.js";
|
|
10
|
+
import { firstTempoDirection, reserveTempoMark } from "./tempoMark.js";
|
|
10
11
|
import { VEXFLOW_STAVE_BOTTOM_LINE_OFFSET, VEXFLOW_STAVE_TOP_LINE_OFFSET } from "./Layout/LayoutMetrics.js";
|
|
11
12
|
/**
|
|
12
13
|
* Measures each staff group by building VexFlow voices and estimating note width.
|
|
@@ -71,20 +72,25 @@ export function measureScore(score, options, {
|
|
|
71
72
|
};
|
|
72
73
|
});
|
|
73
74
|
try {
|
|
74
|
-
// Clef and time signature sit before the note area, so the
|
|
75
|
-
// width must include them or an empty measure with a time
|
|
76
|
-
// measures ~0 wide and the signature clips.
|
|
75
|
+
// Clef, key and time signature sit before the note area, so the
|
|
76
|
+
// intrinsic width must include them or an empty measure with a time
|
|
77
|
+
// signature measures ~0 wide and the signature clips.
|
|
77
78
|
const leftModifierWidth = measureLeftModifierWidth(staffMeasurementContexts);
|
|
78
79
|
const intrinsicNoteWidth = (allVoices.length > 0 ? formatter.preCalculateMinTotalWidth(allVoices) * Math.max(1, minIntrinsicSizeMultiplier) : 0) + leftModifierWidth;
|
|
79
|
-
|
|
80
|
+
// The first measure already shows the system-start modifiers.
|
|
81
|
+
const systemStartModifierWidth = clefOnEachSystem && measureIndex > 0 && measureLeftModifierWidth(staffMeasurementContexts.map(context => ({
|
|
80
82
|
...context,
|
|
81
83
|
modifiers: resolveMeasureModifiers(context.measure, measureIndex, true)
|
|
82
84
|
}))) - leftModifierWidth;
|
|
83
|
-
const
|
|
85
|
+
const {
|
|
86
|
+
staffBounds,
|
|
87
|
+
tempoMarkBaselines
|
|
88
|
+
} = measureStaffVerticalBounds({
|
|
84
89
|
allVoices,
|
|
85
90
|
intrinsicNoteWidth,
|
|
86
91
|
staves,
|
|
87
|
-
staffMeasurementContexts
|
|
92
|
+
staffMeasurementContexts,
|
|
93
|
+
textFontFamily: options.render.textFontFamily
|
|
88
94
|
});
|
|
89
95
|
measures.push({
|
|
90
96
|
groupId: group.groupId,
|
|
@@ -92,9 +98,12 @@ export function measureScore(score, options, {
|
|
|
92
98
|
measureNumbers,
|
|
93
99
|
staffIds: group.staffIds,
|
|
94
100
|
staffBounds,
|
|
101
|
+
...(tempoMarkBaselines ? {
|
|
102
|
+
tempoMarkBaselines
|
|
103
|
+
} : {}),
|
|
95
104
|
intrinsicNoteWidth,
|
|
96
|
-
...(
|
|
97
|
-
|
|
105
|
+
...(systemStartModifierWidth ? {
|
|
106
|
+
systemStartModifierWidth
|
|
98
107
|
} : {})
|
|
99
108
|
});
|
|
100
109
|
} catch (error) {
|
|
@@ -138,7 +147,8 @@ function measureStaffVerticalBounds({
|
|
|
138
147
|
allVoices,
|
|
139
148
|
intrinsicNoteWidth,
|
|
140
149
|
staves,
|
|
141
|
-
staffMeasurementContexts
|
|
150
|
+
staffMeasurementContexts,
|
|
151
|
+
textFontFamily
|
|
142
152
|
}) {
|
|
143
153
|
const width = Math.max(intrinsicNoteWidth, 1);
|
|
144
154
|
const renderedStaves = staffMeasurementContexts.map(({
|
|
@@ -146,6 +156,7 @@ function measureStaffVerticalBounds({
|
|
|
146
156
|
modifiers,
|
|
147
157
|
staff
|
|
148
158
|
}) => applyMeasureModifiers(applyStaffLines(new Stave(0, 0, width), staff.lines), modifiers, resolvedState));
|
|
159
|
+
alignNoteStarts(renderedStaves);
|
|
149
160
|
const staffIndexById = new Map(staves.map((staff, staffIndex) => [staff.id, staffIndex]));
|
|
150
161
|
const bounds = renderedStaves.map(stave => ({
|
|
151
162
|
top: Math.min(VEXFLOW_STAVE_TOP_LINE_OFFSET, stave.getTopLineTopY()),
|
|
@@ -175,8 +186,8 @@ function measureStaffVerticalBounds({
|
|
|
175
186
|
});
|
|
176
187
|
});
|
|
177
188
|
});
|
|
178
|
-
if (allVoices.length > 0 && renderedStaves
|
|
179
|
-
formatter.formatToStave(allVoices, renderedStaves
|
|
189
|
+
if (allVoices.length > 0 && renderedStaves.length > 0) {
|
|
190
|
+
formatter.formatToStave(allVoices, getFormatReferenceStave(renderedStaves));
|
|
180
191
|
}
|
|
181
192
|
staffMeasurementContexts.forEach(({
|
|
182
193
|
measure,
|
|
@@ -222,6 +233,34 @@ function measureStaffVerticalBounds({
|
|
|
222
233
|
});
|
|
223
234
|
});
|
|
224
235
|
});
|
|
225
|
-
return
|
|
236
|
+
return {
|
|
237
|
+
staffBounds: bounds,
|
|
238
|
+
tempoMarkBaselines: reserveTempoMarks(staffMeasurementContexts, renderedStaves, bounds, textFontFamily)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Grows each staff's top bound by its tempo mark, measured last so the mark
|
|
243
|
+
* clears everything else above the staff. */
|
|
244
|
+
function reserveTempoMarks(staffMeasurementContexts, renderedStaves, bounds, textFontFamily) {
|
|
245
|
+
const baselines = {};
|
|
246
|
+
staffMeasurementContexts.forEach(({
|
|
247
|
+
measure,
|
|
248
|
+
staff,
|
|
249
|
+
staffIndex
|
|
250
|
+
}) => {
|
|
251
|
+
const direction = firstTempoDirection(measure.directions);
|
|
252
|
+
const stave = renderedStaves[staffIndex];
|
|
253
|
+
const staffBounds = bounds[staffIndex];
|
|
254
|
+
if (!direction || !stave || !staffBounds) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const {
|
|
258
|
+
baseline,
|
|
259
|
+
top
|
|
260
|
+
} = reserveTempoMark(stave, staffBounds.top, direction.tempo, textFontFamily);
|
|
261
|
+
staffBounds.top = Math.min(staffBounds.top, top);
|
|
262
|
+
baselines[staff.id] = baseline;
|
|
263
|
+
});
|
|
264
|
+
return Object.keys(baselines).length > 0 ? baselines : undefined;
|
|
226
265
|
}
|
|
227
266
|
//# sourceMappingURL=measure.js.map
|