notations 0.0.55 → 0.0.57
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.
- package/lib/cjs/beats.d.ts +3 -3
- package/lib/cjs/beats.js +2 -2
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.js +1 -1
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/atomviews.js +3 -3
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/core.d.ts +12 -1
- package/lib/cjs/core.js +20 -6
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.d.ts +5 -3
- package/lib/cjs/cycle.js +2 -0
- package/lib/cjs/cycle.js.map +1 -1
- package/lib/cjs/entity.d.ts +2 -1
- package/lib/cjs/entity.js +7 -5
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/iterators.d.ts +1 -1
- package/lib/cjs/iterators.js +2 -4
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.d.ts +1 -1
- package/lib/cjs/loader.js +1 -1
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.d.ts +3 -3
- package/lib/cjs/notation.js +2 -6
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/parser.js +1 -1
- package/lib/cjs/parser.js.map +1 -1
- package/lib/esm/beats.d.ts +3 -3
- package/lib/esm/beats.js +2 -2
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/carnatic/NotationView.js +1 -1
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/carnatic/atomviews.js +3 -3
- package/lib/esm/carnatic/atomviews.js.map +1 -1
- package/lib/esm/core.d.ts +12 -1
- package/lib/esm/core.js +20 -6
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/cycle.d.ts +5 -3
- package/lib/esm/cycle.js +2 -0
- package/lib/esm/cycle.js.map +1 -1
- package/lib/esm/entity.d.ts +2 -1
- package/lib/esm/entity.js +7 -5
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/iterators.d.ts +1 -1
- package/lib/esm/iterators.js +2 -4
- package/lib/esm/iterators.js.map +1 -1
- package/lib/esm/layouts.d.ts +1 -1
- package/lib/esm/loader.js +1 -1
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.d.ts +3 -3
- package/lib/esm/notation.js +2 -6
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/parser.js +1 -1
- package/lib/esm/parser.js.map +1 -1
- package/package.json +22 -22
package/lib/cjs/beats.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CycleIterator } from "./cycle";
|
|
|
4
4
|
import { WindowIterator } from "./iterators";
|
|
5
5
|
import { LayoutParams } from "./layouts";
|
|
6
6
|
import { GridModel, GridCell, ColAlign, GridLayoutGroup } from "./grids";
|
|
7
|
-
|
|
7
|
+
type Fraction = TSU.Num.Fraction;
|
|
8
8
|
export declare class Beat {
|
|
9
9
|
readonly index: number;
|
|
10
10
|
readonly role: Role;
|
|
@@ -60,8 +60,8 @@ export declare class BeatColDAG {
|
|
|
60
60
|
getBeatColumn(offset: Fraction, endOffset: Fraction, markerType?: number): BeatColumn;
|
|
61
61
|
protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType?: number): [BeatColumn, boolean];
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
type LineId = number;
|
|
64
|
+
type LPID = number;
|
|
65
65
|
export declare class GlobalBeatLayout {
|
|
66
66
|
gridModelsForLine: Map<number, GridModel>;
|
|
67
67
|
roleBeatsForLine: Map<number, Beat[][]>;
|
package/lib/cjs/beats.js
CHANGED
|
@@ -88,7 +88,7 @@ class Beat {
|
|
|
88
88
|
for (const marker of curr.markersBefore || []) {
|
|
89
89
|
out.push(marker);
|
|
90
90
|
}
|
|
91
|
-
if (curr.
|
|
91
|
+
if (curr.TYPE == _1.AtomType.GROUP) {
|
|
92
92
|
curr = curr.atoms.first;
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
@@ -102,7 +102,7 @@ class Beat {
|
|
|
102
102
|
let curr = this.atom;
|
|
103
103
|
while (curr != null) {
|
|
104
104
|
out.splice(0, 0, ...(curr.markersAfter || []));
|
|
105
|
-
if (curr.
|
|
105
|
+
if (curr.TYPE == _1.AtomType.GROUP) {
|
|
106
106
|
curr = curr.atoms.last;
|
|
107
107
|
}
|
|
108
108
|
else {
|
package/lib/cjs/beats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yBAAsE;AAEtE,2CAA6C;AAE7C,mCAAkF;AAGlF,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC,MAAa,IAAI;IAOf,YACkB,KAAa,EACb,IAAU,EACV,MAAgB,EAChB,QAAkB,EAClB,QAAgB,EAChB,SAAiB,EACjB,QAAgB,EAChB,QAAqB,EAC9B,QAAqB;QARZ,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAM;QACV,WAAM,GAAN,MAAM,CAAU;QAChB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAa;QAC9B,aAAQ,GAAR,QAAQ,CAAa;QAdrB,SAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAIvB,sBAAiB,GAAG,KAAK,CAAC;IAWjC,CAAC;IAEJ,UAAU;QACR,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,I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group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n get preMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n for (const marker of curr.markersBefore || []) {\n out.push(marker);\n }\n if (curr.type == AtomType.GROUP) {\n curr = (curr as Group).atoms.first;\n } else {\n curr = null;\n }\n }\n return out;\n }\n\n get postMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n out.splice(0, 0, ...(curr.markersAfter || []));\n if (curr.type == AtomType.GROUP) {\n curr = (curr as Group).atoms.last;\n } else {\n curr = null;\n }\n }\n return out;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\nexport class BeatColumn extends ColAlign {\n atomSpacing = 5;\n readonly key: string;\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n beatColumns = new Map<string, BeatColumn>();\n\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/**\n * Manages the beat layouts for *all* lines in a notation.\n */\ntype LineId = number;\ntype LPID = number;\nexport class GlobalBeatLayout {\n gridModelsForLine = new Map<LineId, GridModel>();\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Get the GridView associated with a particular line.\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * First lines are added to the BeatLayout object.\n * This ensures that a line is broken down into beats and added\n * into a dedicated GridModel per line.\n *\n * A line must also be given the layout params by which the beat\n * break down will happen. This LayoutParams object does not have\n * to be unique per line (this non-constraint allows to align\n * beats across lines!).\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);\n roleBeats.push(bb.beats);\n\n // Add these to the beat layout too\n for (const beat of bb.beats) {\n // beat.ensureUniformSpaces(layoutParams.beatDuration);\n this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which\n * this beat was added.\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const nthLine = Math.floor(beat.index / lp.totalBeats);\n const realLine = lp.lineBreaks.length * nthLine + layoutLine;\n const realRow = line.roles.length * realLine + roleIndex;\n // pre marker goes on realCol - 1, post marker goes on realCol + 1\n const realCol = 1 + layoutColumn * 3;\n const preMarkers = beat.preMarkers;\n if (preMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: preMarkers,\n };\n const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);\n gridModel.setValue(realRow, realCol - 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = precol;\n return cell;\n });\n }\n const postMarkers = beat.postMarkers;\n if (postMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: postMarkers,\n };\n const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);\n gridModel.setValue(realRow, realCol + 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = postcol;\n return cell;\n });\n }\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol;\n return cell;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yBAAsE;AAEtE,2CAA6C;AAE7C,mCAAkF;AAGlF,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC,MAAa,IAAI;IAOf,YACkB,KAAa,EACb,IAAU,EACV,MAAgB,EAChB,QAAkB,EAClB,QAAgB,EAChB,SAAiB,EACjB,QAAgB,EAChB,QAAqB,EAC9B,QAAqB;QARZ,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAM;QACV,WAAM,GAAN,MAAM,CAAU;QAChB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAa;QAC9B,aAAQ,GAAR,QAAQ,CAAa;QAdrB,SAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAIvB,sBAAiB,GAAG,KAAK,CAAC;IAWjC,CAAC;IAEJ,UAAU;QACR,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;YAClC,QAAQ,EAAE,IAAI,CAAC,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,IAAI,gBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBACxC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;gBACvB,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,MAAM,GAAG,GAAG;gBACV,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,WAAW;aACrB,CAAC;YACF,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;gBAC9E,MAAM,IAAI,GAAG,IAAI,gBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;gBACxB,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;YAClF,MAAM,IAAI,GAAG,IAAI,gBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApHD,4CAoHC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Marker, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n get preMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n for (const marker of curr.markersBefore || []) {\n out.push(marker);\n }\n if (curr.TYPE == AtomType.GROUP) {\n curr = (curr as Group).atoms.first;\n } else {\n curr = null;\n }\n }\n return out;\n }\n\n get postMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n out.splice(0, 0, ...(curr.markersAfter || []));\n if (curr.TYPE == AtomType.GROUP) {\n curr = (curr as Group).atoms.last;\n } else {\n curr = null;\n }\n }\n return out;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\nexport class BeatColumn extends ColAlign {\n atomSpacing = 5;\n readonly key: string;\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n beatColumns = new Map<string, BeatColumn>();\n\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/**\n * Manages the beat layouts for *all* lines in a notation.\n */\ntype LineId = number;\ntype LPID = number;\nexport class GlobalBeatLayout {\n gridModelsForLine = new Map<LineId, GridModel>();\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Get the GridView associated with a particular line.\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * First lines are added to the BeatLayout object.\n * This ensures that a line is broken down into beats and added\n * into a dedicated GridModel per line.\n *\n * A line must also be given the layout params by which the beat\n * break down will happen. This LayoutParams object does not have\n * to be unique per line (this non-constraint allows to align\n * beats across lines!).\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);\n roleBeats.push(bb.beats);\n\n // Add these to the beat layout too\n for (const beat of bb.beats) {\n // beat.ensureUniformSpaces(layoutParams.beatDuration);\n this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which\n * this beat was added.\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const nthLine = Math.floor(beat.index / lp.totalBeats);\n const realLine = lp.lineBreaks.length * nthLine + layoutLine;\n const realRow = line.roles.length * realLine + roleIndex;\n // pre marker goes on realCol - 1, post marker goes on realCol + 1\n const realCol = 1 + layoutColumn * 3;\n const preMarkers = beat.preMarkers;\n if (preMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: preMarkers,\n };\n const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);\n gridModel.setValue(realRow, realCol - 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = precol;\n return cell;\n });\n }\n const postMarkers = beat.postMarkers;\n if (postMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: postMarkers,\n };\n const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);\n gridModel.setValue(realRow, realCol + 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = postcol;\n return cell;\n });\n }\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol;\n return cell;\n });\n }\n}\n"]}
|
|
@@ -1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AY,CAAC;gBAC7B,IAAI,GAAG,IAAI,oBAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;gBAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACrC;YACD,OAAO,IAAI,CAAC;SACb;aAAM;YAEL,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;YAC1B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAY,CAAC;YACjC,IAAI,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;YAC5D,IAAI,IAAI,IAAI,IAAI,EAAE;gBAChB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;gBAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,GAAG,IAAI,sBAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC/E,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAChD;YACD,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AA7MD,oCA6MC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { LineView } from \"./LineView\";\nimport { Notation, RawBlock } from \"../notation\";\nimport { Beat, GlobalBeatLayout } from \"../beats\";\nimport { GridCell, GridCellView } from \"../grids\";\nimport { Line } from \"../core\";\nimport { BeatView, MarkerView } from \"./beatviews\";\n\nexport class NotationView {\n headerElement: HTMLDivElement;\n notation: Notation;\n lineViews: LineView[] = [];\n // Mapping from line id -> list of beats in each of its roles\n currentSVGElement: SVGSVGElement | null = null;\n tableElement: HTMLTableElement;\n markdownParser: (contents: string) => string;\n _beatLayout: GlobalBeatLayout;\n\n constructor(public readonly rootElement: HTMLElement, public readonly config?: any) {\n this.loadChildViews();\n }\n\n get beatLayout(): GlobalBeatLayout {\n return this._beatLayout;\n }\n\n set beatLayout(beatLayout: GlobalBeatLayout) {\n this._beatLayout = beatLayout;\n beatLayout.gridLayoutGroup.getCellView = (cell) => this.viewForBeat(cell);\n }\n\n loadChildViews(): void {\n this.tableElement = TSU.DOM.createNode(\"table\", {\n parent: this.rootElement,\n attrs: {\n class: \"notationsContentRootTable\",\n },\n }) as HTMLTableElement;\n }\n\n renderNotation(notation: Notation, beatLayout: GlobalBeatLayout): void {\n this.notation = notation;\n this.beatLayout = beatLayout;\n const startTime = performance.now();\n this.refreshLayout();\n const layoutTime = performance.now();\n console.log(`V4 Document, Layout Time: ${layoutTime - startTime}ms`);\n }\n\n public addNewRow(id: string, prefix: string, withAnnotation = true): [HTMLElement, HTMLElement] {\n const tr = TSU.DOM.createNode(\"tr\", {\n parent: this.tableElement, // parent,\n attrs: {\n class: prefix + \"Row\",\n id: prefix + \"Row\" + id,\n },\n });\n let td1: HTMLElement | null = null;\n if (withAnnotation) {\n td1 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"AnnotationCell\",\n id: prefix + \"Annotation\" + id,\n },\n }) as HTMLElement;\n }\n const td2 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"ContentCell\",\n id: prefix + \"Content\" + id,\n colspan: withAnnotation ? 1 : 2,\n },\n }) as HTMLElement;\n return [td1!, td2];\n }\n\n public newLineRoot(parent: Element, line: Line): SVGSVGElement {\n const [td1, td2] = this.addNewRow(line.uuid + \"\", \"line\");\n // Hacky solution to \"line headings\"\n if (line.marginText) {\n td1.innerHTML = line.marginText;\n }\n return TSU.DOM.createSVGNode(\"svg\", {\n parent: td2, // parent\n attrs: {\n style: \"margin-bottom: 10px\",\n class: \"lineRootSVG\",\n },\n }) as SVGSVGElement;\n }\n\n ensureLineView(line: Line): LineView {\n let lineView = this.getLineView(line);\n if (lineView == null) {\n const layoutParams = line.layoutParams || null;\n const svgElem = this.newLineRoot(this.tableElement, line);\n lineView = new LineView(svgElem, line, {\n layoutParams: layoutParams,\n } as any);\n if (!line.isEmpty) {\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(layoutParams != null, \"Layout params for a non empty line *should* exist\");\n lineView.gridModel = this.beatLayout!.getGridModelForLine(line.uuid);\n }\n this.lineViews.push(lineView);\n }\n return lineView;\n }\n\n getLineView(line: Line): TSU.Nullable<LineView> {\n return this.lineViews.find((l) => l.line == line) || null;\n }\n\n get currentLineView(): LineView {\n return this.lineViews[this.lineViews.length - 1];\n }\n\n clear(): void {\n this.lineViews = [];\n // Mapping from line id -> list of beats in each of its roles\n this.currentSVGElement = null;\n this.tableElement.innerHTML = \"\";\n this.beatViews = new Map<number, BeatView>();\n }\n\n /**\n * Layout all the blocks in the Notation along with their corresponding blocks.\n * Key thing is here is an opportunity to perform any batch rendering as needed.\n */\n refreshLayout(): void {\n const lines = [] as Line[];\n const lineViews = [] as LineView[];\n for (const block of this.notation.blocks) {\n if (block.type == \"RawBlock\") {\n // Add the markdown here\n this.renderBlock(block as RawBlock);\n } else {\n lines.push(block as Line);\n const lineView = this.ensureLineView(block as Line);\n lineViews.push(lineView);\n }\n }\n\n const now = performance.now();\n for (const lineView of lineViews) {\n lineView.gridModel.lastUpdatedAt = now;\n }\n\n this.beatLayout.gridLayoutGroup.refreshLayout();\n\n for (const lineView of lineViews) {\n lineView.wrapToSize();\n }\n\n // now that all spacing has been calculated\n // go through all\n // for (const beatView of this.beatViews.values()) { beatView.refreshLayout(); }\n }\n\n renderBlock(raw: RawBlock): void {\n const [, td2] = this.addNewRow(raw.uuid + \"\", \"rawBlock\", false);\n if (raw.contentType == \"metadata\") {\n // we have a metadata block\n const meta = this.notation.metadata.get(raw.content);\n if (meta) {\n // For now ignore metadata with \":\" in the key\n if (meta.key.toLowerCase().indexOf(\":\") < 0) {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n const html = `<span class = \"${meta.key.toLowerCase()}\"><strong>${meta.key}</strong>: ${meta.value}</span>`;\n div.innerHTML = html;\n }\n }\n } else {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n div.innerHTML = this.markdownParser(raw.content.trim());\n }\n this.currentSVGElement = null;\n }\n\n beatViews = new Map<number, BeatView>();\n markerViews = new Map<string, MarkerView>();\n viewForBeat(cell: GridCell): GridCellView {\n if (cell.colIndex % 3 == 1) {\n // beat view needed\n const beat = cell.value;\n let curr = this.beatViews.get(beat.uuid) || null;\n if (curr == null) {\n const line = beat.role.line;\n // how to get the bar and beat index for a given beat in a given row?\n const lineView = this.ensureLineView(line);\n const lp = line.layoutParams;\n curr = new BeatView(cell, beat, lineView.gElem, lp.cycle);\n this.beatViews.set(beat.uuid, curr);\n }\n return curr;\n } else {\n // markers view\n const marker = cell.value;\n const beat = marker.beat as Beat;\n let curr = this.markerViews.get(\"pre:\" + beat.uuid) || null;\n if (curr == null) {\n const line = beat.role.line;\n const lineView = this.ensureLineView(line);\n const lp = line.layoutParams;\n const isPreMarker = cell.colIndex % 3 == 0;\n curr = new MarkerView(cell, beat, marker.markers, isPreMarker, lineView.gElem);\n this.markerViews.set(\"pre:\" + beat.uuid, curr);\n }\n return curr;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NotationView.js","sourceRoot":"","sources":["../../../src/carnatic/NotationView.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yCAAsC;AAKtC,2CAAmD;AAEnD,MAAa,YAAY;IAUvB,YAA4B,WAAwB,EAAkB,MAAY;QAAt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AAO,IAAI,CAAC;SACb;aAAM;YAEL,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;YAC1B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAY,CAAC;YACjC,IAAI,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;YAC5D,IAAI,IAAI,IAAI,IAAI,EAAE;gBAChB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;gBAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,GAAG,IAAI,sBAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC/E,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAChD;YACD,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AA7MD,oCA6MC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { LineView } from \"./LineView\";\nimport { Notation, RawBlock } from \"../notation\";\nimport { Beat, GlobalBeatLayout } from \"../beats\";\nimport { GridCell, GridCellView } from \"../grids\";\nimport { Line } from \"../core\";\nimport { BeatView, MarkerView } from \"./beatviews\";\n\nexport class NotationView {\n headerElement: HTMLDivElement;\n notation: Notation;\n lineViews: LineView[] = [];\n // Mapping from line id -> list of beats in each of its roles\n currentSVGElement: SVGSVGElement | null = null;\n tableElement: HTMLTableElement;\n markdownParser: (contents: string) => string;\n _beatLayout: GlobalBeatLayout;\n\n constructor(public readonly rootElement: HTMLElement, public readonly config?: any) {\n this.loadChildViews();\n }\n\n get beatLayout(): GlobalBeatLayout {\n return this._beatLayout;\n }\n\n set beatLayout(beatLayout: GlobalBeatLayout) {\n this._beatLayout = beatLayout;\n beatLayout.gridLayoutGroup.getCellView = (cell) => this.viewForBeat(cell);\n }\n\n loadChildViews(): void {\n this.tableElement = TSU.DOM.createNode(\"table\", {\n parent: this.rootElement,\n attrs: {\n class: \"notationsContentRootTable\",\n },\n }) as HTMLTableElement;\n }\n\n renderNotation(notation: Notation, beatLayout: GlobalBeatLayout): void {\n this.notation = notation;\n this.beatLayout = beatLayout;\n const startTime = performance.now();\n this.refreshLayout();\n const layoutTime = performance.now();\n console.log(`V4 Document, Layout Time: ${layoutTime - startTime}ms`);\n }\n\n public addNewRow(id: string, prefix: string, withAnnotation = true): [HTMLElement, HTMLElement] {\n const tr = TSU.DOM.createNode(\"tr\", {\n parent: this.tableElement, // parent,\n attrs: {\n class: prefix + \"Row\",\n id: prefix + \"Row\" + id,\n },\n });\n let td1: HTMLElement | null = null;\n if (withAnnotation) {\n td1 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"AnnotationCell\",\n id: prefix + \"Annotation\" + id,\n },\n }) as HTMLElement;\n }\n const td2 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"ContentCell\",\n id: prefix + \"Content\" + id,\n colspan: withAnnotation ? 1 : 2,\n },\n }) as HTMLElement;\n return [td1!, td2];\n }\n\n public newLineRoot(parent: Element, line: Line): SVGSVGElement {\n const [td1, td2] = this.addNewRow(line.uuid + \"\", \"line\");\n // Hacky solution to \"line headings\"\n if (line.marginText) {\n td1.innerHTML = line.marginText;\n }\n return TSU.DOM.createSVGNode(\"svg\", {\n parent: td2, // parent\n attrs: {\n style: \"margin-bottom: 10px\",\n class: \"lineRootSVG\",\n },\n }) as SVGSVGElement;\n }\n\n ensureLineView(line: Line): LineView {\n let lineView = this.getLineView(line);\n if (lineView == null) {\n const layoutParams = line.layoutParams || null;\n const svgElem = this.newLineRoot(this.tableElement, line);\n lineView = new LineView(svgElem, line, {\n layoutParams: layoutParams,\n } as any);\n if (!line.isEmpty) {\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(layoutParams != null, \"Layout params for a non empty line *should* exist\");\n lineView.gridModel = this.beatLayout!.getGridModelForLine(line.uuid);\n }\n this.lineViews.push(lineView);\n }\n return lineView;\n }\n\n getLineView(line: Line): TSU.Nullable<LineView> {\n return this.lineViews.find((l) => l.line == line) || null;\n }\n\n get currentLineView(): LineView {\n return this.lineViews[this.lineViews.length - 1];\n }\n\n clear(): void {\n this.lineViews = [];\n // Mapping from line id -> list of beats in each of its roles\n this.currentSVGElement = null;\n this.tableElement.innerHTML = \"\";\n this.beatViews = new Map<number, BeatView>();\n }\n\n /**\n * Layout all the blocks in the Notation along with their corresponding blocks.\n * Key thing is here is an opportunity to perform any batch rendering as needed.\n */\n refreshLayout(): void {\n const lines = [] as Line[];\n const lineViews = [] as LineView[];\n for (const block of this.notation.blocks) {\n if (block.TYPE == \"RawBlock\") {\n // Add the markdown here\n this.renderBlock(block as RawBlock);\n } else {\n lines.push(block as Line);\n const lineView = this.ensureLineView(block as Line);\n lineViews.push(lineView);\n }\n }\n\n const now = performance.now();\n for (const lineView of lineViews) {\n lineView.gridModel.lastUpdatedAt = now;\n }\n\n this.beatLayout.gridLayoutGroup.refreshLayout();\n\n for (const lineView of lineViews) {\n lineView.wrapToSize();\n }\n\n // now that all spacing has been calculated\n // go through all\n // for (const beatView of this.beatViews.values()) { beatView.refreshLayout(); }\n }\n\n renderBlock(raw: RawBlock): void {\n const [, td2] = this.addNewRow(raw.uuid + \"\", \"rawBlock\", false);\n if (raw.contentType == \"metadata\") {\n // we have a metadata block\n const meta = this.notation.metadata.get(raw.content);\n if (meta) {\n // For now ignore metadata with \":\" in the key\n if (meta.key.toLowerCase().indexOf(\":\") < 0) {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n const html = `<span class = \"${meta.key.toLowerCase()}\"><strong>${meta.key}</strong>: ${meta.value}</span>`;\n div.innerHTML = html;\n }\n }\n } else {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n div.innerHTML = this.markdownParser(raw.content.trim());\n }\n this.currentSVGElement = null;\n }\n\n beatViews = new Map<number, BeatView>();\n markerViews = new Map<string, MarkerView>();\n viewForBeat(cell: GridCell): GridCellView {\n if (cell.colIndex % 3 == 1) {\n // beat view needed\n const beat = cell.value;\n let curr = this.beatViews.get(beat.uuid) || null;\n if (curr == null) {\n const line = beat.role.line;\n // how to get the bar and beat index for a given beat in a given row?\n const lineView = this.ensureLineView(line);\n const lp = line.layoutParams;\n curr = new BeatView(cell, beat, lineView.gElem, lp.cycle);\n this.beatViews.set(beat.uuid, curr);\n }\n return curr;\n } else {\n // markers view\n const marker = cell.value;\n const beat = marker.beat as Beat;\n let curr = this.markerViews.get(\"pre:\" + beat.uuid) || null;\n if (curr == null) {\n const line = beat.role.line;\n const lineView = this.ensureLineView(line);\n const lp = line.layoutParams;\n const isPreMarker = cell.colIndex % 3 == 0;\n curr = new MarkerView(cell, beat, marker.markers, isPreMarker, lineView.gElem);\n this.markerViews.set(\"pre:\" + beat.uuid, curr);\n }\n return curr;\n }\n }\n}\n"]}
|
|
@@ -105,7 +105,7 @@ class LeafAtomView extends shapes_1.LeafAtomView {
|
|
|
105
105
|
}
|
|
106
106
|
orderEmbelishments() {
|
|
107
107
|
const atom = this.leafAtom;
|
|
108
|
-
if (atom.
|
|
108
|
+
if (atom.TYPE != core_1.AtomType.SYLLABLE && atom.TYPE != core_1.AtomType.NOTE) {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
const lit = atom;
|
|
@@ -273,7 +273,7 @@ class SyllableView extends LeafAtomView {
|
|
|
273
273
|
}
|
|
274
274
|
function createAtomView(parent, atom, litDefaultsToNote = false, groupViewScale = 1.0) {
|
|
275
275
|
let out;
|
|
276
|
-
switch (atom.
|
|
276
|
+
switch (atom.TYPE) {
|
|
277
277
|
case core_1.AtomType.SPACE:
|
|
278
278
|
out = new SpaceView(atom);
|
|
279
279
|
break;
|
|
@@ -299,7 +299,7 @@ function createAtomView(parent, atom, litDefaultsToNote = false, groupViewScale
|
|
|
299
299
|
out.scaleFactor = groupViewScale;
|
|
300
300
|
break;
|
|
301
301
|
default:
|
|
302
|
-
throw new Error("Invalid atom type: " + atom.
|
|
302
|
+
throw new Error("Invalid atom type: " + atom.TYPE);
|
|
303
303
|
}
|
|
304
304
|
out.createElements(parent);
|
|
305
305
|
return out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,kCAAgF;AAChF,sCAMmB;AACnB,mDAYyB;AACzB,uCAAuC;AAEvC,MAAa,SAAU,SAAQ,kBAAa;IAC1C,cAAc,CAAC,IAAU;QACvB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;CACF;AAJD,8BAIC;AAED,MAAsB,YAAa,SAAQ,qBAAgB;IAA3D;;QACE,aAAQ,GAAmB,EAAE,CAAC;QAC9B,YAAO,GAAmB,EAAE,CAAC;QAC7B,cAAS,GAAmB,EAAE,CAAC;QAC/B,eAAU,GAAmB,EAAE,CAAC;IA+NlC,CAAC;IAnNW,WAAW;QACnB,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAES,cAAc;QACtB,MAAM,GAAG,qBAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAE,CAAC;QACzC,MAAM,UAAU,GACd,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,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,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;aAC7B;YACD,MAAM;QACR,KAAK,eAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YAClC,GAAiB,CAAC,cAAc,GAAG,iBAAiB,CAAC;YACrD,GAAiB,CAAC,WAAW,GAAG,cAAc,CAAC;YAChD,MAAM;QACR;YAGE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;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"]}
|
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,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"]}
|
package/lib/cjs/core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
2
|
import { Entity, TimedEntity } from "./entity";
|
|
3
3
|
import { LayoutParams } from "./layouts";
|
|
4
|
-
|
|
4
|
+
type Fraction = TSU.Num.Fraction;
|
|
5
5
|
export declare enum AtomType {
|
|
6
6
|
NOTE = "Note",
|
|
7
7
|
LITERAL = "Literal",
|
|
@@ -13,6 +13,7 @@ export declare enum AtomType {
|
|
|
13
13
|
MARKER = "Marker"
|
|
14
14
|
}
|
|
15
15
|
export declare abstract class Atom extends TimedEntity {
|
|
16
|
+
readonly TYPE: string;
|
|
16
17
|
protected _duration: Fraction;
|
|
17
18
|
markersBefore: Marker[];
|
|
18
19
|
markersAfter: Marker[];
|
|
@@ -28,6 +29,7 @@ export declare abstract class Atom extends TimedEntity {
|
|
|
28
29
|
set duration(d: Fraction);
|
|
29
30
|
}
|
|
30
31
|
export declare abstract class LeafAtom extends Atom {
|
|
32
|
+
readonly TYPE: string;
|
|
31
33
|
beforeRest: boolean;
|
|
32
34
|
splitAt(duration: Fraction): TSU.Nullable<Atom>;
|
|
33
35
|
protected createSpilloverSpace(duration: Fraction): Space;
|
|
@@ -36,14 +38,17 @@ export declare abstract class LeafAtom extends Atom {
|
|
|
36
38
|
export declare class Marker extends Entity {
|
|
37
39
|
text: string;
|
|
38
40
|
isBefore: boolean;
|
|
41
|
+
readonly TYPE = "Marker";
|
|
39
42
|
constructor(text: string, isBefore?: boolean);
|
|
40
43
|
debugValue(): any;
|
|
41
44
|
toString(): string;
|
|
42
45
|
}
|
|
43
46
|
export declare class Rest extends LeafAtom {
|
|
47
|
+
readonly TYPE = "Rest";
|
|
44
48
|
constructor();
|
|
45
49
|
}
|
|
46
50
|
export declare class Space extends LeafAtom {
|
|
51
|
+
readonly TYPE = "Space";
|
|
47
52
|
isSilent: boolean;
|
|
48
53
|
constructor(duration?: TSU.Num.Fraction, isSilent?: boolean);
|
|
49
54
|
debugValue(): any;
|
|
@@ -54,6 +59,7 @@ export declare class Space extends LeafAtom {
|
|
|
54
59
|
}
|
|
55
60
|
export declare class Literal extends LeafAtom {
|
|
56
61
|
value: string;
|
|
62
|
+
readonly TYPE: string;
|
|
57
63
|
embelishments: any[];
|
|
58
64
|
constructor(value: string, duration?: TSU.Num.Fraction);
|
|
59
65
|
debugValue(): any;
|
|
@@ -62,10 +68,12 @@ export declare class Literal extends LeafAtom {
|
|
|
62
68
|
copyTo(another: this): void;
|
|
63
69
|
}
|
|
64
70
|
export declare class Syllable extends Literal {
|
|
71
|
+
readonly TYPE = "Syllable";
|
|
65
72
|
static fromLit(lit: Literal): Syllable;
|
|
66
73
|
toString(): string;
|
|
67
74
|
}
|
|
68
75
|
export declare class Note extends Literal {
|
|
76
|
+
readonly TYPE = "Note";
|
|
69
77
|
octave: number;
|
|
70
78
|
shift: number | boolean;
|
|
71
79
|
constructor(value: string, duration?: TSU.Num.Fraction, octave?: number, shift?: number);
|
|
@@ -76,6 +84,7 @@ export declare class Note extends Literal {
|
|
|
76
84
|
copyTo(another: this): void;
|
|
77
85
|
}
|
|
78
86
|
export declare class Group extends Atom {
|
|
87
|
+
readonly TYPE = "Group";
|
|
79
88
|
durationIsMultiplier: boolean;
|
|
80
89
|
readonly atoms: TSU.Lists.ValueList<Atom>;
|
|
81
90
|
constructor(...atoms: Atom[]);
|
|
@@ -92,6 +101,7 @@ export declare class Group extends Atom {
|
|
|
92
101
|
removeAtoms(adjustDuration?: boolean, ...atoms: Atom[]): this;
|
|
93
102
|
}
|
|
94
103
|
export declare class Line extends Entity {
|
|
104
|
+
readonly TYPE: string;
|
|
95
105
|
offset: Fraction;
|
|
96
106
|
roles: Role[];
|
|
97
107
|
marginText: string;
|
|
@@ -107,6 +117,7 @@ export declare class Line extends Entity {
|
|
|
107
117
|
export declare class Role extends Entity {
|
|
108
118
|
readonly line: Line;
|
|
109
119
|
readonly name: string;
|
|
120
|
+
readonly TYPE = "Role";
|
|
110
121
|
defaultToNotes: boolean;
|
|
111
122
|
atoms: Atom[];
|
|
112
123
|
constructor(line: Line, name: string);
|
package/lib/cjs/core.js
CHANGED
|
@@ -42,6 +42,7 @@ var AtomType;
|
|
|
42
42
|
class Atom extends entity_1.TimedEntity {
|
|
43
43
|
constructor(duration = ONE) {
|
|
44
44
|
super();
|
|
45
|
+
this.TYPE = "Atom";
|
|
45
46
|
this.nextSibling = null;
|
|
46
47
|
this.prevSibling = null;
|
|
47
48
|
this.parentGroup = null;
|
|
@@ -79,6 +80,7 @@ exports.Atom = Atom;
|
|
|
79
80
|
class LeafAtom extends Atom {
|
|
80
81
|
constructor() {
|
|
81
82
|
super(...arguments);
|
|
83
|
+
this.TYPE = "LeafAtom";
|
|
82
84
|
this.beforeRest = false;
|
|
83
85
|
}
|
|
84
86
|
splitAt(duration) {
|
|
@@ -103,6 +105,7 @@ class Marker extends entity_1.Entity {
|
|
|
103
105
|
super();
|
|
104
106
|
this.text = text;
|
|
105
107
|
this.isBefore = isBefore;
|
|
108
|
+
this.TYPE = "Marker";
|
|
106
109
|
}
|
|
107
110
|
debugValue() {
|
|
108
111
|
return Object.assign(Object.assign({}, super.debugValue()), { text: this.text, before: this.isBefore });
|
|
@@ -115,12 +118,14 @@ exports.Marker = Marker;
|
|
|
115
118
|
class Rest extends LeafAtom {
|
|
116
119
|
constructor() {
|
|
117
120
|
super(ZERO);
|
|
121
|
+
this.TYPE = "Rest";
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
exports.Rest = Rest;
|
|
121
125
|
class Space extends LeafAtom {
|
|
122
126
|
constructor(duration = ONE, isSilent = false) {
|
|
123
127
|
super(duration);
|
|
128
|
+
this.TYPE = "Space";
|
|
124
129
|
this.isSilent = false;
|
|
125
130
|
this.isSilent = isSilent;
|
|
126
131
|
}
|
|
@@ -148,6 +153,7 @@ class Literal extends LeafAtom {
|
|
|
148
153
|
constructor(value, duration = ONE) {
|
|
149
154
|
super(duration);
|
|
150
155
|
this.value = value;
|
|
156
|
+
this.TYPE = "Literal";
|
|
151
157
|
this.embelishments = [];
|
|
152
158
|
}
|
|
153
159
|
debugValue() {
|
|
@@ -170,8 +176,12 @@ class Literal extends LeafAtom {
|
|
|
170
176
|
}
|
|
171
177
|
exports.Literal = Literal;
|
|
172
178
|
class Syllable extends Literal {
|
|
179
|
+
constructor() {
|
|
180
|
+
super(...arguments);
|
|
181
|
+
this.TYPE = "Syllable";
|
|
182
|
+
}
|
|
173
183
|
static fromLit(lit) {
|
|
174
|
-
if (lit.
|
|
184
|
+
if (lit.TYPE == AtomType.SYLLABLE)
|
|
175
185
|
return lit;
|
|
176
186
|
const out = new Syllable(lit.value, lit.duration);
|
|
177
187
|
out.embelishments = lit.embelishments;
|
|
@@ -186,13 +196,14 @@ exports.Syllable = Syllable;
|
|
|
186
196
|
class Note extends Literal {
|
|
187
197
|
constructor(value, duration = ONE, octave = 0, shift = 0) {
|
|
188
198
|
super(value, duration);
|
|
199
|
+
this.TYPE = "Note";
|
|
189
200
|
this.octave = 0;
|
|
190
201
|
this.shift = 0;
|
|
191
202
|
this.octave = octave;
|
|
192
203
|
this.shift = shift;
|
|
193
204
|
}
|
|
194
205
|
static fromLit(lit) {
|
|
195
|
-
if (lit.
|
|
206
|
+
if (lit.TYPE == AtomType.NOTE)
|
|
196
207
|
return lit;
|
|
197
208
|
const out = new Note(lit.value, lit.duration);
|
|
198
209
|
out.embelishments = lit.embelishments;
|
|
@@ -223,6 +234,7 @@ exports.Note = Note;
|
|
|
223
234
|
class Group extends Atom {
|
|
224
235
|
constructor(...atoms) {
|
|
225
236
|
super(atoms.length == 0 ? ZERO : ONE);
|
|
237
|
+
this.TYPE = "Group";
|
|
226
238
|
this.durationIsMultiplier = false;
|
|
227
239
|
this.atoms = new TSU.Lists.ValueList();
|
|
228
240
|
this.addAtoms(false, ...atoms);
|
|
@@ -321,9 +333,9 @@ class Group extends Atom {
|
|
|
321
333
|
}
|
|
322
334
|
atom.parentGroup.removeAtoms(false, atom);
|
|
323
335
|
}
|
|
324
|
-
if (atom.
|
|
336
|
+
if (atom.TYPE == AtomType.REST) {
|
|
325
337
|
const last = this.atoms.last;
|
|
326
|
-
if (last && last.
|
|
338
|
+
if (last && last.TYPE != AtomType.GROUP && last.TYPE != AtomType.LABEL) {
|
|
327
339
|
last.beforeRest = true;
|
|
328
340
|
}
|
|
329
341
|
}
|
|
@@ -378,6 +390,7 @@ exports.Group = Group;
|
|
|
378
390
|
class Line extends entity_1.Entity {
|
|
379
391
|
constructor() {
|
|
380
392
|
super(...arguments);
|
|
393
|
+
this.TYPE = "Line";
|
|
381
394
|
this.offset = ZERO;
|
|
382
395
|
this.roles = [];
|
|
383
396
|
this.marginText = "";
|
|
@@ -435,6 +448,7 @@ class Role extends entity_1.Entity {
|
|
|
435
448
|
super();
|
|
436
449
|
this.line = line;
|
|
437
450
|
this.name = name;
|
|
451
|
+
this.TYPE = "Role";
|
|
438
452
|
this.defaultToNotes = true;
|
|
439
453
|
this.atoms = [];
|
|
440
454
|
}
|
|
@@ -447,8 +461,8 @@ class Role extends entity_1.Entity {
|
|
|
447
461
|
addAtoms(...atoms) {
|
|
448
462
|
let last = null;
|
|
449
463
|
for (const atom of atoms) {
|
|
450
|
-
if (atom.
|
|
451
|
-
if (last && last.
|
|
464
|
+
if (atom.TYPE == AtomType.REST) {
|
|
465
|
+
if (last && last.TYPE != AtomType.GROUP && last.TYPE != AtomType.LABEL) {
|
|
452
466
|
last.beforeRest = true;
|
|
453
467
|
}
|
|
454
468
|
}
|