@mcqj/vexflow 0.0.1-alpha.1

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 (300) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +208 -0
  3. package/build/cjs/vexflow-bravura.js +2 -0
  4. package/build/cjs/vexflow-bravura.js.map +1 -0
  5. package/build/cjs/vexflow-core.js +2 -0
  6. package/build/cjs/vexflow-core.js.map +1 -0
  7. package/build/cjs/vexflow-debug-with-tests.js +43475 -0
  8. package/build/cjs/vexflow-debug-with-tests.js.map +1 -0
  9. package/build/cjs/vexflow-debug.js +19194 -0
  10. package/build/cjs/vexflow-debug.js.map +1 -0
  11. package/build/cjs/vexflow.js +2 -0
  12. package/build/cjs/vexflow.js.map +1 -0
  13. package/build/esm/entry/vexflow-bravura.js +17 -0
  14. package/build/esm/entry/vexflow-core.js +4 -0
  15. package/build/esm/entry/vexflow-debug-with-tests.js +38 -0
  16. package/build/esm/entry/vexflow-debug.js +31 -0
  17. package/build/esm/entry/vexflow.js +31 -0
  18. package/build/esm/package.json +3 -0
  19. package/build/esm/src/accidental.js +330 -0
  20. package/build/esm/src/annotation.js +231 -0
  21. package/build/esm/src/articulation.js +281 -0
  22. package/build/esm/src/barnote.js +56 -0
  23. package/build/esm/src/beam.js +644 -0
  24. package/build/esm/src/bend.js +186 -0
  25. package/build/esm/src/boundingbox.js +59 -0
  26. package/build/esm/src/canvascontext.js +216 -0
  27. package/build/esm/src/chordsymbol.js +325 -0
  28. package/build/esm/src/clef.js +120 -0
  29. package/build/esm/src/clefnote.js +35 -0
  30. package/build/esm/src/crescendo.js +78 -0
  31. package/build/esm/src/curve.js +126 -0
  32. package/build/esm/src/dot.js +129 -0
  33. package/build/esm/src/easyscore.js +374 -0
  34. package/build/esm/src/element.js +409 -0
  35. package/build/esm/src/factory.js +463 -0
  36. package/build/esm/src/flag.js +22 -0
  37. package/build/esm/src/font.js +237 -0
  38. package/build/esm/src/fonts/academico.js +1 -0
  39. package/build/esm/src/fonts/academicobold.js +1 -0
  40. package/build/esm/src/fonts/bravura.js +1 -0
  41. package/build/esm/src/fonts/gonville.js +1 -0
  42. package/build/esm/src/fonts/petaluma.js +1 -0
  43. package/build/esm/src/fonts/petalumascript.js +1 -0
  44. package/build/esm/src/formatter.js +610 -0
  45. package/build/esm/src/fraction.js +170 -0
  46. package/build/esm/src/frethandfinger.js +141 -0
  47. package/build/esm/src/ghostnote.js +50 -0
  48. package/build/esm/src/glyphnote.js +44 -0
  49. package/build/esm/src/glyphs.js +2936 -0
  50. package/build/esm/src/gracenote.js +106 -0
  51. package/build/esm/src/gracenotegroup.js +138 -0
  52. package/build/esm/src/gracetabnote.js +11 -0
  53. package/build/esm/src/index.js +86 -0
  54. package/build/esm/src/keymanager.js +99 -0
  55. package/build/esm/src/keysignature.js +220 -0
  56. package/build/esm/src/keysignote.js +28 -0
  57. package/build/esm/src/metrics.js +237 -0
  58. package/build/esm/src/modifier.js +121 -0
  59. package/build/esm/src/modifiercontext.js +110 -0
  60. package/build/esm/src/multimeasurerest.js +127 -0
  61. package/build/esm/src/music.js +322 -0
  62. package/build/esm/src/note.js +383 -0
  63. package/build/esm/src/notehead.js +89 -0
  64. package/build/esm/src/notesubgroup.js +59 -0
  65. package/build/esm/src/ornament.js +192 -0
  66. package/build/esm/src/parenthesis.js +61 -0
  67. package/build/esm/src/parser.js +164 -0
  68. package/build/esm/src/pedalmarking.js +168 -0
  69. package/build/esm/src/registry.js +81 -0
  70. package/build/esm/src/rendercontext.js +20 -0
  71. package/build/esm/src/renderer.js +112 -0
  72. package/build/esm/src/repeatnote.js +17 -0
  73. package/build/esm/src/stave.js +579 -0
  74. package/build/esm/src/stavebarline.js +237 -0
  75. package/build/esm/src/staveconnector.js +180 -0
  76. package/build/esm/src/stavehairpin.js +115 -0
  77. package/build/esm/src/staveline.js +199 -0
  78. package/build/esm/src/stavemodifier.js +56 -0
  79. package/build/esm/src/stavenote.js +861 -0
  80. package/build/esm/src/staverepetition.js +120 -0
  81. package/build/esm/src/stavesection.js +36 -0
  82. package/build/esm/src/stavetempo.js +110 -0
  83. package/build/esm/src/stavetext.js +55 -0
  84. package/build/esm/src/stavetie.js +186 -0
  85. package/build/esm/src/stavevolta.js +53 -0
  86. package/build/esm/src/stem.js +133 -0
  87. package/build/esm/src/stemmablenote.js +193 -0
  88. package/build/esm/src/stringnumber.js +228 -0
  89. package/build/esm/src/strokes.js +164 -0
  90. package/build/esm/src/svgcontext.js +402 -0
  91. package/build/esm/src/system.js +166 -0
  92. package/build/esm/src/tables.js +696 -0
  93. package/build/esm/src/tabnote.js +278 -0
  94. package/build/esm/src/tabslide.js +68 -0
  95. package/build/esm/src/tabstave.js +17 -0
  96. package/build/esm/src/tabtie.js +19 -0
  97. package/build/esm/src/textbracket.js +128 -0
  98. package/build/esm/src/textdynamics.js +53 -0
  99. package/build/esm/src/textnote.js +116 -0
  100. package/build/esm/src/tickable.js +224 -0
  101. package/build/esm/src/tickcontext.js +189 -0
  102. package/build/esm/src/timesignature.js +169 -0
  103. package/build/esm/src/timesignote.js +30 -0
  104. package/build/esm/src/tremolo.js +30 -0
  105. package/build/esm/src/tuning.js +55 -0
  106. package/build/esm/src/tuplet.js +258 -0
  107. package/build/esm/src/typeguard.js +30 -0
  108. package/build/esm/src/util.js +67 -0
  109. package/build/esm/src/version.js +3 -0
  110. package/build/esm/src/vexflow.js +309 -0
  111. package/build/esm/src/vibrato.js +68 -0
  112. package/build/esm/src/vibratobracket.js +44 -0
  113. package/build/esm/src/voice.js +178 -0
  114. package/build/esm/src/web.js +15 -0
  115. package/build/esm/tests/accidental_tests.js +1055 -0
  116. package/build/esm/tests/annotation_tests.js +381 -0
  117. package/build/esm/tests/articulation_tests.js +432 -0
  118. package/build/esm/tests/auto_beam_formatting_tests.js +551 -0
  119. package/build/esm/tests/barline_tests.js +52 -0
  120. package/build/esm/tests/beam_tests.js +669 -0
  121. package/build/esm/tests/bend_tests.js +223 -0
  122. package/build/esm/tests/boundingbox_tests.js +53 -0
  123. package/build/esm/tests/browser_test_runner.js +128 -0
  124. package/build/esm/tests/chordsymbol_tests.js +405 -0
  125. package/build/esm/tests/clef_tests.js +141 -0
  126. package/build/esm/tests/crossbeam_tests.js +306 -0
  127. package/build/esm/tests/curve_tests.js +152 -0
  128. package/build/esm/tests/demo_petzold_tests.js +335 -0
  129. package/build/esm/tests/dot_tests.js +119 -0
  130. package/build/esm/tests/easyscore_tests.js +488 -0
  131. package/build/esm/tests/factory_tests.js +44 -0
  132. package/build/esm/tests/font_tests.js +134 -0
  133. package/build/esm/tests/formatter/framestack.js +61 -0
  134. package/build/esm/tests/formatter/tests.js +251 -0
  135. package/build/esm/tests/formatter_tests.js +759 -0
  136. package/build/esm/tests/fraction_tests.js +72 -0
  137. package/build/esm/tests/ghostnote_tests.js +77 -0
  138. package/build/esm/tests/glyphnote_tests.js +119 -0
  139. package/build/esm/tests/gracenote_tests.js +414 -0
  140. package/build/esm/tests/gracetabnote_tests.js +79 -0
  141. package/build/esm/tests/index.js +68 -0
  142. package/build/esm/tests/key_clef_tests.js +106 -0
  143. package/build/esm/tests/keymanager_tests.js +68 -0
  144. package/build/esm/tests/keysignature_tests.js +322 -0
  145. package/build/esm/tests/mocks.js +70 -0
  146. package/build/esm/tests/modifier_tests.js +24 -0
  147. package/build/esm/tests/multimeasurerest_tests.js +141 -0
  148. package/build/esm/tests/music_tests.js +161 -0
  149. package/build/esm/tests/node_test_runner.js +31 -0
  150. package/build/esm/tests/notehead_tests.js +224 -0
  151. package/build/esm/tests/notesubgroup_tests.js +149 -0
  152. package/build/esm/tests/offscreencanvas_tests.js +47 -0
  153. package/build/esm/tests/ornament_tests.js +333 -0
  154. package/build/esm/tests/parser_tests.js +122 -0
  155. package/build/esm/tests/pedalmarking_tests.js +91 -0
  156. package/build/esm/tests/percussion_tests.js +184 -0
  157. package/build/esm/tests/playwright/flow.spec.js +127 -0
  158. package/build/esm/tests/playwright/visual_helpers.js +30 -0
  159. package/build/esm/tests/registry_tests.js +64 -0
  160. package/build/esm/tests/renderer_tests.js +113 -0
  161. package/build/esm/tests/rests_tests.js +266 -0
  162. package/build/esm/tests/rhythm_tests.js +357 -0
  163. package/build/esm/tests/stave_tests.js +570 -0
  164. package/build/esm/tests/staveconnector_tests.js +402 -0
  165. package/build/esm/tests/stavehairpin_tests.js +90 -0
  166. package/build/esm/tests/staveline_tests.js +123 -0
  167. package/build/esm/tests/stavemodifier_tests.js +51 -0
  168. package/build/esm/tests/stavenote_tests.js +936 -0
  169. package/build/esm/tests/stavetie_tests.js +137 -0
  170. package/build/esm/tests/stringnumber_tests.js +283 -0
  171. package/build/esm/tests/strokes_tests.js +289 -0
  172. package/build/esm/tests/style_tests.js +96 -0
  173. package/build/esm/tests/tabnote_tests.js +462 -0
  174. package/build/esm/tests/tabslide_tests.js +133 -0
  175. package/build/esm/tests/tabstave_tests.js +24 -0
  176. package/build/esm/tests/tabtie_tests.js +171 -0
  177. package/build/esm/tests/test_runner.js +23 -0
  178. package/build/esm/tests/textbracket_tests.js +100 -0
  179. package/build/esm/tests/textnote_tests.js +216 -0
  180. package/build/esm/tests/threevoice_tests.js +132 -0
  181. package/build/esm/tests/tickcontext_tests.js +36 -0
  182. package/build/esm/tests/timesignature_tests.js +173 -0
  183. package/build/esm/tests/tremolo_tests.js +34 -0
  184. package/build/esm/tests/tuning_tests.js +56 -0
  185. package/build/esm/tests/tuplet_tests.js +711 -0
  186. package/build/esm/tests/typeguard_tests.js +82 -0
  187. package/build/esm/tests/unison_tests.js +74 -0
  188. package/build/esm/tests/vexflow_test_helpers.js +318 -0
  189. package/build/esm/tests/vf_prefix_tests.js +101 -0
  190. package/build/esm/tests/vibrato_tests.js +93 -0
  191. package/build/esm/tests/vibratobracket_tests.js +45 -0
  192. package/build/esm/tests/vitest/job-0.test.js +2 -0
  193. package/build/esm/tests/vitest/job-1.test.js +2 -0
  194. package/build/esm/tests/vitest/job-2.test.js +2 -0
  195. package/build/esm/tests/vitest/job-3.test.js +2 -0
  196. package/build/esm/tests/vitest/run.js +5 -0
  197. package/build/esm/tests/vitest.setup.js +44 -0
  198. package/build/esm/tests/voice_tests.js +69 -0
  199. package/build/types/entry/vexflow-bravura.d.ts +3 -0
  200. package/build/types/entry/vexflow-core.d.ts +3 -0
  201. package/build/types/entry/vexflow-debug.d.ts +3 -0
  202. package/build/types/entry/vexflow.d.ts +3 -0
  203. package/build/types/src/accidental.d.ts +60 -0
  204. package/build/types/src/annotation.d.ts +58 -0
  205. package/build/types/src/articulation.d.ts +78 -0
  206. package/build/types/src/barnote.d.ts +29 -0
  207. package/build/types/src/beam.d.ts +158 -0
  208. package/build/types/src/bend.d.ts +67 -0
  209. package/build/types/src/boundingbox.d.ts +42 -0
  210. package/build/types/src/canvascontext.d.ts +93 -0
  211. package/build/types/src/chordsymbol.d.ts +109 -0
  212. package/build/types/src/clef.d.ts +38 -0
  213. package/build/types/src/clefnote.d.ts +17 -0
  214. package/build/types/src/crescendo.d.ts +26 -0
  215. package/build/types/src/curve.d.ts +42 -0
  216. package/build/types/src/dot.d.ts +19 -0
  217. package/build/types/src/easyscore.d.ts +152 -0
  218. package/build/types/src/element.d.ts +278 -0
  219. package/build/types/src/factory.d.ts +273 -0
  220. package/build/types/src/flag.d.ts +12 -0
  221. package/build/types/src/font.d.ts +96 -0
  222. package/build/types/src/fonts/academico.d.ts +1 -0
  223. package/build/types/src/fonts/academicobold.d.ts +1 -0
  224. package/build/types/src/fonts/bravura.d.ts +1 -0
  225. package/build/types/src/fonts/gonville.d.ts +1 -0
  226. package/build/types/src/fonts/petaluma.d.ts +1 -0
  227. package/build/types/src/fonts/petalumascript.d.ts +1 -0
  228. package/build/types/src/formatter.d.ts +226 -0
  229. package/build/types/src/fraction.d.ts +65 -0
  230. package/build/types/src/frethandfinger.d.ts +19 -0
  231. package/build/types/src/ghostnote.d.ts +16 -0
  232. package/build/types/src/glyphnote.d.ts +14 -0
  233. package/build/types/src/glyphs.d.ts +2935 -0
  234. package/build/types/src/gracenote.d.ts +17 -0
  235. package/build/types/src/gracenotegroup.d.ts +33 -0
  236. package/build/types/src/gracetabnote.d.ts +5 -0
  237. package/build/types/src/index.d.ts +86 -0
  238. package/build/types/src/keymanager.d.ts +25 -0
  239. package/build/types/src/keysignature.d.ts +50 -0
  240. package/build/types/src/keysignote.d.ts +11 -0
  241. package/build/types/src/metrics.d.ts +25 -0
  242. package/build/types/src/modifier.d.ts +90 -0
  243. package/build/types/src/modifiercontext.d.ts +48 -0
  244. package/build/types/src/multimeasurerest.d.ts +61 -0
  245. package/build/types/src/music.d.ts +91 -0
  246. package/build/types/src/note.d.ts +232 -0
  247. package/build/types/src/notehead.d.ts +50 -0
  248. package/build/types/src/notesubgroup.d.ts +18 -0
  249. package/build/types/src/ornament.d.ts +71 -0
  250. package/build/types/src/parenthesis.d.ts +21 -0
  251. package/build/types/src/parser.d.ts +45 -0
  252. package/build/types/src/pedalmarking.d.ts +63 -0
  253. package/build/types/src/registry.d.ts +40 -0
  254. package/build/types/src/rendercontext.d.ts +59 -0
  255. package/build/types/src/renderer.d.ts +35 -0
  256. package/build/types/src/repeatnote.d.ts +6 -0
  257. package/build/types/src/stave.d.ts +181 -0
  258. package/build/types/src/stavebarline.d.ts +38 -0
  259. package/build/types/src/staveconnector.d.ts +53 -0
  260. package/build/types/src/stavehairpin.d.ts +56 -0
  261. package/build/types/src/staveline.d.ts +49 -0
  262. package/build/types/src/stavemodifier.d.ts +35 -0
  263. package/build/types/src/stavenote.d.ts +150 -0
  264. package/build/types/src/staverepetition.d.ts +30 -0
  265. package/build/types/src/stavesection.d.ts +8 -0
  266. package/build/types/src/stavetempo.d.ts +43 -0
  267. package/build/types/src/stavetext.d.ts +11 -0
  268. package/build/types/src/stavetie.d.ts +104 -0
  269. package/build/types/src/stavevolta.d.ts +15 -0
  270. package/build/types/src/stem.d.ts +58 -0
  271. package/build/types/src/stemmablenote.d.ts +39 -0
  272. package/build/types/src/stringnumber.d.ts +26 -0
  273. package/build/types/src/strokes.d.ts +35 -0
  274. package/build/types/src/svgcontext.d.ts +135 -0
  275. package/build/types/src/system.d.ts +121 -0
  276. package/build/types/src/tables.d.ts +86 -0
  277. package/build/types/src/tabnote.d.ts +45 -0
  278. package/build/types/src/tabslide.d.ts +36 -0
  279. package/build/types/src/tabstave.d.ts +7 -0
  280. package/build/types/src/tabtie.d.ts +18 -0
  281. package/build/types/src/textbracket.d.ts +45 -0
  282. package/build/types/src/textdynamics.d.ts +34 -0
  283. package/build/types/src/textnote.d.ts +48 -0
  284. package/build/types/src/tickable.d.ts +149 -0
  285. package/build/types/src/tickcontext.d.ts +112 -0
  286. package/build/types/src/timesignature.d.ts +75 -0
  287. package/build/types/src/timesignote.d.ts +11 -0
  288. package/build/types/src/tremolo.d.ts +12 -0
  289. package/build/types/src/tuning.d.ts +23 -0
  290. package/build/types/src/tuplet.d.ts +98 -0
  291. package/build/types/src/typeguard.d.ts +100 -0
  292. package/build/types/src/util.d.ts +42 -0
  293. package/build/types/src/version.d.ts +3 -0
  294. package/build/types/src/vexflow.d.ts +261 -0
  295. package/build/types/src/vibrato.d.ts +20 -0
  296. package/build/types/src/vibratobracket.d.ts +28 -0
  297. package/build/types/src/voice.d.ts +109 -0
  298. package/build/types/src/web.d.ts +2 -0
  299. package/package.json +145 -0
  300. package/tests/flow.html +256 -0
