@k-l-lambda/lilylet 0.1.49 → 0.1.51

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 (71) hide show
  1. package/lib/abc/abc.d.ts +102 -0
  2. package/lib/abc/abc.js +25 -0
  3. package/lib/abc/grammar.jison.js +1203 -0
  4. package/lib/abc/parser.d.ts +3 -0
  5. package/lib/abc/parser.js +6 -0
  6. package/lib/abcDecoder.d.ts +1 -0
  7. package/lib/abcDecoder.js +1 -0
  8. package/lib/grammar.jison.js +1 -1303
  9. package/lib/index.d.ts +1 -8
  10. package/lib/index.js +1 -10
  11. package/lib/lilylet/abcDecoder.d.ts +25 -0
  12. package/lib/lilylet/abcDecoder.js +1007 -0
  13. package/lib/lilylet/grammar.jison.js +1308 -0
  14. package/lib/lilylet/index.d.ts +10 -0
  15. package/lib/lilylet/index.js +10 -0
  16. package/lib/lilylet/lilypondDecoder.d.ts +29 -0
  17. package/lib/lilylet/lilypondDecoder.js +1053 -0
  18. package/lib/lilylet/lilypondEncoder.d.ts +34 -0
  19. package/lib/lilylet/lilypondEncoder.js +759 -0
  20. package/lib/lilylet/meiEncoder.d.ts +8 -0
  21. package/lib/lilylet/meiEncoder.js +1813 -0
  22. package/lib/lilylet/musicXmlDecoder.d.ts +20 -0
  23. package/lib/lilylet/musicXmlDecoder.js +1195 -0
  24. package/lib/lilylet/musicXmlEncoder.d.ts +15 -0
  25. package/lib/lilylet/musicXmlEncoder.js +701 -0
  26. package/lib/lilylet/musicXmlTypes.d.ts +199 -0
  27. package/lib/lilylet/musicXmlTypes.js +7 -0
  28. package/lib/lilylet/musicXmlUtils.d.ts +92 -0
  29. package/lib/lilylet/musicXmlUtils.js +469 -0
  30. package/lib/lilylet/parser.d.ts +3 -0
  31. package/lib/lilylet/parser.js +151 -0
  32. package/lib/lilylet/serializer.d.ts +11 -0
  33. package/lib/lilylet/serializer.js +702 -0
  34. package/lib/lilylet/types.d.ts +245 -0
  35. package/lib/lilylet/types.js +99 -0
  36. package/lib/lilypondDecoder.d.ts +1 -29
  37. package/lib/lilypondDecoder.js +1 -1006
  38. package/lib/lilypondEncoder.d.ts +1 -34
  39. package/lib/lilypondEncoder.js +1 -759
  40. package/lib/meiEncoder.d.ts +1 -8
  41. package/lib/meiEncoder.js +1 -1545
  42. package/lib/musicXmlDecoder.d.ts +1 -20
  43. package/lib/musicXmlDecoder.js +1 -1151
  44. package/lib/musicXmlEncoder.d.ts +1 -15
  45. package/lib/musicXmlEncoder.js +1 -666
  46. package/lib/musicXmlTypes.d.ts +1 -199
  47. package/lib/musicXmlTypes.js +1 -7
  48. package/lib/musicXmlUtils.d.ts +1 -81
  49. package/lib/musicXmlUtils.js +1 -435
  50. package/lib/parser.d.ts +1 -3
  51. package/lib/parser.js +1 -151
  52. package/lib/serializer.d.ts +1 -11
  53. package/lib/serializer.js +1 -650
  54. package/lib/types.d.ts +1 -244
  55. package/lib/types.js +1 -99
  56. package/package.json +2 -1
  57. package/source/abc/abc.jison +692 -0
  58. package/source/abc/abc.ts +176 -0
  59. package/source/abc/grammar.jison.js +1203 -0
  60. package/source/abc/parser.ts +12 -0
  61. package/source/lilylet/abcDecoder.ts +1121 -0
  62. package/source/lilylet/grammar.jison.js +195 -190
  63. package/source/lilylet/index.ts +4 -3
  64. package/source/lilylet/lilylet.jison +10 -3
  65. package/source/lilylet/lilypondDecoder.ts +91 -41
  66. package/source/lilylet/meiEncoder.ts +284 -0
  67. package/source/lilylet/musicXmlDecoder.ts +74 -27
  68. package/source/lilylet/musicXmlEncoder.ts +201 -146
  69. package/source/lilylet/musicXmlUtils.ts +46 -4
  70. package/source/lilylet/serializer.ts +75 -21
  71. package/source/lilylet/types.ts +1 -0
