notations 0.0.53 → 0.0.55

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.
@@ -19,6 +19,7 @@ export declare class NotationView {
19
19
  get beatLayout(): GlobalBeatLayout;
20
20
  set beatLayout(beatLayout: GlobalBeatLayout);
21
21
  loadChildViews(): void;
22
+ renderNotation(notation: Notation, beatLayout: GlobalBeatLayout): void;
22
23
  addNewRow(id: string, prefix: string, withAnnotation?: boolean): [HTMLElement, HTMLElement];
23
24
  newLineRoot(parent: Element, line: Line): SVGSVGElement;
24
25
  ensureLineView(line: Line): LineView;
@@ -52,6 +52,14 @@ class NotationView {
52
52
  },
53
53
  });
54
54
  }
55
+ renderNotation(notation, beatLayout) {
56
+ this.notation = notation;
57
+ this.beatLayout = beatLayout;
58
+ const startTime = performance.now();
59
+ this.refreshLayout();
60
+ const layoutTime = performance.now();
61
+ console.log(`V4 Document, Layout Time: ${layoutTime - startTime}ms`);
62
+ }
55
63
  addNewRow(id, prefix, withAnnotation = true) {
56
64
  const tr = TSU.DOM.createNode("tr", {
57
65
  parent: this.tableElement,
@@ -1 +1 @@
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;QAAtD,gBAAW,GAAX,WAAW,CAAa;QAAkB,WAAM,GAAN,MAAM,CAAM;QAPlF,cAAS,GAAe,EAAE,CAAC;QAE3B,sBAAiB,GAAyB,IAAI,CAAC;QA+J/C,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;QACxC,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;QA1J1C,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WA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BAC/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;AApMD,oCAoMC","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 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/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AI,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"]}
package/lib/cjs/loader.js CHANGED
@@ -40,6 +40,7 @@ function parse(input) {
40
40
  }
41
41
  exports.parse = parse;
42
42
  function load(codeText, config = {}) {
43
+ codeText = codeText || "";
43
44
  const beatLayout = new beats_1.GlobalBeatLayout();
44
45
  const startTime = performance.now();
45
46
  const [notation, errors] = parse(codeText);
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":";;;;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AC,GAAG,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,GAAG,SAAS,mBAAmB,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC;KAC5G;IACD,OAAO;QACL,QAAQ;QACR,UAAU;QACV,MAAM;QACN;YACE,SAAS,EAAE,SAAS,GAAG,SAAS;YAChC,SAAS,EAAE,SAAS,GAAG,SAAS;SACjC;KACF,CAAC;AACJ,CAAC;AAjCD,oBAiCC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport { Line } from \"./core\";\nimport { GlobalBeatLayout } from \"./beats\";\nimport { Parser } from \"./parser\";\nimport { Notation } from \"./notation\";\n\nexport function parse(input: string): [Notation, G.ParseError[]] {\n const notation = new Notation();\n const parser = new Parser();\n const errors: G.ParseError[] = [];\n parser.parse(input);\n errors.push(...parser.errors);\n for (const cmd of parser.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n}\n\nexport function load(\n codeText: string,\n config: any = {},\n): [Notation, GlobalBeatLayout, G.ParseError[], TSU.StringMap<number>] {\n const beatLayout = new GlobalBeatLayout();\n const startTime = performance.now();\n const [notation, errors] = parse(codeText);\n const parseTime = performance.now();\n\n // Create Line Beats\n for (const block of notation.blocks) {\n if (block.type == \"Line\" && !(block as Line).isEmpty) {\n const line = block as Line;\n // LP should exist by now\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(line.layoutParams != null, \"Layout params for a non empty line *SHOULD* exist\");\n beatLayout.addLine(line);\n }\n }\n\n const buildTime = performance.now();\n if (config.log) {\n console.log(`V4 Document, Parse Time: ${parseTime - startTime}ms, Build Time: ${buildTime - parseTime}ms`);\n }\n return [\n notation,\n beatLayout,\n errors,\n {\n parseTime: parseTime - startTime,\n buildTime: buildTime - parseTime,\n },\n ];\n}\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;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M,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,GAAG,SAAS,mBAAmB,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC;KAC5G;IACD,OAAO;QACL,QAAQ;QACR,UAAU;QACV,MAAM;QACN;YACE,SAAS,EAAE,SAAS,GAAG,SAAS;YAChC,SAAS,EAAE,SAAS,GAAG,SAAS;SACjC;KACF,CAAC;AACJ,CAAC;AAlCD,oBAkCC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport { Line } from \"./core\";\nimport { GlobalBeatLayout } from \"./beats\";\nimport { Parser } from \"./parser\";\nimport { Notation } from \"./notation\";\n\nexport function parse(input: string): [Notation, G.ParseError[]] {\n const notation = new Notation();\n const parser = new Parser();\n const errors: G.ParseError[] = [];\n parser.parse(input);\n errors.push(...parser.errors);\n for (const cmd of parser.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n}\n\nexport function load(\n codeText: string,\n config: any = {},\n): [Notation, GlobalBeatLayout, G.ParseError[], TSU.StringMap<number>] {\n codeText = codeText || \"\";\n const beatLayout = new GlobalBeatLayout();\n const startTime = performance.now();\n const [notation, errors] = parse(codeText);\n const parseTime = performance.now();\n\n // Create Line Beats\n for (const block of notation.blocks) {\n if (block.type == \"Line\" && !(block as Line).isEmpty) {\n const line = block as Line;\n // LP should exist by now\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(line.layoutParams != null, \"Layout params for a non empty line *SHOULD* exist\");\n beatLayout.addLine(line);\n }\n }\n\n const buildTime = performance.now();\n if (config.log) {\n console.log(`V4 Document, Parse Time: ${parseTime - startTime}ms, Build Time: ${buildTime - parseTime}ms`);\n }\n return [\n notation,\n beatLayout,\n errors,\n {\n parseTime: parseTime - startTime,\n buildTime: buildTime - parseTime,\n },\n ];\n}\n"]}
@@ -19,6 +19,7 @@ export declare class NotationView {
19
19
  get beatLayout(): GlobalBeatLayout;
20
20
  set beatLayout(beatLayout: GlobalBeatLayout);
21
21
  loadChildViews(): void;
22
+ renderNotation(notation: Notation, beatLayout: GlobalBeatLayout): void;
22
23
  addNewRow(id: string, prefix: string, withAnnotation?: boolean): [HTMLElement, HTMLElement];
23
24
  newLineRoot(parent: Element, line: Line): SVGSVGElement;
24
25
  ensureLineView(line: Line): LineView;
@@ -26,6 +26,14 @@ export class NotationView {
26
26
  },
27
27
  });
28
28
  }
