notations 0.0.49 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/beats.d.ts +3 -3
- package/lib/cjs/beats.js +57 -3
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/beatview.js +2 -2
- package/lib/cjs/beatview.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.d.ts +4 -3
- package/lib/cjs/carnatic/NotationView.js +26 -9
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.d.ts +19 -0
- package/lib/cjs/carnatic/beatviews.js +71 -1
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.js +1 -1
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/parser.js +11 -6
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/esm/beats.d.ts +3 -3
- package/lib/esm/beats.js +58 -4
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/beatview.js +2 -2
- package/lib/esm/beatview.js.map +1 -1
- package/lib/esm/carnatic/NotationView.d.ts +4 -3
- package/lib/esm/carnatic/NotationView.js +27 -10
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/carnatic/beatviews.d.ts +19 -0
- package/lib/esm/carnatic/beatviews.js +46 -0
- package/lib/esm/carnatic/beatviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.js +1 -1
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/parser.js +11 -6
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.js.map +1 -1
- package/package.json +1 -1
package/lib/cjs/parser.js
CHANGED
|
@@ -97,20 +97,25 @@ const [parser, itemGraph] = G.newParser(String.raw `
|
|
|
97
97
|
Atoms -> Atoms Atom { concatAtoms } ;
|
|
98
98
|
Atoms -> { newArray } ;
|
|
99
99
|
|
|
100
|
-
Atom ->
|
|
101
|
-
|
|
102
|
-
| Atom POST_MARKER { applyPostMarker }
|
|
100
|
+
Atom -> Atom POST_MARKER { applyPostMarker }
|
|
101
|
+
| PreMarkedAtom
|
|
103
102
|
;
|
|
104
|
-
|
|
103
|
+
PreMarkedAtom -> Leaf
|
|
104
|
+
| PRE_MARKER PreMarkedAtom { applyPreMarker }
|
|
105
|
+
;
|
|
106
|
+
|
|
105
107
|
Leaf -> Space | Lit | Group | Rest ;
|
|
108
|
+
Leaf -> Duration Leaf { applyDuration } ;
|
|
106
109
|
Rest -> HYPHEN { newRest };
|
|
107
|
-
|
|
108
110
|
Space -> COMMA { newSpace }
|
|
109
111
|
| SEMI_COLON { newDoubleSpace }
|
|
110
112
|
| UNDER_SCORE { newSilentSpace }
|
|
111
113
|
;
|
|
112
114
|
|
|
113
|
-
/* - An alternative representation to support both pre and
|
|
115
|
+
/* - An alternative representation to support both pre and
|
|
116
|
+
* post embelishment operators. Here PRE_EMBs have a higher
|
|
117
|
+
* associativity over POST_EMBs
|
|
118
|
+
*/
|
|
114
119
|
Lit -> Lit POST_EMB { litWithPostEmb }
|
|
115
120
|
| PreEmbLit
|
|
116
121
|
;
|
package/lib/cjs/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,0CAA4B;AAC5B,2CAA6B;AAC7B,iCAA6F;AAE7F,yCAWoB;AAGpB,qDAAuC;AAEvC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AACjC,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAW5B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,CACrC,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;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AC9C;IACH,CAAC;IAED,UAAU,CAAC,GAAY;QACrB,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAa;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE;YAChC,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY,EAAE,CAAC,GAAwB,EAAE,EAAE;gBACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtB,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB,CAAC,KAAa;QAC7B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAxND,wBAwNC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport * as TLEX from \"tlex\";\nimport { Literal, AtomType, Note, Atom, Rest, Space, Syllable, Group, Marker } from \"./core\";\nimport { Command, CmdParam } from \"./notation\";\nimport {\n RawEmbedding,\n ApplyLayout,\n AddAtoms,\n SetCycle,\n SetBeatDuration,\n SetBreaks,\n ActivateRole,\n CreateRole,\n CreateLine,\n MetaData,\n} from \"./commands\";\n\n// TODO - Make this plugable from the client instead of hard coded\nimport * as carnatic from \"./carnatic\";\n\nconst ONE = TSU.Num.Fraction.ONE;\nconst TWO = ONE.timesNum(2);\n\n/**\n * V4 of our parser builds on V3 and has the following improvements:\n *\n * 1. Embedding Headings to demarcate sections so users dont have to use\n * explicit MD for headings.\n * 2. Unlike V3 here users break out *of* song instead instead break out \"into\"\n * song. So users spend more time writing notation and less worrying about\n * other things like headings etc.\n */\nconst [parser, itemGraph] = G.newParser(\n String.raw`\n %define IdentChar /[^%!@&\\^|\\[\\]={}()+\\-,;~: \\t\\f\\r\\n\\v\\\\\\.]/\n\n %token BSLASH \"\\\\\"\n %token OPEN_SQ \"[\"\n %token CLOSE_SQ \"]\"\n %token EQUALS \"=\"\n %token OPEN_PAREN \"(\"\n %token CLOSE_PAREN \")\"\n %token OPEN_BRACE \"{\"\n %token CLOSE_BRACE \"}\"\n %token SLASH \"/\"\n %token STAR \"*\"\n %token CARET \"^\"\n // %skip \"-\"\n %token COMMA \",\"\n %token SEMI_COLON \";\"\n %token COLON \":\"\n\n %token SINGLE_LINE_RAW_STRING />(.*)$/m { toSingleLineRawString }\n %token MULTI_LINE_RAW_STRING /r(#{0,})\"/ { toMultiLineRawString }\n\n %token EMBELISHMENT /~[^\\s]*/ { toEmbelishment }\n %token NUMBER /-?\\d+/ { toNumber }\n %token BOOLEAN /true|false/ { toBoolean }\n %token POST_MARKER /<<\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\"/ { toMarker }\n %token POST_MARKER /<<'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'/ { toMarker }\n %token PRE_MARKER /\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\">>/ { toMarker }\n %token PRE_MARKER /'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'>>/ { toMarker }\n %token STRING /\"([^\"\\\\\\n]|\\\\.|\\\\\\n)*\"/ { toString }\n %token STRING /'([^'\\\\\\n]|\\\\.|\\\\\\n)*'/ { toString }\n %token DOTS_IDENT /(\\.+)({IdentChar}+)/ { toOctavedNote }\n %token IDENT_DOTS /({IdentChar}+)(\\.+)/ { toOctavedNote }\n %token IDENT_COLON /{IdentChar}+:/ { toRoleSelector }\n %token IDENT /{IdentChar}+/\n %token BSLASH_IDENT /\\\\{IDENT}/ { toCommandName }\n %token BSLASH_NUMBER /\\\\{NUMBER}/\n %token HYPHEN /-/\n %skip /[ \\t\\n\\f\\r]+/\n %skip_flex \"//.*$\"\n %skip /\\/\\*.*?\\*\\//\n\n Elements -> Elements Command Atoms { appendCommand } \n | Elements RoleSelector Atoms { appendRoleSelector } \n | Elements Embedding Atoms { insertEmbedding }\n | Atoms { appendAtoms }\n ;\n\n Embedding -> SINGLE_LINE_RAW_STRING | MULTI_LINE_RAW_STRING ;\n\n Command -> BSLASH_IDENT CommandParams ? { newCommand } ;\n CommandParams -> OPEN_PAREN ParamList ? CLOSE_PAREN { $2 } ;\n\n ParamList -> ParamList COMMA Param { concatParamList } ;\n ParamList -> Param { newParamList };\n Param -> ParamValue { newParam } ;\n Param -> ParamKey EQUALS ParamValue { newParam } ;\n ParamKey -> IDENT ;\n ParamValue -> ( STRING | Fraction | NUMBER | BOOLEAN ) ;\n\n RoleSelector -> IDENT_COLON ;\n\n Atoms -> Atoms Atom { concatAtoms } ;\n Atoms -> { newArray } ;\n\n Atom -> Duration Leaf { applyDuration } ;\n Atom -> PRE_MARKER Atom { applyPreMarker }\n | Atom POST_MARKER { applyPostMarker }\n ;\n Atom -> Leaf ;\n Leaf -> Space | Lit | Group | Rest ;\n Rest -> HYPHEN { newRest };\n\n Space -> COMMA { newSpace } \n | SEMI_COLON { newDoubleSpace } \n | UNDER_SCORE { newSilentSpace } \n ;\n\n /* - An alternative representation to support both pre and post embelishment operators. */\n Lit -> Lit POST_EMB { litWithPostEmb }\n | PreEmbLit\n ;\n\n PreEmbLit -> LitToken \n | LitToken CARET NUMBER { litWithCaret }\n | LitToken CARET STAR { litWithCaret }\n | PRE_EMB PreEmbLit { litWithPreEmb }\n ;\n \n LitToken -> DOTS_IDENT { litToAtom }\n | IDENT { litToAtom }\n | IDENT_DOTS { litToAtom }\n | STRING { litToAtom }\n ;\n\n Group -> OPEN_SQ Atoms CLOSE_SQ { newGroup };\n\n Duration -> Fraction | NUMBER;\n Fraction -> NUMBER SLASH NUMBER { newFraction } ;\n `,\n {\n allowLeftRecursion: true,\n debug: \"\",\n type: \"lalr\",\n tokenHandlers: {\n toEmbelishment: (token: TLEX.Token, tape: TLEX.Tape, owner: Parser) => {\n const [emb, pre] = owner.parseEmbelishment(token.value);\n if (emb == null) {\n console.log(\"Skipping Embelishment: \", token.value);\n owner.errors.push(\n new TLEX.TokenizerError(\n `Invalid embelishment: ${token.value}`,\n token.start,\n 1 + token.end - token.start,\n \"InvalidEmbelishment\",\n token.value,\n ),\n );\n return null;\n }\n token.value = emb;\n token.tag = pre ? \"PRE_EMB\" : \"POST_EMB\";\n return token;\n },\n toCommandName: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value.substring(1);\n return token;\n },\n toBoolean: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value == \"true\";\n return token;\n },\n toNumber: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = parseInt(token.value);\n return token;\n },\n toString: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value.substring(1, token.value.length - 1);\n return token;\n },\n toMarker: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n if (token.tag != \"PRE_MARKER\" && token.tag != \"POST_MARKER\") {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n const isBefore = token.tag == \"PRE_MARKER\";\n const markerText = isBefore\n ? token.value.substring(1, token.value.length - 3)\n : token.value.substring(3, token.value.length - 1);\n // console.log(\"TokVal: \", token.value, token.positions);\n // console.log(\"Marker Text: \", markerText, isBefore);\n token.value = new Marker(markerText, isBefore);\n return token;\n },\n toOctavedNote: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n if (token.tag == \"DOTS_IDENT\") {\n const octave = token.positions[1][1] - token.positions[1][0];\n const note = token.value.substring(octave);\n token.value = new Note(note, ONE, -octave);\n } else if (token.tag == \"IDENT_DOTS\") {\n const octave = token.positions[2][1] - token.positions[2][0];\n const note = token.value.substring(0, token.value.length - octave);\n token.value = new Note(note, ONE, octave);\n } else {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n return token;\n },\n toRoleSelector: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value.substring(0, token.value.length - 1);\n return token;\n },\n toLineAnnotation: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n // skip the initial \"!\"\n token.value = token.value.substring(1);\n return token;\n },\n toSingleLineRawString: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n // skip the initial \">\"\n token.value = token.value.substring(1);\n return token;\n },\n toMultiLineRawString: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n // consume everything until \"#<N times> as start\n const hashes = tape.substring(token.positions[1][0], token.positions[1][1]);\n const endPat = '\"' + hashes;\n const startPos = tape.index;\n const endPos = TLEX.TapeHelper.advanceAfter(tape, endPat) - endPat.length;\n if (endPos < 0) {\n throw new Error(\"EOF expected while finding end of Raw String Literal: '\" + endPat + \"'\");\n }\n token.value = tape.substring(startPos, endPos);\n return token;\n },\n },\n },\n);\n\n/**\n * A notation doc is a list of lines that are found in a single document.\n *\n * Since our document (md or html etc) can contain multiple snippets\n * all these snippets are related\n */\nexport class Parser {\n errors: TLEX.TokenizerError[] = [];\n readonly commands: Command[] = [];\n // readonly notation: Notation = new Notation();\n private runCommandFound = false;\n // readonly parseTree = new PTNodeList(\"Snippet\", null);\n\n protected ruleHandlers = {\n newFraction: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return new TSU.Num.Fraction(children[0].value);\n } else {\n return new TSU.Num.Fraction(children[0].value, children[2].value);\n }\n },\n newGroup: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const out = new Group(...children[1].value).setDuration(TWO, true);\n return out;\n },\n litWithCaret: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = Note.fromLit(children[0].value as Literal);\n const opnode = children[2];\n const shiftValue = opnode.sym.label == \"STAR\" ? true : opnode.value;\n lit.shift = shiftValue;\n return lit;\n },\n litWithPreEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const emb = children[0];\n const lit = children[1].value as Literal;\n lit.embelishments.splice(0, 0, emb.value);\n return lit;\n },\n litWithPostEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0].value as Literal;\n const emb = children[1];\n lit.embelishments.push(emb);\n return lit;\n },\n litToAtom: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0];\n if (lit.sym.label == \"DOTS_IDENT\" || lit.sym.label == \"IDENT_DOTS\") {\n return lit.value;\n } else if (lit.sym.label == \"IDENT\") {\n // Mark this as a Literal to be processed later\n return new Literal(lit.value);\n // return role.notesOnly ? new Note(lit.value) : new Syllable(lit.value);\n } else if (lit.sym.label == \"STRING\") {\n // const role = this.snippet.currRole;\n // if (role.notesOnly) throw new Error(\"Strings cannot appear in notes only mode\");\n return new Syllable(lit.value);\n } else {\n throw new Error(\"Invalid lit: \" + lit);\n }\n },\n newSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Space();\n },\n newRest: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Rest();\n },\n newDoubleSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Space(ONE.timesNum(2));\n },\n newSilentSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Space(ONE, true);\n },\n applyPreMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const marker = children[0].value as Marker;\n const leaf = children[1].value as Atom;\n // console.log(\"marker, leaf: \", marker, leaf);\n if (!leaf.markersBefore) {\n leaf.markersBefore = [];\n }\n leaf.markersBefore.splice(0, 0, marker);\n return leaf;\n },\n applyPostMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const leaf = children[0].value as Atom;\n const marker = children[1].value as Marker;\n if (!leaf.markersAfter) {\n leaf.markersAfter = [];\n }\n leaf.markersAfter.push(marker);\n return leaf;\n },\n applyDuration: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n let dur = children[0].value as TSU.Num.Fraction | number;\n const leaf = children[1].value as Atom;\n if (typeof dur === \"number\") {\n dur = ONE.timesNum(dur);\n }\n if (leaf.type == AtomType.GROUP) {\n (leaf as Group).setDuration(dur, true);\n } else {\n leaf.duration = dur;\n }\n return leaf;\n },\n newArray: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // create an array of values from all the values of child nodes\n return children.map((c) => c.value);\n },\n concatAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value;\n const atom = children[1].value;\n atoms.push(atom);\n return atoms;\n },\n newParam: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return { key: null, value: children[0].value };\n } else {\n return { key: children[0].value, value: children[2].value };\n }\n },\n newParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return [children[0].value];\n },\n concatParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const params = children[0].value;\n const newParam = children[2].value;\n params.push(newParam);\n return params;\n },\n newCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return this.createCommand(children[0].value, children[1].value);\n },\n appendAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n appendCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const command = children[1].value as Command;\n this.addCommand(command);\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n appendRoleSelector: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const roleName = children[1].value;\n const lName = roleName.toLowerCase().trim();\n this.addCommand(new ActivateRole([{ key: null, value: lName }]));\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n insertEmbedding: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // How to handle embeddings - these are just blocks\n // to escape out of song (most likely for some rendering of html/md etc)\n const rawVal = children[1].value;\n this.addCommand(new RawEmbedding([{ key: null, value: rawVal }]));\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n };\n\n constructor(config?: any) {\n config = config || {};\n }\n\n createCommand(name: string, params: CmdParam[]): Command {\n const lName = name.trim().toLowerCase();\n params = params || [];\n if (lName == \"line\") {\n return new CreateLine(params);\n } else if (lName == \"meta\") {\n return new MetaData(params);\n } else if (lName == \"role\") {\n return new CreateRole(params);\n } else if (lName == \"layout\") {\n return new ApplyLayout(params);\n } else if (lName == \"beatduration\") {\n return new SetBeatDuration(params);\n } else if (lName == \"breaks\") {\n return new SetBreaks(params);\n } else if (lName == \"cycle\") {\n return new SetCycle(params);\n } else {\n // Try to set this as the current role\n throw new Error(\"Invalid command: \" + lName);\n }\n }\n\n addCommand(cmd: Command): void {\n cmd.index = this.commands.length;\n this.commands.push(cmd);\n }\n\n parse(input: string): any {\n this.errors = [];\n const ptree = parser.parse(input, {\n tokenizerContext: this,\n ruleHandlers: this.ruleHandlers,\n onTokenError: (err: TLEX.TokenizerError) => {\n this.errors.push(err);\n return true;\n },\n });\n return ptree;\n }\n\n parseEmbelishment(value: string): [any, boolean] {\n return carnatic.parseEmbelishment(value);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,0CAA4B;AAC5B,2CAA6B;AAC7B,iCAA6F;AAE7F,yCAWoB;AAGpB,qDAAuC;AAEvC,MAAM,GAAG,GAAG,GAAG,CAAC,G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AC5B,OAAO,IAAI,oBAAS,CAAC,MAAM,CAAC,CAAC;SAC9B;aAAM,IAAI,KAAK,IAAI,OAAO,EAAE;YAC3B,OAAO,IAAI,mBAAQ,CAAC,MAAM,CAAC,CAAC;SAC7B;aAAM;YAEL,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;SAC9C;IACH,CAAC;IAED,UAAU,CAAC,GAAY;QACrB,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAa;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE;YAChC,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY,EAAE,CAAC,GAAwB,EAAE,EAAE;gBACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtB,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB,CAAC,KAAa;QAC7B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAxND,wBAwNC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport * as TLEX from \"tlex\";\nimport { Literal, AtomType, Note, Atom, Rest, Space, Syllable, Group, Marker } from \"./core\";\nimport { Command, CmdParam } from \"./notation\";\nimport {\n RawEmbedding,\n ApplyLayout,\n AddAtoms,\n SetCycle,\n SetBeatDuration,\n SetBreaks,\n ActivateRole,\n CreateRole,\n CreateLine,\n MetaData,\n} from \"./commands\";\n\n// TODO - Make this plugable from the client instead of hard coded\nimport * as carnatic from \"./carnatic\";\n\nconst ONE = TSU.Num.Fraction.ONE;\nconst TWO = ONE.timesNum(2);\n\n/**\n * V4 of our parser builds on V3 and has the following improvements:\n *\n * 1. Embedding Headings to demarcate sections so users dont have to use\n * explicit MD for headings.\n * 2. Unlike V3 here users break out *of* song instead instead break out \"into\"\n * song. So users spend more time writing notation and less worrying about\n * other things like headings etc.\n */\nconst [parser, itemGraph] = G.newParser(\n String.raw`\n %define IdentChar /[^%!@&\\^|\\[\\]={}()+\\-,;~: \\t\\f\\r\\n\\v\\\\\\.]/\n\n %token BSLASH \"\\\\\"\n %token OPEN_SQ \"[\"\n %token CLOSE_SQ \"]\"\n %token EQUALS \"=\"\n %token OPEN_PAREN \"(\"\n %token CLOSE_PAREN \")\"\n %token OPEN_BRACE \"{\"\n %token CLOSE_BRACE \"}\"\n %token SLASH \"/\"\n %token STAR \"*\"\n %token CARET \"^\"\n // %skip \"-\"\n %token COMMA \",\"\n %token SEMI_COLON \";\"\n %token COLON \":\"\n\n %token SINGLE_LINE_RAW_STRING />(.*)$/m { toSingleLineRawString }\n %token MULTI_LINE_RAW_STRING /r(#{0,})\"/ { toMultiLineRawString }\n\n %token EMBELISHMENT /~[^\\s]*/ { toEmbelishment }\n %token NUMBER /-?\\d+/ { toNumber }\n %token BOOLEAN /true|false/ { toBoolean }\n %token POST_MARKER /<<\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\"/ { toMarker }\n %token POST_MARKER /<<'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'/ { toMarker }\n %token PRE_MARKER /\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\">>/ { toMarker }\n %token PRE_MARKER /'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'>>/ { toMarker }\n %token STRING /\"([^\"\\\\\\n]|\\\\.|\\\\\\n)*\"/ { toString }\n %token STRING /'([^'\\\\\\n]|\\\\.|\\\\\\n)*'/ { toString }\n %token DOTS_IDENT /(\\.+)({IdentChar}+)/ { toOctavedNote }\n %token IDENT_DOTS /({IdentChar}+)(\\.+)/ { toOctavedNote }\n %token IDENT_COLON /{IdentChar}+:/ { toRoleSelector }\n %token IDENT /{IdentChar}+/\n %token BSLASH_IDENT /\\\\{IDENT}/ { toCommandName }\n %token BSLASH_NUMBER /\\\\{NUMBER}/\n %token HYPHEN /-/\n %skip /[ \\t\\n\\f\\r]+/\n %skip_flex \"//.*$\"\n %skip /\\/\\*.*?\\*\\//\n\n Elements -> Elements Command Atoms { appendCommand } \n | Elements RoleSelector Atoms { appendRoleSelector } \n | Elements Embedding Atoms { insertEmbedding }\n | Atoms { appendAtoms }\n ;\n\n Embedding -> SINGLE_LINE_RAW_STRING | MULTI_LINE_RAW_STRING ;\n\n Command -> BSLASH_IDENT CommandParams ? { newCommand } ;\n CommandParams -> OPEN_PAREN ParamList ? CLOSE_PAREN { $2 } ;\n\n ParamList -> ParamList COMMA Param { concatParamList } ;\n ParamList -> Param { newParamList };\n Param -> ParamValue { newParam } ;\n Param -> ParamKey EQUALS ParamValue { newParam } ;\n ParamKey -> IDENT ;\n ParamValue -> ( STRING | Fraction | NUMBER | BOOLEAN ) ;\n\n RoleSelector -> IDENT_COLON ;\n\n Atoms -> Atoms Atom { concatAtoms } ;\n Atoms -> { newArray } ;\n\n Atom -> Atom POST_MARKER { applyPostMarker }\n | PreMarkedAtom\n ;\n PreMarkedAtom -> Leaf\n | PRE_MARKER PreMarkedAtom { applyPreMarker }\n ;\n\n Leaf -> Space | Lit | Group | Rest ;\n Leaf -> Duration Leaf { applyDuration } ;\n Rest -> HYPHEN { newRest };\n Space -> COMMA { newSpace } \n | SEMI_COLON { newDoubleSpace } \n | UNDER_SCORE { newSilentSpace } \n ;\n\n /* - An alternative representation to support both pre and\n * post embelishment operators. Here PRE_EMBs have a higher\n * associativity over POST_EMBs\n */\n Lit -> Lit POST_EMB { litWithPostEmb }\n | PreEmbLit\n ;\n\n PreEmbLit -> LitToken \n | LitToken CARET NUMBER { litWithCaret }\n | LitToken CARET STAR { litWithCaret }\n | PRE_EMB PreEmbLit { litWithPreEmb }\n ;\n \n LitToken -> DOTS_IDENT { litToAtom }\n | IDENT { litToAtom }\n | IDENT_DOTS { litToAtom }\n | STRING { litToAtom }\n ;\n\n Group -> OPEN_SQ Atoms CLOSE_SQ { newGroup };\n\n Duration -> Fraction | NUMBER;\n Fraction -> NUMBER SLASH NUMBER { newFraction } ;\n `,\n {\n allowLeftRecursion: true,\n debug: \"\",\n type: \"lalr\",\n tokenHandlers: {\n toEmbelishment: (token: TLEX.Token, tape: TLEX.Tape, owner: Parser) => {\n const [emb, pre] = owner.parseEmbelishment(token.value);\n if (emb == null) {\n console.log(\"Skipping Embelishment: \", token.value);\n owner.errors.push(\n new TLEX.TokenizerError(\n `Invalid embelishment: ${token.value}`,\n token.start,\n 1 + token.end - token.start,\n \"InvalidEmbelishment\",\n token.value,\n ),\n );\n return null;\n }\n token.value = emb;\n token.tag = pre ? \"PRE_EMB\" : \"POST_EMB\";\n return token;\n },\n toCommandName: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value.substring(1);\n return token;\n },\n toBoolean: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value == \"true\";\n return token;\n },\n toNumber: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = parseInt(token.value);\n return token;\n },\n toString: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value.substring(1, token.value.length - 1);\n return token;\n },\n toMarker: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n if (token.tag != \"PRE_MARKER\" && token.tag != \"POST_MARKER\") {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n const isBefore = token.tag == \"PRE_MARKER\";\n const markerText = isBefore\n ? token.value.substring(1, token.value.length - 3)\n : token.value.substring(3, token.value.length - 1);\n // console.log(\"TokVal: \", token.value, token.positions);\n // console.log(\"Marker Text: \", markerText, isBefore);\n token.value = new Marker(markerText, isBefore);\n return token;\n },\n toOctavedNote: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n if (token.tag == \"DOTS_IDENT\") {\n const octave = token.positions[1][1] - token.positions[1][0];\n const note = token.value.substring(octave);\n token.value = new Note(note, ONE, -octave);\n } else if (token.tag == \"IDENT_DOTS\") {\n const octave = token.positions[2][1] - token.positions[2][0];\n const note = token.value.substring(0, token.value.length - octave);\n token.value = new Note(note, ONE, octave);\n } else {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n return token;\n },\n toRoleSelector: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n token.value = token.value.substring(0, token.value.length - 1);\n return token;\n },\n toLineAnnotation: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n // skip the initial \"!\"\n token.value = token.value.substring(1);\n return token;\n },\n toSingleLineRawString: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n // skip the initial \">\"\n token.value = token.value.substring(1);\n return token;\n },\n toMultiLineRawString: (token: TLEX.Token, tape: TLEX.Tape, owner: any) => {\n // consume everything until \"#<N times> as start\n const hashes = tape.substring(token.positions[1][0], token.positions[1][1]);\n const endPat = '\"' + hashes;\n const startPos = tape.index;\n const endPos = TLEX.TapeHelper.advanceAfter(tape, endPat) - endPat.length;\n if (endPos < 0) {\n throw new Error(\"EOF expected while finding end of Raw String Literal: '\" + endPat + \"'\");\n }\n token.value = tape.substring(startPos, endPos);\n return token;\n },\n },\n },\n);\n\n/**\n * A notation doc is a list of lines that are found in a single document.\n *\n * Since our document (md or html etc) can contain multiple snippets\n * all these snippets are related\n */\nexport class Parser {\n errors: TLEX.TokenizerError[] = [];\n readonly commands: Command[] = [];\n // readonly notation: Notation = new Notation();\n private runCommandFound = false;\n // readonly parseTree = new PTNodeList(\"Snippet\", null);\n\n protected ruleHandlers = {\n newFraction: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return new TSU.Num.Fraction(children[0].value);\n } else {\n return new TSU.Num.Fraction(children[0].value, children[2].value);\n }\n },\n newGroup: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const out = new Group(...children[1].value).setDuration(TWO, true);\n return out;\n },\n litWithCaret: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = Note.fromLit(children[0].value as Literal);\n const opnode = children[2];\n const shiftValue = opnode.sym.label == \"STAR\" ? true : opnode.value;\n lit.shift = shiftValue;\n return lit;\n },\n litWithPreEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const emb = children[0];\n const lit = children[1].value as Literal;\n lit.embelishments.splice(0, 0, emb.value);\n return lit;\n },\n litWithPostEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0].value as Literal;\n const emb = children[1];\n lit.embelishments.push(emb);\n return lit;\n },\n litToAtom: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0];\n if (lit.sym.label == \"DOTS_IDENT\" || lit.sym.label == \"IDENT_DOTS\") {\n return lit.value;\n } else if (lit.sym.label == \"IDENT\") {\n // Mark this as a Literal to be processed later\n return new Literal(lit.value);\n // return role.notesOnly ? new Note(lit.value) : new Syllable(lit.value);\n } else if (lit.sym.label == \"STRING\") {\n // const role = this.snippet.currRole;\n // if (role.notesOnly) throw new Error(\"Strings cannot appear in notes only mode\");\n return new Syllable(lit.value);\n } else {\n throw new Error(\"Invalid lit: \" + lit);\n }\n },\n newSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Space();\n },\n newRest: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Rest();\n },\n newDoubleSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Space(ONE.timesNum(2));\n },\n newSilentSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return new Space(ONE, true);\n },\n applyPreMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const marker = children[0].value as Marker;\n const leaf = children[1].value as Atom;\n // console.log(\"marker, leaf: \", marker, leaf);\n if (!leaf.markersBefore) {\n leaf.markersBefore = [];\n }\n leaf.markersBefore.splice(0, 0, marker);\n return leaf;\n },\n applyPostMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const leaf = children[0].value as Atom;\n const marker = children[1].value as Marker;\n if (!leaf.markersAfter) {\n leaf.markersAfter = [];\n }\n leaf.markersAfter.push(marker);\n return leaf;\n },\n applyDuration: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n let dur = children[0].value as TSU.Num.Fraction | number;\n const leaf = children[1].value as Atom;\n if (typeof dur === \"number\") {\n dur = ONE.timesNum(dur);\n }\n if (leaf.type == AtomType.GROUP) {\n (leaf as Group).setDuration(dur, true);\n } else {\n leaf.duration = dur;\n }\n return leaf;\n },\n newArray: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // create an array of values from all the values of child nodes\n return children.map((c) => c.value);\n },\n concatAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value;\n const atom = children[1].value;\n atoms.push(atom);\n return atoms;\n },\n newParam: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return { key: null, value: children[0].value };\n } else {\n return { key: children[0].value, value: children[2].value };\n }\n },\n newParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return [children[0].value];\n },\n concatParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const params = children[0].value;\n const newParam = children[2].value;\n params.push(newParam);\n return params;\n },\n newCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return this.createCommand(children[0].value, children[1].value);\n },\n appendAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n appendCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const command = children[1].value as Command;\n this.addCommand(command);\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n appendRoleSelector: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const roleName = children[1].value;\n const lName = roleName.toLowerCase().trim();\n this.addCommand(new ActivateRole([{ key: null, value: lName }]));\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n insertEmbedding: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // How to handle embeddings - these are just blocks\n // to escape out of song (most likely for some rendering of html/md etc)\n const rawVal = children[1].value;\n this.addCommand(new RawEmbedding([{ key: null, value: rawVal }]));\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n };\n\n constructor(config?: any) {\n config = config || {};\n }\n\n createCommand(name: string, params: CmdParam[]): Command {\n const lName = name.trim().toLowerCase();\n params = params || [];\n if (lName == \"line\") {\n return new CreateLine(params);\n } else if (lName == \"meta\") {\n return new MetaData(params);\n } else if (lName == \"role\") {\n return new CreateRole(params);\n } else if (lName == \"layout\") {\n return new ApplyLayout(params);\n } else if (lName == \"beatduration\") {\n return new SetBeatDuration(params);\n } else if (lName == \"breaks\") {\n return new SetBreaks(params);\n } else if (lName == \"cycle\") {\n return new SetCycle(params);\n } else {\n // Try to set this as the current role\n throw new Error(\"Invalid command: \" + lName);\n }\n }\n\n addCommand(cmd: Command): void {\n cmd.index = this.commands.length;\n this.commands.push(cmd);\n }\n\n parse(input: string): any {\n this.errors = [];\n const ptree = parser.parse(input, {\n tokenizerContext: this,\n ruleHandlers: this.ruleHandlers,\n onTokenError: (err: TLEX.TokenizerError) => {\n this.errors.push(err);\n return true;\n },\n });\n return ptree;\n }\n\n parseEmbelishment(value: string): [any, boolean] {\n return carnatic.parseEmbelishment(value);\n }\n}\n"]}
|
package/lib/cjs/shapes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapes.js","sourceRoot":"","sources":["../../src/shapes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AASvC,MAAsB,KAAK;IAA3B;QAEW,YAAO,GAAW,KAAK,CAAC,SAAS,EAAE,CAAC;QAQnC,OAAE,GAAkB,IAAI,CAAC;QACzB,OAAE,GAAkB,IAAI,CAAC;QACzB,WAAM,GAAkB,IAAI,CAAC;QAC7B,YAAO,GAAkB,IAAI,CAAC;QAG9B,gBAAW,GAAiB,IAAI,CAAC;QAC3C,aAAQ,GAAY,EAAE,CAAC;IA+LzB,CAAC;IA7LC,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;SACjC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAMD,IAAI,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;SACvC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAeD,gBAAgB;QACd,IAAI,CAAC,QAAQ,GAAG,IAAgC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAgC,CAAC;IAChD,CAAC;IAUD,SAAS,CACP,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,WAAW,GAAG,KAAK;QAEnB,IAAI,CAAC,IAAI,IAAI,EAAE;YACb,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;gBACZ,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;aAChB;iBAAM;gBACL,IAAI,CAAC,EAAE,GAAG,CAAC,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S,CAAC,MAAW;QACnB,IAAI,aAAa,IAAI,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF;AAtGD,8BAsGC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, LeafAtom, Group } from \"./core\";\n\n/**\n * Base class of all renderable objects for caching things like bounding boxes etc.\n * We do this since a lot of the property setters dont change bounding boxes but\n * bounding box reads are a bit slow in general. This also allows us to test\n * layouts, positioning etc without having to worry about implementation details.\n */\nexport abstract class Shape {\n private static idCounter = 0;\n readonly shapeId: number = Shape.idCounter++;\n /**\n * Note that x and y coordinates are not always the x and y coordinates\n * of the bounding box.\n * Eg a circle's x and y coordinates are its center point and not the\n * top left corner.\n * These \"main\" coordinates are referred as control coordinates.\n */\n protected _x: number | null = null;\n protected _y: number | null = null;\n protected _width: number | null = null;\n protected _height: number | null = null;\n protected _bbox: TSU.Geom.Rect;\n protected _minSize: TSU.Geom.Size;\n protected parentShape: Shape | null = null;\n children: Shape[] = [];\n\n get bbox(): TSU.Geom.Rect {\n if (!this._bbox) {\n this._bbox = this.refreshBBox();\n }\n return this._bbox;\n }\n\n /**\n * Sizes can have a minimum size.\n * This is usually the size of the bounding box.\n */\n get minSize(): TSU.Geom.Size {\n if (!this._minSize) {\n this._minSize = this.refreshMinSize();\n }\n return this._minSize;\n }\n\n /**\n * refreshBBox is called by the Shape when it knows the bbox it is tracking\n * cannot be trusted and has to be refreshed by calling native methods.\n */\n protected abstract refreshBBox(): TSU.Geom.Rect;\n protected abstract refreshMinSize(): TSU.Geom.Size;\n protected abstract updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null];\n\n invalidateBounds(): void {\n this._minSize = null as unknown as TSU.Geom.Size;\n this._bbox = null as unknown as TSU.Geom.Rect;\n }\n\n /**\n * Sets the x or y coordinate of this shape in coordinate system within its\n * parent.\n *\n * Note that null and NaN are valid values and mean the following:\n * null - Dont change the value. Passed to \"ignore\" effects.\n * NaN - Ensure the value is set to null so that the bounding box specific coord is used going forward.\n */\n setBounds(\n x: number | null,\n y: number | null,\n w: number | null,\n h: number | null,\n applyLayout = false,\n ): [number | null, number | null, number | null, number | null] {\n if (x != null) {\n if (isNaN(x)) {\n this._x = null;\n } else {\n this._x = x;\n }\n }\n if (y != null) {\n if (isNaN(y)) {\n this._y = null;\n } else {\n this._y = y;\n }\n }\n if (w != null) {\n if (isNaN(w)) {\n this._width = null;\n } else {\n this._width = w;\n }\n }\n if (h != null) {\n if (isNaN(h)) {\n this._height = null;\n } else {\n this._height = h;\n }\n }\n const [nx, ny, nw, nh] = this.updateBounds(x, y, w, h);\n if (nx != null) {\n if (isNaN(nx)) {\n this._x = null;\n } else {\n this._x = nx;\n }\n }\n if (ny != null) {\n if (isNaN(ny)) {\n this._y = null;\n } else {\n this._y = ny;\n }\n }\n if (nw != null) {\n if (isNaN(nw)) {\n this._width = null;\n } else {\n this._width = nw;\n }\n }\n if (nh != null) {\n if (isNaN(nh)) {\n this._height = null;\n } else {\n this._height = nh;\n }\n }\n if (applyLayout) this.refreshLayout();\n // this.resetBBox();\n return [nx, ny, nw, nh];\n }\n\n get hasX(): boolean {\n return this._x != null && !isNaN(this._x);\n }\n\n get hasY(): boolean {\n return this._y != null && !isNaN(this._y);\n }\n\n get hasWidth(): boolean {\n return this._width != null && !isNaN(this._width);\n }\n\n get hasHeight(): boolean {\n return this._height != null && !isNaN(this._height);\n }\n\n /**\n * Gets the x coordinate within the parent's coordinate system.\n */\n get x(): number {\n return this._x || 0;\n }\n\n /**\n * Sets the x coordinate within the parent's coordinate system.\n */\n set x(x: number | null) {\n // Here a manual x is being set - how does this interfere with the bounding box?\n // We should _x to the new value to indicate a manual value was set.\n // and reset bbox so that based on this x a new bbox may need to be calculated\n this.setBounds(x == null ? NaN : x, null, null, null);\n }\n\n /**\n * Gets the y coordinate within the parent's coordinate system.\n */\n get y(): number {\n if (this._y != null) return this._y;\n return 0; // this.bbox.y;\n }\n\n /**\n * Sets the y coordinate within the parent's coordinate system.\n */\n set y(y: number | null) {\n this.setBounds(null, y == null ? NaN : y, null, null);\n }\n\n get width(): number {\n if (this._width != null) return this._width;\n return 0; // this.bbox.width;\n }\n\n set width(w: number | null) {\n this.setBounds(null, null, w == null ? NaN : w, null);\n }\n\n get height(): number {\n if (this._height != null) return this._height;\n return 0; // this.bbox.height;\n }\n\n set height(h: number | null) {\n this.setBounds(null, null, null, h == null ? NaN : h);\n }\n\n /**\n * This is called when bounds or other properties of a shape have changed to\n * give the shape an opportunity to layout the children. For shapes\n * with no children this is a no-op. It is expected the Shape will keep track\n * of all changes so it can apply them all in in one go in this method - A\n * form of \"commit\"ing the layout transaction.\n */\n refreshLayout(): void {\n // throw new Error(\"Implement this\");\n }\n}\n\nexport abstract class Embelishment extends Shape {}\n\nexport class ElementShape<T extends SVGGraphicsElement = SVGGraphicsElement> extends Shape {\n constructor(public readonly element: T) {\n super();\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.element);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n if (this.hasX) this.element.setAttribute(\"x\", \"\" + this._x);\n if (this.hasY) this.element.setAttribute(\"y\", \"\" + this._y);\n }\n}\n\nexport abstract class AtomView extends Shape {\n depth = 0;\n roleIndex = 0;\n\n // LayoutMetrics for the AtomView so all atomviews laid out on the\n // same baseline will show up aligned vertically\n baseline: number;\n ascent: number;\n descent: number;\n capHeight: number;\n leading: number;\n\n abstract isLeaf(): boolean;\n\n /**\n * Creates views needed for this AtomView.\n */\n abstract createElements(parent: SVGGraphicsElement): void;\n}\n\nexport abstract class LeafAtomView extends AtomView {\n constructor(public leafAtom: LeafAtom) {\n super();\n }\n\n isLeaf(): boolean {\n return true;\n }\n\n get viewId(): number {\n return this.leafAtom.uuid;\n }\n\n /*\n embRoot(): SVGGraphicsElement {\n let rootElem = this.glyph.element.parentElement as any as SVGGraphicsElement;\n while (rootElem && (rootElem.tagName == \"tspan\" || rootElem.tagName == \"text\")) {\n rootElem = rootElem.parentElement as any as SVGGraphicsElement;\n }\n return rootElem;\n }\n */\n}\n\n/**\n * An GroupView that contains a collection of AtomViews.\n */\nexport abstract class GroupView extends AtomView {\n protected atomSpacing: number;\n protected groupElement: SVGGElement;\n protected atomViews: AtomView[] = [];\n private _embelishments: Embelishment[];\n defaultToNotes = true;\n needsLayout = true;\n scaleFactor = 1.0;\n constructor(public group: Group, config?: any) {\n super();\n this.atomSpacing = 5;\n this.setStyles(config || {});\n }\n\n /**\n * Creates views needed for this AtomView.\n */\n createElements(parent: SVGGraphicsElement): void {\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: parent,\n attrs: {\n class: \"groupViewRoot\",\n id: \"groupViewRoot\" + this.group.uuid,\n },\n });\n\n // now create child atom views for each atom in this Group\n for (const atom of this.group.atoms.values()) {\n const atomView = this.createAtomView(atom);\n this.atomViews.push(atomView);\n }\n this.invalidateBounds();\n }\n\n isLeaf(): boolean {\n return false;\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.groupElement);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n let totalWidth = 0;\n let maxHeight = 0;\n this.atomViews.forEach((av, index) => {\n const ms = av.minSize;\n totalWidth += ms.width + this.atomSpacing;\n maxHeight = Math.max(maxHeight, ms.height);\n });\n return new TSU.Geom.Size(totalWidth * this.scaleFactor, maxHeight * this.scaleFactor);\n }\n\n abstract createAtomView(atom: Atom): AtomView;\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n let transform = \"translate(\" + this.x + \",\" + this.y + \")\";\n if (this.scaleFactor < 1) {\n transform += \" scale(\" + this.scaleFactor + \")\";\n }\n this.groupElement.setAttribute(\"transform\", transform);\n // if (this.widthChanged) {\n // All our atoms have to be laid out between startX and endX\n // old way of doing where we just set dx between atom views\n // this worked when atomviews were single glyphs. But\n // as atomViews can be complex (eg with accents and pre/post\n // spaces etc) explicitly setting x/y may be important\n let currX = 0;\n const currY = 0; // null; // this.y; // + 10;\n this.atomViews.forEach((av, index) => {\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n });\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n protected createEmbelishments(): Embelishment[] {\n return [];\n }\n\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n this.needsLayout = true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shapes.js","sourceRoot":"","sources":["../../src/shapes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AASvC,MAAsB,KAAK;IAA3B;QAEW,YAAO,GAAW,KAAK,CAAC,SAAS,EAAE,CAAC;QAQnC,OAAE,GAAkB,IAAI,CAAC;QACzB,OAAE,GAAkB,IAAI,CAAC;QACzB,WAAM,GAAkB,IAAI,CAAC;QAC7B,YAAO,GAAkB,IAAI,CAAC;QAG9B,gBAAW,GAAiB,IAAI,CAAC;QAC3C,aAAQ,GAAY,EAAE,CAAC;IA+LzB,CAAC;IA7LC,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;SACjC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;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E,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7C,KAAK,IAAI,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,aAAa;YAAE,CAAC,CAAC,aAAa,EAAE,CAAC;QACtD,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAES,mBAAmB;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,SAAS,CAAC,MAAW;QACnB,IAAI,aAAa,IAAI,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF;AAtGD,8BAsGC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, LeafAtom, Group } from \"./core\";\n\n/**\n * Base class of all renderable objects for caching things like bounding boxes etc.\n * We do this since a lot of the property setters dont change bounding boxes but\n * bounding box reads are a bit slow in general. This also allows us to test\n * layouts, positioning etc without having to worry about implementation details.\n */\nexport abstract class Shape {\n private static idCounter = 0;\n readonly shapeId: number = Shape.idCounter++;\n /**\n * Note that x and y coordinates are not always the x and y coordinates\n * of the bounding box.\n * Eg a circle's x and y coordinates are its center point and not the\n * top left corner.\n * These \"main\" coordinates are referred as control coordinates.\n */\n protected _x: number | null = null;\n protected _y: number | null = null;\n protected _width: number | null = null;\n protected _height: number | null = null;\n protected _bbox: TSU.Geom.Rect;\n protected _minSize: TSU.Geom.Size;\n protected parentShape: Shape | null = null;\n children: Shape[] = [];\n\n get bbox(): TSU.Geom.Rect {\n if (!this._bbox) {\n this._bbox = this.refreshBBox();\n }\n return this._bbox;\n }\n\n /**\n * Sizes can have a minimum size.\n * This is usually the size of the bounding box.\n */\n get minSize(): TSU.Geom.Size {\n if (!this._minSize) {\n this._minSize = this.refreshMinSize();\n }\n return this._minSize;\n }\n\n /**\n * refreshBBox is called by the Shape when it knows the bbox it is tracking\n * cannot be trusted and has to be refreshed by calling native methods.\n */\n protected abstract refreshBBox(): TSU.Geom.Rect;\n protected abstract refreshMinSize(): TSU.Geom.Size;\n protected abstract updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null];\n\n invalidateBounds(): void {\n this._minSize = null as unknown as TSU.Geom.Size;\n this._bbox = null as unknown as TSU.Geom.Rect;\n }\n\n /**\n * Sets the x or y coordinate of this shape in coordinate system within its\n * parent.\n *\n * Note that null and NaN are valid values and mean the following:\n * null - Dont change the value. Passed to \"ignore\" effects.\n * NaN - Ensure the value is set to null so that the bounding box specific coord is used going forward.\n */\n setBounds(\n x: number | null,\n y: number | null,\n w: number | null,\n h: number | null,\n applyLayout = false,\n ): [number | null, number | null, number | null, number | null] {\n if (x != null) {\n if (isNaN(x)) {\n this._x = null;\n } else {\n this._x = x;\n }\n }\n if (y != null) {\n if (isNaN(y)) {\n this._y = null;\n } else {\n this._y = y;\n }\n }\n if (w != null) {\n if (isNaN(w)) {\n this._width = null;\n } else {\n this._width = w;\n }\n }\n if (h != null) {\n if (isNaN(h)) {\n this._height = null;\n } else {\n this._height = h;\n }\n }\n const [nx, ny, nw, nh] = this.updateBounds(x, y, w, h);\n if (nx != null) {\n if (isNaN(nx)) {\n this._x = null;\n } else {\n this._x = nx;\n }\n }\n if (ny != null) {\n if (isNaN(ny)) {\n this._y = null;\n } else {\n this._y = ny;\n }\n }\n if (nw != null) {\n if (isNaN(nw)) {\n this._width = null;\n } else {\n this._width = nw;\n }\n }\n if (nh != null) {\n if (isNaN(nh)) {\n this._height = null;\n } else {\n this._height = nh;\n }\n }\n if (applyLayout) this.refreshLayout();\n // this.resetBBox();\n return [nx, ny, nw, nh];\n }\n\n get hasX(): boolean {\n return this._x != null && !isNaN(this._x);\n }\n\n get hasY(): boolean {\n return this._y != null && !isNaN(this._y);\n }\n\n get hasWidth(): boolean {\n return this._width != null && !isNaN(this._width);\n }\n\n get hasHeight(): boolean {\n return this._height != null && !isNaN(this._height);\n }\n\n /**\n * Gets the x coordinate within the parent's coordinate system.\n */\n get x(): number {\n return this._x || 0;\n }\n\n /**\n * Sets the x coordinate within the parent's coordinate system.\n */\n set x(x: number | null) {\n // Here a manual x is being set - how does this interfere with the bounding box?\n // We should _x to the new value to indicate a manual value was set.\n // and reset bbox so that based on this x a new bbox may need to be calculated\n this.setBounds(x == null ? NaN : x, null, null, null);\n }\n\n /**\n * Gets the y coordinate within the parent's coordinate system.\n */\n get y(): number {\n if (this._y != null) return this._y;\n return 0; // this.bbox.y;\n }\n\n /**\n * Sets the y coordinate within the parent's coordinate system.\n */\n set y(y: number | null) {\n this.setBounds(null, y == null ? NaN : y, null, null);\n }\n\n get width(): number {\n if (this._width != null) return this._width;\n return 0; // this.bbox.width;\n }\n\n set width(w: number | null) {\n this.setBounds(null, null, w == null ? NaN : w, null);\n }\n\n get height(): number {\n if (this._height != null) return this._height;\n return 0; // this.bbox.height;\n }\n\n set height(h: number | null) {\n this.setBounds(null, null, null, h == null ? NaN : h);\n }\n\n /**\n * This is called when bounds or other properties of a shape have changed to\n * give the shape an opportunity to layout the children. For shapes\n * with no children this is a no-op. It is expected the Shape will keep track\n * of all changes so it can apply them all in in one go in this method - A\n * form of \"commit\"ing the layout transaction.\n */\n refreshLayout(): void {\n // throw new Error(\"Implement this\");\n }\n}\n\nexport abstract class Embelishment extends Shape {}\n\nexport class ElementShape<T extends SVGGraphicsElement = SVGGraphicsElement> extends Shape {\n constructor(public readonly element: T) {\n super();\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.element);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n if (this.hasX) this.element.setAttribute(\"x\", \"\" + this._x);\n if (this.hasY) this.element.setAttribute(\"y\", \"\" + this._y);\n }\n}\n\nexport abstract class AtomView extends Shape {\n depth = 0;\n roleIndex = 0;\n\n // LayoutMetrics for the AtomView so all atomviews laid out on the\n // same baseline will show up aligned vertically\n baseline: number;\n ascent: number;\n descent: number;\n capHeight: number;\n leading: number;\n\n abstract isLeaf(): boolean;\n\n /**\n * Creates views needed for this AtomView.\n */\n abstract createElements(parent: SVGGraphicsElement): void;\n}\n\nexport abstract class LeafAtomView extends AtomView {\n constructor(public leafAtom: LeafAtom) {\n super();\n }\n\n isLeaf(): boolean {\n return true;\n }\n\n get viewId(): number {\n return this.leafAtom.uuid;\n }\n}\n\n/**\n * An GroupView that contains a collection of AtomViews.\n */\nexport abstract class GroupView extends AtomView {\n protected atomSpacing: number;\n protected groupElement: SVGGElement;\n protected atomViews: AtomView[] = [];\n private _embelishments: Embelishment[];\n defaultToNotes = true;\n needsLayout = true;\n scaleFactor = 1.0;\n constructor(public group: Group, config?: any) {\n super();\n this.atomSpacing = 5;\n this.setStyles(config || {});\n }\n\n /**\n * Creates views needed for this AtomView.\n */\n createElements(parent: SVGGraphicsElement): void {\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: parent,\n attrs: {\n class: \"groupViewRoot\",\n id: \"groupViewRoot\" + this.group.uuid,\n },\n });\n\n // now create child atom views for each atom in this Group\n for (const atom of this.group.atoms.values()) {\n const atomView = this.createAtomView(atom);\n this.atomViews.push(atomView);\n }\n this.invalidateBounds();\n }\n\n isLeaf(): boolean {\n return false;\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.groupElement);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n let totalWidth = 0;\n let maxHeight = 0;\n this.atomViews.forEach((av, index) => {\n const ms = av.minSize;\n totalWidth += ms.width + this.atomSpacing;\n maxHeight = Math.max(maxHeight, ms.height);\n });\n return new TSU.Geom.Size(totalWidth * this.scaleFactor, maxHeight * this.scaleFactor);\n }\n\n abstract createAtomView(atom: Atom): AtomView;\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n let transform = \"translate(\" + this.x + \",\" + this.y + \")\";\n if (this.scaleFactor < 1) {\n transform += \" scale(\" + this.scaleFactor + \")\";\n }\n this.groupElement.setAttribute(\"transform\", transform);\n // if (this.widthChanged) {\n // All our atoms have to be laid out between startX and endX\n // old way of doing where we just set dx between atom views\n // this worked when atomviews were single glyphs. But\n // as atomViews can be complex (eg with accents and pre/post\n // spaces etc) explicitly setting x/y may be important\n let currX = 0;\n const currY = 0; // null; // this.y; // + 10;\n this.atomViews.forEach((av, index) => {\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n });\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n protected createEmbelishments(): Embelishment[] {\n return [];\n }\n\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n this.needsLayout = true;\n }\n}\n"]}
|
package/lib/esm/beats.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
|
-
import { Line, Atom, Role } from "./";
|
|
2
|
+
import { Marker, Line, Atom, Role } from "./";
|
|
3
3
|
import { CycleIterator } from "./cycle";
|
|
4
4
|
import { WindowIterator } from "./iterators";
|
|
5
5
|
import { LayoutParams } from "./layouts";
|
|
@@ -17,8 +17,6 @@ export declare class Beat {
|
|
|
17
17
|
nextBeat: null | Beat;
|
|
18
18
|
private static idCounter;
|
|
19
19
|
readonly uuid: number;
|
|
20
|
-
layoutLine: number;
|
|
21
|
-
layoutColumn: number;
|
|
22
20
|
atom: Atom;
|
|
23
21
|
protected atomIsPlaceholder: boolean;
|
|
24
22
|
constructor(index: number, role: Role, offset: Fraction, duration: Fraction, barIndex: number, beatIndex: number, instance: number, prevBeat: null | Beat, nextBeat: null | Beat);
|
|
@@ -27,6 +25,8 @@ export declare class Beat {
|
|
|
27
25
|
get filled(): boolean;
|
|
28
26
|
get remaining(): Fraction;
|
|
29
27
|
add(atom: Atom): boolean;
|
|
28
|
+
get preMarkers(): Marker[];
|
|
29
|
+
get postMarkers(): Marker[];
|
|
30
30
|
}
|
|
31
31
|
export declare class BeatsBuilder {
|
|
32
32
|
readonly role: Role;
|
package/lib/esm/beats.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
|
-
import { Group, Space } from "./";
|
|
2
|
+
import { AtomType, Group, Space } from "./";
|
|
3
3
|
import { WindowIterator } from "./iterators";
|
|
4
4
|
import { GridModel, GridCell, ColAlign, GridLayoutGroup } from "./grids";
|
|
5
5
|
const ZERO = TSU.Num.Fraction.ZERO;
|
|
@@ -16,8 +16,6 @@ export class Beat {
|
|
|
16
16
|
this.prevBeat = prevBeat;
|
|
17
17
|
this.nextBeat = nextBeat;
|
|
18
18
|
this.uuid = Beat.idCounter++;
|
|
19
|
-
this.layoutLine = -1;
|
|
20
|
-
this.layoutColumn = -1;
|
|
21
19
|
this.atomIsPlaceholder = false;
|
|
22
20
|
}
|
|
23
21
|
debugValue() {
|
|
@@ -57,6 +55,36 @@ export class Beat {
|
|
|
57
55
|
}
|
|
58
56
|
return true;
|
|
59
57
|
}
|
|
58
|
+
get preMarkers() {
|
|
59
|
+
const out = [];
|
|
60
|
+
let curr = this.atom;
|
|
61
|
+
while (curr != null) {
|
|
62
|
+
for (const marker of curr.markersBefore || []) {
|
|
63
|
+
out.push(marker);
|
|
64
|
+
}
|
|
65
|
+
if (curr.type == AtomType.GROUP) {
|
|
66
|
+
curr = curr.atoms.first;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
curr = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
get postMarkers() {
|
|
75
|
+
const out = [];
|
|
76
|
+
let curr = this.atom;
|
|
77
|
+
while (curr != null) {
|
|
78
|
+
out.splice(0, 0, ...(curr.markersAfter || []));
|
|
79
|
+
if (curr.type == AtomType.GROUP) {
|
|
80
|
+
curr = curr.atoms.last;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
curr = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
60
88
|
}
|
|
61
89
|
Beat.idCounter = 0;
|
|
62
90
|
export class BeatsBuilder {
|
|
@@ -224,7 +252,33 @@ export class GlobalBeatLayout {
|
|
|
224
252
|
const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);
|
|
225
253
|
const roleIndex = beat.role.line.indexOfRole(beat.role.name);
|
|
226
254
|
const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;
|
|
227
|
-
const realCol = layoutColumn * 3;
|
|
255
|
+
const realCol = 1 + layoutColumn * 3;
|
|
256
|
+
const preMarkers = beat.preMarkers;
|
|
257
|
+
if (preMarkers.length > 0) {
|
|
258
|
+
const val = {
|
|
259
|
+
beat: beat,
|
|
260
|
+
markers: preMarkers,
|
|
261
|
+
};
|
|
262
|
+
const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);
|
|
263
|
+
gridModel.setValue(realRow, realCol - 1, val, (gridRow, col) => {
|
|
264
|
+
const cell = new GridCell(gridRow, col);
|
|
265
|
+
cell.colAlign = precol;
|
|
266
|
+
return cell;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
const postMarkers = beat.postMarkers;
|
|
270
|
+
if (postMarkers.length > 0) {
|
|
271
|
+
const val = {
|
|
272
|
+
beat: beat,
|
|
273
|
+
markers: postMarkers,
|
|
274
|
+
};
|
|
275
|
+
const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);
|
|
276
|
+
gridModel.setValue(realRow, realCol + 1, val, (gridRow, col) => {
|
|
277
|
+
const cell = new GridCell(gridRow, col);
|
|
278
|
+
cell.colAlign = postcol;
|
|
279
|
+
return cell;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
228
282
|
return gridModel.setValue(realRow, realCol, beat, (gridRow, col) => {
|
|
229
283
|
const cell = new GridCell(gridRow, col);
|
|
230
284
|
cell.colAlign = bcol;
|
package/lib/esm/beats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAc,KAAK,EAAQ,MAAM,IAAI,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAW,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGlF,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC,MAAM,OAAO,IAAI;IASf,YACkB,KAAa,EACb,IAAU,EACV,MAAgB,EAChB,QAAkB,EAClB,QAAgB,EAChB,SAAiB,EACjB,QAAgB,EAChB,QAAqB,EAC9B,QAAqB;QARZ,UAAK,GAAL,KAAK,CAAQ;QACb,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,UAAU,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAI5D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC;QACtG,MAAM,OAAO,GAAG,YAAY,GAAG,CAAC,CAAC;QACjC,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;YAClF,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n layoutLine = -1;\n layoutColumn = -1;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\nexport class BeatColumn extends ColAlign {\n atomSpacing = 5;\n readonly key: string;\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n beatColumns = new Map<string, BeatColumn>();\n\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/**\n * Manages the beat layouts for *all* lines in a notation.\n */\ntype LineId = number;\ntype LPID = number;\nexport class GlobalBeatLayout {\n gridModelsForLine = new Map<LineId, GridModel>();\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Get the GridView associated with a particular line.\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * First lines are added to the BeatLayout object.\n * This ensures that a line is broken down into beats and added\n * into a dedicated GridModel per line.\n *\n * A line must also be given the layout params by which the beat\n * break down will happen. This LayoutParams object does not have\n * to be unique per line (this non-constraint allows to align\n * beats across lines!).\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);\n roleBeats.push(bb.beats);\n\n // Add these to the beat layout too\n for (const beat of bb.beats) {\n // beat.ensureUniformSpaces(layoutParams.beatDuration);\n this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which\n * this beat was added.\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;\n const realCol = layoutColumn * 3;\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol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AAC;gBACvB,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,MAAM,GAAG,GAAG;gBACV,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,WAAW;aACrB,CAAC;YACF,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;gBAC9E,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;gBACxB,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;YAClF,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Marker, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n get preMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n for (const marker of curr.markersBefore || []) {\n out.push(marker);\n }\n if (curr.type == AtomType.GROUP) {\n curr = (curr as Group).atoms.first;\n } else {\n curr = null;\n }\n }\n return out;\n }\n\n get postMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n out.splice(0, 0, ...(curr.markersAfter || []));\n if (curr.type == AtomType.GROUP) {\n curr = (curr as Group).atoms.last;\n } else {\n curr = null;\n }\n }\n return out;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\nexport class BeatColumn extends ColAlign {\n atomSpacing = 5;\n readonly key: string;\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n beatColumns = new Map<string, BeatColumn>();\n\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/**\n * Manages the beat layouts for *all* lines in a notation.\n */\ntype LineId = number;\ntype LPID = number;\nexport class GlobalBeatLayout {\n gridModelsForLine = new Map<LineId, GridModel>();\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Get the GridView associated with a particular line.\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * First lines are added to the BeatLayout object.\n * This ensures that a line is broken down into beats and added\n * into a dedicated GridModel per line.\n *\n * A line must also be given the layout params by which the beat\n * break down will happen. This LayoutParams object does not have\n * to be unique per line (this non-constraint allows to align\n * beats across lines!).\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);\n roleBeats.push(bb.beats);\n\n // Add these to the beat layout too\n for (const beat of bb.beats) {\n // beat.ensureUniformSpaces(layoutParams.beatDuration);\n this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which\n * this beat was added.\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;\n // pre marker goes on realCol - 1, post marker goes on realCol + 1\n const realCol = 1 + layoutColumn * 3;\n const preMarkers = beat.preMarkers;\n if (preMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: preMarkers,\n };\n const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);\n gridModel.setValue(realRow, realCol - 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = precol;\n return cell;\n });\n }\n const postMarkers = beat.postMarkers;\n if (postMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: postMarkers,\n };\n const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);\n gridModel.setValue(realRow, realCol + 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = postcol;\n return cell;\n });\n }\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol;\n return cell;\n });\n }\n}\n"]}
|
package/lib/esm/beatview.js
CHANGED
|
@@ -9,9 +9,9 @@ export class BeatView extends ElementShape {
|
|
|
9
9
|
beatId: "" + beat.uuid,
|
|
10
10
|
id: "" + beat.uuid,
|
|
11
11
|
roleName: beat.role.name,
|
|
12
|
-
layoutLine: "" + beat.layoutLine,
|
|
13
|
-
layoutColumn: "" + beat.layoutColumn,
|
|
14
12
|
beatIndex: "" + beat.index,
|
|
13
|
+
gridRow: cell.rowIndex,
|
|
14
|
+
gridCol: cell.colIndex,
|
|
15
15
|
},
|
|
16
16
|
}));
|
|
17
17
|
this.cell = cell;
|
package/lib/esm/beatview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beatview.js","sourceRoot":"","sources":["../../src/beatview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAA0B,YAAY,EAAE,MAAM,UAAU,CAAC;AAKhE,MAAM,OAAgB,QAAS,SAAQ,YAAyB;IAI9D,YACkB,IAAc,EACd,IAAU,EACV,WAA+B,EAC/B,KAAY,EAC5B,MAAY;QAEZ,KAAK,CACH,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YACzB,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE;gBACL,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;gBACtB,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;gBAClB,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;gBACxB,
|
|
1
|
+
{"version":3,"file":"beatview.js","sourceRoot":"","sources":["../../src/beatview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAA0B,YAAY,EAAE,MAAM,UAAU,CAAC;AAKhE,MAAM,OAAgB,QAAS,SAAQ,YAAyB;IAI9D,YACkB,IAAc,EACd,IAAU,EACV,WAA+B,EAC/B,KAAY,EAC5B,MAAY;QAEZ,KAAK,CACH,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YACzB,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE;gBACL,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;gBACtB,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;gBAClB,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;gBACxB,SAAS,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK;gBAC1B,OAAO,EAAE,IAAI,CAAC,QAAQ;gBACtB,OAAO,EAAE,IAAI,CAAC,QAAQ;aACvB;SACF,CAAC,CACH,CAAC;QAnBc,SAAI,GAAJ,IAAI,CAAU;QACd,SAAI,GAAJ,IAAI,CAAM;QACV,gBAAW,GAAX,WAAW,CAAoB;QAC/B,UAAK,GAAL,KAAK,CAAO;QAL9B,gBAAW,GAAG,IAAI,CAAC;QAsBjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,MAAW;QACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CAIF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomView, Embelishment, ElementShape } from \"./shapes\";\nimport { GridCell, GridCellView } from \"./grids\";\nimport { Cycle } from \"./cycle\";\nimport { Beat } from \"./beats\";\n\nexport abstract class BeatView extends ElementShape<SVGGElement> implements GridCellView {\n private _embelishments: Embelishment[];\n atomView: AtomView;\n needsLayout = true;\n constructor(\n public readonly cell: GridCell,\n public readonly beat: Beat,\n public readonly rootElement: SVGGraphicsElement,\n public readonly cycle: Cycle,\n config?: any,\n ) {\n super(\n TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n class: \"beatView\",\n beatId: \"\" + beat.uuid,\n id: \"\" + beat.uuid,\n roleName: beat.role.name,\n beatIndex: \"\" + beat.index,\n gridRow: cell.rowIndex,\n gridCol: cell.colIndex,\n },\n }),\n );\n this.atomView = this.createAtomView();\n this.atomView.refreshLayout();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n setStyles(config: any): void {\n this.needsLayout = true;\n }\n\n protected abstract createEmbelishments(): Embelishment[];\n protected abstract createAtomView(): AtomView;\n}\n"]}
|
|
@@ -2,9 +2,9 @@ import * as TSU from "@panyam/tsutils";
|
|
|
2
2
|
import { LineView } from "./LineView";
|
|
3
3
|
import { Notation, RawBlock } from "../notation";
|
|
4
4
|
import { GlobalBeatLayout } from "../beats";
|
|
5
|
-
import { GridCell } from "../grids";
|
|
5
|
+
import { GridCell, GridCellView } from "../grids";
|
|
6
6
|
import { Line } from "../core";
|
|
7
|
-
import { BeatView } from "./beatviews";
|
|
7
|
+
import { BeatView, MarkerView } from "./beatviews";
|
|
8
8
|
export declare class NotationView {
|
|
9
9
|
readonly rootElement: HTMLElement;
|
|
10
10
|
readonly config?: any;
|
|
@@ -28,5 +28,6 @@ export declare class NotationView {
|
|
|
28
28
|
refreshLayout(): void;
|
|
29
29
|
renderBlock(raw: RawBlock): void;
|
|
30
30
|
beatViews: Map<number, BeatView>;
|
|
31
|
-
|
|
31
|
+
markerViews: Map<string, MarkerView>;
|
|
32
|
+
viewForBeat(cell: GridCell): GridCellView;
|
|
32
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
2
|
import { LineView } from "./LineView";
|
|
3
|
-
import { BeatView } from "./beatviews";
|
|
3
|
+
import { BeatView, MarkerView } from "./beatviews";
|
|
4
4
|
export class NotationView {
|
|
5
5
|
constructor(rootElement, config) {
|
|
6
6
|
this.rootElement = rootElement;
|
|
@@ -8,6 +8,7 @@ export class NotationView {
|
|
|
8
8
|
this.lineViews = [];
|
|
9
9
|
this.currentSVGElement = null;
|
|
10
10
|
this.beatViews = new Map();
|
|
11
|
+
this.markerViews = new Map();
|
|
11
12
|
this.loadChildViews();
|
|
12
13
|
}
|
|
13
14
|
get beatLayout() {
|
|
@@ -135,16 +136,32 @@ export class NotationView {
|
|
|
135
136
|
this.currentSVGElement = null;
|
|
136
137
|
}
|
|
137
138
|
viewForBeat(cell) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
if (cell.colIndex % 3 == 1) {
|
|
140
|
+
const beat = cell.value;
|
|
141
|
+
let curr = this.beatViews.get(beat.uuid) || null;
|
|
142
|
+
if (curr == null) {
|
|
143
|
+
const line = beat.role.line;
|
|
144
|
+
const lineView = this.ensureLineView(line);
|
|
145
|
+
const lp = line.layoutParams;
|
|
146
|
+
curr = new BeatView(cell, beat, lineView.gElem, lp.cycle);
|
|
147
|
+
this.beatViews.set(beat.uuid, curr);
|
|
148
|
+
}
|
|
149
|
+
return curr;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const marker = cell.value;
|
|
153
|
+
const beat = marker.beat;
|
|
154
|
+
let curr = this.markerViews.get("pre:" + beat.uuid) || null;
|
|
155
|
+
if (curr == null) {
|
|
156
|
+
const line = beat.role.line;
|
|
157
|
+
const lineView = this.ensureLineView(line);
|
|
158
|
+
const lp = line.layoutParams;
|
|
159
|
+
const isPreMarker = cell.colIndex % 3 == 0;
|
|
160
|
+
curr = new MarkerView(cell, beat, marker.markers, isPreMarker, lineView.gElem);
|
|
161
|
+
this.markerViews.set("pre:" + beat.uuid, curr);
|
|
162
|
+
}
|
|
163
|
+
return curr;
|
|
146
164
|
}
|
|
147
|
-
return curr;
|
|
148
165
|
}
|
|
149
166
|
}
|
|
150
167
|
//# sourceMappingURL=NotationView.js.map
|