notations 0.0.44 → 0.0.45
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/README.md +38 -0
- package/lib/cjs/beats.d.ts +111 -0
- package/lib/cjs/beats.js +523 -0
- package/lib/cjs/beats.js.map +1 -0
- package/lib/cjs/carnatic/LineView.d.ts +20 -0
- package/lib/cjs/carnatic/LineView.js +69 -0
- package/lib/cjs/carnatic/LineView.js.map +1 -0
- package/lib/cjs/carnatic/NotationView.d.ts +31 -0
- package/lib/cjs/carnatic/NotationView.js +250 -0
- package/lib/cjs/carnatic/NotationView.js.map +1 -0
- package/lib/cjs/carnatic/atomviews.d.ts +14 -7
- package/lib/cjs/carnatic/atomviews.js +170 -137
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.d.ts +10 -14
- package/lib/cjs/carnatic/beatviews.js +53 -110
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.d.ts +38 -32
- package/lib/cjs/carnatic/embelishments.js +34 -19
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/carnatic/index.d.ts +2 -0
- package/lib/cjs/carnatic/index.js +2 -0
- package/lib/cjs/carnatic/index.js.map +1 -1
- package/lib/cjs/core.d.ts +15 -73
- package/lib/cjs/core.js +196 -564
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.d.ts +47 -0
- package/lib/cjs/cycle.js +492 -0
- package/lib/cjs/cycle.js.map +1 -0
- package/lib/cjs/entity.d.ts +24 -0
- package/lib/cjs/entity.js +135 -0
- package/lib/cjs/entity.js.map +1 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.js +3 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/iterators.d.ts +14 -2
- package/lib/cjs/iterators.js +77 -5
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.d.ts +7 -106
- package/lib/cjs/layouts.js +4 -478
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.d.ts +2 -1
- package/lib/cjs/loader.js +31 -26
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.d.ts +3 -1
- package/lib/cjs/notation.js +6 -4
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/parser.js +5 -4
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.d.ts +35 -14
- package/lib/cjs/shapes.js +153 -43
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.d.ts +2 -1
- package/lib/cjs/utils.js +4 -3
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/beats.d.ts +111 -0
- package/lib/esm/beats.js +501 -0
- package/lib/esm/beats.js.map +1 -0
- package/lib/esm/carnatic/LineView.d.ts +20 -0
- package/lib/esm/carnatic/LineView.js +47 -0
- package/lib/esm/carnatic/LineView.js.map +1 -0
- package/lib/esm/carnatic/NotationView.d.ts +31 -0
- package/lib/esm/carnatic/NotationView.js +228 -0
- package/lib/esm/carnatic/NotationView.js.map +1 -0
- package/lib/esm/carnatic/atomviews.d.ts +14 -7
- package/lib/esm/carnatic/atomviews.js +170 -137
- package/lib/esm/carnatic/atomviews.js.map +1 -1
- package/lib/esm/carnatic/beatviews.d.ts +10 -14
- package/lib/esm/carnatic/beatviews.js +54 -111
- package/lib/esm/carnatic/beatviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.d.ts +38 -32
- package/lib/esm/carnatic/embelishments.js +33 -18
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/carnatic/index.d.ts +2 -0
- package/lib/esm/carnatic/index.js +2 -0
- package/lib/esm/carnatic/index.js.map +1 -1
- package/lib/esm/core.d.ts +15 -73
- package/lib/esm/core.js +192 -560
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/cycle.d.ts +47 -0
- package/lib/esm/cycle.js +470 -0
- package/lib/esm/cycle.js.map +1 -0
- package/lib/esm/entity.d.ts +24 -0
- package/lib/esm/entity.js +132 -0
- package/lib/esm/entity.js.map +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/iterators.d.ts +14 -2
- package/lib/esm/iterators.js +73 -1
- package/lib/esm/iterators.js.map +1 -1
- package/lib/esm/layouts.d.ts +7 -106
- package/lib/esm/layouts.js +1 -475
- package/lib/esm/layouts.js.map +1 -1
- package/lib/esm/loader.d.ts +2 -1
- package/lib/esm/loader.js +27 -23
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.d.ts +3 -1
- package/lib/esm/notation.js +3 -1
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/parser.js +5 -4
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.d.ts +35 -14
- package/lib/esm/shapes.js +152 -42
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/utils.d.ts +2 -1
- package/lib/esm/utils.js +3 -2
- package/lib/esm/utils.js.map +1 -1
- package/package.json +30 -25
- package/styles/NotationView.scss +35 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,uBAA8D;AAE9D,yCAAuD;AAIvD,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAoBjC;IASE,cACkB,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,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C;iBACxD;;;;;;;;;YACD,IAAI,QAAQ,CAAC,MAAM,EAAE;gBACnB,IAAI,IAAI,CAAC,YAAY;oBAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aACpD;SACF;IACH,CAAC;IACH,mBAAC;AAAD,CAAC,AA1FD,IA0FC;AA1FY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { FlatAtom, WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\ninterface BeatViewDelegate {\n // A way to create all beats for an entire Line in one go (instead of one by one)\n viewForBeat(beat: Beat): BeatView;\n}\n\nexport interface BeatView {\n readonly beat: Beat;\n readonly needsLayout: boolean;\n readonly minSize: TSU.Geom.Size;\n readonly bbox: TSU.Geom.Rect;\n x: number;\n y: number;\n width: number;\n height: number;\n refreshLayout(): void;\n setStyles(config: any): void;\n}\n\nexport class Beat {\n private static idCounter = 0;\n layoutLine = -1;\n layoutColumn = -1;\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\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 ensureUniformSpaces(atoms: FlatAtom[], slotsPerBeat = 1): void {\n let lcm = 1;\n let gcd = 0;\n atoms.forEach((a, index) => {\n a.duration = a.duration.factorized;\n const currDen = a.duration.den;\n if (currDen != 1) {\n lcm *= currDen;\n if (gcd == 0) {\n gcd = a.duration.den;\n } else {\n gcd = TSU.Num.gcdof(gcd, currDen);\n lcm /= gcd;\n }\n }\n });\n\n // Easiest option is (without worrying about depths)\n // just adding this N number 1 / LCM sized spaces for\n // each note where N = (LCM / note.frac.den) - 1\n\n // eg in the case of something like (a beat with) the notes\n // A: 1/2, B: 1/4, C: 1/6\n // LCM (of dens) = 24\n // 12 (1/24) spaces, 6 (1/24)\n // A = (24 / 2) - 1 = 11 spaces after A\n // B = (24 / 4) - 1 = 5 spaces after B\n // C = (24 / 6) - 1 = 3 spaces after C\n // Total = 11 + 5 + 3 + 3 (for A + B + C) = 22 notes in the beat\n\n const baseDur = new TSU.Num.Fraction(1, lcm);\n let currOffset = this.offset;\n for (let i = 0; i < atoms.length; ) {\n const fa = atoms[i];\n const numSpaces = lcm == 1 ? fa.duration.num - 1 : lcm / fa.duration.den - 1;\n // reset its duration to 1 / LCM so we can add numSpaces after it\n fa.duration = baseDur;\n currOffset = currOffset.plus(baseDur);\n i++;\n for (let j = 0; j < numSpaces; j++, i++) {\n const space = new Space(baseDur);\n space.isContinuation = true;\n atoms.splice(i, 0, new FlatAtom(space));\n atoms.splice(i, 0, new FlatAtom(space));\n currOffset = currOffset.plus(baseDur);\n }\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 BeatLayout {\n // beatColumns[i][j] returns all beats in a particular layoutLine and\n // layoutColumn the purpose of beatColumns is to ensure horizontal alignment\n // of beats in a single column\n bcolNextList = new Map<string, Set<string>>();\n beatColumns = new Map<string, BeatColumn>();\n // bcolsStartingAt = new Map<string, BeatColumn[]>();\n // bcolsEndingAt = new Map<string, BeatColumn[]>();\n startingColumns: BeatColumn[] = [];\n\n // Mapping from beat -> BeatColumn where it resides\n columnForBeat = new Map<number, BeatColumn>();\n\n constructor(public readonly layoutParams: LayoutParams) {}\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, duration: Fraction): BeatColumn {\n const key = BeatLayout.keyFor(offset, duration);\n let bcol = this.beatColumns.get(key) || null;\n if (!bcol) {\n bcol = new BeatColumn(offset, duration);\n this.beatColumns.set(key, bcol);\n if (bcol.offset.isZero) {\n // this is a \"starting\" column\n this.startingColumns.push(bcol);\n } else {\n const endOffset = offset.plus(duration);\n // Find all columns \"before\" this and add this as a neighbour to those\n // columsn before are such that their prev.offset + prev.duration == bcol.offset\n for (const other of this.beatColumns.values()) {\n if (other.offset.plus(other.duration).equals(offset)) {\n // mark us as a successor of other\n this.addSuccessor(other, bcol);\n } else if (other.offset.equals(endOffset)) {\n // mark other as a successor of us\n this.addSuccessor(bcol, other);\n }\n }\n\n // Similary find all columns who could \"next\" sets and add us to them\n }\n }\n return bcol;\n }\n\n protected static keyFor(offset: Fraction, duration: Fraction): string {\n return offset.factorized.toString() + \":\" + duration.factorized.toString();\n }\n\n protected addSuccessor(prev: BeatColumn, next: BeatColumn): void {\n TSU.assert(prev.offset.plus(prev.duration).equals(next.offset), \"BeatColumns are not adjacent to each other\");\n const prevKey = BeatLayout.keyFor(prev.offset, prev.duration);\n const nextKey = BeatLayout.keyFor(next.offset, next.duration);\n let nextset = this.bcolNextList.get(prevKey) || null;\n if (!nextset) {\n nextset = new Set<string>();\n this.bcolNextList.set(prevKey, nextset);\n }\n nextset.add(nextKey);\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which this beat was added.\n */\n addBeat(beat: Beat): BeatColumn {\n // Get the beat column at this index (and line) and add to it.\n const lp = this.layoutParams;\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const bcol = this.getBeatColumn(rowOffset, beat.duration);\n\n bcol.add(beat);\n\n // TODO: see if beat exists in another column\n this.columnForBeat.set(beat.uuid, bcol);\n beat.layoutLine = layoutLine;\n beat.layoutColumn = layoutColumn;\n return bcol;\n }\n\n /**\n * Return all beat columns that start immediately after the given beat column.\n */\n neighborsOf(beatColumn: BeatColumn): BeatColumn[] {\n const out: BeatColumn[] = [];\n const endOffset = beatColumn.offset.plus(beatColumn.duration);\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n out.push(other);\n }\n }\n return out;\n }\n\n readonly DEBUG = false;\n evalColumnSizes(beatViewDelegate: BeatViewDelegate): void {\n // Do a bread first traversal of the beat columns so those with earlier offsets\n // will be laid out and nudged so that later ones' offsets can be set only once.\n // TODO - should this be a priority queue - ie is there a need to sort these by\n // \"larger\" widths first?\n let queue: BeatColumn[] = [...this.startingColumns];\n const xForOffsets: TSU.StringMap<number> = {};\n while (queue.length > 0) {\n const nextQueue: BeatColumn[] = [];\n for (const bcol of queue) {\n const offset = bcol.offset.factorized;\n const colWidth = bcol.evalMaxWidth(beatViewDelegate);\n let currX = 0;\n if (!bcol.offset.isZero) {\n // this *must* be in xForOffsets as it would have been calculated by a previous bcol\n TSU.assert(offset.toString() in xForOffsets, \"Cannot find x for given offset\");\n currX = xForOffsets[offset.toString()];\n }\n bcol.setX(currX, beatViewDelegate);\n const endOffset = offset.plus(bcol.duration, true);\n xForOffsets[endOffset.toString()] = Math.max(\n xForOffsets[endOffset.toString()] || 0,\n currX + colWidth + bcol.paddingLeft + bcol.paddingRight,\n );\n // add all neighbours here\n // TODO - Use better lists of going through all beat cols\n // Also ensure we are adding in sorted order and avoiding duplicates\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n nextQueue.push(other);\n }\n }\n }\n queue = nextQueue;\n }\n }\n\n // Spacing between each role in a single row\n roleSpacing = 10;\n\n // Spacing between each row (a row can consist of multiple roles).\n rowSpacing = 15;\n layoutBeatsForLine(line: Line, allRoleBeats: Beat[][], beatViewDelegate: BeatViewDelegate): void {\n // Instead of starting currLayoutLine at 0 - it should start at the line of the\n // first beat being rendered\n const lp = this.layoutParams;\n const currBeats = line.roles.map((l, index) => allRoleBeats[index][0]) as (Beat | null)[];\n let currY = this.roleSpacing;\n let numDone = 0;\n do {\n numDone = 0;\n // Lay one role at a time upto numBeatsInLine number of beats\n for (let currRole = 0; currRole < currBeats.length; currRole++) {\n let currBeat: Beat | null = currBeats[currRole];\n if (currBeat) {\n const temp = currBeat;\n const numBeatsInRow = lp.lineBreaks[currBeat.layoutLine];\n let maxHeight = 0;\n let currX = 15;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.y = currY;\n if (this.DEBUG) {\n beatView.x = currX;\n beatView.refreshLayout();\n currX += beatView.width;\n }\n maxHeight = Math.max(maxHeight, beatView.minSize.height);\n }\n\n currBeat = temp;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.height = maxHeight;\n }\n // Should line heights be \"fixed\"?\n // Set height of all views in this row to same height and Y\n currY += maxHeight;\n currY += this.roleSpacing;\n }\n currBeats[currRole] = currBeat;\n }\n\n // currLayoutLine = (currLayoutLine + 1) % lp.lineBreaks.length;\n currY += this.rowSpacing;\n } while (numDone > 0);\n }\n}\n\nexport class BeatRow {\n protected _y = 0;\n protected _maxHeight = 0;\n needsLayout = false;\n rowSpacing = 5;\n beats: Beat[] = [];\n constructor(public readonly layoutLine: number, public rowIndex: number) {}\n\n get y(): number {\n return this._y;\n }\n\n set y(val: number) {\n this._y = val;\n this.needsLayout = true;\n }\n\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added to either this row or another row?\n this.beats.push(beat);\n this.needsLayout = true;\n }\n}\n\nexport class BeatColumn {\n protected _x = 0;\n protected _maxWidth = 0;\n needsLayout = false;\n atomSpacing = 5;\n paddingLeft = 15;\n paddingRight = 15;\n beats: Beat[] = [];\n constructor(public readonly offset: Fraction, public readonly duration: Fraction) {\n offset = offset.factorized;\n duration = duration.factorized;\n }\n\n get x(): number {\n return this._x;\n }\n\n setX(val: number, beatViewDelegate: BeatViewDelegate): void {\n this._x = val;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n beatView.x = val + this.paddingLeft;\n beatView.width = this._maxWidth;\n // console.log(\"ID, Setting x, width: \", beatView.beat.index, (beatView as any).x, (beatView as any).width);\n }\n }\n\n get maxWidth(): number {\n return this._maxWidth + this.paddingLeft + this.paddingRight;\n }\n\n setPadding(left: number, right: number): void {\n if (left >= 0) {\n this.paddingLeft = left;\n }\n if (right >= 0) {\n this.paddingRight = right;\n }\n }\n\n evalMaxWidth(beatViewDelegate: BeatViewDelegate): number {\n this._maxWidth = 0;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n // console.log( \"index, _minSize, refreshMinSize = \", beatView.beat.index, (beatView as any)._minSize, (beatView as any).refreshMinSize(),);\n const minSize = beatView.minSize;\n if (minSize.width > this._maxWidth) {\n this._maxWidth = minSize.width;\n }\n }\n return this._maxWidth;\n }\n\n /**\n * Adds a new beat to this column.\n * Returns true if the column's width has increased. This is an indicator\n * to the caller that a layout of all other views in this column is needed\n * so the refresh can be scheduled at some time.\n */\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added?\n this.beats.push(beat);\n this.needsLayout = true;\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 ) {\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 at beginning\n // of a cycle. Butif the start offset is < 0 then the startIndex should also shift\n // accordingly\n this.startIndex = index;\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 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"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as TSU from "@panyam/tsutils";
|
|
2
|
+
import { Beat, BeatLayout } from "../beats";
|
|
3
|
+
import { BeatView } from "./beatviews";
|
|
4
|
+
import { Line } from "../core";
|
|
5
|
+
export declare class LineView {
|
|
6
|
+
readonly rootElement: SVGSVGElement;
|
|
7
|
+
line: Line;
|
|
8
|
+
readonly config?: any;
|
|
9
|
+
beatsByLineRole: Beat[][];
|
|
10
|
+
beatLayout: BeatLayout;
|
|
11
|
+
gElem: SVGGElement;
|
|
12
|
+
roleSpacing: number;
|
|
13
|
+
rowSpacing: number;
|
|
14
|
+
constructor(rootElement: SVGSVGElement, line: Line, config?: any);
|
|
15
|
+
protected loadChildViews(): void;
|
|
16
|
+
wrapToSize(): void;
|
|
17
|
+
get prefSize(): TSU.Geom.Size;
|
|
18
|
+
beatViews: Map<number, BeatView>;
|
|
19
|
+
viewForBeat(beat: Beat): BeatView;
|
|
20
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.LineView = void 0;
|
|
23
|
+
var TSU = __importStar(require("@panyam/tsutils"));
|
|
24
|
+
var beatviews_1 = require("./beatviews");
|
|
25
|
+
var LineView = (function () {
|
|
26
|
+
function LineView(rootElement, line, config) {
|
|
27
|
+
this.rootElement = rootElement;
|
|
28
|
+
this.line = line;
|
|
29
|
+
this.config = config;
|
|
30
|
+
this.roleSpacing = 20;
|
|
31
|
+
this.rowSpacing = 10;
|
|
32
|
+
this.beatViews = new Map();
|
|
33
|
+
this.loadChildViews();
|
|
34
|
+
}
|
|
35
|
+
LineView.prototype.loadChildViews = function () {
|
|
36
|
+
this.gElem = TSU.DOM.createSVGNode("g", {
|
|
37
|
+
parent: this.rootElement,
|
|
38
|
+
attrs: {
|
|
39
|
+
class: "lineRoot",
|
|
40
|
+
id: "lineRoot" + this.line.uuid,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
LineView.prototype.wrapToSize = function () {
|
|
45
|
+
var bbox = this.gElem.getBBox();
|
|
46
|
+
this.rootElement.setAttribute("width", "" + (4 + bbox.width));
|
|
47
|
+
this.rootElement.setAttribute("height", "" + (15 + bbox.height));
|
|
48
|
+
this.gElem.setAttribute("transform", "translate(".concat(4 - bbox.x, ", ").concat(4 - bbox.y, ")"));
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(LineView.prototype, "prefSize", {
|
|
51
|
+
get: function () {
|
|
52
|
+
var bbox = this.rootElement.getBBox();
|
|
53
|
+
return new TSU.Geom.Size(4 + bbox.width, 4 + bbox.height);
|
|
54
|
+
},
|
|
55
|
+
enumerable: false,
|
|
56
|
+
configurable: true
|
|
57
|
+
});
|
|
58
|
+
LineView.prototype.viewForBeat = function (beat) {
|
|
59
|
+
if (!this.beatViews.has(beat.uuid)) {
|
|
60
|
+
var b = new beatviews_1.BeatView(beat, this.gElem, this.beatLayout.layoutParams.cycle);
|
|
61
|
+
this.beatViews.set(beat.uuid, b);
|
|
62
|
+
return b;
|
|
63
|
+
}
|
|
64
|
+
return this.beatViews.get(beat.uuid);
|
|
65
|
+
};
|
|
66
|
+
return LineView;
|
|
67
|
+
}());
|
|
68
|
+
exports.LineView = LineView;
|
|
69
|
+
//# sourceMappingURL=LineView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LineView.js","sourceRoot":"","sources":["../../../src/carnatic/LineView.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AAEvC,yCAAuC;AAGvC;IAeE,kBAA4B,WAA0B,EAAS,IAAU,EAAkB,MAAY;QAA3E,gBAAW,GAAX,WAAW,CAAe;QAAS,SAAI,GAAJ,IAAI,CAAM;QAAkB,WAAM,GAAN,MAAM,CAAM;QALvG,gBAAW,GAAG,EAAE,CAAC;QAGjB,eAAU,GAAG,EAAE,CAAC;QA+BhB,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;QA5BtC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAES,iCAAc,GAAxB;QAEE,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YACtC,MAAM,EAAE,IAAI,CAAC,WAAW;YACxB,KAAK,EAAE;gBACL,KAAK,EAAE,UAAU;gBACjB,EAAE,EAAE,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI;aAChC;SACF,CAAgB,CAAC;IACpB,CAAC;IAED,6BAAU,GAAV;QACE,IAAM,IAAI,GAAI,IAAI,CAAC,KAAuB,CAAC,OAAO,EAAE,CAAC;QAErD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,oBAAa,CAAC,GAAG,IAAI,CAAC,CAAC,eAAK,CAAC,GAAG,IAAI,CAAC,CAAC,MAAG,CAAC,CAAC;IAClF,CAAC;IAED,sBAAI,8BAAQ;aAAZ;YACE,IAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAExC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAC;;;OAAA;IAGD,8BAAW,GAAX,UAAY,IAAU;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAElC,IAAM,CAAC,GAAG,IAAI,oBAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAE7E,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACjC,OAAO,CAAC,CAAC;SACV;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC;IACxC,CAAC;IACH,eAAC;AAAD,CAAC,AAvDD,IAuDC;AAvDY,4BAAQ","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Beat, BeatLayout } from \"../beats\";\nimport { BeatView } from \"./beatviews\";\nimport { Line } from \"../core\";\n\nexport class LineView {\n // roleStates: RoleState[];\n // For each line a mapping of its Atoms in each role grouped by Beat for layout\n beatsByLineRole: Beat[][];\n // The beat layout associated with the layout params of this Line\n // at this point beats have already been added to the right columns\n beatLayout: BeatLayout;\n gElem: SVGGElement;\n\n // Space between two roles (within the same row)\n roleSpacing = 20;\n\n // Vertical space between two rows (of multiple roles)\n rowSpacing = 10;\n\n constructor(public readonly rootElement: SVGSVGElement, public line: Line, public readonly config?: any) {\n this.loadChildViews();\n }\n\n protected loadChildViews(): void {\n // create the gElem for wrapping and adjusting to size\n this.gElem = TSU.DOM.createSVGNode(\"g\", {\n parent: this.rootElement,\n attrs: {\n class: \"lineRoot\",\n id: \"lineRoot\" + this.line.uuid,\n },\n }) as SVGGElement;\n }\n\n wrapToSize(): void {\n const bbox = (this.gElem as SVGSVGElement).getBBox();\n // set the size of the svg\n this.rootElement.setAttribute(\"width\", \"\" + (4 + bbox.width));\n this.rootElement.setAttribute(\"height\", \"\" + (15 + bbox.height));\n this.gElem.setAttribute(\"transform\", `translate(${4 - bbox.x}, ${4 - bbox.y})`);\n }\n\n get prefSize(): TSU.Geom.Size {\n const bbox = this.rootElement.getBBox();\n // return new TSU.Geom.Size(4 + bbox.width + bbox.x, 4 + bbox.y + bbox.height);\n return new TSU.Geom.Size(4 + bbox.width, 4 + bbox.height);\n }\n\n beatViews = new Map<number, BeatView>();\n viewForBeat(beat: Beat): BeatView {\n if (!this.beatViews.has(beat.uuid)) {\n // how to get the bar and beat index for a given beat in a given row?\n const b = new BeatView(beat, this.gElem, this.beatLayout.layoutParams.cycle);\n // Check if this needs bar start/end lines?\n this.beatViews.set(beat.uuid, b);\n return b;\n }\n return this.beatViews.get(beat.uuid)!;\n }\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as TSU from "@panyam/tsutils";
|
|
2
|
+
import { LineView } from "./LineView";
|
|
3
|
+
import { Notation, RawBlock } from "../notation";
|
|
4
|
+
import { Beat, BeatLayout, BeatView } from "../beats";
|
|
5
|
+
import { Line } from "../core";
|
|
6
|
+
export declare class NotationView {
|
|
7
|
+
readonly rootElement: HTMLElement;
|
|
8
|
+
readonly config?: any;
|
|
9
|
+
headerElement: HTMLDivElement;
|
|
10
|
+
notation: Notation;
|
|
11
|
+
lineViews: LineView[];
|
|
12
|
+
beatsByLineRole: Map<number, Beat[][]>;
|
|
13
|
+
beatLayouts: Map<number, BeatLayout>;
|
|
14
|
+
currentSVGElement: SVGSVGElement | null;
|
|
15
|
+
tableElement: HTMLTableElement;
|
|
16
|
+
beatViews: Map<number, BeatView>;
|
|
17
|
+
markdownParser: (contents: string) => string;
|
|
18
|
+
constructor(rootElement: HTMLElement, config?: any);
|
|
19
|
+
refresh(): void;
|
|
20
|
+
viewForBeat(beat: Beat): BeatView;
|
|
21
|
+
loadChildViews(): void;
|
|
22
|
+
addNewRow(id: string, prefix: string, withAnnotation?: boolean): [HTMLElement, HTMLElement];
|
|
23
|
+
newLineRoot(parent: Element, line: Line): SVGSVGElement;
|
|
24
|
+
ensureLineView(line: Line): LineView;
|
|
25
|
+
getLineView(line: Line): TSU.Nullable<LineView>;
|
|
26
|
+
get currentLineView(): LineView;
|
|
27
|
+
clear(): void;
|
|
28
|
+
refreshLayout(): void;
|
|
29
|
+
renderLine(line: Line): LineView;
|
|
30
|
+
renderBlock(raw: RawBlock): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
22
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
23
|
+
if (!m) return o;
|
|
24
|
+
var i = m.call(o), r, ar = [], e;
|
|
25
|
+
try {
|
|
26
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
27
|
+
}
|
|
28
|
+
catch (error) { e = { error: error }; }
|
|
29
|
+
finally {
|
|
30
|
+
try {
|
|
31
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
32
|
+
}
|
|
33
|
+
finally { if (e) throw e.error; }
|
|
34
|
+
}
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.NotationView = void 0;
|
|
50
|
+
var TSU = __importStar(require("@panyam/tsutils"));
|
|
51
|
+
var LineView_1 = require("./LineView");
|
|
52
|
+
var NotationView = (function () {
|
|
53
|
+
function NotationView(rootElement, config) {
|
|
54
|
+
this.rootElement = rootElement;
|
|
55
|
+
this.config = config;
|
|
56
|
+
this.lineViews = [];
|
|
57
|
+
this.beatsByLineRole = new Map();
|
|
58
|
+
this.beatLayouts = new Map();
|
|
59
|
+
this.currentSVGElement = null;
|
|
60
|
+
this.beatViews = new Map();
|
|
61
|
+
this.loadChildViews();
|
|
62
|
+
}
|
|
63
|
+
NotationView.prototype.refresh = function () {
|
|
64
|
+
this.beatViews = new Map();
|
|
65
|
+
};
|
|
66
|
+
NotationView.prototype.viewForBeat = function (beat) {
|
|
67
|
+
var curr = this.beatViews.get(beat.uuid) || null;
|
|
68
|
+
if (curr == null) {
|
|
69
|
+
var lineView = this.ensureLineView(beat.role.line);
|
|
70
|
+
curr = lineView.viewForBeat(beat);
|
|
71
|
+
this.beatViews.set(beat.uuid, curr);
|
|
72
|
+
}
|
|
73
|
+
return curr;
|
|
74
|
+
};
|
|
75
|
+
NotationView.prototype.loadChildViews = function () {
|
|
76
|
+
this.tableElement = TSU.DOM.createNode("table", {
|
|
77
|
+
parent: this.rootElement,
|
|
78
|
+
attrs: {
|
|
79
|
+
class: "notationsContentRootTable",
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
NotationView.prototype.addNewRow = function (id, prefix, withAnnotation) {
|
|
84
|
+
if (withAnnotation === void 0) { withAnnotation = true; }
|
|
85
|
+
var tr = TSU.DOM.createNode("tr", {
|
|
86
|
+
parent: this.tableElement,
|
|
87
|
+
attrs: {
|
|
88
|
+
class: prefix + "Row",
|
|
89
|
+
id: prefix + "Row" + id,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
var td1 = null;
|
|
93
|
+
if (withAnnotation) {
|
|
94
|
+
td1 = TSU.DOM.createNode("td", {
|
|
95
|
+
parent: tr,
|
|
96
|
+
attrs: {
|
|
97
|
+
class: prefix + "AnnotationCell",
|
|
98
|
+
id: prefix + "Annotation" + id,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
var td2 = TSU.DOM.createNode("td", {
|
|
103
|
+
parent: tr,
|
|
104
|
+
attrs: {
|
|
105
|
+
class: prefix + "ContentCell",
|
|
106
|
+
id: prefix + "Content" + id,
|
|
107
|
+
colspan: withAnnotation ? 1 : 2,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
return [td1, td2];
|
|
111
|
+
};
|
|
112
|
+
NotationView.prototype.newLineRoot = function (parent, line) {
|
|
113
|
+
var _a = __read(this.addNewRow(line.uuid + "", "line"), 2), td1 = _a[0], td2 = _a[1];
|
|
114
|
+
if (line.marginText) {
|
|
115
|
+
td1.innerHTML = line.marginText;
|
|
116
|
+
}
|
|
117
|
+
return TSU.DOM.createSVGNode("svg", {
|
|
118
|
+
parent: td2,
|
|
119
|
+
attrs: {
|
|
120
|
+
style: "margin-bottom: 10px",
|
|
121
|
+
class: "lineRootSVG",
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
NotationView.prototype.ensureLineView = function (line) {
|
|
126
|
+
var lineView = this.getLineView(line);
|
|
127
|
+
if (lineView == null) {
|
|
128
|
+
var layoutParams = this.notation.layoutParamsForLine(line) || null;
|
|
129
|
+
var svgElem = this.newLineRoot(this.tableElement, line);
|
|
130
|
+
lineView = new LineView_1.LineView(svgElem, line, {
|
|
131
|
+
layoutParams: layoutParams,
|
|
132
|
+
});
|
|
133
|
+
if (!line.isEmpty) {
|
|
134
|
+
TSU.assert(layoutParams != null, "Layout params for a non empty line *should* exist");
|
|
135
|
+
var beatLayout = this.beatLayouts.get(layoutParams.uuid);
|
|
136
|
+
lineView.beatLayout = beatLayout;
|
|
137
|
+
}
|
|
138
|
+
lineView.beatsByLineRole = this.beatsByLineRole.get(line.uuid);
|
|
139
|
+
this.lineViews.push(lineView);
|
|
140
|
+
}
|
|
141
|
+
return lineView;
|
|
142
|
+
};
|
|
143
|
+
NotationView.prototype.getLineView = function (line) {
|
|
144
|
+
return this.lineViews.find(function (l) { return l.line == line; }) || null;
|
|
145
|
+
};
|
|
146
|
+
Object.defineProperty(NotationView.prototype, "currentLineView", {
|
|
147
|
+
get: function () {
|
|
148
|
+
return this.lineViews[this.lineViews.length - 1];
|
|
149
|
+
},
|
|
150
|
+
enumerable: false,
|
|
151
|
+
configurable: true
|
|
152
|
+
});
|
|
153
|
+
NotationView.prototype.clear = function () {
|
|
154
|
+
this.lineViews = [];
|
|
155
|
+
this.beatsByLineRole = new Map();
|
|
156
|
+
this.beatLayouts = new Map();
|
|
157
|
+
this.currentSVGElement = null;
|
|
158
|
+
this.tableElement.innerHTML = "";
|
|
159
|
+
this.beatViews = new Map();
|
|
160
|
+
};
|
|
161
|
+
NotationView.prototype.refreshLayout = function () {
|
|
162
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
163
|
+
var lines = [];
|
|
164
|
+
var lineViews = [];
|
|
165
|
+
try {
|
|
166
|
+
for (var _e = __values(this.notation.blocks), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
167
|
+
var block = _f.value;
|
|
168
|
+
if (block.type == "RawBlock") {
|
|
169
|
+
this.renderBlock(block);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
lines.push(block);
|
|
173
|
+
var lineView = this.renderLine(block);
|
|
174
|
+
lineViews.push(lineView);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
179
|
+
finally {
|
|
180
|
+
try {
|
|
181
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
182
|
+
}
|
|
183
|
+
finally { if (e_1) throw e_1.error; }
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
for (var _g = __values(this.beatLayouts.values()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
187
|
+
var bl = _h.value;
|
|
188
|
+
bl.evalColumnSizes(this);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
192
|
+
finally {
|
|
193
|
+
try {
|
|
194
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
195
|
+
}
|
|
196
|
+
finally { if (e_2) throw e_2.error; }
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
for (var _j = __values(this.beatViews.values()), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
200
|
+
var beatView = _k.value;
|
|
201
|
+
beatView.refreshLayout();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
205
|
+
finally {
|
|
206
|
+
try {
|
|
207
|
+
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
208
|
+
}
|
|
209
|
+
finally { if (e_3) throw e_3.error; }
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
for (var lineViews_1 = __values(lineViews), lineViews_1_1 = lineViews_1.next(); !lineViews_1_1.done; lineViews_1_1 = lineViews_1.next()) {
|
|
213
|
+
var lineView = lineViews_1_1.value;
|
|
214
|
+
lineView.wrapToSize();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
218
|
+
finally {
|
|
219
|
+
try {
|
|
220
|
+
if (lineViews_1_1 && !lineViews_1_1.done && (_d = lineViews_1.return)) _d.call(lineViews_1);
|
|
221
|
+
}
|
|
222
|
+
finally { if (e_4) throw e_4.error; }
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
NotationView.prototype.renderLine = function (line) {
|
|
226
|
+
var lineView = this.ensureLineView(line);
|
|
227
|
+
if (!line.isEmpty) {
|
|
228
|
+
lineView.beatLayout.layoutBeatsForLine(line, lineView.beatsByLineRole, this);
|
|
229
|
+
}
|
|
230
|
+
return lineView;
|
|
231
|
+
};
|
|
232
|
+
NotationView.prototype.renderBlock = function (raw) {
|
|
233
|
+
var _a = __read(this.addNewRow(raw.uuid + "", "rawBlock", false), 2), td2 = _a[1];
|
|
234
|
+
var div = td2.appendChild(TSU.DOM.createNode("div"));
|
|
235
|
+
if (raw.contentType == "metadata") {
|
|
236
|
+
var meta = this.notation.metadata.get(raw.content);
|
|
237
|
+
if (meta) {
|
|
238
|
+
var html = "<span class = \"".concat(meta.key.toLowerCase(), "\"><strong>").concat(meta.key, "</strong>: ").concat(meta.value, "</span>");
|
|
239
|
+
div.innerHTML = html;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
div.innerHTML = this.markdownParser(raw.content.trim());
|
|
244
|
+
}
|
|
245
|
+
this.currentSVGElement = null;
|
|
246
|
+
};
|
|
247
|
+
return NotationView;
|
|
248
|
+
}());
|
|
249
|
+
exports.NotationView = NotationView;
|
|
250
|
+
//# sourceMappingURL=NotationView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotationView.js","sourceRoot":"","sources":["../../../src/carnatic/NotationView.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,uCAAsC;AAKtC;IAYE,sBAA4B,WAAwB,EAAkB,MAAY;QAAtD,gBAAW,GAAX,WAAW,CAAa;QAAkB,WAAM,GAAN,MAAM,CAAM;QATlF,cAAS,GAAe,EAAE,CAAC;QAE3B,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAC;QAC9C,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC5C,sBAAiB,GAAyB,IAAI,CAAC;QAE/C,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;QAItC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED,8BAAO,GAAP;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC/C,CAAC;IAED,kCAAW,GAAX,UAAY,IAAU;QACpB,IAAI,IAAI,GAAG,IAAI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,IAAA,KAAA,OAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,IAAA,EAAvD,GAAG,QAAoD,CAAC;QACjE,IAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACvD,IAAI,GAAG,CAAC,WAAW,IAAI,UAAU,EAAE;YAEjC,IAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,IAAI,EAAE;gBACR,IAAM,IAAI,GAAG,0BAAkB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,IAAI,CAAC,GAAG,wBAAc,IAAI,CAAC,KAAK,YAAS,CAAC;gBAC5G,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;aACtB;SACF;aAAM;YACL,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;SACzD;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;IACH,mBAAC;AAAD,CAAC,AAtLD,IAsLC;AAtLY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { LineView } from \"./LineView\";\nimport { Notation, RawBlock } from \"../notation\";\nimport { Beat, BeatLayout, BeatView } from \"../beats\";\nimport { Line } from \"../core\";\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 beatsByLineRole = new Map<number, Beat[][]>();\n beatLayouts = new Map<number, BeatLayout>();\n currentSVGElement: SVGSVGElement | null = null;\n tableElement: HTMLTableElement;\n beatViews = new Map<number, BeatView>();\n markdownParser: (contents: string) => string;\n\n constructor(public readonly rootElement: HTMLElement, public readonly config?: any) {\n this.loadChildViews();\n }\n\n refresh(): void {\n this.beatViews = new Map<number, BeatView>();\n }\n\n viewForBeat(beat: Beat): BeatView {\n let curr = this.beatViews.get(beat.uuid) || null;\n if (curr == null) {\n // how to get the bar and beat index for a given beat in a given row?\n const lineView = this.ensureLineView(beat.role.line);\n curr = lineView.viewForBeat(beat);\n this.beatViews.set(beat.uuid, curr);\n }\n return curr;\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 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 = this.notation.layoutParamsForLine(line) || 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 const beatLayout = this.beatLayouts.get(layoutParams.uuid)!;\n lineView.beatLayout = beatLayout;\n }\n lineView.beatsByLineRole = this.beatsByLineRole.get(line.uuid)!;\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.beatsByLineRole = new Map<number, Beat[][]>();\n this.beatLayouts = new Map<number, BeatLayout>();\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.renderLine(block as Line);\n lineViews.push(lineView);\n }\n }\n\n // Eval column sizes all beat layouts\n for (const bl of this.beatLayouts.values()) {\n bl.evalColumnSizes(this);\n }\n\n // now that all spacing has been calculated\n // go through all\n for (const beatView of this.beatViews.values()) {\n beatView.refreshLayout();\n }\n\n // Set line view preferred sizes\n for (const lineView of lineViews) {\n lineView.wrapToSize();\n }\n }\n\n renderLine(line: Line): LineView {\n const lineView = this.ensureLineView(line);\n // Layout the \"rows\" for this line - x has already been set by the\n // previous column spacing step\n if (!line.isEmpty) {\n lineView.beatLayout.layoutBeatsForLine(line, lineView.beatsByLineRole, this);\n }\n return lineView;\n }\n\n renderBlock(raw: RawBlock): void {\n const [, td2] = this.addNewRow(raw.uuid + \"\", \"rawBlock\", false);\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n if (raw.contentType == \"metadata\") {\n // we have a metadata block\n const meta = this.notation.metadata.get(raw.content);\n if (meta) {\n const html = `<span class = \"${meta.key.toLowerCase()}\"><strong>${meta.key}</strong>: ${meta.value}</span>`;\n div.innerHTML = html;\n }\n } else {\n div.innerHTML = this.markdownParser(raw.content.trim());\n }\n this.currentSVGElement = null;\n }\n}\n"]}
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare
|
|
2
|
+
import { Atom } from "../core";
|
|
3
|
+
import { LeafAtomView as LeafAtomViewBase, GroupView as GroupViewBase, AtomView, Embelishment, ElementShape } from "../shapes";
|
|
4
|
+
export declare class GroupView extends GroupViewBase {
|
|
5
|
+
createAtomView(atom: Atom): AtomView;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class LeafAtomView extends LeafAtomViewBase {
|
|
5
8
|
leftSlot: Embelishment[];
|
|
6
9
|
topSlot: Embelishment[];
|
|
7
10
|
rightSlot: Embelishment[];
|
|
8
11
|
bottomSlot: Embelishment[];
|
|
12
|
+
glyph: ElementShape;
|
|
9
13
|
protected postSpacingSpan: SVGTSpanElement;
|
|
10
|
-
protected
|
|
14
|
+
protected rootGroup: ElementShape;
|
|
15
|
+
protected rootText: ElementShape;
|
|
11
16
|
abstract get glyphLabel(): string;
|
|
17
|
+
protected refreshBBox(): TSU.Geom.Rect;
|
|
12
18
|
protected refreshMinSize(): TSU.Geom.Size;
|
|
13
19
|
protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
|
|
20
|
+
protected layoutElements(): void;
|
|
14
21
|
refreshLayout(): void;
|
|
15
22
|
protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void;
|
|
16
23
|
orderEmbelishments(): void;
|
|
24
|
+
embRoot(): SVGGraphicsElement;
|
|
17
25
|
needsRootElement(): boolean;
|
|
18
26
|
createElements(parent: SVGGraphicsElement): void;
|
|
19
27
|
protected createGlyphRoot(parent: SVGGraphicsElement): void;
|
|
28
|
+
protected createGlyphElement(): void;
|
|
20
29
|
protected createPostSpacingElement(): void;
|
|
21
|
-
protected moveGlyphToRoot(): void;
|
|
22
|
-
protected createGlyphElement(parent: SVGGraphicsElement): void;
|
|
23
30
|
}
|
|
24
|
-
export declare function createAtomView(parent: SVGGraphicsElement, atom:
|
|
31
|
+
export declare function createAtomView(parent: SVGGraphicsElement, atom: Atom, litDefaultsToNote?: boolean, groupViewScale?: number): AtomView;
|