vexflow-native 0.2.0 → 1.1.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 (259) hide show
  1. package/README.md +267 -37
  2. package/lib/module/base/FontManager.js +139 -0
  3. package/lib/module/base/FontManager.js.map +1 -0
  4. package/lib/module/base/TextMeasureContext.js +46 -0
  5. package/lib/module/base/TextMeasureContext.js.map +1 -0
  6. package/lib/module/base/VexflowCanvas.js +48 -0
  7. package/lib/module/base/VexflowCanvas.js.map +1 -0
  8. package/lib/module/base/VexflowColorScheme.js +16 -0
  9. package/lib/module/base/VexflowColorScheme.js.map +1 -0
  10. package/lib/module/base/VexflowRecordingContext.js +487 -0
  11. package/lib/module/base/VexflowRecordingContext.js.map +1 -0
  12. package/lib/module/base/VexflowRecordingReplay.js +214 -0
  13. package/lib/module/base/VexflowRecordingReplay.js.map +1 -0
  14. package/lib/module/base/VexflowRecordingTypes.js +4 -0
  15. package/lib/module/base/VexflowRecordingTypes.js.map +1 -0
  16. package/lib/module/base/index.js +9 -0
  17. package/lib/module/base/index.js.map +1 -0
  18. package/lib/module/base/setupVexflowReactNative.js +96 -0
  19. package/lib/module/base/setupVexflowReactNative.js.map +1 -0
  20. package/lib/module/base/types.js +4 -0
  21. package/lib/module/base/types.js.map +1 -0
  22. package/lib/module/base/utils.js +18 -0
  23. package/lib/module/base/utils.js.map +1 -0
  24. package/lib/module/musicxml/MusicXmlParser/InternalTypes.js +4 -0
  25. package/lib/module/musicxml/MusicXmlParser/InternalTypes.js.map +1 -0
  26. package/lib/module/musicxml/MusicXmlParser/MeasureParser.js +269 -0
  27. package/lib/module/musicxml/MusicXmlParser/MeasureParser.js.map +1 -0
  28. package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js +62 -0
  29. package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js.map +1 -0
  30. package/lib/module/musicxml/MusicXmlParser/MusicXmlTiming.js +124 -0
  31. package/lib/module/musicxml/MusicXmlParser/MusicXmlTiming.js.map +1 -0
  32. package/lib/module/musicxml/MusicXmlParser/PartParser.js +41 -0
  33. package/lib/module/musicxml/MusicXmlParser/PartParser.js.map +1 -0
  34. package/lib/module/musicxml/MusicXmlParser/Spanners.js +149 -0
  35. package/lib/module/musicxml/MusicXmlParser/Spanners.js.map +1 -0
  36. package/lib/module/musicxml/MusicXmlParser/XmlOrder.js +106 -0
  37. package/lib/module/musicxml/MusicXmlParser/XmlOrder.js.map +1 -0
  38. package/lib/module/musicxml/MusicXmlParser/index.js +110 -0
  39. package/lib/module/musicxml/MusicXmlParser/index.js.map +1 -0
  40. package/lib/module/musicxml/MusicXmlParser/mappers.js +312 -0
  41. package/lib/module/musicxml/MusicXmlParser/mappers.js.map +1 -0
  42. package/lib/module/musicxml/MusicXmlParser/types.js +10 -0
  43. package/lib/module/musicxml/MusicXmlParser/types.js.map +1 -0
  44. package/lib/module/musicxml/index.js +4 -0
  45. package/lib/module/musicxml/index.js.map +1 -0
  46. package/lib/module/musicxml/testfiles/lg-8102429.xml +79620 -0
  47. package/lib/module/renderer/Layout/DocumentLayout.js +156 -0
  48. package/lib/module/renderer/Layout/DocumentLayout.js.map +1 -0
  49. package/lib/module/renderer/Layout/LayoutMetrics.js +13 -0
  50. package/lib/module/renderer/Layout/LayoutMetrics.js.map +1 -0
  51. package/lib/module/renderer/Layout/VerticalSpacing.js +69 -0
  52. package/lib/module/renderer/Layout/VerticalSpacing.js.map +1 -0
  53. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +277 -0
  54. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -0
  55. package/lib/module/renderer/ScoreRenderer/ScoreScrollbar.js +108 -0
  56. package/lib/module/renderer/ScoreRenderer/ScoreScrollbar.js.map +1 -0
  57. package/lib/module/renderer/ScoreRenderer/index.js +7 -0
  58. package/lib/module/renderer/ScoreRenderer/index.js.map +1 -0
  59. package/lib/module/renderer/ScoreRenderer/types.js +4 -0
  60. package/lib/module/renderer/ScoreRenderer/types.js.map +1 -0
  61. package/lib/module/renderer/ScoreRenderer/useScoreScroll.js +77 -0
  62. package/lib/module/renderer/ScoreRenderer/useScoreScroll.js.map +1 -0
  63. package/lib/module/renderer/colorScheme.js +17 -0
  64. package/lib/module/renderer/colorScheme.js.map +1 -0
  65. package/lib/module/renderer/constants.js +18 -0
  66. package/lib/module/renderer/constants.js.map +1 -0
  67. package/lib/module/renderer/index.js +6 -0
  68. package/lib/module/renderer/index.js.map +1 -0
  69. package/lib/module/renderer/layout.js +153 -0
  70. package/lib/module/renderer/layout.js.map +1 -0
  71. package/lib/module/renderer/measure.js +202 -0
  72. package/lib/module/renderer/measure.js.map +1 -0
  73. package/lib/module/renderer/render.js +184 -0
  74. package/lib/module/renderer/render.js.map +1 -0
  75. package/lib/module/renderer/scoreParsing.js +230 -0
  76. package/lib/module/renderer/scoreParsing.js.map +1 -0
  77. package/lib/module/renderer/types.js +4 -0
  78. package/lib/module/renderer/types.js.map +1 -0
  79. package/lib/module/renderer/useScoreRecording.js +112 -0
  80. package/lib/module/renderer/useScoreRecording.js.map +1 -0
  81. package/lib/module/renderer/viewport.js +26 -0
  82. package/lib/module/renderer/viewport.js.map +1 -0
  83. package/lib/module/shared/Logger.js +67 -0
  84. package/lib/module/shared/Logger.js.map +1 -0
  85. package/lib/module/state/index.js +4 -0
  86. package/lib/module/state/index.js.map +1 -0
  87. package/lib/module/state/types.js +2 -0
  88. package/lib/module/state/types.js.map +1 -0
  89. package/lib/module/types.js +7 -0
  90. package/lib/module/types.js.map +1 -1
  91. package/lib/module/utils.js +42 -77
  92. package/lib/module/utils.js.map +1 -1
  93. package/lib/typescript/src/base/FontManager.d.ts +23 -0
  94. package/lib/typescript/src/base/FontManager.d.ts.map +1 -0
  95. package/lib/typescript/src/base/TextMeasureContext.d.ts +22 -0
  96. package/lib/typescript/src/base/TextMeasureContext.d.ts.map +1 -0
  97. package/lib/typescript/src/base/VexflowCanvas.d.ts +5 -0
  98. package/lib/typescript/src/base/VexflowCanvas.d.ts.map +1 -0
  99. package/lib/typescript/src/base/VexflowColorScheme.d.ts +7 -0
  100. package/lib/typescript/src/base/VexflowColorScheme.d.ts.map +1 -0
  101. package/lib/typescript/src/base/VexflowRecordingContext.d.ts +103 -0
  102. package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -0
  103. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +12 -0
  104. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -0
  105. package/lib/typescript/src/base/VexflowRecordingTypes.d.ts +146 -0
  106. package/lib/typescript/src/base/VexflowRecordingTypes.d.ts.map +1 -0
  107. package/lib/typescript/src/base/index.d.ts +7 -0
  108. package/lib/typescript/src/base/index.d.ts.map +1 -0
  109. package/lib/typescript/src/base/setupVexflowReactNative.d.ts +11 -0
  110. package/lib/typescript/src/base/setupVexflowReactNative.d.ts.map +1 -0
  111. package/lib/typescript/src/base/types.d.ts +13 -0
  112. package/lib/typescript/src/base/types.d.ts.map +1 -0
  113. package/lib/typescript/src/base/utils.d.ts +2 -0
  114. package/lib/typescript/src/base/utils.d.ts.map +1 -0
  115. package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts +30 -0
  116. package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts.map +1 -0
  117. package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts +4 -0
  118. package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts.map +1 -0
  119. package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts +5 -0
  120. package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts.map +1 -0
  121. package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlTiming.d.ts +6 -0
  122. package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlTiming.d.ts.map +1 -0
  123. package/lib/typescript/src/musicxml/MusicXmlParser/PartParser.d.ts +8 -0
  124. package/lib/typescript/src/musicxml/MusicXmlParser/PartParser.d.ts.map +1 -0
  125. package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts +4 -0
  126. package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts.map +1 -0
  127. package/lib/typescript/src/musicxml/MusicXmlParser/XmlOrder.d.ts +20 -0
  128. package/lib/typescript/src/musicxml/MusicXmlParser/XmlOrder.d.ts.map +1 -0
  129. package/lib/typescript/src/musicxml/MusicXmlParser/index.d.ts +5 -0
  130. package/lib/typescript/src/musicxml/MusicXmlParser/index.d.ts.map +1 -0
  131. package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts +15 -0
  132. package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts.map +1 -0
  133. package/lib/typescript/src/musicxml/MusicXmlParser/types.d.ts +13 -0
  134. package/lib/typescript/src/musicxml/MusicXmlParser/types.d.ts.map +1 -0
  135. package/lib/typescript/src/musicxml/index.d.ts +2 -0
  136. package/lib/typescript/src/musicxml/index.d.ts.map +1 -0
  137. package/lib/typescript/src/renderer/Layout/DocumentLayout.d.ts +10 -0
  138. package/lib/typescript/src/renderer/Layout/DocumentLayout.d.ts.map +1 -0
  139. package/lib/typescript/src/renderer/Layout/LayoutMetrics.d.ts +6 -0
  140. package/lib/typescript/src/renderer/Layout/LayoutMetrics.d.ts.map +1 -0
  141. package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts +9 -0
  142. package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts.map +1 -0
  143. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts +15 -0
  144. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -0
  145. package/lib/typescript/src/renderer/ScoreRenderer/ScoreScrollbar.d.ts +24 -0
  146. package/lib/typescript/src/renderer/ScoreRenderer/ScoreScrollbar.d.ts.map +1 -0
  147. package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts +5 -0
  148. package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts.map +1 -0
  149. package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +12 -0
  150. package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -0
  151. package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.d.ts +13 -0
  152. package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.d.ts.map +1 -0
  153. package/lib/typescript/src/renderer/colorScheme.d.ts +9 -0
  154. package/lib/typescript/src/renderer/colorScheme.d.ts.map +1 -0
  155. package/lib/typescript/src/renderer/constants.d.ts +5 -0
  156. package/lib/typescript/src/renderer/constants.d.ts.map +1 -0
  157. package/lib/typescript/src/renderer/index.d.ts +4 -0
  158. package/lib/typescript/src/renderer/index.d.ts.map +1 -0
  159. package/lib/typescript/src/renderer/layout.d.ts +56 -0
  160. package/lib/typescript/src/renderer/layout.d.ts.map +1 -0
  161. package/lib/typescript/src/renderer/measure.d.ts +23 -0
  162. package/lib/typescript/src/renderer/measure.d.ts.map +1 -0
  163. package/lib/typescript/src/renderer/render.d.ts +9 -0
  164. package/lib/typescript/src/renderer/render.d.ts.map +1 -0
  165. package/lib/typescript/src/renderer/scoreParsing.d.ts +76 -0
  166. package/lib/typescript/src/renderer/scoreParsing.d.ts.map +1 -0
  167. package/lib/typescript/src/renderer/types.d.ts +56 -0
  168. package/lib/typescript/src/renderer/types.d.ts.map +1 -0
  169. package/lib/typescript/src/renderer/useScoreRecording.d.ts +21 -0
  170. package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -0
  171. package/lib/typescript/src/renderer/viewport.d.ts +3 -0
  172. package/lib/typescript/src/renderer/viewport.d.ts.map +1 -0
  173. package/lib/typescript/src/shared/Logger.d.ts +18 -0
  174. package/lib/typescript/src/shared/Logger.d.ts.map +1 -0
  175. package/lib/typescript/src/state/index.d.ts +2 -0
  176. package/lib/typescript/src/state/index.d.ts.map +1 -0
  177. package/lib/typescript/src/state/types.d.ts +190 -0
  178. package/lib/typescript/src/state/types.d.ts.map +1 -0
  179. package/lib/typescript/src/types.d.ts +0 -6
  180. package/lib/typescript/src/types.d.ts.map +1 -1
  181. package/lib/typescript/src/utils.d.ts +0 -6
  182. package/lib/typescript/src/utils.d.ts.map +1 -1
  183. package/package.json +41 -14
  184. package/src/base/FontManager.ts +206 -0
  185. package/src/base/TextMeasureContext.ts +59 -0
  186. package/src/base/VexflowCanvas.tsx +60 -0
  187. package/src/base/VexflowColorScheme.ts +32 -0
  188. package/src/base/VexflowRecordingContext.ts +545 -0
  189. package/src/base/VexflowRecordingReplay.ts +327 -0
  190. package/src/base/VexflowRecordingTypes.ts +169 -0
  191. package/src/base/index.ts +7 -0
  192. package/src/base/setupVexflowReactNative.ts +124 -0
  193. package/src/base/types.ts +17 -0
  194. package/src/base/utils.ts +21 -0
  195. package/src/musicxml/MusicXmlParser/InternalTypes.ts +41 -0
  196. package/src/musicxml/MusicXmlParser/MeasureParser.ts +469 -0
  197. package/src/musicxml/MusicXmlParser/MusicXmlDirections.ts +84 -0
  198. package/src/musicxml/MusicXmlParser/MusicXmlTiming.ts +153 -0
  199. package/src/musicxml/MusicXmlParser/PartParser.ts +69 -0
  200. package/src/musicxml/MusicXmlParser/Spanners.ts +215 -0
  201. package/src/musicxml/MusicXmlParser/XmlOrder.ts +170 -0
  202. package/src/musicxml/MusicXmlParser/index.ts +144 -0
  203. package/src/musicxml/MusicXmlParser/mappers.ts +307 -0
  204. package/src/musicxml/MusicXmlParser/types.ts +24 -0
  205. package/src/musicxml/index.ts +5 -0
  206. package/src/musicxml/testfiles/lg-8102429.xml +79620 -0
  207. package/src/renderer/Layout/DocumentLayout.ts +240 -0
  208. package/src/renderer/Layout/LayoutMetrics.ts +21 -0
  209. package/src/renderer/Layout/VerticalSpacing.ts +122 -0
  210. package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +384 -0
  211. package/src/renderer/ScoreRenderer/ScoreScrollbar.tsx +231 -0
  212. package/src/renderer/ScoreRenderer/index.ts +13 -0
  213. package/src/renderer/ScoreRenderer/types.ts +14 -0
  214. package/src/renderer/ScoreRenderer/useScoreScroll.ts +146 -0
  215. package/src/renderer/colorScheme.ts +28 -0
  216. package/src/renderer/constants.ts +19 -0
  217. package/src/renderer/index.ts +3 -0
  218. package/src/renderer/layout.ts +309 -0
  219. package/src/renderer/measure.tsx +304 -0
  220. package/src/renderer/render.tsx +308 -0
  221. package/src/renderer/scoreParsing.tsx +352 -0
  222. package/src/renderer/types.ts +65 -0
  223. package/src/renderer/useScoreRecording.ts +177 -0
  224. package/src/renderer/viewport.ts +45 -0
  225. package/src/shared/Logger.ts +85 -0
  226. package/src/state/index.ts +1 -0
  227. package/src/state/types.ts +295 -0
  228. package/src/types.ts +6 -6
  229. package/src/utils.tsx +32 -98
  230. package/lib/module/SkiaVexflowContext.js +0 -285
  231. package/lib/module/SkiaVexflowContext.js.map +0 -1
  232. package/lib/module/VexflowCanvas.js +0 -103
  233. package/lib/module/VexflowCanvas.js.map +0 -1
  234. package/lib/module/colorUtils.js +0 -34
  235. package/lib/module/colorUtils.js.map +0 -1
  236. package/lib/module/colorUtils.test.js +0 -37
  237. package/lib/module/colorUtils.test.js.map +0 -1
  238. package/lib/module/constants.js +0 -30
  239. package/lib/module/constants.js.map +0 -1
  240. package/lib/module/index.js +0 -8
  241. package/lib/module/index.js.map +0 -1
  242. package/lib/typescript/src/SkiaVexflowContext.d.ts +0 -101
  243. package/lib/typescript/src/SkiaVexflowContext.d.ts.map +0 -1
  244. package/lib/typescript/src/VexflowCanvas.d.ts +0 -17
  245. package/lib/typescript/src/VexflowCanvas.d.ts.map +0 -1
  246. package/lib/typescript/src/colorUtils.d.ts +0 -2
  247. package/lib/typescript/src/colorUtils.d.ts.map +0 -1
  248. package/lib/typescript/src/colorUtils.test.d.ts +0 -2
  249. package/lib/typescript/src/colorUtils.test.d.ts.map +0 -1
  250. package/lib/typescript/src/constants.d.ts +0 -21
  251. package/lib/typescript/src/constants.d.ts.map +0 -1
  252. package/lib/typescript/src/index.d.ts +0 -7
  253. package/lib/typescript/src/index.d.ts.map +0 -1
  254. package/src/SkiaVexflowContext.ts +0 -462
  255. package/src/VexflowCanvas.tsx +0 -145
  256. package/src/colorUtils.test.ts +0 -52
  257. package/src/colorUtils.ts +0 -55
  258. package/src/constants.tsx +0 -34
  259. package/src/index.ts +0 -8
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,295 @@
1
+ export type Id = string;
2
+
3
+ export type Clef =
4
+ | 'treble'
5
+ | 'bass'
6
+ | 'alto'
7
+ | 'tenor'
8
+ | 'soprano'
9
+ | 'mezzo-soprano'
10
+ | 'baritone-c'
11
+ | 'baritone-f'
12
+ | 'subbass'
13
+ | 'french'
14
+ | 'percussion'
15
+ | 'tab';
16
+
17
+ export type Step = 'C' | 'D' | 'E' | 'F' | 'G' | 'A' | 'B';
18
+
19
+ export type Accidental =
20
+ | 'bb'
21
+ | 'b'
22
+ | 'n'
23
+ | '#'
24
+ | '##'
25
+ | 'x'
26
+ | 'quarter-flat'
27
+ | 'quarter-sharp';
28
+
29
+ export type NoteLength =
30
+ | 'long'
31
+ | 'breve'
32
+ | 'w'
33
+ | 'h'
34
+ | 'q'
35
+ | '8'
36
+ | '16'
37
+ | '32'
38
+ | '64'
39
+ | '128';
40
+
41
+ export type StemDirection = 'up' | 'down' | 'auto';
42
+
43
+ export type Barline =
44
+ | 'single'
45
+ | 'double'
46
+ | 'end'
47
+ | 'repeat-begin'
48
+ | 'repeat-end'
49
+ | 'final';
50
+
51
+ export type Articulation =
52
+ | 'staccato'
53
+ | 'tenuto'
54
+ | 'accent'
55
+ | 'marcato'
56
+ | 'staccatissimo'
57
+ | 'fermata';
58
+
59
+ export type Dynamic =
60
+ | 'ppp'
61
+ | 'pp'
62
+ | 'p'
63
+ | 'mp'
64
+ | 'mf'
65
+ | 'f'
66
+ | 'ff'
67
+ | 'fff'
68
+ | 'sfz';
69
+
70
+ export type KeyMode =
71
+ | 'major'
72
+ | 'minor'
73
+ | 'dorian'
74
+ | 'phrygian'
75
+ | 'lydian'
76
+ | 'mixolydian'
77
+ | 'locrian';
78
+
79
+ export type VoiceTimingMode = 'strict' | 'soft' | 'free';
80
+
81
+ export type StaffGroupRole = 'grandStaff' | 'choir' | 'section' | 'custom';
82
+ export type StaffGroupSymbol = 'brace' | 'bracket' | 'line';
83
+
84
+ export interface Fraction {
85
+ num: number;
86
+ den: number;
87
+ }
88
+
89
+ export interface Pitch {
90
+ step: Step;
91
+ octave: number;
92
+ accidental?: Accidental;
93
+ }
94
+
95
+ export interface DurationValue {
96
+ length: NoteLength;
97
+ dots?: 0 | 1 | 2 | 3;
98
+ }
99
+
100
+ export interface KeySignature {
101
+ tonic: Step;
102
+ accidental?: 'b' | '#';
103
+ mode?: KeyMode;
104
+ }
105
+
106
+ export interface Meter {
107
+ beats: number;
108
+ beatUnit: number;
109
+ beamGroups?: Fraction[];
110
+ }
111
+
112
+ export interface Tempo {
113
+ bpm: number;
114
+ beatUnit?: DurationValue;
115
+ text?: string;
116
+ }
117
+
118
+ export interface Note {
119
+ id: Id;
120
+ type: 'note';
121
+ pitch: Pitch;
122
+ duration: DurationValue;
123
+ voiceId: Id;
124
+ targetStaffId?: Id;
125
+ stemDirection?: StemDirection;
126
+ }
127
+
128
+ export interface Rest {
129
+ id: Id;
130
+ type: 'rest';
131
+ duration: DurationValue;
132
+ voiceId: Id;
133
+ targetStaffId?: Id;
134
+ kind?: 'visible' | 'spacer' | 'hidden';
135
+ staffLine?: number;
136
+ }
137
+
138
+ export interface Chord {
139
+ id: Id;
140
+ type: 'chord';
141
+ pitches: Pitch[];
142
+ duration: DurationValue;
143
+ voiceId: Id;
144
+ targetStaffId?: Id;
145
+ stemDirection?: StemDirection;
146
+ }
147
+
148
+ export type VoiceItem = Note | Rest | Chord;
149
+
150
+ export interface Voice {
151
+ id: Id;
152
+ name?: string;
153
+ index: number;
154
+ timingMode?: VoiceTimingMode;
155
+ items: VoiceItem[];
156
+ }
157
+
158
+ export interface MeasureState {
159
+ clef?: Clef;
160
+ meter?: Meter;
161
+ keySignature?: KeySignature;
162
+ tempo?: Tempo;
163
+ }
164
+
165
+ export interface MeasureLeftModifiers {
166
+ showClef?: boolean;
167
+ showMeter?: boolean;
168
+ showKeySignature?: boolean;
169
+ startBarline?: Barline;
170
+ }
171
+
172
+ export interface MeasureRightModifiers {
173
+ endBarline?: Barline;
174
+ }
175
+
176
+ export interface TextDirection {
177
+ id: Id;
178
+ type: 'text';
179
+ text: string;
180
+ placement?: 'above' | 'below';
181
+ }
182
+
183
+ export interface TempoDirection {
184
+ id: Id;
185
+ type: 'tempo';
186
+ tempo: Tempo;
187
+ placement?: 'above' | 'below';
188
+ }
189
+
190
+ export type Direction = TextDirection | TempoDirection;
191
+
192
+ export interface Measure {
193
+ id: Id;
194
+ number: number;
195
+
196
+ state?: MeasureState;
197
+
198
+ leftModifiers?: MeasureLeftModifiers;
199
+ rightModifiers?: MeasureRightModifiers;
200
+
201
+ directions?: Direction[];
202
+ voices: Voice[];
203
+ }
204
+
205
+ export interface Staff {
206
+ id: Id;
207
+ name?: string;
208
+ shortName?: string;
209
+ order: number;
210
+ defaultClef: Clef;
211
+ transposition?: number;
212
+ measures: Measure[];
213
+ }
214
+
215
+ export interface StaffGroup {
216
+ id: Id;
217
+ staffIds?: Id[];
218
+ role: StaffGroupRole;
219
+ symbol?: StaffGroupSymbol;
220
+ }
221
+
222
+ export interface ScoreMetadata {
223
+ title?: string;
224
+ subtitle?: string;
225
+ composer?: string;
226
+ lyricist?: string;
227
+ arranger?: string;
228
+ copyright?: string;
229
+ }
230
+
231
+ export interface ScoreDefaults {
232
+ meter: Meter;
233
+ keySignature?: KeySignature;
234
+ tempo?: Tempo;
235
+ }
236
+
237
+ export interface AttachmentBase {
238
+ id: Id;
239
+ ownerId: Id;
240
+ }
241
+
242
+ export interface ArticulationAttachment extends AttachmentBase {
243
+ type: 'articulation';
244
+ articulation: Articulation;
245
+ }
246
+
247
+ export interface DynamicAttachment extends AttachmentBase {
248
+ type: 'dynamic';
249
+ dynamic: Dynamic;
250
+ placement?: 'above' | 'below';
251
+ }
252
+
253
+ export interface LyricAttachment extends AttachmentBase {
254
+ type: 'lyric';
255
+ text: string;
256
+ verse?: number;
257
+ }
258
+
259
+ export type NoteAttachment =
260
+ | ArticulationAttachment
261
+ | DynamicAttachment
262
+ | LyricAttachment;
263
+
264
+ export interface Tie {
265
+ id: Id;
266
+ fromNoteId: Id;
267
+ toNoteId: Id;
268
+ }
269
+
270
+ export interface Slur {
271
+ id: Id;
272
+ fromNoteId: Id;
273
+ toNoteId: Id;
274
+ }
275
+
276
+ export interface TupletGroup {
277
+ id: Id;
278
+ voiceId: Id;
279
+ itemIds: Id[];
280
+ ratio: Fraction;
281
+ bracketed?: boolean;
282
+ placement?: 'above' | 'below';
283
+ }
284
+
285
+ export interface Score {
286
+ id: Id;
287
+ metadata?: ScoreMetadata;
288
+ defaults: ScoreDefaults;
289
+ staves: Staff[];
290
+ staffGroups?: StaffGroup[];
291
+ attachments?: NoteAttachment[];
292
+ ties?: Tie[];
293
+ slurs?: Slur[];
294
+ tuplets?: TupletGroup[];
295
+ }
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
- export type LineCap = 'butt' | 'round' | 'square';
2
- export type LineJoin = 'miter' | 'round' | 'bevel';
1
+ // export type LineCap = 'butt' | 'round' | 'square';
2
+ // export type LineJoin = 'miter' | 'round' | 'bevel';
3
3
 
