vexflow-native 1.8.0 → 2.0.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 (165) hide show
  1. package/README.md +71 -403
  2. package/lib/module/base/FontManager.js +5 -5
  3. package/lib/module/base/FontManager.js.map +1 -1
  4. package/lib/module/base/VexflowCanvas.js +1 -1
  5. package/lib/module/base/VexflowCanvas.js.map +1 -1
  6. package/lib/module/base/VexflowRecordingContext.js +2 -0
  7. package/lib/module/base/VexflowRecordingContext.js.map +1 -1
  8. package/lib/module/base/VexflowRecordingReplay.js +1 -1
  9. package/lib/module/base/VexflowRecordingReplay.js.map +1 -1
  10. package/lib/module/base/index.js +1 -0
  11. package/lib/module/base/index.js.map +1 -1
  12. package/lib/module/musicxml/MusicXmlParser/MeasureParser.js +24 -7
  13. package/lib/module/musicxml/MusicXmlParser/MeasureParser.js.map +1 -1
  14. package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js +11 -3
  15. package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js.map +1 -1
  16. package/lib/module/musicxml/MusicXmlParser/Spanners.js +21 -5
  17. package/lib/module/musicxml/MusicXmlParser/Spanners.js.map +1 -1
  18. package/lib/module/musicxml/MusicXmlParser/mappers.js +1 -1
  19. package/lib/module/musicxml/MusicXmlParser/mappers.js.map +1 -1
  20. package/lib/module/{state/constants.js → percussion/index.js} +3 -3
  21. package/lib/module/percussion/index.js.map +1 -0
  22. package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js +4 -3
  23. package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js.map +1 -1
  24. package/lib/module/renderer/ScoreRenderer/ScorePlayhead.js +1 -1
  25. package/lib/module/renderer/ScoreRenderer/ScorePlayhead.js.map +1 -1
  26. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +5 -1
  27. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
  28. package/lib/module/renderer/ScoreRenderer/utils.js +1 -1
  29. package/lib/module/renderer/ScoreRenderer/utils.js.map +1 -1
  30. package/lib/module/renderer/fixedNoteSpacing.js +56 -0
  31. package/lib/module/renderer/fixedNoteSpacing.js.map +1 -0
  32. package/lib/module/renderer/index.js +1 -0
  33. package/lib/module/renderer/index.js.map +1 -1
  34. package/lib/module/renderer/itemLayout.js +108 -0
  35. package/lib/module/renderer/itemLayout.js.map +1 -0
  36. package/lib/module/renderer/measure.js +30 -106
  37. package/lib/module/renderer/measure.js.map +1 -1
  38. package/lib/module/renderer/measureBounds.js +73 -0
  39. package/lib/module/renderer/measureBounds.js.map +1 -0
  40. package/lib/module/renderer/measureModifiers.js +99 -0
  41. package/lib/module/renderer/measureModifiers.js.map +1 -0
  42. package/lib/module/renderer/noteModifiers.js +212 -0
  43. package/lib/module/renderer/noteModifiers.js.map +1 -0
  44. package/lib/module/renderer/render.js +33 -116
  45. package/lib/module/renderer/render.js.map +1 -1
  46. package/lib/module/renderer/scale.js +16 -2
  47. package/lib/module/renderer/scale.js.map +1 -1
  48. package/lib/module/renderer/scoreParsing.js +37 -199
  49. package/lib/module/renderer/scoreParsing.js.map +1 -1
  50. package/lib/module/renderer/stave.js +19 -3
  51. package/lib/module/renderer/stave.js.map +1 -1
  52. package/lib/module/renderer/useScoreRecording.js +10 -3
  53. package/lib/module/renderer/useScoreRecording.js.map +1 -1
  54. package/lib/module/renderer/vfKeys.js +72 -0
  55. package/lib/module/renderer/vfKeys.js.map +1 -0
  56. package/lib/module/state/index.js +1 -1
  57. package/lib/module/state/index.js.map +1 -1
  58. package/lib/typescript/src/base/FontManager.d.ts +3 -2
  59. package/lib/typescript/src/base/FontManager.d.ts.map +1 -1
  60. package/lib/typescript/src/base/VexflowRecordingContext.d.ts +2 -1
  61. package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -1
  62. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +1 -1
  63. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -1
  64. package/lib/typescript/src/base/index.d.ts +1 -0
  65. package/lib/typescript/src/base/index.d.ts.map +1 -1
  66. package/lib/typescript/src/base/types.d.ts +1 -1
  67. package/lib/typescript/src/base/types.d.ts.map +1 -1
  68. package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts +4 -2
  69. package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts.map +1 -1
  70. package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts.map +1 -1
  71. package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts +6 -1
  72. package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts.map +1 -1
  73. package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts +6 -1
  74. package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts.map +1 -1
  75. package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts.map +1 -1
  76. package/lib/typescript/src/musicxml/index.d.ts +1 -0
  77. package/lib/typescript/src/musicxml/index.d.ts.map +1 -1
  78. package/lib/typescript/src/percussion/index.d.ts +4 -0
  79. package/lib/typescript/src/percussion/index.d.ts.map +1 -0
  80. package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts +1 -1
  81. package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts.map +1 -1
  82. package/lib/typescript/src/renderer/ScoreRenderer/ScorePlayhead.d.ts +1 -1
  83. package/lib/typescript/src/renderer/ScoreRenderer/ScorePlayhead.d.ts.map +1 -1
  84. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
  85. package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +1 -1
  86. package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -1
  87. package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts +1 -1
  88. package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts.map +1 -1
  89. package/lib/typescript/src/renderer/fixedNoteSpacing.d.ts +17 -0
  90. package/lib/typescript/src/renderer/fixedNoteSpacing.d.ts.map +1 -0
  91. package/lib/typescript/src/renderer/index.d.ts +2 -0
  92. package/lib/typescript/src/renderer/index.d.ts.map +1 -1
  93. package/lib/typescript/src/renderer/itemLayout.d.ts +23 -0
  94. package/lib/typescript/src/renderer/itemLayout.d.ts.map +1 -0
  95. package/lib/typescript/src/renderer/layout.d.ts +1 -1
  96. package/lib/typescript/src/renderer/layout.d.ts.map +1 -1
  97. package/lib/typescript/src/renderer/measure.d.ts +3 -6
  98. package/lib/typescript/src/renderer/measure.d.ts.map +1 -1
  99. package/lib/typescript/src/renderer/measureBounds.d.ts +13 -0
  100. package/lib/typescript/src/renderer/measureBounds.d.ts.map +1 -0
  101. package/lib/typescript/src/renderer/measureModifiers.d.ts +20 -0
  102. package/lib/typescript/src/renderer/measureModifiers.d.ts.map +1 -0
  103. package/lib/typescript/src/renderer/noteModifiers.d.ts +29 -0
  104. package/lib/typescript/src/renderer/noteModifiers.d.ts.map +1 -0
  105. package/lib/typescript/src/renderer/render.d.ts +2 -27
  106. package/lib/typescript/src/renderer/render.d.ts.map +1 -1
  107. package/lib/typescript/src/renderer/scale.d.ts.map +1 -1
  108. package/lib/typescript/src/renderer/scoreParsing.d.ts +14 -42
  109. package/lib/typescript/src/renderer/scoreParsing.d.ts.map +1 -1
  110. package/lib/typescript/src/renderer/stave.d.ts +2 -0
  111. package/lib/typescript/src/renderer/stave.d.ts.map +1 -1
  112. package/lib/typescript/src/renderer/types.d.ts +52 -3
  113. package/lib/typescript/src/renderer/types.d.ts.map +1 -1
  114. package/lib/typescript/src/renderer/useScoreRecording.d.ts +3 -3
  115. package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
  116. package/lib/typescript/src/renderer/vfKeys.d.ts +17 -0
  117. package/lib/typescript/src/renderer/vfKeys.d.ts.map +1 -0
  118. package/lib/typescript/src/state/index.d.ts +1 -1
  119. package/lib/typescript/src/state/index.d.ts.map +1 -1
  120. package/lib/typescript/src/state/types.d.ts +23 -5
  121. package/lib/typescript/src/state/types.d.ts.map +1 -1
  122. package/package.json +31 -17
  123. package/src/base/FontManager.ts +5 -11
  124. package/src/base/TextMeasureContext.ts +1 -1
  125. package/src/base/VexflowCanvas.tsx +1 -1
  126. package/src/base/VexflowRecordingContext.ts +2 -4
  127. package/src/base/VexflowRecordingReplay.ts +1 -1
  128. package/src/base/index.ts +1 -0
  129. package/src/base/types.ts +1 -1
  130. package/src/musicxml/MusicXmlParser/InternalTypes.ts +5 -2
  131. package/src/musicxml/MusicXmlParser/MeasureParser.ts +36 -7
  132. package/src/musicxml/MusicXmlParser/MusicXmlDirections.ts +25 -8
  133. package/src/musicxml/MusicXmlParser/Spanners.ts +27 -4
  134. package/src/musicxml/MusicXmlParser/mappers.ts +7 -0
  135. package/src/musicxml/index.ts +1 -0
  136. package/src/percussion/index.ts +7 -0
  137. package/src/renderer/Layout/VerticalSpacing.ts +1 -1
  138. package/src/renderer/ScoreRenderer/ScoreOverlayPicture.tsx +4 -7
  139. package/src/renderer/ScoreRenderer/ScorePlayhead.tsx +1 -1
  140. package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +5 -7
  141. package/src/renderer/ScoreRenderer/types.ts +1 -4
  142. package/src/renderer/ScoreRenderer/utils.ts +1 -1
  143. package/src/renderer/fixedNoteSpacing.ts +78 -0
  144. package/src/renderer/index.ts +8 -0
  145. package/src/renderer/itemLayout.ts +137 -0
  146. package/src/renderer/layout.ts +1 -1
  147. package/src/renderer/measure.tsx +84 -186
  148. package/src/renderer/measureBounds.ts +109 -0
  149. package/src/renderer/measureModifiers.ts +133 -0
  150. package/src/renderer/noteModifiers.ts +298 -0
  151. package/src/renderer/render.tsx +59 -169
  152. package/src/renderer/scale.ts +21 -1
  153. package/src/renderer/scoreParsing.tsx +77 -288
  154. package/src/renderer/stave.ts +22 -3
  155. package/src/renderer/types.ts +66 -3
  156. package/src/renderer/useScoreRecording.ts +12 -4
  157. package/src/renderer/vfKeys.ts +88 -0
  158. package/src/state/index.ts +1 -1
  159. package/src/state/types.ts +30 -5
  160. package/lib/module/musicxml/testfiles/lg-8102429.xml +0 -79620
  161. package/lib/module/state/constants.js.map +0 -1
  162. package/lib/typescript/src/state/constants.d.ts +0 -4
  163. package/lib/typescript/src/state/constants.d.ts.map +0 -1
  164. package/src/musicxml/testfiles/lg-8102429.xml +0 -79620
  165. package/src/state/constants.ts +0 -4
