notations 0.0.43 → 0.0.46

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 (111) hide show
  1. package/README.md +38 -0
  2. package/lib/cjs/beats.d.ts +111 -0
  3. package/lib/cjs/beats.js +527 -0
  4. package/lib/cjs/beats.js.map +1 -0
  5. package/lib/cjs/carnatic/LineView.d.ts +20 -0
  6. package/lib/cjs/carnatic/LineView.js +73 -0
  7. package/lib/cjs/carnatic/LineView.js.map +1 -0
  8. package/lib/cjs/carnatic/NotationView.d.ts +31 -0
  9. package/lib/cjs/carnatic/NotationView.js +254 -0
  10. package/lib/cjs/carnatic/NotationView.js.map +1 -0
  11. package/lib/cjs/carnatic/atomviews.d.ts +14 -7
  12. package/lib/cjs/carnatic/atomviews.js +175 -138
  13. package/lib/cjs/carnatic/atomviews.js.map +1 -1
  14. package/lib/cjs/carnatic/beatviews.d.ts +10 -14
  15. package/lib/cjs/carnatic/beatviews.js +58 -109
  16. package/lib/cjs/carnatic/beatviews.js.map +1 -1
  17. package/lib/cjs/carnatic/embelishments.d.ts +38 -32
  18. package/lib/cjs/carnatic/embelishments.js +39 -20
  19. package/lib/cjs/carnatic/embelishments.js.map +1 -1
  20. package/lib/cjs/carnatic/index.d.ts +2 -0
  21. package/lib/cjs/carnatic/index.js +7 -1
  22. package/lib/cjs/carnatic/index.js.map +1 -1
  23. package/lib/cjs/commands.js +5 -1
  24. package/lib/cjs/commands.js.map +1 -1
  25. package/lib/cjs/core.d.ts +15 -73
  26. package/lib/cjs/core.js +201 -565
  27. package/lib/cjs/core.js.map +1 -1
  28. package/lib/cjs/cycle.d.ts +47 -0
  29. package/lib/cjs/cycle.js +496 -0
  30. package/lib/cjs/cycle.js.map +1 -0
  31. package/lib/cjs/entity.d.ts +24 -0
  32. package/lib/cjs/entity.js +135 -0
  33. package/lib/cjs/entity.js.map +1 -0
  34. package/lib/cjs/index.d.ts +3 -0
  35. package/lib/cjs/index.js +8 -1
  36. package/lib/cjs/index.js.map +1 -1
  37. package/lib/cjs/iterators.d.ts +14 -2
  38. package/lib/cjs/iterators.js +82 -6
  39. package/lib/cjs/iterators.js.map +1 -1
  40. package/lib/cjs/layouts.d.ts +7 -106
  41. package/lib/cjs/layouts.js +9 -479
  42. package/lib/cjs/layouts.js.map +1 -1
  43. package/lib/cjs/loader.d.ts +2 -1
  44. package/lib/cjs/loader.js +36 -27
  45. package/lib/cjs/loader.js.map +1 -1
  46. package/lib/cjs/notation.d.ts +3 -1
  47. package/lib/cjs/notation.js +6 -4
  48. package/lib/cjs/notation.js.map +1 -1
  49. package/lib/cjs/parser.js +10 -5
  50. package/lib/cjs/parser.js.map +1 -1
  51. package/lib/cjs/shapes.d.ts +35 -14
  52. package/lib/cjs/shapes.js +158 -44
  53. package/lib/cjs/shapes.js.map +1 -1
  54. package/lib/cjs/utils.d.ts +2 -1
  55. package/lib/cjs/utils.js +9 -4
  56. package/lib/cjs/utils.js.map +1 -1
  57. package/lib/esm/beats.d.ts +111 -0
  58. package/lib/esm/beats.js +501 -0
  59. package/lib/esm/beats.js.map +1 -0
  60. package/lib/esm/carnatic/LineView.d.ts +20 -0
  61. package/lib/esm/carnatic/LineView.js +47 -0
  62. package/lib/esm/carnatic/LineView.js.map +1 -0
  63. package/lib/esm/carnatic/NotationView.d.ts +31 -0
  64. package/lib/esm/carnatic/NotationView.js +228 -0
  65. package/lib/esm/carnatic/NotationView.js.map +1 -0
  66. package/lib/esm/carnatic/atomviews.d.ts +14 -7
  67. package/lib/esm/carnatic/atomviews.js +170 -137
  68. package/lib/esm/carnatic/atomviews.js.map +1 -1
  69. package/lib/esm/carnatic/beatviews.d.ts +10 -14
  70. package/lib/esm/carnatic/beatviews.js +54 -109
  71. package/lib/esm/carnatic/beatviews.js.map +1 -1
  72. package/lib/esm/carnatic/embelishments.d.ts +38 -32
  73. package/lib/esm/carnatic/embelishments.js +33 -18
  74. package/lib/esm/carnatic/embelishments.js.map +1 -1
  75. package/lib/esm/carnatic/index.d.ts +2 -0
  76. package/lib/esm/carnatic/index.js +2 -0
  77. package/lib/esm/carnatic/index.js.map +1 -1
  78. package/lib/esm/core.d.ts +15 -73
  79. package/lib/esm/core.js +192 -560
  80. package/lib/esm/core.js.map +1 -1
  81. package/lib/esm/cycle.d.ts +47 -0
  82. package/lib/esm/cycle.js +470 -0
  83. package/lib/esm/cycle.js.map +1 -0
  84. package/lib/esm/entity.d.ts +24 -0
  85. package/lib/esm/entity.js +132 -0
  86. package/lib/esm/entity.js.map +1 -0
  87. package/lib/esm/index.d.ts +3 -0
  88. package/lib/esm/index.js +3 -0
  89. package/lib/esm/index.js.map +1 -1
  90. package/lib/esm/iterators.d.ts +14 -2
  91. package/lib/esm/iterators.js +73 -1
  92. package/lib/esm/iterators.js.map +1 -1
  93. package/lib/esm/layouts.d.ts +7 -106
  94. package/lib/esm/layouts.js +1 -475
  95. package/lib/esm/layouts.js.map +1 -1
  96. package/lib/esm/loader.d.ts +2 -1
  97. package/lib/esm/loader.js +27 -23
  98. package/lib/esm/loader.js.map +1 -1
  99. package/lib/esm/notation.d.ts +3 -1
  100. package/lib/esm/notation.js +3 -1
  101. package/lib/esm/notation.js.map +1 -1
  102. package/lib/esm/parser.js +5 -4
  103. package/lib/esm/parser.js.map +1 -1
  104. package/lib/esm/shapes.d.ts +35 -14
  105. package/lib/esm/shapes.js +152 -42
  106. package/lib/esm/shapes.js.map +1 -1
  107. package/lib/esm/utils.d.ts +2 -1
  108. package/lib/esm/utils.js +3 -2
  109. package/lib/esm/utils.js.map +1 -1
  110. package/package.json +33 -28
  111. package/styles/NotationView.scss +35 -0