4
- export type ParsedCssFont = {
5
- sizePx: number;
6
- family?: string;
7
- };
4
+ // export type ParsedCssFont = {
5
+ // sizePx: number;
6
+ // family?: string;
7
+ // };
package/src/utils.tsx CHANGED
@@ -1,108 +1,42 @@
1
- import { Skia, type SkFont } from '@shopify/react-native-skia';
1
+ // import { PT_TO_PX } from './constants';
2
+ // import { type ParsedCssFont } from './types';
2
3
 
3
- import { fontCache, PT_TO_PX } from './constants';
4
- import { type ParsedCssFont } from './types';
4
+ // export function toPxFontSize(size: number | string | undefined): number {
5
+ // if (size === undefined || size === null) return 12;
5
6
 
6
- export function getAdvanceWidth(font: SkFont, text: string): number {
7
- const glyphs = font.getGlyphIDs(text);
8
- const widths = font.getGlyphWidths(glyphs);
9
- return widths.reduce((sum, width) => sum + width, 0);
10
- }
7
+ // if (typeof size === 'number' && Number.isFinite(size)) {
8
+ // return size * PT_TO_PX;
9
+ // }
11
10
 
12
- export function toPxFontSize(size: number | string | undefined): number {
13
- if (size === undefined || size === null) return 12;
11
+ // if (typeof size === 'string') {
12
+ // const match = size.trim().match(/^(\d+(?:\.\d+)?)(px|pt)?$/i);
14
13
 
15
- if (typeof size === 'number' && Number.isFinite(size)) {
16
- return size * PT_TO_PX;
17
- }
14
+ // if (match) {
15
+ // const value = Number.parseFloat(match[1] || '12');
16
+ // const unit = match[2]?.toLowerCase();
17
+ // if (!unit || unit === 'px') return value;
18
+ // return value * PT_TO_PX;
19
+ // }
20
+ // }
18
21
 
19
- if (typeof size === 'string') {
20
- const match = size.trim().match(/^(\d+(?:\.\d+)?)(px|pt)?$/i);
22
+ // return 12;
23
+ // }
21
24
 
22
- if (match) {
23
- const value = Number.parseFloat(match[1] || '12');
24
- const unit = match[2]?.toLowerCase();
25
- if (!unit || unit === 'px') return value;
26
- return value * PT_TO_PX;
27
- }
28
- }
25
+ // export function parseCssFontShorthand(cssFont: string): ParsedCssFont {
26
+ // const sizeMatch = cssFont.match(/(\d+(?:\.\d+)?(?:px|pt))/i);
29
27
 
30
- return 12;
31
- }
28
+ // if (!sizeMatch) {
29
+ // return { sizePx: 12 };
30
+ // }
32
31
 