@@ -0,0 +1,278 @@
1
+ import { BoundingBox } from './boundingbox';
2
+ import { FontInfo } from './font';
3
+ import { Registry } from './registry';
4
+ import { RenderContext } from './rendercontext';
5
+ /** Element attributes. */
6
+ export interface ElementAttributes {
7
+ [name: string]: string | undefined;
8
+ id: string;
9
+ type: string;
10
+ class: string;
11
+ }
12
+ /** Element style. */
13
+ export interface ElementStyle {
14
+ /**
15
+ * CSS color used for the shadow.
16
+ *
17
+ * Examples: 'red', '#ff0000', '#ff000010', 'rgb(255,0,0)'
18
+ *
19
+ * See [CSS Legal Color Values](https://www.w3schools.com/cssref/css_colors_legal.asp)
20
+ */
21
+ shadowColor?: string;
22
+ /**
23
+ * Level of blur applied to shadows.
24
+ *
25
+ * Values that are not finite numbers greater than or equal to zero are ignored.
26
+ */
27
+ shadowBlur?: number;
28
+ /**
29
+ * CSS color used with context fill command.
30
+ *
31
+ * Examples: 'red', '#ff0000', '#ff000010', 'rgb(255,0,0)'
32
+ *
33
+ * See [CSS Legal Color Values](https://www.w3schools.com/cssref/css_colors_legal.asp)
34
+ */
35
+ fillStyle?: string;
36
+ /**
37
+ * CSS color used with context stroke command.
38
+ *
39
+ * Examples: 'red', '#ff0000', '#ff000010', 'rgb(255,0,0)'
40
+ *
41
+ * See [CSS Legal Color Values](https://www.w3schools.com/cssref/css_colors_legal.asp)
42
+ */
43
+ strokeStyle?: string;
44
+ /**
45
+ * Line width, 1.0 by default.
46
+ */
47
+ lineWidth?: number;
48
+ /**
49
+ * See: [SVG `stroke-dasharray` attribute](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray)
50
+ */
51
+ lineDash?: string;
52
+ }
53
+ /**
54
+ * Element implements a generic base class for VexFlow, with implementations
55
+ * of general functions and properties that can be inherited by all VexFlow elements.
56
+ *
57
+ * The Element handles style and font properties for the Element and any child
58
+ * elements, along with working with the Registry to create unique ids.
59
+ *
60
+ * The `text` is a series of unicode characters (including SMuFL codes).
61
+ * The `textFont` property contains information required to style the text (i.e., font family, size, weight, and style).
62
+ * This font family is a comma separated list of fonts.
63
+ * The method `measureText` calculates the `textMetrics`, `boundingBox`, `height` and `width` of the `text`.
64
+ * The method `renderText(...)` will render the text using the provided context and coordinates,
65
+ * taking `xShift` and `yShift` into account.
66
+ */
67
+ export declare class Element {
68
+ static get CATEGORY(): string;
69
+ protected parent?: Element;
70
+ protected children: Element[];
71
+ protected static ID: number;
72
+ protected static newID(): string;
73
+ /** Canvas used to measure text. See measureText(): TextMetrics. */
74
+ private static txtCanvas?;
75
+ static setTextMeasurementCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
76
+ static getTextMeasurementCanvas(): HTMLCanvasElement | OffscreenCanvas | undefined;
77
+ private context?;
78
+ protected attrs: ElementAttributes;
79
+ protected shouldDrawPointerRect: boolean;
80
+ protected rendered: boolean;
81
+ protected style: ElementStyle;
82
+ protected registry?: Registry;
83
+ protected _fontInfo: Required<FontInfo>;
84
+ protected fontScale: number;
85
+ protected _text: string;
86
+ protected metricsValid: boolean;
87
+ protected _textMetrics: TextMetrics;
88
+ protected _height: number;
89
+ protected _width: number;
90
+ protected xShift: number;
91
+ protected yShift: number;
92
+ protected x: number;
93
+ protected y: number;
94
+ constructor(category?: string);
95
+ /**
96
+ * Adds a child to the Element, which lets it inherit the
97
+ * same style as the parent when setGroupStyle() is called.
98
+ *
99
+ * Examples of children are noteheads and stems. Modifiers such
100
+ * as Accidentals are generally not set as children.
101
+ *
102
+ * Note that StaveNote calls setGroupStyle() when setStyle() is called.
103
+ */
104
+ addChild(child: Element): this;
105
+ getCategory(): string;
106
+ /**
107
+ * Set the element style used to render.
108
+ *
109
+ * Example:
110
+ * ```typescript
111
+ * element.setStyle({ fillStyle: 'red', strokeStyle: 'red' });
112
+ * element.drawWithStyle();
113
+ * ```
114
+ * Note: If the element draws additional sub-elements (i.e.: Modifiers in a Stave),
115
+ * the style can be applied to all of them by means of the context:
116
+ * ```typescript
117
+ * element.setStyle({ fillStyle: 'red', strokeStyle: 'red' });
118
+ * element.getContext().setFillStyle('red');
119
+ * element.getContext().setStrokeStyle('red');
120
+ * element.drawWithStyle();
121
+ * ```
122
+ * or using drawWithStyle:
123
+ * ```typescript
124
+ * element.setStyle({ fillStyle: 'red', strokeStyle: 'red' });
125
+ * element.drawWithStyle();
126
+ * ```
127
+ */
128
+ setStyle(style: ElementStyle): this;
129
+ /** Set the element & associated children style used for rendering. */
130
+ setGroupStyle(style: ElementStyle): this;
131
+ /** Get the element style used for rendering. */
132
+ getStyle(): ElementStyle;
133
+ /** Apply the element style to `context`. */
134
+ applyStyle(context?: RenderContext | undefined, style?: ElementStyle): this;
135
+ /**
136
+ * Draw the element and all its sub-elements (i.e.: Modifiers in a Stave)
137
+ * with the element's style (see `getStyle()` and `setStyle()`)
138
+ */
139
+ drawWithStyle(): this;
140
+ /** Draw an element. */
141
+ draw(): void;
142
+ /** Check if it has a class label (An element can have multiple class labels). */
143
+ hasClass(className: string): boolean;
144
+ /** Add a class label (An element can have multiple class labels). */
145
+ addClass(className: string): this;
146
+ /** Remove a class label (An element can have multiple class labels). */
147
+ removeClass(className: string): this;
148
+ /** Call back from registry after the element is registered. */
149
+ onRegister(registry: Registry): this;
150
+ /** Return the rendered status. */
151
+ isRendered(): boolean;
152
+ /** Set the rendered status. */
153
+ setRendered(rendered?: boolean): this;
154
+ /** Return the element attributes. */
155
+ getAttributes(): ElementAttributes;
156
+ /** Return an attribute, such as 'id', 'type' or 'class'. */
157
+ getAttribute(name: string): any;
158
+ /** Return associated SVGElement. */
159
+ getSVGElement(suffix?: string): SVGElement | undefined;
160
+ /** Set an attribute such as 'id', 'class', or 'type'. */
161
+ setAttribute(name: string, value: string | undefined): this;
162
+ /** Get the boundingBox. */
163
+ getBoundingBox(): BoundingBox;
164
+ /** Return the context, such as an SVGContext or CanvasContext object. */
165
+ getContext(): RenderContext | undefined;
166
+ /** Draw pointer rect. This allows mouse interaction with the element */
167
+ drawPointerRect(): void;
168
+ /** Set the context to an SVGContext or CanvasContext object */
169
+ setContext(context?: RenderContext): this;
170
+ /** Validate and return the rendering context. */
171
+ checkContext(): RenderContext;
172
+ /**
173
+ * Provide a CSS compatible font string (e.g., 'bold 16px Arial') that will be applied
174
+ * to text (not glyphs).
175
+ */
176
+ set font(f: string);
177
+ /** Returns the CSS compatible font string for the text font. */
178
+ get font(): string;
179
+ /**
180
+ * Set the element's text font family, size, weight, style
181
+ * (e.g., `Arial`, `10pt`, `bold`, `italic`).
182
+ *
183
+ * This attribute does not determine the font used for musical Glyphs like treble clefs.
184
+ *
185
+ * @param font is 1) a `FontInfo` object or
186
+ * 2) a string formatted as CSS font shorthand (e.g., 'bold 10pt Arial') or
187
+ * 3) a string representing the font family (at least one of `size`, `weight`, or `style` must also be provided).
188
+ * @param size a string specifying the font size and unit (e.g., '16pt'), or a number (the unit is assumed to be 'pt').
189
+ * @param weight is a string (e.g., 'bold', 'normal') or a number (100, 200, ... 900).
190
+ * @param style is a string (e.g., 'italic', 'normal').
191
+ * If no arguments are provided, then the font is set to the default font.
192
+ * Each Element subclass may specify its own default by overriding the static `TEXT_FONT` property.
193
+ */
194
+ setFont(font?: string | FontInfo, size?: string | number, weight?: string | number, style?: string): this;
195
+ /**
196
+ * Get the css string describing this Element's text font. e.g.,
197
+ * 'bold 10pt Arial'.
198
+ */
199
+ getFont(): string;
200
+ /** Return a copy of the current FontInfo object. */
201
+ get fontInfo(): Required<FontInfo>;
202
+ /** Set the current FontInfo object. */
203
+ set fontInfo(fontInfo: FontInfo);
204
+ /** Change the font size, while keeping everything else the same. */
205
+ setFontSize(size?: string | number): this;
206
+ /**
207
+ * @returns a CSS font-size string (e.g., '18pt', '12px', '1em').
208
+ * See Element.fontSizeInPixels or Element.fontSizeInPoints if you need to get a number for calculation purposes.
209
+ */
210
+ getFontSize(): string;
211
+ getFontScale(): number;
212
+ /**
213
+ * The size is 1) a string of the form '10pt' or '16px', compatible with the CSS font-size property.
214
+ * or 2) a number, which is interpreted as a point size (i.e. 12 == '12pt').
215
+ */
216
+ set fontSize(size: string | number);
217
+ /** @returns a CSS font-size string (e.g., '18pt', '12px', '1em'). */
218
+ get fontSize(): string;
219
+ /** @returns the font size in `pt`. */
220
+ get fontSizeInPoints(): number;
221
+ /** @returns the font size in `px`. */
222
+ get fontSizeInPixels(): number;
223
+ /** @returns a CSS font-style string (e.g., 'italic'). */
224
+ get fontStyle(): string;
225
+ /** Set the font style. */
226
+ set fontStyle(style: string);
227
+ /**
228
+ * @returns a CSS font-weight string (e.g., 'bold').
229
+ * As in CSS, font-weight is always returned as a string, even if it was set as a number.
230
+ */
231
+ get fontWeight(): string;
232
+ /** Set the font weight. */
233
+ set fontWeight(weight: string | number);
234
+ /** Get element width. */
235
+ getWidth(): number;
236
+ get width(): number;
237
+ /** Set element width. */
238
+ setWidth(width: number): this;
239
+ set width(width: number);
240
+ /** Set the X coordinate. */
241
+ setX(x: number): this;
242
+ /** Get the X coordinate. */
243
+ getX(): number;
244
+ /** Get the Y coordinate. */
245
+ getY(): number;
246
+ /** Set the Y coordinate. */
247
+ setY(y: number): this;
248
+ /** Shift element down `yShift` pixels. Negative values shift up. */
249
+ setYShift(yShift: number): this;
250
+ /** Get shift element `yShift`. */
251
+ getYShift(): number;
252
+ /** Set shift element right `xShift` pixels. Negative values shift left. */
253
+ setXShift(xShift: number): this;
254
+ /** Get shift element `xShift`. */
255
+ getXShift(): number;
256
+ /** Set element text. */
257
+ setText(text: string): this;
258
+ set text(text: string);
259
+ /** Get element text. */
260
+ getText(): string;
261
+ get text(): string;
262
+ /** Render the element text. */
263
+ renderText(ctx: RenderContext, xPos: number, yPos: number): void;
264
+ /** Measure the text using the textFont. */
265
+ measureText(): TextMetrics;
266
+ /** Measure the text using the FontInfo related with key. */
267
+ static measureWidth(text: string, key?: string): number;
268
+ /** Get the text metrics. */
269
+ getTextMetrics(): TextMetrics;
270
+ get textMetrics(): TextMetrics;
271
+ /** Get the text height. */
272
+ getHeight(): number;
273
+ get height(): number;
274
+ set height(height: number);
275
+ setOriginX(x: number): void;
276
+ setOriginY(y: number): void;
277
+ setOrigin(x: number, y: number): void;
278
+ }
@@ -0,0 +1,273 @@
1
+ import { Accidental } from './accidental';
2
+ import { Annotation, AnnotationHorizontalJustify, AnnotationVerticalJustify } from './annotation';
3
+ import { Articulation } from './articulation';
4
+ import { BarNote } from './barnote';
5
+ import { Beam, PartialBeamDirection } from './beam';
6
+ import { ChordSymbol } from './chordsymbol';
7
+ import { ClefNote } from './clefnote';
8
+ import { Curve, CurveOptions } from './curve';
9
+ import { EasyScore, EasyScoreOptions } from './easyscore';
10
+ import { Element } from './element';
11
+ import { FontInfo } from './font';
12
+ import { Formatter, FormatterOptions } from './formatter';
13
+ import { FretHandFinger } from './frethandfinger';
14
+ import { GhostNote } from './ghostnote';
15
+ import { GlyphNote, GlyphNoteOptions } from './glyphnote';
16
+ import { GraceNote, GraceNoteStruct } from './gracenote';
17
+ import { GraceNoteGroup } from './gracenotegroup';
18
+ import { KeySigNote } from './keysignote';
19
+ import { ModifierContext } from './modifiercontext';
20
+ import { MultiMeasureRest, MultimeasureRestRenderOptions } from './multimeasurerest';
21
+ import { Note, NoteStruct } from './note';
22
+ import { NoteSubGroup } from './notesubgroup';
23
+ import { Ornament } from './ornament';
24
+ import { PedalMarking } from './pedalmarking';
25
+ import { RenderContext } from './rendercontext';
26
+ import { RepeatNote } from './repeatnote';
27
+ import { Stave, StaveOptions } from './stave';
28
+ import { BarlineType } from './stavebarline';
29
+ import { StaveConnector, StaveConnectorType } from './staveconnector';
30
+ import { StaveLine } from './staveline';
31
+ import { StaveNote, StaveNoteStruct } from './stavenote';
32
+ import { StaveTie } from './stavetie';
33
+ import { StemmableNote } from './stemmablenote';
34
+ import { StringNumber } from './stringnumber';
35
+ import { System, SystemOptions } from './system';
36
+ import { TabNote, TabNoteStruct } from './tabnote';
37
+ import { TabStave } from './tabstave';
38
+ import { TextBracket } from './textbracket';
39
+ import { TextDynamics } from './textdynamics';
40
+ import { TextNote, TextNoteStruct } from './textnote';
41
+ import { TickContext } from './tickcontext';
42
+ import { TimeSigNote } from './timesignote';
43
+ import { Tuplet, TupletOptions } from './tuplet';
44
+ import { VibratoBracket } from './vibratobracket';
45
+ import { Voice, VoiceTime } from './voice';
46
+ export interface FactoryOptions {
47
+ stave?: {
48
+ space: number;
49
+ };
50
+ renderer?: {
51
+ elementId: string | null;
52
+ backend?: number;
53
+ width: number;
54
+ height: number;
55
+ background?: string;
56
+ };
57
+ }
58
+ /**
59
+ * Factory implements a high level API around VexFlow.
60
+ */
61
+ export declare class Factory {
62
+ /** To enable logging for this class. Set `VexFlow.Factory.DEBUG` to `true`. */
63
+ static DEBUG: boolean;
64
+ /**
65
+ * Static simplified function to access constructor without providing FactoryOptions
66
+ *
67
+ * Example:
68
+ *
69
+ * Create an SVG renderer and attach it to the DIV element named "boo" to render using <page-width> 1200 and <page-height> 600
70
+ *
71
+ * `const vf: Factory = VexFlow.Factory.newFromElementId('boo', 1200, 600 );`
72
+ */
73
+ static newFromElementId(elementId: string | null, width?: number, height?: number): Factory;
74
+ protected options: Required<FactoryOptions>;
75
+ protected stave?: Stave;
76
+ protected context: RenderContext;
77
+ protected staves: Stave[];
78
+ protected voices: Voice[];
79
+ protected renderQ: Element[];
80
+ protected systems: System[];
81
+ /**
82
+ * Example:
83
+ *
84
+ * Create an SVG renderer and attach it to the DIV element named "boo" to render using <page-width> 1200 and <page-height> 600
85
+ *
86
+ * `const vf: Factory = new VexFlow.Factory({renderer: { elementId: 'boo', width: 1200, height: 600 }});`
87
+ */
88
+ constructor(options?: FactoryOptions);
89
+ reset(): void;
90
+ setOptions(options?: FactoryOptions): void;
91
+ initRenderer(): void;
92
+ getContext(): RenderContext;
93
+ setContext(context: RenderContext): this;
94
+ getStave(): Stave | undefined;
95
+ getVoices(): Voice[];
96
+ /** Return pixels from current stave spacing. */
97
+ Stave(params?: {
98
+ x?: number;
99
+ y?: number;
100
+ width?: number;
101
+ options?: StaveOptions;
102
+ }): Stave;
103
+ TabStave(params?: {
104
+ x?: number;
105
+ y?: number;
106
+ width?: number;
107
+ options?: StaveOptions;
108
+ }): TabStave;
109
+ StaveNote(noteStruct: StaveNoteStruct): StaveNote;
110
+ GlyphNote(glyph: string, noteStruct: NoteStruct, options?: GlyphNoteOptions): GlyphNote;
111
+ RepeatNote(type: string, noteStruct?: NoteStruct, options?: GlyphNoteOptions): RepeatNote;
112
+ GhostNote(noteStruct: string | NoteStruct): GhostNote;
113
+ TextNote(noteStruct: TextNoteStruct): TextNote;
114
+ BarNote(params?: {
115
+ type?: BarlineType | string;
116
+ }): BarNote;
117
+ ClefNote(params?: {
118
+ type?: string;
119
+ options?: {
120
+ size?: string;
121
+ annotation?: string;
122
+ };
123
+ }): ClefNote;
124
+ TimeSigNote(params?: {
125
+ time?: string;
126
+ }): TimeSigNote;
127
+ KeySigNote(params: {
128
+ key: string;
129
+ cancelKey?: string;
130
+ alterKey?: string[];
131
+ }): KeySigNote;
132
+ TabNote(noteStruct: TabNoteStruct): TabNote;
133
+ GraceNote(noteStruct: GraceNoteStruct): GraceNote;
134
+ GraceNoteGroup(params: {
135
+ notes: StemmableNote[];
136
+ slur?: boolean;
137
+ }): GraceNoteGroup;
138
+ Accidental(params: {
139
+ type: string;
140
+ }): Accidental;
141
+ Annotation(params?: {
142
+ text?: string;
143
+ hJustify?: string | AnnotationHorizontalJustify;
144
+ vJustify?: string | AnnotationVerticalJustify;
145
+ font?: FontInfo;
146
+ }): Annotation;
147
+ ChordSymbol(params?: {
148
+ vJustify?: string;
149
+ hJustify?: string;
150
+ fontFamily?: string;
151
+ fontSize?: number;
152
+ fontWeight?: string;
153
+ }): ChordSymbol;
154
+ Articulation(params?: {
155
+ betweenLines?: boolean;
156
+ type?: string;
157
+ position?: string | number;
158
+ }): Articulation;
159
+ Ornament(type: string, params?: {
160
+ position?: string | number;
161
+ upperAccidental?: string;
162
+ lowerAccidental?: string;
163
+ delayed?: boolean;
164
+ }): Ornament;
165
+ TextDynamics(params?: {
166
+ text?: string;
167
+ duration?: string;
168
+ dots?: number;
169
+ line?: number;
170
+ }): TextDynamics;
171
+ Fingering(params: {
172
+ number?: string;
173
+ position?: string;
174
+ }): FretHandFinger;
175
+ StringNumber(params: {
176
+ number: string;
177
+ position: string;
178
+ }, drawCircle?: boolean): StringNumber;
179
+ TickContext(): TickContext;
180
+ ModifierContext(): ModifierContext;
181
+ MultiMeasureRest(params: MultimeasureRestRenderOptions): MultiMeasureRest;
182
+ Voice(params?: {
183
+ time?: VoiceTime | string;
184
+ }): Voice;
185
+ StaveConnector(params: {
186
+ topStave: Stave;
187
+ bottomStave: Stave;
188
+ type: StaveConnectorType;
189
+ }): StaveConnector;
190
+ Formatter(options?: FormatterOptions): Formatter;
191
+ Tuplet(params?: {
192
+ notes?: Note[];
193
+ options?: TupletOptions;
194
+ }): Tuplet;
195
+ Beam(params: {
196
+ notes: StemmableNote[];
197
+ options?: {
198
+ autoStem?: boolean;
199
+ secondaryBeamBreaks?: number[];
200
+ partialBeamDirections?: {
201
+ [noteIndex: number]: PartialBeamDirection;
202
+ };
203
+ };
204
+ }): Beam;
205
+ Curve(params: {
206
+ from: Note | undefined;
207
+ to: Note | undefined;
208
+ options: CurveOptions;
209
+ }): Curve;
210
+ StaveTie(params: {
211
+ from?: Note | null;
212
+ to?: Note | null;
213
+ firstIndexes?: number[];
214
+ lastIndexes?: number[];
215
+ text?: string;
216
+ options?: {
217
+ direction?: number;
218
+ };
219
+ }): StaveTie;
220
+ StaveLine(params: {
221
+ from: StaveNote;
222
+ to: StaveNote;
223
+ firstIndexes: number[];
224
+ lastIndexes: number[];
225
+ options?: {
226
+ text?: string;
227
+ font?: FontInfo;
228
+ };
229
+ }): StaveLine;
230
+ VibratoBracket(params: {
231
+ from: Note | null;
232
+ to: Note | null;
233
+ options: {
234
+ code?: number;
235
+ line?: number;
236
+ };
237
+ }): VibratoBracket;
238
+ TextBracket(params: {
239
+ from: Note;
240
+ to: Note;
241
+ text: string;
242
+ options: {
243
+ superscript: string;
244
+ position: string;
245
+ line?: number;
246
+ font?: FontInfo;
247
+ };
248
+ }): TextBracket;
249
+ System(params?: SystemOptions): System;
250
+ /**
251
+ * Creates EasyScore. Normally the first step after constructing a Factory. For example:
252
+ * ```
253
+ * const vf: Factory = new VexFlow.Factory({renderer: { elementId: 'boo', width: 1200, height: 600 }});
254
+ * const score: EasyScore = vf.EasyScore();
255
+ * ```
256
+ * @param options.factory optional instance of Factory
257
+ * @param options.builder instance of Builder
258
+ * @param options.commitHooks function to call after a note element is created
259
+ * @param options.throwOnError throw error in case of parsing error
260
+ */
261
+ EasyScore(options?: EasyScoreOptions): EasyScore;
262
+ PedalMarking(params?: {
263
+ notes?: StaveNote[];
264
+ options?: {
265
+ style: string;
266
+ };
267
+ }): PedalMarking;
268
+ NoteSubGroup(params?: {
269
+ notes?: Note[];
270
+ }): NoteSubGroup;
271
+ /** Render the score. */
272
+ draw(): void;
273
+ }
@@ -0,0 +1,12 @@
1
+ import { Element } from './element';
2
+ /**
3
+ * `Flags` are typically not manipulated
4
+ * directly, but used internally in `StaveNote`.
5
+ */
6
+ export declare class Flag extends Element {
7
+ /** To enable logging for this class. Set `VexFlow.NoteHead.DEBUG` to `true`. */
8
+ static DEBUG: boolean;
9
+ static get CATEGORY(): string;
10
+ /** Draw the notehead. */
11
+ draw(): void;
12
+ }
@@ -0,0 +1,96 @@
1
+ export interface FontInfo {
2
+ /** CSS font-family, e.g., 'Arial', 'Helvetica Neue, Arial, sans-serif', 'Times, serif' */
3
+ family?: string;
4
+ /**
5
+ * CSS font-size (e.g., '10pt', '12px').
6
+ * For backwards compatibility with 3.0.9, plain numbers are assumed to be specified in 'pt'.
7
+ */
8
+ size?: number | string;
9
+ /** `bold` or a number (e.g., 900) as inspired by CSS font-weight. */
10
+ weight?: string | number;
11
+ /** `italic` as inspired by CSS font-style. */
12
+ style?: string;
13
+ }
14
+ export declare enum FontWeight {
15
+ NORMAL = "normal",
16
+ BOLD = "bold"
17
+ }
18
+ export declare enum FontStyle {
19
+ NORMAL = "normal",
20
+ ITALIC = "italic"
21
+ }
22
+ export declare class Font {
23
+ /** Given a length (for units: pt, px, em, %, in, mm, cm) what is the scale factor to convert it to px? */
24
+ static scaleToPxFrom: Record<string, number>;
25
+ /**
26
+ * @param fontSize a font size to convert. Can be specified as a CSS length string (e.g., '16pt', '1em')
27
+ * or as a number (the unit is assumed to be 'pt'). See `Font.scaleToPxFrom` for the supported
28
+ * units (e.g., pt, em, %).
29
+ * @returns the number of pixels that is equivalent to `fontSize`
30
+ */
31
+ static convertSizeToPixelValue(fontSize: string | number): number;
32
+ /**
33
+ * @param fontSize a font size to convert. Can be specified as a CSS length string (e.g., '16pt', '1em')
34
+ * or as a number (the unit is assumed to be 'pt'). See `Font.scaleToPxFrom` for the supported
35
+ * units (e.g., pt, em, %).
36
+ * @returns the number of points that is equivalent to `fontSize`
37
+ */
38
+ static convertSizeToPointValue(fontSize: string | number): number;
39
+ /**
40
+ * @param f
41
+ * @param size
42
+ * @param weight
43
+ * @param style
44
+ * @returns the `size` field will include the units (e.g., '12pt', '16px').
45
+ */
46
+ static validate(f?: string | FontInfo, size?: string | number, weight?: string | number, style?: string): Required<FontInfo>;
47
+ /**
48
+ * @param cssFontShorthand a string formatted as CSS font shorthand (e.g., 'italic bold 15pt Arial').
49
+ */
50
+ static fromCSSString(cssFontShorthand: string): Required<FontInfo>;
51
+ /**
52
+ * @returns a CSS font shorthand string of the form `italic bold 16pt Arial`.
53
+ */
54
+ static toCSSString(fontInfo?: FontInfo): string;
55
+ /**
56
+ * @param fontSize a number representing a font size, or a string font size with units.
57
+ * @param scaleFactor multiply the size by this factor.
58
+ * @returns size * scaleFactor (e.g., 16pt * 3 = 48pt, 8px * 0.5 = 4px, 24 * 2 = 48).
59
+ * If the fontSize argument was a number, the return value will be a number.
60
+ * If the fontSize argument was a string, the return value will be a string.
61
+ */
62
+ static scaleSize<T extends number | string>(fontSize: T, scaleFactor: number): T;
63
+ /**
64
+ * @param weight a string (e.g., 'bold') or a number (e.g., 600 / semi-bold in the OpenType spec).
65
+ * @returns true if the font weight indicates bold.
66
+ */
67
+ static isBold(weight?: string | number): boolean;
68
+ /**
69
+ * @param style
70
+ * @returns true if the font style indicates 'italic'.
71
+ */
72
+ static isItalic(style?: string): boolean;
73
+ /**
74
+ * Customize this field to specify a different CDN for delivering web fonts.
75
+ * Discussion on GDPR concerns:
76
+ * https://www.jsdelivr.com/blog/how-the-german-courts-ruling-on-google-fonts-affects-jsdelivr-and-why-it-is-safe-to-use/
77
+ *
78
+ * You can also self host, and specify your own server URL here.
79
+ */
80
+ static HOST_URL: string;
81
+ /**
82
+ * These font files will be loaded from the CDN specified by `Font.HOST_URL`.
83
+ * `await VexFlow.loadFonts()` loads all of the fonts below. Useful during debugging.
84
+ * `await VexFlow.loadFonts(FontName1, FontName2)` loads only the specified fonts.
85
+ */
86
+ static FILES: Record<string, string>;
87
+ /**
88
+ * This method is asynchronous, so you should use await or .then() to wait for the fonts to load before proceeding.
89
+ *
90
+ * @param fontName
91
+ * @param url The absolute or relative URL to the woff2/otf file. It can also be a data URI.
92
+ * @param descriptors See: https://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFace#descriptors
93
+ */
94
+ static load(fontName: string, url?: string, descriptors?: Record<string, string>): Promise<FontFace>;
95
+ static getURLForFont(fontName: string): string | undefined;
96
+ }