package/README.md CHANGED
@@ -1,441 +1,105 @@
1
1
  # vexflow-native
2
2
 
3
- React Native Skia bridge for rendering VexFlow music notation.
3
+ React Native Skia bridge for rendering VexFlow music notation: a typed score
4
+ model, a `ScoreRenderer` component with scrolling, playhead and per-item
5
+ style overrides, a MusicXML importer, and a low-level canvas for drawing with
6
+ VexFlow directly.
4
7
 
5
8
  ## Installation
6
9
 
7
10
  Install the library and its peer dependencies:
8
11
 
9
12
  ```sh
10
- npm install vexflow-native react react-native vexflow @shopify/react-native-skia react-native-gesture-handler react-native-reanimated react-native-worklets
13
+ npm install vexflow-native react react-native vexflow react-native-skia react-native-gesture-handler react-native-reanimated react-native-worklets
11
14
  ```
12
15
 
13
- `ScoreRenderer` uses gesture handling and Reanimated worklets for scrolling, so
14
- configure `react-native-gesture-handler`, `react-native-reanimated`, and
16
+ `ScoreRenderer` uses gesture handling and Reanimated worklets for scrolling,
17
+ so configure `react-native-gesture-handler`, `react-native-reanimated`, and
15
18
  `react-native-worklets` as required by your React Native app.
