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,82 @@
1
+ # Research: Key-Distance Enharmonic Spelling
2
+
3
+ All Technical Context items were resolvable from the code; no NEEDS CLARIFICATION remained.
4
+
5
+ ## R1. Representing spellings and keys as one integer each
6
+
7
+ **Decision**: Use the "line of fifths". A spelling's position is `base(letter) + 7 * accidentalCount`, where `base` is F=-1, C=0, G=1, D=2, A=3, E=4, B=5, and `accidentalCount` is +1 per sharp, -1 per flat (double accidentals ±2). A major key's index `k` is its sharps (positive) or flats (negative): C=0, G=1, F=-1, Bb=-2.
8
+
9
+ **Rationale**: Adjacent positions are a fifth apart, so "number of fifths/fourths" from the user's definition is plain subtraction. The seven tones of key `k` are positions `k-1 .. k+5` (check: C gives F..B; G gives C..F#; Eb gives Ab..D). Everything in the spec reduces to comparisons against that window.
10
+
11
+ **Alternatives considered**: Keep a table but generate it (still bulky, still needs lookups); keep `circleOfFifths` array search (`circleOfFifthsIndex` already exists but only covers 12 entries and handles enharmonics by search, which is what we are trying to avoid).
12
+
13
+ ## R2. Distance
14
+
15
+ **Decision**: Signed distance of position `f` from key `k` is `0` if `k-1 <= f <= k+5`, `f - (k+5)` (positive, sharps) if above, `f - (k-1)` (negative, flats) if below. Magnitude is the rank used to choose spellings.
16
+
17
+ **Rationale**: This is the user's definition: the number of sharps/flats added to the signature until a key contains the note. Verified against the stated examples: A# (f=10) in C: 10-5 = 5 sharps; Bb (f=-2) in C: -2-(-1) = -1, one flat. Note that `f` can lie outside the 15 real keys; the distance is computed against a theoretical key, which is fine because only the magnitude matters.
18
+
19
+ **Alternatives considered**: Counting accidentals in the spelling itself (Bb has 1, A# has 1, so no preference); rejected since it ignores the key.
20
+
21
+ ## R3. Default spelling of a pitch class (replaces the bias block in `getEnharmonicInKey`)
22
+
23
+ **Decision**: For a sounding pitch class, enumerate its spellings that use at most a double accidental (positions `f0 + 12m`, in the range -15..19). Choose the one with the smallest absolute distance from the key. On equal absolute distance, choose the lower position (the flat side).
24
+
25
+ **Rationale**: Directly implements FR-003/FR-004. In-key pitches have distance 0 and always win, so a key's own spelling is used (FR-006-style behavior for defaults, US3 scenario 3).
26
+
27
+ **Behavior change to be aware of**: the old code hard-coded a flat bias (`a#`->`bb`, `g#`->`ab`, `c#`->`db`, `d#`->`eb`) for non-sharp keys. The new rule gives, in C major: Bb, Eb, Ab (tie, flat wins), but **C# and F#** (C# is 2 sharps from C vs 4 flats for Db; F# is 1 sharp vs 5 flats). In C major, C# was previously defaulted to Db. This follows from the requested rule and agrees with the requested example (C# in C stays C# when transposed to D as D#).
28
+
29
+ **Alternatives considered**: Keep the old bias block as an override; rejected because it contradicts the stated rule.
30
+
31
+ ## R4. Transposing between keys while preserving distance
32
+
33
+ **Decision**: Compute `s = kd - ks` and set the new position to `f + s`. The sounding pitch is checked: `7 * s` must be congruent to the half-step offset modulo 12. If the caller's destination key and offset disagree, pick the `s` congruent to `7 * offset` (mod 12) that is closest to `kd - ks`, so the sounding pitch is always right. Then fix the octave by solving against `smoPitchToInt`.
34
+
35
+ **Rationale**: Shifting every position by the same amount keeps each note's offset from the key window unchanged, so scale degree, direction and distance are all preserved, and the operation is exactly invertible. Verified by hand against the spec examples:
36
+
37
+ | Case | ks → kd | s | Source f | Result f | Spelling |
38
+ |------|---------|---|----------|----------|----------|
39
+ | C# in C → D | 0 → 2 | 2 | 7 | 9 | D# |
40
+ | A# in C → D | 0 → 2 | 2 | 10 | 12 | B# |
41
+ | E natural in Eb → G | -3 → 1 | 4 | 4 | 8 | G# |
42
+
43
+ **Edge handling**: If `f + s` needs more than a double accidental (positions outside -15..19), respell by ±12 toward the nearest in-range position (the default-spelling rule in R3 picks it). Round trips are therefore exact except for these extremes; the spec's success criterion for round trips is qualified accordingly.
44
+
45
+ **Alternatives considered**: Map to a "role" per scale degree (what the table did; the source of the bulk). Compute from the transposition interval's letter distance (needs interval spelling, not available from half-step offsets alone).
46
+
47
+ ## R5. Destination key for whole-score transposition
48
+
49
+ **Decision**: `kd` is the unique residue of `ks + 7 * offset (mod 12)` in -7..+7, preferring fewer accidentals. The one tie (6 vs -6) goes to flats (Gb), matching R3's tie rule. A zero offset keeps the existing key unchanged, so scores written in C# or Cb are not rewritten. Minor-key signatures are not special-cased; the app's key list is major keys only (the old table has only major keys).
50
+
51
+ **Rationale**: Only a residue modulo 12 is determined by the sounding pitch; choosing the representative with the fewest accidentals is what spec edge case "extreme destination key" requires. The existing `vexKeySigWithOffset` does the same job by pitch lookup with a patch table (`a#`->`bb` etc.); the new helper replaces that table-driven patching for this feature's callers but leaves the function in place for other callers.
52
+
53
+ **Alternatives considered**: Reuse `vexKeySigWithOffset`; it can produce `c#` or `cb` and relies on hard-coded patches, which would make the round-trip property harder to guarantee.
54
+
55
+ ## R6. Current whole-score behavior
56
+
57
+ **Finding**: `SmoOperation.transposeScore` calls `transpose` for each note using the *measure's existing* key signature and never changes any key signature. The dialog ([transposeScore.ts](../../src/ui/dialogs/transposeScore.ts)) calls it in steps of the entered semitone count, and cancel undoes by transposing the negated total.
58
+
59
+ **Decision**: `transposeScore` computes `kd` per measure from that measure's current key and the offset, updates `measure.keySignature` to `kd`, and transposes pitches with `s = kd - ks`. Because the dialog applies each increment separately and cancel applies the negated total, both stay consistent: the inverse offset yields `s' = -s` and returns the original key and spelling. This matches spec US2 scenario 2 (destination key of each measure follows the interval). `storeScore` is transposed with the same function, so it stays in sync.
60
+
61
+ **Risk**: Users who relied on transposing notes while keeping the key signature will see the signature change. This is the behavior described in the request ("calculate the destination key"). Note in the changelog.
62
+
63
+ ## R7. Callers that also use the table
64
+
65
+ | Caller | Use | Replacement |
66
+ |--------|-----|-------------|
67
+ | `getScaleTonesForKey` (also used by `tickMap.ts`, `getKeySignatureKey`, `isPitchInKeySignature`, `getKeyFriendlyEnharmonic`) | Per-letter accidental in the key | Computed from `k`: for letter base `b`, accidental count is `floor((k + 5 - b) / 7)`; return the same `letter + accidental` strings (`'f#'`, `'bb'`, `'cn'`) as before |
68
+ | `getEnharmonicInKey` (also `operations.ts` x2, `midiToSmo.ts`, `getIntervalInKey`) | Default spelling | R3 |
69
+ | `transposePitchForKey` (`note.ts`, chord symbols in `noteModifiers.ts`) | Cross-key spelling | R4 |
70
+ | `findRoleOfPitch`, `findPitchForRole`, `KeySignatureRole` | Table roles | Deleted. Grep shows no callers outside `music.ts` |
71
+
72
+ ## R8. Pre-existing defect found
73
+
74
+ `keySignatureLength` contains the key `'Gg'` (should be `'Gb'`), so `getFlatsInKeySignature('gb')` returns `undefined`. Fixed as part of the new key-index helper since the helper depends on correct sharp/flat counts.
75
+
76
+ ## R9. Existing tests
77
+
78
+ `package.json` has `"test": "exit 0"` and per-feature scripts. Adopt the same pattern (`ts-node -P tests/tsconfig.json`, `check()` helper, exit non-zero on failure).
79
+
80
+ ## R10. Octave rule for B#, B##, Cb, Cbb
81
+
82
+ `smoPitchToInt` only special-cases `cb` (octave minus one). `b#3` evaluates to `3*12+0 = 36` although it sounds as C4 (48), and `b##`/`cbb` have the same problem. The new code therefore computes the sounding value with a letter-based rule that needs no special cases: `octave * 12 + naturalValue(letter) + accidentalCount`, where `naturalValue` is C=0, D=2, E=4, F=5, G=7, A=9, B=11 (so `cb4` = 47, `b#3` = 48). Respelling solves for the octave that makes this value equal the target. `smoPitchToInt` is left unchanged because other code depends on it.
@@ -0,0 +1,132 @@
1
+ # Feature Specification: Key-Distance Enharmonic Spelling for Transposition
2
+
3
+ **Feature Branch**: `033-key-distance-transposition`
4
+
5
+ **Created**: 2026-10-27
6
+
7
+ **Status**: Draft
8
+
9
+ **Input**: User description: "We need a better way to transpose. There is a table object in music.ts called enharmonicRoles. It is supposed to determine enharmonic equivalents when transposing. For instance, when transposing c# in the key of C major to D major, it should be a D# and not an Eb. It is also used to choose the correct default for a non-key enharmonic. But, it (the enharmonic table) doesn't really work and it is too bulky and error-prone. I think there is a better way using just the key signature and the number of sharps/flats per key signature. A non-key note like c# in C Major will have a 'distance', which is how many sharps/flats you would have to add to get a key with the note. For instance, in the key of c, 1/2 down from a B is either Bb or A#. Bb is 2 flats away from C, A# is 5 sharps. So Bb is a more logical default. Likewise when pasting from one key to another, we would want to preserve the distance. So pasting A# from the key of C into D would give a B# since you have to add the same number of accidentals. If the sharps/flats is a tie with both the same distance, we will go with the flat direction. When transposing the whole score in the scoreTranspose component, we should calculate the destination key, and try to preserve the distance for the enharmonics. So for instance going from Eb up 4 steps to G, E natural would go to G#. So we want to replace the enharmonicRoles table in music.ts with this logic."
10
+
11
+ ## User Scenarios & Testing *(mandatory)*
12
+
13
+ ### User Story 1 - Pasting notes into a different key keeps their spelling relationship (Priority: P1)
14
+
15
+ A composer copies a passage from a measure in one key and pastes it into a measure in another key (for example, a transposing instrument's part, or a modulation). Notes that belong to the source key stay diatonic in the destination key. Notes that were chromatic in the source (accidentals outside the key) must stay chromatic in the destination, with the same kind of alteration: a note that was one sharp above a key tone stays one sharp above the corresponding key tone, rather than being respelled as a flat of the next tone up.
16
+
17
+ **Why this priority**: Pasting between keys is the everyday path where wrong spellings appear (a D# turning into an Eb, a B# turning into a C). Fixing it delivers the core value of the feature, and is independently useful even if whole-score transposition is not changed.
18
+
19
+ **Independent Test**: Put a C# in a measure in C major, copy it, and paste it into a measure in D major transposed up a whole step. It must appear as D#, not Eb. Put an A# in C major and paste into D major: it must appear as B#.
20
+
21
+ **Acceptance Scenarios**:
22
+
23
+ 1. **Given** a C# in C major, **When** it is pasted/transposed into D major (up a major second), **Then** the pitch is spelled D#, not Eb.
24
+ 2. **Given** an A# in C major, **When** it is pasted into D major (up a major second), **Then** the pitch is spelled B# (same number of accidentals added to the key as in the source).
25
+ 3. **Given** notes that are all in the source key's signature, **When** they are pasted into another key, **Then** every note is spelled as the corresponding note of the destination key signature.
26
+ 4. **Given** pasting into a measure in the same key with no transposition, **When** the paste completes, **Then** each pitch keeps its original spelling.
27
+
28
+ ---
29
+
30
+ ### User Story 2 - Whole-score transposition preserves chromatic spelling (Priority: P1)
31
+
32
+ A user opens the score transpose dialog and transposes the entire score (or selected staves) by an interval. The destination key signature is computed from the interval. Chromatic notes in the score keep their relationship to the key: a natural sign against a flat key signature stays an "up a step from the key tone" alteration in the destination, and so on.
33
+
34
+ **Why this priority**: Whole-score transposition is how users prepare parts for transposing instruments. Wrong enharmonic spellings force the user to hand-correct many notes, which is the main pain behind this request.
35
+
36
+ **Independent Test**: Create a passage in Eb major containing an E natural, then transpose the score up a major third (4 half steps) to G major. The E natural must become G#. Diatonic notes become the matching G major scale notes.
37
+
38
+ **Acceptance Scenarios**:
39
+
40
+ 1. **Given** a passage in Eb major with an E natural, **When** the score is transposed up 4 half steps (destination key G major), **Then** the E natural becomes G#, not Ab.
41
+ 2. **Given** a score transposed by any interval, **When** the transposition completes, **Then** the destination key signature of each measure is the key signature that results from the interval, and diatonic notes are spelled by that signature.
42
+ 3. **Given** a chromatic note in the source key, **When** the score is transposed, **Then** the distance of the note from the destination key (how many accidentals must be added to the key to include it) equals its distance from the source key.
43
+
44
+ ---
45
+
46
+ ### User Story 3 - Sensible default spelling for notes outside the key (Priority: P2)
47
+
48
+ When a note not in the current key signature is created or converted to a different enharmonic spelling (for example by toggling between sharp and flat, entering a MIDI note, or other operations that must choose between equivalent spellings), the spelling that is closest to the key is chosen. "Closest" means the spelling that requires adding the fewest sharps or flats to the key signature for the note to belong to it. If two spellings are equally close, the flat spelling is chosen.
49
+
50
+ **Why this priority**: This is the second use of the existing table. It affects the default spelling of every non-key note, but each wrong default is a one-click correction, so it is less severe than the transposition errors above.
51
+
52
+ **Independent Test**: In C major, enter the pitch one half step below B. It must default to Bb rather than A#. In a key where a sharp spelling and a flat spelling are equally far from the key, the flat spelling must be chosen.
53
+
54
+ **Acceptance Scenarios**:
55
+
56
+ 1. **Given** the key of C major, **When** the pitch a half step below B is spelled by default, **Then** the result is Bb (closer to the key than A#).
57
+ 2. **Given** a pitch whose sharp spelling and flat spelling are equally far from the key, **When** the default spelling is chosen, **Then** the flat spelling is used.
58
+ 3. **Given** a pitch that is already in the key signature, **When** the default spelling is chosen, **Then** the key's own spelling is used.
59
+
60
+ ---
61
+
62
+ ### User Story 4 - Existing behavior outside spelling is unchanged (Priority: P3)
63
+
64
+ Maintainers and users should see no change in how notes are laid out, played, or saved. Only the enharmonic spelling chosen during transposition, paste, and default spelling changes. The large per-key spelling table is removed from the product in favor of a rule derived from the key signature.
65
+
66
+ **Why this priority**: This is a refactor guard. It matters for confidence and maintainability but does not add a user-visible capability by itself.
67
+
68
+ **Independent Test**: Run the existing test suite and open an existing saved score. Everything that does not involve choosing between enharmonic spellings behaves as before.
69
+
70
+ **Acceptance Scenarios**:
71
+
72
+ 1. **Given** the existing test suite, **When** it is run after the change, **Then** tests unrelated to enharmonic spelling continue to pass.
73
+ 2. **Given** a saved score, **When** it is opened without being transposed, **Then** it renders and plays identically to before.
74
+
75
+ ---
76
+
77
+ ### Edge Cases
78
+
79
+ - A note whose preserved-distance spelling needs a double sharp or double flat (for example, a sharp above a key tone that is already sharped in the destination key): the double accidental is used, since it preserves the relationship.
80
+ - The source and destination keys are the same, or the transposition offset is zero: pitches keep their original spelling.
81
+ - Octave boundaries: a spelling change that crosses between B and C (for example B# or Cb) must land in the correct octave so the sounding pitch is unchanged.
82
+ - Transposing by an interval that gives an extreme destination key (more than 7 sharps or flats): the destination key is mapped to its enharmonic equivalent key with fewer accidentals, and note spelling follows the mapped key.
83
+ - Minor keys: a minor key and its relative major share a key signature; spelling is determined from the key signature, so both behave the same way.
84
+ - Percussion, unpitched, and rest notes are not affected.
85
+ - Grace notes, chord tones, and pitches stored on modifiers (such as pitch-bearing annotations) follow the same rules as regular notes.
86
+ - Two pitches in a chord that map to the same sounding pitch after transposition remain distinct chord tones as they do today.
87
+
88
+ ## Requirements *(mandatory)*
89
+
90
+ ### Functional Requirements
91
+
92
+ - **FR-001**: The system MUST decide the spelling of a transposed or pasted pitch using only the source key signature, the destination key signature, and the number of sharps or flats in each key signature. It MUST NOT rely on a per-key table of spellings.
93
+ - **FR-002**: The system MUST define the "distance" of a pitch from a key as the number of sharps or flats that would have to be added to the key signature for the pitch to belong to it, and MUST use distance to rank alternative spellings of the same sounding pitch.
94
+ - **FR-003**: When choosing a default spelling for a pitch that is not in the key, the system MUST choose the spelling with the smallest distance from the key. Example: in C major, the pitch a half step below B defaults to Bb rather than A#.
95
+ - **FR-004**: When two alternative spellings are equally distant from the key, the system MUST choose the flat spelling.
96
+ - **FR-005**: When a pitch is transposed or pasted from one key to another, the system MUST spell the result so that its distance from the destination key equals its distance from the source key, in the same direction (sharp or flat).
97
+ - **FR-006**: A pitch that belongs to the source key signature MUST be spelled as the corresponding pitch of the destination key signature.
98
+ - **FR-007**: Transposing C# in C major to D major MUST produce D#; pasting A# from C major into D major MUST produce B#.
99
+ - **FR-008**: The score transpose action MUST compute the destination key signature from the source key signature and the transposition interval, and MUST apply the distance-preserving rule to every pitch it transposes.
100
+ - **FR-009**: Transposing a passage in Eb major up 4 half steps to G major MUST turn an E natural into G#.
101
+ - **FR-010**: The sounding pitch (pitch class and octave) of every note MUST be unchanged by respelling; only the letter and accidental may change, and octave numbers MUST be adjusted wherever respelling crosses the B/C boundary.
102
+ - **FR-011**: The previous per-key enharmonic spelling table and the lookups built on it (role-of-pitch and pitch-for-role) MUST be removed, and every feature that used them (transposition, paste into another key, default enharmonic spelling, scale-tone lookup) MUST use the new key-signature-based logic instead.
103
+ - **FR-012**: Behavior that does not involve choosing between enharmonic spellings (rendering, playback, file load/save) MUST be unchanged.
104
+ - **FR-013**: Automated tests MUST cover the worked examples in this specification, the tie-break toward flats, same-key pasting, zero-offset transposition, and octave handling at the B/C boundary.
105
+
106
+ ### Key Entities
107
+
108
+ - **Key signature**: A key identified by its tonic and its number of sharps or flats. It determines which seven spellings are natural to the key and is the only information needed to rank other spellings.
109
+ - **Pitch**: A letter, an accidental, and an octave. Several pitches can share one sounding pitch (enharmonic equivalents).
110
+ - **Distance (from a key)**: For a given spelling, the number of sharps or flats that must be added to the key signature for the pitch to belong to it (the number of fifths/fourths from the key to the nearest key containing the pitch), with a direction (sharp-side or flat-side). Zero for pitches in the key. Example: from C, Bb is 1 flat away and A# is 5 sharps away.
111
+ - **Transposition interval**: A signed number of half steps (with the matching diatonic step change) that, together with the source key, determines the destination key.
112
+
113
+ ## Success Criteria *(mandatory)*
114
+
115
+ ### Measurable Outcomes
116
+
117
+ - **SC-001**: All worked examples in this specification (C# C→D = D#; A# C→D = B#; E natural Eb→G = G#; half step below B in C = Bb) produce the stated spelling.
118
+ - **SC-002**: Transposing every chromatic pitch in a 12-note chromatic passage between every pair of the 15 major key signatures produces a spelling whose distance from the destination key equals its distance from the source key, with no exceptions.
119
+ - **SC-003**: After transposing a passage and then transposing it back by the opposite interval, 100% of the notes return to their original spelling and octave, except notes whose intermediate spelling would need a triple sharp or flat; those are respelled to the nearest double-accidental spelling.
120
+ - **SC-004**: A user transposing a typical melody with chromatic passing notes needs to hand-correct no enharmonic spellings in the result.
121
+ - **SC-005**: The sounding pitch of every note is identical before and after respelling, for all tested keys and intervals.
122
+ - **SC-006**: The existing automated test suite passes with no regressions in behavior unrelated to enharmonic spelling.
123
+
124
+ ## Assumptions
125
+
126
+ - Keys are identified by their key signature. A minor key uses the key signature of its relative major, and spelling decisions depend only on the signature.
127
+ - "Distance" is the number of steps around the circle of fifths (equivalently, a count of fourths or fifths) from the current key to the nearest key whose signature contains the pitch as spelled. This equals the number of sharps or flats that must be added to the signature. Example: from C major, Bb is 1 flat away (C to F major), while A# is 5 sharps away (C to B major), so Bb is the default.
128
+ - Direction is part of distance: a note one half step above a key tone is a sharp-direction alteration and a note one half step below is a flat-direction alteration; preserving distance means preserving both count and direction.
129
+ - When transposition would produce a destination key with more than 7 sharps or flats, the enharmonically equivalent key with fewer accidentals is used.
130
+ - Double sharps and double flats are allowed when needed to preserve the distance.
131
+ - The existing score transpose dialog and the paste-into-different-key flow are the only user entry points for transposition. No new dialogs or settings are introduced.
132
+ - The existing scale-tone lookup, which currently reads the table, will be satisfied from the key signature alone.
@@ -0,0 +1,139 @@
1
+ ---
2
+
3
+ description: "Task list for key-distance enharmonic spelling"
4
+ ---
5
+
6
+ # Tasks: Key-Distance Enharmonic Spelling for Transposition
7
+
8
+ **Input**: Design documents from `/specs/033-key-distance-transposition/`
9
+
10
+ **Prerequisites**: plan.md, spec.md, research.md, data-model.md, contracts/spelling-api.md, quickstart.md
11
+
12
+ **Tests**: Requested (FR-013). One headless test file, `tests/keyDistanceTransposition.ts`, grown story by story.
13
+
14
+ **Organization**: Grouped by user story. US1 and US2 (both P1) share the foundational spelling arithmetic; US1 additionally rewrites cross-key transposition, US2 the whole-score operation, US3 the default spelling, US4 removes the table.
15
+
16
+ ## Format: `[ID] [P?] [Story] Description`
17
+
18
+ - **[P]**: Can run in parallel (different files, no dependencies)
19
+ - **[Story]**: Which user story this task belongs to
20
+
21
+ ## Phase 1: Setup
22
+
23
+ - [X] T001 Create `tests/keyDistanceTransposition.ts` with the `check()`/failure-count harness and score-less imports used by `tests/voiceCopyPaste.ts` (exit code 1 on any failure), and register `"test:key-distance-transposition": "ts-node -P tests/tsconfig.json tests/keyDistanceTransposition.ts"` in `package.json`
24
+
25
+ ---
26
+
27
+ ## Phase 2: Foundational (Blocking Prerequisites)
28
+
29
+ **Purpose**: The line-of-fifths arithmetic every story uses. See [data-model.md](data-model.md).
30
+
31
+ - [X] T002 Fix the `'Gg'` typo to `'Gb'` in `SmoMusic.keySignatureLength` in `src/smo/data/music.ts` (research R8)
32
+ - [X] T003 Add `SmoMusic.keyFifths(keySignature)` in `src/smo/data/music.ts` returning sharps (+) / flats (-) for a lowercase VexFlow key, using the existing sharp/flat counts; unknown key returns 0
33
+ - [X] T004 Add `SmoMusic.pitchFifths(pitch)` and `SmoMusic.fifthsToPitch(f, octave)` in `src/smo/data/music.ts` per the data model (base F=-1, C=0, G=1, D=2, A=3, E=4, B=5; +7 per sharp; valid range -15..19; accidental strings `'n'`, `'#'`, `'##'`, `'b'`, `'bb'`)
34
+ - [X] T005 Add a sounding-pitch helper in `src/smo/data/music.ts` using the letter-based rule in research R10 (`octave*12 + naturalValue + accidentalCount`), and a helper that returns the pitch for position `f` whose sounding value equals a given target (solves the octave); do not change `smoPitchToInt`
35
+ - [X] T006 Add `SmoMusic.distanceFromKey(pitch, keySignature)` in `src/smo/data/music.ts`: 0 inside `k-1..k+5`, `f-(k+5)` above, `f-(k-1)` below
36
+ - [X] T007 Add `SmoMusic.spellPitchClass(soundingValue, keySignature)` (internal helper used by US1, US3): enumerates positions `f0+12m` within -15..19 for the pitch class, returns the smallest absolute distance, ties to the lower (flat-side) position, with octave solved via T005
37
+ - [X] T008 Tests in `tests/keyDistanceTransposition.ts`: `keyFifths` for all 15 major keys, `pitchFifths`/`fifthsToPitch` round trip over -15..19, `distanceFromKey` for A# in C (+5), Bb in C (-1), C# in C (+2), E in Eb (+2), G# in G (+2), in-key notes (0), and sounding-value checks `cb4`=47, `b#3`=48
38
+
39
+ **Checkpoint**: arithmetic verified; stories can proceed.
40
+
41
+ ---
42
+
43
+ ## Phase 3: User Story 1 - Pasting into a different key keeps spelling (Priority: P1) 🎯 MVP
44
+
45
+ **Goal**: `transposePitchForKey` preserves distance from source key to destination key, for paste, chord symbols and instrument transposition.
46
+
47
+ **Independent Test**: C# in C → D (+2) gives D#; A# in C → D gives B#.
48
+
49
+ ### Tests for User Story 1
50
+
51
+ - [X] T009 [US1] In `tests/keyDistanceTransposition.ts` add cases: C#→D#, A#→B#, E natural Eb→G (+4)→G#, F in C → G (+7)→C, in-key scale (all 7 notes of C into every other major key map to the destination scale), same key with offset 0 keeps spelling, Cb4 in Gb → G (+1)→C4 with sounding value +1, sounding value invariant `value(result) == value(input)+offset` over all 12 chromatic notes × 15 key pairs × offsets consistent with the keys, mismatched key/offset still yields correct sounding pitch (research R4), chord symbol `C#` in C→D gives `D#` via `SmoNoteModifiers` chord transposition path (`src/smo/data/noteModifiers.ts`)
52
+
53
+ ### Implementation for User Story 1
54
+
55
+ - [X] T010 [US1] Rewrite `SmoMusic.transposePitchForKey` in `src/smo/data/music.ts`: `s = kd - ks`, adjusted by a multiple of 12 only when `7*s mod 12` disagrees with `7*offset mod 12`; new position `f + s`; if outside -15..19 respell via `spellPitchClass`; solve octave via T005; return a new `Pitch` (no `findRoleOfPitch`/`findPitchForRole`)
56
+ - [X] T011 [US1] Verify callers need no change: `SmoNote.transpose` in `src/smo/data/note.ts` and chord-symbol transposition in `src/smo/data/noteModifiers.ts`; run `npm run test:key-distance-transposition` and `npm run test:voice-copy-paste`
57
+
58
+ **Checkpoint**: Cross-key paste and chord symbols spell correctly. MVP complete.
59
+
60
+ ---
61
+
62
+ ## Phase 4: User Story 2 - Whole-score transposition (Priority: P1)
63
+
64
+ **Goal**: Transpose Score computes each measure's destination key and preserves distance, including grace notes.
65
+
66
+ **Independent Test**: Two Eb-major measures containing E natural, transposed +4, become G major with G#.
67
+
68
+ ### Tests for User Story 2
69
+
70
+ - [X] T012 [US2] In `tests/keyDistanceTransposition.ts` add `keyForOffset` cases (offset 0 returns the input key including `c#`/`cb`; Eb+4=g; 6 vs -6 tie gives `gb`; results always within -7..+7) and a score-level case: build a small `SmoScore` (see setup in `tests/voiceCopyPaste.ts`), call `SmoOperation.transposeScore(score, 4)`, assert each measure's `keySignature` is `g` and E natural became G#; then `transposeScore(score, -4)` restores spelling, octave and key; include a grace note and a chord
71
+
72
+ ### Implementation for User Story 2
73
+
74
+ - [X] T013 [US2] Add `SmoMusic.keyForOffset(keySignature, offset)` in `src/smo/data/music.ts`: residue of `ks + 7*offset` mod 12 in -7..+7, fewest accidentals, tie to flats, offset 0 returns the input key unchanged (research R5); return lowercase VexFlow string
75
+ - [X] T014 [US2] Rewrite `SmoOperation.transposeScore` in `src/smo/xform/operations.ts` (line ~416): for each measure compute `kd = keyForOffset(measure.keySignature, offset)`, transpose every note pitch and grace-note pitch with `transposePitchForKey(pitch, ks, kd, offset)` (preserving the tab-note fret adjustment already done in `SmoOperation.transpose`), then set `measure.keySignature = kd`; zero offset is a no-op. Keep `SuiScoreViewOperations.transposeScore` in `src/render/sui/scoreViewOperations.ts` calling it for both `score` and `storeScore`
76
+ - [X] T015 [US2] Confirm the dialog in `src/ui/dialogs/transposeScore.ts` still works with incremental offsets and cancel (`-delta`) by reasoning through the inverse-shift property; adjust only if the inverse does not restore the key
77
+
78
+ **Checkpoint**: Transpose Score yields correct key and spelling and is reversible.
79
+
80
+ ---
81
+
82
+ ## Phase 5: User Story 3 - Default spelling outside the key (Priority: P2)
83
+
84
+ **Goal**: `getEnharmonicInKey` (and callers) pick the closest spelling to the key, ties to flats.
85
+
86
+ **Independent Test**: In C, the pitch a half step below B defaults to Bb; a tie such as pitch class 8 in C defaults to Ab.
87
+
88
+ ### Tests for User Story 3
89
+
90
+ - [X] T016 [US3] In `tests/keyDistanceTransposition.ts` add default-spelling cases for key C: pc 10 → Bb, pc 3 → Eb, pc 8 → Ab (tie to flat), pc 1 → C#, pc 6 → F#; for key G: pc 6 → F# (in key); for key F: pc 10 → Bb (in key); octave preserved including B/C boundary cases; document in a comment that C# in C (previously Db) is an intended behavior change (research R3)
91
+
92
+ ### Implementation for User Story 3
93
+
94
+ - [X] T017 [US3] Rewrite `SmoMusic.getEnharmonicInKey` in `src/smo/data/music.ts` to call `spellPitchClass` (T007), removing the hard-coded `a#/g#/c#/d#/f#` bias block; keep the `octave === undefined` default of 1 and the signature
95
+ - [X] T018 [US3] Reimplement `SmoMusic.getScaleTonesForKey` in `src/smo/data/music.ts` from `keyFifths` (accidental count for base `b` is `floor((k + 5 - b) / 7)`), returning the same `letter → 'f#' / 'bb' / 'cn'` shape; add tests that it matches the old table's output for all 15 major keys (capture expected values before deleting the table, see T020)
96
+ - [X] T019 [US3] Run `npm run test:key-distance-transposition`, then re-run the existing scripts in `package.json` (`test:voice-copy-paste`, `test:multimeasure-rest`, `test:select-voice`, ...) and compare callers `tickMap.ts`, `operations.ts` (lines ~469 and ~1000), `midiToSmo.ts`, `getIntervalInKey` for unintended changes
97
+
98
+ **Checkpoint**: Defaults and scale lookups no longer use the table.
99
+
100
+ ---
101
+
102
+ ## Phase 6: User Story 4 - Table removed, no other change (Priority: P3)
103
+
104
+ **Goal**: The old table and its lookups are gone; nothing unrelated changes.
105
+
106
+ **Independent Test**: Build succeeds with no references to the removed symbols; existing scripts pass.
107
+
108
+ - [X] T020 [US4] Before deleting, record `getScaleTonesForKey` output for every key from the old table into a fixture in `tests/keyDistanceTransposition.ts` (if not already done in T018)
109
+ - [X] T021 [US4] Delete `SmoMusic.enharmonicRoles`, `findRoleOfPitch`, `findPitchForRole` and the `KeySignatureRole` interface from `src/smo/data/music.ts`; confirm with a grep that no references remain in `src/`, `tests/`, `types/`
110
+ - [X] T022 [US4] Regenerate type declarations with `npm run types` so `types/src/smo/data/music.d.ts` drops `enharmonicRoles` and gains the new methods
111
+ - [X] T023 [US4] Run `npm run build` and every `test:*` script in `package.json`; fix regressions
112
+
113
+ ---
114
+
115
+ ## Phase 7: Polish & Cross-Cutting
116
+
117
+ - [X] T024 [P] Add a changelog entry to `changes.md` describing the new spelling rules, the changed default for C# in C, and that Transpose Score now updates key signatures
118
+ - [X] T025 [P] Update the doc comment above `getEnharmonicInKey`/`transposePitchForKey` in `src/smo/data/music.ts` to describe the distance rule
119
+ - [ ] T026 Walk through the manual checks in [quickstart.md](quickstart.md) in the running application
120
+
121
+ ---
122
+
123
+ ## Dependencies & Execution Order
124
+
125
+ - Phase 1 → Phase 2 → stories. Phase 2 blocks everything.
126
+ - US1 (Phase 3) and US2 (Phase 4): US2 needs T010 (the rewritten `transposePitchForKey`) but not the rest of US1's tests; sequence US1 → US2.
127
+ - US3 (Phase 5) depends only on Phase 2 and can run in parallel with US1/US2 by a second contributor, but all edits are in `music.ts`, so serialize the edits.
128
+ - US4 (Phase 6) last: it removes the table, after T018 has replaced the last reader (`getScaleTonesForKey`) and T010/T017 replaced the others.
129
+ - Polish after all stories.
130
+
131
+ ## Parallel Opportunities
132
+
133
+ Most tasks edit `music.ts` or the single test file, so parallelism is limited. T024 and T025 (changelog, doc comment) can be done together after T023.
134
+
135
+ ## Implementation Strategy
136
+
137
+ 1. Phases 1–2 (arithmetic), then US1 → validate with the C#→D# and A#→B# cases (MVP).
138
+ 2. US2 for whole-score transposition, validate with the Eb→G example.
139
+ 3. US3 for defaults, then US4 to remove the table and clean up.
@@ -0,0 +1,35 @@
1
+ # Specification Quality Checklist: Compressed Score Files (.smz)
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+ **Created**: 2026-10-30
5
+ **Feature**: [spec.md](../spec.md)
6
+
7
+ ## Content Quality
8
+
9
+ - [x] No implementation details (languages, frameworks, APIs)
10
+ - [x] Focused on user value and business needs
11
+ - [x] Written for non-technical stakeholders
12
+ - [x] All mandatory sections completed
13
+
14
+ ## Requirement Completeness
15
+
16
+ - [x] No [NEEDS CLARIFICATION] markers remain
17
+ - [x] Requirements are testable and unambiguous
18
+ - [x] Success criteria are measurable
19
+ - [x] Success criteria are technology-agnostic (no implementation details)
20
+ - [x] All acceptance scenarios are defined
21
+ - [x] Edge cases are identified
22
+ - [x] Scope is clearly bounded
23
+ - [x] Dependencies and assumptions identified
24
+
25
+ ## Feature Readiness
26
+
27
+ - [x] All functional requirements have clear acceptance criteria
28
+ - [x] User scenarios cover primary flows
29
+ - [x] Feature meets measurable outcomes defined in Success Criteria
30
+ - [x] No implementation details leak into specification
31
+
32
+ ## Notes
33
+
34
+ - "Zip" and ".smz" are user-facing format names given in the request, not implementation choices.
35
+ - Interpretations to confirm (recorded in Assumptions): the default Smoosic save becomes `.smz` with no separate new-abbreviated-JSON option; the validation format stays plain `.json`; files are recognized by their contents when the name and contents disagree; remote/library loading also accepts `.smz`.
@@ -0,0 +1,30 @@
1
+ # Contract: Score archive API
2
+
3
+ Library surface (exported from `src/application/exports.ts`). All functions are static on `SmoScoreArchive` in `src/ui/fileio/scoreArchive.ts`. Requires the global `JSZip` at call time.
4
+
5
+ ## Methods
6
+
7
+ | Method | Signature | Behavior |
8
+ |--------|-----------|----------|
9
+ | `pack` | `(score: SmoScore) => Promise<Uint8Array>` | Serializes with `{ skipStaves: false, useDictionary: false, preserveStaffIds: false }` and returns a zip with one `score.json` entry, DEFLATE level 9. |
10
+ | `isZip` | `(data: ArrayBuffer \| Uint8Array \| string) => boolean` | True when the first four bytes are `50 4B 03 04`. A string input is never a zip. |
11
+ | `unpack` | `(data: ArrayBuffer \| Uint8Array \| string) => Promise<string>` | Returns the score document text. Zip: finds the score entry as in the data model. Not a zip: UTF-8 decodes bytes (or takes the string) and strips a leading byte-order mark. Throws `Error` with a readable message on failure. |
12
+ | `load` | `(data: ArrayBuffer \| Uint8Array \| string) => Promise<SmoScore>` | `unpack` then `SmoScore.deserialize`. Throws `Error` if the result is not a score. |
13
+
14
+ ## Changed behavior elsewhere
15
+
16
+ | Item | Change |
17
+ |------|--------|
18
+ | `SmoScore.serialize(options)` | `useDictionary` is read from `options.useDictionary` (default true), not from `skipStaves`. |
19
+ | `isFullSaveFormat(ext)` | True for `.json` and `.smz` (case-insensitive, trimmed). |
20
+ | `SuiFileInput(evt, scoresAsBytes?)` | When `scoresAsBytes` is true, `.json` and `.smz` are read as `ArrayBuffer`. `.smz` is always read as bytes. Default behavior otherwise unchanged. |
21
+ | `SuiXhrLoader.loadScoreAsync()` | New. Returns the score document text for a `.json` or `.smz` URL; throws as `unpack` does. `loadAsync()` is unchanged. |
22
+ | Save dialog formats | "Smoosic" is `.smz` (default); "Validation (large)" saves plain full JSON with the `.json` extension; MusicXML, MIDI and Vex unchanged. |
23
+ | Open dialog | Accepts `.smz` as well as `.json`, `.mid`, `.midi`, `.xml`, `.mxl`. A failed `.json`/`.smz` load shows a message and leaves the open score untouched. |
24
+
25
+ ## Invariants (asserted by tests)
26
+
27
+ 1. `await SmoScore.deserialize(await unpack(await pack(score)))` serializes (full form) to the same text as `score`.
28
+ 2. `unpack` of a legacy abbreviated file and `unpack` of the same score's validation file yield scores whose full serialization is identical.
29
+ 3. `unpack` gives the same result for a zip regardless of what the file was called (the name is not an input).
30
+ 4. A failed load throws; no function mutates a score it was not asked to create.
@@ -0,0 +1,48 @@
1
+ # Data Model: Compressed Score Files (.smz)
2
+
3
+ The score document itself does not change. These are the file-level shapes.
4
+
5
+ ## Score document (existing)
6
+
7
+ The JSON produced by `SmoScore.serialize` and read by `SmoScore.deserialize`. Two textual forms exist:
8
+
9
+ | Form | Where it comes from | How to tell |
10
+ |------|--------------------|-------------|
11
+ | Abbreviated (legacy) | Default save before this feature | Has a top-level `dictionary` key; other keys are short tokens |
12
+ | Full | Validation save; contents of `.smz` | No `dictionary` key |
13
+
14
+ `deserialize` handles both; it is not changed by this feature.
15
+
16
+ ## `.smz` archive (new)
17
+
18
+ | Part | Value |
19
+ |------|-------|
20
+ | Container | Standard zip file, starts with bytes `50 4B 03 04` |
21
+ | Entry `score.json` | Full score document, UTF-8, no byte-order mark |
22
+ | Compression | DEFLATE, level 9 |
23
+ | Other entries | Ignored on read; not written |
24
+
25
+ Read rule: use `score.json` if present; otherwise the first non-directory entry whose name ends in `.json`; otherwise the file is refused.
26
+
27
+ ## Score file kinds and how each is recognized
28
+
29
+ | Kind | Extension written | Recognized by | Written by this version? |
30
+ |------|------------------|---------------|-------------------------|
31
+ | Compressed (`.smz`) | `.smz` | zip signature | Yes (default) |
32
+ | Legacy abbreviated | `.json` | text, JSON with `dictionary` key | No |
33
+ | Validation | `.json` | text, JSON without `dictionary` key | Yes (option) |
34
+
35
+ Recognition ignores the file name; the extension only picks the suggested name and the file-chooser filter.
36
+
37
+ ## Load result
38
+
39
+ `unpack(input)` returns the score document text, or throws one of these failures (message shown to the user):
40
+
41
+ | Failure | Cause |
42
+ |---------|-------|
43
+ | Not a score file | Not a zip and the text is not valid JSON |
44
+ | Damaged archive | Zip signature present but the archive cannot be read |
45
+ | No score in archive | Valid zip with no `score.json` or other `.json` entry |
46
+ | Not a score | JSON that does not look like a score (no `staves`) |
47
+
48
+ State transitions: none. Loading never mutates the open score; replacement happens only after a successful load and the unsaved-changes confirmation.
@@ -0,0 +1,89 @@
1
+ # Implementation Plan: Compressed Score Files (.smz)
2
+
3
+ **Branch**: `034-smz-compressed-scores` (work is on `main`; no feature branch was created) | **Date**: 2026-10-30 | **Spec**: [spec.md](spec.md)
4
+
5
+ **Input**: Feature specification from `/specs/034-smz-compressed-scores/spec.md`
6
+
7
+ ## Summary
8
+
9
+ Add a small, DOM-free module that turns a score into a `.smz` archive (a zip holding one full, un-abbreviated score document) and turns bytes or text from any supported score file (`.smz`, legacy abbreviated `.json`, validation `.json`) back into the JSON text that `SmoScore.deserialize` already understands. Wire it into the save dialog (default format becomes `.smz`, validation stays plain `.json`), the Open dialog, and the remote/library loaders. Detection is by content (zip signature), so a mis-named file still works. Failures leave the open score alone and show a message.
10
+
11
+ Measured on the one library score in the repo: the full document zipped is 1,857 bytes, against 17,627 for today's default save and 22,112 for the validation text, so the dictionary is not needed (see [research.md](research.md) R1).
12
+
13
+ ## Technical Context
14
+
15
+ **Language/Version**: TypeScript, tests run with `ts-node` (see `tests/tsconfig.json`).
16
+
17
+ **Primary Dependencies**: JSZip v3.6.0, already shipped (`src/common/jszip.js`, `release/jszip.js`, loaded by a script tag, declared as `JSZip: 'JSZip'` in webpack externals and used as `declare var JSZip: any` in `src/ui/fileio`). No new dependency. Vue 3 for the dialogs.
18
+
19
+ **Storage**: User-chosen files on disk (download link on save, file input on open); remote files over XHR. The browser's automatic local-storage copy is untouched.
20
+
21
+ **Testing**: Headless `ts-node` script `tests/scoreArchive.ts` (npm script `test:score-archive`). In Node the global `JSZip` is provided by `require('../src/common/jszip.js')`.
22
+
23
+ **Target Platform**: Browser application and library; the archive module is also usable headless.
24
+
25
+ **Project Type**: Single project.
26
+
27
+ **Performance Goals**: Save and open within 1 second of the previous format on a typical score (SC-004). Compression and decompression are asynchronous and do not block rendering.
28
+
29
+ **Constraints**: Must open every existing `.json` score unchanged. The data model in `src/smo` stays free of file and UI concerns (constitution principle 4); `TextDecoder`/`TextEncoder` and the `JSZip` global are the only platform pieces.
30
+
31
+ **Scale/Scope**: One new module, edits to about six existing files, one new test file.
32
+
33
+ ## Constitution Check
34
+
35
+ *GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
36
+
37
+ | Principle | Assessment |
38
+ |-----------|------------|
39
+ | #1 Serialization (scores must serialize and deserialize, including legacy) | Pass. This feature is about serialization. The score document is unchanged; only the container changes. Legacy abbreviated and validation JSON stay readable, and tests cover each. |
40
+ | #2 Editing/transformation logic regression tested | Pass. Round-trip, legacy, validation and failure cases are all headless tests. |
41
+ | #3 Rendering performance | Pass. No render-path change; compression is async and off the render path. |
42
+ | #4 Logical dependencies | Pass. The archive module sits in `src/ui/fileio` with the other load utilities, and nothing in `src/smo` refers to it. It depends on `SmoScore`; the dependency does not run the other way. |
43
+
44
+ Re-check after Phase 1 design: still passes. No complexity violations.
45
+
46
+ ## Project Structure
47
+
48
+ ### Documentation (this feature)
49
+
50
+ ```text
51
+ specs/034-smz-compressed-scores/
52
+ ├── plan.md # This file
53
+ ├── research.md # Phase 0 output
54
+ ├── data-model.md # Phase 1 output
55
+ ├── quickstart.md # Phase 1 output
56
+ ├── contracts/
57
+ │ └── archive-api.md # Phase 1 output
58
+ ├── checklists/
59
+ │ └── requirements.md
60
+ └── tasks.md # Phase 2 output (/speckit-tasks - NOT created by /speckit-plan)
61
+ ```
62
+
63
+ ### Source Code (repository root)
64
+
65
+ ```text
66
+ src/ui/fileio/scoreArchive.ts # NEW: pack / unpack / load / isZip, no DOM dependency; with the other load utilities
67
+ src/smo/data/score.ts # fix useDictionary option (reads skipStaves today)
68
+ src/ui/fileio/fileInput.ts # read .smz (and, opt-in, .json) as bytes
69
+ src/ui/fileio/xhrLoader.ts # loadScoreAsync(): read a score URL as bytes, return JSON text
70
+ src/ui/dialogs/fileDialogs.ts # open: accept .smz, content detection, error message; save: .smz
71
+ src/ui/components/dialogs/fileUpload.vue # accept list gains .smz
72
+ src/ui/components/dialogs/save.vue # Smoosic = .smz, binary contents, wait for async content
73
+ src/render/sui/scoreChangeState.ts # isFullSaveFormat accepts .smz
74
+ src/render/sui/scoreViewOperations.ts # loadRemoteJson uses loadScoreAsync
75
+ src/application/application.ts # remote initial score uses loadScoreAsync for .json/.smz
76
+ src/application/generateVexTests.ts # remote scores use loadScoreAsync
77
+ src/application/exports.ts # export the new module
78
+ types/src/ui/fileio/scoreArchive.d.ts, fileInput.d.ts, xhrLoader.d.ts, exports.d.ts # regenerated (only these)
79
+ tests/scoreArchive.ts # NEW
80
+ tests/scoreChangeState.ts # .smz is a full save
81
+ package.json # test:score-archive script
82
+ changes.md # changelog entry
83
+ ```
84
+
85
+ **Structure Decision**: Single-project layout as it exists. A separate module in `src/ui/fileio` rather than methods on `SmoScore` or a file in `src/smo/data`, because it deals with bytes and the zip library like the other file loaders, while `SmoScore` and the data model deal with the document and know nothing about files.
86
+
87
+ ## Complexity Tracking
88
+
89
+ No constitution violations to justify.
@@ -0,0 +1,44 @@
1
+ # Quickstart: Validating .smz Support
2
+
3
+ ## Prerequisites
4
+
5
+ - `npm install` done at the repository root.
6
+ - For the manual checks, a built application (`npm run build`) or the development page you normally use.
7
+
8
+ ## Automated check
9
+
10
+ ```bash
11
+ npm run test:score-archive
12
+ npm run test:score-change-state
13
+ ```
14
+
15
+ Expected: every line prints `PASS`, exit code 0. See [contracts/archive-api.md](contracts/archive-api.md) for the invariants and [data-model.md](data-model.md) for the file shapes.
16
+
17
+ | # | Scenario | Expected |
18
+ |---|----------|----------|
19
+ | 1 | Pack a score, check the first bytes and the entry name | Starts `50 4B 03 04`; one entry `score.json` |
20
+ | 2 | Pack then load a score with accented and non-Latin text in title and lyrics | Identical full serialization, text intact |
21
+ | 3 | Load `release/library/pennylane2 (6).json` (legacy abbreviated) | Loads; full serialization equals the validation file for the same score |
22
+ | 4 | Load a validation file | Loads |
23
+ | 5 | Hand the bytes of a zip to `unpack` as if it were named `.json`; hand text to `unpack` as if named `.smz` | Both load (content, not name, decides) |
24
+ | 6 | Truncated zip | Throws "damaged archive" |
25
+ | 7 | Zip with only `readme.txt` | Throws "no score in archive" |
26
+ | 8 | Text `{"hello":1}` | Throws "not a score" |
27
+ | 9 | Text with a leading byte-order mark | Loads |
28
+ | 10 | Sizes for the library score | Zipped full document smaller than the abbreviated text; at least 50% smaller than the full text |
29
+ | 11 | `serialize({ skipStaves: true, useDictionary: false })` | No `dictionary` key |
30
+ | 12 | `isFullSaveFormat('.smz')` | True |
31
+
32
+ ## Manual check in the application
33
+
34
+ 1. Start the app and open the Save dialog. The format shown is Smoosic and the suggested file ends in `.smz`.
35
+ 2. Save. The unsaved-changes indicator clears. Open the file with any zip tool: one `score.json`.
36
+ 3. Open the Load dialog; the file chooser lists `.smz`. Load the file you just saved; the score is identical.
37
+ 4. Load an older `.json` score (for example one downloaded from the library) and a validation file; both open.
38
+ 5. Rename a `.smz` to `.json` and load it; it still opens.
39
+ 6. Load a text file renamed to `.smz`; a message says the file could not be read and the open score is unchanged.
40
+ 7. Switch the save format to MusicXML, then back to Smoosic, and save quickly. The saved file is a valid `.smz`.
41
+
42
+ ## Regression
43
+
44
+ Run the other `test:*` scripts in `package.json` to confirm nothing else changed.