musicxml-io 0.1.0 → 0.2.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/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { S as Score, M as Measure, T as TimeSignature, P as Part, a as Pitch } from './types-DC_TnJu_.js';
2
- export { A as Accidental, i as AccidentalInfo, B as BackupEntry, p as Barline, k as BeamInfo, s as Chord, C as Clef, w as Credit, v as Defaults, D as DirectionEntry, m as DirectionType, n as DynamicsValue, F as ForwardEntry, K as KeySignature, L as Lyric, f as MeasureAttributes, g as MeasureEntry, l as Notation, N as NoteEntry, t as NoteIteratorItem, h as NoteType, r as NoteWithPosition, d as PartGroup, c as PartInfo, e as PartListEntry, u as Print, b as ScoreMetadata, q as StaffGroup, j as TieInfo, o as Transpose, V as VoiceGroup } from './types-DC_TnJu_.js';
3
- export { NormalizedPositionOptions, VoiceFilter, getAbsolutePosition, getAllNotes, getChords, getNormalizedDuration, getNormalizedPosition, getNotesForStaff, getNotesForVoice, getStaves, getVoices, groupByStaff, groupByVoice, hasNotes, isRestMeasure, iterateNotes, withAbsolutePositions } from './accessors/index.js';
1
+ import { S as Score, P as Pitch, M as Measure } from './types-Dp9zcgIg.js';
2
+ export { A as Accidental, i as AccidentalInfo, O as AdjacentNotes, a4 as AssembledLyrics, B as BackupEntry, p as Barline, a5 as BarlineWithContext, a0 as BeamGroup, j as BeamInfo, s as Chord, C as Clef, aa as ClefChangeInfo, w as Credit, v as Defaults, D as DirectionEntry, Q as DirectionKind, l as DirectionType, z as DirectionWithContext, R as DynamicWithContext, m as DynamicsValue, a7 as EndingInfo, E as EntryWithContext, F as ForwardEntry, a2 as HarmonyWithContext, a8 as KeyChangeInfo, K as KeySignature, L as Lyric, a3 as LyricWithContext, f as MeasureAttributes, g as MeasureEntry, k as Notation, a1 as NotationType, N as NoteEntry, t as NoteIteratorItem, h as NoteType, y as NoteWithContext, r as NoteWithPosition, Y as OctaveShiftWithContext, e as Part, c as PartGroup, b as PartInfo, d as PartListEntry, W as PedalWithContext, H as PositionQueryOptions, u as Print, a6 as RepeatInfo, a as ScoreMetadata, _ as SlurSpan, q as StaffGroup, G as StaffRange, ab as StructuralChanges, U as TempoWithContext, T as TieInfo, Z as TiedNoteGroup, a9 as TimeChangeInfo, n as TimeSignature, o as Transpose, $ as TupletGroup, I as VerticalSlice, V as VoiceGroup, J as VoiceLine, x as VoiceToStaffMap, X as WedgeWithContext } from './types-Dp9zcgIg.js';
3
+ import { V as ValidateOptions, a as ValidationResult } from './index-DCty0U8p.js';
4
+ export { L as LocalValidateOptions, M as MeasureValidationContext, G as ValidationError, I as ValidationErrorCode, C as ValidationException, J as ValidationLevel, H as ValidationLocation, g as addChordNote, b as addNote, F as assertMeasureValid, k as assertValid, c as changeKey, e as changeTime, f as deleteMeasure, d as deleteNote, B as formatLocation, E as getMeasureContext, i as insertMeasure, j as isValid, h as modifyNoteDuration, m as modifyNotePitch, t as transpose, v as validate, o as validateBackupForward, q as validateBeams, l as validateDivisions, n as validateMeasureDuration, D as validateMeasureLocal, u as validatePartReferences, w as validatePartStructure, r as validateSlurs, A as validateSlursAcrossMeasures, x as validateStaffStructure, p as validateTies, z as validateTiesAcrossMeasures, s as validateTuplets, y as validateVoiceStaff } from './index-DCty0U8p.js';
5
+ export { NormalizedPositionOptions, VoiceFilter, buildVoiceToStaffMap, buildVoiceToStaffMapForPart, findBarlines, findDirectionsByType, findNotesWithNotation, getAbsolutePosition, getAdjacentNotes, getAllNotes, getBeamGroups, getChordProgression, getChords, getClefChanges, getClefForStaff, getDirections, getDirectionsAtPosition, getDynamics, getEffectiveStaff, getEndings, getEntriesAtPosition, getEntriesForStaff, getEntriesInRange, getHarmonies, getHarmonyAtPosition, getKeyChanges, getLyricText, getLyrics, getNextNote, getNormalizedDuration, getNormalizedPosition, getNotesAtPosition, getNotesForStaff, getNotesForVoice, getNotesInRange, getOctaveShifts, getPartByIndex, getPartCount, getPartIds, getPedalMarkings, getPrevNote, getRepeatStructure, getSlurSpans, getStaffRange, getStaves, getStructuralChanges, getTempoMarkings, getTiedNoteGroups, getTimeChanges, getTupletGroups, getVerseCount, getVerticalSlice, getVoiceLine, getVoiceLineInRange, getVoices, getVoicesForStaff, getWedges, groupByStaff, groupByVoice, hasNotes, inferStaff, isRestMeasure, iterateEntries, iterateNotes, withAbsolutePositions } from './accessors/index.js';
4
6
  export { FindNotesFilter, PitchRange, RoundtripMetrics, countNotes, findNotes, getAttributesAtMeasure, getDivisions, getDuration, getMeasure, getMeasureByIndex, getMeasureCount, getPartById, getPartIndex, getStaveCount, hasMultipleStaves, measureRoundtrip, scoresEqual } from './query/index.js';
