vexflow-native 1.1.0 → 1.3.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 +33 -1
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +50 -10
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
- package/lib/module/renderer/constants.js +2 -1
- package/lib/module/renderer/constants.js.map +1 -1
- package/lib/module/renderer/measure.js +85 -4
- package/lib/module/renderer/measure.js.map +1 -1
- package/lib/module/renderer/render.js +147 -8
- package/lib/module/renderer/render.js.map +1 -1
- package/lib/module/renderer/scale.js +78 -0
- package/lib/module/renderer/scale.js.map +1 -0
- package/lib/module/renderer/scoreParsing.js +121 -24
- package/lib/module/renderer/scoreParsing.js.map +1 -1
- package/lib/module/renderer/useScoreRecording.js +22 -4
- package/lib/module/renderer/useScoreRecording.js.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts +7 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
- package/lib/typescript/src/renderer/constants.d.ts.map +1 -1
- package/lib/typescript/src/renderer/measure.d.ts.map +1 -1
- package/lib/typescript/src/renderer/render.d.ts +25 -3
- package/lib/typescript/src/renderer/render.d.ts.map +1 -1
- package/lib/typescript/src/renderer/scale.d.ts +32 -0
- package/lib/typescript/src/renderer/scale.d.ts.map +1 -0
- package/lib/typescript/src/renderer/scoreParsing.d.ts +32 -2
- package/lib/typescript/src/renderer/scoreParsing.d.ts.map +1 -1
- package/lib/typescript/src/renderer/types.d.ts +80 -1
- package/lib/typescript/src/renderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/useScoreRecording.d.ts +8 -1
- package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
- package/lib/typescript/src/state/types.d.ts +4 -0
- package/lib/typescript/src/state/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +59 -12
- package/src/renderer/constants.ts +1 -0
- package/src/renderer/measure.tsx +117 -5
- package/src/renderer/render.tsx +223 -12
- package/src/renderer/scale.ts +93 -0
- package/src/renderer/scoreParsing.tsx +173 -34
- package/src/renderer/types.ts +84 -1
- package/src/renderer/useScoreRecording.ts +41 -3
- package/src/state/types.ts +13 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Beam, Fraction as VFFraction, StaveNote, Tuplet, Voice as VFVoice } from 'vexflow';
|
|
2
2
|
import type { StemmableNote } from 'vexflow';
|
|
3
|
-
import type { Clef, KeySignature, DurationValue, Meter, Pitch, Score, Staff, StaffGroup, StemDirection, Tempo, TupletGroup, Voice, VoiceItem, VoiceTimingMode } from '../state';
|
|
3
|
+
import type { Articulation, Clef, KeySignature, DurationValue, Meter, NoteAttachment, Notehead, Pitch, Score, Staff, StaffGroup, StemDirection, Tempo, TupletGroup, Voice, VoiceItem, VoiceTimingMode } from '../state';
|
|
4
4
|
export type StaffGroupLookup = {
|
|
5
5
|
groupId: string;
|
|
6
6
|
staffGroup?: StaffGroup;
|
|
@@ -15,7 +15,20 @@ export interface ResolvedMeasureState {
|
|
|
15
15
|
export type VFVoiceNote = StemmableNote;
|
|
16
16
|
export interface MakeVFVoiceOptions {
|
|
17
17
|
resolveClef?: (item: VoiceItem) => Clef;
|
|
18
|
+
/**
|
|
19
|
+
* Precomputed attachment index; pass it when calling in a loop to avoid
|
|
20
|
+
* rebuilding it on every call.
|
|
21
|
+
*/
|
|
22
|
+
attachmentsByOwner?: Map<string, NoteAttachment[]>;
|
|
18
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Maps library notehead names to VexFlow key glyph codes.
|
|
26
|
+
*/
|
|
27
|
+
export declare const NOTEHEAD_TO_VF_CODE: Record<Notehead, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Maps library articulation names to VexFlow articulation codes.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ARTICULATION_TO_VF_CODE: Record<Articulation, string>;
|
|
19
32
|
/**
|
|
20
33
|
* Maps the library stem direction to the numeric VexFlow value.
|
|
21
34
|
*/
|
|
@@ -36,10 +49,27 @@ export declare function applyDots(note: StaveNote, dots?: 0 | 1 | 2 | 3): void;
|
|
|
36
49
|
* Adds pitch accidentals to the matching keys in a VexFlow note.
|
|
37
50
|
*/
|
|
38
51
|
export declare function addPitchAccidentals(note: StaveNote, pitches: Pitch[]): void;
|
|
52
|
+
/**
|
|
53
|
+
* Wraps each ghost pitch of a note in parentheses.
|
|
54
|
+
*/
|
|
55
|
+
export declare function applyGhostParentheses(note: StaveNote, pitches: readonly Pitch[]): void;
|
|
56
|
+
export declare function applyArticulations(note: StaveNote, attachments: NoteAttachment[] | undefined): void;
|
|
57
|
+
export declare function indexAttachmentsByOwner(score: Score): Map<string, NoteAttachment[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Width a `spacer` rest reserves on its tick: an up-stem flagged note
|
|
60
|
+
* (2 × notehead + padding), the widest ordinary tickable. A TickContext takes
|
|
61
|
+
* the MAX of its members' widths, so reserving the worst case keeps a tick's
|
|
62
|
+
* width constant whether or not a real note shares it — a voice of spacers
|
|
63
|
+
* therefore holds engraved spacing still while notes toggle on and off its
|
|
64
|
+
* lattice. `hidden` rests stay zero-width (pure timing placeholders).
|
|
65
|
+
* Measured live because the value depends on the active music font.
|
|
66
|
+
*/
|
|
67
|
+
/** Measured width of the black notehead under the active music font. */
|
|
68
|
+
export declare function noteheadWidth(): number;
|
|
39
69
|
/**
|
|
40
70
|
* Builds a VexFlow stave note from a score voice item and clef.
|
|
41
71
|
*/
|
|
42
|
-
export declare function voiceItemToStaveNote(item: VoiceItem, clef: Clef): VFVoiceNote;
|
|
72
|
+
export declare function voiceItemToStaveNote(item: VoiceItem, clef: Clef, attachments?: NoteAttachment[]): VFVoiceNote;
|
|
43
73
|
/**
|
|
44
74
|
* Translates beam group fractions into the VexFlow representation.
|
|
45
75
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoreParsing.d.ts","sourceRoot":"","sources":["../../../../src/renderer/scoreParsing.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"scoreParsing.d.ts","sourceRoot":"","sources":["../../../../src/renderer/scoreParsing.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,IAAI,EAGJ,QAAQ,IAAI,UAAU,EAItB,SAAS,EAET,MAAM,EACN,KAAK,IAAI,OAAO,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,KAAK,EACV,YAAY,EACZ,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,KAAK,EACL,cAAc,EACd,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,UAAU,EACV,aAAa,EACb,KAAK,EACL,WAAW,EACX,KAAK,EACL,SAAS,EACT,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CASxD,CAAC;AAEF;;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AAE,KAAK,EAAE,KAAK,GAAG,WAAW,EAAE,CAE7E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAUtD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,GACX,oBAAoB,EAAE,CAmBxB;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,kBAAuB,GAC/B;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAmEA;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,gBAAgB,EAAE,CAwBvE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,gBAAgB,GACtB,KAAK,EAAE,CAIT"}
|
|
@@ -13,9 +13,19 @@ export interface ScoreRendererProps {
|
|
|
13
13
|
colorScheme?: ScoreColorScheme;
|
|
14
14
|
itemStyleOverrides?: SharedValue<ScoreItemStyleOverrides>;
|
|
15
15
|
rendererType?: RendererType;
|
|
16
|
-
options?:
|
|
16
|
+
options?: ScoreRendererOptions;
|
|
17
17
|
scrollEnabled?: boolean;
|
|
18
18
|
showScrollbars?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Fired after every recording pass with the final geometry of the rendered
|
|
21
|
+
* score. Coordinates are view-space points at scroll offset 0 and do not
|
|
22
|
+
* track scrolling. For the `document` and `documentEven` renderer types they
|
|
23
|
+
* map 1:1 to view-local coordinates; for `infiniteScore` they cannot be
|
|
24
|
+
* mapped to on-screen positions.
|
|
25
|
+
*
|
|
26
|
+
* @param layout Geometry of all rendered items and measures.
|
|
27
|
+
*/
|
|
28
|
+
onItemsLayout?: (layout: ScoreItemsLayout) => void;
|
|
19
29
|
}
|
|
20
30
|
export interface Viewport {
|
|
21
31
|
width: number;
|
|
@@ -32,15 +42,84 @@ export interface ScoreSpacing {
|
|
|
32
42
|
minIntrinsicSizeMultiplier: number;
|
|
33
43
|
}
|
|
34
44
|
export interface RenderOptions {
|
|
45
|
+
/** Currently unused — reserved for future raster-density control. */
|
|
35
46
|
pixelRatio: number;
|
|
47
|
+
/**
|
|
48
|
+
* Uniform notation scale, default 1. Scaling is lossless — the notation is
|
|
49
|
+
* re-rasterized at the final size. Non-finite or non-positive values are
|
|
50
|
+
* treated as 1.
|
|
51
|
+
*/
|
|
36
52
|
scale: number;
|
|
37
53
|
debug: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Position every tick context at its time-proportional x inside the note
|
|
56
|
+
* area instead of VexFlow's duration-weighted spacing. With a `spacer`
|
|
57
|
+
* voice covering each lattice tick, engraved x positions become a pure
|
|
58
|
+
* function of time — content edits cannot reflow them. Meant for
|
|
59
|
+
* step-editor previews; default false (classic engraving spacing).
|
|
60
|
+
*/
|
|
61
|
+
fixedNoteSpacing: boolean;
|
|
38
62
|
}
|
|
39
63
|
export interface ScoreOptions {
|
|
40
64
|
spacing: ScoreSpacing;
|
|
41
65
|
insets: ScoreInsets;
|
|
42
66
|
render: RenderOptions;
|
|
43
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Partial options accepted by the `ScoreRenderer` `options` prop, merged over
|
|
70
|
+
* the library defaults.
|
|
71
|
+
*/
|
|
72
|
+
export interface ScoreRendererOptions {
|
|
73
|
+
spacing?: Partial<ScoreSpacing>;
|
|
74
|
+
insets?: Partial<ScoreInsets>;
|
|
75
|
+
render?: Partial<RenderOptions>;
|
|
76
|
+
}
|
|
77
|
+
/** Final formatted geometry of one rendered voice item (note, chord or rest). */
|
|
78
|
+
export interface ScoreItemLayout {
|
|
79
|
+
/**
|
|
80
|
+
* Left edge of the formatted note block. Glyphs draw to the right of it, so
|
|
81
|
+
* use {@link headCenterX} for visual alignment.
|
|
82
|
+
*/
|
|
83
|
+
x: number;
|
|
84
|
+
/** Formatted width of the item. */
|
|
85
|
+
width: number;
|
|
86
|
+
/**
|
|
87
|
+
* Center of the item's notehead span — the coordinate external UI should
|
|
88
|
+
* align to. Items without a notehead (hidden and spacer rests) fall back to
|
|
89
|
+
* the center of a notional notehead at the block's left edge, so they agree
|
|
90
|
+
* with a real note on the same tick.
|
|
91
|
+
*/
|
|
92
|
+
headCenterX: number;
|
|
93
|
+
measureIndex: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Geometry of one rendered stave of a measure. Entries of the same measure
|
|
97
|
+
* share `x`/`width`, but note bounds are per stave — clef and time signature
|
|
98
|
+
* can differ between the staves of a group.
|
|
99
|
+
*/
|
|
100
|
+
export interface ScoreMeasureItemsLayout {
|
|
101
|
+
groupId: string;
|
|
102
|
+
staffId: string;
|
|
103
|
+
measureIndex: number;
|
|
104
|
+
systemIndex: number;
|
|
105
|
+
/** Stave origin x. */
|
|
106
|
+
x: number;
|
|
107
|
+
/** Stave width. */
|
|
108
|
+
width: number;
|
|
109
|
+
/** X where notes may start on this stave (after its clef/meter). */
|
|
110
|
+
staveNoteStartX: number;
|
|
111
|
+
/** X where the note area of this stave ends. */
|
|
112
|
+
staveNoteEndX: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Geometry of all rendered items keyed by item id, plus per-stave measure
|
|
116
|
+
* bounds. Coordinates and `contentSize` are view-space at scroll offset 0.
|
|
117
|
+
*/
|
|
118
|
+
export interface ScoreItemsLayout {
|
|
119
|
+
items: Record<string, ScoreItemLayout>;
|
|
120
|
+
measures: ScoreMeasureItemsLayout[];
|
|
121
|
+
contentSize: RendererSize;
|
|
122
|
+
}
|
|
44
123
|
export interface RendererPoint {
|
|
45
124
|
x: number;
|
|
46
125
|
y: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/renderer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,UAAU,GAAG,cAAc,CAAC;AACzE,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC1D,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAE7E,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,kBAAkB,CAAC,EAAE,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAC1D,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/renderer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,M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MAAM,WAAW,eAAgB,SAAQ,YAAY;CAAG"}
|
|
@@ -3,10 +3,17 @@ import type { VexflowRecordingCommand } from '../base';
|
|
|
3
3
|
import type { Score } from '../state';
|
|
4
4
|
import { type ScoreLayoutPlan } from './layout';
|
|
5
5
|
import type { ResolvedScoreColorScheme } from './colorScheme';
|
|
6
|
-
import type { RendererRect, RendererType, ScoreOptions } from './types';
|
|
6
|
+
import type { RendererRect, RendererType, ScoreItemsLayout, ScoreOptions } from './types';
|
|
7
7
|
export interface ScoreRecording {
|
|
8
|
+
/** Recorded draw commands, content-space coordinates. */
|
|
8
9
|
commands: readonly VexflowRecordingCommand[];
|
|
10
|
+
/**
|
|
11
|
+
* Layout plan in content space; multiply its `contentSize` by the render
|
|
12
|
+
* scale for the view-space size that drives scrolling.
|
|
13
|
+
*/
|
|
9
14
|
layoutPlan: ScoreLayoutPlan;
|
|
15
|
+
/** Emitted geometry, already converted to view space. */
|
|
16
|
+
itemsLayout: ScoreItemsLayout;
|
|
10
17
|
}
|
|
11
18
|
export declare function useScoreRecording({ defaultFont, enabled, fontManager, colorScheme, options, rendererType, score, viewport, }: {
|
|
12
19
|
defaultFont: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScoreRecording.d.ts","sourceRoot":"","sources":["../../../../src/renderer/useScoreRecording.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useScoreRecording.d.ts","sourceRoot":"","sources":["../../../../src/renderer/useScoreRecording.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAQ7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,QAAQ,EAAE,SAAS,uBAAuB,EAAE,CAAC;IAC7C;;;OAGG;IACH,UAAU,EAAE,eAAe,CAAC;IAC5B,yDAAyD;IACzD,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,OAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;CACxB,GAAG,cAAc,CA0EjB"}
|
|
@@ -4,6 +4,7 @@ export type Step = 'C' | 'D' | 'E' | 'F' | 'G' | 'A' | 'B';
|
|
|
4
4
|
export type Accidental = 'bb' | 'b' | 'n' | '#' | '##' | 'x' | 'quarter-flat' | 'quarter-sharp';
|
|
5
5
|
export type NoteLength = 'long' | 'breve' | 'w' | 'h' | 'q' | '8' | '16' | '32' | '64' | '128';
|
|
6
6
|
export type StemDirection = 'up' | 'down' | 'auto';
|
|
7
|
+
export type Notehead = 'x' | 'circle-x' | 'diamond' | 'circle' | 'square' | 'triangle' | 'triangle-down' | 'slash';
|
|
7
8
|
export type Barline = 'single' | 'double' | 'end' | 'repeat-begin' | 'repeat-end' | 'final';
|
|
8
9
|
export type Articulation = 'staccato' | 'tenuto' | 'accent' | 'marcato' | 'staccatissimo' | 'fermata';
|
|
9
10
|
export type Dynamic = 'ppp' | 'pp' | 'p' | 'mp' | 'mf' | 'f' | 'ff' | 'fff' | 'sfz';
|
|
@@ -19,6 +20,8 @@ export interface Pitch {
|
|
|
19
20
|
step: Step;
|
|
20
21
|
octave: number;
|
|
21
22
|
accidental?: Accidental;
|
|
23
|
+
notehead?: Notehead;
|
|
24
|
+
ghost?: boolean;
|
|
22
25
|
}
|
|
23
26
|
export interface DurationValue {
|
|
24
27
|
length: NoteLength;
|
|
@@ -146,6 +149,7 @@ export interface AttachmentBase {
|
|
|
146
149
|
export interface ArticulationAttachment extends AttachmentBase {
|
|
147
150
|
type: 'articulation';
|
|
148
151
|
articulation: Articulation;
|
|
152
|
+
placement?: 'above' | 'below';
|
|
149
153
|
}
|
|
150
154
|
export interface DynamicAttachment extends AttachmentBase {
|
|
151
155
|
type: 'dynamic';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/state/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,EAAE,GAAG,MAAM,CAAC;AAExB,MAAM,MAAM,IAAI,GACZ,QAAQ,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,eAAe,GACf,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,KAAK,CAAC;AAEV,MAAM,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE3D,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,GAAG,GACH,cAAc,GACd,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,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,EAAE,CAAC;IACP,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import {
|
|
4
4
|
Canvas,
|
|
5
5
|
Group,
|
|
@@ -18,11 +18,13 @@ import type { VexflowRecordingCommand } from '../../base';
|
|
|
18
18
|
import { renderVexflowRecordingCommands } from '../../base/VexflowRecordingReplay';
|
|
19
19
|
import { resolveScoreColorScheme } from '../colorScheme';
|
|
20
20
|
import { insets, renderOptions, spacing } from '../constants';
|
|
21
|
+
import { getRenderScale, toViewSize } from '../scale';
|
|
21
22
|
import type {
|
|
22
23
|
RendererSize,
|
|
23
24
|
RendererType,
|
|
24
25
|
ScoreItemStyleOverrides,
|
|
25
26
|
ScoreOptions,
|
|
27
|
+
ScoreRendererOptions,
|
|
26
28
|
ScoreRendererProps,
|
|
27
29
|
Viewport,
|
|
28
30
|
} from '../types';
|
|
@@ -31,7 +33,7 @@ import { createVisibleViewport } from '../viewport';
|
|
|
31
33
|
import ScoreScrollbar from './ScoreScrollbar';
|
|
32
34
|
import { getMaxScroll, useScoreScroll } from './useScoreScroll';
|
|
33
35
|
|
|
34
|
-
const EMPTY_OPTIONS:
|
|
36
|
+
const EMPTY_OPTIONS: ScoreRendererOptions = {};
|
|
35
37
|
const EMPTY_SIZE: RendererSize = { width: 0, height: 0 };
|
|
36
38
|
|
|
37
39
|
const ScoreRenderer: React.FC<ScoreRendererProps> = ({
|
|
@@ -44,6 +46,7 @@ const ScoreRenderer: React.FC<ScoreRendererProps> = ({
|
|
|
44
46
|
options: userOptions = EMPTY_OPTIONS,
|
|
45
47
|
scrollEnabled = true,
|
|
46
48
|
showScrollbars = true,
|
|
49
|
+
onItemsLayout,
|
|
47
50
|
}) => {
|
|
48
51
|
const options = useMemo(() => withDefaultOptions(userOptions), [userOptions]);
|
|
49
52
|
const resolvedColorScheme = useMemo(
|
|
@@ -83,7 +86,11 @@ const ScoreRenderer: React.FC<ScoreRendererProps> = ({
|
|
|
83
86
|
}),
|
|
84
87
|
[viewportSize.height, viewportSize.width]
|
|
85
88
|
);
|
|
86
|
-
const {
|
|
89
|
+
const {
|
|
90
|
+
commands: recordedCommands,
|
|
91
|
+
layoutPlan,
|
|
92
|
+
itemsLayout,
|
|
93
|
+
} = useScoreRecording({
|
|
87
94
|
defaultFont,
|
|
88
95
|
enabled: hasViewportSize,
|
|
89
96
|
fontManager,
|
|
@@ -93,15 +100,37 @@ const ScoreRenderer: React.FC<ScoreRendererProps> = ({
|
|
|
93
100
|
score,
|
|
94
101
|
viewport,
|
|
95
102
|
});
|
|
103
|
+
// Scrolling and overflow checks need the view-space content size, not the
|
|
104
|
+
// content-space size that bounds the recorded picture.
|
|
105
|
+
const scale = getRenderScale(options);
|
|
96
106
|
const contentSize = layoutPlan.contentSize;
|
|
107
|
+
const viewContentSize = useMemo(
|
|
108
|
+
() => toViewSize(contentSize, scale),
|
|
109
|
+
[contentSize, scale]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Deliver geometry once per recording pass. The callback lives in a ref so
|
|
113
|
+
// a new inline callback identity neither re-fires the effect nor loops when
|
|
114
|
+
// the callback sets parent state.
|
|
115
|
+
const onItemsLayoutRef = useRef(onItemsLayout);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
onItemsLayoutRef.current = onItemsLayout;
|
|
118
|
+
});
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (!hasViewportSize) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
onItemsLayoutRef.current?.(itemsLayout);
|
|
125
|
+
}, [itemsLayout, hasViewportSize]);
|
|
97
126
|
const scrollState = useScoreScroll({
|
|
98
|
-
contentSize,
|
|
127
|
+
contentSize: viewContentSize,
|
|
99
128
|
rendererType: effectiveRendererType,
|
|
100
129
|
scrollEnabled,
|
|
101
130
|
viewportSize,
|
|
102
131
|
});
|
|
103
132
|
const hasScrollableOverflow =
|
|
104
|
-
getMaxScroll(effectiveRendererType, viewportSize,
|
|
133
|
+
getMaxScroll(effectiveRendererType, viewportSize, viewContentSize) > 0;
|
|
105
134
|
|
|
106
135
|
const viewportClip = useMemo(
|
|
107
136
|
() => Skia.XYWHRect(0, 0, viewportSize.width, viewportSize.height),
|
|
@@ -128,17 +157,22 @@ const ScoreRenderer: React.FC<ScoreRendererProps> = ({
|
|
|
128
157
|
recordedCommands,
|
|
129
158
|
]);
|
|
130
159
|
|
|
160
|
+
// Destructure so the worklet below doesn't capture the whole scrollState —
|
|
161
|
+
// the PanGesture inside it is not serializable and would crash the worklet.
|
|
162
|
+
const { scrollOffset } = scrollState;
|
|
131
163
|
const pictureTransform = useDerivedValue(() => {
|
|
132
164
|
return createPictureTransform(
|
|
133
|
-
|
|
165
|
+
scrollOffset.value,
|
|
134
166
|
effectiveRendererType,
|
|
135
167
|
{ width: viewportSize.width, height: viewportSize.height },
|
|
136
|
-
|
|
168
|
+
viewContentSize,
|
|
169
|
+
scale
|
|
137
170
|
);
|
|
138
171
|
}, [
|
|
139
|
-
contentSize,
|
|
140
172
|
effectiveRendererType,
|
|
141
|
-
|
|
173
|
+
scale,
|
|
174
|
+
scrollOffset,
|
|
175
|
+
viewContentSize,
|
|
142
176
|
viewportSize.height,
|
|
143
177
|
viewportSize.width,
|
|
144
178
|
]);
|
|
@@ -289,11 +323,18 @@ function createScorePictureWorklet({
|
|
|
289
323
|
return recorder.finishRecordingAsPicture();
|
|
290
324
|
}
|
|
291
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Maps the content-space picture into the view. Skia applies the transform
|
|
328
|
+
* array right-to-left, so the trailing scale entry runs first and the
|
|
329
|
+
* translate entries then shift by the view-space scroll offset; `contentSize`
|
|
330
|
+
* must be the view-space content size.
|
|
331
|
+
*/
|
|
292
332
|
export function createPictureTransform(
|
|
293
333
|
scrollOffset: number,
|
|
294
334
|
rendererType: RendererType,
|
|
295
335
|
viewport: Viewport,
|
|
296
|
-
contentSize: RendererSize
|
|
336
|
+
contentSize: RendererSize,
|
|
337
|
+
scale: number = 1
|
|
297
338
|
): Transforms3d {
|
|
298
339
|
'worklet';
|
|
299
340
|
|
|
@@ -304,7 +345,7 @@ export function createPictureTransform(
|
|
|
304
345
|
contentSize
|
|
305
346
|
);
|
|
306
347
|
|
|
307
|
-
|
|
348
|
+
const transform: Transforms3d = [
|
|
308
349
|
{
|
|
309
350
|
translateX: visibleViewport.x === 0 ? 0 : -visibleViewport.x,
|
|
310
351
|
},
|
|
@@ -312,9 +353,15 @@ export function createPictureTransform(
|
|
|
312
353
|
translateY: visibleViewport.y === 0 ? 0 : -visibleViewport.y,
|
|
313
354
|
},
|
|
314
355
|
];
|
|
356
|
+
|
|
357
|
+
if (scale !== 1) {
|
|
358
|
+
transform.push({ scale });
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return transform;
|
|
315
362
|
}
|
|
316
363
|
|
|
317
|
-
function withDefaultOptions(options:
|
|
364
|
+
function withDefaultOptions(options: ScoreRendererOptions): ScoreOptions {
|
|
318
365
|
return {
|
|
319
366
|
insets: { ...insets, ...(options.insets || {}) },
|
|
320
367
|
spacing: { ...spacing, ...(options.spacing || {}) },
|
package/src/renderer/measure.tsx
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Articulation as VFArticulation,
|
|
3
|
+
Formatter,
|
|
4
|
+
Stave,
|
|
5
|
+
Voice as VFVoice,
|
|
6
|
+
} from 'vexflow';
|
|
7
|
+
import type { BoundingBox, RenderContext } from 'vexflow';
|
|
3
8
|
import { Platform } from 'react-native';
|
|
4
9
|
|
|
5
10
|
import {
|
|
@@ -10,6 +15,7 @@ import type { Score, Staff } from '../state';
|
|
|
10
15
|
import {
|
|
11
16
|
buildResolvedMeasureStates,
|
|
12
17
|
buildMeasurementGroups,
|
|
18
|
+
indexAttachmentsByOwner,
|
|
13
19
|
makeVFVoice,
|
|
14
20
|
resolveGroupStaves,
|
|
15
21
|
} from './scoreParsing';
|
|
@@ -47,6 +53,7 @@ export function measureScore(
|
|
|
47
53
|
options: ScoreOptions
|
|
48
54
|
): MeasuredScore {
|
|
49
55
|
const groups = buildMeasurementGroups(score);
|
|
56
|
+
const attachmentsByOwner = indexAttachmentsByOwner(score);
|
|
50
57
|
const measures: MeasuredMeasure[] = [];
|
|
51
58
|
const {
|
|
52
59
|
spacing: { minIntrinsicSizeMultiplier },
|
|
@@ -88,6 +95,7 @@ export function measureScore(
|
|
|
88
95
|
|
|
89
96
|
const voiceArtifacts = measure.voices.map((voice) =>
|
|
90
97
|
makeVFVoice(score, resolvedState.meter, resolvedState.clef, voice, {
|
|
98
|
+
attachmentsByOwner,
|
|
91
99
|
resolveClef: (item) =>
|
|
92
100
|
item.targetStaffId
|
|
93
101
|
? resolvedStateByStaffId.get(item.targetStaffId)?.clef ??
|
|
@@ -110,16 +118,20 @@ export function measureScore(
|
|
|
110
118
|
resolvedState,
|
|
111
119
|
showClef:
|
|
112
120
|
measureIndex === 0 || Boolean(measure.leftModifiers?.showClef),
|
|
121
|
+
showMeter: measure.leftModifiers?.showMeter === true,
|
|
113
122
|
voiceArtifacts,
|
|
114
123
|
};
|
|
115
124
|
});
|
|
116
125
|
|
|
117
126
|
try {
|
|
127
|
+
// Clef and time signature sit before the note area, so the intrinsic
|
|
128
|
+
// width must include them or an empty measure with a time signature
|
|
129
|
+
// measures ~0 wide and the signature clips.
|
|
118
130
|
const intrinsicNoteWidth =
|
|
119
|
-
allVoices.length > 0
|
|
131
|
+
(allVoices.length > 0
|
|
120
132
|
? formatter.preCalculateMinTotalWidth(allVoices) *
|
|
121
133
|
Math.max(1, minIntrinsicSizeMultiplier)
|
|
122
|
-
: 0;
|
|
134
|
+
: 0) + measureLeftModifierWidth(staffMeasurementContexts);
|
|
123
135
|
const staffBounds = measureStaffVerticalBounds({
|
|
124
136
|
allVoices,
|
|
125
137
|
intrinsicNoteWidth,
|
|
@@ -154,6 +166,48 @@ export function measureScore(
|
|
|
154
166
|
};
|
|
155
167
|
}
|
|
156
168
|
|
|
169
|
+
// Wide enough that VexFlow never clamps the modifier block on the probe stave.
|
|
170
|
+
const MODIFIER_PROBE_STAVE_WIDTH = 500;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Widest clef/time-signature block of the measure, measured as the note-start
|
|
174
|
+
* delta between a bare probe stave and one carrying the shown modifiers.
|
|
175
|
+
*/
|
|
176
|
+
function measureLeftModifierWidth(
|
|
177
|
+
staffMeasurementContexts: Array<{
|
|
178
|
+
resolvedState: { clef: string; meter: { beats: number; beatUnit: number } };
|
|
179
|
+
showClef: boolean;
|
|
180
|
+
showMeter: boolean;
|
|
181
|
+
}>
|
|
182
|
+
): number {
|
|
183
|
+
return staffMeasurementContexts.reduce(
|
|
184
|
+
(maxWidth, { resolvedState, showClef, showMeter }) => {
|
|
185
|
+
if (!showClef && !showMeter) {
|
|
186
|
+
return maxWidth;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const bareStave = new Stave(0, 0, MODIFIER_PROBE_STAVE_WIDTH);
|
|
190
|
+
const modifiedStave = new Stave(0, 0, MODIFIER_PROBE_STAVE_WIDTH);
|
|
191
|
+
|
|
192
|
+
if (showClef) {
|
|
193
|
+
modifiedStave.addClef(resolvedState.clef);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (showMeter) {
|
|
197
|
+
modifiedStave.addTimeSignature(
|
|
198
|
+
`${resolvedState.meter.beats}/${resolvedState.meter.beatUnit}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return Math.max(
|
|
203
|
+
maxWidth,
|
|
204
|
+
modifiedStave.getNoteStartX() - bareStave.getNoteStartX()
|
|
205
|
+
);
|
|
206
|
+
},
|
|
207
|
+
0
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
157
211
|
function measureStaffVerticalBounds({
|
|
158
212
|
allVoices,
|
|
159
213
|
intrinsicNoteWidth,
|
|
@@ -169,18 +223,25 @@ function measureStaffVerticalBounds({
|
|
|
169
223
|
measure: Staff['measures'][number];
|
|
170
224
|
resolvedState: ReturnType<typeof buildResolvedMeasureStates>[number];
|
|
171
225
|
showClef: boolean;
|
|
226
|
+
showMeter: boolean;
|
|
172
227
|
voiceArtifacts: ReturnType<typeof makeVFVoice>[];
|
|
173
228
|
}>;
|
|
174
229
|
}): StaffVerticalBounds[] {
|
|
175
230
|
const width = Math.max(intrinsicNoteWidth, 1);
|
|
176
231
|
const renderedStaves = staffMeasurementContexts.map(
|
|
177
|
-
({ resolvedState, showClef }) => {
|
|
232
|
+
({ resolvedState, showClef, showMeter }) => {
|
|
178
233
|
const stave = new Stave(0, 0, width);
|
|
179
234
|
|
|
180
235
|
if (showClef) {
|
|
181
236
|
stave.addClef(resolvedState.clef);
|
|
182
237
|
}
|
|
183
238
|
|
|
239
|
+
if (showMeter) {
|
|
240
|
+
stave.addTimeSignature(
|
|
241
|
+
`${resolvedState.meter.beats}/${resolvedState.meter.beatUnit}`
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
184
245
|
return stave;
|
|
185
246
|
}
|
|
186
247
|
);
|
|
@@ -245,6 +306,7 @@ function measureStaffVerticalBounds({
|
|
|
245
306
|
staffIndexById.get(
|
|
246
307
|
items[noteIndex]?.targetStaffId ?? ownerStaffId
|
|
247
308
|
) ?? staffIndex;
|
|
309
|
+
mergeArticulationBounds(bounds[ownerStaffIndex], note);
|
|
248
310
|
mergeNoteBounds(bounds[ownerStaffIndex], note);
|
|
249
311
|
});
|
|
250
312
|
|
|
@@ -274,6 +336,56 @@ function measureStaffVerticalBounds({
|
|
|
274
336
|
return bounds;
|
|
275
337
|
}
|
|
276
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Render context that absorbs every method call without drawing anything, so
|
|
341
|
+
* modifiers can run their `draw()` placement math during measurement.
|
|
342
|
+
*/
|
|
343
|
+
function createNoopRenderContext(): RenderContext {
|
|
344
|
+
const memo: Record<PropertyKey, unknown> = {};
|
|
345
|
+
const proxy: object = new Proxy(memo, {
|
|
346
|
+
get: (target, property) => {
|
|
347
|
+
if (!(property in target)) {
|
|
348
|
+
target[property] = () => proxy;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return target[property];
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
return proxy as RenderContext;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const NOOP_RENDER_CONTEXT = createNoopRenderContext();
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Merges the drawn extents of a note's articulations into the staff bounds.
|
|
362
|
+
* VexFlow only positions an articulation inside `draw()`, so each one is
|
|
363
|
+
* drawn against a no-op context first to make its bounding box real.
|
|
364
|
+
*/
|
|
365
|
+
function mergeArticulationBounds(
|
|
366
|
+
bounds: StaffVerticalBounds | undefined,
|
|
367
|
+
note: VFVoiceNote
|
|
368
|
+
) {
|
|
369
|
+
if (!bounds) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
for (const modifier of note.getModifiers()) {
|
|
374
|
+
if (!(modifier instanceof VFArticulation)) {
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
modifier.setContext(NOOP_RENDER_CONTEXT);
|
|
380
|
+
modifier.draw();
|
|
381
|
+
mergeBoundingBox(bounds, modifier.getBoundingBox());
|
|
382
|
+
} catch {
|
|
383
|
+
// Ghost and spacer notes cannot place modifiers; note bounds remain
|
|
384
|
+
// the fallback.
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
277
389
|
function mergeNoteBounds(
|
|
278
390
|
bounds: StaffVerticalBounds | undefined,
|
|
279
391
|
note: VFVoiceNote
|