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
@@ -1,5 +1,7 @@
1
1
  // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
2
  // Copyright (c) Aaron David Newman 2021.
3
+ import { toRaw } from 'vue';
4
+ import { isFullSaveFormat } from './scoreChangeState';
3
5
  import { SuiScoreView, updateStaffModifierFunc } from './scoreView';
4
6
  import { SmoScore, engravingFontType } from '../../smo/data/score';
5
7
  import { SmoSystemStaffParams, SmoSystemStaff } from '../../smo/data/systemStaff';
@@ -20,7 +22,8 @@ import { UndoBuffer } from '../../smo/xform/undo';
20
22
  import {
21
23
  SmoOperation, createStaffModifierType, MakeTupletOperation
22
24
  } from '../../smo/xform/operations';
23
- import { BatchSelectionOperation } from '../../smo/xform/operations';
25
+ import { BatchSelectionOperation, AddPartParams, DeleteAttributeKind } from '../../smo/xform/operations';
26
+ import { MeasureFillType } from '../../smo/xform/measureFill';
24
27
  import { smoSerialize } from '../../common/serializationHelpers';
25
28
  import { FontInfo } from '../../common/vex';
26
29
  import { SmoMusic } from '../../smo/data/music';
@@ -28,12 +31,14 @@ import { SuiOscillator } from '../audio/oscillator';
28
31
  import { XmlToSmo } from '../../smo/mxml/xmlToSmo';
29
32
  import { SuiAudioPlayer } from '../audio/player';
30
33
  import { SuiXhrLoader } from '../../ui/fileio/xhrLoader';
34
+ import { SmoScoreArchive } from '../../ui/fileio/scoreArchive';
35
+ import { PasteAttributeOptions } from '../../smo/xform/copypaste';
31
36
  import { SmoSelection, SmoSelector } from '../../smo/xform/selections';
32
37
  import { StaffModifierBase,
33
38
  SmoInstrument, SmoInstrumentParams, SmoStaffTextBracket, SmoTabStave } from '../../smo/data/staffModifiers';
39
+ import { AutosaveEntry } from './autosave';
34
40
  import { SuiPiano } from './piano';
35
41
  import { SvgHelpers } from './svgHelpers';
36
- import { PromiseHelpers } from '../../common/promiseHelpers';
37
42
  import { parseJsonText } from 'typescript';
38
43
  import {NoteEntryCaret} from "./NoteEntryCaret";
39
44
  declare var $: any;
@@ -212,8 +217,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
212
217
  */
213
218
  async loadRemoteJson(url: string) : Promise<any> {
214
219
  const req = new SuiXhrLoader(url);
215
- await req.loadAsync();
216
- const score = SmoScore.deserialize(req.value);
220
+ const score = await SmoScoreArchive.load(await req.loadScoreAsync());
217
221
  await this.changeScore(score);
218
222
  }
