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
@@ -27,7 +27,11 @@ var __assign = (this && this.__assign) || function () {
27
27
  };
28
28
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
29
  if (k2 === undefined) k2 = k;
30
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
31
35
  }) : (function(o, m, k, k2) {
32
36
  if (k2 === undefined) k2 = k;
33
37
  o[k2] = m[k];
@@ -56,12 +60,23 @@ var __values = (this && this.__values) || function(o) {
56
60
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
57
61
  };
58
62
  Object.defineProperty(exports, "__esModule", { value: true });
59
- exports.createAtomView = exports.LeafAtomView = void 0;
63
+ exports.createAtomView = exports.LeafAtomView = exports.GroupView = void 0;
60
64
  var TSU = __importStar(require("@panyam/tsutils"));
61
65
  var core_1 = require("../core");
62
66
  var shapes_1 = require("../shapes");
63
67
  var embelishments_1 = require("./embelishments");
64
68
  var gamakas_1 = require("./gamakas");
69
+ var GroupView = (function (_super) {
70
+ __extends(GroupView, _super);
71
+ function GroupView() {
72
+ return _super !== null && _super.apply(this, arguments) || this;
73
+ }
74
+ GroupView.prototype.createAtomView = function (atom) {
75
+ return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);
76
+ };
77
+ return GroupView;
78
+ }(shapes_1.GroupView));
79
+ exports.GroupView = GroupView;
65
80
  var LeafAtomView = (function (_super) {
66
81
  __extends(LeafAtomView, _super);
67
82
  function LeafAtomView() {
@@ -72,8 +87,11 @@ var LeafAtomView = (function (_super) {
72
87
  _this.bottomSlot = [];
73
88
  return _this;
74
89
  }
90
+ LeafAtomView.prototype.refreshBBox = function () {
91
+ return TSU.DOM.svgBBox(this.rootGroup.element);
92
+ };
75
93
  LeafAtomView.prototype.refreshMinSize = function () {
76
- var out = __assign({}, (this.rootShape || this.glyph).minSize);
94
+ var out = __assign({}, this.rootText.minSize);
77
95
  var totalWidth = this.leftSlot.reduce(function (a, b) { return a + b.minSize.width; }, 0) +
78
96
  this.rightSlot.reduce(function (a, b) { return a + b.minSize.width; }, 0) +
79
97
  this.leftSlot.length +
@@ -87,95 +105,92 @@ var LeafAtomView = (function (_super) {
87
105
  LeafAtomView.prototype.updateBounds = function (x, y, w, h) {
88
106
  return [x, y, NaN, NaN];
89
107
  };
90
- LeafAtomView.prototype.refreshLayout = function () {
108
+ LeafAtomView.prototype.layoutElements = function () {
91
109
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
92
- var x = this.x;
93
- var y = this.y;
94
- this.glyph.setBounds(null, y, null, null, true);
95
- var currX = x;
96
- var currY = y;
97
- if (currX != null) {
110
+ var textSize = this.rootText.minSize;
111
+ var currX = 0;
112
+ var currY = this.hasY ? this.y : 0;
113
+ try {
114
+ for (var _e = __values(this.leftSlot), _f = _e.next(); !_f.done; _f = _e.next()) {
115
+ var emb = _f.value;
116
+ emb.x = currX;
117
+ emb.refreshLayout();
118
+ currX += emb.minSize.width + 1;
119
+ }
120
+ }
121
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
122
+ finally {
98
123
  try {
99
- for (var _e = __values(this.leftSlot), _f = _e.next(); !_f.done; _f = _e.next()) {
100
- var emb = _f.value;
101
- emb.x = currX;
102
- emb.refreshLayout();
103
- currX += emb.minSize.width + 1;
104
- }
124
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
105
125
  }
106
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
107
- finally {
108
- try {
109
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
110
- }
111
- finally { if (e_1) throw e_1.error; }
126
+ finally { if (e_1) throw e_1.error; }
127
+ }
128
+ var textX = currX;
129
+ this.rootText.x = currX;
130
+ this.rootText.refreshLayout();
131
+ currX += this.rootText.minSize.width;
132
+ try {
133
+ for (var _g = __values(this.rightSlot), _h = _g.next(); !_h.done; _h = _g.next()) {
134
+ var emb = _h.value;
135
+ emb.x = currX;
136
+ emb.refreshLayout();
137
+ currX += emb.minSize.width + 1;
112
138
  }
113
- var glyphRoot = this.rootShape || this.glyph;
114
- glyphRoot.x = currX;
115
- glyphRoot.refreshLayout();
116
- currX += glyphRoot.minSize.width;
139
+ }
140
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
141
+ finally {
117
142
  try {
118
- for (var _g = __values(this.rightSlot), _h = _g.next(); !_h.done; _h = _g.next()) {
119
- var emb = _h.value;
120
- emb.x = currX;
121
- emb.refreshLayout();
122
- currX += emb.minSize.width + 1;
123
- }
143
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
124
144
  }
125
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
126
- finally {
127
- try {
128
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
129
- }
130
- finally { if (e_2) throw e_2.error; }
145
+ finally { if (e_2) throw e_2.error; }
146
+ }
147
+ var gminSize = this.glyph.minSize;
148
+ var glyphX = textX + this.glyph.x;
149
+ var glyphY = this.glyph.y;
150
+ currY = glyphY - this.glyph.minSize.height + 5;
151
+ try {
152
+ for (var _j = __values(this.topSlot), _k = _j.next(); !_k.done; _k = _j.next()) {
153
+ var emb = _k.value;
154
+ var bb = emb.minSize;
155
+ emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
156
+ currY = emb.y;
131
157
  }
132
158
  }
133
- if (currX != null || currY != null) {
134
- var gminSize = this.glyph.minSize;
135
- var glyphX = this.glyph.x;
136
- var glyphY = this.glyph.y;
137
- currY = glyphY - 1;
159
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
160
+ finally {
138
161
  try {
139
- for (var _j = __values(this.topSlot), _k = _j.next(); !_k.done; _k = _j.next()) {
140
- var emb = _k.value;
141
- var bb = emb.minSize;
142
- emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
143
- currY = emb.y;
144
- }
162
+ if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
145
163
  }
146
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
147
- finally {
148
- try {
149
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
150
- }
151
- finally { if (e_3) throw e_3.error; }
164
+ finally { if (e_3) throw e_3.error; }
165
+ }
166
+ currY = glyphY + 7;
167
+ try {
168
+ for (var _l = __values(this.bottomSlot), _m = _l.next(); !_m.done; _m = _l.next()) {
169
+ var emb = _m.value;
170
+ var bb = emb.minSize;
171
+ emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
172
+ currY = emb.y + bb.height;
152
173
  }
153
- currY = glyphY + gminSize.height + 2;
174
+ }
175
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
176
+ finally {
154
177
  try {
155
- for (var _l = __values(this.bottomSlot), _m = _l.next(); !_m.done; _m = _l.next()) {
156
- var emb = _m.value;
157
- var bb = emb.minSize;
158
- emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
159
- currY = emb.y + bb.height;
160
- }
161
- }
162
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
163
- finally {
164
- try {
165
- if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
166
- }
167
- finally { if (e_4) throw e_4.error; }
178
+ if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
168
179
  }
180
+ finally { if (e_4) throw e_4.error; }
169
181
  }
170
- this.resetMinSize();
182
+ this.invalidateBounds();
183
+ };
184
+ LeafAtomView.prototype.refreshLayout = function () {
185
+ this.layoutElements();
186
+ this.rootGroup.element.setAttribute("transform", "translate(" + this.x + "," + this.y + ")");
171
187
  };
172
188
  LeafAtomView.prototype.addEmbelishment = function (slot, emb) {
173
189
  slot.push(emb);
174
- this.addShape(emb);
175
190
  };
176
191
  LeafAtomView.prototype.orderEmbelishments = function () {
177
192
  var e_5, _a;
178
- var atom = this.flatAtom.atom;
193
+ var atom = this.leafAtom;
179
194
  if (atom.type != core_1.AtomType.SYLLABLE && atom.type != core_1.AtomType.NOTE) {
180
195
  return;
181
196
  }
@@ -228,86 +243,67 @@ var LeafAtomView = (function (_super) {
228
243
  finally { if (e_5) throw e_5.error; }
229
244
  }
230
245
  };
246
+ LeafAtomView.prototype.embRoot = function () {
247
+ return this.rootGroup.element;
248
+ };
231
249
  LeafAtomView.prototype.needsRootElement = function () {
232
- return this.rightSlot.length > 0 || this.flatAtom.atom.beforeRest;
250
+ return true;
233
251
  };
234
252
  LeafAtomView.prototype.createElements = function (parent) {
235
- var _a;
236
- if (this.needsRootElement()) {
237
- this.createGlyphRoot(parent);
238
- }
239
- this.createGlyphElement(((_a = this.rootShape) === null || _a === void 0 ? void 0 : _a.element) || parent);
253
+ this.createGlyphRoot(parent);
254
+ this.createGlyphElement();
240
255
  this.orderEmbelishments();
241
- if (this.needsRootElement()) {
242
- if (!this.rootShape) {
243
- this.createGlyphRoot(parent);
244
- this.moveGlyphToRoot();
245
- }
246
- this.createPostSpacingElement();
247
- }
248
- this.resetMinSize();
256
+ this.createPostSpacingElement();
257
+ this.invalidateBounds();
249
258
  };
250
259
  LeafAtomView.prototype.createGlyphRoot = function (parent) {
251
- this.rootShape = new shapes_1.ElementShape(TSU.DOM.createSVGNode("tspan", {
260
+ this.rootGroup = new shapes_1.ElementShape(TSU.DOM.createSVGNode("g", {
252
261
  doc: document,
253
262
  parent: parent,
254
263
  attrs: {
255
- depth: this.flatAtom.depth || 0,
256
- atomid: this.flatAtom.atom.uuid,
257
- id: "atomViewRoot" + this.flatAtom.atom.uuid,
264
+ atomid: this.leafAtom.uuid,
265
+ class: "atomViewRootGroup",
266
+ id: "atomViewRootGroup" + this.leafAtom.uuid,
258
267
  },
259
268
  }));
260
- };
261
- LeafAtomView.prototype.createPostSpacingElement = function () {
262
- this.postSpacingSpan = TSU.DOM.createSVGNode("tspan", {
269
+ this.rootText = new shapes_1.ElementShape(TSU.DOM.createSVGNode("text", {
263
270
  doc: document,
264
- parent: this.rootShape.element,
271
+ parent: this.rootGroup.element,
265
272
  attrs: {
266
- depth: this.flatAtom.depth || 0,
267
- atomid: this.flatAtom.atom.uuid,
268
- id: "postSpacing" + this.flatAtom.atom.uuid,
273
+ atomid: this.leafAtom.uuid,
274
+ class: "atomViewTextRoot",
275
+ id: "atomViewTextRoot" + this.leafAtom.uuid,
269
276
  },
270
- text: this.flatAtom.atom.beforeRest ? " - " : " ",
271
- });
272
- };
273
- LeafAtomView.prototype.moveGlyphToRoot = function () {
274
- this.rootShape.element.appendChild(this.glyph.element);
277
+ }));
275
278
  };
276
- LeafAtomView.prototype.createGlyphElement = function (parent) {
277
- var atom = this.flatAtom.atom;
279
+ LeafAtomView.prototype.createGlyphElement = function () {
280
+ var atom = this.leafAtom;
278
281
  this.glyph = new shapes_1.ElementShape(TSU.DOM.createSVGNode("tspan", {
279
282
  doc: document,
280
- parent: parent,
283
+ parent: this.rootText.element,
281
284
  attrs: {
282
- depth: this.flatAtom.depth || 0,
283
285
  atomid: atom.uuid,
284
- id: "atom" + atom.uuid,
286
+ id: "atomGlyph" + atom.uuid,
285
287
  },
286
288
  text: this.glyphLabel,
287
289
  }));
288
290
  };
291
+ LeafAtomView.prototype.createPostSpacingElement = function () {
292
+ if (this.leafAtom.beforeRest) {
293
+ this.postSpacingSpan = TSU.DOM.createSVGNode("tspan", {
294
+ doc: document,
295
+ parent: this.rootText.element,
296
+ attrs: {
297
+ atomid: this.leafAtom.uuid,
298
+ id: "postSpacing" + this.leafAtom.uuid,
299
+ },
300
+ text: this.leafAtom.beforeRest ? " - " : " ",
301
+ });
302
+ }
303
+ };
289
304
  return LeafAtomView;
290
- }(shapes_1.AtomView));
305
+ }(shapes_1.LeafAtomView));
291
306
  exports.LeafAtomView = LeafAtomView;
292
- function createAtomView(parent, atom) {
293
- var out;
294
- switch (atom.atom.type) {
295
- case core_1.AtomType.SPACE:
296
- out = new SpaceView(atom);
297
- break;
298
- case core_1.AtomType.SYLLABLE:
299
- out = new SyllableView(atom);
300
- break;
301
- case core_1.AtomType.NOTE:
302
- out = new NoteView(atom);
303
- break;
304
- default:
305
- throw new Error("Invalid atom type: " + atom.atom.type);
306
- }
307
- out.createElements(parent);
308
- return out;
309
- }
310
- exports.createAtomView = createAtomView;
311
307
  var SpaceView = (function (_super) {
312
308
  __extends(SpaceView, _super);
313
309
  function SpaceView() {
@@ -315,14 +311,20 @@ var SpaceView = (function (_super) {
315
311
  }
316
312
  Object.defineProperty(SpaceView.prototype, "glyphLabel", {
317
313
  get: function () {
318
- return this.space.isSilent ? " " : ",";
314
+ if (this.space.isSilent)
315
+ return " ";
316
+ if (this.space.duration.isOne)
317
+ return ",";
318
+ if (this.space.duration.cmpNum(2) == 0)
319
+ return ";";
320
+ return "_";
319
321
  },
320
322
  enumerable: false,
321
323
  configurable: true
322
324
  });
323
325
  Object.defineProperty(SpaceView.prototype, "space", {
324
326
  get: function () {
325
- return this.flatAtom.atom;
327
+ return this.leafAtom;
326
328
  },
327
329
  enumerable: false,
328
330
  configurable: true
@@ -342,17 +344,17 @@ var NoteView = (function (_super) {
342
344
  configurable: true
343
345
  });
344
346
  NoteView.prototype.needsRootElement = function () {
345
- return this.note.shift == true || this.note.shift != 0 || _super.prototype.needsRootElement.call(this);
347
+ return true;
346
348
  };
347
- NoteView.prototype.createGlyphElement = function (parent) {
348
- _super.prototype.createGlyphElement.call(this, parent);
349
+ NoteView.prototype.createGlyphElement = function () {
350
+ _super.prototype.createGlyphElement.call(this);
349
351
  if (this.note.shift == true || this.note.shift != 0) {
350
352
  this.shiftElement = TSU.DOM.createSVGNode("tspan", {
351
353
  doc: document,
352
- parent: this.rootShape.element,
354
+ parent: this.rootText.element,
353
355
  attrs: {
354
- depth: this.flatAtom.depth || 0,
355
356
  atomid: this.note.uuid,
357
+ class: "noteShiftTSpan",
356
358
  id: "noteShift" + this.note.uuid,
357
359
  "baseline-shift": "sub",
358
360
  },
@@ -361,9 +363,8 @@ var NoteView = (function (_super) {
361
363
  }
362
364
  };
363
365
  NoteView.prototype.moveGlyphToRoot = function () {
364
- _super.prototype.moveGlyphToRoot.call(this);
365
366
  if (this.shiftElement) {
366
- this.rootShape.element.appendChild(this.shiftElement);
367
+ this.rootGroup.element.appendChild(this.shiftElement);
367
368
  }
368
369
  };
369
370
  NoteView.prototype.orderEmbelishments = function () {
@@ -378,7 +379,7 @@ var NoteView = (function (_super) {
378
379
  };
379
380
  Object.defineProperty(NoteView.prototype, "note", {
380
381
  get: function () {
381
- return this.flatAtom.atom;
382
+ return this.leafAtom;
382
383
  },
383
384
  enumerable: false,
384
385
  configurable: true
@@ -399,11 +400,47 @@ var SyllableView = (function (_super) {
399
400
  });
400
401
  Object.defineProperty(SyllableView.prototype, "syllable", {
401
402
  get: function () {
402
- return this.flatAtom.atom;
403
+ return this.leafAtom;
403
404
  },
404
405
  enumerable: false,
405
406
  configurable: true
406
407
  });
407
408
  return SyllableView;
408
409
  }(LeafAtomView));
410
+ function createAtomView(parent, atom, litDefaultsToNote, groupViewScale) {
411
+ if (litDefaultsToNote === void 0) { litDefaultsToNote = false; }
412
+ if (groupViewScale === void 0) { groupViewScale = 1.0; }
413
+ var out;
414
+ switch (atom.type) {
415
+ case core_1.AtomType.SPACE:
416
+ out = new SpaceView(atom);
417
+ break;
418
+ case core_1.AtomType.SYLLABLE:
419
+ out = new SyllableView(atom);
420
+ break;
421
+ case core_1.AtomType.NOTE:
422
+ out = new NoteView(atom);
423
+ break;
424
+ case core_1.AtomType.LITERAL:
425
+ if (litDefaultsToNote) {
426
+ var lit = core_1.Note.fromLit(atom);
427
+ out = new NoteView(lit);
428
+ }
429
+ else {
430
+ var lit = core_1.Syllable.fromLit(atom);
431
+ out = new SyllableView(lit);
432
+ }
433
+ break;
434
+ case core_1.AtomType.GROUP:
435
+ out = new GroupView(atom);
436
+ out.defaultToNotes = litDefaultsToNote;
437
+ out.scaleFactor = groupViewScale;
438
+ break;
439
+ default:
440
+ throw new Error("Invalid atom type: " + atom.type);
441
+ }
442
+ out.createElements(parent);
443
+ return out;
444
+ }
445
+ exports.createAtomView = createAtomView;
409
446
  //# sourceMappingURL=atomviews.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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,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,mDAAuC;AACvC,gCAAgF;AAChF,oCAMmB;AACnB,iDAYyB;AACzB,qCAAuC;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,kBAAa,GAI3C;AAJY,8BAAS;AAMtB;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,I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;KACtD;IACD,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC;AAvCD,wCAuCC","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
  }