5
- export { AddNoteOptions, addChordNote, addNote, changeKey, changeTime, deleteMeasure, deleteNote, insertMeasure, modifyNoteDuration, modifyNotePitch, setDivisions, transpose } from './operations/index.js';
6
7
 
7
8
  declare function parse(xmlString: string): Score;
8
9
 
@@ -26,185 +27,6 @@ declare function isCompressed(data: Uint8Array): boolean;
26
27
  */
27
28
  declare function parseAuto(data: Uint8Array | string): Score;
28
29
 
29
- type ValidationErrorCode = 'MISSING_DIVISIONS' | 'INVALID_DIVISIONS' | 'MEASURE_DURATION_MISMATCH' | 'MEASURE_DURATION_OVERFLOW' | 'MEASURE_DURATION_UNDERFLOW' | 'NEGATIVE_POSITION' | 'BACKUP_EXCEEDS_POSITION' | 'TIE_START_WITHOUT_STOP' | 'TIE_STOP_WITHOUT_START' | 'TIE_PITCH_MISMATCH' | 'BEAM_BEGIN_WITHOUT_END' | 'BEAM_END_WITHOUT_BEGIN' | 'SLUR_START_WITHOUT_STOP' | 'SLUR_STOP_WITHOUT_START' | 'TUPLET_START_WITHOUT_STOP' | 'TUPLET_STOP_WITHOUT_START' | 'PART_ID_NOT_IN_PART_LIST' | 'PART_LIST_ID_NOT_IN_PARTS' | 'PART_MEASURE_COUNT_MISMATCH' | 'PART_MEASURE_NUMBER_MISMATCH' | 'PART_GROUP_START_WITHOUT_STOP' | 'PART_GROUP_STOP_WITHOUT_START' | 'DUPLICATE_PART_ID' | 'INVALID_VOICE_NUMBER' | 'INVALID_STAFF_NUMBER' | 'STAFF_EXCEEDS_STAVES' | 'MISSING_STAVES_DECLARATION' | 'STAVES_DECLARATION_MISMATCH' | 'MISSING_CLEF_FOR_STAFF' | 'CLEF_STAFF_EXCEEDS_STAVES' | 'INVALID_DURATION' | 'EMPTY_MEASURE';
30
- type ValidationLevel = 'error' | 'warning' | 'info';
31
- interface ValidationLocation {
32
- partIndex?: number;
33
- partId?: string;
34
- measureIndex?: number;
35
- measureNumber?: string;
36
- entryIndex?: number;
37
- voice?: number;
38
- staff?: number;
39
- }
40
- interface ValidationError {
41
- code: ValidationErrorCode;
42
- level: ValidationLevel;
43
- message: string;
44
- location: ValidationLocation;
45
- details?: Record<string, unknown>;
46
- }
47
- interface ValidationResult {
48
- valid: boolean;
49
- errors: ValidationError[];
50
- warnings: ValidationError[];
51
- infos: ValidationError[];
52
- }
53
- interface ValidateOptions {
54
- /** Check divisions consistency (default: true) */
55
- checkDivisions?: boolean;
56
- /** Check measure durations match time signature (default: true) */
57
- checkMeasureDuration?: boolean;
58
- /** Check backup/forward position consistency (default: true) */
59
- checkPosition?: boolean;
60
- /** Check tie start/stop pairing (default: true) */
61
- checkTies?: boolean;
62
- /** Check beam begin/end pairing (default: true) */
63
- checkBeams?: boolean;
64
- /** Check slur start/stop pairing (default: true) */
65
- checkSlurs?: boolean;
66
- /** Check tuplet start/stop pairing (default: true) */
67
- checkTuplets?: boolean;
68
- /** Check part ID references (default: true) */
69
- checkPartReferences?: boolean;
70
- /** Check part structure (measure count, numbers) (default: true) */
71
- checkPartStructure?: boolean;
72
- /** Check voice/staff numbers (default: true) */
73
- checkVoiceStaff?: boolean;
74
- /** Check staff structure (staves declaration, clefs) (default: true) */
75
- checkStaffStructure?: boolean;
76
- /** Tolerance for measure duration (in divisions, default: 0) */
77
- durationTolerance?: number;
78
- }
79
- /**
80
- * Validate a Score for internal consistency
81
- */
82
- declare function validate(score: Score, options?: ValidateOptions): ValidationResult;
83
- /**
84
- * Validate that divisions are defined and consistent
85
- */
86
- declare function validateDivisions(score: Score): ValidationError[];
87
- /**
88
- * Validate measure duration matches time signature
89
- */
90
- declare function validateMeasureDuration(measure: Measure, divisions: number, time: TimeSignature, location: ValidationLocation, tolerance?: number): ValidationError[];
91
- /**
92
- * Validate backup/forward position consistency
93
- */
94
- declare function validateBackupForward(measure: Measure, location: ValidationLocation): ValidationError[];
95
- /**
96
- * Validate tie start/stop pairing
97
- */
98
- declare function validateTies(measure: Measure, location: ValidationLocation): ValidationError[];
99
- /**
100
- * Validate beam begin/end pairing
101
- */
102
- declare function validateBeams(measure: Measure, location: ValidationLocation): ValidationError[];
103
- /**
104
- * Validate slur start/stop pairing
105
- */
106
- declare function validateSlurs(measure: Measure, _location: ValidationLocation): ValidationError[];
107
- /**
108
- * Validate tuplet start/stop pairing
109
- */
110
- declare function validateTuplets(measure: Measure, location: ValidationLocation): ValidationError[];
111
- /**
112
- * Validate part ID references between partList and parts
113
- */
114
- declare function validatePartReferences(score: Score): ValidationError[];
115
- /**
116
- * Validate voice and staff numbers
117
- */
118
- declare function validateVoiceStaff(measure: Measure, staves: number, location: ValidationLocation): ValidationError[];
119
- /**
120
- * Validate part structure (measure counts and numbers match across parts)
121
- */
122
- declare function validatePartStructure(score: Score): ValidationError[];
123
- /**
124
- * Validate staff structure within a part
125
- */
126
- declare function validateStaffStructure(part: Part, partIndex: number): ValidationError[];
127
- /**
128
- * Context needed to validate a single measure
129
- */
130
- interface MeasureValidationContext {
131
- /** Current divisions value (from previous attributes) */
132
- divisions: number;
133
- /** Current time signature */
134
- time?: TimeSignature;
135
- /** Current staves count */
136
- staves: number;
137
- /** Part index (for error location) */
138
- partIndex: number;
139
- /** Part ID (for error location) */
140
- partId: string;
141
- /** Measure index (for error location) */
142
- measureIndex: number;
143
- }
144
- /**
145
- * Options for local measure validation
146
- */
147
- interface LocalValidateOptions {
148
- checkMeasureDuration?: boolean;
149
- checkPosition?: boolean;
150
- checkBeams?: boolean;
151
- checkTuplets?: boolean;
152
- checkVoiceStaff?: boolean;
153
- durationTolerance?: number;
154
- }
155
- /**
156
- * Validate a single measure with provided context.
157
- * This is useful for validating after local operations like addNote, deleteNote.
158
- *
159
- * @example
160
- * ```typescript
161
- * const context = getMeasureContext(score, partIndex, measureIndex);
162
- * const errors = validateMeasureLocal(measure, context);
163
- * if (errors.length > 0) {
164
- * throw new Error('Operation created invalid state');
165
- * }
166
- * ```
167
- */
168
- declare function validateMeasureLocal(measure: Measure, context: MeasureValidationContext, options?: LocalValidateOptions): ValidationError[];
169
- /**
170
- * Get the validation context for a measure by traversing previous attributes.
171
- * This collects divisions, time, and staves from measure 0 to the target measure.
172
- */
173
- declare function getMeasureContext(score: Score, partIndex: number, measureIndex: number): MeasureValidationContext;
174
- /**
175
- * Validate a measure after an operation, throwing if invalid.
176
- * Convenience wrapper around validateMeasureLocal.
177
- */
178
- declare function assertMeasureValid(score: Score, partIndex: number, measureIndex: number, options?: LocalValidateOptions): void;
179
- /**
180
- * Check if a score is valid (no errors)
181
- */
182
- declare function isValid(score: Score, options?: ValidateOptions): boolean;
183
- /**
184
- * Validate and throw if invalid
185
- */
186
- declare function assertValid(score: Score, options?: ValidateOptions): void;
187
- /**
188
- * Format a validation location for display
189
- */
190
- declare function formatLocation(location: ValidationLocation): string;
191
- /**
192
- * Validation exception with structured error information
193
- */
194
- declare class ValidationException extends Error {
195
- readonly errors: ValidationError[];
196
- constructor(errors: ValidationError[], message: string);
197
- }
198
- /**
199
- * Validate ties across measures
200
- * This is more complex as ties can span multiple measures
201
- */
202
- declare function validateTiesAcrossMeasures(part: Part): ValidationError[];
203
- /**
204
- * Validate slurs across measures
205
- */
206
- declare function validateSlursAcrossMeasures(part: Part): ValidationError[];
207
-
208
30
  interface SerializeOptions {
209
31
  version?: '3.1' | '4.0';
210
32
  indent?: string;
@@ -282,4 +104,4 @@ declare function pitchToSemitone(pitch: Pitch): number;
282
104
  /** Get position at end of measure */
283
105
  declare function getMeasureEndPosition(measure: Measure): number;
284
106
 
285
- export { type LocalValidateOptions, Measure, type MeasureValidationContext, type MidiExportOptions, Part, Pitch, STEPS, STEP_SEMITONES, Score, type SerializeOptions, TimeSignature, type ValidateOptions, type ValidationError, type ValidationErrorCode, ValidationException, type ValidationLevel, type ValidationLocation, type ValidationResult, assertMeasureValid, assertValid, decodeBuffer, exportMidi, formatLocation, getMeasureContext, getMeasureEndPosition, isCompressed, isValid, parse, parseAuto, parseCompressed, parseFile, pitchToSemitone, serialize, serializeCompressed, serializeToFile, validate, validateBackupForward, validateBeams, validateDivisions, validateMeasureDuration, validateMeasureLocal, validatePartReferences, validatePartStructure, validateSlurs, validateSlursAcrossMeasures, validateStaffStructure, validateTies, validateTiesAcrossMeasures, validateTuplets, validateVoiceStaff };
107
+ export { Measure, type MidiExportOptions, Pitch, STEPS, STEP_SEMITONES, Score, type SerializeOptions, ValidateOptions, ValidationResult, decodeBuffer, exportMidi, getMeasureEndPosition, isCompressed, parse, parseAuto, parseCompressed, parseFile, pitchToSemitone, serialize, serializeCompressed, serializeToFile };