vexflow-native 1.0.1 → 1.2.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.
Files changed (55) hide show
  1. package/README.md +35 -1
  2. package/lib/module/base/VexflowRecordingContext.js +69 -7
  3. package/lib/module/base/VexflowRecordingContext.js.map +1 -1
  4. package/lib/module/base/VexflowRecordingReplay.js +79 -5
  5. package/lib/module/base/VexflowRecordingReplay.js.map +1 -1
  6. package/lib/module/base/index.js +1 -0
  7. package/lib/module/base/index.js.map +1 -1
  8. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +103 -18
  9. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
  10. package/lib/module/renderer/measure.js +85 -4
  11. package/lib/module/renderer/measure.js.map +1 -1
  12. package/lib/module/renderer/render.js +120 -7
  13. package/lib/module/renderer/render.js.map +1 -1
  14. package/lib/module/renderer/scale.js +78 -0
  15. package/lib/module/renderer/scale.js.map +1 -0
  16. package/lib/module/renderer/scoreParsing.js +96 -23
  17. package/lib/module/renderer/scoreParsing.js.map +1 -1
  18. package/lib/module/renderer/useScoreRecording.js +22 -4
  19. package/lib/module/renderer/useScoreRecording.js.map +1 -1
  20. package/lib/typescript/src/base/VexflowRecordingContext.d.ts +32 -3
  21. package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -1
  22. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +10 -2
  23. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -1
  24. package/lib/typescript/src/base/VexflowRecordingTypes.d.ts +53 -1
  25. package/lib/typescript/src/base/VexflowRecordingTypes.d.ts.map +1 -1
  26. package/lib/typescript/src/base/index.d.ts +1 -0
  27. package/lib/typescript/src/base/index.d.ts.map +1 -1
  28. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts +12 -5
  29. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
  30. package/lib/typescript/src/renderer/measure.d.ts.map +1 -1
  31. package/lib/typescript/src/renderer/render.d.ts +11 -3
  32. package/lib/typescript/src/renderer/render.d.ts.map +1 -1
  33. package/lib/typescript/src/renderer/scale.d.ts +32 -0
  34. package/lib/typescript/src/renderer/scale.d.ts.map +1 -0
  35. package/lib/typescript/src/renderer/scoreParsing.d.ts +21 -2
  36. package/lib/typescript/src/renderer/scoreParsing.d.ts.map +1 -1
  37. package/lib/typescript/src/renderer/types.d.ts +76 -1
  38. package/lib/typescript/src/renderer/types.d.ts.map +1 -1
  39. package/lib/typescript/src/renderer/useScoreRecording.d.ts +8 -1
  40. package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
  41. package/lib/typescript/src/state/types.d.ts +4 -0
  42. package/lib/typescript/src/state/types.d.ts.map +1 -1
  43. package/package.json +2 -3
  44. package/src/base/VexflowRecordingContext.ts +57 -7
  45. package/src/base/VexflowRecordingReplay.ts +121 -5
  46. package/src/base/VexflowRecordingTypes.ts +54 -2
  47. package/src/base/index.ts +1 -0
  48. package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +146 -25
  49. package/src/renderer/measure.tsx +117 -5
  50. package/src/renderer/render.tsx +181 -15
  51. package/src/renderer/scale.ts +93 -0
  52. package/src/renderer/scoreParsing.tsx +146 -33
  53. package/src/renderer/types.ts +80 -1
  54. package/src/renderer/useScoreRecording.ts +41 -3
  55. 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,16 @@ 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[]>;
39
58
  /**
40
59
  * Builds a VexFlow stave note from a score voice item and clef.
41
60
  */
42
- export declare function voiceItemToStaveNote(item: VoiceItem, clef: Clef): VFVoiceNote;
61
+ export declare function voiceItemToStaveNote(item: VoiceItem, clef: Clef, attachments?: NoteAttachment[]): VFVoiceNote;
43
62
  /**
44
63
  * Translates beam group fractions into the VexFlow representation.
45
64
  */
@@ -1 +1 @@
1
- {"version":3,"file":"scoreParsing.d.ts","sourceRoot":"","sources":["../../../../src/renderer/scoreParsing.tsx"],"names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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"}
@@ -1,16 +1,31 @@
1
1
  import type { SkTypefaceFontProvider } from '@shopify/react-native-skia';
2
+ import type { SharedValue } from 'react-native-reanimated';
3
+ import type { VexflowStyleOverride } from '../base';
2
4
  import type { Score } from '../state';