29
+ renderNotation(notation, beatLayout) {
30
+ this.notation = notation;
31
+ this.beatLayout = beatLayout;
32
+ const startTime = performance.now();
33
+ this.refreshLayout();
34
+ const layoutTime = performance.now();
35
+ console.log(`V4 Document, Layout Time: ${layoutTime - startTime}ms`);
36
+ }
29
37
  addNewRow(id, prefix, withAnnotation = true) {
30
38
  const tr = TSU.DOM.createNode("tr", {
31
39
  parent: this.tableElement,
@@ -1 +1 @@
1
- {"version":3,"file":"NotationView.js","sourceRoot":"","sources":["../../../src/carnatic/NotationView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,OAAO,YAAY;IAUvB,YAA4B,WAAwB,EAAkB,MAAY;QAAtD,gBAAW,GAAX,WAAW,CAAa;QAAkB,WAAM,GAAN,MAAM,CAAM;QAPlF,cAAS,GAAe,EAAE,CAAC;QAE3B,sBAAiB,GAAyB,IAAI,CAAC;QA+J/C,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;QACxC,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;QA1J1C,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,UAAU,CAAC,UAA4B;QACzC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,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D,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF","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 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,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CA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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,UAAU,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","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"]}
package/lib/esm/loader.js CHANGED
@@ -13,6 +13,7 @@ export function parse(input) {
13
13
  return [notation, errors];
14
14
  }
15
15
  export function load(codeText, config = {}) {
16
+ codeText = codeText || "";
16
17
  const beatLayout = new GlobalBeatLayout();
17
18
  const startTime = performance.now();
18
19
  const [notation, errors] = parse(codeText);
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAA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AAC,GAAG,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,GAAG,SAAS,mBAAmB,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC;KAC5G;IACD,OAAO;QACL,QAAQ;QACR,UAAU;QACV,MAAM;QACN;YACE,SAAS,EAAE,SAAS,GAAG,SAAS;YAChC,SAAS,EAAE,SAAS,GAAG,SAAS;SACjC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport { Line } from \"./core\";\nimport { GlobalBeatLayout } from \"./beats\";\nimport { Parser } from \"./parser\";\nimport { Notation } from \"./notation\";\n\nexport function parse(input: string): [Notation, G.ParseError[]] {\n const notation = new Notation();\n const parser = new Parser();\n const errors: G.ParseError[] = [];\n parser.parse(input);\n errors.push(...parser.errors);\n for (const cmd of parser.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n}\n\nexport function load(\n codeText: string,\n config: any = {},\n): [Notation, GlobalBeatLayout, G.ParseError[], TSU.StringMap<number>] {\n const beatLayout = new GlobalBeatLayout();\n const startTime = performance.now();\n const [notation, errors] = parse(codeText);\n const parseTime = performance.now();\n\n // Create Line Beats\n for (const block of notation.blocks) {\n if (block.type == \"Line\" && !(block as Line).isEmpty) {\n const line = block as Line;\n // LP should exist by now\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(line.layoutParams != null, \"Layout params for a non empty line *SHOULD* exist\");\n beatLayout.addLine(line);\n }\n }\n\n const buildTime = performance.now();\n if (config.log) {\n console.log(`V4 Document, Parse Time: ${parseTime - startTime}ms, Build Time: ${buildTime - parseTime}ms`);\n }\n return [\n notation,\n beatLayout,\n errors,\n {\n parseTime: parseTime - startTime,\n buildTime: buildTime - parseTime,\n },\n ];\n}\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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AC3F,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;KACF;IAED,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,GAAG,SAAS,mBAAmB,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC;KAC5G;IACD,OAAO;QACL,QAAQ;QACR,UAAU;QACV,MAAM;QACN;YACE,SAAS,EAAE,SAAS,GAAG,SAAS;YAChC,SAAS,EAAE,SAAS,GAAG,SAAS;SACjC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport { Line } from \"./core\";\nimport { GlobalBeatLayout } from \"./beats\";\nimport { Parser } from \"./parser\";\nimport { Notation } from \"./notation\";\n\nexport function parse(input: string): [Notation, G.ParseError[]] {\n const notation = new Notation();\n const parser = new Parser();\n const errors: G.ParseError[] = [];\n parser.parse(input);\n errors.push(...parser.errors);\n for (const cmd of parser.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n}\n\nexport function load(\n codeText: string,\n config: any = {},\n): [Notation, GlobalBeatLayout, G.ParseError[], TSU.StringMap<number>] {\n codeText = codeText || \"\";\n const beatLayout = new GlobalBeatLayout();\n const startTime = performance.now();\n const [notation, errors] = parse(codeText);\n const parseTime = performance.now();\n\n // Create Line Beats\n for (const block of notation.blocks) {\n if (block.type == \"Line\" && !(block as Line).isEmpty) {\n const line = block as Line;\n // LP should exist by now\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(line.layoutParams != null, \"Layout params for a non empty line *SHOULD* exist\");\n beatLayout.addLine(line);\n }\n }\n\n const buildTime = performance.now();\n if (config.log) {\n console.log(`V4 Document, Parse Time: ${parseTime - startTime}ms, Build Time: ${buildTime - parseTime}ms`);\n }\n return [\n notation,\n beatLayout,\n errors,\n {\n parseTime: parseTime - startTime,\n buildTime: buildTime - parseTime,\n },\n ];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notations",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "author": "Sriram Panyam",
5
5
  "description": "A package for modelling, parsing, laying out carnatic musical notation",
6
6
  "homepage": "https://github.com/panyam/notations#readme",
@@ -31,5 +31,5 @@
31
31
 
32
32
  .notationsContentRootTable {
33
33
  border-top: solid 1px gray;
34
- width: unset;
34
+ width: 100%;
35
35
  }