219
223
  /**
@@ -245,10 +249,22 @@ export class SuiScoreViewOperations extends SuiScoreView {
245
249
  this._undoScorePreferences('Update preferences');
246
250
  const oldXpose = this.score.preferences.transposingScore;
247
251
  const curXpose = pref.transposingScore;
252
+ const oldAutosaveInterval = this.score.preferences.autosaveInterval;
253
+ const oldAutosaveCount = this.score.preferences.autosaveCount;
248
254
  const currentLayout = this.score.layoutManager?.getGlobalLayout();
249
255
  const oldDisplayMode = currentLayout ? currentLayout.displayMode : 'vertical';
250
256
  this.score.updateScorePreferences(new SmoScorePreferences(pref));
251
257
  this.storeScore.updateScorePreferences(new SmoScorePreferences(pref));
258
+ // new autosave settings take effect now: drop snapshots beyond a lower count, and restart
259
+ // a waiting snapshot with the new interval
260
+ if (this.autosaveStore) {
261
+ if (this.score.preferences.autosaveCount !== oldAutosaveCount) {
262
+ this.autosaveStore.trim(this.score.preferences.autosaveCount);
263
+ }
264
+ if (this.score.preferences.autosaveInterval !== oldAutosaveInterval) {
265
+ this.autosaveScheduler.retime(this.score.preferences.autosaveInterval);
266
+ }
267
+ }
252
268
  const newLayout = this.score.layoutManager?.getGlobalLayout();
253
269
  const displayMode = newLayout ? newLayout.displayMode : 'vertical';
254
270
  if (oldDisplayMode !== displayMode) {
@@ -273,6 +289,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
273
289
  this._undoScorePreferences('Update preferences');
274
290
  this.score.scoreInfo = scoreInfo;
275
291
  this.storeScore.scoreInfo = JSON.parse(JSON.stringify(scoreInfo));
292
+ this.refreshScoreName();
276
293
  return this.renderer.updatePromise()
277
294
  }
278
295
  async addRemoveArpeggio(code: SmoArpeggioType) {
@@ -408,7 +425,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
408
425
  async removeLyric(selector: SmoSelector, lyric: SmoLyric): Promise<void> {
409
426
  const selection = SmoSelection.noteFromSelector(this.score, selector);
410
427
  if (selection === null) {
411
- return PromiseHelpers.emptyPromise();
428
+ return;
412
429
  }
413
430
  this._undoSelection('remove lyric', selection);
414
431
  selection.note!.removeLyric(lyric);
@@ -449,7 +466,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
449
466
  async removeAnnotation(selector: SmoSelector, annotation: SmoLyric): Promise<void> {
450
467
  const selection = SmoSelection.noteFromSelector(this.score, selector);
451
468
  if (selection === null) {
452
- return PromiseHelpers.emptyPromise();
469
+ return;
453
470
  }
454
471
  this._undoSelection('remove annotation', selection);
455
472
  selection.note!.removeAnnotations(annotation);
@@ -1130,6 +1147,45 @@ export class SuiScoreViewOperations extends SuiScoreView {
1130
1147
  SmoOperation.clearAllBeamGroups(this.storeScore);
1131
1148
  await this.awaitRender();
1132
1149
  }
1150
+ /**
1151
+ * Set the beam grouping of measures, for compound or irregular meters such as 3 + 2 in 5/8.
1152
+ * An empty grouping goes back to the default for the meter. This replaces any hand-placed beams
1153
+ * in those measures.
1154
+ * @param groups the longest beam group for each group in turn, whole numbers from 1 to 4
1155
+ * @param scope the measures of the selected notes, or every measure in the score
1156
+ */
1157
+ async setBeamGroups(groups: number[], scope: 'selections' | 'all'): Promise<void> {
1158
+ if (scope === 'all') {
1159
+ this._undoScore('beam groups');
1160
+ SmoOperation.setAllBeamGroups(this.score, groups);
1161
+ SmoOperation.setAllBeamGroups(this.storeScore, groups);
1162
+ await this.awaitRender();
1163
+ return;
1164
+ }
1165
+ await this.modifyCurrentSelections('beam groups', (score, selections) => {
1166
+ SmoOperation.setBeamGroups(score, selections, groups);
1167
+ });
1168
+ }
1169
+ /**
1170
+ * Fill the selected measures with rests. This removes all the notes and voices in them, and anything
1171
+ * attached to those notes, such as slurs and text. It is one undo step.
1172
+ * @param fill which rests: the largest that fit, a rest for each beat, or eighth rests
1173
+ */
1174
+ async fillMeasures(fill: MeasureFillType): Promise<void> {
1175
+ const selections = this.tracker.selections;
1176
+ if (selections.length < 1) {
1177
+ return;
1178
+ }
1179
+ const measureSelections = SmoSelection.getMeasureList(selections);
1180
+ this._undoScore('fill measures');
1181
+ SmoOperation.fillMeasures(this.score, selections, fill);
1182
+ SmoOperation.fillMeasures(this.storeScore, this._getEquivalentSelections(selections), fill);
1183
+ // The displayed score's staves can be numbered differently from the stored score's. The stored
1184
+ // score is the one that is right about which text was attached to which staff.
1185
+ this.score.synchronizeTextGroups(this.storeScore.textGroups);
1186
+ this._renderChangedMeasures(measureSelections);
1187
+ await this.renderer.updatePromise();
1188
+ }
1133
1189
  async clearSelectedBeams() {
1134
1190
  const selections = this.tracker.selections;
1135
1191
  const measures = SmoSelection.getMeasureList(selections);
@@ -1154,6 +1210,32 @@ export class SuiScoreViewOperations extends SuiScoreView {
1154
1210
  this._renderChangedMeasures(measureSelections);
1155
1211
  await this.renderer.updatePromise();
1156
1212
  }
1213
+ /**
1214
+ * Put the selected notes back to automatic beaming, removing any hand-placed beam breaks and joins
1215
+ */
1216
+ async autoBeamSelections(): Promise<void> {
1217
+ const selections = this.tracker.selections;
1218
+ const measureSelections = this.undoTrackerMeasureSelections('auto beam selections');
1219
+ SmoOperation.autoBeamSelections(this.score, selections);
1220
+ SmoOperation.autoBeamSelections(this.storeScore, this._getEquivalentSelections(selections));
1221
+ this._renderChangedMeasures(measureSelections);
1222
+ await this.renderer.updatePromise();
1223
+ }
1224
+ /**
1225
+ * Set the stem direction of the selected notes
1226
+ * @param flagState one of SmoNote.flagStates: auto, up or down
1227
+ */
1228
+ async setStemDirection(flagState: number): Promise<void> {
1229
+ const selections = this.tracker.selections;
1230
+ if (selections.length < 1) {
1231
+ return;
1232
+ }
1233
+ const measureSelections = this.undoTrackerMeasureSelections('set stem direction');
1234
+ SmoOperation.setStemDirection(selections, flagState);
1235
+ SmoOperation.setStemDirection(this._getEquivalentSelections(selections), flagState);
1236
+ this._renderChangedMeasures(measureSelections);
1237
+ await this.renderer.updatePromise();
1238
+ }
1157
1239
  async toggleCue() {
1158
1240
  const measureSelections = this.undoTrackerMeasureSelections('toggle note cue');
1159
1241
  this.tracker.selections.forEach((selection) => {
@@ -1175,7 +1257,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
1175
1257
  async toggleBeamDirection(): Promise<void> {
1176
1258
  const selections = this.tracker.selections;
1177
1259
  if (selections.length < 1) {
1178
- return PromiseHelpers.emptyPromise();
1260
+ return;
1179
1261
  }
1180
1262
  const measureSelections = this.undoTrackerMeasureSelections('toggle beam direction');
1181
1263
  SmoOperation.toggleBeamDirection(selections);
@@ -1323,7 +1405,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
1323
1405
  }
1324
1406
  // The selection no longer exists, possibly deleted
1325
1407
  if (hintSel === null || hintSel.note === null) {
1326
- return PromiseHelpers.emptyPromise();
1408
+ return;
1327
1409
  }
1328
1410
  const pitch = SmoMusic.getLetterNotePitch(hintSel.note.pitches[0],
1329
1411
  letter, hintSel.measure.keySignature);
@@ -1360,9 +1442,135 @@ export class SuiScoreViewOperations extends SuiScoreView {
1360
1442
  this.storePaste.setSelections(this.storeScore, altAr);
1361
1443
  await this.renderer.updatePromise();
1362
1444
  }
1445
+ /**
1446
+ * The voices that Select Voice can offer for the current selection: empty unless some selected
1447
+ * measure has more than one voice.
1448
+ */
1449
+ getSelectVoiceChoices(): number[] {
1450
+ return SmoSelection.voiceChoices(this.score, this.tracker.selections);
1451
+ }
1452
+ /**
1453
+ * Select all the notes of a voice in the measures that currently have a selection. Only the
1454
+ * selection changes: no edit is made and no undo is recorded.
1455
+ * @param voice the voice to select (0-3)
1456
+ */
1457
+ async selectVoice(voice: number): Promise<void> {
1458
+ this.tracker.selectVoice(voice);
1459
+ }
1460
+ /**
1461
+ * The most voices any of the selected measures has, for the Copy Voices menu
1462
+ */
1463
+ getSelectionVoiceCount(): number {
1464
+ let rv = 0;
1465
+ this.tracker.getSelectedMeasures().forEach((sel) => {
1466
+ rv = Math.max(rv, sel.measure.voices.length);
1467
+ });
1468
+ return rv;
1469
+ }
1470
+ /**
1471
+ * Where a voice paste would go, in the full score: the selected staff and measure, and the
1472
+ * measures from there that the copied voices cover (adding up measure lengths until the copy fits,
1473
+ * but not past the last measure). Null if nothing is selected or no voices are copied.
1474
+ */
1475
+ private _getVoicePasteRange(): { staff: number, firstMeasure: number, lastMeasure: number } | null {
1476
+ if (!this.storePaste.hasVoiceCopy() || this.tracker.selections.length < 1) {
1477
+ return null;
1478
+ }
1479
+ const altSelection = this._getEquivalentSelection(this.tracker.selections[0]);
1480
+ if (altSelection === null) {
1481
+ return null;
1482
+ }
1483
+ const staff = altSelection.selector.staff;
1484
+ const measures = this.storeScore.staves[staff].measures;
1485
+ const firstMeasure = altSelection.selector.measure;
1486
+ const ticksToPaste = this.storePaste.getVoiceCopyTickCount();
1487
+ let lastMeasure = firstMeasure;
1488
+ let covered = measures[firstMeasure].getTicksFromThisOrAnyVoice(0);
1489
+ while (covered < ticksToPaste && lastMeasure + 1 < measures.length) {
1490
+ lastMeasure += 1;
1491
+ covered += measures[lastMeasure].getTicksFromThisOrAnyVoice(0);
1492
+ }
1493
+ return { staff, firstMeasure, lastMeasure };
1494
+ }
1495
+ /**
1496
+ * The number of voices at the paste destination, for the Paste Voice menu: the most voices in
1497
+ * any measure the paste would cover, on the staves it would cover. A voice number at or above
1498
+ * this count is empty everywhere in the destination.
1499
+ */
1500
+ getDestinationVoiceCount(): number {
1501
+ const range = this._getVoicePasteRange();
1502
+ if (range === null) {
1503
+ const measures = this.tracker.getSelectedMeasures();
1504
+ return measures.length > 0 ? measures[0].measure.voices.length : 0;
1505
+ }
1506
+ const copy = this.storePaste.voiceCopy!;
1507
+ let rv = 0;
1508
+ for (let k = 0; k < copy.staffCount; ++k) {
1509
+ const staff = this.storeScore.staves[range.staff + k];
1510
+ if (!staff) {
1511
+ break;
1512
+ }
1513
+ for (let m = range.firstMeasure; m <= range.lastMeasure; ++m) {
1514
+ rv = Math.max(rv, staff.measures[m].voices.length);
1515
+ }
1516
+ }
1517
+ return rv;
1518
+ }
1519
+ /**
1520
+ * Copy a voice, or all the voices, of the selected measures. The copy always covers whole
1521
+ * measures, from the start of the first selected measure to the end of the last.
1522
+ * @param voice the voice to copy (0-3), or 'all'
1523
+ */
1524
+ async copyVoices(voice: number | 'all'): Promise<void> {
1525
+ const altAr: SmoSelection[] = [];
1526
+ this.tracker.selections.forEach((sel) => {
1527
+ const noteSelection = this._getEquivalentSelection(sel);
1528
+ if (noteSelection !== null) {
1529
+ altAr.push(noteSelection);
1530
+ }
1531
+ });
1532
+ this.storePaste.setVoiceSelections(this.storeScore, altAr, voice);
1533
+ await this.renderer.updatePromise();
1534
+ }
1535
+ /**
1536
+ * Paste the voices copied with copyVoices, starting at the beginning of the first selected
1537
+ * measure. A voice that doesn't exist in a measure is created there first.
1538
+ * @param voice the voice to paste into (0-3) for a single copied voice; 'new' to paste a single
1539
+ * copied voice into a new voice after the existing ones; or 'all' to paste every copied voice
1540
+ * into the voice with the same number
1541
+ */
1542
+ async pasteVoices(voice: number | 'all' | 'new'): Promise<void> {
1543
+ const range = this._getVoicePasteRange();
1544
+ if (range === null) {
1545
+ return;
1546
+ }
1547
+ let destVoice: number | 'all' = voice === 'new' ? this.getDestinationVoiceCount() : voice;
1548
+ if (destVoice !== 'all' && (destVoice < 0 || destVoice > 3)) {
1549
+ // 'new' with all the voices already in use
1550
+ return;
1551
+ }
1552
+ this.renderer.preserveScroll();
1553
+ // The paste always begins at the start of the measure
1554
+ const target: SmoSelector = { staff: range.staff, measure: range.firstMeasure, voice: 0, tick: 0, pitches: [] };
1555
+ const measureRange = [range.firstMeasure, range.lastMeasure];
1556
+ // One undo for the whole paste, including any voices it creates
1557
+ this.storeUndo.grouping = true;
1558
+ for (let i = measureRange[0]; i <= measureRange[1]; ++i) {
1559
+ this._undoColumn('paste voices', i);
1560
+ this.renderer.unrenderColumn(this.score.staves[0].measures[i]);
1561
+ }
1562
+ this.storeUndo.grouping = false;
1563
+ if (destVoice === 'all') {
1564
+ this.storePaste.pasteAllVoices(target);
1565
+ } else {
1566
+ this.storePaste.pasteVoice(target, destVoice);
1567
+ }
1568
+ this.replaceMeasureView(measureRange);
1569
+ await this.renderer.updatePromise();
1570
+ }
1363
1571
  /**
1364
1572
  * clipboard paste action
1365
- * @returns
1573
+ * @returns
1366
1574
  */
1367
1575
  async paste(): Promise<void> {
1368
1576
  // We undo the whole score on a paste, since we don't yet know the
@@ -1389,31 +1597,60 @@ export class SuiScoreViewOperations extends SuiScoreView {
1389
1597
  await this.renderer.updatePromise();
1390
1598
  }
1391
1599
  /**
1392
- * Paste only the chords.
1600
+ * @returns true if notes have been copied, so there is something to paste
1393
1601
  */
1394
- async pasteChords(): Promise<void> {
1395
- // We undo the whole score on a paste, since we don't yet know the
1396
- // extent of the overlap
1602
+ hasCopiedNotes(): boolean {
1603
+ return this.storePaste.hasNotes();
1604
+ }
1605
+ /**
1606
+ * Paste only some kinds of marking (dynamics, lyrics, annotations, chords, articulations, ornaments)
1607
+ * from the copied notes onto the notes at the current selection. The notes themselves are not changed.
1608
+ * @param options the kinds to paste, and whether they replace or are added to the destination's markings
1609
+ */
1610
+ async pasteAttributes(options: PasteAttributeOptions): Promise<void> {
1611
+ if (!this.storePaste.hasNotes() || this.tracker.selections.length < 1) {
1612
+ return;
1613
+ }
1614
+ const firstSelection = this.tracker.selections[0];
1615
+ const altSelection = this._getEquivalentSelection(firstSelection);
1616
+ if (altSelection === null) {
1617
+ return;
1618
+ }
1619
+ const altTarget = JSON.parse(JSON.stringify(altSelection.selector));
1620
+ altTarget.tick = firstSelection.selector.tick;
1621
+ // Find out which measures the paste will change before changing them. The copied duration isn't
1622
+ // enough, since a copied note can go to a destination note that starts later.
1623
+ const extent = this.storePaste.getAttributePasteExtent(altTarget);
1624
+ if (extent === null) {
1625
+ return;
1626
+ }
1397
1627
  this.renderer.preserveScroll();
1398
- const selections: SmoSelection[] = this.getPasteMeasureList();
1399
- const firstSelection = selections[0];
1400
- const measureEnd = selections[selections.length - 1].selector.measure;
1401
- const measureRange = [firstSelection.selector.measure, measureEnd];
1628
+ // Group the undo of all the affected measures into one step.
1402
1629
  this.storeUndo.grouping = true;
1403
- // Undo the paste by selecting all the affected measures
1404
- for (let i = measureRange[0]; i <= measureRange[1]; ++i) {
1630
+ for (let i = extent.firstMeasure; i <= extent.lastMeasure; ++i) {
1405
1631
  this._undoColumn('paste', i);
1406
1632
  this.renderer.unrenderColumn(this.score.staves[0].measures[i]);
1407
1633
  }
1408
1634
  this.storeUndo.grouping = false;
1409
- const altSelection = this._getEquivalentSelection(firstSelection);
1410
- const altTarget = altSelection!.selector;
1411
- altTarget.tick = this.tracker.selections[0].selector.tick;
1412
- this.storePaste.pasteChords(altTarget);
1413
- // Refresh those measures.
1414
- this.replaceMeasureView(measureRange);
1635
+ this.storePaste.pasteAttributes(altTarget, options);
1636
+ this.replaceMeasureView([extent.firstMeasure, extent.lastMeasure]);
1415
1637
  await this.renderer.updatePromise();
1416
1638
  }
1639
+ /**
1640
+ * Remove the chosen kinds of marking (dynamics, lyrics, annotations, chords, articulations, ornaments,
1641
+ * grace notes, arpeggios, microtones) from the selected notes. The notes themselves are not changed.
1642
+ * It is one undo step. Nothing happens, and no undo step is made, if no kind is chosen or the selected
1643
+ * notes have none of them.
1644
+ * @param kinds the kinds of marking to remove
1645
+ */
1646
+ async deleteNoteAttributes(kinds: DeleteAttributeKind[]): Promise<void> {
1647
+ if (kinds.length < 1 || SmoOperation.countNoteAttributes(this.tracker.selections, kinds) < 1) {
1648
+ return;
1649
+ }
1650
+ await this.modifyCurrentSelections('delete special', (score, selections) => {
1651
+ SmoOperation.deleteNoteAttributes(selections, kinds);
1652
+ });
1653
+ }
1417
1654
  /**
1418
1655
  * specify a note head other than the default for the duration
1419
1656
  * @param head
@@ -1614,7 +1851,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
1614
1851
  modifier = StaffModifierBase.deserialize(original);
1615
1852
  } else {
1616
1853
  console.warn('update modifier: bad modifier');
1617
- return PromiseHelpers.emptyPromise();
1854
+ return;
1618
1855
  }
1619
1856
  }
1620
1857
  const existing = this.score.staves[modifier.startSelector.staff]
@@ -1775,6 +2012,33 @@ export class SuiScoreViewOperations extends SuiScoreView {
1775
2012
  this.renderer.pageMap.updateZoom(zoomFactor);
1776
2013
  this.renderer.pageMap.updateContainerOffset(this.scroller.scrollState);
1777
2014
  }
2015
+ /**
2016
+ * Keep text groups in the same visual position when a layout changes: rescale by the
2017
+ * svg scale ratio, and by the page width/height ratios. Groups are de-duplicated by
2018
+ * identity, since a part's staves (and the view and store copies, after a part update)
2019
+ * can share the same text group objects, and scaling one twice would double-apply it.
2020
+ * @param textGroups groups to adjust
2021
+ * @param previousLayout layout before the change
2022
+ * @param layout layout after the change
2023
+ */
2024
+ static repositionTextGroups(textGroups: SmoTextGroup[], previousLayout: SmoGlobalLayout, layout: SmoGlobalLayout) {
2025
+ const scaleChanged = previousLayout.svgScale !== layout.svgScale;
2026
+ const widthChanged = previousLayout.pageWidth !== layout.pageWidth;
2027
+ const heightChanged = previousLayout.pageHeight !== layout.pageHeight;
2028
+ const scaleRatio = previousLayout.svgScale / layout.svgScale;
2029
+ const widthRatio = widthChanged ? layout.pageWidth / previousLayout.pageWidth : 1;
2030
+ const heightRatio = heightChanged ? layout.pageHeight / previousLayout.pageHeight : 1;
2031
+ const unique = new Set<SmoTextGroup>();
2032
+ textGroups.forEach((tg) => unique.add(toRaw(tg)));
2033
+ unique.forEach((tg) => {
2034
+ if (scaleChanged) {
2035
+ tg.scaleText(scaleRatio);
2036
+ }
2037
+ if (widthChanged || heightChanged) {
2038
+ tg.rescalePosition(widthRatio, heightRatio);
2039
+ }
2040
+ });
2041
+ }
1778
2042
  /**
1779
2043
  * set global page for score, zoom etc.
1780
2044
  * @param layout global SVG settings
@@ -1792,16 +2056,8 @@ export class SuiScoreViewOperations extends SuiScoreView {
1792
2056
  return;
1793
2057
  }
1794
2058
  this._undoScore('Set Global Layout');
1795
- const scaleRatio = previousLayout.svgScale / layout.svgScale;
1796
- const widthRatio = widthChanged ? layout.pageWidth / previousLayout.pageWidth : 1;
1797
- const heightRatio = heightChanged ? layout.pageHeight / previousLayout.pageHeight : 1;
1798
2059
  const repositionGroups = (textGroups: SmoTextGroup[]) => {
1799
- if (scaleChanged) {
1800
- textGroups.forEach((tg) => tg.scaleText(scaleRatio));
1801
- }
1802
- if (widthChanged || heightChanged) {
1803
- textGroups.forEach((tg) => tg.rescalePosition(widthRatio, heightRatio));
1804
- }
2060
+ SuiScoreViewOperations.repositionTextGroups(textGroups, previousLayout, layout);
1805
2061
  };
1806
2062
  if (this.isPartExposed()) {
1807
2063
  // A part has its own layoutManager/textGroups (see SuiScoreView._mapPartFormatting,
@@ -1907,7 +2163,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
1907
2163
  async deleteMeasure(): Promise<void> {
1908
2164
  this._undoScore('Delete Measure');
1909
2165
  if (this.storeScore.staves[0].measures.length < 2) {
1910
- return PromiseHelpers.emptyPromise();
2166
+ return;
1911
2167
  }
1912
2168
  const selections = SmoSelection.getMeasureList(this.tracker.selections);
1913
2169
  // THe measures get renumbered, so keep the index at 0
@@ -2004,7 +2260,7 @@ export class SuiScoreViewOperations extends SuiScoreView {
2004
2260
  async removeStaff(): Promise<void> {
2005
2261
  this._undoScore('Remove Instrument');
2006
2262
  if (this.storeScore.staves.length < 2 || this.score.staves.length < 2) {
2007
- return PromiseHelpers.emptyPromise();
2263
+ return;
2008
2264
  }
2009
2265
  // if we are looking at a subset of the score,
2010
2266
  // revert to the full score view before removing the staff.
@@ -2062,6 +2318,18 @@ export class SuiScoreViewOperations extends SuiScoreView {
2062
2318
  this.viewAll();
2063
2319
  return this.renderer.updatePromise();
2064
2320
  }
2321
+ /**
2322
+ * Create a part, with one or two staves, at the requested place in the score. It is one undo step.
2323
+ * See {@link SmoOperation.addPart}.
2324
+ * @param params where the part goes, its instrument, name and abbreviation
2325
+ */
2326
+ async createPart(params: AddPartParams): Promise<void> {
2327
+ this._undoScore('Create part');
2328
+ // The new staves go in the full score, which may not be what is displayed.
2329
+ SmoOperation.addPart(this.storeScore, params);
2330
+ this.viewAll();
2331
+ return this.renderer.updatePromise();
2332
+ }
2065
2333
  /**
2066
2334
  * Update part info assumes that the part is currently exposed - that
2067
2335
  * staff 0 is the first staff in the part prior to editing.
@@ -2075,6 +2343,19 @@ export class SuiScoreViewOperations extends SuiScoreView {
2075
2343
  const resetView = !SmoLayoutManager.areLayoutsEqual(info.layoutManager.getGlobalLayout(), this.score.layoutManager!.getGlobalLayout());
2076
2344
  const restChange = this.score.staves[0].partInfo.expandMultimeasureRests != info.expandMultimeasureRests;
2077
2345
  const stavesChange = this.score.staves[0].partInfo.stavesAfter !== info.stavesAfter;
2346
+ // The displayed part's layout has not been replaced yet, so it is the 'before' value.
2347
+ // Reposition the part's text groups the same way setGlobalLayout does for the score.
2348
+ const previousLayout = this.score.layoutManager!.getGlobalLayout();
2349
+ const newLayout = info.layoutManager.getGlobalLayout();
2350
+ if (previousLayout.svgScale !== newLayout.svgScale || previousLayout.pageWidth !== newLayout.pageWidth ||
2351
+ previousLayout.pageHeight !== newLayout.pageHeight) {
2352
+ const partText: SmoTextGroup[] = [];
2353
+ for (i = 0; i < partLength; ++i) {
2354
+ partText.push(...(this.storeScore.staves[storeStaff + i]?.partInfo.textGroups ?? []));
2355
+ partText.push(...(this.score.staves[i]?.partInfo.textGroups ?? []));
2356
+ }
2357
+ SuiScoreViewOperations.repositionTextGroups(partText, previousLayout, newLayout);
2358
+ }
2078
2359
  this.PartName.value = info.partName;
2079
2360
  for (i = 0; i < partLength; ++i) {
2080
2361
  const nStaffIndex = storeStaff + i;
@@ -2124,12 +2405,57 @@ export class SuiScoreViewOperations extends SuiScoreView {
2124
2405
  this.addStaff(staffParams);
2125
2406
  return this.renderer.updatePromise();
2126
2407
  }
2408
+ /**
2409
+ * The autosaved snapshots, newest first, for the Recovery dialog.
2410
+ * @returns each snapshot, with `available` false if its stored text is missing or damaged
2411
+ */
2412
+ listSnapshots(): (AutosaveEntry & { available: boolean })[] {
2413
+ if (!this.autosaveStore) {
2414
+ return [];
2415
+ }
2416
+ const store = this.autosaveStore;
2417
+ return store.list().reverse().map((entry) => {
2418
+ return { ...entry, available: store.read(entry.id) !== null };
2419
+ });
2420
+ }
2421
+ /**
2422
+ * Replace the open score with an autosaved snapshot. The snapshot is kept, and the recovered
2423
+ * score counts as having unsaved changes. The caller asks about unsaved changes in the open
2424
+ * score first.
2425
+ * @param id the snapshot's id, from listSnapshots
2426
+ * @throws Error with a message for the user; the open score is left as it was
2427
+ */
2428
+ async recoverSnapshot(id: number): Promise<void> {
2429
+ const text = this.autosaveStore ? this.autosaveStore.read(id) : null;
2430
+ if (text === null) {
2431
+ throw new Error('That autosave is no longer available.');
2432
+ }
2433
+ const score = await SmoScoreArchive.load(SmoScoreArchive.fromBase64(text));
2434
+ await this.changeScore(score);
2435
+ // changeScore treats a new score as saved, but this one has not been saved to a file
2436
+ this.markScoreChanged();
2437
+ }
2127
2438
  /**
2128
2439
  * Save the score to local storage.
2129
2440
  */
2130
2441
  quickSave() {
2131
2442
  const scoreStr = JSON.stringify(this.storeScore.serialize());
2132
2443
  localStorage.setItem(smoSerialize.localScore, scoreStr);
2444
+ this.markScoreSaved();
2445
+ }
2446
+ /**
2447
+ * Called when the user has saved the score to a file. Only a save in the full Smoosic
2448
+ * format counts: other formats (MusicXML, MIDI...) lose information, so the score still
2449
+ * has unsaved changes. The save dialog doesn't know which formats are lossy; we do.
2450
+ * @param extension the extension of the file that was saved, e.g. '.json'
2451
+ * @returns true if the score is now considered saved
2452
+ */
2453
+ recordSave(extension: string): boolean {
2454
+ if (!isFullSaveFormat(extension)) {
2455
+ return false;
2456
+ }
2457
+ this.markScoreSaved();
2458
+ return true;
2133
2459
  }
2134
2460
  updateRepeatCount(count: number) {
2135
2461
  const measureSelections = this.undoTrackerMeasureSelections('repeat bar');
@@ -0,0 +1,82 @@
1
+ // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
+ // Copyright (c) Aaron David Newman 2026.
3
+ /**
4
+ * Pure geometry for the note entry caret: converting between a y position and a staff line.
5
+ * Staff line 1 is the bottom line of the staff and each step of 1 is one staff line, so a
6
+ * space is a half step. The caller must pass every y in the same coordinate system: either all
7
+ * absolute (measured from the top of the first page, as mouse positions are after conversion to
8
+ * SVG coordinates) or all local to one page. Mixing them is wrong on every page after the first.
9
+ * No imports, so it can be tested without a DOM.
10
+ * @module /render/sui/staffLineGeometry
11
+ */
12
+
13
+ /**
14
+ * The staff line (in half steps) at a y position.
15
+ * @param y the y position, in the same coordinate system as `caretTop`
16
+ * @param caretTop the y of the top of the caret box (the top of the highest ledger line position)
17
+ * @param bottomOffset distance from `caretTop` down to the bottom line of the staff's lower ledger area
18
+ * @param lineHeight pixels between staff lines
19
+ * @returns the staff line, to the nearest half step
20
+ */
21
+ export function staffLineFromY(y: number, caretTop: number, bottomOffset: number, lineHeight: number): number {
22
+ const relativeY = y - caretTop;
23
+ return Math.round((bottomOffset - relativeY) / (lineHeight / 2)) / 2;
24
+ }
25
+
26
+ /**
27
+ * The y position of a staff line.
28
+ * @param staffLine the staff line, in half steps
29
+ * @param caretTop the y of the top of the caret box
30
+ * @param bottomOffset distance from `caretTop` down to the bottom line of the staff's lower ledger area
31
+ * @param lineHeight pixels between staff lines
32
+ * @returns the y, in the same coordinate system as `caretTop`
33
+ */
34
+ export function yFromStaffLine(staffLine: number, caretTop: number, bottomOffset: number, lineHeight: number): number {
35
+ return (bottomOffset - (staffLine * lineHeight)) + caretTop;
36
+ }
37
+
38
+ /**
39
+ * The vertical extent in which the mouse is tracked by the note entry caret. All y values are in
40
+ * one coordinate system (absolute, from the top of the first page).
41
+ */
42
+ export interface TrackingLimitParams {
43
+ /** top of the caret box (the highest ledger position above the staff) */
44
+ caretTop: number,
45
+ /** bottom of the caret box (the lowest ledger position below the staff) */
46
+ caretBottom: number,
47
+ /** top of the staff itself; tracking always covers the staff */
48
+ staffTop: number,
49
+ /** bottom of the staff itself */
50
+ staffBottom: number,
51
+ /** top of the page the staff is on */
52
+ pageTop: number,
53
+ /** bottom of the page the staff is on */
54
+ pageBottom: number,
55
+ /** bottom of the staff above in this system, or of the previous system, if there is one */
56
+ aboveBottom: number | null,
57
+ /** top of the staff below in this system, or of the next system, if there is one */
58
+ belowTop: number | null
59
+ }
60
+ export interface TrackingLimits {
61
+ top: number,
62
+ bottom: number
63
+ }
64
+ /**
65
+ * Where to stop tracking the mouse above and below a staff. The caret allows for ledger lines above
66
+ * and below the staff, but when staves are close together that area overlaps the next staff (or the
67
+ * next system), which makes the notes there hard to select. So tracking stops at the bottom of the
68
+ * staff above or the previous system (or the top of the page), and at the top of the staff below or the
69
+ * next system (or the bottom of the page), whichever comes first. It never cuts into the staff itself.
70
+ * @param p the geometry, see {@link TrackingLimitParams}
71
+ */
72
+ export function trackingLimits(p: TrackingLimitParams): TrackingLimits {
73
+ let top = Math.max(p.caretTop, p.pageTop);
74
+ if (p.aboveBottom !== null) {
75
+ top = Math.max(top, p.aboveBottom);
76
+ }
77
+ let bottom = Math.min(p.caretBottom, p.pageBottom);
78
+ if (p.belowTop !== null) {
79
+ bottom = Math.min(bottom, p.belowTop);
80
+ }
81
+ return { top: Math.min(top, p.staffTop), bottom: Math.max(bottom, p.staffBottom) };
82
+ }