vibe-editor 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/package.json +65 -61
  2. package/src/scripts/js/Core.js +32 -13
  3. package/src/scripts/js/entry.js +6 -5
  4. package/src/scripts/js/gui/Annotations.js +28 -13
  5. package/src/scripts/js/gui/ScoreManipulator.js +13 -11
  6. package/src/scripts/js/gui/Tabbar.js +14 -5
  7. package/src/scripts/js/gui/Toolbar.js +1 -1
  8. package/src/scripts/js/handlers/AnnotationChangeHandler.js +16 -4
  9. package/src/scripts/js/handlers/CustomAnnotationShapeDrawer.js +2 -2
  10. package/src/scripts/js/handlers/InsertModeHandler.js +7 -7
  11. package/src/scripts/js/handlers/KeyModeHandler.js +1 -1
  12. package/src/scripts/js/handlers/LabelHandler.js +1 -1
  13. package/src/scripts/js/handlers/NoteDragHandler.js +1 -1
  14. package/src/scripts/js/handlers/PhantomElementHandler.js +3 -10
  15. package/src/scripts/js/handlers/{SideBarHandler.js → SidebarHandler.js} +1 -1
  16. package/src/scripts/js/handlers/TooltipHandler.js +1 -1
  17. package/src/scripts/js/handlers/WindowHandler.js +7 -7
  18. package/src/scripts/js/scripts/Core.js +932 -0
  19. package/src/scripts/js/scripts/MusicProcessor.js +810 -0
  20. package/src/scripts/js/scripts/VIBE.js +219 -0
  21. package/src/scripts/js/{assets → scripts/assets}/mei_template.js +2 -2
  22. package/src/scripts/js/scripts/datastructures/MeasureMatrix.js +156 -0
  23. package/src/scripts/js/scripts/gui/Annotations.js +549 -0
  24. package/src/scripts/js/scripts/gui/Cursor.js +203 -0
  25. package/src/scripts/js/{gui → scripts/gui}/HarmonyLabel.js +1 -1
  26. package/src/scripts/js/scripts/gui/PhantomElement.js +132 -0
  27. package/src/scripts/js/scripts/gui/ScoreManipulator.js +188 -0
  28. package/src/scripts/js/scripts/gui/Tabbar.js +705 -0
  29. package/src/scripts/js/{gui → scripts/gui}/TempoLabel.js +1 -1
  30. package/src/scripts/js/{gui/Toolbar copy.js → scripts/gui/Toolbar.js} +15 -11
  31. package/src/scripts/js/scripts/handlers/AnnotationChangeHandler.js +650 -0
  32. package/src/scripts/js/scripts/handlers/ClickModeHandler.js +535 -0
  33. package/src/scripts/js/{gui → scripts/handlers}/CustomAnnotationShapeDrawer.js +34 -17
  34. package/src/scripts/js/{handlers/ModHandler.js → scripts/handlers/CustomToolbarHandler.js} +54 -66
  35. package/src/scripts/js/scripts/handlers/GlobalKeyboardHandler.js +372 -0
  36. package/src/scripts/js/scripts/handlers/Handler.js +2 -0
  37. package/src/scripts/js/{handlers/InsertModeHandler_deprecated.js → scripts/handlers/InsertModeHandler.js} +117 -164
  38. package/src/scripts/js/scripts/handlers/KeyModeHandler.js +405 -0
  39. package/src/scripts/js/scripts/handlers/LabelHandler.js +463 -0
  40. package/src/scripts/js/scripts/handlers/NoteDragHandler.js +97 -0
  41. package/src/scripts/js/scripts/handlers/PhantomElementHandler.js +168 -0
  42. package/src/scripts/js/scripts/handlers/ScoreManipulatorHandler.js +233 -0
  43. package/src/scripts/js/scripts/handlers/SidebarHandler.js +506 -0
  44. package/src/scripts/js/scripts/handlers/TooltipHandler.js +132 -0
  45. package/src/scripts/js/scripts/handlers/WindowHandler.js +278 -0
  46. package/src/scripts/js/scripts/utils/MEIOperations.js +2121 -0
  47. package/src/scripts/js/{utils/Mouse2MEI.js → scripts/utils/Mouse2SVG.js} +225 -57
  48. package/src/scripts/js/{utils → scripts/utils}/ReactWrapper.js +1 -1
  49. package/src/scripts/js/scripts/utils/SVGEditor.js +453 -0
  50. package/src/scripts/js/scripts/utils/Types.js +2 -0
  51. package/src/scripts/js/{utils/VerovioWrapper copy.js → scripts/utils/VerovioWrapper.js} +35 -21
  52. package/src/scripts/js/scripts/utils/coordinates.js +54 -0
  53. package/src/scripts/js/utils/MEIOperations.js +22 -22
  54. package/src/scripts/js/utils/Mouse2SVG.js +13 -6
  55. package/src/scripts/js/utils/SVGEditor.js +2 -2
  56. package/src/scripts/js/utils/VerovioWrapper.js +4 -4
  57. package/src/scripts/js/utils/coordinates.js +26 -2
  58. package/src/scripts/js/.DS_Store +0 -0
  59. package/src/scripts/js/MusicPlayer.js +0 -572
  60. package/src/scripts/js/datastructures/ScoreGraph copy.js +0 -432
  61. package/src/scripts/js/gui/CustomAnnotationDrawer.js +0 -114
  62. package/src/scripts/js/handlers/AnnotationDragHandler.js +0 -113
  63. package/src/scripts/js/handlers/AnnotationLineHandler.js +0 -113
  64. package/src/scripts/js/handlers/ArticulationHandler.js +0 -20
  65. package/src/scripts/js/handlers/HarmonyHandler.js +0 -282
  66. package/src/scripts/js/handlers/InsertModeHandler copy.js +0 -423
  67. package/src/scripts/js/handlers/KeyModeHandler copy.js +0 -407
  68. package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +0 -411
  69. package/src/scripts/js/handlers/NoteDragHandler copy.js +0 -148
  70. package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +0 -150
  71. package/src/scripts/js/handlers/SelectionHandler.js +0 -262
  72. package/src/scripts/js/utils/RectWrapper.js +0 -10
  73. package/src/scripts/js/utils/SVGFiller.js +0 -245
  74. package/src/scripts/js/utils/VerovioWrapperLocal.js +0 -156
  75. package/src/scripts/js/utils/firefoxBBoxes.js +0 -143
  76. package/src/styles/vibe.css +0 -785
  77. /package/src/scripts/js/{constants.js → scripts/constants.js} +0 -0
  78. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph.js +0 -0
  79. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph_deprecated.js +0 -0
  80. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreNode.js +0 -0
  81. /package/src/scripts/js/{gui → scripts/gui}/Label.js +0 -0
  82. /package/src/scripts/js/{handlers → scripts/handlers}/DeleteHandler.js +0 -0
  83. /package/src/scripts/js/{utils → scripts/utils}/DOMCreator.js +0 -0
  84. /package/src/scripts/js/{utils → scripts/utils}/MEIConverter.js +0 -0
  85. /package/src/scripts/js/{utils → scripts/utils}/convenienceQueries.js +0 -0
  86. /package/src/scripts/js/{utils → scripts/utils}/mappings.js +0 -0
  87. /package/src/scripts/js/{utils → scripts/utils}/random.js +0 -0
