@tspro/web-music-score 3.1.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +35 -7
  2. package/README.md +189 -331
  3. package/dist/audio/index.d.ts +1 -1
  4. package/dist/audio/index.js +1 -1
  5. package/dist/audio/index.mjs +2 -2
  6. package/dist/audio-cg/index.js +1 -1
  7. package/dist/audio-cg/index.mjs +2 -2
  8. package/dist/{chunk-PU4J7K4Z.mjs → chunk-D643HZHM.mjs} +2 -2
  9. package/dist/core/index.js +2 -2
  10. package/dist/core/index.mjs +3 -3
  11. package/dist/{guitar-C2Cp71NZ.d.ts → guitar-cNmE-EvH.d.ts} +1 -1
  12. package/dist/iife/index.global.js +11 -11
  13. package/dist/{interface-Fn8ufBQx.d.ts → interface-7k8qGG44.d.ts} +131 -83
  14. package/dist/{interface-Bz_525zj.d.mts → interface-XoKiryoV.d.mts} +130 -82
  15. package/dist/{note-BFa43I86.d.ts → note-CcVdUFqS.d.ts} +1 -1
  16. package/dist/pieces/index.d.mts +2 -2
  17. package/dist/pieces/index.d.ts +3 -3
  18. package/dist/pieces/index.js +4 -7
  19. package/dist/pieces/index.mjs +8 -11
  20. package/dist/react-ui/index.d.mts +3 -3
  21. package/dist/react-ui/index.d.ts +5 -5
  22. package/dist/react-ui/index.js +1 -1
  23. package/dist/react-ui/index.mjs +2 -2
  24. package/dist/{scale-DRR-t4Kr.d.mts → scale-C2pCNxdE.d.mts} +4 -3
  25. package/dist/{scale-ebJm37q1.d.ts → scale-CvPbJvfN.d.ts} +5 -4
  26. package/dist/score/index.d.mts +98 -31
  27. package/dist/score/index.d.ts +99 -32
  28. package/dist/score/index.js +922 -599
  29. package/dist/score/index.mjs +929 -606
  30. package/dist/tempo-BAYoZ_Li.d.mts +187 -0
  31. package/dist/tempo-r2sb6Ku2.d.ts +187 -0
  32. package/dist/theory/index.d.mts +3 -3
  33. package/dist/theory/index.d.ts +6 -6
  34. package/dist/theory/index.js +221 -78
  35. package/dist/theory/index.mjs +218 -76
  36. package/package.json +2 -2
  37. package/dist/tempo-B4h5Ktob.d.mts +0 -104
  38. package/dist/tempo-DgqDEsn0.d.ts +0 -104
