notations 1.0.2 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/notations.umd.js +4234 -12211
- package/dist/notations.umd.min.js +2 -3
- package/dist/notations.umd.min.js.map +1 -1
- package/lib/cjs/block.d.ts +4 -0
- package/lib/cjs/block.js +24 -0
- package/lib/cjs/block.js.map +1 -1
- package/lib/cjs/core.d.ts +15 -0
- package/lib/cjs/core.js +144 -4
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/entity.d.ts +4 -0
- package/lib/cjs/entity.js +12 -0
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/events.d.ts +56 -0
- package/lib/cjs/events.js +27 -0
- package/lib/cjs/events.js.map +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/parser.js +1 -1
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.d.ts +11 -0
- package/lib/cjs/shapes.js +25 -2
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/web/components/DockViewPlayground.d.ts +51 -0
- package/lib/cjs/web/components/DockViewPlayground.js +364 -0
- package/lib/cjs/web/components/DockViewPlayground.js.map +1 -0
- package/lib/cjs/web/components/NotationBlock.d.ts +35 -0
- package/lib/cjs/web/components/NotationBlock.js +219 -0
- package/lib/cjs/web/components/NotationBlock.js.map +1 -0
- package/lib/cjs/web/components/NotebookCell.d.ts +41 -0
- package/lib/cjs/web/components/NotebookCell.js +269 -0
- package/lib/cjs/web/components/NotebookCell.js.map +1 -0
- package/lib/cjs/web/components/NotebookView.d.ts +37 -0
- package/lib/cjs/web/components/NotebookView.js +379 -0
- package/lib/cjs/web/components/NotebookView.js.map +1 -0
- package/lib/cjs/web/components/SideBySideEditor.d.ts +47 -0
- package/lib/cjs/web/components/SideBySideEditor.js +171 -0
- package/lib/cjs/web/components/SideBySideEditor.js.map +1 -0
- package/lib/cjs/web/dockview.d.ts +2 -0
- package/lib/cjs/web/dockview.js +11 -0
- package/lib/cjs/web/dockview.js.map +1 -0
- package/lib/cjs/web/index.d.ts +8 -0
- package/lib/cjs/web/index.js +34 -0
- package/lib/cjs/web/index.js.map +1 -0
- package/lib/cjs/web/types/notebook.d.ts +64 -0
- package/lib/cjs/web/types/notebook.js +56 -0
- package/lib/cjs/web/types/notebook.js.map +1 -0
- package/lib/cjs/web/utils/cellFactory.d.ts +16 -0
- package/lib/cjs/web/utils/cellFactory.js +137 -0
- package/lib/cjs/web/utils/cellFactory.js.map +1 -0
- package/lib/cjs/web/utils/sourceSerializer.d.ts +19 -0
- package/lib/cjs/web/utils/sourceSerializer.js +162 -0
- package/lib/cjs/web/utils/sourceSerializer.js.map +1 -0
- package/lib/esm/block.d.ts +4 -0
- package/lib/esm/block.js +24 -0
- package/lib/esm/block.js.map +1 -1
- package/lib/esm/core.d.ts +15 -0
- package/lib/esm/core.js +144 -4
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/entity.d.ts +4 -0
- package/lib/esm/entity.js +12 -0
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/events.d.ts +56 -0
- package/lib/esm/events.js +24 -0
- package/lib/esm/events.js.map +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/parser.js +1 -1
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.d.ts +11 -0
- package/lib/esm/shapes.js +24 -2
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/web/components/DockViewPlayground.d.ts +51 -0
- package/lib/esm/web/components/DockViewPlayground.js +358 -0
- package/lib/esm/web/components/DockViewPlayground.js.map +1 -0
- package/lib/esm/web/components/NotationBlock.d.ts +35 -0
- package/lib/esm/web/components/NotationBlock.js +216 -0
- package/lib/esm/web/components/NotationBlock.js.map +1 -0
- package/lib/esm/web/components/NotebookCell.d.ts +41 -0
- package/lib/esm/web/components/NotebookCell.js +266 -0
- package/lib/esm/web/components/NotebookCell.js.map +1 -0
- package/lib/esm/web/components/NotebookView.d.ts +37 -0
- package/lib/esm/web/components/NotebookView.js +376 -0
- package/lib/esm/web/components/NotebookView.js.map +1 -0
- package/lib/esm/web/components/SideBySideEditor.d.ts +47 -0
- package/lib/esm/web/components/SideBySideEditor.js +168 -0
- package/lib/esm/web/components/SideBySideEditor.js.map +1 -0
- package/lib/esm/web/dockview.d.ts +2 -0
- package/lib/esm/web/dockview.js +3 -0
- package/lib/esm/web/dockview.js.map +1 -0
- package/lib/esm/web/index.d.ts +8 -0
- package/lib/esm/web/index.js +9 -0
- package/lib/esm/web/index.js.map +1 -0
- package/lib/esm/web/types/notebook.d.ts +64 -0
- package/lib/esm/web/types/notebook.js +50 -0
- package/lib/esm/web/types/notebook.js.map +1 -0
- package/lib/esm/web/utils/cellFactory.d.ts +16 -0
- package/lib/esm/web/utils/cellFactory.js +127 -0
- package/lib/esm/web/utils/cellFactory.js.map +1 -0
- package/lib/esm/web/utils/sourceSerializer.d.ts +19 -0
- package/lib/esm/web/utils/sourceSerializer.js +154 -0
- package/lib/esm/web/utils/sourceSerializer.js.map +1 -0
- package/package.json +43 -1
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,gDAAwB;AACxB,iCAA6F;AAC7F,yCAA2E;AAC3E,yCAaoB;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,CAAe,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ACzF,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ;YAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC/D,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,iBAAiB,CAAC,KAAa;QAC7B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAvRD,wBAuRC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport * as TLEX from \"tlex\";\nimport YAML from \"yaml\";\nimport { Literal, AtomType, Note, Atom, Rest, Space, Syllable, Group, Marker } from \"./core\";\nimport { Notation, MetaData as Meta, Command, CmdParam } from \"./notation\";\nimport {\n RawEmbedding,\n ApplyLayout,\n AddAtoms,\n SetCycle,\n SetBeatDuration,\n SetBreaks,\n ActivateRole,\n CreateRole,\n CreateLine,\n Section,\n ScopedGroup,\n Repeat,\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 FRONT_MATTER /^---$/m { toFrontMatter }\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 Document -> Elements\n | FRONT_MATTER Elements { prependFrontMatter }\n ;\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 ? OptBlock { newCommandWithBlock } ;\n CommandParams -> OPEN_PAREN ParamList ? CLOSE_PAREN { $2 } ;\n OptBlock -> Block\n | { nullBlock }\n ;\n Block -> BlockStart Elements CLOSE_BRACE { endBlock } ;\n BlockStart -> OPEN_BRACE { beginBlock } ;\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 toFrontMatter: (token: TLEX.Token, tape: TLEX.Tape, _owner: any) => {\n // skip the initial \">\"\n const endPat = \"\\n---\";\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 front matter\");\n }\n token.value = tape.substring(startPos, endPos);\n // console.log(\"Found FM: \", token.value);\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 */\nimport {\n Block,\n SectionBlock,\n RepeatBlock,\n CycleBlock,\n BeatDurationBlock,\n BreaksBlock,\n RoleBlock,\n GroupBlock,\n} from \"./block\";\nimport { parseCycle } from \"./utils\";\n\n/**\n * Wrapper for a command that has a block of child commands.\n * When applied, it creates the appropriate Block subclass and applies child commands to it.\n */\nexport class BlockCommand extends Command {\n readonly innerCommand: Command;\n readonly blockCommands: Command[];\n\n constructor(innerCommand: Command, blockCommands: Command[]) {\n super(innerCommand.params);\n this.innerCommand = innerCommand;\n this.blockCommands = blockCommands;\n }\n\n get name(): string {\n return `Block(${this.innerCommand.name})`;\n }\n\n /**\n * Creates the appropriate Block subclass based on the inner command type.\n */\n private createBlock(parent: Block): Block {\n const cmd = this.innerCommand;\n\n if (cmd instanceof Section) {\n return new SectionBlock(cmd.sectionName, parent);\n } else if (cmd instanceof Repeat) {\n return new RepeatBlock(cmd.count, parent);\n } else if (cmd instanceof SetCycle) {\n const cycle = parseCycle(cmd.getParamAt(0));\n return new CycleBlock(cycle, parent);\n } else if (cmd instanceof SetBeatDuration) {\n return new BeatDurationBlock(cmd.beatDuration, parent);\n } else if (cmd instanceof SetBreaks) {\n return new BreaksBlock(cmd.pattern, parent);\n } else if (cmd instanceof CreateRole) {\n const roleName = cmd.getParamAt(0);\n return new RoleBlock(roleName, cmd.notesOnly, parent);\n } else if (cmd instanceof ScopedGroup) {\n return new GroupBlock(cmd.groupName || null, parent);\n } else {\n // Generic block for other commands\n return new Block(cmd.name.toLowerCase(), parent);\n }\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n innerCommand: this.innerCommand.debugValue(),\n blockCommands: this.blockCommands.map((cmd) => cmd.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n // Create the appropriate Block subclass\n // Cast notation as Block since Notation will extend Block\n const block = this.createBlock(notation as unknown as Block);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the notation\n notation.addBlockItem(block);\n }\n\n applyToBlock(container: Block): void {\n // Create the appropriate Block subclass\n const block = this.createBlock(container);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the container\n container.addBlockItem(block);\n }\n}\n\nexport class Parser {\n errors: (TLEX.TokenizerError | G.ParseError)[] = [];\n metadata: any = {};\n readonly commands: Command[] = [];\n // Stack to track command indices when entering blocks\n private blockStartStack: number[] = [];\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 // Block handling semantic actions\n beginBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Push current command count to track where this block's commands start\n this.blockStartStack.push(this.commands.length);\n return null;\n },\n endBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Pop the start index and extract commands added since then\n const startIndex = this.blockStartStack.pop()!;\n const blockCommands = this.commands.splice(startIndex);\n return blockCommands;\n },\n nullBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // No block present\n return null;\n },\n newCommandWithBlock: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const name = children[0].value;\n const params = children[1].value;\n const blockCommands = children[2].value as Command[] | null;\n\n const innerCommand = this.createCommand(name, params);\n\n if (blockCommands !== null) {\n // Wrap in BlockCommand\n return new BlockCommand(innerCommand, blockCommands);\n } else {\n // No block, return regular command\n return innerCommand;\n }\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 prependFrontMatter: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const fm = children[0].value;\n // console.log(\"Child 0: \", fm);\n // console.log(\"Child 1: \", children[1].value);\n const data = YAML.parse(fm);\n console.log(\"Parsed FM: \", data);\n this.metadata = data;\n return children[1].value;\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\") { 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 if (lName == \"section\") {\n return new Section(params);\n } else if (lName == \"group\") {\n return new ScopedGroup(params);\n } else if (lName == \"repeat\") {\n return new Repeat(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 try {\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 } catch (err) {\n if (err instanceof G.ParseError) {\n this.errors.push(err);\n } else {\n throw err;\n }\n }\n return null;\n }\n\n parseAndBuild(input: string): [Notation, G.ParseError[]] {\n this.parse(input);\n const notation = new Notation();\n const errors: G.ParseError[] = [];\n errors.push(...this.errors);\n\n // First add the metadata then we can set it\n for (const key in this.metadata) notation.addMetaData(new Meta(key, this.metadata[key]));\n for (const cmd of this.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n }\n\n parseEmbelishment(value: string): [any, boolean] {\n return carnatic.parseEmbelishment(value);\n }\n}\n"]}
|
|
1
|
+
{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,CAAC;IAED,aAAa,CAAC,KAAa;QACzB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClB,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;QAChC,MAAM,MAAM,GAAmB,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAG5B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ;YAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,mBAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzF,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ;YAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC/D,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,iBAAiB,CAAC,KAAa;QAC7B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAvRD,wBAuRC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport * as TLEX from \"tlex\";\nimport YAML from \"yaml\";\nimport { Literal, AtomType, Note, Atom, Rest, Space, Syllable, Group, Marker } from \"./core\";\nimport { Notation, MetaData as Meta, Command, CmdParam } from \"./notation\";\nimport {\n RawEmbedding,\n ApplyLayout,\n AddAtoms,\n SetCycle,\n SetBeatDuration,\n SetBreaks,\n ActivateRole,\n CreateRole,\n CreateLine,\n Section,\n ScopedGroup,\n Repeat,\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 FRONT_MATTER /^---$/m { toFrontMatter }\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 Document -> Elements\n | FRONT_MATTER Elements { prependFrontMatter }\n ;\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 ? OptBlock { newCommandWithBlock } ;\n CommandParams -> OPEN_PAREN ParamList ? CLOSE_PAREN { $2 } ;\n OptBlock -> Block\n | { nullBlock }\n ;\n Block -> BlockStart Elements CLOSE_BRACE { endBlock } ;\n BlockStart -> OPEN_BRACE { beginBlock } ;\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 debug: \"\",\n type: \"lalr\",\n leftRecursive: true,\n tokenHandlers: {\n toEmbelishment: (token: TLEX.Token, tape: TLEX.TapeInterface, owner: any) => {\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.TapeInterface, _owner: any) => {\n token.value = token.value.substring(1);\n return token;\n },\n toBoolean: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = token.value == \"true\";\n return token;\n },\n toNumber: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = parseInt(token.value);\n return token;\n },\n toString: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = token.value.substring(1, token.value.length - 1);\n return token;\n },\n toMarker: (token: TLEX.Token, _tape: TLEX.TapeInterface, _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.TapeInterface, _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.TapeInterface, _owner: any) => {\n token.value = token.value.substring(0, token.value.length - 1);\n return token;\n },\n toLineAnnotation: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n // skip the initial \"!\"\n token.value = token.value.substring(1);\n return token;\n },\n toSingleLineRawString: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n // skip the initial \">\"\n token.value = token.value.substring(1);\n return token;\n },\n toMultiLineRawString: (token: TLEX.Token, tape: TLEX.TapeInterface, _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 toFrontMatter: (token: TLEX.Token, tape: TLEX.TapeInterface, _owner: any) => {\n // skip the initial \">\"\n const endPat = \"\\n---\";\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 front matter\");\n }\n token.value = tape.substring(startPos, endPos);\n // console.log(\"Found FM: \", token.value);\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 */\nimport {\n Block,\n SectionBlock,\n RepeatBlock,\n CycleBlock,\n BeatDurationBlock,\n BreaksBlock,\n RoleBlock,\n GroupBlock,\n} from \"./block\";\nimport { parseCycle } from \"./utils\";\n\n/**\n * Wrapper for a command that has a block of child commands.\n * When applied, it creates the appropriate Block subclass and applies child commands to it.\n */\nexport class BlockCommand extends Command {\n readonly innerCommand: Command;\n readonly blockCommands: Command[];\n\n constructor(innerCommand: Command, blockCommands: Command[]) {\n super(innerCommand.params);\n this.innerCommand = innerCommand;\n this.blockCommands = blockCommands;\n }\n\n get name(): string {\n return `Block(${this.innerCommand.name})`;\n }\n\n /**\n * Creates the appropriate Block subclass based on the inner command type.\n */\n private createBlock(parent: Block): Block {\n const cmd = this.innerCommand;\n\n if (cmd instanceof Section) {\n return new SectionBlock(cmd.sectionName, parent);\n } else if (cmd instanceof Repeat) {\n return new RepeatBlock(cmd.count, parent);\n } else if (cmd instanceof SetCycle) {\n const cycle = parseCycle(cmd.getParamAt(0));\n return new CycleBlock(cycle, parent);\n } else if (cmd instanceof SetBeatDuration) {\n return new BeatDurationBlock(cmd.beatDuration, parent);\n } else if (cmd instanceof SetBreaks) {\n return new BreaksBlock(cmd.pattern, parent);\n } else if (cmd instanceof CreateRole) {\n const roleName = cmd.getParamAt(0);\n return new RoleBlock(roleName, cmd.notesOnly, parent);\n } else if (cmd instanceof ScopedGroup) {\n return new GroupBlock(cmd.groupName || null, parent);\n } else {\n // Generic block for other commands\n return new Block(cmd.name.toLowerCase(), parent);\n }\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n innerCommand: this.innerCommand.debugValue(),\n blockCommands: this.blockCommands.map((cmd) => cmd.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n // Create the appropriate Block subclass\n // Cast notation as Block since Notation will extend Block\n const block = this.createBlock(notation as unknown as Block);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the notation\n notation.addBlockItem(block);\n }\n\n applyToBlock(container: Block): void {\n // Create the appropriate Block subclass\n const block = this.createBlock(container);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the container\n container.addBlockItem(block);\n }\n}\n\nexport class Parser {\n errors: (TLEX.TokenizerError | G.ParseError)[] = [];\n metadata: any = {};\n readonly commands: Command[] = [];\n // Stack to track command indices when entering blocks\n private blockStartStack: number[] = [];\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 // Block handling semantic actions\n beginBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Push current command count to track where this block's commands start\n this.blockStartStack.push(this.commands.length);\n return null;\n },\n endBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Pop the start index and extract commands added since then\n const startIndex = this.blockStartStack.pop()!;\n const blockCommands = this.commands.splice(startIndex);\n return blockCommands;\n },\n nullBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // No block present\n return null;\n },\n newCommandWithBlock: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const name = children[0].value;\n const params = children[1].value;\n const blockCommands = children[2].value as Command[] | null;\n\n const innerCommand = this.createCommand(name, params);\n\n if (blockCommands !== null) {\n // Wrap in BlockCommand\n return new BlockCommand(innerCommand, blockCommands);\n } else {\n // No block, return regular command\n return innerCommand;\n }\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 prependFrontMatter: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const fm = children[0].value;\n // console.log(\"Child 0: \", fm);\n // console.log(\"Child 1: \", children[1].value);\n const data = YAML.parse(fm);\n console.log(\"Parsed FM: \", data);\n this.metadata = data;\n return children[1].value;\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\") { 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 if (lName == \"section\") {\n return new Section(params);\n } else if (lName == \"group\") {\n return new ScopedGroup(params);\n } else if (lName == \"repeat\") {\n return new Repeat(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 try {\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 } catch (err) {\n if (err instanceof G.ParseError) {\n this.errors.push(err);\n } else {\n throw err;\n }\n }\n return null;\n }\n\n parseAndBuild(input: string): [Notation, G.ParseError[]] {\n this.parse(input);\n const notation = new Notation();\n const errors: G.ParseError[] = [];\n errors.push(...this.errors);\n\n // First add the metadata then we can set it\n for (const key in this.metadata) notation.addMetaData(new Meta(key, this.metadata[key]));\n for (const cmd of this.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n }\n\n parseEmbelishment(value: string): [any, boolean] {\n return carnatic.parseEmbelishment(value);\n }\n}\n"]}
|
package/lib/cjs/shapes.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
2
|
import { Atom, LeafAtom, Group } from "./core";
|
|
3
|
+
export interface CollisionLayoutItem {
|
|
4
|
+
timeOffset: TSU.Num.Fraction;
|
|
5
|
+
duration: TSU.Num.Fraction;
|
|
6
|
+
glyphOffset: number;
|
|
7
|
+
minWidth: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CollisionLayoutResult {
|
|
10
|
+
x: number;
|
|
11
|
+
wasCollision: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function computeCollisionLayout(items: CollisionLayoutItem[], totalDuration: TSU.Num.Fraction, containerWidth: number): CollisionLayoutResult[];
|
|
3
14
|
export declare abstract class Shape {
|
|
4
15
|
private static idCounter;
|
|
5
16
|
readonly shapeId: number;
|
package/lib/cjs/shapes.js
CHANGED
|
@@ -34,8 +34,26 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.GroupView = exports.LeafAtomView = exports.AtomView = exports.ElementShape = exports.Embelishment = exports.Shape = void 0;
|
|
37
|
+
exports.computeCollisionLayout = computeCollisionLayout;
|
|
37
38
|
const TSU = __importStar(require("@panyam/tsutils"));
|
|
38
39
|
const core_1 = require("./core");
|
|
40
|
+
function computeCollisionLayout(items, totalDuration, containerWidth) {
|
|
41
|
+
const results = [];
|
|
42
|
+
let prevItemEndX = 0;
|
|
43
|
+
let currTime = core_1.ZERO;
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
const glyphX = totalDuration.isZero ? 0 : currTime.timesNum(containerWidth).divby(totalDuration).floor;
|
|
46
|
+
let realX = glyphX - item.glyphOffset;
|
|
47
|
+
const wasCollision = realX < prevItemEndX;
|
|
48
|
+
if (wasCollision) {
|
|
49
|
+
realX = prevItemEndX;
|
|
50
|
+
}
|
|
51
|
+
results.push({ x: realX, wasCollision });
|
|
52
|
+
prevItemEndX = realX + item.minWidth;
|
|
53
|
+
currTime = currTime.plus(item.duration);
|
|
54
|
+
}
|
|
55
|
+
return results;
|
|
56
|
+
}
|
|
39
57
|
class Shape {
|
|
40
58
|
constructor() {
|
|
41
59
|
this.shapeId = Shape.idCounter++;
|
|
@@ -300,10 +318,15 @@ class GroupView extends AtomView {
|
|
|
300
318
|
const groupWidth = this.hasWidth ? this.width / this.scaleFactor : unscaledMinWidth;
|
|
301
319
|
this.clearContinuationMarkers();
|
|
302
320
|
let currTime = core_1.ZERO;
|
|
321
|
+
let prevNoteEndX = 0;
|
|
303
322
|
this.atomViews.forEach((av, index) => {
|
|
304
323
|
const glyphX = totalDur.isZero ? 0 : currTime.timesNum(groupWidth).divby(totalDur).floor;
|
|
305
|
-
|
|
306
|
-
|
|
324
|
+
let realX = glyphX - av.glyphOffset;
|
|
325
|
+
if (realX < prevNoteEndX) {
|
|
326
|
+
realX = prevNoteEndX;
|
|
327
|
+
}
|
|
328
|
+
av.setBounds(realX, currY, null, null, true);
|
|
329
|
+
prevNoteEndX = realX + av.minSize.width;
|
|
307
330
|
if (this.showContinuationMarkers && !totalDur.isZero) {
|
|
308
331
|
const atomDur = av.totalDuration;
|
|
309
332
|
const durValue = atomDur.num / atomDur.den;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S,EAAE,CAAS;QACrD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE;YAC3C,MAAM,EAAE,IAAI,CAAC,YAAY;YACzB,KAAK,EAAE;gBACL,KAAK,EAAE,oBAAoB;gBAC3B,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;gBACf,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;aAChB;YACD,IAAI,EAAE,GAAG;SACV,CAAmB,CAAC;QACrB,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAKD,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAMS,mBAAmB;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAMD,SAAS,CAAC,MAAW;QACnB,IAAI,aAAa,IAAI,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnE,IAAI,yBAAyB,IAAI,MAAM;YAAE,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,uBAAuB,CAAC;QACvG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF;AAhUD,8BAgUC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { ZERO, Atom, LeafAtom, Group } from \"./core\";\n\n/**\n * Base class for all renderable objects.\n *\n * Shape caches properties like bounding boxes to improve performance,\n * since bounding box calculations can be expensive. This also allows\n * testing layouts and positioning without worrying about implementation details.\n */\nexport abstract class Shape {\n private static idCounter = 0;\n readonly shapeId: number = Shape.idCounter++;\n\n /**\n * Note that x and y coordinates are not always the x and y coordinates\n * of the bounding box.\n * E.g., a circle's x and y coordinates are its center point and not the\n * top left corner.\n * These \"main\" coordinates are referred to 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 /** Child shapes contained within this shape */\n children: Shape[] = [];\n\n /**\n * Gets the bounding box of this shape.\n * Calculates it if it hasn't been calculated yet.\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 * Gets the minimum size of this shape.\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 * Refreshes the bounding box of this shape.\n * Called when the shape knows the bbox it is tracking cannot be trusted\n * and has to be refreshed by calling native methods.\n * @returns The refreshed bounding box\n */\n protected abstract refreshBBox(): TSU.Geom.Rect;\n\n /**\n * Refreshes the minimum size of this shape.\n * @returns The refreshed minimum size\n */\n protected abstract refreshMinSize(): TSU.Geom.Size;\n\n /**\n * Updates the bounds of this shape.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\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 /**\n * Invalidates the cached bounds of this shape.\n * Forces recalculation of bounding box and minimum size.\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 bounds of this shape.\n *\n * Note that null and NaN are valid values and mean the following:\n * - null: Don't change the value\n * - NaN: Set the value to null (use the bounding box's value)\n *\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @param applyLayout Whether to apply layout immediately\n * @returns The updated bounds values\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 /**\n * Checks if this shape has an explicit x coordinate.\n */\n get hasX(): boolean {\n return this._x != null && !isNaN(this._x);\n }\n\n /**\n * Checks if this shape has an explicit y coordinate.\n */\n get hasY(): boolean {\n return this._y != null && !isNaN(this._y);\n }\n\n /**\n * Checks if this shape has an explicit width.\n */\n get hasWidth(): boolean {\n return this._width != null && !isNaN(this._width);\n }\n\n /**\n * Checks if this shape has an explicit height.\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 /**\n * Gets the width of this shape.\n */\n get width(): number {\n if (this._width != null) return this._width;\n return 0; // this.bbox.width;\n }\n\n /**\n * Sets the width of this shape.\n */\n set width(w: number | null) {\n this.setBounds(null, null, w == null ? NaN : w, null);\n }\n\n /**\n * Gets the height of this shape.\n */\n get height(): number {\n if (this._height != null) return this._height;\n return 0; // this.bbox.height;\n }\n\n /**\n * Sets the height of this shape.\n */\n set height(h: number | null) {\n this.setBounds(null, null, null, h == null ? NaN : h);\n }\n\n /**\n * Refreshes the layout of this shape.\n * Called when bounds or other properties have changed to give the shape an\n * opportunity to layout its children. For shapes with no children this is a no-op.\n */\n refreshLayout(): void {\n // throw new Error(\"Implement this\");\n }\n}\n\n/**\n * Represents an embellishment applied to a musical element.\n */\nexport abstract class Embelishment extends Shape {}\n\n/**\n * A shape that wraps an SVG element.\n * ElementShape provides the base class for all shapes that are rendered as SVG elements.\n */\nexport class ElementShape<T extends SVGGraphicsElement = SVGGraphicsElement> extends Shape {\n /**\n * Creates a new ElementShape.\n * @param element The SVG element this shape wraps\n */\n constructor(public readonly element: T) {\n super();\n }\n\n /**\n * Refreshes the bounding box of this element.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Refreshes the minimum size of this element.\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Updates the bounds of this element.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\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 /**\n * Refreshes the layout of this element.\n * Updates the element's attributes based on the shape's properties.\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\n/**\n * Base class for views that represent atoms in the notation.\n * AtomView provides the visual representation of an atom.\n */\nexport abstract class AtomView extends Shape {\n /** Nesting depth of this atom in the structure */\n depth = 0;\n /** Index of the role containing this atom */\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 position for vertical alignment */\n baseline: number;\n /** Ascent (space above baseline) */\n ascent: number;\n /** Descent (space below baseline) */\n descent: number;\n /** Height of capital letters */\n capHeight: number;\n /** Space between lines */\n leading: number;\n\n /**\n * Checks if this atom view represents a leaf atom.\n */\n abstract isLeaf(): boolean;\n\n abstract get totalDuration(): TSU.Num.Fraction;\n\n /**\n * Returns the horizontal offset from the atom's origin to where the note glyph starts.\n * This accounts for left embellishments that appear before the note.\n * Used by GroupView to align note glyphs at their correct time positions.\n *\n * Default is 0 (glyph starts at origin). Subclasses with left embellishments\n * should override to return the width of left-side decorations.\n */\n get glyphOffset(): number {\n return 0;\n }\n\n /**\n * Creates the SVG elements needed for this atom view.\n * @param parent The parent SVG element to attach to\n */\n abstract createElements(parent: SVGGraphicsElement): void;\n}\n\n/**\n * A view for leaf atoms (those that cannot contain other atoms).\n */\nexport abstract class LeafAtomView extends AtomView {\n /**\n * Creates a new LeafAtomView.\n * @param leafAtom The leaf atom this view represents\n */\n constructor(public leafAtom: LeafAtom) {\n super();\n }\n\n /**\n * Leaf atom views always return true for isLeaf().\n */\n isLeaf(): boolean {\n return true;\n }\n\n /**\n * Gets a unique identifier for this view based on the atom's UUID.\n */\n get viewId(): number {\n return this.leafAtom.uuid;\n }\n\n /**\n * Returns the total duration of the atom rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.leafAtom.duration;\n }\n}\n\n/**\n * A view for group atoms that contain multiple child atoms.\n */\nexport abstract class GroupView extends AtomView {\n /** Space between atoms in this group */\n protected atomSpacing: number;\n /** The SVG group element for this view */\n protected groupElement: SVGGElement;\n /** Views for the atoms in this group */\n protected atomViews: AtomView[] = [];\n private _embelishments: Embelishment[];\n /** Whether this group represents notes by default */\n defaultToNotes = true;\n /** Whether this view needs layout */\n needsLayout = true;\n /** Scale factor for this group */\n scaleFactor = 1.0;\n /**\n * When true, shows continuation markers (\",\") for atoms with duration > 1\n * instead of just leaving empty space.\n */\n showContinuationMarkers = true;\n /** SVG elements for continuation markers */\n protected continuationMarkerElements: SVGTextElement[] = [];\n\n /**\n * Creates a new GroupView.\n * @param group The group atom this view represents\n * @param config Optional configuration object\n */\n constructor(\n public group: Group,\n config?: any,\n ) {\n super();\n this.atomSpacing = 5;\n this.setStyles(config || {});\n }\n\n /**\n * Returns the total duration of the group rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.group.totalChildDuration;\n }\n\n /**\n * Creates the SVG elements needed for this group view.\n * @param parent The parent SVG element to attach to\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 /**\n * Group views always return false for isLeaf().\n */\n isLeaf(): boolean {\n return false;\n }\n\n /**\n * Refreshes the bounding box of this group.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.groupElement);\n }\n\n /**\n * Refreshes the minimum size of this group using duration-based width calculation.\n *\n * ## Duration-Based Width Algorithm\n *\n * This algorithm ensures atoms with extended durations receive proportionally\n * more horizontal space. For example, with `\\beatDuration(4)` and input `S 2 R G M`:\n * - S has duration 1, R has duration 2, G has duration 1\n * - R should visually occupy twice the horizontal space of S or G\n *\n * ### Algorithm Steps:\n *\n * 1. **Calculate width per duration unit**: For each atom, compute the visual width\n * needed per unit of duration: `(visualWidth + spacing) / duration`\n *\n * 2. **Find maximum**: Take the maximum width-per-duration across all atoms.\n * This ensures every atom has enough space for its visual content.\n *\n * 3. **Scale by total duration**: Multiply the max width-per-duration by the\n * group's total duration to get the final group width.\n *\n * ### Example:\n * ```\n * Atoms: S(dur=1, width=10px), R(dur=2, width=10px), G(dur=1, width=10px)\n * Spacing: 5px\n *\n * Width per duration:\n * S: (10 + 5) / 1 = 15 px/unit\n * R: (10 + 5) / 2 = 7.5 px/unit\n * G: (10 + 5) / 1 = 15 px/unit\n *\n * Max width per duration: 15 px/unit\n * Total duration: 1 + 2 + 1 = 4 units\n * Group width: 15 * 4 = 60px\n *\n * Positioning:\n * S at x=0 (time 0/4 * 60 = 0)\n * R at x=15 (time 1/4 * 60 = 15)\n * G at x=45 (time 3/4 * 60 = 45)\n * ```\n *\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n let maxHeight = 0;\n\n // Step 1: Calculate width per duration unit for each atom\n let minWidthPerDuration = 0;\n this.atomViews.forEach((av) => {\n const ms = av.minSize;\n const dur = av.totalDuration;\n if (!dur.isZero) {\n const durValue = dur.num / dur.den;\n const widthPerDur = (ms.width + this.atomSpacing) / durValue;\n // Step 2: Track maximum width per duration\n minWidthPerDuration = Math.max(minWidthPerDuration, widthPerDur);\n }\n maxHeight = Math.max(maxHeight, ms.height);\n });\n\n // Step 3: Scale by total duration\n const totalDuration = this.group.totalChildDuration;\n const totalDurValue = totalDuration.num / totalDuration.den;\n const totalWidth = minWidthPerDuration * totalDurValue;\n\n return new TSU.Geom.Size(totalWidth * this.scaleFactor, maxHeight * this.scaleFactor);\n }\n\n /**\n * Creates an atom view for a specific atom.\n * @param atom The atom to create a view for\n * @returns The created atom view\n */\n abstract createAtomView(atom: Atom): AtomView;\n\n /**\n * Updates the bounds of this group.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\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 /**\n * Refreshes the layout of this group using duration-based positioning.\n *\n * ## Duration-Based Positioning Algorithm\n *\n * Atoms are positioned at x-coordinates proportional to their time offset\n * within the group's total duration. This ensures that atoms with extended\n * durations visually occupy the correct amount of horizontal space.\n *\n * ### Width Source Priority:\n *\n * 1. **Column width** (preferred): If width was set via `setBounds()` from the\n * grid layout system (ColAlign), use that width. This enables global alignment\n * across all beats in the same column.\n *\n * 2. **Minimum size**: Fall back to `minSize.width` calculated by `refreshMinSize()`.\n *\n * ### Positioning Formula:\n * ```\n * xPosition = (timeOffset / totalDuration) * groupWidth\n * ```\n *\n * ### Continuation Markers:\n *\n * When `showContinuationMarkers` is true (default), atoms with duration > 1\n * will have \",\" markers rendered at each additional time slot. For example,\n * an atom with duration 2 will show \"R ,\" instead of \"R \".\n *\n * This helps users visually understand that the note continues through\n * multiple time slots without relying on empty space alone.\n *\n * ### Example:\n * ```\n * Input: S 2 R G (with beatDuration=4)\n * Group width: 60px, Total duration: 4 units\n *\n * Positioning:\n * S at x=0 (time 0, offset 0/4 * 60 = 0)\n * R at x=15 (time 1, offset 1/4 * 60 = 15)\n * \",\" at x=30 (continuation marker for R at time 2)\n * G at x=45 (time 3, offset 3/4 * 60 = 45)\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\n const currY = 0;\n const totalDur = this.group.totalChildDuration;\n\n // Width source priority: column width (for global alignment) > minSize\n const unscaledMinWidth = this.minSize.width / this.scaleFactor;\n const groupWidth = this.hasWidth ? this.width / this.scaleFactor : unscaledMinWidth;\n\n // Clear existing continuation markers before re-rendering\n this.clearContinuationMarkers();\n\n // Position each atom based on its time offset\n let currTime = ZERO;\n this.atomViews.forEach((av, index) => {\n // Calculate where the NOTE GLYPH should appear based on time offset\n const glyphX = totalDur.isZero ? 0 : currTime.timesNum(groupWidth).divby(totalDur).floor;\n // Subtract glyphOffset so left embellishments don't push the glyph past its time position\n // The atom origin is placed earlier, so the glyph ends up at the correct time position\n const xPos = Math.max(0, glyphX - av.glyphOffset);\n av.setBounds(xPos, currY, null, null, true);\n\n // Render continuation markers for atoms with duration > 1\n if (this.showContinuationMarkers && !totalDur.isZero) {\n const atomDur = av.totalDuration;\n const durValue = atomDur.num / atomDur.den;\n if (durValue > 1) {\n // Render one marker at each additional time slot within the atom's duration\n const numMarkers = Math.floor(durValue) - 1;\n for (let i = 1; i <= numMarkers; i++) {\n // Marker time = currTime + (atomDuration * i / floor(duration))\n const markerTime = currTime.plus(atomDur.timesNum(i).divbyNum(Math.floor(durValue)));\n const markerX = markerTime.timesNum(groupWidth).divby(totalDur).floor;\n this.renderContinuationMarker(markerX, currY);\n }\n }\n }\n\n currTime = currTime.plus(av.totalDuration);\n });\n\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n /**\n * Clears all continuation marker elements.\n */\n protected clearContinuationMarkers(): void {\n for (const el of this.continuationMarkerElements) {\n el.remove();\n }\n this.continuationMarkerElements = [];\n }\n\n /**\n * Renders a continuation marker (\",\") at the specified position.\n * @param x X position for the marker\n * @param y Y position for the marker\n */\n protected renderContinuationMarker(x: number, y: number): void {\n const marker = TSU.DOM.createSVGNode(\"text\", {\n parent: this.groupElement,\n attrs: {\n class: \"continuationMarker\",\n x: x.toString(),\n y: y.toString(),\n },\n text: \",\",\n }) as SVGTextElement;\n this.continuationMarkerElements.push(marker);\n }\n\n /**\n * Gets the embellishments for this group.\n */\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n /**\n * Creates the embellishments for this group.\n * @returns An array of embellishments\n */\n protected createEmbelishments(): Embelishment[] {\n return [];\n }\n\n /**\n * Sets the styles for this group.\n * @param config Style configuration object\n */\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n if (\"showContinuationMarkers\" in config) this.showContinuationMarkers = config.showContinuationMarkers;\n this.needsLayout = true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shapes.js","sourceRoot":"","sources":["../../src/shapes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,wDA+BC;AAzED,qDAAuC;AACvC,iCAAqD;AAyCrD,SAAgB,sBAAsB,CACpC,KAA4B,EAC5B,aAA+B,EAC/B,cAAsB;IAEtB,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,QAAQ,GAAG,WAAI,CAAC;IAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAEzB,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC;QAGvG,IAAI,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAGtC,MAAM,YAAY,GAAG,KAAK,GAAG,YAAY,CAAC;QAC1C,IAAI,YAAY,EAAE,CAAC;YACjB,KAAK,GAAG,YAAY,CAAC;QACvB,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAGzC,YAAY,GAAG,KAA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MAAM,EAAE,CAAC;QACd,CAAC;QACD,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;IACvC,CAAC;IAOS,wBAAwB,CAAC,CAAS,EAAE,CAAS;QACrD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE;YAC3C,MAAM,EAAE,IAAI,CAAC,YAAY;YACzB,KAAK,EAAE;gBACL,KAAK,EAAE,oBAAoB;gBAC3B,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;gBACf,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;aAChB;YACD,IAAI,EAAE,GAAG;SACV,CAAmB,CAAC;QACrB,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAKD,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAMS,mBAAmB;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAMD,SAAS,CAAC,MAAW;QACnB,IAAI,aAAa,IAAI,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnE,IAAI,yBAAyB,IAAI,MAAM;YAAE,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,uBAAuB,CAAC;QACvG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF;AA9VD,8BA8VC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { ZERO, Atom, LeafAtom, Group } from \"./core\";\n\n/**\n * Represents an item to be positioned in collision-based layout.\n */\nexport interface CollisionLayoutItem {\n /** Time offset as a fraction (numerator/denominator) */\n timeOffset: TSU.Num.Fraction;\n /** Duration of this item */\n duration: TSU.Num.Fraction;\n /** Width of pre-embellishments (extends left from glyph position) */\n glyphOffset: number;\n /** Minimum width of the item (includes all embellishments and glyph) */\n minWidth: number;\n}\n\n/**\n * Result of collision-based layout for a single item.\n */\nexport interface CollisionLayoutResult {\n /** The calculated x position for the item */\n x: number;\n /** Whether the item was pushed right due to collision */\n wasCollision: boolean;\n}\n\n/**\n * Computes collision-based positions for a sequence of items within a container.\n *\n * ## Algorithm\n *\n * 1. Calculate ideal glyph position: `glyphX = (timeOffset / totalDuration) * containerWidth`\n * 2. Pre-embellishments extend left: `realX = glyphX - glyphOffset`\n * 3. Collision check: if `realX < prevItemEndX`, then `realX = prevItemEndX`\n * 4. Track: `prevItemEndX = realX + minWidth`\n *\n * @param items Items to position (must be in time order)\n * @param totalDuration Total duration of all items\n * @param containerWidth Width of the container to position items within\n * @returns Array of positions for each item\n */\nexport function computeCollisionLayout(\n items: CollisionLayoutItem[],\n totalDuration: TSU.Num.Fraction,\n containerWidth: number,\n): CollisionLayoutResult[] {\n const results: CollisionLayoutResult[] = [];\n let prevItemEndX = 0;\n let currTime = ZERO;\n\n for (const item of items) {\n // 1. Calculate ideal glyph position based on time offset\n const glyphX = totalDuration.isZero ? 0 : currTime.timesNum(containerWidth).divby(totalDuration).floor;\n\n // 2. Pre-embellishments extend left from glyph position\n let realX = glyphX - item.glyphOffset;\n\n // 3. Collision check: push right if overlapping previous item\n const wasCollision = realX < prevItemEndX;\n if (wasCollision) {\n realX = prevItemEndX;\n }\n\n results.push({ x: realX, wasCollision });\n\n // 4. Track end position for next collision check\n prevItemEndX = realX + item.minWidth;\n\n currTime = currTime.plus(item.duration);\n }\n\n return results;\n}\n\n/**\n * Base class for all renderable objects.\n *\n * Shape caches properties like bounding boxes to improve performance,\n * since bounding box calculations can be expensive. This also allows\n * testing layouts and positioning without worrying about implementation details.\n */\nexport abstract class Shape {\n private static idCounter = 0;\n readonly shapeId: number = Shape.idCounter++;\n\n /**\n * Note that x and y coordinates are not always the x and y coordinates\n * of the bounding box.\n * E.g., a circle's x and y coordinates are its center point and not the\n * top left corner.\n * These \"main\" coordinates are referred to 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 /** Child shapes contained within this shape */\n children: Shape[] = [];\n\n /**\n * Gets the bounding box of this shape.\n * Calculates it if it hasn't been calculated yet.\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 * Gets the minimum size of this shape.\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 * Refreshes the bounding box of this shape.\n * Called when the shape knows the bbox it is tracking cannot be trusted\n * and has to be refreshed by calling native methods.\n * @returns The refreshed bounding box\n */\n protected abstract refreshBBox(): TSU.Geom.Rect;\n\n /**\n * Refreshes the minimum size of this shape.\n * @returns The refreshed minimum size\n */\n protected abstract refreshMinSize(): TSU.Geom.Size;\n\n /**\n * Updates the bounds of this shape.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\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 /**\n * Invalidates the cached bounds of this shape.\n * Forces recalculation of bounding box and minimum size.\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 bounds of this shape.\n *\n * Note that null and NaN are valid values and mean the following:\n * - null: Don't change the value\n * - NaN: Set the value to null (use the bounding box's value)\n *\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @param applyLayout Whether to apply layout immediately\n * @returns The updated bounds values\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 /**\n * Checks if this shape has an explicit x coordinate.\n */\n get hasX(): boolean {\n return this._x != null && !isNaN(this._x);\n }\n\n /**\n * Checks if this shape has an explicit y coordinate.\n */\n get hasY(): boolean {\n return this._y != null && !isNaN(this._y);\n }\n\n /**\n * Checks if this shape has an explicit width.\n */\n get hasWidth(): boolean {\n return this._width != null && !isNaN(this._width);\n }\n\n /**\n * Checks if this shape has an explicit height.\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 /**\n * Gets the width of this shape.\n */\n get width(): number {\n if (this._width != null) return this._width;\n return 0; // this.bbox.width;\n }\n\n /**\n * Sets the width of this shape.\n */\n set width(w: number | null) {\n this.setBounds(null, null, w == null ? NaN : w, null);\n }\n\n /**\n * Gets the height of this shape.\n */\n get height(): number {\n if (this._height != null) return this._height;\n return 0; // this.bbox.height;\n }\n\n /**\n * Sets the height of this shape.\n */\n set height(h: number | null) {\n this.setBounds(null, null, null, h == null ? NaN : h);\n }\n\n /**\n * Refreshes the layout of this shape.\n * Called when bounds or other properties have changed to give the shape an\n * opportunity to layout its children. For shapes with no children this is a no-op.\n */\n refreshLayout(): void {\n // throw new Error(\"Implement this\");\n }\n}\n\n/**\n * Represents an embellishment applied to a musical element.\n */\nexport abstract class Embelishment extends Shape {}\n\n/**\n * A shape that wraps an SVG element.\n * ElementShape provides the base class for all shapes that are rendered as SVG elements.\n */\nexport class ElementShape<T extends SVGGraphicsElement = SVGGraphicsElement> extends Shape {\n /**\n * Creates a new ElementShape.\n * @param element The SVG element this shape wraps\n */\n constructor(public readonly element: T) {\n super();\n }\n\n /**\n * Refreshes the bounding box of this element.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Refreshes the minimum size of this element.\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Updates the bounds of this element.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\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 /**\n * Refreshes the layout of this element.\n * Updates the element's attributes based on the shape's properties.\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\n/**\n * Base class for views that represent atoms in the notation.\n * AtomView provides the visual representation of an atom.\n */\nexport abstract class AtomView extends Shape {\n /** Nesting depth of this atom in the structure */\n depth = 0;\n /** Index of the role containing this atom */\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 position for vertical alignment */\n baseline: number;\n /** Ascent (space above baseline) */\n ascent: number;\n /** Descent (space below baseline) */\n descent: number;\n /** Height of capital letters */\n capHeight: number;\n /** Space between lines */\n leading: number;\n\n /**\n * Checks if this atom view represents a leaf atom.\n */\n abstract isLeaf(): boolean;\n\n abstract get totalDuration(): TSU.Num.Fraction;\n\n /**\n * Returns the horizontal offset from the atom's origin to where the note glyph starts.\n * This accounts for left embellishments that appear before the note.\n * Used by GroupView to align note glyphs at their correct time positions.\n *\n * Default is 0 (glyph starts at origin). Subclasses with left embellishments\n * should override to return the width of left-side decorations.\n */\n get glyphOffset(): number {\n return 0;\n }\n\n /**\n * Creates the SVG elements needed for this atom view.\n * @param parent The parent SVG element to attach to\n */\n abstract createElements(parent: SVGGraphicsElement): void;\n}\n\n/**\n * A view for leaf atoms (those that cannot contain other atoms).\n */\nexport abstract class LeafAtomView extends AtomView {\n /**\n * Creates a new LeafAtomView.\n * @param leafAtom The leaf atom this view represents\n */\n constructor(public leafAtom: LeafAtom) {\n super();\n }\n\n /**\n * Leaf atom views always return true for isLeaf().\n */\n isLeaf(): boolean {\n return true;\n }\n\n /**\n * Gets a unique identifier for this view based on the atom's UUID.\n */\n get viewId(): number {\n return this.leafAtom.uuid;\n }\n\n /**\n * Returns the total duration of the atom rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.leafAtom.duration;\n }\n}\n\n/**\n * A view for group atoms that contain multiple child atoms.\n */\nexport abstract class GroupView extends AtomView {\n /** Space between atoms in this group */\n protected atomSpacing: number;\n /** The SVG group element for this view */\n protected groupElement: SVGGElement;\n /** Views for the atoms in this group */\n protected atomViews: AtomView[] = [];\n private _embelishments: Embelishment[];\n /** Whether this group represents notes by default */\n defaultToNotes = true;\n /** Whether this view needs layout */\n needsLayout = true;\n /** Scale factor for this group */\n scaleFactor = 1.0;\n /**\n * When true, shows continuation markers (\",\") for atoms with duration > 1\n * instead of just leaving empty space.\n */\n showContinuationMarkers = true;\n /** SVG elements for continuation markers */\n protected continuationMarkerElements: SVGTextElement[] = [];\n\n /**\n * Creates a new GroupView.\n * @param group The group atom this view represents\n * @param config Optional configuration object\n */\n constructor(\n public group: Group,\n config?: any,\n ) {\n super();\n this.atomSpacing = 5;\n this.setStyles(config || {});\n }\n\n /**\n * Returns the total duration of the group rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.group.totalChildDuration;\n }\n\n /**\n * Creates the SVG elements needed for this group view.\n * @param parent The parent SVG element to attach to\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 /**\n * Group views always return false for isLeaf().\n */\n isLeaf(): boolean {\n return false;\n }\n\n /**\n * Refreshes the bounding box of this group.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.groupElement);\n }\n\n /**\n * Refreshes the minimum size of this group using duration-based width calculation.\n *\n * ## Duration-Based Width Algorithm\n *\n * This algorithm ensures atoms with extended durations receive proportionally\n * more horizontal space. For example, with `\\beatDuration(4)` and input `S 2 R G M`:\n * - S has duration 1, R has duration 2, G has duration 1\n * - R should visually occupy twice the horizontal space of S or G\n *\n * ### Algorithm Steps:\n *\n * 1. **Calculate width per duration unit**: For each atom, compute the visual width\n * needed per unit of duration: `(visualWidth + spacing) / duration`\n *\n * 2. **Find maximum**: Take the maximum width-per-duration across all atoms.\n * This ensures every atom has enough space for its visual content.\n *\n * 3. **Scale by total duration**: Multiply the max width-per-duration by the\n * group's total duration to get the final group width.\n *\n * ### Example:\n * ```\n * Atoms: S(dur=1, width=10px), R(dur=2, width=10px), G(dur=1, width=10px)\n * Spacing: 5px\n *\n * Width per duration:\n * S: (10 + 5) / 1 = 15 px/unit\n * R: (10 + 5) / 2 = 7.5 px/unit\n * G: (10 + 5) / 1 = 15 px/unit\n *\n * Max width per duration: 15 px/unit\n * Total duration: 1 + 2 + 1 = 4 units\n * Group width: 15 * 4 = 60px\n *\n * Positioning:\n * S at x=0 (time 0/4 * 60 = 0)\n * R at x=15 (time 1/4 * 60 = 15)\n * G at x=45 (time 3/4 * 60 = 45)\n * ```\n *\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n let maxHeight = 0;\n\n // Step 1: Calculate width per duration unit for each atom\n let minWidthPerDuration = 0;\n this.atomViews.forEach((av) => {\n const ms = av.minSize;\n const dur = av.totalDuration;\n if (!dur.isZero) {\n const durValue = dur.num / dur.den;\n const widthPerDur = (ms.width + this.atomSpacing) / durValue;\n // Step 2: Track maximum width per duration\n minWidthPerDuration = Math.max(minWidthPerDuration, widthPerDur);\n }\n maxHeight = Math.max(maxHeight, ms.height);\n });\n\n // Step 3: Scale by total duration\n const totalDuration = this.group.totalChildDuration;\n const totalDurValue = totalDuration.num / totalDuration.den;\n const totalWidth = minWidthPerDuration * totalDurValue;\n\n return new TSU.Geom.Size(totalWidth * this.scaleFactor, maxHeight * this.scaleFactor);\n }\n\n /**\n * Creates an atom view for a specific atom.\n * @param atom The atom to create a view for\n * @returns The created atom view\n */\n abstract createAtomView(atom: Atom): AtomView;\n\n /**\n * Updates the bounds of this group.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\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 /**\n * Refreshes the layout of this group using collision-based positioning.\n *\n * ## Collision-Based Layout Algorithm\n *\n * Atoms are positioned using time-based positioning with collision avoidance.\n * Each atom starts at its ideal time-based position, but is pushed right if\n * it would overlap with the previous atom (including embellishments).\n *\n * ### Algorithm:\n * ```\n * 1. Calculate ideal glyph position: glyphX = (time / totalDuration) * groupWidth\n * 2. Pre-embellishments extend left: realX = glyphX - preEmbellishmentWidth\n * 3. Collision check: if (realX < prevNoteEndX) realX = prevNoteEndX\n * 4. Position the atom at realX\n * 5. Track: prevNoteEndX = realX + atom.minSize.width\n * ```\n *\n * ### Width Source Priority:\n *\n * 1. **Column width** (preferred): If width was set via `setBounds()` from the\n * grid layout system (ColAlign), use that width. This enables global alignment\n * across all beats in the same column.\n *\n * 2. **Minimum size**: Fall back to `minSize.width` calculated by `refreshMinSize()`.\n *\n * ### Continuation Markers:\n *\n * When `showContinuationMarkers` is true (default), atoms with duration > 1\n * will have \",\" markers rendered at each additional time slot. For example,\n * an atom with duration 2 will show \"R ,\" instead of \"R \".\n *\n * ### Example (no collisions):\n * ```\n * Input: S R G M (equal duration, no embellishments)\n * Group width: 60px, Total duration: 4 units\n *\n * Positioning:\n * S at x=0 (time 0/4 * 60 = 0)\n * R at x=15 (time 1/4 * 60 = 15)\n * G at x=30 (time 2/4 * 60 = 30)\n * M at x=45 (time 3/4 * 60 = 45)\n * ```\n *\n * ### Example (with collision):\n * ```\n * Input: [Jaaru+S] R (S has 10px pre-embellishment, each atom 15px wide)\n * Group width: 60px, Total duration: 2 units\n *\n * Without collision avoidance:\n * S.glyphX = 0, S.realX = 0 - 10 = -10 (clamped to 0)\n * R.glyphX = 30, R overlaps with S\n *\n * With collision avoidance:\n * S at x=0 (prevNoteEndX becomes 15)\n * R.glyphX = 30, R.realX = 30 - 0 = 30\n * 30 >= 15, no collision, R at x=30\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\n const currY = 0;\n const totalDur = this.group.totalChildDuration;\n\n // Width source priority: column width (for global alignment) > minSize\n const unscaledMinWidth = this.minSize.width / this.scaleFactor;\n const groupWidth = this.hasWidth ? this.width / this.scaleFactor : unscaledMinWidth;\n\n // Clear existing continuation markers before re-rendering\n this.clearContinuationMarkers();\n\n // Position each atom using collision-based layout\n // Atoms start at their time-based position, but are pushed right if they would\n // overlap with the previous atom (including embellishments)\n let currTime = ZERO;\n let prevNoteEndX = 0;\n this.atomViews.forEach((av, index) => {\n // 1. Calculate ideal glyph position based on time offset\n const glyphX = totalDur.isZero ? 0 : currTime.timesNum(groupWidth).divby(totalDur).floor;\n\n // 2. Pre-embellishments extend left from glyph position\n // realX is where the atom origin should be placed\n let realX = glyphX - av.glyphOffset;\n\n // 3. Collision check: push right if overlapping previous atom\n if (realX < prevNoteEndX) {\n realX = prevNoteEndX;\n }\n\n // 4. Position the atom\n av.setBounds(realX, currY, null, null, true);\n\n // 5. Track end position for next collision check\n prevNoteEndX = realX + av.minSize.width;\n\n // Render continuation markers for atoms with duration > 1\n if (this.showContinuationMarkers && !totalDur.isZero) {\n const atomDur = av.totalDuration;\n const durValue = atomDur.num / atomDur.den;\n if (durValue > 1) {\n // Render one marker at each additional time slot within the atom's duration\n const numMarkers = Math.floor(durValue) - 1;\n for (let i = 1; i <= numMarkers; i++) {\n // Marker time = currTime + (atomDuration * i / floor(duration))\n const markerTime = currTime.plus(atomDur.timesNum(i).divbyNum(Math.floor(durValue)));\n const markerX = markerTime.timesNum(groupWidth).divby(totalDur).floor;\n this.renderContinuationMarker(markerX, currY);\n }\n }\n }\n\n currTime = currTime.plus(av.totalDuration);\n });\n\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n /**\n * Clears all continuation marker elements.\n */\n protected clearContinuationMarkers(): void {\n for (const el of this.continuationMarkerElements) {\n el.remove();\n }\n this.continuationMarkerElements = [];\n }\n\n /**\n * Renders a continuation marker (\",\") at the specified position.\n * @param x X position for the marker\n * @param y Y position for the marker\n */\n protected renderContinuationMarker(x: number, y: number): void {\n const marker = TSU.DOM.createSVGNode(\"text\", {\n parent: this.groupElement,\n attrs: {\n class: \"continuationMarker\",\n x: x.toString(),\n y: y.toString(),\n },\n text: \",\",\n }) as SVGTextElement;\n this.continuationMarkerElements.push(marker);\n }\n\n /**\n * Gets the embellishments for this group.\n */\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n /**\n * Creates the embellishments for this group.\n * @returns An array of embellishments\n */\n protected createEmbelishments(): Embelishment[] {\n return [];\n }\n\n /**\n * Sets the styles for this group.\n * @param config Style configuration object\n */\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n if (\"showContinuationMarkers\" in config) this.showContinuationMarkers = config.showContinuationMarkers;\n this.needsLayout = true;\n }\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import SideBySideEditor, { SideBySideEditorConfig } from "./SideBySideEditor";
|
|
2
|
+
import { Notation } from "../../notation";
|
|
3
|
+
import { GlobalBeatLayout } from "../../beats";
|
|
4
|
+
export interface DockViewPlaygroundConfig {
|
|
5
|
+
initialSource?: string;
|
|
6
|
+
showConsole?: boolean;
|
|
7
|
+
persistLayout?: boolean;
|
|
8
|
+
storageKey?: string;
|
|
9
|
+
layoutVersion?: number;
|
|
10
|
+
syncScroll?: boolean;
|
|
11
|
+
markdownParser?: (content: string) => string;
|
|
12
|
+
editorConfig?: Partial<SideBySideEditorConfig>;
|
|
13
|
+
onSourceChange?: (source: string) => void;
|
|
14
|
+
onNotationParsed?: (notation: Notation, beatLayout: GlobalBeatLayout) => void;
|
|
15
|
+
onParseError?: (errors: any[]) => void;
|
|
16
|
+
isDarkMode?: () => boolean;
|
|
17
|
+
editorClass?: string;
|
|
18
|
+
outputClass?: string;
|
|
19
|
+
}
|
|
20
|
+
export default class DockViewPlayground {
|
|
21
|
+
readonly container: HTMLElement;
|
|
22
|
+
readonly config: DockViewPlaygroundConfig;
|
|
23
|
+
private dockview;
|
|
24
|
+
private sideBySideEditor;
|
|
25
|
+
private consoleOutput;
|
|
26
|
+
private consoleEntries;
|
|
27
|
+
constructor(container: HTMLElement, config?: DockViewPlaygroundConfig);
|
|
28
|
+
get editor(): SideBySideEditor | null;
|
|
29
|
+
get source(): string;
|
|
30
|
+
set source(value: string);
|
|
31
|
+
log(message: string, level?: "info" | "error" | "warning"): void;
|
|
32
|
+
clearConsole(): void;
|
|
33
|
+
render(): boolean;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
resetLayout(): void;
|
|
36
|
+
private _consoleVisible;
|
|
37
|
+
isConsoleVisible(): boolean;
|
|
38
|
+
showConsole(): void;
|
|
39
|
+
hideConsole(): void;
|
|
40
|
+
toggleConsole(): boolean;
|
|
41
|
+
private init;
|
|
42
|
+
private isDarkMode;
|
|
43
|
+
private saveLayout;
|
|
44
|
+
private loadLayout;
|
|
45
|
+
private createComponent;
|
|
46
|
+
private createDefaultLayout;
|
|
47
|
+
private createEditorPanel;
|
|
48
|
+
private createOutputPanel;
|
|
49
|
+
private createConsolePanel;
|
|
50
|
+
private renderConsoleEntry;
|
|
51
|
+
}
|