notations 0.0.43 → 0.0.44

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.
@@ -172,13 +172,15 @@ var BeatView = (function (_super) {
172
172
  var cycle = this.cycle;
173
173
  var bar = cycle.bars[beat.barIndex];
174
174
  if (beat.beatIndex == bar.beatCount - 1) {
175
- if (beat.barIndex == cycle.bars.length - 1) {
176
- var emb = new embelishments_1.BeatEndLines(this, rootElement, 2);
177
- this._embelishments = [emb];
178
- }
179
- else {
180
- var emb = new embelishments_1.BeatEndLines(this, rootElement);
181
- this._embelishments = [emb];
175
+ if (beat.instance == bar.beatCounts[beat.beatIndex] - 1) {
176
+ if (beat.barIndex == cycle.bars.length - 1) {
177
+ var emb = new embelishments_1.BeatEndLines(this, rootElement, 2);
178
+ this._embelishments = [emb];
179
+ }
180
+ else {
181
+ var emb = new embelishments_1.BeatEndLines(this, rootElement);
182
+ this._embelishments = [emb];
183
+ }
182
184
  }
183
185
  }
184
186
  }
@@ -1 +1 @@
1
- {"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnatic/beatviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,gCAAmE;AAEnE,oCAA0D;AAC1D,yCAA6C;AAC7C,iDAA+D;AAE/D;IAA8B,4BAAK;IAOjC,kBAA4B,IAAU,EAAE,WAAoB,EAAkB,KAAY,EAAE,MAAY;;QAAxG,YACE,iBAAO,SA+CR;QAhD2B,UAAI,GAAJ,IAAI,CAAM;QAAwC,WAAK,GAAL,KAAK,CAAO;QAL1F,iBAAW,GAAG,IAAI,CAAC;QAEX,eAAS,GAAe,EAAE,CAAC;QAKjC,KAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,KAAI,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YAC7C,MAAM,EAAE,WA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IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBAGtC,IAAI,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE;wBACvC,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;4BAE1C,IAAM,GAAG,GAAG,IAAI,4BAAY,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;4BACnD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;yBAC7B;6BAAM;4BAEL,IAAM,GAAG,GAAG,IAAI,4BAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;4BAChD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;yBAC7B;qBACF;iBACF;aACF;YACD,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;;;OAAA;IACH,eAAC;AAAD,CAAC,AApID,CAA8B,cAAK,GAoIlC;AApIY,4BAAQ","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Cycle, AtomType, Syllable, Note, Literal } from \"../core\";\nimport { BeatView as BeatViewBase, Beat } from \"../layouts\";\nimport { AtomView, Embelishment, Shape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class BeatView extends Shape implements BeatViewBase {\n protected atomSpacing: number;\n needsLayout = true;\n private _embelishments: Embelishment[];\n private atomViews: AtomView[] = [];\n groupElement: SVGGElement;\n textElement: SVGTextElement;\n constructor(public readonly beat: Beat, rootElement: Element, public readonly cycle: Cycle, config?: any) {\n super();\n this.atomSpacing = 5;\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n beatId: beat.uuid,\n id: \"beatGroup\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n });\n this.textElement = TSU.DOM.createSVGNode(\"text\", {\n parent: this.groupElement,\n attrs: {\n class: \"roleAtomsText\",\n // y: \"0%\",\n style: \"dominant-baseline: hanging\",\n beatId: beat.uuid,\n id: \"beatText\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n }) as SVGTextElement;\n\n // create the children\n for (const flatAtom of beat.atoms) {\n if (flatAtom.atom.type == AtomType.LITERAL) {\n const lit = flatAtom.atom as Literal;\n // convert to note or syllable here\n if (beat.role.defaultToNotes) {\n flatAtom.atom = Note.fromLit(lit);\n } else {\n flatAtom.atom = Syllable.fromLit(lit);\n }\n // carry over rest info\n flatAtom.atom.beforeRest = lit.beforeRest;\n }\n const atomView = createAtomView(this.textElement, flatAtom);\n atomView.depth = flatAtom.depth;\n this.atomViews.push(atomView);\n }\n\n this.setStyles(config || {});\n }\n\n // protected refreshMinSize(): TSU.Geom.Size { return TSU.DOM.svgBBox(this.groupElement); }\n protected refreshMinSize(): TSU.Geom.Size {\n let totalWidth = 0;\n let maxHeight = 0;\n this.atomViews.forEach((av, index) => {\n const ms = av.minSize;\n totalWidth += ms.width + this.atomSpacing;\n maxHeight = Math.max(maxHeight, ms.height);\n });\n return new TSU.Geom.Size(totalWidth, maxHeight);\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, w, h];\n }\n\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n this.needsLayout = true;\n }\n\n refreshLayout(): void {\n this.groupElement.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n // if (this.widthChanged) {\n // All our atoms have to be laid out between startX and endX\n // old way of doing where we just set dx between atom views\n // this worked when atomviews were single glyphs. But\n // as atomViews can be complex (eg with accents and pre/post\n // spaces etc) explicitly setting x/y may be important\n let currX = 0;\n const currY = 0; // null; // this.y; // + 10;\n this.atomViews.forEach((av, index) => {\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n });\n this.resetMinSize();\n for (const e of this.embelishments) e.refreshLayout();\n this.resetMinSize();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.textElement.parentElement as any as SVGGraphicsElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n this._embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n // TODO - ensure that we are in the last instance of this beat\n // since for now we dont have a way of specifying kalai this wont fail\n if (beat.beatIndex == bar.beatCount - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n this._embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n this._embelishments = [emb];\n }\n }\n }\n }\n return this._embelishments;\n }\n}\n"]}
1
+ {"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnatic/beatviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,gCAAmE;AAEnE,oCAA0D;AAC1D,yCAA6C;AAC7C,iDAA+D;AAE/D;IAA8B,4BAAK;IAOjC,kBAA4B,IAAU,EAAE,WAAoB,EAAkB,KAAY,EAAE,MAAY;;QAAxG,YACE,iBAAO,SA+CR;QAhD2B,UAAI,GAAJ,IAAI,CAAM;QAAwC,WAAK,GAAL,KAAK,CAAO;QAL1F,iBAAW,GAAG,IAAI,CAAC;QAEX,eAAS,GAAe,EAAE,CAAC;QAKjC,KAAI,CAAC,WAAW,G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AI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;iBAC7B;qBAAM;oBACL,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;oBACzB,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACtC,IAAI,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE;wBAIvC,IAAI,IAAI,CAAC,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;4BACvD,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;gCAE1C,IAAM,GAAG,GAAG,IAAI,4BAAY,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;gCACnD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;6BAC7B;iCAAM;gCAEL,IAAM,GAAG,GAAG,IAAI,4BAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;gCAChD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;6BAC7B;yBACF;qBACF;iBACF;aACF;YACD,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;;;OAAA;IACH,eAAC;AAAD,CAAC,AAvID,CAA8B,cAAK,GAuIlC;AAvIY,4BAAQ","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Cycle, AtomType, Syllable, Note, Literal } from \"../core\";\nimport { BeatView as BeatViewBase, Beat } from \"../layouts\";\nimport { AtomView, Embelishment, Shape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class BeatView extends Shape implements BeatViewBase {\n protected atomSpacing: number;\n needsLayout = true;\n private _embelishments: Embelishment[];\n private atomViews: AtomView[] = [];\n groupElement: SVGGElement;\n textElement: SVGTextElement;\n constructor(public readonly beat: Beat, rootElement: Element, public readonly cycle: Cycle, config?: any) {\n super();\n this.atomSpacing = 5;\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n beatId: beat.uuid,\n id: \"beatGroup\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n });\n this.textElement = TSU.DOM.createSVGNode(\"text\", {\n parent: this.groupElement,\n attrs: {\n class: \"roleAtomsText\",\n // y: \"0%\",\n style: \"dominant-baseline: hanging\",\n beatId: beat.uuid,\n id: \"beatText\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n }) as SVGTextElement;\n\n // create the children\n for (const flatAtom of beat.atoms) {\n if (flatAtom.atom.type == AtomType.LITERAL) {\n const lit = flatAtom.atom as Literal;\n // convert to note or syllable here\n if (beat.role.defaultToNotes) {\n flatAtom.atom = Note.fromLit(lit);\n } else {\n flatAtom.atom = Syllable.fromLit(lit);\n }\n // carry over rest info\n flatAtom.atom.beforeRest = lit.beforeRest;\n }\n const atomView = createAtomView(this.textElement, flatAtom);\n atomView.depth = flatAtom.depth;\n this.atomViews.push(atomView);\n }\n\n this.setStyles(config || {});\n }\n\n // protected refreshMinSize(): TSU.Geom.Size { return TSU.DOM.svgBBox(this.groupElement); }\n protected refreshMinSize(): TSU.Geom.Size {\n let totalWidth = 0;\n let maxHeight = 0;\n this.atomViews.forEach((av, index) => {\n const ms = av.minSize;\n totalWidth += ms.width + this.atomSpacing;\n maxHeight = Math.max(maxHeight, ms.height);\n });\n return new TSU.Geom.Size(totalWidth, maxHeight);\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, w, h];\n }\n\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n this.needsLayout = true;\n }\n\n refreshLayout(): void {\n this.groupElement.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n // if (this.widthChanged) {\n // All our atoms have to be laid out between startX and endX\n // old way of doing where we just set dx between atom views\n // this worked when atomviews were single glyphs. But\n // as atomViews can be complex (eg with accents and pre/post\n // spaces etc) explicitly setting x/y may be important\n let currX = 0;\n const currY = 0; // null; // this.y; // + 10;\n this.atomViews.forEach((av, index) => {\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n });\n this.resetMinSize();\n for (const e of this.embelishments) e.refreshLayout();\n this.resetMinSize();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.textElement.parentElement as any as SVGGraphicsElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n this._embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n if (beat.beatIndex == bar.beatCount - 1) {\n // It is important that we are not just looking at the last beat of the bar\n // but also in the last \"instance\" of the beat in this bar to account for\n // kalais\n if (beat.instance == bar.beatCounts[beat.beatIndex] - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n this._embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n this._embelishments = [emb];\n }\n }\n }\n }\n }\n return this._embelishments;\n }\n}\n"]}
@@ -150,13 +150,15 @@ var BeatView = (function (_super) {
150
150
  var cycle = this.cycle;
151
151
  var bar = cycle.bars[beat.barIndex];
152
152
  if (beat.beatIndex == bar.beatCount - 1) {
153
- if (beat.barIndex == cycle.bars.length - 1) {
154
- var emb = new BeatEndLines(this, rootElement, 2);
155
- this._embelishments = [emb];
156
- }
157
- else {
158
- var emb = new BeatEndLines(this, rootElement);
159
- this._embelishments = [emb];
153
+ if (beat.instance == bar.beatCounts[beat.beatIndex] - 1) {
154
+ if (beat.barIndex == cycle.bars.length - 1) {
155
+ var emb = new BeatEndLines(this, rootElement, 2);
156
+ this._embelishments = [emb];
157
+ }
158
+ else {
159
+ var emb = new BeatEndLines(this, rootElement);
160
+ this._embelishments = [emb];
161
+ }
160
162
  }
161
163
  }
162
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnatic/beatviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAW,MAAM,SAAS,CAAC;AAEnE,OAAO,EAA0B,KAAK,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D;IAA8B,4BAAK;IAOjC,kBAA4B,IAAU,EAAE,WAAoB,EAAkB,KAAY,EAAE,MAAY;;QAAxG,YACE,iBAAO,SA+CR;QAhD2B,UAAI,GAAJ,IAAI,CAAM;QAAwC,WAAK,GAAL,KAAK,CAAO;QAL1F,iBAAW,GAAG,IAAI,CAAC;QAEX,eAAS,GAAe,EAAE,CAAC;QAKjC,KAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,KAAI,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YAC7C,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI,CAAC,IAAI;gBACjB,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC,IAAI;gBAC3B,QAAQ,EAAE,IAAI,CAAC,IAAI,C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AAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;4BAE1C,IAAM,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;4BACnD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;yBAC7B;6BAAM;4BAEL,IAAM,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;4BAChD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;yBAC7B;qBACF;iBACF;aACF;YACD,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;;;OAAA;IACH,eAAC;AAAD,CAAC,AApID,CAA8B,KAAK,GAoIlC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Cycle, AtomType, Syllable, Note, Literal } from \"../core\";\nimport { BeatView as BeatViewBase, Beat } from \"../layouts\";\nimport { AtomView, Embelishment, Shape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class BeatView extends Shape implements BeatViewBase {\n protected atomSpacing: number;\n needsLayout = true;\n private _embelishments: Embelishment[];\n private atomViews: AtomView[] = [];\n groupElement: SVGGElement;\n textElement: SVGTextElement;\n constructor(public readonly beat: Beat, rootElement: Element, public readonly cycle: Cycle, config?: any) {\n super();\n this.atomSpacing = 5;\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n beatId: beat.uuid,\n id: \"beatGroup\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n });\n this.textElement = TSU.DOM.createSVGNode(\"text\", {\n parent: this.groupElement,\n attrs: {\n class: \"roleAtomsText\",\n // y: \"0%\",\n style: \"dominant-baseline: hanging\",\n beatId: beat.uuid,\n id: \"beatText\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n }) as SVGTextElement;\n\n // create the children\n for (const flatAtom of beat.atoms) {\n if (flatAtom.atom.type == AtomType.LITERAL) {\n const lit = flatAtom.atom as Literal;\n // convert to note or syllable here\n if (beat.role.defaultToNotes) {\n flatAtom.atom = Note.fromLit(lit);\n } else {\n flatAtom.atom = Syllable.fromLit(lit);\n }\n // carry over rest info\n flatAtom.atom.beforeRest = lit.beforeRest;\n }\n const atomView = createAtomView(this.textElement, flatAtom);\n atomView.depth = flatAtom.depth;\n this.atomViews.push(atomView);\n }\n\n this.setStyles(config || {});\n }\n\n // protected refreshMinSize(): TSU.Geom.Size { return TSU.DOM.svgBBox(this.groupElement); }\n protected refreshMinSize(): TSU.Geom.Size {\n let totalWidth = 0;\n let maxHeight = 0;\n this.atomViews.forEach((av, index) => {\n const ms = av.minSize;\n totalWidth += ms.width + this.atomSpacing;\n maxHeight = Math.max(maxHeight, ms.height);\n });\n return new TSU.Geom.Size(totalWidth, maxHeight);\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, w, h];\n }\n\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n this.needsLayout = true;\n }\n\n refreshLayout(): void {\n this.groupElement.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n // if (this.widthChanged) {\n // All our atoms have to be laid out between startX and endX\n // old way of doing where we just set dx between atom views\n // this worked when atomviews were single glyphs. But\n // as atomViews can be complex (eg with accents and pre/post\n // spaces etc) explicitly setting x/y may be important\n let currX = 0;\n const currY = 0; // null; // this.y; // + 10;\n this.atomViews.forEach((av, index) => {\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n });\n this.resetMinSize();\n for (const e of this.embelishments) e.refreshLayout();\n this.resetMinSize();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.textElement.parentElement as any as SVGGraphicsElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n this._embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n // TODO - ensure that we are in the last instance of this beat\n // since for now we dont have a way of specifying kalai this wont fail\n if (beat.beatIndex == bar.beatCount - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n this._embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n this._embelishments = [emb];\n }\n }\n }\n }\n return this._embelishments;\n }\n}\n"]}
1
+ {"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnatic/beatviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAW,MAAM,SAAS,CAAC;AAEnE,OAAO,EAA0B,KAAK,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D;IAA8B,4BAAK;IAOjC,kBAA4B,IAAU,EAAE,WAAoB,EAAkB,KAAY,EAAE,MAAY;;QAAxG,YACE,iBAAO,SA+CR;QAhD2B,UAAI,GAAJ,IAAI,CAAM;QAAwC,WAAK,GAAL,KAAK,CAAO;QAL1F,iBAAW,GAAG,IAAI,CAAC;QAEX,eAAS,GAAe,EAAE,CAAC;QAKjC,KAAI,CAAC,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I,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;iBAC7B;qBAAM;oBACL,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;oBACzB,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACtC,IAAI,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE;wBAIvC,IAAI,IAAI,CAAC,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;4BACvD,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;gCAE1C,IAAM,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;gCACnD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;6BAC7B;iCAAM;gCAEL,IAAM,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;gCAChD,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;6BAC7B;yBACF;qBACF;iBACF;aACF;YACD,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;;;OAAA;IACH,eAAC;AAAD,CAAC,AAvID,CAA8B,KAAK,GAuIlC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Cycle, AtomType, Syllable, Note, Literal } from \"../core\";\nimport { BeatView as BeatViewBase, Beat } from \"../layouts\";\nimport { AtomView, Embelishment, Shape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class BeatView extends Shape implements BeatViewBase {\n protected atomSpacing: number;\n needsLayout = true;\n private _embelishments: Embelishment[];\n private atomViews: AtomView[] = [];\n groupElement: SVGGElement;\n textElement: SVGTextElement;\n constructor(public readonly beat: Beat, rootElement: Element, public readonly cycle: Cycle, config?: any) {\n super();\n this.atomSpacing = 5;\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n beatId: beat.uuid,\n id: \"beatGroup\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n });\n this.textElement = TSU.DOM.createSVGNode(\"text\", {\n parent: this.groupElement,\n attrs: {\n class: \"roleAtomsText\",\n // y: \"0%\",\n style: \"dominant-baseline: hanging\",\n beatId: beat.uuid,\n id: \"beatText\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: beat.layoutLine,\n layoutColumn: beat.layoutColumn,\n beatIndex: beat.index,\n },\n }) as SVGTextElement;\n\n // create the children\n for (const flatAtom of beat.atoms) {\n if (flatAtom.atom.type == AtomType.LITERAL) {\n const lit = flatAtom.atom as Literal;\n // convert to note or syllable here\n if (beat.role.defaultToNotes) {\n flatAtom.atom = Note.fromLit(lit);\n } else {\n flatAtom.atom = Syllable.fromLit(lit);\n }\n // carry over rest info\n flatAtom.atom.beforeRest = lit.beforeRest;\n }\n const atomView = createAtomView(this.textElement, flatAtom);\n atomView.depth = flatAtom.depth;\n this.atomViews.push(atomView);\n }\n\n this.setStyles(config || {});\n }\n\n // protected refreshMinSize(): TSU.Geom.Size { return TSU.DOM.svgBBox(this.groupElement); }\n protected refreshMinSize(): TSU.Geom.Size {\n let totalWidth = 0;\n let maxHeight = 0;\n this.atomViews.forEach((av, index) => {\n const ms = av.minSize;\n totalWidth += ms.width + this.atomSpacing;\n maxHeight = Math.max(maxHeight, ms.height);\n });\n return new TSU.Geom.Size(totalWidth, maxHeight);\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, w, h];\n }\n\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n this.needsLayout = true;\n }\n\n refreshLayout(): void {\n this.groupElement.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n // if (this.widthChanged) {\n // All our atoms have to be laid out between startX and endX\n // old way of doing where we just set dx between atom views\n // this worked when atomviews were single glyphs. But\n // as atomViews can be complex (eg with accents and pre/post\n // spaces etc) explicitly setting x/y may be important\n let currX = 0;\n const currY = 0; // null; // this.y; // + 10;\n this.atomViews.forEach((av, index) => {\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n });\n this.resetMinSize();\n for (const e of this.embelishments) e.refreshLayout();\n this.resetMinSize();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.textElement.parentElement as any as SVGGraphicsElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n this._embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n if (beat.beatIndex == bar.beatCount - 1) {\n // It is important that we are not just looking at the last beat of the bar\n // but also in the last \"instance\" of the beat in this bar to account for\n // kalais\n if (beat.instance == bar.beatCounts[beat.beatIndex] - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n this._embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n this._embelishments = [emb];\n }\n }\n }\n }\n }\n return this._embelishments;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notations",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "author": "Sriram Panyam",
5
5
  "description": "A package for modelling, parsing, laying out carnatic musical notation",
6
6
  "homepage": "https://github.com/panyam/notations#readme",