smoosic 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/build/smoosic.js +408 -69
  2. package/changes.md +95 -0
  3. package/package.json +19 -1
  4. package/release/smoosic.js +408 -69
  5. package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
  6. package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
  7. package/specs/032-split-multimeasure-rests/data-model.md +70 -0
  8. package/specs/032-split-multimeasure-rests/plan.md +81 -0
  9. package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
  10. package/specs/032-split-multimeasure-rests/research.md +63 -0
  11. package/specs/032-split-multimeasure-rests/spec.md +127 -0
  12. package/specs/032-split-multimeasure-rests/tasks.md +174 -0
  13. package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
  14. package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
  15. package/specs/033-key-distance-transposition/data-model.md +49 -0
  16. package/specs/033-key-distance-transposition/plan.md +87 -0
  17. package/specs/033-key-distance-transposition/quickstart.md +40 -0
  18. package/specs/033-key-distance-transposition/research.md +82 -0
  19. package/specs/033-key-distance-transposition/spec.md +132 -0
  20. package/specs/033-key-distance-transposition/tasks.md +139 -0
  21. package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
  22. package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
  23. package/specs/034-smz-compressed-scores/data-model.md +48 -0
  24. package/specs/034-smz-compressed-scores/plan.md +89 -0
  25. package/specs/034-smz-compressed-scores/quickstart.md +44 -0
  26. package/specs/034-smz-compressed-scores/research.md +86 -0
  27. package/specs/034-smz-compressed-scores/spec.md +137 -0
  28. package/specs/034-smz-compressed-scores/tasks.md +148 -0
  29. package/specs/035-paste-special/checklists/requirements.md +35 -0
  30. package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
  31. package/specs/035-paste-special/data-model.md +47 -0
  32. package/specs/035-paste-special/plan.md +83 -0
  33. package/specs/035-paste-special/quickstart.md +51 -0
  34. package/specs/035-paste-special/research.md +97 -0
  35. package/specs/035-paste-special/spec.md +170 -0
  36. package/specs/035-paste-special/tasks.md +149 -0
  37. package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
  38. package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
  39. package/specs/036-autosave-recovery/data-model.md +70 -0
  40. package/specs/036-autosave-recovery/plan.md +87 -0
  41. package/specs/036-autosave-recovery/quickstart.md +65 -0
  42. package/specs/036-autosave-recovery/research.md +105 -0
  43. package/specs/036-autosave-recovery/spec.md +143 -0
  44. package/specs/036-autosave-recovery/tasks.md +165 -0
  45. package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
  46. package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
  47. package/specs/037-fix-new-part-dialog/data-model.md +68 -0
  48. package/specs/037-fix-new-part-dialog/plan.md +83 -0
  49. package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
  50. package/specs/037-fix-new-part-dialog/research.md +86 -0
  51. package/specs/037-fix-new-part-dialog/spec.md +144 -0
  52. package/specs/037-fix-new-part-dialog/tasks.md +174 -0
  53. package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
  54. package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
  55. package/specs/038-per-measure-beam-groups/data-model.md +75 -0
  56. package/specs/038-per-measure-beam-groups/plan.md +84 -0
  57. package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
  58. package/specs/038-per-measure-beam-groups/research.md +72 -0
  59. package/specs/038-per-measure-beam-groups/spec.md +146 -0
  60. package/specs/038-per-measure-beam-groups/tasks.md +132 -0
  61. package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
  62. package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
  63. package/specs/039-measure-fill-submenu/data-model.md +79 -0
  64. package/specs/039-measure-fill-submenu/plan.md +81 -0
  65. package/specs/039-measure-fill-submenu/quickstart.md +62 -0
  66. package/specs/039-measure-fill-submenu/research.md +68 -0
  67. package/specs/039-measure-fill-submenu/spec.md +153 -0
  68. package/specs/039-measure-fill-submenu/tasks.md +121 -0
  69. package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
  70. package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
  71. package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
  72. package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
  73. package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
  74. package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
  75. package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
  76. package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
  77. package/specs/041-delete-special/checklists/requirements.md +35 -0
  78. package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
  79. package/specs/041-delete-special/data-model.md +40 -0
  80. package/specs/041-delete-special/plan.md +93 -0
  81. package/specs/041-delete-special/quickstart.md +41 -0
  82. package/specs/041-delete-special/research.md +75 -0
  83. package/specs/041-delete-special/spec.md +136 -0
  84. package/specs/041-delete-special/tasks.md +106 -0
  85. package/specs/042-preserve-music-time-signature/checklists/requirements.md +35 -0
  86. package/specs/042-preserve-music-time-signature/contracts/rebar-api.md +66 -0
  87. package/specs/042-preserve-music-time-signature/data-model.md +73 -0
  88. package/specs/042-preserve-music-time-signature/plan.md +93 -0
  89. package/specs/042-preserve-music-time-signature/quickstart.md +37 -0
  90. package/specs/042-preserve-music-time-signature/research.md +102 -0
  91. package/specs/042-preserve-music-time-signature/spec.md +153 -0
  92. package/specs/042-preserve-music-time-signature/tasks.md +104 -0
  93. package/src/application/application.ts +13 -2
  94. package/src/application/exports.ts +402 -395
  95. package/src/application/generateVexTests.ts +2 -2
  96. package/src/render/sui/NoteEntryCaret.ts +117 -16
  97. package/src/render/sui/autosave.ts +265 -0
  98. package/src/render/sui/formatter.ts +12 -2
  99. package/src/render/sui/renderState.ts +4 -4
  100. package/src/render/sui/scoreChangeState.ts +8 -3
  101. package/src/render/sui/scoreView.ts +47 -2
  102. package/src/render/sui/scoreViewOperations.ts +2761 -2555
  103. package/src/render/sui/staffLineGeometry.ts +82 -0
  104. package/src/render/sui/tracker.ts +18 -23
  105. package/src/render/vex/vxMeasure.ts +22 -8
  106. package/src/render/vex/vxNote.ts +2 -4
  107. package/src/smo/data/measure.ts +58 -1
  108. package/src/smo/data/measureModifiers.ts +81 -1
  109. package/src/smo/data/music.ts +169 -359
  110. package/src/smo/data/note.ts +1 -1
  111. package/src/smo/data/noteModifiers.ts +12 -0
  112. package/src/smo/data/score.ts +179 -7
  113. package/src/smo/data/scoreModifiers.ts +46 -1
  114. package/src/smo/data/systemStaff.ts +43 -0
  115. package/src/smo/xform/beamers.ts +80 -6
  116. package/src/smo/xform/copypaste.ts +207 -47
  117. package/src/smo/xform/measureFill.ts +89 -0
  118. package/src/smo/xform/operations.ts +452 -61
  119. package/src/smo/xform/rebar.ts +490 -0
  120. package/src/smo/xform/selections.ts +73 -0
  121. package/src/ui/components/dialogs/beamGroups.vue +106 -0
  122. package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
  123. package/src/ui/components/dialogs/dynamics.vue +16 -3
  124. package/src/ui/components/dialogs/fileUpload.vue +2 -2
  125. package/src/ui/components/dialogs/hairpin.vue +3 -3
  126. package/src/ui/components/dialogs/newPart.vue +148 -184
  127. package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
  128. package/src/ui/components/dialogs/recovery.vue +66 -0
  129. package/src/ui/components/dialogs/save.vue +11 -4
  130. package/src/ui/components/dialogs/scorePreferences.vue +23 -1
  131. package/src/ui/components/dialogs/slur.vue +6 -6
  132. package/src/ui/components/dialogs/tempo.vue +11 -3
  133. package/src/ui/components/dialogs/timeSignature.vue +18 -3
  134. package/src/ui/components/dialogs/volta.vue +3 -3
  135. package/src/ui/dialogs/annotationVue.ts +1 -1
  136. package/src/ui/dialogs/beamGroupsVue.ts +69 -0
  137. package/src/ui/dialogs/createPartHelpers.ts +68 -0
  138. package/src/ui/dialogs/deleteSpecial.ts +57 -0
  139. package/src/ui/dialogs/dynamicsVue.ts +87 -60
  140. package/src/ui/dialogs/factory.ts +0 -2
  141. package/src/ui/dialogs/fileDialogs.ts +63 -22
  142. package/src/ui/dialogs/instrument.ts +37 -30
  143. package/src/ui/dialogs/pasteSpecial.ts +59 -0
  144. package/src/ui/dialogs/preferences.ts +41 -40
  145. package/src/ui/dialogs/recovery.ts +49 -0
  146. package/src/ui/dialogs/timeSignature.ts +27 -39
  147. package/src/ui/fileio/fileInput.ts +12 -3
  148. package/src/ui/fileio/scoreArchive.ts +151 -0
  149. package/src/ui/fileio/xhrLoader.ts +26 -0
  150. package/src/ui/i18n/language.ts +1 -1
  151. package/src/ui/menus/beams.ts +181 -112
  152. package/src/ui/menus/edit.ts +44 -6
  153. package/src/ui/menus/file.ts +21 -1
  154. package/src/ui/menus/measure.ts +40 -1
  155. package/tests/autosave.ts +332 -0
  156. package/tests/beamDotted.ts +56 -0
  157. package/tests/beamGroups.ts +338 -0
  158. package/tests/createPart.ts +292 -0
  159. package/tests/deleteSpecial.ts +350 -0
  160. package/tests/dynamicsFontSize.ts +132 -0
  161. package/tests/keyDistanceTransposition.ts +351 -0
  162. package/tests/measureFill.ts +295 -0
  163. package/tests/movePart.ts +94 -0
  164. package/tests/multimeasureRest.ts +338 -0
  165. package/tests/pasteIntoMeasure.ts +103 -0
  166. package/tests/pasteSpecial.ts +541 -0
  167. package/tests/quickBeam.ts +126 -0
  168. package/tests/rebarMeasures.ts +492 -0
  169. package/tests/scoreArchive.ts +218 -0
  170. package/tests/scoreChangeState.ts +2 -0
  171. package/tests/staffLineGeometry.ts +179 -0
  172. package/tests/timeRangeSelect.ts +111 -0
  173. package/tests/timeSignatureDisplay.ts +58 -0
  174. package/tools/smoosic-schema.json +37 -0
  175. package/typedoc.ts +2 -1
  176. package/types/src/application/exports.d.ts +454 -447
  177. package/types/src/common/promiseHelpers.d.ts +30 -30
  178. package/types/src/common/vex.d.ts +224 -224
  179. package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
  180. package/types/src/render/sui/autosave.d.ts +99 -0
  181. package/types/src/render/sui/scoreView.d.ts +23 -0
  182. package/types/src/render/sui/scoreViewOperations.d.ts +776 -639
  183. package/types/src/render/sui/svgHelpers.d.ts +88 -88
  184. package/types/src/render/sui/svgPageMap.d.ts +344 -344
  185. package/types/src/render/sui/textEdit.d.ts +96 -96
  186. package/types/src/render/sui/textRender.d.ts +199 -199
  187. package/types/src/render/vex/smoAdapter.d.ts +47 -47
  188. package/types/src/render/vex/vxMeasure.d.ts +97 -97
  189. package/types/src/render/vex/vxNote.d.ts +56 -56
  190. package/types/src/render/vex/vxSystem.d.ts +71 -71
  191. package/types/src/smo/data/measure.d.ts +30 -0
  192. package/types/src/smo/data/measureModifiers.d.ts +568 -513
  193. package/types/src/smo/data/music.d.ts +74 -32
  194. package/types/src/smo/data/note.d.ts +498 -498
  195. package/types/src/smo/data/noteModifiers.d.ts +615 -606
  196. package/types/src/smo/data/score.d.ts +479 -421
  197. package/types/src/smo/data/scoreModifiers.d.ts +30 -0
  198. package/types/src/smo/data/scoreText.d.ts +334 -334
  199. package/types/src/smo/data/systemStaff.d.ts +14 -0
  200. package/types/src/smo/xform/beamers.d.ts +23 -1
  201. package/types/src/smo/xform/copypaste.d.ts +138 -2
  202. package/types/src/smo/xform/measureFill.d.ts +21 -0
  203. package/types/src/smo/xform/operations.d.ts +269 -129
  204. package/types/src/smo/xform/rebar.d.ts +53 -0
  205. package/types/src/smo/xform/selections.d.ts +168 -154
  206. package/types/src/smo/xform/undo.d.ts +142 -142
  207. package/types/src/ui/buttons/button.d.ts +100 -100
  208. package/types/src/ui/buttons/ribbon.d.ts +70 -70
  209. package/types/src/ui/common.d.ts +76 -76
  210. package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
  211. package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
  212. package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
  213. package/types/src/ui/composable/draggable.d.ts +15 -15
  214. package/types/src/ui/dialogs/adapter.d.ts +120 -120
  215. package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
  216. package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
  217. package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
  218. package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
  219. package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
  220. package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
  221. package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
  222. package/types/src/ui/dialogs/dialog.d.ts +203 -203
  223. package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
  224. package/types/src/ui/dialogs/factory.d.ts +15 -15
  225. package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
  226. package/types/src/ui/dialogs/hairpin.d.ts +35 -35
  227. package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
  228. package/types/src/ui/dialogs/instrument.d.ts +3 -3
  229. package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
  230. package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
  231. package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
  232. package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
  233. package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
  234. package/types/src/ui/dialogs/recovery.d.ts +8 -0
  235. package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
  236. package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
  237. package/types/src/ui/dialogs/slur.d.ts +57 -57
  238. package/types/src/ui/dialogs/slurVue.d.ts +7 -7
  239. package/types/src/ui/dialogs/tempo.d.ts +50 -50
  240. package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
  241. package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
  242. package/types/src/ui/dialogs/textBracket.d.ts +35 -35
  243. package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
  244. package/types/src/ui/dialogs/tie.d.ts +41 -41
  245. package/types/src/ui/dialogs/volta.d.ts +40 -40
  246. package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
  247. package/types/src/ui/fileio/fileInput.d.ts +7 -1
  248. package/types/src/ui/fileio/library.d.ts +40 -40
  249. package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
  250. package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
  251. package/types/src/ui/menus/file.d.ts +8 -8
  252. package/types/src/ui/menus/language.d.ts +7 -7
  253. package/types/src/ui/menus/manager.d.ts +58 -58
  254. package/types/src/ui/menus/menu.d.ts +159 -159
  255. package/types/src/ui/menus/partSelection.d.ts +14 -14
  256. package/types/src/ui/menus/score.d.ts +8 -8
  257. package/types/src/ui/menus/staffModifier.d.ts +17 -17
  258. package/types/typedoc.d.ts +148 -147
  259. package/src/ui/dialogs/dynamics.ts +0 -141
  260. package/types/src/ui/dialogs/dynamics.d.ts +0 -37