33
- export function parseCssFontShorthand(cssFont: string): ParsedCssFont {
34
- const sizeMatch = cssFont.match(/(\d+(?:\.\d+)?(?:px|pt))/i);
32
+ // const sizePx = toPxFontSize(sizeMatch[1]);
35
33
 
36
- if (!sizeMatch) {
37
- return { sizePx: 12 };
38
- }
34
+ // const family = cssFont
35
+ // .slice((sizeMatch.index ?? 0) + (sizeMatch[1]?.length || 0))
36
+ // .trim();
39
37
 
40
- const sizePx = toPxFontSize(sizeMatch[1]);
41
-
42
- const family = cssFont
43
- .slice((sizeMatch.index ?? 0) + (sizeMatch[1]?.length || 0))
44
- .trim();
45
-
46
- return {
47
- sizePx,
48
- family: family || undefined,
49
- };
50
- }
51
-
52
- export function createFont(
53
- size: number,
54
- familyName?: string,
55
- bravuraFont?: SkFont | null
56
- ): SkFont {
57
- const fontSize = Number.isFinite(size) && size > 0 ? size : 12;
58
- const family = familyName?.trim();
59
-
60
- if (family?.toLowerCase().includes('bravura') && bravuraFont) {
61
- const cacheKey = `Bravura-${fontSize}`;
62
- const cached = fontCache.get(cacheKey);
63
- if (cached) return cached;
64
-
65
- const typeface = bravuraFont.getTypeface();
66
- if (typeface) {
67
- const font = Skia.Font(typeface, fontSize);
68
- fontCache.set(cacheKey, font);
69
- return font;
70
- }
71
- }
72
-
73
- const fontMgr = Skia.FontMgr.System();
74
- const requestedFamilies = family
75
- ? family
76
- .replace(/["']/g, '')
77
- .split(',')
78
- .map((part) => part.trim())
79
- .filter(Boolean)
80
- : [];
81
-
82
- for (const requestedFamily of requestedFamilies) {
83
- const typeface = fontMgr.matchFamilyStyle(requestedFamily, {
84
- weight: 400,
85
- width: 5,
86
- slant: 0,
87
- });
88
-
89
- if (typeface) {
90
- return Skia.Font(typeface, fontSize);
91
- }
92
- }
93
-
94
- for (let i = 0; i < fontMgr.countFamilies(); i++) {
95
- const systemFamily = fontMgr.getFamilyName(i);
96
- const typeface = fontMgr.matchFamilyStyle(systemFamily, {
97
- weight: 400,
98
- width: 5,
99
- slant: 0,
100
- });
101
-
102
- if (typeface) {
103
- return Skia.Font(typeface, fontSize);
104
- }
105
- }
106
-
107
- throw new Error('Unable to create a Skia font.');
108
- }
38
+ // return {
39
+ // sizePx,
40
+ // family: family || undefined,
41
+ // };
42
+ // }