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 +27 -0
- package/dist/accessors/index.d.mts +1 -1
- package/dist/accessors/index.d.ts +1 -1
- package/dist/index-CVGy8DJi.d.ts +1269 -0
- package/dist/index-D4hW6ANJ.d.mts +1269 -0
- package/dist/index.d.mts +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +31 -4
- package/dist/index.mjs +30 -4
- package/dist/operations/index.d.mts +2 -2
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.js +3211 -55
- package/dist/operations/index.mjs +3142 -54
- package/dist/query/index.d.mts +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/{types-Dp9zcgIg.d.mts → types-CSI8kV28.d.mts} +17 -2
- package/dist/{types-Dp9zcgIg.d.ts → types-CSI8kV28.d.ts} +17 -2
- package/package.json +3 -2
- package/dist/index-DCty0U8p.d.ts +0 -377
- package/dist/index-nCaclfqu.d.mts +0 -377
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-
|
|
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-
|
|
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
|