musicxml-io 0.2.0 → 0.2.7

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 CHANGED
@@ -154,6 +154,33 @@ import { transpose } from 'musicxml-io/operations';
154
154
  import { findNotes } from 'musicxml-io/query';
155
155
  ```
156
156
 
157
+ ## Unique Element IDs
158
+
159
+ All elements in the Score structure have a unique `_id` property that is automatically generated when:
160
+ - MusicXML is parsed/imported
161
+ - New elements are created via operations
162
+
163
+ The ID format is `"i" + nanoid(10)` (11 characters total), where:
164
+ - `"i"` prefix ensures XML ID compatibility (IDs must start with a letter or underscore)
165
+ - `nanoid(10)` generates a URL-safe unique identifier
166
+
167
+ ```typescript
168
+ import { parse, generateId } from 'musicxml-io';
169
+
170
+ const score = parse(xmlString);
171
+ console.log(score._id); // e.g., "iV1StGXR8_Z"
172
+ console.log(score.parts[0]._id); // e.g., "i2x4K9mL1Qp"
173
+
174
+ // Generate IDs manually for custom elements
175
+ const customId = generateId(); // e.g., "iAb3Cd5Ef7H"
176
+ ```
177
+
178
+ This feature enables:
179
+ - Tracking elements across transformations
180
+ - Building element references in external systems
181
+ - Implementing undo/redo functionality
182
+ - Diffing and merging scores
183
+
157
184
  ## Round-trip Fidelity
158
185
 
159
186
  | Metric | Score |
@@ -1,4 +1,4 @@
1
- import { M as Measure, N as NoteEntry, V as VoiceGroup, q as StaffGroup, r as NoteWithPosition, s as Chord, S as Score, t as NoteIteratorItem, g as MeasureEntry, x as VoiceToStaffMap, e as Part, C as Clef, G as StaffRange, H as PositionQueryOptions, I as VerticalSlice, J as VoiceLine, E as EntryWithContext, y as NoteWithContext, O as AdjacentNotes, z as DirectionWithContext, D as DirectionEntry, Q as DirectionKind, R as DynamicWithContext, U as TempoWithContext, W as PedalWithContext, X as WedgeWithContext, Y as OctaveShiftWithContext, Z as TiedNoteGroup, _ as SlurSpan, $ as TupletGroup, a0 as BeamGroup, a1 as NotationType, a2 as HarmonyWithContext, ac as HarmonyEntry, a3 as LyricWithContext, a4 as AssembledLyrics, a6 as RepeatInfo, a5 as BarlineWithContext, a7 as EndingInfo, a8 as KeyChangeInfo, a9 as TimeChangeInfo, aa as ClefChangeInfo, ab as StructuralChanges } from '../types-Dp9zcgIg.mjs';
1
+ import { M as Measure, N as NoteEntry, V as VoiceGroup, q as StaffGroup, r as NoteWithPosition, s as Chord, S as Score, t as NoteIteratorItem, g as MeasureEntry, x as VoiceToStaffMap, e as Part, C as Clef, G as StaffRange, H as PositionQueryOptions, I as VerticalSlice, J as VoiceLine, E as EntryWithContext, y as NoteWithContext, O as AdjacentNotes, z as DirectionWithContext, D as DirectionEntry, Q as DirectionKind, R as DynamicWithContext, U as TempoWithContext, W as PedalWithContext, X as WedgeWithContext, Y as OctaveShiftWithContext, Z as TiedNoteGroup, _ as SlurSpan, $ as TupletGroup, a0 as BeamGroup, a1 as NotationType, a2 as HarmonyWithContext, ac as HarmonyEntry, a3 as LyricWithContext, a4 as AssembledLyrics, a6 as RepeatInfo, a5 as BarlineWithContext, a7 as EndingInfo, a8 as KeyChangeInfo, a9 as TimeChangeInfo, aa as ClefChangeInfo, ab as StructuralChanges } from '../types-CSI8kV28.mjs';
2
2
 
3
3
  /**
4
4
  * Filter options for voice/staff selection
@@ -1,4 +1,4 @@
1
- import { M as Measure, N as NoteEntry, V as VoiceGroup, q as StaffGroup, r as NoteWithPosition, s as Chord, S as Score, t as NoteIteratorItem, g as MeasureEntry, x as VoiceToStaffMap, e as Part, C as Clef, G as StaffRange, H as PositionQueryOptions, I as VerticalSlice, J as VoiceLine, E as EntryWithContext, y as NoteWithContext, O as AdjacentNotes, z as DirectionWithContext, D as DirectionEntry, Q as DirectionKind, R as DynamicWithContext, U as TempoWithContext, W as PedalWithContext, X as WedgeWithContext, Y as OctaveShiftWithContext, Z as TiedNoteGroup, _ as SlurSpan, $ as TupletGroup, a0 as BeamGroup, a1 as NotationType, a2 as HarmonyWithContext, ac as HarmonyEntry, a3 as LyricWithContext, a4 as AssembledLyrics, a6 as RepeatInfo, a5 as BarlineWithContext, a7 as EndingInfo, a8 as KeyChangeInfo, a9 as TimeChangeInfo, aa as ClefChangeInfo, ab as StructuralChanges } from '../types-Dp9zcgIg.js';
1
+ import { M as Measure, N as NoteEntry, V as VoiceGroup, q as StaffGroup, r as NoteWithPosition, s as Chord, S as Score, t as NoteIteratorItem, g as MeasureEntry, x as VoiceToStaffMap, e as Part, C as Clef, G as StaffRange, H as PositionQueryOptions, I as VerticalSlice, J as VoiceLine, E as EntryWithContext, y as NoteWithContext, O as AdjacentNotes, z as DirectionWithContext, D as DirectionEntry, Q as DirectionKind, R as DynamicWithContext, U as TempoWithContext, W as PedalWithContext, X as WedgeWithContext, Y as OctaveShiftWithContext, Z as TiedNoteGroup, _ as SlurSpan, $ as TupletGroup, a0 as BeamGroup, a1 as NotationType, a2 as HarmonyWithContext, ac as HarmonyEntry, a3 as LyricWithContext, a4 as AssembledLyrics, a6 as RepeatInfo, a5 as BarlineWithContext, a7 as EndingInfo, a8 as KeyChangeInfo, a9 as TimeChangeInfo, aa as ClefChangeInfo, ab as StructuralChanges } from '../types-CSI8kV28.js';
2
2
 
3
3
  /**
4
4
  * Filter options for voice/staff selection