smoosic 2.0.3 → 2.0.4
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/build/smoosic.js +395 -67
- package/changes.md +85 -0
- package/package.json +98 -82
- package/release/smoosic.js +395 -67
- package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
- package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
- package/specs/032-split-multimeasure-rests/data-model.md +70 -0
- package/specs/032-split-multimeasure-rests/plan.md +81 -0
- package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
- package/specs/032-split-multimeasure-rests/research.md +63 -0
- package/specs/032-split-multimeasure-rests/spec.md +127 -0
- package/specs/032-split-multimeasure-rests/tasks.md +174 -0
- package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
- package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
- package/specs/033-key-distance-transposition/data-model.md +49 -0
- package/specs/033-key-distance-transposition/plan.md +87 -0
- package/specs/033-key-distance-transposition/quickstart.md +40 -0
- package/specs/033-key-distance-transposition/research.md +82 -0
- package/specs/033-key-distance-transposition/spec.md +132 -0
- package/specs/033-key-distance-transposition/tasks.md +139 -0
- package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
- package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
- package/specs/034-smz-compressed-scores/data-model.md +48 -0
- package/specs/034-smz-compressed-scores/plan.md +89 -0
- package/specs/034-smz-compressed-scores/quickstart.md +44 -0
- package/specs/034-smz-compressed-scores/research.md +86 -0
- package/specs/034-smz-compressed-scores/spec.md +137 -0
- package/specs/034-smz-compressed-scores/tasks.md +148 -0
- package/specs/035-paste-special/checklists/requirements.md +35 -0
- package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
- package/specs/035-paste-special/data-model.md +47 -0
- package/specs/035-paste-special/plan.md +83 -0
- package/specs/035-paste-special/quickstart.md +51 -0
- package/specs/035-paste-special/research.md +97 -0
- package/specs/035-paste-special/spec.md +170 -0
- package/specs/035-paste-special/tasks.md +149 -0
- package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
- package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
- package/specs/036-autosave-recovery/data-model.md +70 -0
- package/specs/036-autosave-recovery/plan.md +87 -0
- package/specs/036-autosave-recovery/quickstart.md +65 -0
- package/specs/036-autosave-recovery/research.md +105 -0
- package/specs/036-autosave-recovery/spec.md +143 -0
- package/specs/036-autosave-recovery/tasks.md +165 -0
- package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
- package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
- package/specs/037-fix-new-part-dialog/data-model.md +68 -0
- package/specs/037-fix-new-part-dialog/plan.md +83 -0
- package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
- package/specs/037-fix-new-part-dialog/research.md +86 -0
- package/specs/037-fix-new-part-dialog/spec.md +144 -0
- package/specs/037-fix-new-part-dialog/tasks.md +174 -0
- package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
- package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
- package/specs/038-per-measure-beam-groups/data-model.md +75 -0
- package/specs/038-per-measure-beam-groups/plan.md +84 -0
- package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
- package/specs/038-per-measure-beam-groups/research.md +72 -0
- package/specs/038-per-measure-beam-groups/spec.md +146 -0
- package/specs/038-per-measure-beam-groups/tasks.md +132 -0
- package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
- package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
- package/specs/039-measure-fill-submenu/data-model.md +79 -0
- package/specs/039-measure-fill-submenu/plan.md +81 -0
- package/specs/039-measure-fill-submenu/quickstart.md +62 -0
- package/specs/039-measure-fill-submenu/research.md +68 -0
- package/specs/039-measure-fill-submenu/spec.md +153 -0
- package/specs/039-measure-fill-submenu/tasks.md +121 -0
- package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
- package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
- package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
- package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
- package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
- package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
- package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
- package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
- package/specs/041-delete-special/checklists/requirements.md +35 -0
- package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
- package/specs/041-delete-special/data-model.md +40 -0
- package/specs/041-delete-special/plan.md +93 -0
- package/specs/041-delete-special/quickstart.md +41 -0
- package/specs/041-delete-special/research.md +75 -0
- package/specs/041-delete-special/spec.md +136 -0
- package/specs/041-delete-special/tasks.md +106 -0
- package/src/application/application.ts +13 -2
- package/src/application/exports.ts +401 -395
- package/src/application/generateVexTests.ts +2 -2
- package/src/render/sui/NoteEntryCaret.ts +117 -16
- package/src/render/sui/autosave.ts +265 -0
- package/src/render/sui/formatter.ts +12 -2
- package/src/render/sui/scoreChangeState.ts +8 -3
- package/src/render/sui/scoreView.ts +47 -2
- package/src/render/sui/scoreViewOperations.ts +2706 -2555
- package/src/render/sui/staffLineGeometry.ts +82 -0
- package/src/render/vex/vxMeasure.ts +22 -8
- package/src/render/vex/vxNote.ts +2 -4
- package/src/smo/data/measure.ts +58 -1
- package/src/smo/data/measureModifiers.ts +81 -1
- package/src/smo/data/music.ts +169 -359
- package/src/smo/data/note.ts +1 -1
- package/src/smo/data/noteModifiers.ts +12 -0
- package/src/smo/data/score.ts +167 -2
- package/src/smo/data/scoreModifiers.ts +46 -1
- package/src/smo/data/systemStaff.ts +43 -0
- package/src/smo/xform/beamers.ts +80 -6
- package/src/smo/xform/copypaste.ts +207 -47
- package/src/smo/xform/measureFill.ts +89 -0
- package/src/smo/xform/operations.ts +403 -61
- package/src/smo/xform/selections.ts +7 -0
- package/src/ui/components/dialogs/beamGroups.vue +106 -0
- package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
- package/src/ui/components/dialogs/dynamics.vue +16 -3
- package/src/ui/components/dialogs/fileUpload.vue +2 -2
- package/src/ui/components/dialogs/hairpin.vue +3 -3
- package/src/ui/components/dialogs/newPart.vue +148 -184
- package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
- package/src/ui/components/dialogs/recovery.vue +66 -0
- package/src/ui/components/dialogs/save.vue +11 -4
- package/src/ui/components/dialogs/scorePreferences.vue +23 -1
- package/src/ui/components/dialogs/slur.vue +6 -6
- package/src/ui/components/dialogs/tempo.vue +11 -3
- package/src/ui/components/dialogs/timeSignature.vue +5 -0
- package/src/ui/components/dialogs/volta.vue +3 -3
- package/src/ui/dialogs/annotationVue.ts +1 -1
- package/src/ui/dialogs/beamGroupsVue.ts +69 -0
- package/src/ui/dialogs/createPartHelpers.ts +68 -0
- package/src/ui/dialogs/deleteSpecial.ts +57 -0
- package/src/ui/dialogs/dynamicsVue.ts +87 -60
- package/src/ui/dialogs/factory.ts +0 -2
- package/src/ui/dialogs/fileDialogs.ts +63 -22
- package/src/ui/dialogs/instrument.ts +37 -30
- package/src/ui/dialogs/pasteSpecial.ts +59 -0
- package/src/ui/dialogs/preferences.ts +41 -40
- package/src/ui/dialogs/recovery.ts +49 -0
- package/src/ui/fileio/fileInput.ts +12 -3
- package/src/ui/fileio/scoreArchive.ts +151 -0
- package/src/ui/fileio/xhrLoader.ts +26 -0
- package/src/ui/i18n/language.ts +1 -1
- package/src/ui/menus/beams.ts +181 -112
- package/src/ui/menus/edit.ts +44 -6
- package/src/ui/menus/file.ts +21 -1
- package/src/ui/menus/measure.ts +40 -1
- package/tests/autosave.ts +332 -0
- package/tests/beamDotted.ts +56 -0
- package/tests/beamGroups.ts +338 -0
- package/tests/createPart.ts +292 -0
- package/tests/deleteSpecial.ts +350 -0
- package/tests/dynamicsFontSize.ts +132 -0
- package/tests/keyDistanceTransposition.ts +351 -0
- package/tests/measureFill.ts +295 -0
- package/tests/movePart.ts +94 -0
- package/tests/multimeasureRest.ts +338 -0
- package/tests/pasteIntoMeasure.ts +103 -0
- package/tests/pasteSpecial.ts +541 -0
- package/tests/quickBeam.ts +126 -0
- package/tests/scoreArchive.ts +218 -0
- package/tests/scoreChangeState.ts +2 -0
- package/tests/staffLineGeometry.ts +179 -0
- package/tests/timeSignatureDisplay.ts +58 -0
- package/tools/smoosic-schema.json +37 -0
- package/typedoc.ts +1 -1
- package/types/src/application/exports.d.ts +453 -447
- package/types/src/common/promiseHelpers.d.ts +30 -30
- package/types/src/common/vex.d.ts +224 -224
- package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
- package/types/src/render/sui/autosave.d.ts +99 -0
- package/types/src/render/sui/scoreView.d.ts +23 -0
- package/types/src/render/sui/scoreViewOperations.d.ts +759 -639
- package/types/src/render/sui/svgHelpers.d.ts +88 -88
- package/types/src/render/sui/svgPageMap.d.ts +344 -344
- package/types/src/render/sui/textEdit.d.ts +96 -96
- package/types/src/render/sui/textRender.d.ts +199 -199
- package/types/src/render/vex/smoAdapter.d.ts +47 -47
- package/types/src/render/vex/vxMeasure.d.ts +97 -97
- package/types/src/render/vex/vxNote.d.ts +56 -56
- package/types/src/render/vex/vxSystem.d.ts +71 -71
- package/types/src/smo/data/measure.d.ts +30 -0
- package/types/src/smo/data/measureModifiers.d.ts +568 -513
- package/types/src/smo/data/music.d.ts +74 -32
- package/types/src/smo/data/note.d.ts +498 -498
- package/types/src/smo/data/noteModifiers.d.ts +615 -606
- package/types/src/smo/data/score.d.ts +476 -421
- package/types/src/smo/data/scoreModifiers.d.ts +30 -0
- package/types/src/smo/data/scoreText.d.ts +334 -334
- package/types/src/smo/data/systemStaff.d.ts +14 -0
- package/types/src/smo/xform/beamers.d.ts +23 -1
- package/types/src/smo/xform/copypaste.d.ts +138 -2
- package/types/src/smo/xform/measureFill.d.ts +21 -0
- package/types/src/smo/xform/operations.d.ts +245 -129
- package/types/src/smo/xform/selections.d.ts +154 -154
- package/types/src/smo/xform/undo.d.ts +142 -142
- package/types/src/ui/buttons/button.d.ts +100 -100
- package/types/src/ui/buttons/ribbon.d.ts +70 -70
- package/types/src/ui/common.d.ts +76 -76
- package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
- package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
- package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
- package/types/src/ui/composable/draggable.d.ts +15 -15
- package/types/src/ui/dialogs/adapter.d.ts +120 -120
- package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
- package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
- package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
- package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
- package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
- package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
- package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
- package/types/src/ui/dialogs/dialog.d.ts +203 -203
- package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
- package/types/src/ui/dialogs/factory.d.ts +15 -15
- package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
- package/types/src/ui/dialogs/hairpin.d.ts +35 -35
- package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
- package/types/src/ui/dialogs/instrument.d.ts +3 -3
- package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
- package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
- package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
- package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
- package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
- package/types/src/ui/dialogs/recovery.d.ts +8 -0
- package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
- package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
- package/types/src/ui/dialogs/slur.d.ts +57 -57
- package/types/src/ui/dialogs/slurVue.d.ts +7 -7
- package/types/src/ui/dialogs/tempo.d.ts +50 -50
- package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
- package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
- package/types/src/ui/dialogs/textBracket.d.ts +35 -35
- package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
- package/types/src/ui/dialogs/tie.d.ts +41 -41
- package/types/src/ui/dialogs/volta.d.ts +40 -40
- package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
- package/types/src/ui/fileio/fileInput.d.ts +7 -1
- package/types/src/ui/fileio/library.d.ts +40 -40
- package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
- package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
- package/types/src/ui/menus/file.d.ts +8 -8
- package/types/src/ui/menus/language.d.ts +7 -7
- package/types/src/ui/menus/manager.d.ts +58 -58
- package/types/src/ui/menus/menu.d.ts +159 -159
- package/types/src/ui/menus/partSelection.d.ts +14 -14
- package/types/src/ui/menus/score.d.ts +8 -8
- package/types/src/ui/menus/staffModifier.d.ts +17 -17
- package/types/typedoc.d.ts +147 -147
- package/src/ui/dialogs/dynamics.ts +0 -141
- package/types/src/ui/dialogs/dynamics.d.ts +0 -37
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Feature Specification: Key-Distance Enharmonic Spelling for Transposition
|
|
2
|
+
|
|
3
|
+
**Feature Branch**: `033-key-distance-transposition`
|
|
4
|
+
|
|
5
|
+
**Created**: 2026-10-27
|
|
6
|
+
|
|
7
|
+
**Status**: Draft
|
|
8
|
+
|
|
9
|
+
**Input**: User description: "We need a better way to transpose. There is a table object in music.ts called enharmonicRoles. It is supposed to determine enharmonic equivalents when transposing. For instance, when transposing c# in the key of C major to D major, it should be a D# and not an Eb. It is also used to choose the correct default for a non-key enharmonic. But, it (the enharmonic table) doesn't really work and it is too bulky and error-prone. I think there is a better way using just the key signature and the number of sharps/flats per key signature. A non-key note like c# in C Major will have a 'distance', which is how many sharps/flats you would have to add to get a key with the note. For instance, in the key of c, 1/2 down from a B is either Bb or A#. Bb is 2 flats away from C, A# is 5 sharps. So Bb is a more logical default. Likewise when pasting from one key to another, we would want to preserve the distance. So pasting A# from the key of C into D would give a B# since you have to add the same number of accidentals. If the sharps/flats is a tie with both the same distance, we will go with the flat direction. When transposing the whole score in the scoreTranspose component, we should calculate the destination key, and try to preserve the distance for the enharmonics. So for instance going from Eb up 4 steps to G, E natural would go to G#. So we want to replace the enharmonicRoles table in music.ts with this logic."
|
|
10
|
+
|
|
11
|
+
## User Scenarios & Testing *(mandatory)*
|
|
12
|
+
|
|
13
|
+
### User Story 1 - Pasting notes into a different key keeps their spelling relationship (Priority: P1)
|
|
14
|
+
|
|
15
|
+
A composer copies a passage from a measure in one key and pastes it into a measure in another key (for example, a transposing instrument's part, or a modulation). Notes that belong to the source key stay diatonic in the destination key. Notes that were chromatic in the source (accidentals outside the key) must stay chromatic in the destination, with the same kind of alteration: a note that was one sharp above a key tone stays one sharp above the corresponding key tone, rather than being respelled as a flat of the next tone up.
|
|
16
|
+
|
|
17
|
+
**Why this priority**: Pasting between keys is the everyday path where wrong spellings appear (a D# turning into an Eb, a B# turning into a C). Fixing it delivers the core value of the feature, and is independently useful even if whole-score transposition is not changed.
|
|
18
|
+
|
|
19
|
+
**Independent Test**: Put a C# in a measure in C major, copy it, and paste it into a measure in D major transposed up a whole step. It must appear as D#, not Eb. Put an A# in C major and paste into D major: it must appear as B#.
|
|
20
|
+
|
|
21
|
+
**Acceptance Scenarios**:
|
|
22
|
+
|
|
23
|
+
1. **Given** a C# in C major, **When** it is pasted/transposed into D major (up a major second), **Then** the pitch is spelled D#, not Eb.
|
|
24
|
+
2. **Given** an A# in C major, **When** it is pasted into D major (up a major second), **Then** the pitch is spelled B# (same number of accidentals added to the key as in the source).
|
|
25
|
+
3. **Given** notes that are all in the source key's signature, **When** they are pasted into another key, **Then** every note is spelled as the corresponding note of the destination key signature.
|
|
26
|
+
4. **Given** pasting into a measure in the same key with no transposition, **When** the paste completes, **Then** each pitch keeps its original spelling.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### User Story 2 - Whole-score transposition preserves chromatic spelling (Priority: P1)
|
|
31
|
+
|
|
32
|
+
A user opens the score transpose dialog and transposes the entire score (or selected staves) by an interval. The destination key signature is computed from the interval. Chromatic notes in the score keep their relationship to the key: a natural sign against a flat key signature stays an "up a step from the key tone" alteration in the destination, and so on.
|
|
33
|
+
|
|
34
|
+
**Why this priority**: Whole-score transposition is how users prepare parts for transposing instruments. Wrong enharmonic spellings force the user to hand-correct many notes, which is the main pain behind this request.
|
|
35
|
+
|
|
36
|
+
**Independent Test**: Create a passage in Eb major containing an E natural, then transpose the score up a major third (4 half steps) to G major. The E natural must become G#. Diatonic notes become the matching G major scale notes.
|
|
37
|
+
|
|
38
|
+
**Acceptance Scenarios**:
|
|
39
|
+
|
|
40
|
+
1. **Given** a passage in Eb major with an E natural, **When** the score is transposed up 4 half steps (destination key G major), **Then** the E natural becomes G#, not Ab.
|
|
41
|
+
2. **Given** a score transposed by any interval, **When** the transposition completes, **Then** the destination key signature of each measure is the key signature that results from the interval, and diatonic notes are spelled by that signature.
|
|
42
|
+
3. **Given** a chromatic note in the source key, **When** the score is transposed, **Then** the distance of the note from the destination key (how many accidentals must be added to the key to include it) equals its distance from the source key.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### User Story 3 - Sensible default spelling for notes outside the key (Priority: P2)
|
|
47
|
+
|
|
48
|
+
When a note not in the current key signature is created or converted to a different enharmonic spelling (for example by toggling between sharp and flat, entering a MIDI note, or other operations that must choose between equivalent spellings), the spelling that is closest to the key is chosen. "Closest" means the spelling that requires adding the fewest sharps or flats to the key signature for the note to belong to it. If two spellings are equally close, the flat spelling is chosen.
|
|
49
|
+
|
|
50
|
+
**Why this priority**: This is the second use of the existing table. It affects the default spelling of every non-key note, but each wrong default is a one-click correction, so it is less severe than the transposition errors above.
|
|
51
|
+
|
|
52
|
+
**Independent Test**: In C major, enter the pitch one half step below B. It must default to Bb rather than A#. In a key where a sharp spelling and a flat spelling are equally far from the key, the flat spelling must be chosen.
|
|
53
|
+
|
|
54
|
+
**Acceptance Scenarios**:
|
|
55
|
+
|
|
56
|
+
1. **Given** the key of C major, **When** the pitch a half step below B is spelled by default, **Then** the result is Bb (closer to the key than A#).
|
|
57
|
+
2. **Given** a pitch whose sharp spelling and flat spelling are equally far from the key, **When** the default spelling is chosen, **Then** the flat spelling is used.
|
|
58
|
+
3. **Given** a pitch that is already in the key signature, **When** the default spelling is chosen, **Then** the key's own spelling is used.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### User Story 4 - Existing behavior outside spelling is unchanged (Priority: P3)
|
|
63
|
+
|
|
64
|
+
Maintainers and users should see no change in how notes are laid out, played, or saved. Only the enharmonic spelling chosen during transposition, paste, and default spelling changes. The large per-key spelling table is removed from the product in favor of a rule derived from the key signature.
|
|
65
|
+
|
|
66
|
+
**Why this priority**: This is a refactor guard. It matters for confidence and maintainability but does not add a user-visible capability by itself.
|
|
67
|
+
|
|
68
|
+
**Independent Test**: Run the existing test suite and open an existing saved score. Everything that does not involve choosing between enharmonic spellings behaves as before.
|
|
69
|
+
|
|
70
|
+
**Acceptance Scenarios**:
|
|
71
|
+
|
|
72
|
+
1. **Given** the existing test suite, **When** it is run after the change, **Then** tests unrelated to enharmonic spelling continue to pass.
|
|
73
|
+
2. **Given** a saved score, **When** it is opened without being transposed, **Then** it renders and plays identically to before.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### Edge Cases
|
|
78
|
+
|
|
79
|
+
- A note whose preserved-distance spelling needs a double sharp or double flat (for example, a sharp above a key tone that is already sharped in the destination key): the double accidental is used, since it preserves the relationship.
|
|
80
|
+
- The source and destination keys are the same, or the transposition offset is zero: pitches keep their original spelling.
|
|
81
|
+
- Octave boundaries: a spelling change that crosses between B and C (for example B# or Cb) must land in the correct octave so the sounding pitch is unchanged.
|
|
82
|
+
- Transposing by an interval that gives an extreme destination key (more than 7 sharps or flats): the destination key is mapped to its enharmonic equivalent key with fewer accidentals, and note spelling follows the mapped key.
|
|
83
|
+
- Minor keys: a minor key and its relative major share a key signature; spelling is determined from the key signature, so both behave the same way.
|
|
84
|
+
- Percussion, unpitched, and rest notes are not affected.
|
|
85
|
+
- Grace notes, chord tones, and pitches stored on modifiers (such as pitch-bearing annotations) follow the same rules as regular notes.
|
|
86
|
+
- Two pitches in a chord that map to the same sounding pitch after transposition remain distinct chord tones as they do today.
|
|
87
|
+
|
|
88
|
+
## Requirements *(mandatory)*
|
|
89
|
+
|
|
90
|
+
### Functional Requirements
|
|
91
|
+
|
|
92
|
+
- **FR-001**: The system MUST decide the spelling of a transposed or pasted pitch using only the source key signature, the destination key signature, and the number of sharps or flats in each key signature. It MUST NOT rely on a per-key table of spellings.
|
|
93
|
+
- **FR-002**: The system MUST define the "distance" of a pitch from a key as the number of sharps or flats that would have to be added to the key signature for the pitch to belong to it, and MUST use distance to rank alternative spellings of the same sounding pitch.
|
|
94
|
+
- **FR-003**: When choosing a default spelling for a pitch that is not in the key, the system MUST choose the spelling with the smallest distance from the key. Example: in C major, the pitch a half step below B defaults to Bb rather than A#.
|
|
95
|
+
- **FR-004**: When two alternative spellings are equally distant from the key, the system MUST choose the flat spelling.
|
|
96
|
+
- **FR-005**: When a pitch is transposed or pasted from one key to another, the system MUST spell the result so that its distance from the destination key equals its distance from the source key, in the same direction (sharp or flat).
|
|
97
|
+
- **FR-006**: A pitch that belongs to the source key signature MUST be spelled as the corresponding pitch of the destination key signature.
|
|
98
|
+
- **FR-007**: Transposing C# in C major to D major MUST produce D#; pasting A# from C major into D major MUST produce B#.
|
|
99
|
+
- **FR-008**: The score transpose action MUST compute the destination key signature from the source key signature and the transposition interval, and MUST apply the distance-preserving rule to every pitch it transposes.
|
|
100
|
+
- **FR-009**: Transposing a passage in Eb major up 4 half steps to G major MUST turn an E natural into G#.
|
|
101
|
+
- **FR-010**: The sounding pitch (pitch class and octave) of every note MUST be unchanged by respelling; only the letter and accidental may change, and octave numbers MUST be adjusted wherever respelling crosses the B/C boundary.
|
|
102
|
+
- **FR-011**: The previous per-key enharmonic spelling table and the lookups built on it (role-of-pitch and pitch-for-role) MUST be removed, and every feature that used them (transposition, paste into another key, default enharmonic spelling, scale-tone lookup) MUST use the new key-signature-based logic instead.
|
|
103
|
+
- **FR-012**: Behavior that does not involve choosing between enharmonic spellings (rendering, playback, file load/save) MUST be unchanged.
|
|
104
|
+
- **FR-013**: Automated tests MUST cover the worked examples in this specification, the tie-break toward flats, same-key pasting, zero-offset transposition, and octave handling at the B/C boundary.
|
|
105
|
+
|
|
106
|
+
### Key Entities
|
|
107
|
+
|
|
108
|
+
- **Key signature**: A key identified by its tonic and its number of sharps or flats. It determines which seven spellings are natural to the key and is the only information needed to rank other spellings.
|
|
109
|
+
- **Pitch**: A letter, an accidental, and an octave. Several pitches can share one sounding pitch (enharmonic equivalents).
|
|
110
|
+
- **Distance (from a key)**: For a given spelling, the number of sharps or flats that must be added to the key signature for the pitch to belong to it (the number of fifths/fourths from the key to the nearest key containing the pitch), with a direction (sharp-side or flat-side). Zero for pitches in the key. Example: from C, Bb is 1 flat away and A# is 5 sharps away.
|
|
111
|
+
- **Transposition interval**: A signed number of half steps (with the matching diatonic step change) that, together with the source key, determines the destination key.
|
|
112
|
+
|
|
113
|
+
## Success Criteria *(mandatory)*
|
|
114
|
+
|
|
115
|
+
### Measurable Outcomes
|
|
116
|
+
|
|
117
|
+
- **SC-001**: All worked examples in this specification (C# C→D = D#; A# C→D = B#; E natural Eb→G = G#; half step below B in C = Bb) produce the stated spelling.
|
|
118
|
+
- **SC-002**: Transposing every chromatic pitch in a 12-note chromatic passage between every pair of the 15 major key signatures produces a spelling whose distance from the destination key equals its distance from the source key, with no exceptions.
|
|
119
|
+
- **SC-003**: After transposing a passage and then transposing it back by the opposite interval, 100% of the notes return to their original spelling and octave, except notes whose intermediate spelling would need a triple sharp or flat; those are respelled to the nearest double-accidental spelling.
|
|
120
|
+
- **SC-004**: A user transposing a typical melody with chromatic passing notes needs to hand-correct no enharmonic spellings in the result.
|
|
121
|
+
- **SC-005**: The sounding pitch of every note is identical before and after respelling, for all tested keys and intervals.
|
|
122
|
+
- **SC-006**: The existing automated test suite passes with no regressions in behavior unrelated to enharmonic spelling.
|
|
123
|
+
|
|
124
|
+
## Assumptions
|
|
125
|
+
|
|
126
|
+
- Keys are identified by their key signature. A minor key uses the key signature of its relative major, and spelling decisions depend only on the signature.
|
|
127
|
+
- "Distance" is the number of steps around the circle of fifths (equivalently, a count of fourths or fifths) from the current key to the nearest key whose signature contains the pitch as spelled. This equals the number of sharps or flats that must be added to the signature. Example: from C major, Bb is 1 flat away (C to F major), while A# is 5 sharps away (C to B major), so Bb is the default.
|
|
128
|
+
- Direction is part of distance: a note one half step above a key tone is a sharp-direction alteration and a note one half step below is a flat-direction alteration; preserving distance means preserving both count and direction.
|
|
129
|
+
- When transposition would produce a destination key with more than 7 sharps or flats, the enharmonically equivalent key with fewer accidentals is used.
|
|
130
|
+
- Double sharps and double flats are allowed when needed to preserve the distance.
|
|
131
|
+
- The existing score transpose dialog and the paste-into-different-key flow are the only user entry points for transposition. No new dialogs or settings are introduced.
|
|
132
|
+
- The existing scale-tone lookup, which currently reads the table, will be satisfied from the key signature alone.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
description: "Task list for key-distance enharmonic spelling"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tasks: Key-Distance Enharmonic Spelling for Transposition
|
|
7
|
+
|
|
8
|
+
**Input**: Design documents from `/specs/033-key-distance-transposition/`
|
|
9
|
+
|
|
10
|
+
**Prerequisites**: plan.md, spec.md, research.md, data-model.md, contracts/spelling-api.md, quickstart.md
|
|
11
|
+
|
|
12
|
+
**Tests**: Requested (FR-013). One headless test file, `tests/keyDistanceTransposition.ts`, grown story by story.
|
|
13
|
+
|
|
14
|
+
**Organization**: Grouped by user story. US1 and US2 (both P1) share the foundational spelling arithmetic; US1 additionally rewrites cross-key transposition, US2 the whole-score operation, US3 the default spelling, US4 removes the table.
|
|
15
|
+
|
|
16
|
+
## Format: `[ID] [P?] [Story] Description`
|
|
17
|
+
|
|
18
|
+
- **[P]**: Can run in parallel (different files, no dependencies)
|
|
19
|
+
- **[Story]**: Which user story this task belongs to
|
|
20
|
+
|
|
21
|
+
## Phase 1: Setup
|
|
22
|
+
|
|
23
|
+
- [X] T001 Create `tests/keyDistanceTransposition.ts` with the `check()`/failure-count harness and score-less imports used by `tests/voiceCopyPaste.ts` (exit code 1 on any failure), and register `"test:key-distance-transposition": "ts-node -P tests/tsconfig.json tests/keyDistanceTransposition.ts"` in `package.json`
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Phase 2: Foundational (Blocking Prerequisites)
|
|
28
|
+
|
|
29
|
+
**Purpose**: The line-of-fifths arithmetic every story uses. See [data-model.md](data-model.md).
|
|
30
|
+
|
|
31
|
+
- [X] T002 Fix the `'Gg'` typo to `'Gb'` in `SmoMusic.keySignatureLength` in `src/smo/data/music.ts` (research R8)
|
|
32
|
+
- [X] T003 Add `SmoMusic.keyFifths(keySignature)` in `src/smo/data/music.ts` returning sharps (+) / flats (-) for a lowercase VexFlow key, using the existing sharp/flat counts; unknown key returns 0
|
|
33
|
+
- [X] T004 Add `SmoMusic.pitchFifths(pitch)` and `SmoMusic.fifthsToPitch(f, octave)` in `src/smo/data/music.ts` per the data model (base F=-1, C=0, G=1, D=2, A=3, E=4, B=5; +7 per sharp; valid range -15..19; accidental strings `'n'`, `'#'`, `'##'`, `'b'`, `'bb'`)
|
|
34
|
+
- [X] T005 Add a sounding-pitch helper in `src/smo/data/music.ts` using the letter-based rule in research R10 (`octave*12 + naturalValue + accidentalCount`), and a helper that returns the pitch for position `f` whose sounding value equals a given target (solves the octave); do not change `smoPitchToInt`
|
|
35
|
+
- [X] T006 Add `SmoMusic.distanceFromKey(pitch, keySignature)` in `src/smo/data/music.ts`: 0 inside `k-1..k+5`, `f-(k+5)` above, `f-(k-1)` below
|
|
36
|
+
- [X] T007 Add `SmoMusic.spellPitchClass(soundingValue, keySignature)` (internal helper used by US1, US3): enumerates positions `f0+12m` within -15..19 for the pitch class, returns the smallest absolute distance, ties to the lower (flat-side) position, with octave solved via T005
|
|
37
|
+
- [X] T008 Tests in `tests/keyDistanceTransposition.ts`: `keyFifths` for all 15 major keys, `pitchFifths`/`fifthsToPitch` round trip over -15..19, `distanceFromKey` for A# in C (+5), Bb in C (-1), C# in C (+2), E in Eb (+2), G# in G (+2), in-key notes (0), and sounding-value checks `cb4`=47, `b#3`=48
|
|
38
|
+
|
|
39
|
+
**Checkpoint**: arithmetic verified; stories can proceed.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Phase 3: User Story 1 - Pasting into a different key keeps spelling (Priority: P1) 🎯 MVP
|
|
44
|
+
|
|
45
|
+
**Goal**: `transposePitchForKey` preserves distance from source key to destination key, for paste, chord symbols and instrument transposition.
|
|
46
|
+
|
|
47
|
+
**Independent Test**: C# in C → D (+2) gives D#; A# in C → D gives B#.
|
|
48
|
+
|
|
49
|
+
### Tests for User Story 1
|
|
50
|
+
|
|
51
|
+
- [X] T009 [US1] In `tests/keyDistanceTransposition.ts` add cases: C#→D#, A#→B#, E natural Eb→G (+4)→G#, F in C → G (+7)→C, in-key scale (all 7 notes of C into every other major key map to the destination scale), same key with offset 0 keeps spelling, Cb4 in Gb → G (+1)→C4 with sounding value +1, sounding value invariant `value(result) == value(input)+offset` over all 12 chromatic notes × 15 key pairs × offsets consistent with the keys, mismatched key/offset still yields correct sounding pitch (research R4), chord symbol `C#` in C→D gives `D#` via `SmoNoteModifiers` chord transposition path (`src/smo/data/noteModifiers.ts`)
|
|
52
|
+
|
|
53
|
+
### Implementation for User Story 1
|
|
54
|
+
|
|
55
|
+
- [X] T010 [US1] Rewrite `SmoMusic.transposePitchForKey` in `src/smo/data/music.ts`: `s = kd - ks`, adjusted by a multiple of 12 only when `7*s mod 12` disagrees with `7*offset mod 12`; new position `f + s`; if outside -15..19 respell via `spellPitchClass`; solve octave via T005; return a new `Pitch` (no `findRoleOfPitch`/`findPitchForRole`)
|
|
56
|
+
- [X] T011 [US1] Verify callers need no change: `SmoNote.transpose` in `src/smo/data/note.ts` and chord-symbol transposition in `src/smo/data/noteModifiers.ts`; run `npm run test:key-distance-transposition` and `npm run test:voice-copy-paste`
|
|
57
|
+
|
|
58
|
+
**Checkpoint**: Cross-key paste and chord symbols spell correctly. MVP complete.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Phase 4: User Story 2 - Whole-score transposition (Priority: P1)
|
|
63
|
+
|
|
64
|
+
**Goal**: Transpose Score computes each measure's destination key and preserves distance, including grace notes.
|
|
65
|
+
|
|
66
|
+
**Independent Test**: Two Eb-major measures containing E natural, transposed +4, become G major with G#.
|
|
67
|
+
|
|
68
|
+
### Tests for User Story 2
|
|
69
|
+
|
|
70
|
+
- [X] T012 [US2] In `tests/keyDistanceTransposition.ts` add `keyForOffset` cases (offset 0 returns the input key including `c#`/`cb`; Eb+4=g; 6 vs -6 tie gives `gb`; results always within -7..+7) and a score-level case: build a small `SmoScore` (see setup in `tests/voiceCopyPaste.ts`), call `SmoOperation.transposeScore(score, 4)`, assert each measure's `keySignature` is `g` and E natural became G#; then `transposeScore(score, -4)` restores spelling, octave and key; include a grace note and a chord
|
|
71
|
+
|
|
72
|
+
### Implementation for User Story 2
|
|
73
|
+
|
|
74
|
+
- [X] T013 [US2] Add `SmoMusic.keyForOffset(keySignature, offset)` in `src/smo/data/music.ts`: residue of `ks + 7*offset` mod 12 in -7..+7, fewest accidentals, tie to flats, offset 0 returns the input key unchanged (research R5); return lowercase VexFlow string
|
|
75
|
+
- [X] T014 [US2] Rewrite `SmoOperation.transposeScore` in `src/smo/xform/operations.ts` (line ~416): for each measure compute `kd = keyForOffset(measure.keySignature, offset)`, transpose every note pitch and grace-note pitch with `transposePitchForKey(pitch, ks, kd, offset)` (preserving the tab-note fret adjustment already done in `SmoOperation.transpose`), then set `measure.keySignature = kd`; zero offset is a no-op. Keep `SuiScoreViewOperations.transposeScore` in `src/render/sui/scoreViewOperations.ts` calling it for both `score` and `storeScore`
|
|
76
|
+
- [X] T015 [US2] Confirm the dialog in `src/ui/dialogs/transposeScore.ts` still works with incremental offsets and cancel (`-delta`) by reasoning through the inverse-shift property; adjust only if the inverse does not restore the key
|
|
77
|
+
|
|
78
|
+
**Checkpoint**: Transpose Score yields correct key and spelling and is reversible.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Phase 5: User Story 3 - Default spelling outside the key (Priority: P2)
|
|
83
|
+
|
|
84
|
+
**Goal**: `getEnharmonicInKey` (and callers) pick the closest spelling to the key, ties to flats.
|
|
85
|
+
|
|
86
|
+
**Independent Test**: In C, the pitch a half step below B defaults to Bb; a tie such as pitch class 8 in C defaults to Ab.
|
|
87
|
+
|
|
88
|
+
### Tests for User Story 3
|
|
89
|
+
|
|
90
|
+
- [X] T016 [US3] In `tests/keyDistanceTransposition.ts` add default-spelling cases for key C: pc 10 → Bb, pc 3 → Eb, pc 8 → Ab (tie to flat), pc 1 → C#, pc 6 → F#; for key G: pc 6 → F# (in key); for key F: pc 10 → Bb (in key); octave preserved including B/C boundary cases; document in a comment that C# in C (previously Db) is an intended behavior change (research R3)
|
|
91
|
+
|
|
92
|
+
### Implementation for User Story 3
|
|
93
|
+
|
|
94
|
+
- [X] T017 [US3] Rewrite `SmoMusic.getEnharmonicInKey` in `src/smo/data/music.ts` to call `spellPitchClass` (T007), removing the hard-coded `a#/g#/c#/d#/f#` bias block; keep the `octave === undefined` default of 1 and the signature
|
|
95
|
+
- [X] T018 [US3] Reimplement `SmoMusic.getScaleTonesForKey` in `src/smo/data/music.ts` from `keyFifths` (accidental count for base `b` is `floor((k + 5 - b) / 7)`), returning the same `letter → 'f#' / 'bb' / 'cn'` shape; add tests that it matches the old table's output for all 15 major keys (capture expected values before deleting the table, see T020)
|
|
96
|
+
- [X] T019 [US3] Run `npm run test:key-distance-transposition`, then re-run the existing scripts in `package.json` (`test:voice-copy-paste`, `test:multimeasure-rest`, `test:select-voice`, ...) and compare callers `tickMap.ts`, `operations.ts` (lines ~469 and ~1000), `midiToSmo.ts`, `getIntervalInKey` for unintended changes
|
|
97
|
+
|
|
98
|
+
**Checkpoint**: Defaults and scale lookups no longer use the table.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Phase 6: User Story 4 - Table removed, no other change (Priority: P3)
|
|
103
|
+
|
|
104
|
+
**Goal**: The old table and its lookups are gone; nothing unrelated changes.
|
|
105
|
+
|
|
106
|
+
**Independent Test**: Build succeeds with no references to the removed symbols; existing scripts pass.
|
|
107
|
+
|
|
108
|
+
- [X] T020 [US4] Before deleting, record `getScaleTonesForKey` output for every key from the old table into a fixture in `tests/keyDistanceTransposition.ts` (if not already done in T018)
|
|
109
|
+
- [X] T021 [US4] Delete `SmoMusic.enharmonicRoles`, `findRoleOfPitch`, `findPitchForRole` and the `KeySignatureRole` interface from `src/smo/data/music.ts`; confirm with a grep that no references remain in `src/`, `tests/`, `types/`
|
|
110
|
+
- [X] T022 [US4] Regenerate type declarations with `npm run types` so `types/src/smo/data/music.d.ts` drops `enharmonicRoles` and gains the new methods
|
|
111
|
+
- [X] T023 [US4] Run `npm run build` and every `test:*` script in `package.json`; fix regressions
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Phase 7: Polish & Cross-Cutting
|
|
116
|
+
|
|
117
|
+
- [X] T024 [P] Add a changelog entry to `changes.md` describing the new spelling rules, the changed default for C# in C, and that Transpose Score now updates key signatures
|
|
118
|
+
- [X] T025 [P] Update the doc comment above `getEnharmonicInKey`/`transposePitchForKey` in `src/smo/data/music.ts` to describe the distance rule
|
|
119
|
+
- [ ] T026 Walk through the manual checks in [quickstart.md](quickstart.md) in the running application
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Dependencies & Execution Order
|
|
124
|
+
|
|
125
|
+
- Phase 1 → Phase 2 → stories. Phase 2 blocks everything.
|
|
126
|
+
- US1 (Phase 3) and US2 (Phase 4): US2 needs T010 (the rewritten `transposePitchForKey`) but not the rest of US1's tests; sequence US1 → US2.
|
|
127
|
+
- US3 (Phase 5) depends only on Phase 2 and can run in parallel with US1/US2 by a second contributor, but all edits are in `music.ts`, so serialize the edits.
|
|
128
|
+
- US4 (Phase 6) last: it removes the table, after T018 has replaced the last reader (`getScaleTonesForKey`) and T010/T017 replaced the others.
|
|
129
|
+
- Polish after all stories.
|
|
130
|
+
|
|
131
|
+
## Parallel Opportunities
|
|
132
|
+
|
|
133
|
+
Most tasks edit `music.ts` or the single test file, so parallelism is limited. T024 and T025 (changelog, doc comment) can be done together after T023.
|
|
134
|
+
|
|
135
|
+
## Implementation Strategy
|
|
136
|
+
|
|
137
|
+
1. Phases 1–2 (arithmetic), then US1 → validate with the C#→D# and A#→B# cases (MVP).
|
|
138
|
+
2. US2 for whole-score transposition, validate with the Eb→G example.
|
|
139
|
+
3. US3 for defaults, then US4 to remove the table and clean up.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Specification Quality Checklist: Compressed Score Files (.smz)
|
|
2
|
+
|
|
3
|
+
**Purpose**: Validate specification completeness and quality before proceeding to planning
|
|
4
|
+
**Created**: 2026-10-30
|
|
5
|
+
**Feature**: [spec.md](../spec.md)
|
|
6
|
+
|
|
7
|
+
## Content Quality
|
|
8
|
+
|
|
9
|
+
- [x] No implementation details (languages, frameworks, APIs)
|
|
10
|
+
- [x] Focused on user value and business needs
|
|
11
|
+
- [x] Written for non-technical stakeholders
|
|
12
|
+
- [x] All mandatory sections completed
|
|
13
|
+
|
|
14
|
+
## Requirement Completeness
|
|
15
|
+
|
|
16
|
+
- [x] No [NEEDS CLARIFICATION] markers remain
|
|
17
|
+
- [x] Requirements are testable and unambiguous
|
|
18
|
+
- [x] Success criteria are measurable
|
|
19
|
+
- [x] Success criteria are technology-agnostic (no implementation details)
|
|
20
|
+
- [x] All acceptance scenarios are defined
|
|
21
|
+
- [x] Edge cases are identified
|
|
22
|
+
- [x] Scope is clearly bounded
|
|
23
|
+
- [x] Dependencies and assumptions identified
|
|
24
|
+
|
|
25
|
+
## Feature Readiness
|
|
26
|
+
|
|
27
|
+
- [x] All functional requirements have clear acceptance criteria
|
|
28
|
+
- [x] User scenarios cover primary flows
|
|
29
|
+
- [x] Feature meets measurable outcomes defined in Success Criteria
|
|
30
|
+
- [x] No implementation details leak into specification
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- "Zip" and ".smz" are user-facing format names given in the request, not implementation choices.
|
|
35
|
+
- Interpretations to confirm (recorded in Assumptions): the default Smoosic save becomes `.smz` with no separate new-abbreviated-JSON option; the validation format stays plain `.json`; files are recognized by their contents when the name and contents disagree; remote/library loading also accepts `.smz`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Contract: Score archive API
|
|
2
|
+
|
|
3
|
+
Library surface (exported from `src/application/exports.ts`). All functions are static on `SmoScoreArchive` in `src/ui/fileio/scoreArchive.ts`. Requires the global `JSZip` at call time.
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
| Method | Signature | Behavior |
|
|
8
|
+
|--------|-----------|----------|
|
|
9
|
+
| `pack` | `(score: SmoScore) => Promise<Uint8Array>` | Serializes with `{ skipStaves: false, useDictionary: false, preserveStaffIds: false }` and returns a zip with one `score.json` entry, DEFLATE level 9. |
|
|
10
|
+
| `isZip` | `(data: ArrayBuffer \| Uint8Array \| string) => boolean` | True when the first four bytes are `50 4B 03 04`. A string input is never a zip. |
|
|
11
|
+
| `unpack` | `(data: ArrayBuffer \| Uint8Array \| string) => Promise<string>` | Returns the score document text. Zip: finds the score entry as in the data model. Not a zip: UTF-8 decodes bytes (or takes the string) and strips a leading byte-order mark. Throws `Error` with a readable message on failure. |
|
|
12
|
+
| `load` | `(data: ArrayBuffer \| Uint8Array \| string) => Promise<SmoScore>` | `unpack` then `SmoScore.deserialize`. Throws `Error` if the result is not a score. |
|
|
13
|
+
|
|
14
|
+
## Changed behavior elsewhere
|
|
15
|
+
|
|
16
|
+
| Item | Change |
|
|
17
|
+
|------|--------|
|
|
18
|
+
| `SmoScore.serialize(options)` | `useDictionary` is read from `options.useDictionary` (default true), not from `skipStaves`. |
|
|
19
|
+
| `isFullSaveFormat(ext)` | True for `.json` and `.smz` (case-insensitive, trimmed). |
|
|
20
|
+
| `SuiFileInput(evt, scoresAsBytes?)` | When `scoresAsBytes` is true, `.json` and `.smz` are read as `ArrayBuffer`. `.smz` is always read as bytes. Default behavior otherwise unchanged. |
|
|
21
|
+
| `SuiXhrLoader.loadScoreAsync()` | New. Returns the score document text for a `.json` or `.smz` URL; throws as `unpack` does. `loadAsync()` is unchanged. |
|
|
22
|
+
| Save dialog formats | "Smoosic" is `.smz` (default); "Validation (large)" saves plain full JSON with the `.json` extension; MusicXML, MIDI and Vex unchanged. |
|
|
23
|
+
| Open dialog | Accepts `.smz` as well as `.json`, `.mid`, `.midi`, `.xml`, `.mxl`. A failed `.json`/`.smz` load shows a message and leaves the open score untouched. |
|
|
24
|
+
|
|
25
|
+
## Invariants (asserted by tests)
|
|
26
|
+
|
|
27
|
+
1. `await SmoScore.deserialize(await unpack(await pack(score)))` serializes (full form) to the same text as `score`.
|
|
28
|
+
2. `unpack` of a legacy abbreviated file and `unpack` of the same score's validation file yield scores whose full serialization is identical.
|
|
29
|
+
3. `unpack` gives the same result for a zip regardless of what the file was called (the name is not an input).
|
|
30
|
+
4. A failed load throws; no function mutates a score it was not asked to create.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Data Model: Compressed Score Files (.smz)
|
|
2
|
+
|
|
3
|
+
The score document itself does not change. These are the file-level shapes.
|
|
4
|
+
|
|
5
|
+
## Score document (existing)
|
|
6
|
+
|
|
7
|
+
The JSON produced by `SmoScore.serialize` and read by `SmoScore.deserialize`. Two textual forms exist:
|
|
8
|
+
|
|
9
|
+
| Form | Where it comes from | How to tell |
|
|
10
|
+
|------|--------------------|-------------|
|
|
11
|
+
| Abbreviated (legacy) | Default save before this feature | Has a top-level `dictionary` key; other keys are short tokens |
|
|
12
|
+
| Full | Validation save; contents of `.smz` | No `dictionary` key |
|
|
13
|
+
|
|
14
|
+
`deserialize` handles both; it is not changed by this feature.
|
|
15
|
+
|
|
16
|
+
## `.smz` archive (new)
|
|
17
|
+
|
|
18
|
+
| Part | Value |
|
|
19
|
+
|------|-------|
|
|
20
|
+
| Container | Standard zip file, starts with bytes `50 4B 03 04` |
|
|
21
|
+
| Entry `score.json` | Full score document, UTF-8, no byte-order mark |
|
|
22
|
+
| Compression | DEFLATE, level 9 |
|
|
23
|
+
| Other entries | Ignored on read; not written |
|
|
24
|
+
|
|
25
|
+
Read rule: use `score.json` if present; otherwise the first non-directory entry whose name ends in `.json`; otherwise the file is refused.
|
|
26
|
+
|
|
27
|
+
## Score file kinds and how each is recognized
|
|
28
|
+
|
|
29
|
+
| Kind | Extension written | Recognized by | Written by this version? |
|
|
30
|
+
|------|------------------|---------------|-------------------------|
|
|
31
|
+
| Compressed (`.smz`) | `.smz` | zip signature | Yes (default) |
|
|
32
|
+
| Legacy abbreviated | `.json` | text, JSON with `dictionary` key | No |
|
|
33
|
+
| Validation | `.json` | text, JSON without `dictionary` key | Yes (option) |
|
|
34
|
+
|
|
35
|
+
Recognition ignores the file name; the extension only picks the suggested name and the file-chooser filter.
|
|
36
|
+
|
|
37
|
+
## Load result
|
|
38
|
+
|
|
39
|
+
`unpack(input)` returns the score document text, or throws one of these failures (message shown to the user):
|
|
40
|
+
|
|
41
|
+
| Failure | Cause |
|
|
42
|
+
|---------|-------|
|
|
43
|
+
| Not a score file | Not a zip and the text is not valid JSON |
|
|
44
|
+
| Damaged archive | Zip signature present but the archive cannot be read |
|
|
45
|
+
| No score in archive | Valid zip with no `score.json` or other `.json` entry |
|
|
46
|
+
| Not a score | JSON that does not look like a score (no `staves`) |
|
|
47
|
+
|
|
48
|
+
State transitions: none. Loading never mutates the open score; replacement happens only after a successful load and the unsaved-changes confirmation.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Implementation Plan: Compressed Score Files (.smz)
|
|
2
|
+
|
|
3
|
+
**Branch**: `034-smz-compressed-scores` (work is on `main`; no feature branch was created) | **Date**: 2026-10-30 | **Spec**: [spec.md](spec.md)
|
|
4
|
+
|
|
5
|
+
**Input**: Feature specification from `/specs/034-smz-compressed-scores/spec.md`
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
Add a small, DOM-free module that turns a score into a `.smz` archive (a zip holding one full, un-abbreviated score document) and turns bytes or text from any supported score file (`.smz`, legacy abbreviated `.json`, validation `.json`) back into the JSON text that `SmoScore.deserialize` already understands. Wire it into the save dialog (default format becomes `.smz`, validation stays plain `.json`), the Open dialog, and the remote/library loaders. Detection is by content (zip signature), so a mis-named file still works. Failures leave the open score alone and show a message.
|
|
10
|
+
|
|
11
|
+
Measured on the one library score in the repo: the full document zipped is 1,857 bytes, against 17,627 for today's default save and 22,112 for the validation text, so the dictionary is not needed (see [research.md](research.md) R1).
|
|
12
|
+
|
|
13
|
+
## Technical Context
|
|
14
|
+
|
|
15
|
+
**Language/Version**: TypeScript, tests run with `ts-node` (see `tests/tsconfig.json`).
|
|
16
|
+
|
|
17
|
+
**Primary Dependencies**: JSZip v3.6.0, already shipped (`src/common/jszip.js`, `release/jszip.js`, loaded by a script tag, declared as `JSZip: 'JSZip'` in webpack externals and used as `declare var JSZip: any` in `src/ui/fileio`). No new dependency. Vue 3 for the dialogs.
|
|
18
|
+
|
|
19
|
+
**Storage**: User-chosen files on disk (download link on save, file input on open); remote files over XHR. The browser's automatic local-storage copy is untouched.
|
|
20
|
+
|
|
21
|
+
**Testing**: Headless `ts-node` script `tests/scoreArchive.ts` (npm script `test:score-archive`). In Node the global `JSZip` is provided by `require('../src/common/jszip.js')`.
|
|
22
|
+
|
|
23
|
+
**Target Platform**: Browser application and library; the archive module is also usable headless.
|
|
24
|
+
|
|
25
|
+
**Project Type**: Single project.
|
|
26
|
+
|
|
27
|
+
**Performance Goals**: Save and open within 1 second of the previous format on a typical score (SC-004). Compression and decompression are asynchronous and do not block rendering.
|
|
28
|
+
|
|
29
|
+
**Constraints**: Must open every existing `.json` score unchanged. The data model in `src/smo` stays free of file and UI concerns (constitution principle 4); `TextDecoder`/`TextEncoder` and the `JSZip` global are the only platform pieces.
|
|
30
|
+
|
|
31
|
+
**Scale/Scope**: One new module, edits to about six existing files, one new test file.
|
|
32
|
+
|
|
33
|
+
## Constitution Check
|
|
34
|
+
|
|
35
|
+
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
|
36
|
+
|
|
37
|
+
| Principle | Assessment |
|
|
38
|
+
|-----------|------------|
|
|
39
|
+
| #1 Serialization (scores must serialize and deserialize, including legacy) | Pass. This feature is about serialization. The score document is unchanged; only the container changes. Legacy abbreviated and validation JSON stay readable, and tests cover each. |
|
|
40
|
+
| #2 Editing/transformation logic regression tested | Pass. Round-trip, legacy, validation and failure cases are all headless tests. |
|
|
41
|
+
| #3 Rendering performance | Pass. No render-path change; compression is async and off the render path. |
|
|
42
|
+
| #4 Logical dependencies | Pass. The archive module sits in `src/ui/fileio` with the other load utilities, and nothing in `src/smo` refers to it. It depends on `SmoScore`; the dependency does not run the other way. |
|
|
43
|
+
|
|
44
|
+
Re-check after Phase 1 design: still passes. No complexity violations.
|
|
45
|
+
|
|
46
|
+
## Project Structure
|
|
47
|
+
|
|
48
|
+
### Documentation (this feature)
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
specs/034-smz-compressed-scores/
|
|
52
|
+
├── plan.md # This file
|
|
53
|
+
├── research.md # Phase 0 output
|
|
54
|
+
├── data-model.md # Phase 1 output
|
|
55
|
+
├── quickstart.md # Phase 1 output
|
|
56
|
+
├── contracts/
|
|
57
|
+
│ └── archive-api.md # Phase 1 output
|
|
58
|
+
├── checklists/
|
|
59
|
+
│ └── requirements.md
|
|
60
|
+
└── tasks.md # Phase 2 output (/speckit-tasks - NOT created by /speckit-plan)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Source Code (repository root)
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
src/ui/fileio/scoreArchive.ts # NEW: pack / unpack / load / isZip, no DOM dependency; with the other load utilities
|
|
67
|
+
src/smo/data/score.ts # fix useDictionary option (reads skipStaves today)
|
|
68
|
+
src/ui/fileio/fileInput.ts # read .smz (and, opt-in, .json) as bytes
|
|
69
|
+
src/ui/fileio/xhrLoader.ts # loadScoreAsync(): read a score URL as bytes, return JSON text
|
|
70
|
+
src/ui/dialogs/fileDialogs.ts # open: accept .smz, content detection, error message; save: .smz
|
|
71
|
+
src/ui/components/dialogs/fileUpload.vue # accept list gains .smz
|
|
72
|
+
src/ui/components/dialogs/save.vue # Smoosic = .smz, binary contents, wait for async content
|
|
73
|
+
src/render/sui/scoreChangeState.ts # isFullSaveFormat accepts .smz
|
|
74
|
+
src/render/sui/scoreViewOperations.ts # loadRemoteJson uses loadScoreAsync
|
|
75
|
+
src/application/application.ts # remote initial score uses loadScoreAsync for .json/.smz
|
|
76
|
+
src/application/generateVexTests.ts # remote scores use loadScoreAsync
|
|
77
|
+
src/application/exports.ts # export the new module
|
|
78
|
+
types/src/ui/fileio/scoreArchive.d.ts, fileInput.d.ts, xhrLoader.d.ts, exports.d.ts # regenerated (only these)
|
|
79
|
+
tests/scoreArchive.ts # NEW
|
|
80
|
+
tests/scoreChangeState.ts # .smz is a full save
|
|
81
|
+
package.json # test:score-archive script
|
|
82
|
+
changes.md # changelog entry
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Structure Decision**: Single-project layout as it exists. A separate module in `src/ui/fileio` rather than methods on `SmoScore` or a file in `src/smo/data`, because it deals with bytes and the zip library like the other file loaders, while `SmoScore` and the data model deal with the document and know nothing about files.
|
|
86
|
+
|
|
87
|
+
## Complexity Tracking
|
|
88
|
+
|
|
89
|
+
No constitution violations to justify.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Quickstart: Validating .smz Support
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
- `npm install` done at the repository root.
|
|
6
|
+
- For the manual checks, a built application (`npm run build`) or the development page you normally use.
|
|
7
|
+
|
|
8
|
+
## Automated check
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm run test:score-archive
|
|
12
|
+
npm run test:score-change-state
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Expected: every line prints `PASS`, exit code 0. See [contracts/archive-api.md](contracts/archive-api.md) for the invariants and [data-model.md](data-model.md) for the file shapes.
|
|
16
|
+
|
|
17
|
+
| # | Scenario | Expected |
|
|
18
|
+
|---|----------|----------|
|
|
19
|
+
| 1 | Pack a score, check the first bytes and the entry name | Starts `50 4B 03 04`; one entry `score.json` |
|
|
20
|
+
| 2 | Pack then load a score with accented and non-Latin text in title and lyrics | Identical full serialization, text intact |
|
|
21
|
+
| 3 | Load `release/library/pennylane2 (6).json` (legacy abbreviated) | Loads; full serialization equals the validation file for the same score |
|
|
22
|
+
| 4 | Load a validation file | Loads |
|
|
23
|
+
| 5 | Hand the bytes of a zip to `unpack` as if it were named `.json`; hand text to `unpack` as if named `.smz` | Both load (content, not name, decides) |
|
|
24
|
+
| 6 | Truncated zip | Throws "damaged archive" |
|
|
25
|
+
| 7 | Zip with only `readme.txt` | Throws "no score in archive" |
|
|
26
|
+
| 8 | Text `{"hello":1}` | Throws "not a score" |
|
|
27
|
+
| 9 | Text with a leading byte-order mark | Loads |
|
|
28
|
+
| 10 | Sizes for the library score | Zipped full document smaller than the abbreviated text; at least 50% smaller than the full text |
|
|
29
|
+
| 11 | `serialize({ skipStaves: true, useDictionary: false })` | No `dictionary` key |
|
|
30
|
+
| 12 | `isFullSaveFormat('.smz')` | True |
|
|
31
|
+
|
|
32
|
+
## Manual check in the application
|
|
33
|
+
|
|
34
|
+
1. Start the app and open the Save dialog. The format shown is Smoosic and the suggested file ends in `.smz`.
|
|
35
|
+
2. Save. The unsaved-changes indicator clears. Open the file with any zip tool: one `score.json`.
|
|
36
|
+
3. Open the Load dialog; the file chooser lists `.smz`. Load the file you just saved; the score is identical.
|
|
37
|
+
4. Load an older `.json` score (for example one downloaded from the library) and a validation file; both open.
|
|
38
|
+
5. Rename a `.smz` to `.json` and load it; it still opens.
|
|
39
|
+
6. Load a text file renamed to `.smz`; a message says the file could not be read and the open score is unchanged.
|
|
40
|
+
7. Switch the save format to MusicXML, then back to Smoosic, and save quickly. The saved file is a valid `.smz`.
|
|
41
|
+
|
|
42
|
+
## Regression
|
|
43
|
+
|
|
44
|
+
Run the other `test:*` scripts in `package.json` to confirm nothing else changed.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Research: Compressed Score Files (.smz)
|
|
2
|
+
|
|
3
|
+
No NEEDS CLARIFICATION remained in the Technical Context. Findings below came from reading the code and from one measurement.
|
|
4
|
+
|
|
5
|
+
## R1. Is the dictionary still worth using?
|
|
6
|
+
|
|
7
|
+
**Decision**: No. `.smz` holds the full, un-abbreviated score document.
|
|
8
|
+
|
|
9
|
+
**Evidence**: Measured on `release/library/pennylane2 (6).json`, the only score shipped in the repo (one sample; the measurement should be repeated on larger scores during implementation):
|
|
10
|
+
|
|
11
|
+
| Form | Bytes |
|
|
12
|
+
|------|-------|
|
|
13
|
+
| Existing file on disk (abbreviated) | 17,270 |
|
|
14
|
+
| Abbreviated text from today's default save | 17,627 |
|
|
15
|
+
| Full text (the validation format) | 22,112 |
|
|
16
|
+
| Abbreviated, zipped | 3,244 |
|
|
17
|
+
| **Full, zipped** | **1,857** |
|
|
18
|
+
|
|
19
|
+
Full-and-zipped is 43% smaller than abbreviated-and-zipped (the short tokens defeat the compressor's matching of repeated names) and about 90% smaller than today's default file. This is better than the "probably the same" in the request, and it also means the file is readable by any tool after unzipping without needing the token map.
|
|
20
|
+
|
|
21
|
+
**Alternatives considered**: Zip the abbreviated form (bigger, and keeps the token map as a permanent compatibility burden); gzip instead of zip (no multi-file container and the user asked for zip).
|
|
22
|
+
|
|
23
|
+
## R2. Container layout and how to recognize it
|
|
24
|
+
|
|
25
|
+
**Decision**: A standard zip with one entry named `score.json` containing the full score document as UTF-8 text, compressed with DEFLATE (level 9). On read, a file is a zip if its first four bytes are `50 4B 03 04`; the entry is `score.json` if present, otherwise the first non-directory entry whose name ends in `.json`. A file that is not a zip is decoded as UTF-8 text (an initial byte-order mark is removed) and treated as JSON.
|
|
26
|
+
|
|
27
|
+
**Rationale**: Content detection satisfies the spec edge case "extension and contents disagree" (FR-008) and does not depend on the file name, which is also unavailable for string input from configuration. A fixed entry name keeps the file self-describing and trivial for other tools to read, while the fallback tolerates archives made by hand.
|
|
28
|
+
|
|
29
|
+
**Alternatives considered**: Detect only by extension (fails the mismatch case); add a manifest or mimetype entry as in EPUB (more moving parts than one document needs).
|
|
30
|
+
|
|
31
|
+
## R3. JSZip availability
|
|
32
|
+
|
|
33
|
+
**Finding**: JSZip is not an npm package in this repo. It ships as `src/common/jszip.js`, is loaded in the HTML pages with `<script src="../jszip.js">`, is a webpack external (`jszip: 'JSZip'`), and the existing `.mxl` import reads it as `declare var JSZip: any`. A headless test therefore needs the global.
|
|
34
|
+
|
|
35
|
+
**Decision**: Use the same `declare var JSZip: any` in the new module (no new import style). The test file sets `global.JSZip = require('../src/common/jszip.js')` before use. The module looks the global up at call time, so import order does not matter.
|
|
36
|
+
|
|
37
|
+
**Alternatives considered**: Add `jszip` to `package.json` (a new dependency and a second copy of the library); implement DEFLATE by hand (reinventing a shipped library).
|
|
38
|
+
|
|
39
|
+
## R4. Where the logic lives
|
|
40
|
+
|
|
41
|
+
**Decision**: New `src/ui/fileio/scoreArchive.ts` exporting a `SmoScoreArchive` class with static `pack`, `unpack`, `load` and `isZip`. It depends only on `SmoScore`, `JSZip`, `TextEncoder` and `TextDecoder`.
|
|
42
|
+
|
|
43
|
+
**Rationale**: Keeps zip and text-decoding logic out of the dialogs so one place decides what a score file is (local, remote, configuration string) and so it is testable without a browser. It sits in `src/ui/fileio` with the other load utilities, because nothing in the data model refers to it (constitution principle 4: `src/smo` stays free of file handling).
|
|
44
|
+
|
|
45
|
+
## R5. Reading files from disk and from URLs
|
|
46
|
+
|
|
47
|
+
**Finding**:
|
|
48
|
+
- `SuiFileInput` reads `.mxl`/`.mid` as `ArrayBuffer` and everything else as text. It is also used by the exported legacy `SuiFileDownloadComponent`, whose callers expect text for `.json`.
|
|
49
|
+
- `SuiXhrLoader` reads text for everything except `.mxl` and `.mid`. Its `value` for `.json` is used as a string by `application.ts` (initial remote score), `scoreViewOperations.loadRemoteJson`, `generateVexTests.ts` and the library list loader.
|
|
50
|
+
|
|
51
|
+
**Decision**:
|
|
52
|
+
- `SuiFileInput` gets an opt-in constructor flag `scoresAsBytes` (default false). With it, `.smz` and `.json` are read as `ArrayBuffer` so the content can be sniffed. `.smz` is always binary because text mode would corrupt it. The Open dialog passes the flag; the legacy component is unchanged.
|
|
53
|
+
- `SuiXhrLoader` gets `loadScoreAsync(): Promise<string>` which reads the response as bytes and returns the JSON text via `SmoScoreArchive.unpack`. Callers that load scores (`loadRemoteJson`, the configured remote score for `.json`/`.smz`, `generateVexTests`) switch to it; the library list loader and `.xml`/`.mxl` paths keep `loadAsync`.
|
|
54
|
+
|
|
55
|
+
**Alternatives considered**: Make every JSON read binary (breaks the library list and legacy callers); decide only on the URL's extension for remote files (fails mismatches, but is simpler; rejected because the spec says remote files follow the same rule as local ones).
|
|
56
|
+
|
|
57
|
+
## R6. Save dialog
|
|
58
|
+
|
|
59
|
+
**Finding**: `save.vue` receives `contents` (a string ref) and builds a `Blob` from it for a download link. `changeExtensionCb` is synchronous and sets `contents`. The options are `.json` (default), `.xml`, `.mid`, `.js`, and `.smojson` ("Validation (large)", which sets the extension to `.json`). `isFullSaveFormat` allows only `.json`.
|
|
60
|
+
|
|
61
|
+
**Decision**:
|
|
62
|
+
- Replace `.json` ("Smoosic") with `.smz`, which is the default. Keep `.smojson` mapped to plain `.json` unchanged.
|
|
63
|
+
- `contents` may be a string or a `Uint8Array`; `Blob` accepts both. Packing is asynchronous, so `changeExtensionCb` becomes async and the dialog awaits the latest pending computation before it clicks the download link, so a quick Save after changing the format never saves stale content.
|
|
64
|
+
- `isFullSaveFormat` accepts `.smz` as well as `.json` (validation still ends in `.json`).
|
|
65
|
+
|
|
66
|
+
## R7. The dictionary option defect
|
|
67
|
+
|
|
68
|
+
**Finding**: In `SmoScore.serialize`, `const useDictionary = options?.skipStaves ?? true;` reads the wrong option. Called with no options (today's default save) the dictionary is used. Called with `{ skipStaves: false, useDictionary: false }` it is not used, only because `skipStaves` is false. Called with `{ skipStaves: true, useDictionary: false }` (the undo and snapshot calls in `scoreView.ts`) it IS used, contradicting the caller's request.
|
|
69
|
+
|
|
70
|
+
**Decision**: Read `options?.useDictionary ?? true`. The archive writer passes `useDictionary: false` explicitly. `deserialize` already handles both forms, so existing snapshots and files are unaffected. The only behavior change is that `{ skipStaves: true, useDictionary: false }` snapshots stop being abbreviated, which is what those callers asked for; implementation should confirm snapshot sizes stay acceptable.
|
|
71
|
+
|
|
72
|
+
## R8. Failure behavior (spec US4)
|
|
73
|
+
|
|
74
|
+
**Finding**: `convertJson` in `fileDialogs.ts` catches any error, logs a warning and returns `null`, so a bad file silently does nothing. The existing `modalMessage.vue` dialog (headline, message, OK) is available, as used by the print dialog.
|
|
75
|
+
|
|
76
|
+
**Decision**: `SmoScoreArchive.load` throws an `Error` with a short readable message for each failure kind (not a zip and not JSON, zip without a score, corrupt archive, text that is not a score). The Open dialog catches it, leaves `pendingScore` null, and after the open dialog closes shows `modalMessage` with the message. The open score is never touched because replacement already waits for `pendingScore`.
|
|
77
|
+
|
|
78
|
+
**Alternatives considered**: Show the error inside the open dialog (it closes on commit; showing after close follows the pattern `confirmReplaceScore` already uses).
|
|
79
|
+
|
|
80
|
+
## R9. Where `.smz` is accepted on open
|
|
81
|
+
|
|
82
|
+
**Decision**: The file chooser `accept` list in `fileUpload.vue` gains `.smz`; the extension check in `fileDialogs.ts` is case-insensitive and routes `.json` and `.smz` to the same loader. MusicXML and MIDI paths are unchanged (FR-012).
|
|
83
|
+
|
|
84
|
+
## R10. Tests
|
|
85
|
+
|
|
86
|
+
**Decision**: `tests/scoreArchive.ts`, with `test:score-archive` in `package.json`, covers: pack/unpack round trip comparing the full serialized document before and after; zip signature and entry name; non-Latin text; legacy abbreviated JSON (from `release/library/pennylane2 (6).json`); validation JSON; a zip renamed (bytes handed to `unpack` regardless of name) and text passed as bytes; corrupt (truncated) zip; zip without a score; text that is not a score; BOM; size comparison on the library score; `serialize` option fix. `tests/scoreChangeState.ts` gains `.smz`.
|