@@ -1,199 +1 @@
1
- /**
2
- * MusicXML Intermediate Types
3
- *
4
- * These types represent the parsed MusicXML structure before conversion to LilyletDoc.
5
- * They closely mirror MusicXML elements for easier parsing.
6
- */
7
- export interface MusicXmlPitch {
8
- step: string;
9
- alter?: number;
10
- octave: number;
11
- }
12
- export interface MusicXmlDuration {
13
- divisions: number;
14
- type?: string;
15
- dots: number;
16
- timeModification?: {
17
- actualNotes: number;
18
- normalNotes: number;
19
- };
20
- }
21
- export interface MusicXmlKey {
22
- fifths: number;
23
- mode?: string;
24
- }
25
- export interface MusicXmlTime {
26
- beats: number;
27
- beatType: number;
28
- }
29
- export interface MusicXmlClef {
30
- sign: string;
31
- line?: number;
32
- clefOctaveChange?: number;
33
- }
34
- export interface MusicXmlAttributes {
35
- divisions?: number;
36
- key?: MusicXmlKey;
37
- time?: MusicXmlTime;
38
- clefs?: {
39
- staff: number;
40
- clef: MusicXmlClef;
41
- }[];
42
- staves?: number;
43
- }
44
- export type MusicXmlStemDirection = 'up' | 'down';
45
- export interface MusicXmlNotations {
46
- ties?: {
47
- type: 'start' | 'stop';
48
- }[];
49
- slurs?: {
50
- type: 'start' | 'stop';
51
- number: number;
52
- }[];
53
- beams?: {
54
- type: 'begin' | 'continue' | 'end';
55
- number: number;
56
- }[];
57
- articulations?: string[];
58
- ornaments?: string[];
59
- fermata?: boolean;
60
- arpeggiate?: boolean;
61
- tremolo?: {
62
- type: 'single' | 'start' | 'stop';
63
- value: number;
64
- };
65
- tuplet?: {
66
- type: 'start' | 'stop';
67
- number: number;
68
- };
69
- }
70
- export interface MusicXmlNote {
71
- isChord: boolean;
72
- isRest: boolean;
73
- isGrace: boolean;
74
- pitch?: MusicXmlPitch;
75
- duration: MusicXmlDuration;
76
- voice: number;
77
- staff?: number;
78
- stem?: MusicXmlStemDirection;
79
- notations?: MusicXmlNotations;
80
- fingering?: number;
81
- beams?: {
82
- type: 'begin' | 'continue' | 'end';
83
- number: number;
84
- }[];
85
- }
86
- export interface MusicXmlDynamic {
87
- type: string;
88
- }
89
- export interface MusicXmlWedge {
90
- type: 'crescendo' | 'diminuendo' | 'stop';
91
- number?: number;
92
- }
93
- export interface MusicXmlPedal {
94
- type: 'start' | 'stop' | 'change';
95
- line?: boolean;
96
- }
97
- export interface MusicXmlMetronome {
98
- beatUnit: string;
99
- beatUnitDot?: boolean;
100
- perMinute: number;
101
- }
102
- export interface MusicXmlWords {
103
- text: string;
104
- fontStyle?: string;
105
- fontWeight?: string;
106
- }
107
- export interface MusicXmlOctaveShift {
108
- type: 'up' | 'down' | 'stop';
109
- size?: number;
110
- }
111
- export interface MusicXmlDirection {
112
- placement?: 'above' | 'below';
113
- staff?: number;
114
- dynamics?: MusicXmlDynamic[];
115
- wedge?: MusicXmlWedge;
116
- pedal?: MusicXmlPedal;
117
- metronome?: MusicXmlMetronome;
118
- words?: MusicXmlWords[];
119
- octaveShift?: MusicXmlOctaveShift;
120
- coda?: boolean;
121
- segno?: boolean;
122
- }
123
- export interface MusicXmlBarline {
124
- location?: 'left' | 'right' | 'middle';
125
- barStyle?: string;
126
- repeat?: {
127
- direction: 'forward' | 'backward';
128
- };
129
- ending?: {
130
- type: 'start' | 'stop' | 'discontinue';
131
- number: string;
132
- };
133
- }
134
- export interface MusicXmlHarmony {
135
- root: {
136
- step: string;
137
- alter?: number;
138
- };
139
- kind: string;
140
- bass?: {
141
- step: string;
142
- alter?: number;
143
- };
144
- degrees?: {
145
- value: number;
146
- alter: number;
147
- type: 'add' | 'alter' | 'subtract';
148
- }[];
149
- }
150
- export type MusicXmlMeasureContent = {
151
- type: 'attributes';
152
- data: MusicXmlAttributes;
153
- } | {
154
- type: 'note';
155
- data: MusicXmlNote;
156
- } | {
157
- type: 'direction';
158
- data: MusicXmlDirection;
159
- } | {
160
- type: 'barline';
161
- data: MusicXmlBarline;
162
- } | {
163
- type: 'harmony';
164
- data: MusicXmlHarmony;
165
- } | {
166
- type: 'backup';
167
- duration: number;
168
- } | {
169
- type: 'forward';
170
- duration: number;
171
- };
172
- export interface MusicXmlMeasure {
173
- number: string;
174
- width?: number;
175
- implicit?: boolean;
176
- contents: MusicXmlMeasureContent[];
177
- }
178
- export interface MusicXmlPart {
179
- id: string;
180
- name?: string;
181
- measures: MusicXmlMeasure[];
182
- }
183
- export interface MusicXmlMetadata {
184
- workTitle?: string;
185
- movementTitle?: string;
186
- composer?: string;
187
- arranger?: string;
188
- lyricist?: string;
189
- }
190
- export interface MusicXmlPartInfo {
191
- id: string;
192
- name?: string;
193
- abbreviation?: string;
194
- }
195
- export interface MusicXmlDocument {
196
- metadata: MusicXmlMetadata;
197
- partList: MusicXmlPartInfo[];
198
- parts: MusicXmlPart[];
199
- }
1
+ export * from "./lilylet/musicXmlTypes.js";
@@ -1,7 +1 @@
1
- /**
2
- * MusicXML Intermediate Types
3
- *
4
- * These types represent the parsed MusicXML structure before conversion to LilyletDoc.
5
- * They closely mirror MusicXML elements for easier parsing.
6
- */
7
- export {};
1
+ export * from "./lilylet/musicXmlTypes.js";
@@ -1,81 +1 @@
1
- /**
2
- * MusicXML Utility Functions
3
- *
4
- * Helper functions for parsing MusicXML elements and converting values.
5
- */
6
- import { Clef, StemDirection, ArticulationType, OrnamentType, DynamicType, HairpinType, PedalType, KeySignature, Pitch, Duration, Fraction } from './types';
7
- /**
8
- * Get text content of a child element by tag name
9
- */
10
- export declare const getElementText: (parent: Element, tagName: string) => string | undefined;
11
- /**
12
- * Get numeric content of a child element
13
- */
14
- export declare const getElementNumber: (parent: Element, tagName: string) => number | undefined;
15
- /**
16
- * Get integer content of a child element
17
- */
18
- export declare const getElementInt: (parent: Element, tagName: string) => number | undefined;
19
- /**
20
- * Check if element has a child with given tag name
21
- */
22
- export declare const hasElement: (parent: Element, tagName: string) => boolean;
23
- /**
24
- * Get attribute value from element
25
- */
26
- export declare const getAttribute: (el: Element, name: string) => string | undefined;
27
- /**
28
- * Get numeric attribute value
29
- */
30
- export declare const getAttributeNumber: (el: Element, name: string) => number | undefined;
31
- /**
32
- * Get all child elements with given tag name
33
- */
34
- export declare const getElements: (parent: Element, tagName: string) => Element[];
35
- /**
36
- * Get all direct child elements (xmldom compatible - uses childNodes)
37
- */
38
- export declare const getChildElements: (parent: Element) => Element[];
39
- /**
40
- * Get direct child elements (not nested)
41
- * Note: Uses childNodes instead of children for xmldom compatibility
42
- */
43
- export declare const getDirectChildren: (parent: Element, tagName: string) => Element[];
44
- /**
45
- * Convert MusicXML pitch to Lilylet Pitch
46
- * MusicXML octave 4 = middle C octave = Lilylet octave 0
47
- */
48
- export declare const convertPitch: (step: string, alter: number | undefined, octave: number) => Pitch;
49
- /**
50
- * Convert MusicXML duration to Lilylet Duration
51
- *
52
- * @param divisions - Current divisions value (divisions per quarter note)
53
- * @param duration - Duration value in divisions
54
- * @param type - Note type (quarter, eighth, etc.)
55
- * @param dots - Number of dots
56
- * @param timeModification - Tuplet info
57
- */
58
- export declare const convertDuration: (divisions: number, duration: number, type?: string, dots?: number, timeModification?: {
59
- actualNotes: number;
60
- normalNotes: number;
61
- }) => Duration;
62
- /**
63
- * Convert MusicXML key (fifths, mode) to KeySignature
64
- */
65
- export declare const convertKeySignature: (fifths: number, mode?: string) => KeySignature | undefined;
66
- /**
67
- * Convert MusicXML clef (sign, line) to Lilylet Clef
68
- */
69
- export declare const convertClef: (sign: string, line?: number) => Clef | undefined;
70
- export declare const convertStemDirection: (stem: string) => StemDirection | undefined;
71
- export declare const convertArticulation: (name: string) => ArticulationType | undefined;
72
- export declare const convertOrnament: (name: string) => OrnamentType | undefined;
73
- export declare const convertDynamic: (name: string) => DynamicType | undefined;
74
- export declare const convertWedge: (type: "crescendo" | "diminuendo" | "stop", isStart: boolean) => HairpinType | undefined;
75
- export declare const convertPedal: (type: string) => PedalType | undefined;
76
- export declare const convertBarlineStyle: (barStyle?: string, repeatDirection?: "forward" | "backward") => string;
77
- /**
78
- * Convert MusicXML harmony to chord symbol text
79
- */
80
- export declare const convertHarmonyToText: (rootStep: string, rootAlter: number | undefined, kind: string, bassStep?: string, bassAlter?: number) => string;
81
- export declare const createFraction: (numerator: number, denominator: number) => Fraction;
1
+ export * from "./lilylet/musicXmlUtils.js";