@@ -36,10 +36,21 @@ var __values = (this && this.__values) || function(o) {
36
36
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
37
  };
38
38
  import * as TSU from "@panyam/tsutils";
39
- import { AtomType } from "../core";
40
- import { AtomView, ElementShape } from "../shapes";
39
+ import { AtomType, Note, Syllable } from "../core";
40
+ import { LeafAtomView as LeafAtomViewBase, GroupView as GroupViewBase, ElementShape, } from "../shapes";
41
41
  import { OctaveIndicator, Kampitham, Nokku, Spuritham, Prathyagatham, Orikkai, Odukkal, Raavi, Kandippu, Vaali, Jaaru, } from "./embelishments";
42
42
  import { GamakaType } from "./gamakas";
43
+ var GroupView = (function (_super) {
44
+ __extends(GroupView, _super);
45
+ function GroupView() {
46
+ return _super !== null && _super.apply(this, arguments) || this;
47
+ }
48
+ GroupView.prototype.createAtomView = function (atom) {
49
+ return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);
50
+ };
51
+ return GroupView;
52
+ }(GroupViewBase));
53
+ export { GroupView };
43
54
  var LeafAtomView = (function (_super) {
44
55
  __extends(LeafAtomView, _super);
45
56
  function LeafAtomView() {
@@ -50,8 +61,11 @@ var LeafAtomView = (function (_super) {
50
61
  _this.bottomSlot = [];
51
62
  return _this;
52
63
  }
64
+ LeafAtomView.prototype.refreshBBox = function () {
65
+ return TSU.DOM.svgBBox(this.rootGroup.element);
66
+ };
53
67
  LeafAtomView.prototype.refreshMinSize = function () {
54
- var out = __assign({}, (this.rootShape || this.glyph).minSize);
68
+ var out = __assign({}, this.rootText.minSize);
55
69
  var totalWidth = this.leftSlot.reduce(function (a, b) { return a + b.minSize.width; }, 0) +
56
70
  this.rightSlot.reduce(function (a, b) { return a + b.minSize.width; }, 0) +
57
71
  this.leftSlot.length +
@@ -65,95 +79,92 @@ var LeafAtomView = (function (_super) {
65
79
  LeafAtomView.prototype.updateBounds = function (x, y, w, h) {
66
80
  return [x, y, NaN, NaN];
67
81
  };
68
- LeafAtomView.prototype.refreshLayout = function () {
82
+ LeafAtomView.prototype.layoutElements = function () {
69
83
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
70
- var x = this.x;
71
- var y = this.y;
72
- this.glyph.setBounds(null, y, null, null, true);
73
- var currX = x;
74
- var currY = y;
75
- if (currX != null) {
84
+ var textSize = this.rootText.minSize;
85
+ var currX = 0;
86
+ var currY = this.hasY ? this.y : 0;
87
+ try {
88
+ for (var _e = __values(this.leftSlot), _f = _e.next(); !_f.done; _f = _e.next()) {
89
+ var emb = _f.value;
90
+ emb.x = currX;
91
+ emb.refreshLayout();
92
+ currX += emb.minSize.width + 1;
93
+ }
94
+ }
95
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
96
+ finally {
76
97
  try {
77
- for (var _e = __values(this.leftSlot), _f = _e.next(); !_f.done; _f = _e.next()) {
78
- var emb = _f.value;
79
- emb.x = currX;
80
- emb.refreshLayout();
81
- currX += emb.minSize.width + 1;
82
- }
98
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
83
99
  }
84
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
85
- finally {
86
- try {
87
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
88
- }
89
- finally { if (e_1) throw e_1.error; }
100
+ finally { if (e_1) throw e_1.error; }
101
+ }
102
+ var textX = currX;
103
+ this.rootText.x = currX;
104
+ this.rootText.refreshLayout();
105
+ currX += this.rootText.minSize.width;
106
+ try {
107
+ for (var _g = __values(this.rightSlot), _h = _g.next(); !_h.done; _h = _g.next()) {
108
+ var emb = _h.value;
109
+ emb.x = currX;
110
+ emb.refreshLayout();
111
+ currX += emb.minSize.width + 1;
90
112
  }
91
- var glyphRoot = this.rootShape || this.glyph;
92
- glyphRoot.x = currX;
93
- glyphRoot.refreshLayout();
94
- currX += glyphRoot.minSize.width;
113
+ }
114
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
115
+ finally {
95
116
  try {
96
- for (var _g = __values(this.rightSlot), _h = _g.next(); !_h.done; _h = _g.next()) {
97
- var emb = _h.value;
98
- emb.x = currX;
99
- emb.refreshLayout();
100
- currX += emb.minSize.width + 1;
101
- }
117
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
102
118
  }
103
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
104
- finally {
105
- try {
106
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
107
- }
108
- finally { if (e_2) throw e_2.error; }
119
+ finally { if (e_2) throw e_2.error; }
120
+ }
121
+ var gminSize = this.glyph.minSize;
122
+ var glyphX = textX + this.glyph.x;
123
+ var glyphY = this.glyph.y;
124
+ currY = glyphY - this.glyph.minSize.height + 5;
125
+ try {
126
+ for (var _j = __values(this.topSlot), _k = _j.next(); !_k.done; _k = _j.next()) {
127
+ var emb = _k.value;
128
+ var bb = emb.minSize;
129
+ emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
130
+ currY = emb.y;
109
131
  }
110
132
  }
111
- if (currX != null || currY != null) {
112
- var gminSize = this.glyph.minSize;
113
- var glyphX = this.glyph.x;
114
- var glyphY = this.glyph.y;
115
- currY = glyphY - 1;
133
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
134
+ finally {
116
135
  try {
117
- for (var _j = __values(this.topSlot), _k = _j.next(); !_k.done; _k = _j.next()) {
118
- var emb = _k.value;
119
- var bb = emb.minSize;
120
- emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
121
- currY = emb.y;
122
- }
136
+ if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
123
137
  }
124
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
125
- finally {
126
- try {
127
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
128
- }
129
- finally { if (e_3) throw e_3.error; }
138
+ finally { if (e_3) throw e_3.error; }
139
+ }
140
+ currY = glyphY + 7;
141
+ try {
142
+ for (var _l = __values(this.bottomSlot), _m = _l.next(); !_m.done; _m = _l.next()) {
143
+ var emb = _m.value;
144
+ var bb = emb.minSize;
145
+ emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
146
+ currY = emb.y + bb.height;
130
147
  }
131
- currY = glyphY + gminSize.height + 2;
148
+ }
149
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
150
+ finally {
132
151
  try {
133
- for (var _l = __values(this.bottomSlot), _m = _l.next(); !_m.done; _m = _l.next()) {
134
- var emb = _m.value;
135
- var bb = emb.minSize;
136
- emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
137
- currY = emb.y + bb.height;
138
- }
139
- }
140
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
141
- finally {
142
- try {
143
- if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
144
- }
145
- finally { if (e_4) throw e_4.error; }
152
+ if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
146
153
  }
154
+ finally { if (e_4) throw e_4.error; }
147
155
  }
148
- this.resetMinSize();
156
+ this.invalidateBounds();
157
+ };
158
+ LeafAtomView.prototype.refreshLayout = function () {
159
+ this.layoutElements();
160
+ this.rootGroup.element.setAttribute("transform", "translate(" + this.x + "," + this.y + ")");
149
161
  };
150
162
  LeafAtomView.prototype.addEmbelishment = function (slot, emb) {
151
163
  slot.push(emb);
152
- this.addShape(emb);
153
164
  };
154
165
  LeafAtomView.prototype.orderEmbelishments = function () {
155
166
  var e_5, _a;
156
- var atom = this.flatAtom.atom;
167
+ var atom = this.leafAtom;
157
168
  if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {
158
169
  return;
159
170
  }
@@ -206,85 +217,67 @@ var LeafAtomView = (function (_super) {
206
217
  finally { if (e_5) throw e_5.error; }
207
218
  }
208
219
  };
220
+ LeafAtomView.prototype.embRoot = function () {
221
+ return this.rootGroup.element;
222
+ };
209
223
  LeafAtomView.prototype.needsRootElement = function () {
210
- return this.rightSlot.length > 0 || this.flatAtom.atom.beforeRest;
224
+ return true;
211
225
  };
212
226
  LeafAtomView.prototype.createElements = function (parent) {
213
- var _a;
214
- if (this.needsRootElement()) {
215
- this.createGlyphRoot(parent);
216
- }
217
- this.createGlyphElement(((_a = this.rootShape) === null || _a === void 0 ? void 0 : _a.element) || parent);
227
+ this.createGlyphRoot(parent);
228
+ this.createGlyphElement();
218
229
  this.orderEmbelishments();
219
- if (this.needsRootElement()) {
220
- if (!this.rootShape) {
221
- this.createGlyphRoot(parent);
222
- this.moveGlyphToRoot();
223
- }
224
- this.createPostSpacingElement();
225
- }
226
- this.resetMinSize();
230
+ this.createPostSpacingElement();
231
+ this.invalidateBounds();
227
232
  };
228
233
  LeafAtomView.prototype.createGlyphRoot = function (parent) {
229
- this.rootShape = new ElementShape(TSU.DOM.createSVGNode("tspan", {
234
+ this.rootGroup = new ElementShape(TSU.DOM.createSVGNode("g", {
230
235
  doc: document,
231
236
  parent: parent,
232
237
  attrs: {
233
- depth: this.flatAtom.depth || 0,
234
- atomid: this.flatAtom.atom.uuid,
235
- id: "atomViewRoot" + this.flatAtom.atom.uuid,
238
+ atomid: this.leafAtom.uuid,
239
+ class: "atomViewRootGroup",
240
+ id: "atomViewRootGroup" + this.leafAtom.uuid,
236
241
  },
237
242
  }));
238
- };
239
- LeafAtomView.prototype.createPostSpacingElement = function () {
240
- this.postSpacingSpan = TSU.DOM.createSVGNode("tspan", {
243
+ this.rootText = new ElementShape(TSU.DOM.createSVGNode("text", {
241
244
  doc: document,
242
- parent: this.rootShape.element,
245
+ parent: this.rootGroup.element,
243
246
  attrs: {
244
- depth: this.flatAtom.depth || 0,
245
- atomid: this.flatAtom.atom.uuid,
246
- id: "postSpacing" + this.flatAtom.atom.uuid,
247
+ atomid: this.leafAtom.uuid,
248
+ class: "atomViewTextRoot",
249
+ id: "atomViewTextRoot" + this.leafAtom.uuid,
247
250
  },
248
- text: this.flatAtom.atom.beforeRest ? " - " : " ",
249
- });
250
- };
251
- LeafAtomView.prototype.moveGlyphToRoot = function () {
252
- this.rootShape.element.appendChild(this.glyph.element);
251
+ }));
253
252
  };
254
- LeafAtomView.prototype.createGlyphElement = function (parent) {
255
- var atom = this.flatAtom.atom;
253
+ LeafAtomView.prototype.createGlyphElement = function () {
254
+ var atom = this.leafAtom;
256
255
  this.glyph = new ElementShape(TSU.DOM.createSVGNode("tspan", {
257
256
  doc: document,
258
- parent: parent,
257
+ parent: this.rootText.element,
259
258
  attrs: {
260
- depth: this.flatAtom.depth || 0,
261
259
  atomid: atom.uuid,
262
- id: "atom" + atom.uuid,
260
+ id: "atomGlyph" + atom.uuid,
263
261
  },
264
262
  text: this.glyphLabel,
265
263
  }));
266
264
  };
265
+ LeafAtomView.prototype.createPostSpacingElement = function () {
266
+ if (this.leafAtom.beforeRest) {
267
+ this.postSpacingSpan = TSU.DOM.createSVGNode("tspan", {
268
+ doc: document,
269
+ parent: this.rootText.element,
270
+ attrs: {
271
+ atomid: this.leafAtom.uuid,
272
+ id: "postSpacing" + this.leafAtom.uuid,
273
+ },
274
+ text: this.leafAtom.beforeRest ? " - " : " ",
275
+ });
276
+ }
277
+ };
267
278
  return LeafAtomView;
268
- }(AtomView));
279
+ }(LeafAtomViewBase));
269
280
  export { LeafAtomView };
270
- export function createAtomView(parent, atom) {
271
- var out;
272
- switch (atom.atom.type) {
273
- case AtomType.SPACE:
274
- out = new SpaceView(atom);
275
- break;
276
- case AtomType.SYLLABLE:
277
- out = new SyllableView(atom);
278
- break;
279
- case AtomType.NOTE:
280
- out = new NoteView(atom);
281
- break;
282
- default:
283
- throw new Error("Invalid atom type: " + atom.atom.type);
284
- }
285
- out.createElements(parent);
286
- return out;
287
- }
288
281
  var SpaceView = (function (_super) {
289
282
  __extends(SpaceView, _super);
290
283
  function SpaceView() {
@@ -292,14 +285,20 @@ var SpaceView = (function (_super) {
292
285
  }
293
286
  Object.defineProperty(SpaceView.prototype, "glyphLabel", {
294
287
  get: function () {
295
- return this.space.isSilent ? " " : ",";
288
+ if (this.space.isSilent)
289
+ return " ";
290
+ if (this.space.duration.isOne)
291
+ return ",";
292
+ if (this.space.duration.cmpNum(2) == 0)
293
+ return ";";
294
+ return "_";
296
295
  },
297
296
  enumerable: false,
298
297
  configurable: true
299
298
  });
300
299
  Object.defineProperty(SpaceView.prototype, "space", {
301
300
  get: function () {
302
- return this.flatAtom.atom;
301
+ return this.leafAtom;
303
302
  },
304
303
  enumerable: false,
305
304
  configurable: true
@@ -319,17 +318,17 @@ var NoteView = (function (_super) {
319
318
  configurable: true
320
319
  });
321
320
  NoteView.prototype.needsRootElement = function () {
322
- return this.note.shift == true || this.note.shift != 0 || _super.prototype.needsRootElement.call(this);
321
+ return true;
323
322
  };
324
- NoteView.prototype.createGlyphElement = function (parent) {
325
- _super.prototype.createGlyphElement.call(this, parent);
323
+ NoteView.prototype.createGlyphElement = function () {
324
+ _super.prototype.createGlyphElement.call(this);
326
325
  if (this.note.shift == true || this.note.shift != 0) {
327
326
  this.shiftElement = TSU.DOM.createSVGNode("tspan", {
328
327
  doc: document,
329
- parent: this.rootShape.element,
328
+ parent: this.rootText.element,
330
329
  attrs: {
331
- depth: this.flatAtom.depth || 0,
332
330
  atomid: this.note.uuid,
331
+ class: "noteShiftTSpan",
333
332
  id: "noteShift" + this.note.uuid,
334
333
  "baseline-shift": "sub",
335
334
  },
@@ -338,9 +337,8 @@ var NoteView = (function (_super) {
338
337
  }
339
338
  };
340
339
  NoteView.prototype.moveGlyphToRoot = function () {
341
- _super.prototype.moveGlyphToRoot.call(this);
342
340
  if (this.shiftElement) {
343
- this.rootShape.element.appendChild(this.shiftElement);
341
+ this.rootGroup.element.appendChild(this.shiftElement);
344
342
  }
345
343
  };
346
344
  NoteView.prototype.orderEmbelishments = function () {
@@ -355,7 +353,7 @@ var NoteView = (function (_super) {
355
353
  };
356
354
  Object.defineProperty(NoteView.prototype, "note", {
357
355
  get: function () {
358
- return this.flatAtom.atom;
356
+ return this.leafAtom;
359
357
  },
360
358
  enumerable: false,
361
359
  configurable: true
@@ -376,11 +374,46 @@ var SyllableView = (function (_super) {
376
374
  });
377
375
  Object.defineProperty(SyllableView.prototype, "syllable", {
378
376
  get: function () {
379
- return this.flatAtom.atom;
377
+ return this.leafAtom;
380
378
  },
381
379
  enumerable: false,
382
380
  configurable: true
383
381
  });
384
382
  return SyllableView;
385
383
  }(LeafAtomView));
384
+ export function createAtomView(parent, atom, litDefaultsToNote, groupViewScale) {
385
+ if (litDefaultsToNote === void 0) { litDefaultsToNote = false; }
386
+ if (groupViewScale === void 0) { groupViewScale = 1.0; }
387
+ var out;
388
+ switch (atom.type) {
389
+ case AtomType.SPACE:
390
+ out = new SpaceView(atom);
391
+ break;
392
+ case AtomType.SYLLABLE:
393
+ out = new SyllableView(atom);
394
+ break;
395
+ case AtomType.NOTE:
396
+ out = new NoteView(atom);
397
+ break;
398
+ case AtomType.LITERAL:
399
+ if (litDefaultsToNote) {
400
+ var lit = Note.fromLit(atom);
401
+ out = new NoteView(lit);
402
+ }
403
+ else {
404
+ var lit = Syllable.fromLit(atom);
405
+ out = new SyllableView(lit);
406
+ }
407
+ break;
408
+ case AtomType.GROUP:
409
+ out = new GroupView(atom);
410
+ out.defaultToNotes = litDefaultsToNote;
411
+ out.scaleFactor = groupViewScale;
412
+ break;
413
+ default:
414
+ throw new Error("Invalid atom type: " + atom.type);
415
+ }
416
+ out.createElements(parent);
417
+ return out;
418
+ }
386
419
  //# sourceMappingURL=atomviews.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAW,QAAQ,EAAyB,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAgB,YAAY,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;IAA2C,gCAAQ;IAAnD;QAAA,qEA6NC;QA5NC,cAAQ,GAAmB,EAAE,CAAC;QAC9B,aAAO,GAAmB,EAAE,CAAC;QAC7B,eAAS,GAAmB,E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C,GAAG,GAAG;aAC9D,CAAC,CAAC;SACJ;IACH,CAAC;IAES,kCAAe,GAAzB;QACE,iBAAM,eAAe,WAAE,CAAC;QACxB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACvD;IACH,CAAC;IAED,qCAAkB,GAAlB;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;SACpD;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;SACvD;QACD,iBAAM,kBAAkB,WAAE,CAAC;IAC7B,CAAC;IAED,sBAAI,0BAAI;aAAR;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAY,CAAC;QACpC,CAAC;;;OAAA;IACH,eAAC;AAAD,CAAC,AAhDD,CAAuB,YAAY,GAgDlC;AAED;IAA2B,gCAAY;IAAvC;;IAQA,CAAC;IAPC,sBAAI,oCAAU;aAAd;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,CAAC;;;OAAA;IAED,sBAAI,kCAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAgB,CAAC;QACxC,CAAC;;;OAAA;IACH,mBAAC;AAAD,CAAC,AARD,CAA2B,YAAY,GAQtC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport { AtomView, Embelishment, ElementShape } from \"../shapes\";\nimport { FlatAtom } from \"../iterators\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport abstract class LeafAtomView extends AtomView {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootShape: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...(this.rootShape || this.glyph).minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n const x = this.x;\n const y = this.y;\n this.glyph.setBounds(null, y, null, null, true);\n\n // now layout leftSlots\n let currX = x;\n let currY = y;\n if (currX != null) {\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the glyph\n const glyphRoot = this.rootShape || this.glyph;\n glyphRoot.x = currX;\n glyphRoot.refreshLayout();\n currX += glyphRoot.minSize.width;\n\n // And right embelishments\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n }\n\n // layout top and bottom if x or y has changed\n if (currX != null || currY != null) {\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - 1;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + gminSize.height + 2;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n }\n this.resetMinSize();\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.flatAtom.atom;\n if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n needsRootElement(): boolean {\n return this.rightSlot.length > 0 || this.flatAtom.atom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n if (this.needsRootElement()) {\n this.createGlyphRoot(parent);\n }\n this.createGlyphElement(this.rootShape?.element || parent);\n\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n if (this.needsRootElement()) {\n // create as 2 sub span elements\n if (!this.rootShape) {\n this.createGlyphRoot(parent);\n // move the element into the parent\n this.moveGlyphToRoot();\n }\n\n this.createPostSpacingElement();\n }\n this.resetMinSize();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootShape = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: parent,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: this.flatAtom.atom.uuid,\n id: \"atomViewRoot\" + this.flatAtom.atom.uuid,\n },\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootShape.element,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: this.flatAtom.atom.uuid,\n id: \"postSpacing\" + this.flatAtom.atom.uuid,\n },\n text: this.flatAtom.atom.beforeRest ? \" - \" : \" \",\n });\n }\n\n protected moveGlyphToRoot(): void {\n this.rootShape.element.appendChild(this.glyph.element);\n }\n\n protected createGlyphElement(parent: SVGGraphicsElement): void {\n const atom = this.flatAtom.atom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: parent,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: atom.uuid,\n id: \"atom\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n}\n\nexport function createAtomView(parent: SVGGraphicsElement, atom: FlatAtom): AtomView {\n let out: AtomView;\n switch (atom.atom.type) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom);\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.atom.type);\n }\n out.createElements(parent);\n return out;\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n return this.space.isSilent ? \" \" : \",\";\n }\n\n get space(): Space {\n return this.flatAtom.atom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(parent: SVGGraphicsElement): void {\n super.createGlyphElement(parent);\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootShape.element,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: this.note.uuid,\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootShape.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.flatAtom.atom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.flatAtom.atom as Syllable;\n }\n}\n"]}
1
+ {"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAwB,QAAQ,EAAE,IAAI,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,SAAS,IAAI,aAAa,EAG1B,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;IAA+B,6BAAa;IAA5C;;IAIA,CAAC;IAHC,kCAAc,GAAd,UAAe,IAAU;QACvB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;IACH,gBAAC;AAAD,CAAC,AAJD,CAA+B,aAAa,GAI3C;;AAED;IAA2C,gCAAgB;IAA3D;QAAA,qEAmOC;QAlOC,cAAQ,GAAmB,EAAE,CAAC;QAC9B,aAAO,GAAmB,EAAE,CAAC;QAC7B,eAAS,GAAmB,EAAE,CAAC;QAC/B,gBAAU,GAAmB,EAAE,CAAC;;IA+NlC,CAAC;IAnNW,kCAAW,GAArB;QACE,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAES,qCAAc,GAAxB;QACE,IAAM,GAAG,gBAAQ,IAAI,CAAC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IAC3B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Group, Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport {\n LeafAtomView as LeafAtomViewBase,\n GroupView as GroupViewBase,\n AtomView,\n Embelishment,\n ElementShape,\n} from \"../shapes\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport class GroupView extends GroupViewBase {\n createAtomView(atom: Atom): AtomView {\n return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);\n }\n}\n\nexport abstract class LeafAtomView extends LeafAtomViewBase {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n glyph: ElementShape;\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootGroup: ElementShape;\n protected rootText: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.rootGroup.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...this.rootText.minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n\n protected layoutElements(): void {\n // Lays out all the child elements locally\n const textSize = this.rootText.minSize;\n // assume text is at 0,0 and lay things around it\n\n // now layout leftSlots\n let currX = 0;\n let currY = this.hasY ? this.y : 0;\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the text\n const textX = currX;\n this.rootText.x = currX;\n this.rootText.refreshLayout();\n\n // And right embelishments\n currX += this.rootText.minSize.width;\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // layout top and bottom if x or y has changed\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = textX + this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - this.glyph.minSize.height + 5;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + 7;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n this.invalidateBounds();\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.layoutElements();\n this.rootGroup.element.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n // this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.leafAtom;\n if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n embRoot(): SVGGraphicsElement {\n return this.rootGroup.element;\n }\n\n needsRootElement(): boolean {\n return true; // this.rightSlot.length > 0 || this.leafAtom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n this.createGlyphRoot(parent);\n this.createGlyphElement();\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n this.createPostSpacingElement();\n this.invalidateBounds();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootGroup = new ElementShape(\n TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: parent,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewRootGroup\",\n id: \"atomViewRootGroup\" + this.leafAtom.uuid,\n },\n }),\n );\n this.rootText = new ElementShape(\n TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: this.rootGroup.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewTextRoot\",\n id: \"atomViewTextRoot\" + this.leafAtom.uuid,\n },\n }),\n );\n }\n\n protected createGlyphElement(): void {\n const atom = this.leafAtom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: atom.uuid,\n id: \"atomGlyph\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n if (this.leafAtom.beforeRest) {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n id: \"postSpacing\" + this.leafAtom.uuid,\n },\n text: this.leafAtom.beforeRest ? \" - \" : \" \",\n });\n }\n }\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n if (this.space.isSilent) return \" \";\n if (this.space.duration.isOne) return \",\";\n if (this.space.duration.cmpNum(2) == 0) return \";\";\n return \"_\";\n }\n\n get space(): Space {\n return this.leafAtom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return true; // this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(): void {\n super.createGlyphElement();\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.note.uuid,\n class: \"noteShiftTSpan\",\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n // super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootGroup.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.leafAtom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.leafAtom as Syllable;\n }\n}\n\nexport function createAtomView(\n parent: SVGGraphicsElement,\n atom: Atom,\n litDefaultsToNote = false,\n groupViewScale = 1.0,\n): AtomView {\n let out: AtomView;\n switch (atom.type) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom as Space);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom as Syllable);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom as Note);\n break;\n case AtomType.LITERAL:\n if (litDefaultsToNote) {\n const lit = Note.fromLit(atom as Note);\n out = new NoteView(lit);\n } else {\n const lit = Syllable.fromLit(atom as Syllable);\n out = new SyllableView(lit);\n }\n break;\n case AtomType.GROUP:\n out = new GroupView(atom as Group);\n (out as GroupView).defaultToNotes = litDefaultsToNote;\n (out as GroupView).scaleFactor = groupViewScale;\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.type);\n }\n out.createElements(parent);\n return out;\n}\n"]}
@@ -1,20 +1,16 @@
1
- import * as TSU from "@panyam/tsutils";
2
- import { Cycle } from "../core";
3
- import { BeatView as BeatViewBase, Beat } from "../layouts";
4
- import { Embelishment, Shape } from "../shapes";
5
- export declare class BeatView extends Shape implements BeatViewBase {
1
+ import { Cycle } from "../cycle";
2
+ import { BeatView as BeatViewBase, Beat } from "../beats";
3
+ import { AtomView, Embelishment, ElementShape } from "../shapes";
4
+ export declare class BeatView extends ElementShape<SVGGElement> implements BeatViewBase {
6
5
  readonly beat: Beat;
6
+ readonly rootElement: SVGGraphicsElement;
7
7
  readonly cycle: Cycle;
8
- protected atomSpacing: number;
9
- needsLayout: boolean;
10
8
  private _embelishments;
11
- private atomViews;
12
- groupElement: SVGGElement;
13
- textElement: SVGTextElement;
14
- constructor(beat: Beat, rootElement: Element, cycle: Cycle, config?: any);
15
- protected refreshMinSize(): TSU.Geom.Size;
16
- protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
17
- setStyles(config: any): void;
9
+ atomView: AtomView;
10
+ needsLayout: boolean;
11
+ constructor(beat: Beat, rootElement: SVGGraphicsElement, cycle: Cycle, config?: any);
18
12
  refreshLayout(): void;
19
13
  get embelishments(): Embelishment[];
14
+ protected createEmbelishments(): Embelishment[];
15
+ setStyles(config: any): void;
20
16
  }