@@ -0,0 +1,137 @@
1
+ # Feature Specification: Compressed Score Files (.smz)
2
+
3
+ **Feature Branch**: `034-smz-compressed-scores`
4
+
5
+ **Created**: 2026-10-30
6
+
7
+ **Status**: Draft
8
+
9
+ **Input**: User description: "allow us to save scores that are compressed. Currently we save scores to disk in a dictionary that is smaller than just serializing the score. When we save to disk, we should save files in zip format. The extension should be smz for Smoosic zipped format. I don't think it matters to use the dictionary anymore, since the serialized score will probably compress to the same size. We should support the legacy json format for existing scores. We should also support the 'validation' format since that's how we compare the score to the specification. When we open a file for input, we should accept either smz or json file and handle it accordingly."
10
+
11
+ ## User Scenarios & Testing *(mandatory)*
12
+
13
+ ### User Story 1 - Save a score as a compressed .smz file (Priority: P1)
14
+
15
+ A composer finishes editing and chooses to save. The default "Smoosic" format now produces a single compressed file with the extension `.smz` (Smoosic zipped). The file is smaller than the full, un-abbreviated score text and no larger than the abbreviated text format used until now. The saved file contains the whole score, so the unsaved-changes indicator clears just as it does after any full save today.
16
+
17
+ **Why this priority**: This is the request itself. Smaller files are easier to store, email and share, and a single compressed format replaces the current trade-off between readable and compact files.
18
+
19
+ **Independent Test**: Open or create a score, choose Save, keep the default Smoosic format, and save. The file name ends in `.smz`, the file is a valid zip archive, and its size is no larger than the same score saved in the previous abbreviated format.
20
+
21
+ **Acceptance Scenarios**:
22
+
23
+ 1. **Given** a score is open, **When** the user saves in the default Smoosic format, **Then** a file with the extension `.smz` is produced and the suggested file name ends in `.smz`.
24
+ 2. **Given** a score has unsaved changes, **When** the user saves it as `.smz`, **Then** the unsaved-changes indicator clears.
25
+ 3. **Given** a score is saved as `.smz`, **When** the file is inspected with an ordinary zip tool, **Then** it opens as a zip archive holding the full score document.
26
+ 4. **Given** a typical multi-page score, **When** it is saved as `.smz`, **Then** the file is no larger than the same score saved in the previous abbreviated text format.
27
+
28
+ ---
29
+
30
+ ### User Story 2 - Open either .smz or .json files (Priority: P1)
31
+
32
+ A user opens a file from disk. They can pick a new `.smz` file or any score they saved earlier as `.json`, including scores in the previous abbreviated format and scores saved in the validation format. The application recognizes which kind it was given and loads the score without the user having to say.
33
+
34
+ **Why this priority**: Without this, saved `.smz` files cannot be reopened, and existing scores would become unreadable. It is as essential as saving.
35
+
36
+ **Independent Test**: Save the same score as `.smz`, then reopen it. The score shown is identical to the original. Then open a legacy `.json` file saved before this change; it also opens and shows the same music.
37
+
38
+ **Acceptance Scenarios**:
39
+
40
+ 1. **Given** a `.smz` file, **When** the user opens it, **Then** the score loads with all of its content (staves, measures, notes, text, layout and preferences).
41
+ 2. **Given** a legacy abbreviated `.json` file, **When** the user opens it, **Then** the score loads exactly as before this change.
42
+ 3. **Given** a `.json` file saved in the validation format, **When** the user opens it, **Then** the score loads.
43
+ 4. **Given** the file chooser, **When** the user browses for a file, **Then** `.smz` files are offered alongside `.json`, MusicXML and MIDI files.
44
+ 5. **Given** a score saved as `.smz` and reopened, **When** it is saved again as `.smz`, **Then** the content is unchanged (the round trip loses nothing).
45
+
46
+ ---
47
+
48
+ ### User Story 3 - Keep the validation format (Priority: P2)
49
+
50
+ The validation format is how a saved score is compared against the published specification. It stays available as a save option, still produces plain, complete, un-abbreviated, uncompressed score text, and files saved this way can still be opened.
51
+
52
+ **Why this priority**: Specification checks and tooling depend on it, but it is used far less often than normal saving.
53
+
54
+ **Independent Test**: Save a score using the validation option; confirm the result is plain readable score text that passes the same specification check as before this change, and that the application can open it again.
55
+
56
+ **Acceptance Scenarios**:
57
+
58
+ 1. **Given** a score is open, **When** the user saves with the validation option, **Then** the file is plain text, not zipped, and contains the complete score in full, un-abbreviated form.
59
+ 2. **Given** a validation file saved by this version, **When** it is compared against the specification as before, **Then** it validates the same way as files from the previous version.
60
+ 3. **Given** a score is saved in the validation format and as `.smz`, **When** both are opened, **Then** they show the same score.
61
+
62
+ ---
63
+
64
+ ### User Story 4 - Clear message when a file can't be read (Priority: P3)
65
+
66
+ A user opens a damaged `.smz` file, a zip that does not hold a score, or a file whose name and contents don't agree. They see that the file could not be opened and the score they were working on is left alone.
67
+
68
+ **Why this priority**: Failure handling protects the user's work, but it is only exercised when something has gone wrong.
69
+
70
+ **Independent Test**: Try to open a truncated `.smz`, an empty zip, and a text file renamed to `.smz`. Each is refused with a message, and the open score is unchanged.
71
+
72
+ **Acceptance Scenarios**:
73
+
74
+ 1. **Given** a truncated or corrupt `.smz`, **When** the user opens it, **Then** an error is shown and the current score stays open and unchanged.
75
+ 2. **Given** a valid zip that does not contain a score, **When** the user opens it, **Then** an error is shown and the current score is unchanged.
76
+ 3. **Given** a `.json` file whose contents are not a valid score, **When** the user opens it, **Then** an error is shown and the current score is unchanged.
77
+
78
+ ---
79
+
80
+ ### Edge Cases
81
+
82
+ - A file's extension and its actual contents disagree (a zip named `.json`, or plain text named `.smz`): the file is handled according to its contents, not its name.
83
+ - A zip that contains more than one file, or extra files such as folder entries: the score document is found and the rest ignored; if there is no score document, the file is refused.
84
+ - Very large scores: saving and opening complete without freezing the application for noticeably longer than the previous format.
85
+ - Scores saved with a name that already ends in `.smz`, or that contain periods: the extension is not duplicated.
86
+ - Scores loaded from a web address (a configured remote score or a library entry): `.smz` and `.json` are both accepted there too.
87
+ - Opening a legacy abbreviated `.json`, then saving: the saved result is `.smz` with the full score content; the legacy abbreviation is not carried forward.
88
+ - Unicode text in titles, lyrics and annotations survives the save and open round trip unchanged.
89
+ - Scores saved by this version in `.smz` are not expected to open in older versions of the application; this is acceptable, and the validation format remains the readable interchange form.
90
+
91
+ ## Requirements *(mandatory)*
92
+
93
+ ### Functional Requirements
94
+
95
+ - **FR-001**: The default Smoosic save format MUST produce a compressed zip archive with the extension `.smz`.
96
+ - **FR-002**: The `.smz` archive MUST contain the complete score, in full un-abbreviated form (no key-abbreviation dictionary), so that opening it restores everything a previously saved score restored.
97
+ - **FR-003**: The save dialog MUST offer `.smz` as the Smoosic format, suggest file names ending in `.smz`, and not add a second extension when the name already ends with it.
98
+ - **FR-004**: Saving as `.smz` MUST count as a full save of the score, clearing the unsaved-changes indicator as other full saves do.
99
+ - **FR-005**: The validation save option MUST remain available and MUST continue to produce plain, uncompressed, un-abbreviated score text suitable for comparison against the specification, with output equivalent to the previous version's.
100
+ - **FR-006**: The application MUST open `.smz` files, legacy abbreviated `.json` files, and validation-format `.json` files from the Open/Load file dialog, choosing how to read each automatically.
101
+ - **FR-007**: The file chooser in the Open/Load dialog MUST list `.smz` as an accepted type.
102
+ - **FR-008**: When a file's name and contents disagree about its kind (zip versus text), the application MUST handle the file according to its contents.
103
+ - **FR-009**: Opening any of these files and then saving as `.smz` MUST produce a file that opens to an identical score (no data loss in the round trip), including text with accented and non-Latin characters.
104
+ - **FR-010**: When a file cannot be read (corrupt archive, archive with no score, text that is not a score), the application MUST show an error message and MUST leave the currently open score unchanged.
105
+ - **FR-011**: Scores loaded from a web address MUST accept both `.smz` and `.json` content, determined the same way as for local files.
106
+ - **FR-012**: MusicXML, MIDI and Vex exports and imports MUST be unchanged.
107
+ - **FR-013**: Scores written by previous versions MUST continue to open with no loss, and the file layouts the specification defines MUST be unchanged for the validation format.
108
+ - **FR-014**: Automated tests MUST cover: save-then-open round trip for `.smz`; opening a legacy abbreviated `.json`; opening a validation `.json`; a corrupt `.smz`; a zip with no score; a mismatched extension; and a text round trip with non-Latin characters.
109
+
110
+ ### Key Entities
111
+
112
+ - **Score file (.smz)**: A zip archive holding one complete score document. Identified by the `.smz` extension, and by its zip contents when the extension is wrong.
113
+ - **Legacy score file (.json, abbreviated)**: Plain text score using a dictionary to shorten repeated names. Read-only going forward.
114
+ - **Validation score file (.json, full)**: Plain text, complete, un-abbreviated score used to compare against the specification. Can be saved and opened.
115
+ - **Score document**: The complete serialized description of a score (staves, measures, notes, text, layout, preferences) common to all three file kinds once decoded.
116
+
117
+ ## Success Criteria *(mandatory)*
118
+
119
+ ### Measurable Outcomes
120
+
121
+ - **SC-001**: A score saved as `.smz` is no larger than the same score saved in the previous abbreviated format, and at least 50% smaller than the same score in the validation format, for a multi-page sample score.
122
+ - **SC-002**: 100% of scores in the project's sample and test collection open after being saved as `.smz`, and show identical content (measured by comparing the full score document before and after).
123
+ - **SC-003**: 100% of existing `.json` scores in the sample collection (both abbreviated and validation) open with identical content to what the previous version produced.
124
+ - **SC-004**: Saving or opening a typical score takes no more than 1 second longer than the previous format on the same machine.
125
+ - **SC-005**: Opening a corrupt, empty-zip or non-score file never changes the open score and always shows an error message (verified in all three failure scenarios).
126
+ - **SC-006**: A user can save and reopen a score with no extra step compared with today: the number of choices in the save dialog does not increase (one Smoosic format replaces the previous one).
127
+
128
+ ## Assumptions
129
+
130
+ - The default "Smoosic" choice in the save dialog now means `.smz`. A separate plain-text option for new abbreviated `.json` files is not retained; the validation option remains the plain-text, full-fidelity choice. Existing abbreviated `.json` files remain readable.
131
+ - The archive holds a single score document; its internal file name is not part of the user-facing contract, and the application finds the score by looking at the archive's contents.
132
+ - The validation format is saved with the same content and options as today, and keeps the `.json` extension, so existing specification-checking tools keep working.
133
+ - The existing zip support already available in the application can be reused; no new third-party dependency is expected.
134
+ - Scores held in the browser's own automatic local storage are not saved to disk and are not affected.
135
+ - Files from the previous abbreviated format and the validation format are both recognized without the user choosing.
136
+ - Forward compatibility (older application versions opening `.smz`) is out of scope.
137
+ - Library and remote scores currently published as `.json` remain valid; publishing them as `.smz` is a later, optional change.
@@ -0,0 +1,148 @@
1
+ ---
2
+
3
+ description: "Task list for compressed score files (.smz)"
4
+ ---
5
+
6
+ # Tasks: Compressed Score Files (.smz)
7
+
8
+ **Input**: Design documents from `/specs/034-smz-compressed-scores/`
9
+
10
+ **Prerequisites**: plan.md, spec.md, research.md, data-model.md, contracts/archive-api.md, quickstart.md
11
+
12
+ **Tests**: Requested (FR-014). One headless file, `tests/scoreArchive.ts`, grown story by story.
13
+
14
+ **Organization**: Grouped by user story. The archive module (Foundational) serves every story. US1 is saving, US2 opening, US3 the validation format, US4 failure handling.
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/scoreArchive.ts` with the `check()`/failure-count harness and the `registerDynamicCtors` calls used in `tests/voiceCopyPaste.ts`, set `(global as any).JSZip = require('../src/common/jszip.js')` before any archive call, add a `buildScore()` helper (default score plus about 20 measures with notes, a title containing accented and non-Latin characters, and a lyric), and register `"test:score-archive": "ts-node -P tests/tsconfig.json tests/scoreArchive.ts"` in `package.json`
24
+
25
+ ---
26
+
27
+ ## Phase 2: Foundational (Blocking Prerequisites)
28
+
29
+ **Purpose**: The archive module and the serialization option fix. Every story uses these.
30
+
31
+ - [X] T002 Fix the dictionary option in `SmoScore.serialize` in `src/smo/data/score.ts` (line ~493): read `options?.useDictionary ?? true` instead of `options?.skipStaves ?? true`
32
+ - [X] T003 Create `src/ui/fileio/scoreArchive.ts` with `declare var JSZip: any;` and a `SmoScoreArchive` class with `static isZip(data)` (first four bytes `50 4B 03 04`; false for strings) per [contracts/archive-api.md](contracts/archive-api.md)
33
+ - [X] T004 Add `SmoScoreArchive.pack(score)` in `src/ui/fileio/scoreArchive.ts`: serialize with `{ skipStaves: false, useDictionary: false, preserveStaffIds: false }`, `JSON.stringify`, store as one `score.json` entry, DEFLATE level 9, return `Uint8Array` via `generateAsync({ type: 'uint8array' })`
34
+ - [X] T005 Add `SmoScoreArchive.unpack(data)` in `src/ui/fileio/scoreArchive.ts` per [data-model.md](data-model.md): zip input uses `score.json`, else the first non-directory `.json` entry; non-zip bytes are UTF-8 decoded with a leading BOM removed; strings are used as-is (BOM removed); throw `Error` with the messages "damaged archive", "no score in archive", "not a score file" as listed in the data model
35
+ - [X] T006 Add `SmoScoreArchive.load(data)` in `src/ui/fileio/scoreArchive.ts`: `unpack`, parse, require a `staves` array (else throw "not a score"), then `SmoScore.deserialize`
36
+ - [X] T007 Export the module from `src/application/exports.ts` (follow the existing `export *` and class-list pattern)
37
+ - [X] T008 Tests in `tests/scoreArchive.ts` for the foundation: `serialize({ skipStaves: true, useDictionary: false })` has no `dictionary`, and `serialize()` still does; `isZip` for a packed score, a string and plain bytes; `pack` result starts `50 4B 03 04` and the archive has exactly one entry `score.json` holding text with no `dictionary` key
38
+
39
+ **Checkpoint**: Archive module exists and is tested in isolation.
40
+
41
+ ---
42
+
43
+ ## Phase 3: User Story 1 - Save a score as .smz (Priority: P1) 🎯 MVP
44
+
45
+ **Goal**: The default Smoosic save writes a `.smz`, counts as a full save, and is smaller than before.
46
+
47
+ **Independent Test**: Save with the default format; the file ends in `.smz`, is a valid zip holding the score, and is no larger than the previous abbreviated file; the unsaved-changes indicator clears.
48
+
49
+ ### Tests for User Story 1
50
+
51
+ - [X] T009 [P] [US1] In `tests/scoreArchive.ts` add: pack then `load` returns a score whose full serialization equals the original's, including the non-Latin title and lyric text (FR-009); size check on `release/library/pennylane2 (6).json`: packed size is less than the size of `score.serialize()` text and at most half the size of the full text (SC-001), printing the three sizes
52
+ - [X] T010 [P] [US1] In `tests/scoreChangeState.ts` add: `isFullSaveFormat('.smz')`, `' .SMZ '` and `'.json'` are true; `.xml`, `.mid`, `.js` stay false
53
+
54
+ ### Implementation for User Story 1
55
+
56
+ - [X] T011 [US1] Update `isFullSaveFormat` in `src/render/sui/scoreChangeState.ts` to accept `.smz` as well as `.json` (trimmed, case-insensitive)
57
+ - [X] T012 [US1] In `src/ui/dialogs/fileDialogs.ts` (`SuiFileSaveDialog`): make `getSmoContent` async using `SmoScoreArchive.pack`, default `extension` to `'.smz'`, make `changeExtensionCb` async (set `contents.value` before returning), keep `.smojson` mapping to plain full JSON with extension `.json`, and remove the old `'.json'` branch
58
+ - [X] T013 [US1] In `src/ui/components/dialogs/save.vue`: change the format list so "Smoosic" is `.smz` (default) and "Validation (large)" stays `.smojson`; accept `contents` as `string | Uint8Array`; store the pending promise returned by `changeExtensionCb` and `await` it in `saveFileCb` before clicking the download link, so saving right after changing format never uses stale content; keep `.smz` from being appended twice to the file name
59
+ - [X] T014 [US1] Run `npm run test:score-archive` and `npm run test:score-change-state`
60
+
61
+ **Checkpoint**: Saving works end to end and the save dialog defaults to `.smz`.
62
+
63
+ ---
64
+
65
+ ## Phase 4: User Story 2 - Open .smz or .json (Priority: P1)
66
+
67
+ **Goal**: The Open dialog accepts `.smz` and both kinds of `.json`, detecting by content, and so do remote loaders.
68
+
69
+ **Independent Test**: Save a score as `.smz`, reopen it, same score. Open a legacy abbreviated `.json`; it opens as before. Rename a `.smz` to `.json`; it still opens.
70
+
71
+ ### Tests for User Story 2
72
+
73
+ - [X] T015 [P] [US2] In `tests/scoreArchive.ts` add: `load` of the legacy abbreviated `release/library/pennylane2 (6).json` text yields a score whose full serialization equals that of a `pack`/`load` round trip of the same score (FR-013, SC-003); `unpack` gives identical results for the same packed bytes passed as `ArrayBuffer` and `Uint8Array`; zip bytes with any imagined name load, and plain JSON bytes load (FR-008); text with a leading BOM loads; a second pack of a loaded `.smz` yields the same full document (FR-009)
74
+
75
+ ### Implementation for User Story 2
76
+
77
+ - [X] T016 [US2] In `src/ui/fileio/fileInput.ts`: treat `.smz` as binary (`ArrayBuffer`); add an optional constructor argument `scoresAsBytes` (default false) that also reads `.json` as `ArrayBuffer`; leave `.mxl` and `.mid` handling and the default behavior for existing callers (`SuiFileDownloadComponent`) unchanged
78
+ - [X] T017 [US2] In `src/ui/dialogs/fileDialogs.ts` (`SuiFileUploadDialog`): create the input with `scoresAsBytes` true; route filenames ending `.json` or `.smz` (lower-cased) to the score loader; make `convertJson` async using `SmoScoreArchive.load(uploadedFile)`; `await` it in `commitCb`
79
+ - [X] T018 [P] [US2] Add `.smz` to the `accept` list on both file inputs in `src/ui/components/dialogs/fileUpload.vue`
80
+ - [X] T019 [US2] Add `loadScoreAsync()` to `SuiXhrLoader` in `src/ui/fileio/xhrLoader.ts`: request as a blob, read as `ArrayBuffer`, return `SmoScoreArchive.unpack`'s text; leave `loadAsync()` unchanged
81
+ - [X] T020 [US2] Switch score loads to it: `loadRemoteJson` in `src/render/sui/scoreViewOperations.ts` (`SmoScoreArchive.load` of the loader result), the configured `remoteScore` path in `createScore` in `src/application/application.ts` (use `loadScoreAsync` unless the URL ends in `xml`/`mxl`), and `renderVexTests` in `src/application/generateVexTests.ts`; keep the library list loader in `src/ui/fileio/library.ts` on `loadAsync`
82
+ - [X] T021 [US2] Run `npm run test:score-archive`; run the other `test:*` scripts
83
+
84
+ **Checkpoint**: Round trip works from the UI and from URLs; legacy scores still open.
85
+
86
+ ---
87
+
88
+ ## Phase 5: User Story 3 - Validation format (Priority: P2)
89
+
90
+ **Goal**: The validation save still produces plain full JSON and still opens.
91
+
92
+ **Independent Test**: Save with "Validation (large)": a plain-text `.json`, no `dictionary` key, no zip signature; open it back; same score as the `.smz`.
93
+
94
+ ### Tests for User Story 3
95
+
96
+ - [X] T022 [P] [US3] In `tests/scoreArchive.ts` add: the validation text (`JSON.stringify(score.serialize({ useDictionary: false, skipStaves: false, preserveStaffIds: false }))`) is valid text with no `dictionary` key and not a zip; `load` of it equals the score loaded from its `.smz`; it is byte-for-byte the document inside the `.smz` entry (FR-005)
97
+
98
+ ### Implementation for User Story 3
99
+
100
+ - [X] T023 [US3] In `src/ui/dialogs/fileDialogs.ts`, confirm `getSmoValidationContent` still writes the full document with the same options as before and returns a string; confirm `recordSave('.json')` still clears the changed flag; keep the file name suggestion `.json` for that option (adjust only if T012/T013 broke it)
101
+
102
+ **Checkpoint**: Validation output unchanged and readable.
103
+
104
+ ---
105
+
106
+ ## Phase 6: User Story 4 - Clear errors (Priority: P3)
107
+
108
+ **Goal**: An unreadable file shows a message and the open score is untouched.
109
+
110
+ **Independent Test**: Try a truncated `.smz`, a zip with no score, and text renamed `.smz`: each shows a message, and the open score is unchanged.
111
+
112
+ ### Tests for User Story 4
113
+
114
+ - [X] T024 [P] [US4] In `tests/scoreArchive.ts` add: truncated packed bytes (cut to half) make `load` throw an error whose message mentions the archive; a zip made with only `readme.txt` throws a "no score" error; `{"hello":1}` throws "not a score"; empty input throws; none of these touch a score object the test holds (FR-010, SC-005)
115
+
116
+ ### Implementation for User Story 4
117
+
118
+ - [X] T025 [US4] In `src/ui/dialogs/fileDialogs.ts` (`SuiFileUploadDialog`): catch the error from `convertJson`, keep `pendingScore` null, remember the message, and in `afterCloseCb` show it with the `modalMessage.vue` dialog (headline "Could not open file", the message, OK button), using `replaceVueRoot(modalContainerId)` and `InstallDialog` as the print dialog does; make sure no score replacement or unsaved-changes prompt happens on failure
119
+ - [X] T026 [US4] Check the remote path: a failure in `loadRemoteJson` or `createScore` must not leave the application without a score (`createScore` already falls back through `tryParse`; make `tryParse` also accept the new loader's text and keep its default-score fallback)
120
+
121
+ **Checkpoint**: Failure paths are safe and visible.
122
+
123
+ ---
124
+
125
+ ## Phase 7: Polish & Cross-Cutting
126
+
127
+ - [X] T027 [P] Regenerate declarations with `npm run types`, keep only `types/src/ui/fileio/scoreArchive.d.ts` (plus the small `fileInput.d.ts`, `xhrLoader.d.ts` and `exports.d.ts` changes), and restore every other changed or untracked file under `types/` (the generated output is otherwise stale)
128
+ - [X] T028 [P] Add a changelog entry to `changes.md`: scores save as compressed `.smz`, `.smz` and `.json` both open, validation format unchanged, the dictionary is no longer used for new files
129
+ - [X] T029 Run `tsc --noEmit -p tsconfig.json` and every `test:*` script in `package.json`; fix regressions
130
+ - [ ] T030 Walk through the manual checks in [quickstart.md](quickstart.md) in the running application
131
+
132
+ ---
133
+
134
+ ## Dependencies & Execution Order
135
+
136
+ - Phase 1 → Phase 2 → stories. Phase 2 blocks everything.
137
+ - US1 (Phase 3) and US2 (Phase 4) both depend on Phase 2 and are independent of each other, but US2's round-trip test needs `pack` from Phase 2; they touch `fileDialogs.ts` in different functions, so serialize those edits (T012, T017, T023, T025).
138
+ - US3 depends on T012/T013 (the save dialog changes). US4 depends on T017.
139
+ - Polish last.
140
+
141
+ ## Parallel Opportunities
142
+
143
+ T009 and T010 (different test files), T018 (a Vue file) alongside T016/T017, T022 and T024 alongside implementation of earlier phases, and T027/T028.
144
+
145
+ ## Implementation Strategy
146
+
147
+ 1. Phases 1–2 (archive module), then US1 for a working `.smz` writer, then US2 so it can be read back (the pair is the usable MVP).
148
+ 2. US3 and US4 harden the edges, then Polish.
@@ -0,0 +1,35 @@
1
+ # Specification Quality Checklist: Paste Special for Note Attachments
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+ **Created**: 2026-10-31
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
+ - Interpretations to confirm (recorded in Assumptions): Paste Special replaces Paste Chords; no box is pre-ticked and the mode defaults to Replace; in Replace mode a destination marking is cleared when the copied note has none (the old Paste Chords only replaced chords when the copied note had some).
35
+ - Alignment follows the existing Paste Chords: by elapsed time (summed note lengths), not by counting notes. Confirmed by the user on 2026-10-31, replacing the earlier "count notes" wording.
@@ -0,0 +1,50 @@
1
+ # Contract: Paste Special API
2
+
3
+ Library surface (`PasteBuffer` and `SuiScoreViewOperations` are exported from `src/application/exports.ts`).
4
+
5
+ ## Types (`src/smo/xform/copypaste.ts`)
6
+
7
+ ```text
8
+ PasteAttributeKind = 'dynamics' | 'lyrics' | 'annotations' | 'chords' | 'articulations' | 'ornaments'
9
+ PasteAttributeMode = 'replace' | 'add'
10
+ PasteAttributeOptions { kinds: PasteAttributeKind[]; mode: PasteAttributeMode }
11
+ PasteAttributePair { copied: PasteNote; destination: SmoSelection }
12
+ ```
13
+
14
+ `PasteBuffer.attributeKinds` is the list of all six kinds in dialog order, so the dialog and the tests share one list.
15
+
16
+ ## `PasteBuffer`
17
+
18
+ | Member | Signature | Behavior |
19
+ |--------|-----------|----------|
20
+ | `hasNotes` | `() => boolean` | True when a normal copy is held. |
21
+ | `alignAttributeNotes` | `(selector: SmoSelector, notes: PasteNote[]) => PasteAttributePair[]` | The alignment of the spec (R1). Reads only; changes nothing. Returns `[]` when `notes` is empty or the score is not set. |
22
+ | `getAttributePasteExtent` | `(selector: SmoSelector) => { firstMeasure: number, lastMeasure: number } \| null` | Dry run over all copied staves (same staff stepping as an ordinary paste). |
23
+ | `pasteAttributes` | `(selector: SmoSelector, options: PasteAttributeOptions) => void` | Applies the ticked kinds as in the data model. Does nothing when `options.kinds` is empty. Never changes pitches, durations, note types or any unticked kind. |
24
+
25
+ Removed: `pasteChords`, `pasteChordNotes`.
26
+
27
+ ## `SuiScoreViewOperations`
28
+
29
+ | Member | Signature | Behavior |
30
+ |--------|-----------|----------|
31
+ | `hasCopiedNotes` | `() => boolean` | `storePaste.hasNotes()`; drives the menu. |
32
+ | `pasteAttributes` | `(options: PasteAttributeOptions) => Promise<void>` | Computes the extent, groups undo over those measures, pastes in the store score at the equivalent of the tracker's first selection, re-renders. Returns without doing anything when nothing is copied, nothing is selected or the extent is `null`. |
33
+
34
+ Removed: `pasteChords`.
35
+
36
+ ## UI
37
+
38
+ | Item | Behavior |
39
+ |------|----------|
40
+ | Edit menu | "Paste Special..." is shown when `hasCopiedNotes()` is true; "Paste Chords" is gone. |
41
+ | `SuiPasteSpecialDialog(parameters)` | Opens the dialog. Six toggles in the order dynamics, lyrics, annotations, chords, articulations, ornaments, all off; a "Replace existing" toggle, on. Confirm is disabled until a kind is on. Confirm calls `view.pasteAttributes`; cancel changes nothing. |
42
+
43
+ ## Invariants (asserted by tests)
44
+
45
+ 1. After `pasteAttributes`, every destination note's pitches, `tickCount`, `noteType`, ties, slurs and unticked kinds are identical to before.
46
+ 2. With the same rhythm in both, copied note *i* and destination note *i* are paired.
47
+ 3. For any inputs, the dry-run extent equals the min and max measure of the notes `pasteAttributes` actually edited.
48
+ 4. Replace on a destination note whose aligned copied notes have no items of a ticked kind leaves it with none of that kind.
49
+ 5. Add never removes an existing item except one with the same key (same dynamic slot, same verse and parser, same articulation or ornament).
50
+ 6. A pasted marking is not the same object as, and shares no state with, the copied one.
@@ -0,0 +1,47 @@
1
+ # Data Model: Paste Special
2
+
3
+ No persisted data changes. These are the in-memory shapes the paste works with.
4
+
5
+ ## Marking kind
6
+
7
+ A string union, `'dynamics' | 'lyrics' | 'annotations' | 'chords' | 'articulations' | 'ornaments'`. Where each is stored on a `SmoNote` and how it is added and cleared is in [research.md](research.md) R2.
8
+
9
+ ## Paste options
10
+
11
+ | Field | Type | Meaning |
12
+ |-------|------|---------|
13
+ | `kinds` | list of marking kinds | The kinds to paste. Must not be empty. Duplicates are ignored. |
14
+ | `mode` | `'replace'` or `'add'` | Replace: each aligned destination note first loses its existing markings of the ticked kinds. Add: it keeps them. |
15
+
16
+ ## Alignment pair
17
+
18
+ | Field | Type | Meaning |
19
+ |-------|------|---------|
20
+ | `copied` | `PasteNote` (existing) | A note from the copy, with the key it was copied from. |
21
+ | `destination` | `SmoSelection` | The destination note it is aligned to. |
22
+
23
+ Rules:
24
+ - Pairs come out in copied-note order. Each copied note has at most one pair; it has none once the destination part runs out.
25
+ - A destination note can appear in several pairs (a long destination note against short copied notes). It never appears out of order.
26
+ - Destination notes that appear in no pair are never read or changed.
27
+ - The first copied note is always paired with the note at the cursor.
28
+
29
+ ## Paste extent
30
+
31
+ `{ firstMeasure, lastMeasure }`: the lowest and highest measure index of any alignment pair over all copied staves, or `null` when there are no pairs. The view undoes and re-renders exactly these measures.
32
+
33
+ ## Elapsed time and note index
34
+
35
+ | Name in the code | What it is |
36
+ |------------------|------------|
37
+ | `copiedElapsed`, `destinationElapsed` | Running sums of `note.tickCount`: durations, from the start of the copy and of the cursor. |
38
+ | `noteIndex` (the selector's `tick`) | Which note within a voice. Never added to a duration. |
39
+
40
+ ## Per-note application
41
+
42
+ For one destination note and the ordered list of copied notes aligned to it:
43
+
44
+ 1. If `mode` is replace, clear each ticked kind on the destination note.
45
+ 2. For each copied note in order, for each ticked kind, add a clone of each of the copied note's items of that kind (chords transposed to the destination's key first).
46
+
47
+ State transitions: none. The operation is a single synchronous edit of the score; undo is the existing grouped column undo.
@@ -0,0 +1,83 @@
1
+ # Implementation Plan: Paste Special for Note Attachments
2
+
3
+ **Branch**: `035-paste-special` (work is on `main`; no feature branch was created) | **Date**: 2026-10-31 | **Spec**: [spec.md](spec.md)
4
+
5
+ **Input**: Feature specification from `/specs/035-paste-special/spec.md`
6
+
7
+ ## Summary
8
+
9
+ Generalize the Edit menu's **Paste Chords** into **Paste Special**. A small dialog offers six toggles (dynamics, lyrics, annotations, chords, articulations, ornaments) and a Replace/Add choice. The copy buffer gains one operation that applies the chosen kinds to the destination without touching pitches or durations.
10
+
11
+ The alignment of copied notes to destination notes is lifted unchanged from the existing `pasteChordNotes` (by elapsed time, see [research.md](research.md) R1) into a routine that returns the pairs. That routine is used twice: once as a dry run to find which measures a paste touches (for undo and refresh), and once to apply the markings. Replace is "clear the ticked kinds on each aligned destination note, then add"; Add is the same without the clear. Chords go through the existing key transposition; everything else is copied as is.
12
+
13
+ ## Technical Context
14
+
15
+ **Language/Version**: TypeScript; Vue 3 single-file components for the dialog. Tests run with `ts-node`.
16
+
17
+ **Primary Dependencies**: None new. Reuses `PasteBuffer`, `SmoSelection`, `SmoNote` modifier methods, `SmoLyric.transposeChordToKey`, the `dialogContainer.vue` and `toggle.vue` components, and the `InstallDialog` helper.
18
+
19
+ **Storage**: N/A. Pasted markings serialize exactly as markings created in any other way.
20
+
21
+ **Testing**: Headless `ts-node` script `tests/pasteSpecial.ts` (npm script `test:paste-special`), following `tests/voiceCopyPaste.ts` and `tests/pasteIntoMeasure.ts`. The dialog and menu are checked by compilation and the manual steps in [quickstart.md](quickstart.md).
22
+
23
+ **Target Platform**: Browser application and library.
24
+
25
+ **Project Type**: Single project.
26
+
27
+ **Performance Goals**: A 16-measure paste completes with no delay beyond an ordinary paste. Only the affected measures are re-rendered.
28
+
29
+ **Constraints**: Pitches, durations, rests, ties, slurs, beams, tuplets and unticked kinds must be byte-for-byte unchanged by a paste. Logic stays in `src/smo`, free of UI dependencies.
30
+
31
+ **Scale/Scope**: One new method group on `PasteBuffer`, one view method replacing `pasteChords`, one dialog (TypeScript plus Vue), one menu entry change, 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 | Pass. No new persisted fields. Pasted markings are ordinary modifiers; a test round-trips a score through serialization after a paste. |
40
+ | #2 Editing and transformation logic regression tested | Pass. All six kinds, both modes, mismatched rhythms, end-of-part and multi-staff cases are headless tests. |
41
+ | #3 Rendering performance | Pass. The measure range is computed before the paste so only those columns are unrendered and replaced, as for an ordinary paste. |
42
+ | #4 Logical dependencies | Pass. The paste logic is in `src/smo/xform/copypaste.ts` and imports no UI. The dialog lives in `src/ui` and calls the view. |
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/035-paste-special/
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
+ │ └── paste-special-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/smo/xform/copypaste.ts # alignment routine, attribute paste, extent; remove pasteChords/pasteChordNotes
67
+ src/smo/data/note.ts # fix removeAllAnnotations (removes every lyric and chord today)
68
+ src/render/sui/scoreViewOperations.ts # pasteAttributes() replaces pasteChords(); hasCopiedNotes()
69
+ src/ui/dialogs/pasteSpecial.ts # NEW: SuiPasteSpecialDialog
70
+ src/ui/components/dialogs/pasteSpecial.vue # NEW: six toggles + replace/add toggle
71
+ src/ui/menus/edit.ts # Paste Special replaces Paste Chords
72
+ src/application/exports.ts # export the dialog
73
+ types/src/... # regenerated declarations for the files above only
74
+ tests/pasteSpecial.ts # NEW
75
+ package.json # test:paste-special script
76
+ changes.md # changelog entry
77
+ ```
78
+
79
+ **Structure Decision**: Single-project layout as it exists. The new behavior belongs in `PasteBuffer` because it already owns the copied notes and the alignment code; a separate class would have to duplicate both.
80
+
81
+ ## Complexity Tracking
82
+
83
+ No constitution violations to justify.
@@ -0,0 +1,51 @@
1
+ # Quickstart: Validating Paste Special
2
+
3
+ ## Prerequisites
4
+
5
+ - `npm install` done at the repository root.
6
+ - For the manual checks, a built application or the development page you normally use.
7
+
8
+ ## Automated check
9
+
10
+ ```bash
11
+ npm run test:paste-special
12
+ ```
13
+
14
+ Expected: every line prints `PASS`, exit code 0. See [contracts/paste-special-api.md](contracts/paste-special-api.md) for the invariants and [data-model.md](data-model.md) for the shapes.
15
+
16
+ | # | Scenario | Expected |
17
+ |---|----------|----------|
18
+ | 1 | Each kind alone (six runs), same rhythm | Only that kind arrives on the destination; others untouched |
19
+ | 2 | All six ticked | All arrive |
20
+ | 3 | Pitches, durations, note types before and after | Identical |
21
+ | 4 | Replace over existing articulations; copied note has none | Destination left with none |
22
+ | 5 | Add over existing articulations | Destination keeps its own and gains the copied ones |
23
+ | 6 | Add: dynamic over existing dynamic; same-verse lyric over same-verse lyric | Pasted one wins, never two |
24
+ | 7 | 4 quarters (lyrics 1-4) onto 8 eighths | Lyrics land on eighths 1, 3, 5, 7; 2, 4, 6, 8 unchanged |
25
+ | 8 | 2 quarters onto whole notes in two measures | First to measure 1's note, second to measure 2's note |
26
+ | 9 | 4 copied quarters onto half, quarter, quarter | Pairing is destination notes 1, 2, 2, 3 (by position); the 2nd quarter gets copied notes 2 and 3 together; later dynamic and same-verse lyric win |
27
+ | 10 | Copy longer than the destination part | Stops at the end, no error, no notes added |
28
+ | 11 | Rests in the copy and in the destination | Aligned by length like notes |
29
+ | 12 | 2-measure copy onto 2 following measures | Aligned across the barline |
30
+ | 13 | 2-staff copy | Staves pair in order; a missing second staff ends the paste |
31
+ | 14 | Chords C, F, G, Am onto a staff transposed up a whole step; and onto a concert-pitch staff in another key | D, G, A, Bm; and unchanged. Lyrics, annotations and the rest identical on both |
32
+ | 15 | Dry-run extent vs the measures actually edited | Equal, including case 8 |
33
+ | 16 | Edit a pasted marking afterwards | The copied marking is unchanged |
34
+ | 17 | Serialize and deserialize the pasted score | Markings survive |
35
+ | 18 | `removeAllAnnotations` on a note with lyrics, chords and annotations | Only annotations removed |
36
+
37
+ ## Manual check in the application
38
+
39
+ 1. Put a dynamic, a lyric and an articulation on the notes of staff 1; give staff 2 different pitches.
40
+ 2. Select staff 1's measures and Copy. Select staff 2's first note.
41
+ 3. Open the Edit menu: **Paste Special...** is listed and **Paste Chords** is not. With nothing copied (fresh page), Paste Special is not listed.
42
+ 4. Choose Paste Special. Confirm is disabled. Turn on **Dynamics** only; confirm is enabled. Confirm. Staff 2 shows staff 1's dynamics and nothing else changed.
43
+ 5. Undo once: staff 2 is as before.
44
+ 6. Repeat with **Replace existing** off and staff 2 already holding its own dynamics: it keeps and gains.
45
+ 7. Paste lyrics from a quarter-note line onto an eighth-note line: they land on every other note.
46
+ 8. Paste chords onto a transposing instrument's part (for example a B-flat clarinet): names are spelled for it. Onto a concert-pitch part in another key they are unchanged.
47
+ 9. Cancel the dialog: nothing changes.
48
+
49
+ ## Regression
50
+
51
+ Run the other `test:*` scripts in `package.json` to confirm nothing else changed.