@@ -1,54 +1,121 @@
1
- import { S as StaffPreset, a as ScoreConfiguration, M as MDocument, N as NoteOptions, R as RestOptions, F as Fermata, b as StaffTabOrGroups, c as Navigation, L as Label, A as Annotation, C as Connective, T as TieType, d as NoteAnchor, V as VerticalPosition } from '../interface-Fn8ufBQx.js';
2
- export { a4 as Arpeggio, Y as Clef, a5 as ConnectiveSpan, D as DivRect, k as MAccidental, m as MArpeggio, v as MBarLineLeft, u as MBarLineRight, n as MBeamGroup, l as MConnective, p as MEnding, Q as MExtensionLine, q as MFermata, r as MHeader, s as MImage, t as MMeasure, x as MNoteGroup, X as MPlaybackButtons, U as MPlayer, W as MRenderer, B as MRest, G as MRhythmColumn, H as MScoreRow, K as MSignature, O as MSpecialText, I as MStaff, o as MStaffBeamGroup, y as MStaffNoteGroup, E as MStaffRest, w as MStaffTabBarLine, J as MTab, z as MTabNoteGroup, P as MText, j as MusicInterface, a7 as PlayState, a8 as PlayStateChangeListener, f as ScoreEvent, i as ScoreEventListener, e as ScoreEventType, h as ScoreObjectEvent, g as ScoreStaffPosEvent, Z as StaffConfig, a6 as StaffTabOrGroup, a3 as Stem, a1 as StringNumber, _ as TabConfig, $ as VoiceId, a2 as getStringNumbers, a0 as getVoiceIds } from '../interface-Fn8ufBQx.js';
3
- import { N as Note } from '../note-BFa43I86.js';
4
- import { S as ScaleType, c as Scale } from '../scale-ebJm37q1.js';
5
- import { K as KeySignature, a as TimeSignature, T as TimeSignatureString, N as NoteLength } from '../tempo-DgqDEsn0.js';
1
+ import { N as NoteOptions, R as RestOptions, S as StaffPreset, a as ScoreConfiguration, M as MDocument, V as VoiceId, T as TupletOptions, F as Fermata, b as StaffTabOrGroups, c as Navigation, A as Annotation, L as Label, C as Connective, d as TieType, e as NoteAnchor, f as VerticalPosition } from '../interface-7k8qGG44.js';
2
+ export { a5 as Arpeggio, _ as Clef, D as DivRect, m as MAccidental, o as MArpeggio, x as MBarLineLeft, w as MBarLineRight, p as MBeamGroup, n as MConnective, r as MEnding, W as MExtensionLine, s as MFermata, t as MHeader, u as MImage, v as MMeasure, z as MNoteGroup, Z as MPlaybackButtons, X as MPlayer, Y as MRenderer, G as MRest, I as MRhythmColumn, J as MScoreRow, P as MSignature, Q as MSpecialText, K as MStaff, q as MStaffBeamGroup, B as MStaffNoteGroup, H as MStaffRest, y as MStaffTabBarLine, O as MTab, E as MTabNoteGroup, U as MText, l as MusicInterface, a7 as PlayState, a8 as PlayStateChangeListener, h as ScoreEvent, k as ScoreEventListener, g as ScoreEventType, j as ScoreObjectEvent, i as ScoreStaffPosEvent, $ as StaffConfig, a6 as StaffTabOrGroup, a4 as Stem, a2 as StringNumber, a0 as TabConfig, a3 as getStringNumbers, a1 as getVoiceIds } from '../interface-7k8qGG44.js';
3
+ import { N as Note } from '../note-CcVdUFqS.js';
4
+ import { S as ScaleType, c as Scale } from '../scale-CvPbJvfN.js';
5
+ import { N as NoteLength, h as NoteLengthStr, K as KeySignature, a as TimeSignature, T as TimeSignatureString, j as TupletRatio } from '../tempo-r2sb6Ku2.js';
6
6
  import '@tspro/ts-utils-lib';
7
7
 