16
19
 
17
- ## Entrypoints
18
-
19
- - `vexflow-native` exports the low-level `VexflowCanvas` bridge for drawing with
20
- VexFlow directly.
21
- - `vexflow-native/renderer` exports `ScoreRenderer`, a React component that
22
- renders the typed score model.
23
- - `vexflow-native/state` exports the score state types, including `Score`.
24
- - `vexflow-native/musicxml` exports `parseMusicXmlToScore` and
25
- `MusicXmlParseError`.
26
-
27
- ## Fonts
28
-
29
- Load a notation font with Skia and pass the returned font provider to the
30
- renderer. The `defaultFont` prop must match one of the font family names passed
31
- to `useFonts`.
32
-
33
- ```tsx
34
- import { useFonts } from '@shopify/react-native-skia';
35
-
36
- import bravuraFont from './assets/fonts/Bravura.otf';
37
-
38
- const fontManager = useFonts({
39
- Bravura: [bravuraFont],
40
- });
41
-
42
- if (!fontManager) {
43
- return null;
44
- }
45
- ```
46
-
47
- ## React Native Skia web patches
48
-
49
- The example app includes a `patch-package` patch for
50
- `@shopify/react-native-skia@2.6.2` at
51
- `example/patches/@shopify+react-native-skia+2.6.2.patch`. The repository root
52
- applies it after install with:
53
-
54
- ```sh
55
- yarn workspace vexflow-native-example apply-patches
56
- ```
57
-
58
- The patch is needed by the web example with this Skia version. It:
59
-
60
- - lets Skia web resolve string asset sources;
61
- - forwards `JsiSkTypefaceFontProvider.matchFamilyStyle` to CanvasKit so fonts
62
- registered with `useFonts` can be matched by family name;
63
- - keeps a small diagnostic log in the web font manager patch.
64
-
65
- Native iOS and Android usage does not need this example patch. If your own app
66
- targets React Native Web with `@shopify/react-native-skia@2.6.2` and hits font
67
- matching or asset source issues, apply an equivalent patch in your app with
68
- `patch-package`. Re-check the patch when upgrading Skia, because it is tied to
69
- that package version and may become unnecessary after upstream changes.
70
-
71
- ## Render MusicXML
72
-
73
- Convert a MusicXML string into a `Score`, then render it with `ScoreRenderer`.
74
-
75
- ```tsx
76
- import React, { useMemo } from 'react';
77
- import { View } from 'react-native';
78
- import { useFonts } from '@shopify/react-native-skia';
79
- import { ScoreRenderer } from 'vexflow-native/renderer';
80
- import {
81
- MusicXmlParseError,
82
- parseMusicXmlToScore,
83
- } from 'vexflow-native/musicxml';
84
-
85
- import bravuraFont from './assets/fonts/Bravura.otf';
86
-
87
- type MusicXmlScoreProps = {
88
- xml: string;
89
- };
90
-
91
- export function MusicXmlScore({ xml }: MusicXmlScoreProps) {
92
- const fontManager = useFonts({
93
- Bravura: [bravuraFont],
94
- });
95
- const score = useMemo(
96
- () => parseMusicXmlToScore(xml, { scoreId: 'imported-score' }),
97
- [xml]
98
- );
99
-
100
- if (!fontManager) {
101
- return null;
102
- }
103
-
104
- return (
105
- <View style={{ flex: 1 }}>
106
- <ScoreRenderer
107
- score={score}
108
- defaultFont="Bravura"
109
- fontManager={fontManager}
110
- />
111
- </View>
112
- );
113
- }
114
-
115
- try {
116
- parseMusicXmlToScore('<score-timewise />');
117
- } catch (error) {
118
- if (error instanceof MusicXmlParseError) {
119
- // The current parser targets score-partwise MusicXML.
20
+ Load a notation font with Skia; the `defaultFont` prop must match one of the
21
+ family names passed to `useFonts`.
22
+
23
+ ### Requirements
24
+
25
+ | Package | Version |
26
+ | ------------------------- | ----------------------------- |
27
+ | `react-native-skia` | ≥ 3.0.0 |
28
+ | `react-native-reanimated` | ≥ 4.0.0 |
29
+ | `react-native-worklets` | ≥ 0.7.0 |
30
+ | `react` / `react-native` | React 19, React Native ≥ 0.78 |
31
+
32
+ - iOS 15.1 or newer.
33
+ - Android: minSdkVersion 26 (Android 8.0) or higher and a GPU with Vulkan.
34
+ react-native-skia 3 draws with Skia Graphite, which uses Vulkan on Android
35
+ and has no OpenGL fallback. The Android Emulator works with `-gpu auto` or
36
+ `-gpu host`, but may fall back to software (llvmpipe) Vulkan, so don't judge
37
+ performance there.
38
+ - Colour: `ScoreRenderer` and `VexflowCanvas` draw into react-native-skia 3's
39
+ Graphite `<Canvas>`, which picks its colour space itself: Display P3 on
40
+ wide-gamut Apple screens, sRGB elsewhere (always sRGB on Android). Colours
41
+ are managed, so sRGB colours look the same either way; there is no
42
+ `colorSpace` option.
43
+ - Web: react-native-skia 3.0.x throws from `matchFamilyStyle` on `useFonts`
44
+ providers, so scores need
45
+ [this patch](example/patches/react-native-skia+3.0.3.patch) (apply it with
46
+ `patch-package`) until upstream ships the fix.
47
+
48
+ With Expo, raise the Android minSdkVersion with `expo-build-properties`:
49
+
50
+ ```json
51
+ {
52
+ "expo": {
53
+ "plugins": [
54
+ ["expo-build-properties", { "android": { "minSdkVersion": 26 } }]
55
+ ]
120
56
  }
121
57
  }