3
5
  import type { ScoreColorScheme } from './colorScheme';
4
6
  export type RendererType = 'infiniteScore' | 'document' | 'documentEven';
7
+ export type ScoreItemStyleOverride = VexflowStyleOverride;
8
+ export type ScoreItemStyleOverrides = Record<string, ScoreItemStyleOverride>;
5
9
  export interface ScoreRendererProps {
6
10
  score: Score;
7
11
  defaultFont: string;
8
12
  fontManager: SkTypefaceFontProvider;
9
13
  colorScheme?: ScoreColorScheme;
14
+ itemStyleOverrides?: SharedValue<ScoreItemStyleOverrides>;
10
15
  rendererType?: RendererType;
11
- options?: Partial<ScoreOptions>;
16
+ options?: ScoreRendererOptions;
12
17
  scrollEnabled?: boolean;
13
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;
14
29
  }
15
30
  export interface Viewport {
16
31
  width: number;
@@ -27,7 +42,13 @@ export interface ScoreSpacing {
27
42
  minIntrinsicSizeMultiplier: number;
28
43
  }
29
44
  export interface RenderOptions {
45
+ /** Currently unused — reserved for future raster-density control. */
30
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
+ */
31
52
  scale: number;
32
53
  debug: boolean;
33
54
  }
@@ -36,6 +57,60 @@ export interface ScoreOptions {
36
57
  insets: ScoreInsets;
37
58
  render: RenderOptions;
38
59
  }
60
+ /**
61
+ * Partial options accepted by the `ScoreRenderer` `options` prop, merged over
62
+ * the library defaults.
63
+ */
64
+ export interface ScoreRendererOptions {
65
+ spacing?: Partial<ScoreSpacing>;
66
+ insets?: Partial<ScoreInsets>;
67
+ render?: Partial<RenderOptions>;
68
+ }
69
+ /** Final formatted geometry of one rendered voice item (note, chord or rest). */
70
+ export interface ScoreItemLayout {
71
+ /**
72
+ * Left edge of the formatted note block. Glyphs draw to the right of it, so
73
+ * use {@link headCenterX} for visual alignment.
74
+ */
75
+ x: number;
76
+ /** Formatted width of the item. */
77
+ width: number;
78
+ /**
79
+ * Center of the item's notehead span — the coordinate external UI should
80
+ * align to. Items without a notehead (hidden and spacer rests) fall back to
81
+ * the block center.
82
+ */
83
+ headCenterX: number;
84
+ measureIndex: number;
85
+ }
86
+ /**
87
+ * Geometry of one rendered stave of a measure. Entries of the same measure
88
+ * share `x`/`width`, but note bounds are per stave — clef and time signature
89
+ * can differ between the staves of a group.
90
+ */
91
+ export interface ScoreMeasureItemsLayout {
92
+ groupId: string;
93
+ staffId: string;
94
+ measureIndex: number;
95
+ systemIndex: number;
96
+ /** Stave origin x. */
97
+ x: number;
98
+ /** Stave width. */
99
+ width: number;
100
+ /** X where notes may start on this stave (after its clef/meter). */
101
+ staveNoteStartX: number;
102
+ /** X where the note area of this stave ends. */
103
+ staveNoteEndX: number;
104
+ }
105
+ /**
106
+ * Geometry of all rendered items keyed by item id, plus per-stave measure
107
+ * bounds. Coordinates and `contentSize` are view-space at scroll offset 0.
108
+ */
109
+ export interface ScoreItemsLayout {
110
+ items: Record<string, ScoreItemLayout>;
111
+ measures: ScoreMeasureItemsLayout[];
112
+ contentSize: RendererSize;
113
+ }
39
114
  export interface RendererPoint {
40
115
  x: number;
41
116
  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;AAEzE,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;AAEzE,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,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B,E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K,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACvC,QAAQ,EAAE,uBAAuB,EAAE,CAAC;IACpC,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa,EAAE,YAAY;CAAG;AAEpE,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;AAG7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAExE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,SAAS,uBAAuB,EAAE,CAAC;IAC7C,UAAU,EAAE,eAAe,CAAC;CAC7B;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,CAgEjB"}
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,eAAe,CAAC;AAEpB,MAAM,MAAM,UAAU,GAClB,MAA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AC/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,7 +1,7 @@
1
1
  {
2
2
  "name": "vexflow-native",
3
- "version": "1.0.1",
4
- "description": "React native backend for rendering music notation using @shopify/react-native-skiaact-native-skia",
3
+ "version": "1.2.0",
4
+ "description": "React native backend for rendering music notation using @shopify/react-native-skia",
5
5
  "main": "./lib/module/base/index.js",
6
6
  "types": "./lib/typescript/src/base/index.d.ts",
7
7
  "exports": {
@@ -46,7 +46,6 @@
46
46
  "example": "yarn workspace vexflow-native-example",
47
47
  "clean": "del-cli lib",
48
48
  "prepare": "bob build",
49
- "postinstall": "yarn workspace vexflow-native-example apply-patches",
50
49
  "typecheck": "tsc",
51
50
  "lint": "eslint src example --ext .js,.ts,.tsx",
52
51
  "lint:fix": "yarn lint --fix",
@@ -40,6 +40,7 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
40
40
  __workletClass = true;
41
41
 
42
42
  private commands: VexflowRecordingCommand[] = [];
43
+ private colorGroupId?: string;
43
44
  private currentPath?: VexflowRecordingPathCommand[];
44
45
  private fillPaint: VexflowRecordingPaint = {
45
46
  color: '#000000',
@@ -136,13 +137,28 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
136
137
  return this;
137
138
  }
138
139
 
139
- setShadowColor(_color: string): this {
140
- logUnimplemented('setShadowColor');
140
+ /**
141
+ * Record a glow/shadow colour (CSS `shadowColor`) into both the fill and the
142
+ * stroke paint — VexFlow's `ElementStyle.shadowColor` is applied as ctx-level
143
+ * state that affects whatever is drawn next, fill or stroke. Replayed in Skia
144
+ * as a drop-shadow image filter (a glow around the ink) and overridable per
145
+ * group at replay.
146
+ */
147
+ setShadowColor(color: string): this {
148
+ const resolved = resolveVexflowColor(color, this.colorScheme);
149
+ this.fillPaint = { ...this.fillPaint, shadowColor: resolved };
150
+ this.strokePaint = { ...this.strokePaint, shadowColor: resolved };
141
151
  return this;
142
152
  }
143
153
 
144
- setShadowBlur(_blur: number) {
145
- logUnimplemented('setShadowBlur');
154
+ /**
155
+ * Record a glow/shadow blur radius (CSS `shadowBlur`) into both the fill and
156
+ * the stroke paint. Mapped to a Gaussian sigma at replay; only takes effect
157
+ * when a `shadowColor` is also set.
158
+ */
159
+ setShadowBlur(blur: number): this {
160
+ this.fillPaint = { ...this.fillPaint, shadowBlur: blur };
161
+ this.strokePaint = { ...this.strokePaint, shadowBlur: blur };
146
162
  return this;
147
163
  }
148
164
 
@@ -162,8 +178,17 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
162
178
  return this;
163
179
  }
164
180
 
165
- setLineDash(_dashPattern: number[]) {
166
- logUnimplemented('setLineDash');
181
+ /**
182
+ * Record a dash pattern (CSS `setLineDash`) into the stroke paint — dashing is
183
+ * a stroke-only concept (stems, ledger lines, …). Replayed in Skia as a dash
184
+ * path effect and overridable per group at replay. An empty array clears any
185
+ * recorded dash (CSS semantics: solid line).
186
+ */
187
+ setLineDash(dashPattern: number[]): this {
188
+ this.strokePaint = {
189
+ ...this.strokePaint,
190
+ lineDash: dashPattern.length > 0 ? [...dashPattern] : undefined,
191
+ };
167
192
  return this;
168
193
  }
169
194
 
@@ -336,6 +361,24 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
336
361
  return this;
337
362
  }
338
363
 
364
+ /**
365
+ * Open a colour group. Every command recorded until `endColorGroup()` is
366
+ * stamped with `id` as its `groupId`, so a replay can recolor the whole group
367
+ * from a `groupId -> color` override map without re-recording. This is a
368
+ * dedicated, explicit grouping — distinct from VexFlow's
369
+ * `openGroup`/`closeGroup` (above, no-ops here), which a real score nests per
370
+ * element. Returns `this` for chaining.
371
+ */
372
+ beginColorGroup(id: string) {
373
+ this.colorGroupId = id;
374
+ return this;
375
+ }
376
+
377
+ endColorGroup() {
378
+ this.colorGroupId = undefined;
379
+ return this;
380
+ }
381
+
339
382
  openRotation(_angleDegrees: number, _x: number, _y: number) {
340
383
  logUnimplemented('openRotation');
341
384
  return this;
@@ -414,6 +457,10 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
414
457
  );
415
458
  }
416
459
 
460
+ if (this.colorGroupId != null) {
461
+ command.groupId = this.colorGroupId;
462
+ }
463
+
417
464
  this.commands.push(command);
418
465
  }
419
466
  }
@@ -436,7 +483,10 @@ function normalizeLineCap(cap: string): VexflowRecordingLineCap {
436
483
  }
437
484
 
438
485
  function clonePaint(paint: VexflowRecordingPaint): VexflowRecordingPaint {
439
- return { ...paint };
486
+ return {
487
+ ...paint,
488
+ ...(paint.lineDash ? { lineDash: [...paint.lineDash] } : null),
489
+ };
440
490
  }
441
491
 
442
492
  function cloneFont(font: VexflowRecordingFont): VexflowRecordingFont {
@@ -18,8 +18,47 @@ import type {
18
18
  VexflowRecordingPaint,
19
19
  VexflowRecordingPathCommand,
20
20
  VexflowRecordingRect,
21
+ VexflowStyleOverride,
21
22
  } from './VexflowRecordingTypes';
22
23
 
24
+ /**
25
+ * Map a CSS `shadowBlur` (a blur radius in px) to a Gaussian sigma for Skia's
26
+ * drop-shadow filter. Canvas measures shadow blur as a radius; Skia's filter is
27
+ * parameterised by sigma. `radius / 2` is the conventional approximation used
28
+ * across Skia-backed canvas shims and gives a visually matching glow.
29
+ */
30
+ function shadowBlurToSigma(shadowBlur: number): number {
31
+ 'worklet';
32
+
33
+ return shadowBlur / 2;
34
+ }
35
+
36
+ /**
37
+ * Apply the recorded glow (CSS shadow) to a Skia paint as a drop-shadow image
38
+ * filter. `dx = dy = 0` turns the drop shadow into a symmetric glow centred on
39
+ * the ink; `MakeDropShadow` (not `…Only`) keeps the source content, so the note
40
+ * still draws on top of its halo. No-op unless a `shadowColor` resolved.
41
+ */
42
+ function applyGlow(skPaint: SkPaint, paint: VexflowRecordingPaint) {
43
+ 'worklet';
44
+
45
+ if (paint.shadowColor == null) {
46
+ return;
47
+ }
48
+
49
+ const sigma = shadowBlurToSigma(paint.shadowBlur ?? 0);
50
+
51
+ skPaint.setImageFilter(
52
+ Skia.ImageFilter.MakeDropShadow(
53
+ 0,
54
+ 0,
55
+ sigma,
56
+ sigma,
57
+ Skia.Color(paint.shadowColor)
58
+ )
59
+ );
60
+ }
61
+
23
62
  function toSkiaRect(rect: VexflowRecordingRect) {
24
63
  'worklet';
25
64
 
@@ -47,6 +86,7 @@ function createFillPaint(paint: VexflowRecordingPaint): SkPaint {
47
86
  skPaint.setStyle(PaintStyle.Fill);
48
87
  skPaint.setAntiAlias(true);
49
88
  skPaint.setColor(Skia.Color(paint.color));
89
+ applyGlow(skPaint, paint);
50
90
 
51
91
  return skPaint;
52
92
  }
@@ -60,6 +100,11 @@ function createStrokePaint(paint: VexflowRecordingPaint): SkPaint {
60
100
  skPaint.setColor(Skia.Color(paint.color));
61
101
  skPaint.setStrokeWidth(paint.strokeWidth ?? 1);
62
102
  skPaint.setStrokeCap(mapRecordingLineCap(paint.strokeCap ?? 'butt'));
103
+ applyGlow(skPaint, paint);
104
+
105
+ if (paint.lineDash != null && paint.lineDash.length > 0) {
106
+ skPaint.setPathEffect(Skia.PathEffect.MakeDash(paint.lineDash));
107
+ }
63
108
 
64
109
  return skPaint;
65
110
  }
@@ -73,6 +118,56 @@ function createClearPaint(): SkPaint {
73
118
  return clearPaint;
74
119
  }
75
120
 
121
+ type PaintKind = 'fill' | 'stroke';
122
+
123
+ /**
124
+ * Resolve a recorded paint against an optional per-group style override map
125
+ * (`groupId -> VexflowStyleOverride`), merging the override OVER the recorded
126
+ * paint. Returns the original paint object (referentially) when no override
127
+ * applies, so untagged chrome (staff lines, clefs, …) is never restyled and a
128
+ * replay with no `styleOverrides` is byte-identical to a faithful replay.
129
+ *
130
+ * `kind` disambiguates which colour field wins: a fill command reads
131
+ * `fillColor ?? color`, a stroke command reads `strokeColor ?? color`, each
132
+ * falling back to the recorded colour. Glow (shadow) is applied to both kinds so
133
+ * the whole note glows; dash is stroke-only. This is the seam that lets a single
134
+ * recording be replayed many times in different styles (e.g. per-frame from a
135
+ * shared value) without re-recording.
136
+ */
137
+ function resolveStyle(
138
+ paint: VexflowRecordingPaint,
139
+ groupId: string | undefined,
140
+ kind: PaintKind,
141
+ styleOverrides?: Record<string, VexflowStyleOverride>
142
+ ): VexflowRecordingPaint {
143
+ 'worklet';
144
+
145
+ if (styleOverrides == null || groupId == null) {
146
+ return paint;
147
+ }
148
+
149
+ const override = styleOverrides[groupId];
150
+
151
+ if (override == null) {
152
+ return paint;
153
+ }
154
+
155
+ const color =
156
+ kind === 'fill'
157
+ ? override.fillColor ?? override.color ?? paint.color
158
+ : override.strokeColor ?? override.color ?? paint.color;
159
+
160
+ return {
161
+ ...paint,
162
+ color,
163
+ shadowColor: override.shadowColor ?? paint.shadowColor,
164
+ shadowBlur: override.shadowBlur ?? paint.shadowBlur,
165
+ // Dash is stroke-only; ignore any override.lineDash on fill commands.
166
+ lineDash:
167
+ kind === 'stroke' ? override.lineDash ?? paint.lineDash : paint.lineDash,
168
+ };
169
+ }
170
+
76
171
  function createFont(fontManager: FontManager, font: VexflowRecordingFont) {
77
172
  'worklet';
78
173
 
@@ -148,7 +243,15 @@ export function renderVexflowRecordingCommands(
148
243
  canvas: SkCanvas,
149
244
  commands: readonly VexflowRecordingCommand[],
150
245
  fontProvider: SkTypefaceFontProvider,
151
- defaultFont: string
246
+ defaultFont: string,
247
+ /**
248
+ * Optional `groupId -> VexflowStyleOverride` map. Commands tagged (via
249
+ * `beginColorGroup`/`endColorGroup`) with a `groupId` present here are drawn
250
+ * with the override merged over their recorded paint — separate fill/stroke
251
+ * colours, a glow (shadow), and a stroke dash are all expressible. Omit for a
252
+ * byte-identical replay of the recorded style.
253
+ */
254
+ styleOverrides?: Record<string, VexflowStyleOverride>
152
255
  ) {
153
256
  'worklet';
154
257
 
@@ -177,7 +280,9 @@ export function renderVexflowRecordingCommands(
177
280
  case 'fillRect':
178
281
  canvas.drawRect(
179
282
  toSkiaRect(command.rect),
180
- createFillPaint(command.paint)
283
+ createFillPaint(
284
+ resolveStyle(command.paint, command.groupId, 'fill', styleOverrides)
285
+ )
181
286
  );
182
287
  break;
183
288
  case 'clearRect':
@@ -186,13 +291,22 @@ export function renderVexflowRecordingCommands(
186
291
  case 'fillPath':
187
292
  canvas.drawPath(
188
293
  buildPath(command.path),
189
- createFillPaint(command.paint)
294
+ createFillPaint(
295
+ resolveStyle(command.paint, command.groupId, 'fill', styleOverrides)
296
+ )
190
297
  );
191
298
  break;
192
299
  case 'strokePath':
193
300
  canvas.drawPath(
194
301
  buildPath(command.path),
195
- createStrokePaint(command.paint)
302
+ createStrokePaint(
303
+ resolveStyle(
304
+ command.paint,
305
+ command.groupId,
306
+ 'stroke',
307
+ styleOverrides
308
+ )
309
+ )
196
310
  );
197
311
  break;
198
312
  case 'fillText':
@@ -200,7 +314,9 @@ export function renderVexflowRecordingCommands(
200
314
  command.text,
201
315
  command.x,
202
316
  command.y,
203
- createFillPaint(command.paint),
317
+ createFillPaint(
318
+ resolveStyle(command.paint, command.groupId, 'fill', styleOverrides)
319
+ ),
204
320
  createFont(fontManager, command.font)
205
321
  );
206
322
  break;
@@ -13,6 +13,50 @@ export interface VexflowRecordingPaint {
13
13
  color: string;
14
14
  strokeCap?: VexflowRecordingLineCap;
15
15
  strokeWidth?: number;
16
+ /**
17
+ * Glow/shadow colour (CSS `shadowColor`). Recorded from
18
+ * `VexflowRecordingContext.setShadowColor`. Replayed in Skia as a drop-shadow
19
+ * image filter with `dx = dy = 0` (a glow around the ink), and overridable per
20
+ * group via `VexflowStyleOverride.shadowColor`.
21
+ */
22
+ shadowColor?: string;
23
+ /**
24
+ * Glow/shadow blur radius in px (CSS `shadowBlur`). Recorded from
25
+ * `VexflowRecordingContext.setShadowBlur`. Mapped to a Gaussian sigma of
26
+ * `shadowBlur / 2` at replay. Only takes effect when `shadowColor` is set.
27
+ */
28
+ shadowBlur?: number;
29
+ /**
30
+ * Dash pattern (CSS `setLineDash`), stroke only. Recorded from
31
+ * `VexflowRecordingContext.setLineDash`. Replayed as a Skia dash path effect
32
+ * and overridable per group via `VexflowStyleOverride.lineDash`.
33
+ */
34
+ lineDash?: number[];
35
+ }
36
+
37
+ /**
38
+ * A granular, disambiguated style override applied to every command sharing a
39
+ * `groupId` at replay (see `renderVexflowRecordingCommands`'s `styleOverrides`).
40
+ *
41
+ * Each field is merged OVER the recorded paint, so any field left undefined
42
+ * falls back to whatever was recorded. An override is resolved per command
43
+ * against the paint that command uses (fill vs stroke), which is why fill and
44
+ * stroke colours are separable here — the consumer can, e.g., fill a notehead
45
+ * green while stroking its stem red.
46
+ */
47
+ export interface VexflowStyleOverride {
48
+ /** Fill paint colour (noteheads, rests, glyphs, filled shapes). */
49
+ fillColor?: string;
50
+ /** Stroke paint colour (stems, ledger lines, beam edges). */
51
+ strokeColor?: string;
52
+ /** Shorthand applied to both fill and stroke (lower precedence than the two above). */
53
+ color?: string;
54
+ /** Glow colour (CSS `shadowColor`), applied to both fill and stroke so the whole note glows. */
55
+ shadowColor?: string;
56
+ /** Glow blur radius in px (CSS `shadowBlur`). Only takes effect when a `shadowColor` resolves. */
57
+ shadowBlur?: number;
58
+ /** Dash pattern (stroke only). */
59
+ lineDash?: number[];
16
60
  }
17
61
 
18
62
  export interface VexflowRecordingFont {
@@ -63,7 +107,14 @@ export type VexflowRecordingPathCommand =
63
107
  type: 'close';
64
108
  };
65
109
 
66
- export type VexflowRecordingCommand =
110
+ /**
111
+ * A recorded draw command. `groupId` (optional) is stamped by
112
+ * `beginColorGroup`/`endColorGroup` on the recording context: a replay can then
113
+ * recolor every command sharing a `groupId` from a `groupId -> color` override
114
+ * map without re-recording. Untagged commands (staff lines, clefs, …) are never
115
+ * overridden.
116
+ */
117
+ export type VexflowRecordingCommand = { groupId?: string } & (
67
118
  | {
68
119
  type: 'clear';
69
120
  color: string;
@@ -114,4 +165,5 @@ export type VexflowRecordingCommand =
114
165
  y: number;
115
166
  paint: VexflowRecordingPaint;
116
167
  font: VexflowRecordingFont;
117
- };
168
+ }
169
+ );
package/src/base/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as VexflowCanvas } from './VexflowCanvas';
2
2
  export { default as VexflowRecordingContext } from './VexflowRecordingContext';
3
+ export { renderVexflowRecordingCommands } from './VexflowRecordingReplay';
3
4
 
4
5
  export * from './VexflowColorScheme';
5
6
  export * from './VexflowRecordingTypes';