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.
- package/README.md +267 -37
- package/lib/module/base/FontManager.js +139 -0
- package/lib/module/base/FontManager.js.map +1 -0
- package/lib/module/base/TextMeasureContext.js +46 -0
- package/lib/module/base/TextMeasureContext.js.map +1 -0
- package/lib/module/base/VexflowCanvas.js +48 -0
- package/lib/module/base/VexflowCanvas.js.map +1 -0
- package/lib/module/base/VexflowColorScheme.js +16 -0
- package/lib/module/base/VexflowColorScheme.js.map +1 -0
- package/lib/module/base/VexflowRecordingContext.js +487 -0
- package/lib/module/base/VexflowRecordingContext.js.map +1 -0
- package/lib/module/base/VexflowRecordingReplay.js +214 -0
- package/lib/module/base/VexflowRecordingReplay.js.map +1 -0
- package/lib/module/base/VexflowRecordingTypes.js +4 -0
- package/lib/module/base/VexflowRecordingTypes.js.map +1 -0
- package/lib/module/base/index.js +9 -0
- package/lib/module/base/index.js.map +1 -0
- package/lib/module/base/setupVexflowReactNative.js +96 -0
- package/lib/module/base/setupVexflowReactNative.js.map +1 -0
- package/lib/module/base/types.js +4 -0
- package/lib/module/base/types.js.map +1 -0
- package/lib/module/base/utils.js +18 -0
- package/lib/module/base/utils.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/InternalTypes.js +4 -0
- package/lib/module/musicxml/MusicXmlParser/InternalTypes.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/MeasureParser.js +269 -0
- package/lib/module/musicxml/MusicXmlParser/MeasureParser.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js +62 -0
- package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/MusicXmlTiming.js +124 -0
- package/lib/module/musicxml/MusicXmlParser/MusicXmlTiming.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/PartParser.js +41 -0
- package/lib/module/musicxml/MusicXmlParser/PartParser.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/Spanners.js +149 -0
- package/lib/module/musicxml/MusicXmlParser/Spanners.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/XmlOrder.js +106 -0
- package/lib/module/musicxml/MusicXmlParser/XmlOrder.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/index.js +110 -0
- package/lib/module/musicxml/MusicXmlParser/index.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/mappers.js +312 -0
- package/lib/module/musicxml/MusicXmlParser/mappers.js.map +1 -0
- package/lib/module/musicxml/MusicXmlParser/types.js +10 -0
- package/lib/module/musicxml/MusicXmlParser/types.js.map +1 -0
- package/lib/module/musicxml/index.js +4 -0
- package/lib/module/musicxml/index.js.map +1 -0
- package/lib/module/musicxml/testfiles/lg-8102429.xml +79620 -0
- package/lib/module/renderer/Layout/DocumentLayout.js +156 -0
- package/lib/module/renderer/Layout/DocumentLayout.js.map +1 -0
- package/lib/module/renderer/Layout/LayoutMetrics.js +13 -0
- package/lib/module/renderer/Layout/LayoutMetrics.js.map +1 -0
- package/lib/module/renderer/Layout/VerticalSpacing.js +69 -0
- package/lib/module/renderer/Layout/VerticalSpacing.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +277 -0
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/ScoreScrollbar.js +108 -0
- package/lib/module/renderer/ScoreRenderer/ScoreScrollbar.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/index.js +7 -0
- package/lib/module/renderer/ScoreRenderer/index.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/types.js +4 -0
- package/lib/module/renderer/ScoreRenderer/types.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/useScoreScroll.js +77 -0
- package/lib/module/renderer/ScoreRenderer/useScoreScroll.js.map +1 -0
- package/lib/module/renderer/colorScheme.js +17 -0
- package/lib/module/renderer/colorScheme.js.map +1 -0
- package/lib/module/renderer/constants.js +18 -0
- package/lib/module/renderer/constants.js.map +1 -0
- package/lib/module/renderer/index.js +6 -0
- package/lib/module/renderer/index.js.map +1 -0
- package/lib/module/renderer/layout.js +153 -0
- package/lib/module/renderer/layout.js.map +1 -0
- package/lib/module/renderer/measure.js +202 -0
- package/lib/module/renderer/measure.js.map +1 -0
- package/lib/module/renderer/render.js +184 -0
- package/lib/module/renderer/render.js.map +1 -0
- package/lib/module/renderer/scoreParsing.js +230 -0
- package/lib/module/renderer/scoreParsing.js.map +1 -0
- package/lib/module/renderer/types.js +4 -0
- package/lib/module/renderer/types.js.map +1 -0
- package/lib/module/renderer/useScoreRecording.js +112 -0
- package/lib/module/renderer/useScoreRecording.js.map +1 -0
- package/lib/module/renderer/viewport.js +26 -0
- package/lib/module/renderer/viewport.js.map +1 -0
- package/lib/module/shared/Logger.js +67 -0
- package/lib/module/shared/Logger.js.map +1 -0
- package/lib/module/state/index.js +4 -0
- package/lib/module/state/index.js.map +1 -0
- package/lib/module/state/types.js +2 -0
- package/lib/module/state/types.js.map +1 -0
- package/lib/module/types.js +7 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils.js +42 -77
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/base/FontManager.d.ts +23 -0
- package/lib/typescript/src/base/FontManager.d.ts.map +1 -0
- package/lib/typescript/src/base/TextMeasureContext.d.ts +22 -0
- package/lib/typescript/src/base/TextMeasureContext.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowCanvas.d.ts +5 -0
- package/lib/typescript/src/base/VexflowCanvas.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowColorScheme.d.ts +7 -0
- package/lib/typescript/src/base/VexflowColorScheme.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowRecordingContext.d.ts +103 -0
- package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +12 -0
- package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowRecordingTypes.d.ts +146 -0
- package/lib/typescript/src/base/VexflowRecordingTypes.d.ts.map +1 -0
- package/lib/typescript/src/base/index.d.ts +7 -0
- package/lib/typescript/src/base/index.d.ts.map +1 -0
- package/lib/typescript/src/base/setupVexflowReactNative.d.ts +11 -0
- package/lib/typescript/src/base/setupVexflowReactNative.d.ts.map +1 -0
- package/lib/typescript/src/base/types.d.ts +13 -0
- package/lib/typescript/src/base/types.d.ts.map +1 -0
- package/lib/typescript/src/base/utils.d.ts +2 -0
- package/lib/typescript/src/base/utils.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts +30 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts +4 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts +5 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlTiming.d.ts +6 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlTiming.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/PartParser.d.ts +8 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/PartParser.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts +4 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/XmlOrder.d.ts +20 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/XmlOrder.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/index.d.ts +5 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/index.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts +15 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/types.d.ts +13 -0
- package/lib/typescript/src/musicxml/MusicXmlParser/types.d.ts.map +1 -0
- package/lib/typescript/src/musicxml/index.d.ts +2 -0
- package/lib/typescript/src/musicxml/index.d.ts.map +1 -0
- package/lib/typescript/src/renderer/Layout/DocumentLayout.d.ts +10 -0
- package/lib/typescript/src/renderer/Layout/DocumentLayout.d.ts.map +1 -0
- package/lib/typescript/src/renderer/Layout/LayoutMetrics.d.ts +6 -0
- package/lib/typescript/src/renderer/Layout/LayoutMetrics.d.ts.map +1 -0
- package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts +9 -0
- package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts +15 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreScrollbar.d.ts +24 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreScrollbar.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts +5 -0
- package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +12 -0
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.d.ts +13 -0
- package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.d.ts.map +1 -0
- package/lib/typescript/src/renderer/colorScheme.d.ts +9 -0
- package/lib/typescript/src/renderer/colorScheme.d.ts.map +1 -0
- package/lib/typescript/src/renderer/constants.d.ts +5 -0
- package/lib/typescript/src/renderer/constants.d.ts.map +1 -0
- package/lib/typescript/src/renderer/index.d.ts +4 -0
- package/lib/typescript/src/renderer/index.d.ts.map +1 -0
- package/lib/typescript/src/renderer/layout.d.ts +56 -0
- package/lib/typescript/src/renderer/layout.d.ts.map +1 -0
- package/lib/typescript/src/renderer/measure.d.ts +23 -0
- package/lib/typescript/src/renderer/measure.d.ts.map +1 -0
- package/lib/typescript/src/renderer/render.d.ts +9 -0
- package/lib/typescript/src/renderer/render.d.ts.map +1 -0
- package/lib/typescript/src/renderer/scoreParsing.d.ts +76 -0
- package/lib/typescript/src/renderer/scoreParsing.d.ts.map +1 -0
- package/lib/typescript/src/renderer/types.d.ts +56 -0
- package/lib/typescript/src/renderer/types.d.ts.map +1 -0
- package/lib/typescript/src/renderer/useScoreRecording.d.ts +21 -0
- package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -0
- package/lib/typescript/src/renderer/viewport.d.ts +3 -0
- package/lib/typescript/src/renderer/viewport.d.ts.map +1 -0
- package/lib/typescript/src/shared/Logger.d.ts +18 -0
- package/lib/typescript/src/shared/Logger.d.ts.map +1 -0
- package/lib/typescript/src/state/index.d.ts +2 -0
- package/lib/typescript/src/state/index.d.ts.map +1 -0
- package/lib/typescript/src/state/types.d.ts +190 -0
- package/lib/typescript/src/state/types.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +0 -6
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +0 -6
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/package.json +41 -14
- package/src/base/FontManager.ts +206 -0
- package/src/base/TextMeasureContext.ts +59 -0
- package/src/base/VexflowCanvas.tsx +60 -0
- package/src/base/VexflowColorScheme.ts +32 -0
- package/src/base/VexflowRecordingContext.ts +545 -0
- package/src/base/VexflowRecordingReplay.ts +327 -0
- package/src/base/VexflowRecordingTypes.ts +169 -0
- package/src/base/index.ts +7 -0
- package/src/base/setupVexflowReactNative.ts +124 -0
- package/src/base/types.ts +17 -0
- package/src/base/utils.ts +21 -0
- package/src/musicxml/MusicXmlParser/InternalTypes.ts +41 -0
- package/src/musicxml/MusicXmlParser/MeasureParser.ts +469 -0
- package/src/musicxml/MusicXmlParser/MusicXmlDirections.ts +84 -0
- package/src/musicxml/MusicXmlParser/MusicXmlTiming.ts +153 -0
- package/src/musicxml/MusicXmlParser/PartParser.ts +69 -0
- package/src/musicxml/MusicXmlParser/Spanners.ts +215 -0
- package/src/musicxml/MusicXmlParser/XmlOrder.ts +170 -0
- package/src/musicxml/MusicXmlParser/index.ts +144 -0
- package/src/musicxml/MusicXmlParser/mappers.ts +307 -0
- package/src/musicxml/MusicXmlParser/types.ts +24 -0
- package/src/musicxml/index.ts +5 -0
- package/src/musicxml/testfiles/lg-8102429.xml +79620 -0
- package/src/renderer/Layout/DocumentLayout.ts +240 -0
- package/src/renderer/Layout/LayoutMetrics.ts +21 -0
- package/src/renderer/Layout/VerticalSpacing.ts +122 -0
- package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +384 -0
- package/src/renderer/ScoreRenderer/ScoreScrollbar.tsx +231 -0
- package/src/renderer/ScoreRenderer/index.ts +13 -0
- package/src/renderer/ScoreRenderer/types.ts +14 -0
- package/src/renderer/ScoreRenderer/useScoreScroll.ts +146 -0
- package/src/renderer/colorScheme.ts +28 -0
- package/src/renderer/constants.ts +19 -0
- package/src/renderer/index.ts +3 -0
- package/src/renderer/layout.ts +309 -0
- package/src/renderer/measure.tsx +304 -0
- package/src/renderer/render.tsx +308 -0
- package/src/renderer/scoreParsing.tsx +352 -0
- package/src/renderer/types.ts +65 -0
- package/src/renderer/useScoreRecording.ts +177 -0
- package/src/renderer/viewport.ts +45 -0
- package/src/shared/Logger.ts +85 -0
- package/src/state/index.ts +1 -0
- package/src/state/types.ts +295 -0
- package/src/types.ts +6 -6
- package/src/utils.tsx +32 -98
- package/lib/module/SkiaVexflowContext.js +0 -285
- package/lib/module/SkiaVexflowContext.js.map +0 -1
- package/lib/module/VexflowCanvas.js +0 -103
- package/lib/module/VexflowCanvas.js.map +0 -1
- package/lib/module/colorUtils.js +0 -34
- package/lib/module/colorUtils.js.map +0 -1
- package/lib/module/colorUtils.test.js +0 -37
- package/lib/module/colorUtils.test.js.map +0 -1
- package/lib/module/constants.js +0 -30
- package/lib/module/constants.js.map +0 -1
- package/lib/module/index.js +0 -8
- package/lib/module/index.js.map +0 -1
- package/lib/typescript/src/SkiaVexflowContext.d.ts +0 -101
- package/lib/typescript/src/SkiaVexflowContext.d.ts.map +0 -1
- package/lib/typescript/src/VexflowCanvas.d.ts +0 -17
- package/lib/typescript/src/VexflowCanvas.d.ts.map +0 -1
- package/lib/typescript/src/colorUtils.d.ts +0 -2
- package/lib/typescript/src/colorUtils.d.ts.map +0 -1
- package/lib/typescript/src/colorUtils.test.d.ts +0 -2
- package/lib/typescript/src/colorUtils.test.d.ts.map +0 -1
- package/lib/typescript/src/constants.d.ts +0 -21
- package/lib/typescript/src/constants.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -7
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/src/SkiaVexflowContext.ts +0 -462
- package/src/VexflowCanvas.tsx +0 -145
- package/src/colorUtils.test.ts +0 -52
- package/src/colorUtils.ts +0 -55
- package/src/constants.tsx +0 -34
- 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
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
4
|
+
// export type ParsedCssFont = {
|
|
5
|
+
// sizePx: number;
|
|
6
|
+
// family?: string;
|
|
7
|
+
// };
|
package/src/utils.tsx
CHANGED
|
@@ -1,108 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
// import { PT_TO_PX } from './constants';
|
|
2
|
+
// import { type ParsedCssFont } from './types';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
// export function toPxFontSize(size: number | string | undefined): number {
|
|
5
|
+
// if (size === undefined || size === null) return 12;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
-
|
|
11
|
+
// if (typeof size === 'string') {
|
|
12
|
+
// const match = size.trim().match(/^(\d+(?:\.\d+)?)(px|pt)?$/i);
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
20
|
-
|
|
22
|
+
// return 12;
|
|
23
|
+
// }
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
31
|
-
}
|
|
28
|
+
// if (!sizeMatch) {
|
|
29
|
+
// return { sizePx: 12 };
|
|
30
|
+
// }
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
const sizeMatch = cssFont.match(/(\d+(?:\.\d+)?(?:px|pt))/i);
|
|
32
|
+
// const sizePx = toPxFontSize(sizeMatch[1]);
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
// const family = cssFont
|
|
35
|
+
// .slice((sizeMatch.index ?? 0) + (sizeMatch[1]?.length || 0))
|
|
36
|
+
// .trim();
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
// }
|