122
58
  ```
123
59
 
124
- The MusicXML parser currently targets `score-partwise` documents. `score-timewise`
125
- input throws `MusicXmlParseError`.
126
-
127
- ## Render a Plain Score Object
60
+ In a bare React Native app, set `minSdkVersion = 26` in `buildscript.ext` of
61
+ `android/build.gradle`.
128
62
 
129
- Use `ScoreRenderer` directly when you already have score state or want to build
130
- it yourself.
63
+ ## Quick start
131
64
 
132
65
  ```tsx
133
- import React from 'react';
134
- import { View } from 'react-native';
135
- import { useFonts } from '@shopify/react-native-skia';
66
+ import { useMemo } from 'react';
67
+ import { useFonts } from 'react-native-skia';
136
68
  import { ScoreRenderer } from 'vexflow-native/renderer';
137
- import type { Score } from 'vexflow-native/state';
69
+ import { parseMusicXmlToScore } from 'vexflow-native/musicxml';
138
70
 
139
71
  import bravuraFont from './assets/fonts/Bravura.otf';
140
72
 
141
- const score: Score = {
142
- id: 'plain-score',
143
- defaults: {
144
- meter: {
145
- beats: 4,
146
- beatUnit: 4,
147
- },
148
- keySignature: {
149
- tonic: 'C',
150
- mode: 'major',
151
- },
152
- },
153
- staves: [
154
- {
155
- id: 'staff-1',
156
- order: 0,
157
- defaultClef: 'treble',
158
- measures: [
159
- {
160
- id: 'measure-1',
161
- number: 1,
162
- leftModifiers: {
163
- showClef: true,
164
- showKeySignature: true,
165
- showMeter: true,
166
- },
167
- voices: [
168
- {
169
- id: 'voice-1',
170
- index: 0,
171
- items: [
172
- {
173
- id: 'note-1',
174
- type: 'note',
175
- pitch: { step: 'C', octave: 4 },
176
- duration: { length: 'q' },
177
- voiceId: 'voice-1',
178
- },
179
- {
180
- id: 'note-2',
181
- type: 'note',
182
- pitch: { step: 'D', octave: 4 },
183
- duration: { length: 'q' },
184
- voiceId: 'voice-1',
185
- },
186
- {
187
- id: 'note-3',
188
- type: 'note',
189
- pitch: { step: 'E', octave: 4 },
190
- duration: { length: 'q' },
191
- voiceId: 'voice-1',
192
- },
193
- {
194
- id: 'note-4',
195
- type: 'note',
196
- pitch: { step: 'F', octave: 4 },
197
- duration: { length: 'q' },
198
- voiceId: 'voice-1',
199
- },
200
- ],
201
- },
202
- ],
203
- },
204
- ],
205
- },
206
- ],
207
- };
208
-
209
- export function PlainScore() {
210
- const fontManager = useFonts({
211
- Bravura: [bravuraFont],
212
- });
73
+ export function MusicXmlScore({ xml }: { xml: string }) {
74
+ const fontManager = useFonts({ Bravura: [bravuraFont] });
75
+ const score = useMemo(() => parseMusicXmlToScore(xml), [xml]);
213
76
 
214
77
  if (!fontManager) {
215
78
  return null;
216
79
  }
217
80
 
218
81
  return (
219
- <View style={{ flex: 1 }}>
220
- <ScoreRenderer
221
- score={score}
222
- defaultFont="Bravura"
223
- fontManager={fontManager}
224
- rendererType="document"
225
- />
226
- </View>
82
+ <ScoreRenderer
83
+ score={score}
84
+ defaultFont="Bravura"
85
+ fontManager={fontManager}
86
+ />
227
87
  );
228
88
  }
229
89
  ```
230
90
 
231
- `rendererType` is optional. The default is `document`; use `documentEven` for
232
- even measure widths across document systems, or `infiniteScore` for a horizontal
233
- single-system layout.
91
+ ## Documentation
234
92
 
235
- ## Drum Notation
93
+ | Entry point | Page | Contents |
94
+ | --------------------------- | ---------------------------------------- | ------------------------------------------------------------------ |
95
+ | `vexflow-native/state` | [docs/state.md](docs/state.md) | Score model: staves, measures, voices, pitches, attachments, meter |
96
+ | `vexflow-native/renderer` | [docs/renderer.md](docs/renderer.md) | `ScoreRenderer` props, layout contract, per-item hooks |
97
+ | `vexflow-native/musicxml` | [docs/musicxml.md](docs/musicxml.md) | `parseMusicXmlToScore` coverage and limitations |
98
+ | `vexflow-native/percussion` | [docs/percussion.md](docs/percussion.md) | One-line staff, sticking, flams, drags, accents, ghost notes |
99
+ | `vexflow-native` | [docs/canvas.md](docs/canvas.md) | `VexflowCanvas` and the recording layer |
236
100
 
237
- Percussion scores use the same score model: pick the `percussion` clef, set
238
- alternate noteheads and ghost flags on pitches, and attach articulations
239
- through `score.attachments`.
240
-
241
- ```tsx
242
- import type { NoteAttachment, Pitch } from 'vexflow-native/state';
243
-
244
- const hiHat: Pitch = { step: 'G', octave: 5, notehead: 'x' };
245
- const ghostSnare: Pitch = { step: 'C', octave: 5, ghost: true };
246
- const accentedSnare: Pitch = { step: 'C', octave: 5, accent: true };
247
-
248
- const accent: NoteAttachment = {
249
- id: 'accent-1',
250
- ownerId: 'note-1',
251
- type: 'articulation',
252
- articulation: 'accent',
253
- placement: 'above',
254
- };
255
-
256
- const flam: NoteAttachment = {
257
- id: 'flam-1',
258
- ownerId: 'note-1',
259
- type: 'grace',
260
- slash: true,
261
- notes: [{ pitch: { step: 'C', octave: 5 }, duration: { length: '8' } }],
262
- };
263
-
264
- const drag: NoteAttachment = {
265
- id: 'drag-1',
266
- ownerId: 'note-2',
267
- type: 'grace',
268
- notes: [
269
- { pitch: { step: 'C', octave: 5 }, duration: { length: '16' } },
270
- { pitch: { step: 'C', octave: 5 }, duration: { length: '16' } },
271
- ],
272
- };
273
-
274
- const rightHand: NoteAttachment = {
275
- id: 'sticking-1',
276
- ownerId: 'note-1',
277
- type: 'annotation',
278
- text: 'R',
279
- };
280
-
281
- const restSticking: NoteAttachment = {
282
- id: 'sticking-2',
283
- ownerId: 'rest-1',
284
- type: 'annotation',
285
- text: 'L',
286
- };
287
- ```
288
-
289
- - `pitch.notehead`: `x`, `circle-x`, `diamond`, `circle`, `square`, `triangle`,
290
- `triangle-down`, or `slash`.
291
- - `pitch.ghost`: wraps the notehead in parentheses.
292
- - `pitch.accent`: draws one accent (`>`) above the note or chord, however many
293
- of its pitches are flagged; skipped when the owner already has an `accent`
294
- articulation attachment.
295
- - Annotation attachments draw their `text` in a bold sans font under the
296
- owner (`placement: 'above'` puts it on top). The owner may be a note, a
297
- chord or a visible rest, so a sticking lane can mark silent slots too.
298
- - Articulation attachments accept an optional `placement` of `above` (default)
299
- or `below`.
300
- - Grace attachments draw their `notes` before the owner (a flam is one slashed
301
- grace 8th, a drag two beamed grace 16ths); `slash` adds the acciaccatura
302
- slash through the first stem. Grace notes stem up unless the owner's
303
- `stemDirection` is `down`.
304
-
305
- A single-drum part can use a one-line staff: set `lines: 1` on the staff and
306
- put every note on `ONE_LINE_STAFF_PITCH` (the staff keeps the 5-line pitch
307
- geometry, so that pitch lands on the visible line). `showClef: false` hides
308
- the first measure's clef (`showClef` undefined shows it on the first measure
309
- only); `lines` accepts 1, 3 or 5 (default 5).
310
-
311
- ```tsx
312
- import type { Staff } from 'vexflow-native/state';
313
- import { ONE_LINE_STAFF_PITCH } from 'vexflow-native/state';
314
-
315
- const snareLine: Staff = {
316
- id: 'snare',
317
- order: 0,
318
- defaultClef: 'percussion',
319
- lines: 1,
320
- measures: [
321
- {
322
- id: 'm1',
323
- number: 1,
324
- leftModifiers: { showClef: false, showMeter: true },
325
- voices: [
326
- {
327
- id: 'v1',
328
- index: 0,
329
- items: [
330
- {
331
- id: 'hit-1',
332
- type: 'note',
333
- voiceId: 'v1',
334
- pitch: ONE_LINE_STAFF_PITCH,
335
- duration: { length: 'q' },
336
- },
337
- ],
338
- },
339
- ],
340
- },
341
- ],
342
- };
343
- ```
344
-
345
- See `example/src/screens/DrumKitExample.tsx` for a full drum-kit groove with
346
- two voices, a triplet, an open hi-hat accent, a flam and a drag.
347
-
348
- ## Draw Directly with VexFlow
349
-
350
- Use `VexflowCanvas` when you want direct VexFlow control instead of the typed
351
- score model.
352
-
353
- ```tsx
354
- import React, { useCallback } from 'react';
355
- import { View } from 'react-native';
356
- import { useFonts } from '@shopify/react-native-skia';
357
- import { Formatter, Stave, StaveNote, Voice } from 'vexflow';
358
- import { VexflowCanvas, type OnDrawParams } from 'vexflow-native';
359
-
360
- import bravuraFont from './assets/fonts/Bravura.otf';
361
-
362
- export function DirectVexFlow() {
363
- const fontManager = useFonts({
364
- Bravura: [bravuraFont],
365
- });
366
-
367
- const onDraw = useCallback(({ ctx }: OnDrawParams) => {
368
- const stave = new Stave(10, 40, 400);
369
-
370
- stave.addClef('treble').addTimeSignature('4/4');
371
-
372
- const notes = [
373
- new StaveNote({ keys: ['c/4'], duration: 'q' }),
374
- new StaveNote({ keys: ['d/4'], duration: 'q' }),
375
- new StaveNote({ keys: ['e/4'], duration: 'q' }),
376
- new StaveNote({ keys: ['f/4'], duration: 'q' }),
377
- ];
378
-
379
- const voice = new Voice({ numBeats: 4, beatValue: 4 });
380
- voice.addTickables(notes);
381
-
382
- new Formatter().joinVoices([voice]).formatToStave([voice], stave);
383
-
384
- stave.setContext(ctx).draw();
385
- voice.draw(ctx, stave);
386
- }, []);
387
-
388
- if (!fontManager) {
389
- return null;
390
- }
391
-
392
- return (
393
- <View style={{ flex: 1 }}>
394
- <VexflowCanvas
395
- onDraw={onDraw}
396
- fontManager={fontManager}
397
- defaultFont="Bravura"
398
- />
399
- </View>
400
- );
401
- }
402
- ```
403
-
404
- ## ScoreRenderer props
405
-
406
- - `score`: typed score state to render.
407
- - `defaultFont`: font family name used as the default VexFlow font.
408
- - `fontManager`: Skia font provider returned by `useFonts`.
409
- - `colorScheme`: optional foreground, background, and ledger line colors.
410
- - `itemStyleOverrides`: optional Reanimated shared value mapping score item ids
411
- to replay-time fill/stroke color, glow, and dash overrides.
412
- - `rendererType`: `document`, `documentEven`, or `infiniteScore`.
413
- - `options`: optional renderer settings grouped by `insets`, `spacing`, and
414
- `render`; `render.scale` uniformly scales the notation without quality loss.
415
- - `scrollEnabled`: enables or disables pan scrolling. Defaults to `true`.
416
- - `showScrollbars`: shows scrollbars when the score overflows. Defaults to
417
- `true`.
418
- - `scrollOffset`: optional controlled Reanimated shared value for the scroll
419
- position along the renderer's axis. The renderer reads and writes it (pan
420
- gesture, clamping), and external writes move the content — the seam for
421
- playback auto-scroll. Must stay the same shared value for the component's
422
- lifetime.
423
- - `playhead`: optional Reanimated shared value positioning a playhead overlay
424
- (`{ x, y, height }` in `onItemsLayout` coordinates, `null` hides it). The
425
- overlay tracks scrolling on the UI thread without re-recording the score.
426
- - `playheadStyle`: optional playhead appearance (`color`, `width`,
427
- `borderRadius`, `opacity`); defaults derive from the color scheme
428
- foreground.
429
- - `onScrollGeometry`: optional callback fired when the scroll envelope
430
- changes (`axis`, `viewportSize`, `contentSize`, `maxScroll`) — everything a
431
- consumer needs to compute follow-scroll targets.
432
- - `onItemsLayout`: optional callback fired after each recording pass with the
433
- view-space geometry (at scroll offset 0) of rendered items and measures,
434
- including each measure's system band `y`/`height`.
435
- - `onReady`: optional callback fired once per mount, when the first score
436
- picture has been rasterized for a non-empty viewport. Later re-records
437
- (resize, option changes) do not re-fire it — the seam for hiding a loading
438
- indicator once the score is actually on screen.
101
+ Generate the API reference from the TypeScript sources with `yarn docs:api`
102
+ (output in `docs/api/`, not committed).
439
103
 
440
104
  ## Contributing
441
105
 
@@ -443,6 +107,10 @@ export function DirectVexFlow() {
443
107
  - [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
444
108
  - [Code of conduct](CODE_OF_CONDUCT.md)
445
109
 
110
+ Before sending changes run `yarn lint:fix`, `yarn format`, `yarn typecheck`,
111
+ `yarn test` and `yarn prepare` (builds `lib/`). Public API changes update the
112
+ matching `docs/` page in the same change.
113
+
446
114
  ## License
447
115
 
448
116
  MIT
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { FontWeight, FontSlant, FontWidth, Skia } from '@shopify/react-native-skia';
3
+ import { FontWeight, FontSlant, FontWidth, Skia } from 'react-native-skia';
4
4
 
5
5
  // import Logger, { LogCategory } from '../shared/Logger';
6
6
 
@@ -67,10 +67,8 @@ function parseSlant(style) {
67
67
  }
68
68
  export default class FontManager {
69
69
  __workletClass = true;
70
- // Each runtime's clone of a __workletClass instance owns its own caches
71
- // from the moment of capture; entries only ever hold same-usage-pattern
72
- // Skia host objects, which are shareable across reanimated runtimes (the
73
- // provider itself already crosses the same way).
70
+ // Instances never cross runtimes; each runtime builds its own, so these
71
+ // caches are runtime-local.
74
72
  familyMatchCache = {};
75
73
  skFontCache = {};
76
74
  constructor(fontProvider, defaultFontName) {
@@ -148,6 +146,8 @@ export default class FontManager {
148
146
  }
149
147
  return null;
150
148
  }
149
+
150
+ /** @internal */
151
151
  resolveFontDescriptor(font, size, weight, style) {
152
152
  return {
153
153
  family: this.matchFontFamilyName(font || ''),
@@ -1 +1 @@
1
- {"version":3,"names":["FontWeight","FontSlant","FontWidth","Skia","PT_TO_PX","parseSize","size","match","trim","value","parseFloat","unit","parseWeight","weight","weightStr","String","toLowerCase","Normal","Bold","Thin","ExtraLight","Light","Medium","SemiBold","ExtraBold","Black","parseSlant","style","styleStr","normal","Upright","italic","Italic","oblique","Oblique","FontManager","__workletClass","familyMatchCache","skFontCache","constructor","fontProvider","defaultFontName","families","i","countFamilies","push","getFamilyName","includes","Error","join","familiesLower","map","family","isFamilyAvailable","getFamiliesFromFont","font","split","f","matchFontFamilyName","cacheKey","cached","matched","matchSystemTypeface","systemFontMgr","undefined","FontMgr","System","typeface","matchFamilyStyle","resolveFontDescriptor","slant","width","createSkFont","resolvedSize","resolvedWeight","fontStyle","requested","skFont","Font"],"sourceRoot":"../../../src","sources":["base/FontManager.ts"],"mappings":";;AACA,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,IAAI,QACC,4BAA4B;;AAQnC;;AAEA;;AAUA,MAAMC,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;;AAExB,SAASC,SAASA,CAACC,IAAsB,EAAU;EACjD,SAAS;;EAET,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;EAEA,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAI,CAAC,CAAC,CAACD,KAAK,CAAC,gCAAgC,CAAC;IAEjE,IAAIA,KAAK,EAAE;MACT,MAAME,KAAK,GAAGC,UAAU,CAACH,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;MAC5C,MAAMI,IAAI,GAAGJ,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI;MAE7B,QAAQI,IAAI;QACV,KAAK,IAAI;UACP,OA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I,EAAEH,MAAM,IAAI,EAAE;IACtE,MAAMO,QAAQ,GAAG,GAAGiB,SAAS,IAAIxB,MAAM,IAAIqB,YAAY,IAAIC,cAAc,IAAIJ,KAAK,EAAE;IACpF,MAAMV,MAAM,GAAG,IAAI,CAACtB,WAAW,CAACqB,QAAQ,CAAC;IAEzC,IAAIC,MAAM,IAAI,IAAI,EAAE;MAClB,OAAOA,MAAM;IACf;IAEA,MAAMO,QAAQ,GACZ,IAAI,CAACL,mBAAmB,CAACP,IAAI,EAAEoB,SAAS,CAAC,IACzC,IAAI,CAACnC,YAAY,CAAC4B,gBAAgB,CAAChB,MAAM,EAAEuB,SAAS,CAAC;IAEvD,IAAI,CAACR,QAAQ,EAAE;MACb,MAAM,IAAInB,KAAK,CACb,mEAAmEI,MAAM,kBAAkBsB,cAAc,gBAAgBJ,KAAK,IAChI,CAAC;IACH;IAEA,MAAMO,MAAM,GAAG1E,IAAI,CAAC2E,IAAI,CAACX,QAAQ,EAAEM,YAAY,GAAGrE,QAAQ,CAAC,CAAC,CAAC;IAC7D,IAAI,CAACkC,WAAW,CAACqB,QAAQ,CAAC,GAAGkB,MAAM;IACnC,OAAOA,MAAM;EACf;AACF","ignoreList":[]}
1
+ {"version":3,"names":["FontWeight","FontSlant","FontWidth","Skia","PT_TO_PX","parseSize","size","match","trim","value","parseFloat","unit","parseWeight","weight","weightStr","String","toLowerCase","Normal","Bold","Thin","ExtraLight","Light","Medium","SemiBold","ExtraBold","Black","parseSlant","style","styleStr","normal","Upright","italic","Italic","oblique","Oblique","FontManager","__workletClass","familyMatchCache","skFontCache","constructor","fontProvider","defaultFontName","families","i","countFamilies","push","getFamilyName","includes","Error","join","familiesLower","map","family","isFamilyAvailable","getFamiliesFromFont","font","split","f","matchFontFamilyName","cacheKey","cached","matched","matchSystemTypeface","systemFontMgr","undefined","FontMgr","System","typeface","matchFamilyStyle","resolveFontDescriptor","slant","width","createSkFont","resolvedSize","resolvedWeight","fontStyle","requested","skFont","Font"],"source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E,IAAI,CAACX,QAAQ,EAAEM,YAAY,GAAGrE,QAAQ,CAAC,CAAC,CAAC;IAC7D,IAAI,CAACkC,WAAW,CAACqB,QAAQ,CAAC,GAAGkB,MAAM;IACnC,OAAOA,MAAM;EACf;AACF","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { Canvas, Picture, Skia, useCanvasRef, useCanvasSize } from '@shopify/react-native-skia';
3
+ import { Canvas, Picture, Skia, useCanvasRef, useCanvasSize } from 'react-native-skia';
4
4
  import React, { useMemo } from 'react';
5
5
  import { StyleSheet } from 'react-native';
6
6
  import VexflowRecordingContext from "./VexflowRecordingContext.js";
@@ -1 +1 @@
1
- {"version":3,"names":["Canvas","Picture","Skia","useCanvasRef","useCanvasSize","React","useMemo","StyleSheet","VexflowRecordingContext","renderVexflowRecordingCommands","jsx","_jsx","VexflowCanvas","props","onDraw","fontManager","defaultFont","canvasRef","size","canvasSize","picture","recorder","PictureRecorder","canvas","beginRecording","XYWHRect","width","height","ctx","finish","finishRecordingAsPicture","style","styles","ref","children","create","flex"],"sourceRoot":"../../../src","sources":["base/VexflowCanvas.tsx"],"mappings":";;AAAA,SACEA,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,YAAY,EACZC,aAAa,QACR,4BAA4B;AACnC,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,UAAU,QAAQ,cAAc;AAGzC,OAAOC,uBAAuB,MAAM,8BAA2B;AAC/D,SAASC,8BAA8B,QAAQ,6BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1E,MAAMC,aAA2C,GAAIC,KAAK,IAAK;EAC7D,MAAM;IACJC,MAAM;IACNC,WAAW;IACXC;IACA;IACA;IACA;EACF,CAAC,GAAGH,KAAK;EAET,MAAMI,SAAS,GAAGd,YAAY,CAAC,CAAC;EAChC,MAAM;IAAEe,IAAI,EAAEC;EAAW,CAAC,GAAGf,aAAa,CAACa,SAAS,CAAC;EAErD,MAAMG,OAAO,GAAGd,OAAO,CAAC,MAAM;IAC5B,MAAMe,QAAQ,GAAGnB,IAAI,CAACoB,eAAe,CAAC,CAAC;IACvC,MAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAc,CACpCtB,IAAI,CAACuB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAEN,UAAU,CAACO,KAAK,EAAEP,UAAU,CAACQ,MAAM,CACzD,CAAC;IAED,MAAMC,GAAG,GAAG,IAAIpB,uBAAuB,CAACO,WAAW,EAAEC,WAAW,CAAC;IAEjEF,MAAM,CAAC;MAAEc,GAAG;MAAEF,KAAK,EAAEP,UAAU,CAACO,KAAK;MAAEC,MAAM,EAAER,UAAU,CAACQ;IAAO,CAAC,CAAC;IACnElB,8BAA8B,CAC5Bc,MAAM,EACNK,GAAG,CAACC,MAAM,CAAC,CAAC,EACZd,WAAW,EACXC,WACF,CAAC;IAED,OAAOK,QAAQ,CAACS,wBAAwB,CAAC,CAAC;EAC5C,CAAC,EAAE,CAAChB,MAAM,EAAEK,UAAU,EAAEJ,WAAW,EAAEC,WAAW,CAAC,CAAC;EAElD,oBACEL,IAAA,CAACX,MAAM;IAAC+B,KAAK,EAAEC,MAAM,CAACT,MAAO;IAACU,GAAG,EAAEhB,SAAU;IAAAiB,QAAA,eAC3CvB,IAAA,CAACV,OAAO;MAACmB,OAAO,EAAEA;IAAQ,CAAE;EAAC,CACvB,CAAC;AAEb,CAAC;AAED,eAAeR,aAAa;AAE5B,MAAMoB,MAAM,GAAGzB,UAAU,CAAC4B,MAAM,CAAC;EAC/BZ,MAAM,EAAE;IACNa,IAAI,EAAE,CAAC,CAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Canvas","Picture","Skia","useCanvasRef","useCanvasSize","React","useMemo","StyleSheet","VexflowRecordingContext","renderVexflowRecordingCommands","jsx","_jsx","VexflowCanvas","props","onDraw","fontManager","defaultFont","canvasRef","size","canvasSize","picture","recorder","PictureRecorder","canvas","beginRecording","XYWHRect","width","height","ctx","finish","finishRecordingAsPicture","style","styles","ref","children","create","flex"],"sourceRoot":"../../../src","sources":["base/VexflowCanvas.tsx"],"mappings":";;AAAA,SACEA,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,YAAY,EACZC,aAAa,QACR,mBAAmB;AAC1B,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,UAAU,QAAQ,cAAc;AAGzC,OAAOC,uBAAuB,MAAM,8BAA2B;AAC/D,SAASC,8BAA8B,QAAQ,6BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1E,MAAMC,aAA2C,GAAIC,KAAK,IAAK;EAC7D,MAAM;IACJC,MAAM;IACNC,WAAW;IACXC;IACA;IACA;IACA;EACF,CAAC,GAAGH,KAAK;EAET,MAAMI,SAAS,GAAGd,YAAY,CAAC,CAAC;EAChC,MAAM;IAAEe,IAAI,EAAEC;EAAW,CAAC,GAAGf,aAAa,CAACa,SAAS,CAAC;EAErD,MAAMG,OAAO,GAAGd,OAAO,CAAC,MAAM;IAC5B,MAAMe,QAAQ,GAAGnB,IAAI,CAACoB,eAAe,CAAC,CAAC;IACvC,MAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAc,CACpCtB,IAAI,CAACuB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAEN,UAAU,CAACO,KAAK,EAAEP,UAAU,CAACQ,MAAM,CACzD,CAAC;IAED,MAAMC,GAAG,GAAG,IAAIpB,uBAAuB,CAACO,WAAW,EAAEC,WAAW,CAAC;IAEjEF,MAAM,CAAC;MAAEc,GAAG;MAAEF,KAAK,EAAEP,UAAU,CAACO,KAAK;MAAEC,MAAM,EAAER,UAAU,CAACQ;IAAO,CAAC,CAAC;IACnElB,8BAA8B,CAC5Bc,MAAM,EACNK,GAAG,CAACC,MAAM,CAAC,CAAC,EACZd,WAAW,EACXC,WACF,CAAC;IAED,OAAOK,QAAQ,CAACS,wBAAwB,CAAC,CAAC;EAC5C,CAAC,EAAE,CAAChB,MAAM,EAAEK,UAAU,EAAEJ,WAAW,EAAEC,WAAW,CAAC,CAAC;EAElD,oBACEL,IAAA,CAACX,MAAM;IAAC+B,KAAK,EAAEC,MAAM,CAACT,MAAO;IAACU,GAAG,EAAEhB,SAAU;IAAAiB,QAAA,eAC3CvB,IAAA,CAACV,OAAO;MAACmB,OAAO,EAAEA;IAAQ,CAAE;EAAC,CACvB,CAAC;AAEb,CAAC;AAED,eAAeR,aAAa;AAE5B,MAAMoB,MAAM,GAAGzB,UAAU,CAAC4B,MAAM,CAAC;EAC/BZ,MAAM,EAAE;IACNa,IAAI,EAAE,CAAC,CAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
@@ -54,6 +54,8 @@ export default class VexflowRecordingContext {
54
54
  getCurrentSkFont() {
55
55
  return this.textFont;
56
56
  }
57
+
58
+ /** @internal */
57
59
  getMeasurementContext() {
58
60
  return this.textMeasurementContext;
59
61
  }