8
+ declare enum DynamicsAnnotations {
9
+ cresc = "cresc.",
10
+ decresc = "decresc.",
11
+ dim = "dim.",
12
+ ppp = "ppp",
13
+ pp = "pp",
14
+ p = "p",
15
+ mp = "mp",
16
+ m = "m",
17
+ mf = "mf",
18
+ f = "f",
19
+ ff = "ff",
20
+ fff = "fff"
21
+ }
22
+ declare enum TempoAnnotations {
23
+ accel = "accel.",
24
+ rit = "rit.",
25
+ a_tempo = "a tempo"
26
+ }
27
+ type AnnotationsType = `${DynamicsAnnotations}` | `${TempoAnnotations}`;
28
+
29
+ type TupletBuilder = {
30
+ addNote: (note: Note | string, noteLength: NoteLength | NoteLengthStr, options?: NoteOptions) => TupletBuilder;
31
+ addChord: (notes: (Note | string)[], noteLength: NoteLength | NoteLengthStr, options?: NoteOptions) => TupletBuilder;
32
+ addRest: (restLength: NoteLength | NoteLengthStr, options?: RestOptions) => TupletBuilder;
33
+ };
34
+ type ExtensionBuilder = {
35
+ notes: (noteLength: NoteLength | NoteLengthStr, noteCount?: number) => ExtensionBuilder;
36
+ measures: (measureCount: number) => ExtensionBuilder;
37
+ infinity: () => ExtensionBuilder;
38
+ hide: () => ExtensionBuilder;
39
+ };
8
40
  declare class DocumentBuilder {
9
41
  private readonly doc;
10
42
  constructor();
11
- setScoreConfiguration(staffPreset: StaffPreset): DocumentBuilder;
43
+ setScoreConfiguration(staffPreset: StaffPreset | `${StaffPreset}`): DocumentBuilder;
12
44
  setScoreConfiguration(config: ScoreConfiguration): DocumentBuilder;
13
45
  private getMeasure;
14
46
  getDocument(): MDocument;
15
47
  setHeader(title?: string, composer?: string, arranger?: string): DocumentBuilder;
16
48
  setMeasuresPerRow(measuresPerRow: number): DocumentBuilder;
17
49
  addMeasure(): DocumentBuilder;
18
- setKeySignature(tonic: string, scaleType: ScaleType): DocumentBuilder;
50
+ setKeySignature(tonic: string, scaleType: ScaleType | `${ScaleType}`): DocumentBuilder;
19
51
  setKeySignature(keySignature: KeySignature): DocumentBuilder;
52
+ setKeySignature(keySignature: string): DocumentBuilder;
20
53
  setKeySignature(scale: Scale): DocumentBuilder;
21
54
  setTimeSignature(timeSignature: TimeSignature | TimeSignatureString): DocumentBuilder;
22
- setTempo(beatsPerMinute: number, beatLength?: NoteLength, dotted?: boolean): DocumentBuilder;
23
- addNote(voiceId: number, note: Note | string, noteLength: NoteLength, options?: NoteOptions): DocumentBuilder;
24
- addChord(voiceId: number, notes: (Note | string)[], noteLength: NoteLength, options?: NoteOptions): DocumentBuilder;
25
- addRest(voiceId: number, restLength: NoteLength, options?: RestOptions): DocumentBuilder;
55
+ setTempo(beatsPerMinute: number): DocumentBuilder;
56
+ setTempo(beatsPerMinute: number, beatLength: NoteLength | NoteLengthStr): DocumentBuilder;
57
+ /** @deprecated - Use dotted beatLength instead (e.g. "4..") */
58
+ setTempo(beatsPerMinute: number, beatLength: NoteLength | NoteLengthStr, dotted: boolean | number): DocumentBuilder;
59
+ addNote(voiceId: number, note: Note | string, noteLength: NoteLength | NoteLengthStr, options?: NoteOptions): DocumentBuilder;
60
+ addChord(voiceId: number, notes: (Note | string)[], noteLength: NoteLength | NoteLengthStr, options?: NoteOptions): DocumentBuilder;
61
+ addRest(voiceId: number, restLength: NoteLength | NoteLengthStr, options?: RestOptions): DocumentBuilder;
62
+ /**
63
+ * Usage:
64
+ * <pre>
65
+ * addTuplet(0, Theory.Tuplet.Triplet, notes => {
66
+ * notes.addNote("G3", Theory.NoteLength.Eighth);
67
+ * notes.addNote("B3", Theory.NoteLength.Eighth);
68
+ * notes.addNote("D4", Theory.NoteLength.Eighth);
69
+ * });
70
+ * </pre>
71
+ *
72
+ * @param voiceId
73
+ * @param tupletRatio - You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).
74
+ * @param tupletBuilder
75
+ * @returns
76
+ */
77
+ addTuplet(voiceId: VoiceId, tupletRatio: TupletRatio & TupletOptions, tupletBuilder: (notes: TupletBuilder) => void): DocumentBuilder;
26
78
  private addFermataInternal;
27
- addFermata(fermata?: Fermata): DocumentBuilder;
79
+ addFermata(fermata?: Fermata | `${Fermata}`): DocumentBuilder;
28
80
  /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
29
- addFermataTo(staffTabOrGroups: StaffTabOrGroups, fermata?: Fermata): DocumentBuilder;
81
+ addFermataTo(staffTabOrGroups: StaffTabOrGroups, fermata?: Fermata | `${Fermata}`): DocumentBuilder;
30
82
  private addNavigationInternal;
31
- addNavigation(navigation: Navigation): DocumentBuilder;
32
- addNavigation(navigation: Navigation.EndRepeat, playCount: number): DocumentBuilder;
33
- addNavigation(navigation: Navigation.Ending, ...passages: number[]): DocumentBuilder;
83
+ addNavigation(navigation: Navigation | `${Navigation}`): DocumentBuilder;
84
+ addNavigation(navigation: Navigation.EndRepeat | `${Navigation.EndRepeat}`, playCount: number): DocumentBuilder;
85
+ addNavigation(navigation: Navigation.Ending | `${Navigation.Ending}`, ...passages: number[]): DocumentBuilder;
34
86
  /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
35
- addNavigationTo(staffTabOrGroups: StaffTabOrGroups, navigation: Navigation): DocumentBuilder;
87
+ addNavigationTo(staffTabOrGroups: StaffTabOrGroups, navigation: Navigation | `${Navigation}`): DocumentBuilder;
36
88
  /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
37
- addNavigationTo(staffTabOrGroups: StaffTabOrGroups, navigation: Navigation.EndRepeat, playCount: number): DocumentBuilder;
89
+ addNavigationTo(staffTabOrGroups: StaffTabOrGroups, navigation: Navigation.EndRepeat | `${Navigation.EndRepeat}`, playCount: number): DocumentBuilder;
38
90
  /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
39
- addNavigationTo(staffTabOrGroups: StaffTabOrGroups, navigation: Navigation.Ending, ...passages: number[]): DocumentBuilder;
40
- private addLabelInternal;
41
- addLabel(label: Label, text: string): DocumentBuilder;
42
- /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
43
- addLabelTo(staffTabOrGroups: StaffTabOrGroups, label: Label, text: string): DocumentBuilder;
91
+ addNavigationTo(staffTabOrGroups: StaffTabOrGroups, navigation: Navigation.Ending | `${Navigation.Ending}`, ...passages: number[]): DocumentBuilder;
44
92
  private addAnnotationInternal;
45
- addAnnotation(annotation: Annotation, text: string): DocumentBuilder;
93
+ addAnnotation(text: AnnotationsType): DocumentBuilder;
94
+ addAnnotation(annotation: Annotation | `${Annotation}`, text: string): DocumentBuilder;
95
+ /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
96
+ addAnnotationTo(staffTabOrGroups: StaffTabOrGroups, text: AnnotationsType): DocumentBuilder;
97
+ /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
98
+ addAnnotationTo(staffTabOrGroups: StaffTabOrGroups, annotation: Annotation | `${Annotation}`, text: string): DocumentBuilder;
99
+ private addLabelInternal;
100
+ addLabel(label: Label | `${Label}`, text: string): DocumentBuilder;
46
101
  /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
47
- addAnnotationTo(staffTabOrGroups: StaffTabOrGroups, annotation: Annotation, text: string): DocumentBuilder;
48
- addConnective(connective: Connective.Tie, tieSpan?: number | TieType, notAnchor?: NoteAnchor): DocumentBuilder;
49
- addConnective(connective: Connective.Slur, slurSpan?: number, notAnchor?: NoteAnchor): DocumentBuilder;
50
- addConnective(connective: Connective.Slide, notAnchor?: NoteAnchor): DocumentBuilder;
51
- addExtension(extensionLength: NoteLength | number, extensionVisible?: boolean): DocumentBuilder;
102
+ addLabelTo(staffTabOrGroups: StaffTabOrGroups, label: Label | `${Label}`, text: string): DocumentBuilder;
103
+ addConnective(connective: Connective.Tie | `${Connective.Tie}`, tieSpan?: number | TieType | `${TieType}`, notAnchor?: NoteAnchor | `${NoteAnchor}`): DocumentBuilder;
104
+ addConnective(connective: Connective.Slur | `${Connective.Slur}`, slurSpan?: number, notAnchor?: NoteAnchor | `${NoteAnchor}`): DocumentBuilder;
105
+ addConnective(connective: Connective.Slide | `${Connective.Slide}`, notAnchor?: NoteAnchor | `${NoteAnchor}`): DocumentBuilder;
106
+ /**
107
+ * Extension length example:
108
+ * <pre>
109
+ * addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
110
+ * addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
111
+ * addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
112
+ * addExtension(ext => ext.infinity()) // length is as long as possible
113
+ * </pre>
114
+ * @param extensionLength
115
+ * @param extensionVisible
116
+ * @returns
117
+ */
118
+ addExtension(extensionBuilder?: (ext: ExtensionBuilder) => void): DocumentBuilder;
52
119
  /**
53
120
  *
54
121
  * @param groupName - Name of staff group.
@@ -56,12 +123,12 @@ declare class DocumentBuilder {
56
123
  * @param verticalPosition - Vertical position, are elements added above, below or both.
57
124
  * @returns
58
125
  */
59
- addStaffGroup(groupName: string, staffsTabsAndGroups: number | string | (number | string)[], verticalPosition?: VerticalPosition): DocumentBuilder;
126
+ addStaffGroup(groupName: string, staffsTabsAndGroups: number | string | (number | string)[], verticalPosition?: VerticalPosition | `${VerticalPosition}`): DocumentBuilder;
60
127
  endSong(): DocumentBuilder;
61
128
  endSection(): DocumentBuilder;
62
129
  endRow(): DocumentBuilder;
63
- completeRests(voiceId?: number): DocumentBuilder;
130
+ completeRests(voiceId?: VoiceId | VoiceId[]): DocumentBuilder;
64
131
  addScaleArpeggio(scale: Scale, bottomNote: string, numOctaves: number): DocumentBuilder;
65
132
  }
66
133
 
67
- export { Annotation, Connective, DocumentBuilder, Fermata, Label, MDocument, Navigation, NoteAnchor, NoteOptions, RestOptions, ScoreConfiguration, StaffPreset, StaffTabOrGroups, TieType, VerticalPosition };
134
+ export { Annotation, Connective, DocumentBuilder, type ExtensionBuilder, Fermata, Label, MDocument, Navigation, NoteAnchor, NoteOptions, RestOptions, ScoreConfiguration, StaffPreset, StaffTabOrGroups, TieType, type TupletBuilder, TupletOptions, VerticalPosition, VoiceId };