@@ -1,156 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const verovio_1 = require("verovio");
4
- //@ts-ignore
5
- //const $ = H5P.jQuery;
6
- /**
7
- * A wrapper around the verovio web worker to permit mocking in tests.
8
- */
9
- class VerovioWrapper {
10
- constructor() {
11
- this.vrvToolkit = new verovio_1.default.toolkit() || null;
12
- this.r = 1;
13
- if (this.isRetina()) {
14
- this.r = 2;
15
- }
16
- this.widthValue = 2500;
17
- this.options = {
18
- // from: 'mei',
19
- footer: 'none',
20
- header: 'none',
21
- pageMarginLeft: 50,
22
- pageMarginTop: 100,
23
- pageMarginBottom: 0,
24
- font: 'Bravura',
25
- //adjustPageWidth: 0,
26
- //adjustPageHeight: 0,
27
- noJustification: 1,
28
- pageWidth: (this.widthValue / (window.devicePixelRatio / this.r)) / (screen.availHeight / window.innerWidth),
29
- //svgRemoveXlink: true,
30
- svgViewBox: true,
31
- //svgBoundingBoxes: true
32
- //pageHeight: 60000
33
- };
34
- this.vrvToolkit.setOptions(this.options);
35
- }
36
- /**
37
- * Detect, if retina display is used.
38
- * This will be important to adjust the pagewith with the given zoom level
39
- * @returns
40
- */
41
- isRetina() {
42
- if (window.matchMedia) {
43
- var mq = window.matchMedia("only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)");
44
- return (mq && mq.matches);
45
- }
46
- }
47
- setMessage(data) {
48
- this.r = 1;
49
- if (this.isRetina()) {
50
- this.r = 2;
51
- }
52
- this.vrvToolkit.setOptions({
53
- //pageWidth: (this.vrvToolkit.getOptions().pageWidth / (window.devicePixelRatio / this.r)) / (screen.availHeight / window.innerWidth)
54
- pageWidth: (this.widthValue / (window.devicePixelRatio / this.r)) / (screen.availHeight / window.innerWidth)
55
- });
56
- this.data = data || null;
57
- var result = {
58
- id: data.id
59
- };
60
- switch (data.action) {
61
- case 'renderData':
62
- result.mei = this.renderData();
63
- break;
64
- case 'getElementAttr':
65
- result.attributes = this.getElementAttr();
66
- break;
67
- case 'getTimeForElement':
68
- result.time = this.getTimeForElement();
69
- break;
70
- case "getTimesForElement":
71
- result.times = this.getTimesForElement();
72
- case 'edit':
73
- result.result = this.edit();
74
- break;
75
- case 'getMEI':
76
- result.mei = this.getMEI();
77
- break;
78
- case 'editInfo':
79
- result.info = this.editInfo();
80
- break;
81
- case 'renderToSVG':
82
- result.svg = this.renderToSVG();
83
- break;
84
- case 'renderToMidi':
85
- result.midi = this.renderToMidi();
86
- default:
87
- break;
88
- }
89
- return result;
90
- }
91
- getID() {
92
- return this.data.id;
93
- }
94
- renderData() {
95
- var meiString;
96
- if (this.data.isUrl) {
97
- const req = new XMLHttpRequest();
98
- req.open('GET', this.data.mei, false);
99
- //req.onload = () => req.status === 200 ? resolve(req.response) : reject(Error(req.statusText));
100
- //req.onerror = (e) => reject(Error(`Network Error: ` + e));
101
- req.send();
102
- if (req.status === 200) {
103
- meiString = req.response;
104
- }
105
- }
106
- else {
107
- meiString = this.data.mei;
108
- }
109
- return this.vrvToolkit.renderData(meiString, {});
110
- }
111
- getElementAttr() {
112
- return this.vrvToolkit.getElementAttr(this.data.elementId);
113
- }
114
- getTimeForElement() {
115
- return this.vrvToolkit.getTimeForElement(this.data.elementId);
116
- }
117
- getTimesForElement() {
118
- return this.vrvToolkit.getTimesForElement(this.data.elementId);
119
- }
120
- edit() {
121
- return this.vrvToolkit.edit(this.data.editorAction);
122
- }
123
- getMEI() {
124
- return this.vrvToolkit.getMEI({
125
- pageNo: 0,
126
- scoreBased: true
127
- });
128
- }
129
- editInfo() {
130
- return this.vrvToolkit.editInfo();
131
- }
132
- renderToSVG() {
133
- return this.vrvToolkit.renderToSVG(1);
134
- }
135
- renderToMidi() {
136
- return this.vrvToolkit.renderToMIDI();
137
- }
138
- /**
139
- * Get Toolkit instance to use any method of verovio outside of score editor.
140
- * FOr all available methods go to: https://book.verovio.org/toolkit-reference/toolkit-methods.html
141
- * @returns toolkit instance
142
- */
143
- getToolkit() {
144
- return this.vrvToolkit;
145
- }
146
- getOptions() {
147
- return this.options;
148
- }
149
- setWidthValue(wv) {
150
- this.widthValue = wv;
151
- }
152
- setHeightValue(hv) {
153
- this.heightValue = hv;
154
- }
155
- }
156
- exports.default = VerovioWrapper;
@@ -1,143 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.adjustBBox = void 0;
4
- const coordinates = require("./coordinates");
5
- const allowedClasses = ["chord", "note", "notehead", "staff", "rest", "mRest", "clef", "meterSig", "keySig", "stem"];
6
- /**
7
- * Compute new bounding box coordinates for relevant elements. And attach new translate function to element
8
- * @param element can be either element in #vrvSVG .definition-scale or #interactionOverlay #scoreRects
9
- * @returns
10
- */
11
- function adjustBBox(element) {
12
- var _a;
13
- var elClass;
14
- if (!allowedClasses.some(ac => {
15
- if (element.classList.contains(ac)) {
16
- elClass = ac;
17
- return true;
18
- }
19
- })) {
20
- return;
21
- }
22
- //target = element in #scoreRects
23
- var target;
24
- //source = element in #vrvSVG
25
- var source;
26
- if (element.getAttribute("refId") === null) {
27
- target = (_a = document.querySelector("[refId=" + element.id + "]")) === null || _a === void 0 ? void 0 : _a.querySelector("rect");
28
- source = element;
29
- }
30
- else {
31
- target = element.querySelector("rect");
32
- source = document.getElementById(element.getAttribute("refId"));
33
- }
34
- if (source === null || target === null) {
35
- throw new Error("Referenced Element is null. BBox can't be computed for" + element.toString());
36
- }
37
- switch (elClass) {
38
- case "clef":
39
- case "keySig":
40
- simpleTranslate(source, target);
41
- break;
42
- case "mRest":
43
- simpleTranslate(source, target);
44
- halfWidth(target);
45
- break;
46
- case "rest":
47
- simpleTranslate(source, target);
48
- adjustHightToLowestStaffLine(source, target);
49
- halfWidth(target);
50
- break;
51
- case "meterSig":
52
- simpleTranslate(source, target);
53
- adjustHightToLowestStaffLine(source, target);
54
- break;
55
- case "staff":
56
- adjustHightToLowestStaffLine(source, target);
57
- adjustWidthToBarLine(source, target);
58
- break;
59
- case "note":
60
- translateNotehead(source, target);
61
- adjustToBetweenStemNoteheadBounds(source, target);
62
- break;
63
- case "chord":
64
- simpleTranslate(source, target);
65
- adjustToBetweenStemNoteheadBounds(source, target);
66
- break;
67
- case "stem":
68
- nullifyBBox(target);
69
- break;
70
- }
71
- }
72
- exports.adjustBBox = adjustBBox;
73
- function simpleTranslate(source, target) {
74
- var useElement = source.querySelector("use") || source.querySelector("rect");
75
- var translateY = -parseFloat(useElement.getAttribute("y"));
76
- var translateX = -parseFloat(useElement.getAttribute("x"));
77
- target.setAttribute("transform", "translate(" + translateX.toString() + "," + translateY.toString() + ")");
78
- }
79
- function adjustHightToLowestStaffLine(source, target) {
80
- var closestStaff;
81
- if (source.classList.contains("staff")) {
82
- closestStaff = source;
83
- }
84
- else {
85
- closestStaff = source.closest(".staff");
86
- }
87
- var lowestStaffLine = Array.from(closestStaff.querySelectorAll(":scope > path")).reverse()[0];
88
- var coordsStaffline = coordinates.getDOMMatrixCoordinates(lowestStaffLine, source.closest("#vrvSVG"));
89
- var coordsTarget = coordinates.getDOMMatrixCoordinates(target, target.closest("#interactionOverlay"));
90
- var targetHeight = coordsStaffline.y - coordsTarget.y;
91
- target.setAttribute("height", targetHeight.toString());
92
- }
93
- function adjustWidthToBarLine(source, target) {
94
- var closestMeasure = source.closest(".measure");
95
- var barline = closestMeasure.querySelector(".barLine");
96
- var coordsBarline = coordinates.getDOMMatrixCoordinates(barline, source.closest("#vrvSVG"));
97
- var coordsTarget = coordinates.getDOMMatrixCoordinates(target, target.closest("#interactionOverlay"));
98
- var targetWidth = coordsBarline.x - coordsTarget.x;
99
- target.setAttribute("width", targetWidth.toString());
100
- }
101
- function translateNotehead(source, target) {
102
- var noteHeadSource = source.querySelector(".notehead");
103
- var noteHeadTarget = target.closest("#interactionOverlay").querySelector("[refId=" + noteHeadSource.id + "]");
104
- simpleTranslate(noteHeadSource, noteHeadTarget);
105
- }
106
- function adjustToBetweenStemNoteheadBounds(source, target) {
107
- var _a, _b;
108
- if (source.classList.contains("chord")) {
109
- var noteHeadSource = Array.from(source.querySelectorAll(".notehead")).reverse()[0];
110
- }
111
- else {
112
- noteHeadSource = source.querySelector(".notehead");
113
- }
114
- var noteHeadTarget = target.closest("#interactionOverlay").querySelector("[refId=" + noteHeadSource.id + "]");
115
- var coordsNoteHead = coordinates.getDOMMatrixCoordinates(noteHeadTarget, target.closest("#interactionOverlay"));
116
- var upperBoundSource = source.querySelector(".stem")
117
- || ((_a = source.closest(".chord")) === null || _a === void 0 ? void 0 : _a.querySelector(".stem"))
118
- || ((_b = source.closest(".chord")) === null || _b === void 0 ? void 0 : _b.querySelector(".notehead"))
119
- || source.querySelector(".notehead");
120
- var upperBoundTarget = target.closest("#interactionOverlay").querySelector("[refId=" + upperBoundSource.id + "]");
121
- var coordsUpperBound = coordinates.getDOMMatrixCoordinates(upperBoundTarget, target.closest("#interactionOverlay"));
122
- var targetWidth;
123
- targetWidth = parseFloat(target.closest("#interactionOverlay").querySelector(".barLine rect").getAttribute("width")) * 2; // very crude heuristic
124
- noteHeadTarget.querySelector("rect").setAttribute("width", targetWidth.toString());
125
- target.setAttribute("width", targetWidth.toString());
126
- target.setAttribute("x", coordsNoteHead.x.toString());
127
- target.setAttribute("y", coordsUpperBound.y.toString());
128
- var noteHeadHeight;
129
- noteHeadHeight = parseFloat(target.closest("#interactionOverlay").querySelector(".barLine rect").getAttribute("width")) * 2; // very crude heuristic
130
- noteHeadTarget.querySelector("rect").setAttribute("height", noteHeadHeight.toString());
131
- coordsNoteHead = coordinates.getDOMMatrixCoordinates(noteHeadTarget, target.closest("#interactionOverlay"));
132
- if (source.querySelector(".stem") !== null) {
133
- adjustHightToLowestStaffLine(source, target);
134
- }
135
- }
136
- function nullifyBBox(target) {
137
- target.setAttribute("width", "1");
138
- target.setAttribute("height", "1");
139
- }
140
- function halfWidth(target) {
141
- var w = parseFloat(target.getAttribute("width")) / 2;
142
- target.setAttribute("width", w.toString());
143
- }