smoosic 2.0.2 → 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.
Files changed (352) hide show
  1. package/build/smoosic.js +546 -125
  2. package/changes.md +85 -0
  3. package/package.json +23 -2
  4. package/release/smoosic.js +549 -128
  5. package/release/styles/menus.css +26 -0
  6. package/specs/022-text-reposition-on-resize/spec.md +1 -0
  7. package/specs/027-fix-bottom-modifier-lookup/checklists/requirements.md +38 -0
  8. package/specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md +51 -0
  9. package/specs/027-fix-bottom-modifier-lookup/data-model.md +43 -0
  10. package/specs/027-fix-bottom-modifier-lookup/plan.md +77 -0
  11. package/specs/027-fix-bottom-modifier-lookup/quickstart.md +36 -0
  12. package/specs/027-fix-bottom-modifier-lookup/research.md +58 -0
  13. package/specs/027-fix-bottom-modifier-lookup/spec.md +105 -0
  14. package/specs/027-fix-bottom-modifier-lookup/tasks.md +167 -0
  15. package/specs/028-unsaved-changes-indicator/checklists/requirements.md +39 -0
  16. package/specs/028-unsaved-changes-indicator/contracts/score-change-contract.md +44 -0
  17. package/specs/028-unsaved-changes-indicator/data-model.md +64 -0
  18. package/specs/028-unsaved-changes-indicator/plan.md +96 -0
  19. package/specs/028-unsaved-changes-indicator/quickstart.md +54 -0
  20. package/specs/028-unsaved-changes-indicator/research.md +68 -0
  21. package/specs/028-unsaved-changes-indicator/spec.md +135 -0
  22. package/specs/028-unsaved-changes-indicator/tasks.md +173 -0
  23. package/specs/029-remove-promise-helpers/checklists/requirements.md +39 -0
  24. package/specs/029-remove-promise-helpers/contracts/public-api-contract.md +32 -0
  25. package/specs/029-remove-promise-helpers/data-model.md +45 -0
  26. package/specs/029-remove-promise-helpers/plan.md +86 -0
  27. package/specs/029-remove-promise-helpers/quickstart.md +53 -0
  28. package/specs/029-remove-promise-helpers/research.md +71 -0
  29. package/specs/029-remove-promise-helpers/spec.md +107 -0
  30. package/specs/029-remove-promise-helpers/tasks.md +164 -0
  31. package/specs/030-copy-paste-voices/checklists/requirements.md +39 -0
  32. package/specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md +47 -0
  33. package/specs/030-copy-paste-voices/data-model.md +63 -0
  34. package/specs/030-copy-paste-voices/plan.md +80 -0
  35. package/specs/030-copy-paste-voices/quickstart.md +50 -0
  36. package/specs/030-copy-paste-voices/research.md +80 -0
  37. package/specs/030-copy-paste-voices/spec.md +124 -0
  38. package/specs/030-copy-paste-voices/tasks.md +183 -0
  39. package/specs/031-select-voice/checklists/requirements.md +39 -0
  40. package/specs/031-select-voice/contracts/select-voice-contract.md +43 -0
  41. package/specs/031-select-voice/data-model.md +47 -0
  42. package/specs/031-select-voice/plan.md +79 -0
  43. package/specs/031-select-voice/quickstart.md +43 -0
  44. package/specs/031-select-voice/research.md +55 -0
  45. package/specs/031-select-voice/spec.md +113 -0
  46. package/specs/031-select-voice/tasks.md +171 -0
  47. package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
  48. package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
  49. package/specs/032-split-multimeasure-rests/data-model.md +70 -0
  50. package/specs/032-split-multimeasure-rests/plan.md +81 -0
  51. package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
  52. package/specs/032-split-multimeasure-rests/research.md +63 -0
  53. package/specs/032-split-multimeasure-rests/spec.md +127 -0
  54. package/specs/032-split-multimeasure-rests/tasks.md +174 -0
  55. package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
  56. package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
  57. package/specs/033-key-distance-transposition/data-model.md +49 -0
  58. package/specs/033-key-distance-transposition/plan.md +87 -0
  59. package/specs/033-key-distance-transposition/quickstart.md +40 -0
  60. package/specs/033-key-distance-transposition/research.md +82 -0
  61. package/specs/033-key-distance-transposition/spec.md +132 -0
  62. package/specs/033-key-distance-transposition/tasks.md +139 -0
  63. package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
  64. package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
  65. package/specs/034-smz-compressed-scores/data-model.md +48 -0
  66. package/specs/034-smz-compressed-scores/plan.md +89 -0
  67. package/specs/034-smz-compressed-scores/quickstart.md +44 -0
  68. package/specs/034-smz-compressed-scores/research.md +86 -0
  69. package/specs/034-smz-compressed-scores/spec.md +137 -0
  70. package/specs/034-smz-compressed-scores/tasks.md +148 -0
  71. package/specs/035-paste-special/checklists/requirements.md +35 -0
  72. package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
  73. package/specs/035-paste-special/data-model.md +47 -0
  74. package/specs/035-paste-special/plan.md +83 -0
  75. package/specs/035-paste-special/quickstart.md +51 -0
  76. package/specs/035-paste-special/research.md +97 -0
  77. package/specs/035-paste-special/spec.md +170 -0
  78. package/specs/035-paste-special/tasks.md +149 -0
  79. package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
  80. package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
  81. package/specs/036-autosave-recovery/data-model.md +70 -0
  82. package/specs/036-autosave-recovery/plan.md +87 -0
  83. package/specs/036-autosave-recovery/quickstart.md +65 -0
  84. package/specs/036-autosave-recovery/research.md +105 -0
  85. package/specs/036-autosave-recovery/spec.md +143 -0
  86. package/specs/036-autosave-recovery/tasks.md +165 -0
  87. package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
  88. package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
  89. package/specs/037-fix-new-part-dialog/data-model.md +68 -0
  90. package/specs/037-fix-new-part-dialog/plan.md +83 -0
  91. package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
  92. package/specs/037-fix-new-part-dialog/research.md +86 -0
  93. package/specs/037-fix-new-part-dialog/spec.md +144 -0
  94. package/specs/037-fix-new-part-dialog/tasks.md +174 -0
  95. package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
  96. package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
  97. package/specs/038-per-measure-beam-groups/data-model.md +75 -0
  98. package/specs/038-per-measure-beam-groups/plan.md +84 -0
  99. package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
  100. package/specs/038-per-measure-beam-groups/research.md +72 -0
  101. package/specs/038-per-measure-beam-groups/spec.md +146 -0
  102. package/specs/038-per-measure-beam-groups/tasks.md +132 -0
  103. package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
  104. package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
  105. package/specs/039-measure-fill-submenu/data-model.md +79 -0
  106. package/specs/039-measure-fill-submenu/plan.md +81 -0
  107. package/specs/039-measure-fill-submenu/quickstart.md +62 -0
  108. package/specs/039-measure-fill-submenu/research.md +68 -0
  109. package/specs/039-measure-fill-submenu/spec.md +153 -0
  110. package/specs/039-measure-fill-submenu/tasks.md +121 -0
  111. package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
  112. package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
  113. package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
  114. package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
  115. package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
  116. package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
  117. package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
  118. package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
  119. package/specs/041-delete-special/checklists/requirements.md +35 -0
  120. package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
  121. package/specs/041-delete-special/data-model.md +40 -0
  122. package/specs/041-delete-special/plan.md +93 -0
  123. package/specs/041-delete-special/quickstart.md +41 -0
  124. package/specs/041-delete-special/research.md +75 -0
  125. package/specs/041-delete-special/spec.md +136 -0
  126. package/specs/041-delete-special/tasks.md +106 -0
  127. package/src/application/application.ts +475 -459
  128. package/src/application/exports.ts +401 -395
  129. package/src/application/generateVexTests.ts +2 -2
  130. package/src/common/promiseHelpers.ts +2 -2
  131. package/src/render/audio/samples.ts +117 -118
  132. package/src/render/sui/NoteEntryCaret.ts +117 -16
  133. package/src/render/sui/autosave.ts +265 -0
  134. package/src/render/sui/formatter.ts +12 -2
  135. package/src/render/sui/pageDivisions.ts +58 -0
  136. package/src/render/sui/renderState.ts +469 -464
  137. package/src/render/sui/scoreChangeState.ts +67 -0
  138. package/src/render/sui/scoreView.ts +77 -2
  139. package/src/render/sui/scoreViewOperations.ts +363 -37
  140. package/src/render/sui/staffLineGeometry.ts +82 -0
  141. package/src/render/sui/svgPageMap.ts +16 -17
  142. package/src/render/sui/textEdit.ts +310 -311
  143. package/src/render/sui/tracker.ts +40 -0
  144. package/src/render/vex/vxMeasure.ts +22 -8
  145. package/src/render/vex/vxNote.ts +5 -5
  146. package/src/smo/data/measure.ts +58 -1
  147. package/src/smo/data/measureModifiers.ts +81 -1
  148. package/src/smo/data/music.ts +169 -359
  149. package/src/smo/data/note.ts +1 -1
  150. package/src/smo/data/noteModifiers.ts +12 -0
  151. package/src/smo/data/score.ts +167 -2
  152. package/src/smo/data/scoreModifiers.ts +46 -1
  153. package/src/smo/data/systemStaff.ts +43 -0
  154. package/src/smo/xform/beamers.ts +80 -6
  155. package/src/smo/xform/copypaste.ts +511 -51
  156. package/src/smo/xform/measureFill.ts +89 -0
  157. package/src/smo/xform/operations.ts +403 -61
  158. package/src/smo/xform/selections.ts +75 -0
  159. package/src/smo/xform/undo.ts +9 -0
  160. package/src/styles/menus.css +26 -0
  161. package/src/ui/buttons/ribbon.ts +3 -1
  162. package/src/ui/components/buttons/sidebar.vue +15 -6
  163. package/src/ui/components/dialogs/beamGroups.vue +106 -0
  164. package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
  165. package/src/ui/components/dialogs/dynamics.vue +16 -3
  166. package/src/ui/components/dialogs/fileUpload.vue +2 -2
  167. package/src/ui/components/dialogs/hairpin.vue +3 -3
  168. package/src/ui/components/dialogs/library.vue +3 -1
  169. package/src/ui/components/dialogs/newPart.vue +148 -184
  170. package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
  171. package/src/ui/components/dialogs/recovery.vue +66 -0
  172. package/src/ui/components/dialogs/save.vue +11 -4
  173. package/src/ui/components/dialogs/scorePreferences.vue +23 -1
  174. package/src/ui/components/dialogs/slur.vue +6 -6
  175. package/src/ui/components/dialogs/tempo.vue +11 -3
  176. package/src/ui/components/dialogs/timeSignature.vue +5 -0
  177. package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
  178. package/src/ui/components/dialogs/volta.vue +3 -3
  179. package/src/ui/dialogs/adapter.ts +181 -183
  180. package/src/ui/dialogs/addMeasure.ts +97 -97
  181. package/src/ui/dialogs/annotationVue.ts +56 -56
  182. package/src/ui/dialogs/audioSettings.ts +121 -123
  183. package/src/ui/dialogs/beamGroupsVue.ts +69 -0
  184. package/src/ui/dialogs/chordChangeVue.ts +46 -46
  185. package/src/ui/dialogs/clefChange.ts +53 -53
  186. package/src/ui/dialogs/createPartHelpers.ts +68 -0
  187. package/src/ui/dialogs/customTuplets.ts +95 -96
  188. package/src/ui/dialogs/customTupletsVue.ts +47 -47
  189. package/src/ui/dialogs/deleteSpecial.ts +57 -0
  190. package/src/ui/dialogs/dialog.ts +627 -620
  191. package/src/ui/dialogs/durations.ts +34 -34
  192. package/src/ui/dialogs/dynamicsVue.ts +87 -60
  193. package/src/ui/dialogs/factory.ts +196 -198
  194. package/src/ui/dialogs/fileDialogs.ts +286 -179
  195. package/src/ui/dialogs/fonts.ts +93 -93
  196. package/src/ui/dialogs/globalLayout.ts +40 -40
  197. package/src/ui/dialogs/gracenote.ts +31 -31
  198. package/src/ui/dialogs/hairpin.ts +108 -110
  199. package/src/ui/dialogs/hairpinVue.ts +51 -51
  200. package/src/ui/dialogs/instrument.ts +119 -112
  201. package/src/ui/dialogs/keySignature.ts +175 -176
  202. package/src/ui/dialogs/keySignatureVue.ts +47 -47
  203. package/src/ui/dialogs/library.ts +207 -207
  204. package/src/ui/dialogs/libraryVue.ts +62 -48
  205. package/src/ui/dialogs/lyricVue.ts +46 -46
  206. package/src/ui/dialogs/measureFormat.ts +78 -78
  207. package/src/ui/dialogs/microtones.ts +147 -147
  208. package/src/ui/dialogs/noteHead.ts +319 -319
  209. package/src/ui/dialogs/pageLayout.ts +61 -61
  210. package/src/ui/dialogs/partInfo.ts +60 -60
  211. package/src/ui/dialogs/pasteSpecial.ts +59 -0
  212. package/src/ui/dialogs/pedalMarking.ts +117 -117
  213. package/src/ui/dialogs/pedalMarkingVue.ts +73 -73
  214. package/src/ui/dialogs/pitch.ts +352 -352
  215. package/src/ui/dialogs/preferences.ts +1 -0
  216. package/src/ui/dialogs/recovery.ts +49 -0
  217. package/src/ui/dialogs/rehearsalMark.ts +64 -64
  218. package/src/ui/dialogs/rehearsalMarkVue.ts +57 -57
  219. package/src/ui/dialogs/scoreId.ts +35 -36
  220. package/src/ui/dialogs/scoreView.ts +42 -42
  221. package/src/ui/dialogs/slur.ts +308 -310
  222. package/src/ui/dialogs/slurVue.ts +91 -91
  223. package/src/ui/dialogs/staffGroup.ts +112 -112
  224. package/src/ui/dialogs/tabNote.ts +84 -84
  225. package/src/ui/dialogs/tabStave.ts +182 -182
  226. package/src/ui/dialogs/tempo.ts +261 -263
  227. package/src/ui/dialogs/tempoVue.ts +73 -73
  228. package/src/ui/dialogs/textBlockVue.ts +127 -127
  229. package/src/ui/dialogs/textBracket.ts +114 -116
  230. package/src/ui/dialogs/textBracketVue.ts +56 -56
  231. package/src/ui/dialogs/tie.ts +140 -142
  232. package/src/ui/dialogs/timeSignature.ts +65 -66
  233. package/src/ui/dialogs/transposeScore.ts +39 -39
  234. package/src/ui/dialogs/unsavedChanges.ts +43 -0
  235. package/src/ui/dialogs/volta.ts +120 -122
  236. package/src/ui/dialogs/voltaVue.ts +51 -51
  237. package/src/ui/fileio/fileInput.ts +12 -3
  238. package/src/ui/fileio/library.ts +110 -111
  239. package/src/ui/fileio/scoreArchive.ts +151 -0
  240. package/src/ui/fileio/xhrLoader.ts +26 -0
  241. package/src/ui/i18n/language.ts +1 -1
  242. package/src/ui/menus/beams.ts +181 -112
  243. package/src/ui/menus/edit.ts +143 -6
  244. package/src/ui/menus/file.ts +40 -4
  245. package/src/ui/menus/measure.ts +40 -1
  246. package/tests/autosave.ts +332 -0
  247. package/tests/beamDotted.ts +56 -0
  248. package/tests/beamGroups.ts +338 -0
  249. package/tests/createPart.ts +292 -0
  250. package/tests/deleteSpecial.ts +350 -0
  251. package/tests/dynamicsFontSize.ts +132 -0
  252. package/tests/keyDistanceTransposition.ts +351 -0
  253. package/tests/measureFill.ts +295 -0
  254. package/tests/movePart.ts +94 -0
  255. package/tests/multimeasureRest.ts +338 -0
  256. package/tests/pageDivisions.ts +156 -0
  257. package/tests/pasteIntoMeasure.ts +103 -0
  258. package/tests/pasteSpecial.ts +541 -0
  259. package/tests/promiseHelpersUsage.ts +142 -0
  260. package/tests/quickBeam.ts +126 -0
  261. package/tests/scoreArchive.ts +218 -0
  262. package/tests/scoreChangeState.ts +104 -0
  263. package/tests/selectVoice.ts +189 -0
  264. package/tests/staffLineGeometry.ts +179 -0
  265. package/tests/timeSignatureDisplay.ts +58 -0
  266. package/tests/voiceCopyPaste.ts +417 -0
  267. package/tools/smoosic-schema.json +37 -0
  268. package/typedoc.ts +1 -1
  269. package/types/src/application/exports.d.ts +453 -447
  270. package/types/src/common/promiseHelpers.d.ts +30 -30
  271. package/types/src/common/vex.d.ts +224 -224
  272. package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
  273. package/types/src/render/sui/autosave.d.ts +99 -0
  274. package/types/src/render/sui/scoreView.d.ts +23 -0
  275. package/types/src/render/sui/scoreViewOperations.d.ts +759 -639
  276. package/types/src/render/sui/svgHelpers.d.ts +88 -88
  277. package/types/src/render/sui/svgPageMap.d.ts +344 -344
  278. package/types/src/render/sui/textEdit.d.ts +96 -96
  279. package/types/src/render/sui/textRender.d.ts +199 -199
  280. package/types/src/render/vex/smoAdapter.d.ts +47 -47
  281. package/types/src/render/vex/vxMeasure.d.ts +97 -97
  282. package/types/src/render/vex/vxNote.d.ts +56 -56
  283. package/types/src/render/vex/vxSystem.d.ts +71 -71
  284. package/types/src/smo/data/measure.d.ts +30 -0
  285. package/types/src/smo/data/measureModifiers.d.ts +568 -513
  286. package/types/src/smo/data/music.d.ts +74 -32
  287. package/types/src/smo/data/note.d.ts +498 -498
  288. package/types/src/smo/data/noteModifiers.d.ts +615 -606
  289. package/types/src/smo/data/score.d.ts +476 -421
  290. package/types/src/smo/data/scoreModifiers.d.ts +30 -0
  291. package/types/src/smo/data/scoreText.d.ts +334 -334
  292. package/types/src/smo/data/systemStaff.d.ts +14 -0
  293. package/types/src/smo/xform/beamers.d.ts +23 -1
  294. package/types/src/smo/xform/copypaste.d.ts +138 -2
  295. package/types/src/smo/xform/measureFill.d.ts +21 -0
  296. package/types/src/smo/xform/operations.d.ts +245 -129
  297. package/types/src/smo/xform/selections.d.ts +154 -154
  298. package/types/src/smo/xform/undo.d.ts +142 -142
  299. package/types/src/ui/buttons/button.d.ts +100 -100
  300. package/types/src/ui/buttons/ribbon.d.ts +70 -70
  301. package/types/src/ui/common.d.ts +76 -76
  302. package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
  303. package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
  304. package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
  305. package/types/src/ui/composable/draggable.d.ts +15 -15
  306. package/types/src/ui/dialogs/adapter.d.ts +120 -120
  307. package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
  308. package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
  309. package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
  310. package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
  311. package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
  312. package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
  313. package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
  314. package/types/src/ui/dialogs/dialog.d.ts +203 -203
  315. package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
  316. package/types/src/ui/dialogs/factory.d.ts +15 -15
  317. package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
  318. package/types/src/ui/dialogs/hairpin.d.ts +35 -35
  319. package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
  320. package/types/src/ui/dialogs/instrument.d.ts +3 -3
  321. package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
  322. package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
  323. package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
  324. package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
  325. package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
  326. package/types/src/ui/dialogs/recovery.d.ts +8 -0
  327. package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
  328. package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
  329. package/types/src/ui/dialogs/slur.d.ts +57 -57
  330. package/types/src/ui/dialogs/slurVue.d.ts +7 -7
  331. package/types/src/ui/dialogs/tempo.d.ts +50 -50
  332. package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
  333. package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
  334. package/types/src/ui/dialogs/textBracket.d.ts +35 -35
  335. package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
  336. package/types/src/ui/dialogs/tie.d.ts +41 -41
  337. package/types/src/ui/dialogs/volta.d.ts +40 -40
  338. package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
  339. package/types/src/ui/fileio/fileInput.d.ts +7 -1
  340. package/types/src/ui/fileio/library.d.ts +40 -40
  341. package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
  342. package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
  343. package/types/src/ui/menus/file.d.ts +8 -8
  344. package/types/src/ui/menus/language.d.ts +7 -7
  345. package/types/src/ui/menus/manager.d.ts +58 -58
  346. package/types/src/ui/menus/menu.d.ts +159 -159
  347. package/types/src/ui/menus/partSelection.d.ts +14 -14
  348. package/types/src/ui/menus/score.d.ts +8 -8
  349. package/types/src/ui/menus/staffModifier.d.ts +17 -17
  350. package/types/typedoc.d.ts +147 -147
  351. package/src/ui/dialogs/dynamics.ts +0 -143
  352. package/types/src/ui/dialogs/dynamics.d.ts +0 -37
@@ -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`.
@@ -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.