notations 1.0.4 → 1.0.7
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/NotationView.css +15 -0
- package/dist/NotationView.css.map +1 -1
- package/dist/NotationView.min.css +1 -1
- package/dist/NotationView.min.css.map +1 -1
- package/dist/notations.umd.js +469 -108
- package/dist/notations.umd.min.js +2 -2
- package/dist/notations.umd.min.js.map +1 -1
- package/lib/cjs/beats.js +1 -1
- package/lib/cjs/beats.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/carnatic/NotationView.d.ts +1 -0
- package/lib/cjs/carnatic/NotationView.js +10 -0
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/atomviews.d.ts +4 -1
- package/lib/cjs/carnatic/atomviews.js +18 -2
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.d.ts +18 -1
- package/lib/cjs/carnatic/embelishments.js +87 -1
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/core.d.ts +18 -3
- package/lib/cjs/core.js +161 -21
- 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/shapes.d.ts +13 -1
- package/lib/cjs/shapes.js +35 -7
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/esm/beats.js +1 -1
- package/lib/esm/beats.js.map +1 -1
- 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/carnatic/NotationView.d.ts +1 -0
- package/lib/esm/carnatic/NotationView.js +10 -0
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/carnatic/atomviews.d.ts +4 -1
- package/lib/esm/carnatic/atomviews.js +19 -3
- package/lib/esm/carnatic/atomviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.d.ts +18 -1
- package/lib/esm/carnatic/embelishments.js +85 -0
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/core.d.ts +18 -3
- package/lib/esm/core.js +161 -21
- 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/shapes.d.ts +13 -1
- package/lib/esm/shapes.js +34 -7
- package/lib/esm/shapes.js.map +1 -1
- package/package.json +3 -1
- package/styles/NotationView.scss +15 -0
package/lib/esm/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAO/C,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAOxC,MAAM,CAAN,IAAY,QASX;AATD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,+BAAmB,CAAA;IACnB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;IACf,2BAAe,CAA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,IAAI,CAAC,CAAC;YACxB,CAAC;YACD,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAMD,MAAM,CAAC,OAAa;QAClB,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAKD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\nimport { LayoutParams } from \"./layouts\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nexport const ZERO = TSU.Num.Fraction.ZERO;\nexport const ONE = TSU.Num.Fraction.ONE;\n\n/**\n * AtomType enums are used to denote specific Atoms\n * Each type represents a specific musical or notational element.\n * @enum\n */\nexport enum AtomType {\n NOTE = \"Note\",\n LITERAL = \"Literal\",\n SYLLABLE = \"Syllable\",\n SPACE = \"Space\",\n GROUP = \"Group\",\n LABEL = \"Label\",\n REST = \"Rest\",\n MARKER = \"Marker\",\n}\n\n/**\n * Atoms are the base class for all timed entities that can appear in a Notation.\n * An Atom represents the fundamental building block of the notation system.\n */\nexport abstract class Atom extends TimedEntity {\n readonly TYPE: string = \"Atom\";\n\n protected _duration: Fraction;\n /** Markers to be displayed before this atom */\n markersBefore: Marker[];\n /** Markers to be displayed after this atom */\n markersAfter: Marker[];\n /** Next atom in the sequence */\n nextSibling: TSU.Nullable<Atom> = null;\n /** Previous atom in the sequence */\n prevSibling: TSU.Nullable<Atom> = null;\n /** The Group this Atom belongs to, if any */\n parentGroup: TSU.Nullable<Group> = null;\n\n /** Indicates if this Atom is a continuation from a previous atom */\n isContinuation = false;\n\n /**\n * Creates a new Atom with the specified duration.\n * @param duration The duration of the atom, defaults to ONE (1/1)\n */\n constructor(duration = ONE) {\n super();\n this._duration = duration || ONE;\n }\n\n /**\n * Splits this atom at the specified duration.\n * @param requiredDuration The duration at which to split the atom\n * @returns A new atom representing the portion beyond the split point, or null if no split is needed\n */\n abstract splitAt(requiredDuration: Fraction): TSU.Nullable<Atom>;\n\n /**\n * Returns a debug-friendly representation of this Atom.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = super.debugValue();\n if (!this.duration.isOne) {\n out.duration = this.duration.factorized.toString();\n }\n if (this.isContinuation) {\n out.isContinuation = true;\n }\n if ((this.markersBefore || []).length > 0) {\n out.mbef = this.markersBefore.map((m) => m.debugValue());\n }\n if ((this.markersAfter || []).length > 0) {\n out.maft = this.markersAfter.map((m) => m.debugValue());\n }\n return out;\n }\n\n /**\n * Copies the properties of this atom to another atom.\n * @param another The target atom to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another._duration = new TSU.Num.Fraction(this.duration.num, this.duration.den);\n }\n\n /**\n * Gets the duration of this atom.\n */\n get duration(): Fraction {\n return this._duration;\n }\n\n /**\n * Sets the duration of this atom.\n */\n set duration(d: Fraction) {\n this._duration = d;\n }\n}\n\n/**\n * Base class for atoms that cannot contain other atoms.\n * LeafAtom represents atomic elements that can't be further subdivided.\n */\nexport abstract class LeafAtom extends Atom {\n readonly TYPE: string = \"LeafAtom\";\n\n /** Indicates if this atom is followed by a rest */\n beforeRest = false;\n\n /**\n * Splits this atom at a certain duration.\n * If this atom's duration is longer than the given duration, it's truncated\n * to the given duration and a continuation space is returned.\n *\n * @param duration The duration at which to split the atom\n * @returns A new Space atom representing the spillover if needed, otherwise null\n */\n splitAt(duration: Fraction): TSU.Nullable<Atom> {\n if (this.duration.cmp(duration) > 0) {\n const spillOver = this.createSpilloverSpace(this.duration.minus(duration));\n spillOver.isContinuation = true;\n this.duration = duration;\n // TODO - Here we need to move the markersAfter to the spill-over as it doesnt belong to this any more\n return spillOver;\n }\n return null;\n }\n\n /**\n * Creates a Space atom to represent spillover duration when splitting.\n * @param duration The duration of the spillover\n * @returns A new Space atom\n */\n protected createSpilloverSpace(duration: Fraction): Space {\n return new Space(duration);\n }\n\n /**\n * Returns a debug-friendly representation of this LeafAtom.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return this.beforeRest ? { ...super.debugValue(), beforeRest: true } : super.debugValue();\n }\n}\n\n/**\n * Represents a marker or annotation in the notation.\n * Markers can be placed before or after atoms to provide additional context.\n */\nexport class Marker extends Entity {\n readonly TYPE = \"Marker\";\n\n /**\n * Creates a new Marker with the specified text.\n * @param text The text content of the marker\n * @param isBefore Whether the marker should appear before (true) or after (false) its associated atom\n */\n constructor(\n public text: string,\n public isBefore = true,\n ) {\n super();\n }\n\n /**\n * Returns a debug-friendly representation of this Marker.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { ...super.debugValue(), text: this.text, before: this.isBefore };\n }\n\n /**\n * Returns a string representation of this Marker.\n * @returns A string representation\n */\n toString(): string {\n return `Marker(${this.text}-${this.isBefore})`;\n }\n}\n\n/**\n * Represents a rest (silence) in the notation.\n * Rests are zero-length atoms that indicate a pause.\n */\nexport class Rest extends LeafAtom {\n readonly TYPE = \"Rest\";\n\n /**\n * Creates a new Rest.\n * Rests are zero length by default.\n */\n constructor() {\n super(ZERO);\n }\n}\n\n/**\n * Represents a space or silence in the notation.\n * Spaces can be used to denote either silence or continuations of previous notes.\n */\nexport class Space extends LeafAtom {\n readonly TYPE = \"Space\";\n\n /**\n * Indicates whether this is a silent space or a continuation of the previous note.\n */\n isSilent = false;\n\n /**\n * Creates a new Space with the specified duration and silence property.\n * @param duration The duration of the space, defaults to ONE (1/1)\n * @param isSilent Whether the space represents silence (true) or a continuation (false)\n */\n constructor(duration = ONE, isSilent = false) {\n super(duration);\n this.isSilent = isSilent;\n }\n\n /**\n * Returns a debug-friendly representation of this Space.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { ...super.debugValue(), isSilent: this.isSilent };\n }\n\n /**\n * Returns a string representation of this Space.\n * @returns A string representation\n */\n toString(): string {\n return `Space(${this.duration}-${this.isSilent})`;\n }\n\n /**\n * Copies the properties of this Space to another Space.\n * @param another The target Space to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.isSilent = this.isSilent;\n }\n\n /**\n * Checks if this Space is equal to another Space.\n * @param another The Space to compare with\n * @returns True if the Spaces are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.isSilent == another.isSilent;\n }\n\n /**\n * Creates a Space atom to represent spillover duration when splitting.\n * @param duration The duration of the spillover\n * @returns A new Space atom with the same silence property as this Space\n */\n protected createSpilloverSpace(duration: Fraction): Space {\n const out = super.createSpilloverSpace(duration);\n out.isSilent = this.isSilent;\n return out;\n }\n}\n\n/**\n * Represents a literal value in the notation.\n * Literals are the basic building blocks for notes and syllables.\n */\nexport class Literal extends LeafAtom {\n readonly TYPE: string = \"Literal\";\n\n /**\n * The embellishments applied to this Literal.\n */\n embelishments: any[] = [];\n\n /**\n * Creates a new Literal with the specified value and duration.\n * @param value The string value of the literal\n * @param duration The duration of the literal, defaults to ONE (1/1)\n */\n constructor(\n public value: string,\n duration = ONE,\n ) {\n super(duration);\n }\n\n /**\n * Returns a debug-friendly representation of this Literal.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = { ...super.debugValue(), value: this.value };\n if (this.embelishments.length > 0) {\n out.embs = this.embelishments.map((e) => (\"debugValue\" in e ? e.debugValue() : e));\n }\n return out;\n }\n\n /**\n * Returns a string representation of this Literal.\n * @returns A string representation\n */\n toString(): string {\n return `Lit(${this.duration}-${this.value})`;\n }\n\n /**\n * Checks if this Literal is equal to another Literal.\n * @param another The Literal to compare with\n * @returns True if the Literals are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.value == another.value;\n }\n\n /**\n * Copies the properties of this Literal to another Literal.\n * @param another The target Literal to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.value = this.value;\n }\n}\n\n/**\n * Represents a syllable in lyrics or text to be sung.\n * Extends Literal to provide specialized handling for sung text.\n */\nexport class Syllable extends Literal {\n readonly TYPE = \"Syllable\";\n\n /**\n * Creates a Syllable from a Literal.\n * @param lit The Literal to convert to a Syllable\n * @returns A new Syllable with the properties of the Literal\n */\n static fromLit(lit: Literal): Syllable {\n if (lit.TYPE == AtomType.SYLLABLE) return lit as Syllable;\n const out = new Syllable(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n out.beforeRest = lit.beforeRest;\n return out;\n }\n\n /**\n * Returns a string representation of this Syllable.\n * @returns A string representation\n */\n toString(): string {\n return `Syll(${this.duration}-${this.value})`;\n }\n}\n\n/**\n * Represents a musical note in the notation.\n * Extends Literal to add properties specific to musical notes.\n */\nexport class Note extends Literal {\n readonly TYPE = \"Note\";\n\n /**\n * Which octave the note is in. Can be positive or negative to indicate higher or lower octaves.\n */\n octave = 0;\n\n /**\n * How the note is shifted - i.e., shifted towards major or minor by # of semi-tones.\n */\n shift: number | boolean = 0;\n\n /**\n * Creates a new Note with the specified properties.\n * @param value The string value of the note\n * @param duration The duration of the note, defaults to ONE (1/1)\n * @param octave The octave of the note, defaults to 0\n * @param shift The shift of the note, defaults to 0\n */\n constructor(value: string, duration = ONE, octave = 0, shift = 0) {\n super(value, duration);\n this.octave = octave;\n this.shift = shift;\n }\n\n /**\n * Creates a Note from a Literal.\n * @param lit The Literal to convert to a Note\n * @returns A new Note with the properties of the Literal\n */\n static fromLit(lit: Literal): Note {\n if (lit.TYPE == AtomType.NOTE) return lit as Note;\n const out = new Note(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n out.beforeRest = lit.beforeRest;\n return out;\n }\n\n /**\n * Returns a debug-friendly representation of this Note.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = { ...super.debugValue() };\n if (this.octave != 0) out.octave = this.octave;\n if (this.shift != 0) out.shift = this.shift;\n return out;\n }\n\n /**\n * Returns a string representation of this Note.\n * @returns A string representation\n */\n toString(): string {\n return `Note(${this.duration}-${this.value}-${this.octave})`;\n }\n\n /**\n * Checks if this Note is equal to another Note.\n * @param another The Note to compare with\n * @returns True if the Notes are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.octave == another.octave && this.shift == another.shift;\n }\n\n /**\n * Copies the properties of this Note to another Note.\n * @param another The target Note to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.octave = this.octave;\n another.shift = this.shift;\n }\n}\n\n/**\n * Represents a group of atoms that are treated as a single unit.\n * Groups can contain any number of atoms, including other groups.\n */\nexport class Group extends Atom {\n readonly TYPE = \"Group\";\n\n /**\n * Indicates whether the duration is static or linear to the number of atoms in this group.\n * When true, the duration is used as a multiplier for the total child duration.\n * When false, the duration is absolute.\n */\n durationIsMultiplier = false;\n\n /**\n * The list of atoms in this group.\n */\n readonly atoms = new TSU.Lists.ValueList<Atom>();\n\n /**\n * Creates a new Group containing the specified atoms.\n * @param atoms The atoms to include in this group\n */\n constructor(...atoms: Atom[]) {\n super(atoms.length == 0 ? ZERO : ONE);\n this.addAtoms(false, ...atoms);\n }\n\n /**\n * Checks if this Group is equal to another Group.\n * @param another The Group to compare with\n * @param expect Optional parameter\n * @returns True if the Groups are equal, false otherwise\n */\n equals(another: this, expect = false): boolean {\n if (!super.equals(another)) return false;\n return this.atoms.equals(another.atoms, (a1, a2) => a1.equals(a2));\n }\n\n /**\n * Copies the properties of this Group to another Group.\n * @param another The target Group to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.durationIsMultiplier = this.durationIsMultiplier;\n this.atoms.forEach((atom) => another.atoms.add(atom.clone()));\n }\n\n /**\n * Gets the duration of this group.\n * If durationIsMultiplier is true, returns the total child duration divided by the multiplier.\n * Otherwise, returns the absolute duration.\n */\n get duration(): Fraction {\n if (this.durationIsMultiplier) {\n return this.totalChildDuration.divby(this._duration);\n } else {\n return this._duration;\n }\n }\n\n /**\n * Sets this group to use a multiplier for duration calculations.\n * @param asMultiplier Whether to use the duration as a multiplier\n * @returns This Group instance for method chaining\n */\n setDurationAsMultiplier(asMultiplier = true): this {\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n\n /**\n * Sets the duration of this group.\n * @param d The new duration\n * @param asMultiplier Whether to use the duration as a multiplier\n * @returns This Group instance for method chaining\n */\n setDuration(d: Fraction, asMultiplier = false): this {\n this._duration = d;\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n\n /**\n * Returns a debug-friendly representation of this Group.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = { ...super.debugValue(), atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) };\n if (this.durationIsMultiplier) out.durationIsMultiplier = true;\n return out;\n }\n\n /**\n * Splits this group into two parts.\n * The first part (this group) fits within the given duration and everything else\n * longer than the given duration is returned as a new Group.\n *\n * @param requiredDuration The duration at which to split the group\n * @returns A new Group containing the atoms beyond the split point, or null if no split is needed\n */\n splitAt(requiredDuration: Fraction): TSU.Nullable<Group> {\n if (this.duration.isLTE(requiredDuration) || requiredDuration.isLTE(ZERO)) {\n return null;\n }\n const targetGroup = new Group();\n if (this.durationIsMultiplier) {\n targetGroup.durationIsMultiplier = true;\n targetGroup._duration = this._duration;\n }\n\n let remainingDur = this.duration;\n const totalChildDuration = this.totalChildDuration;\n const durationFactor = this.durationIsMultiplier\n ? ONE.divby(this._duration)\n : this._duration.divby(totalChildDuration, true);\n while (remainingDur.isGT(requiredDuration) && this.atoms.last) {\n const lastChild = this.atoms.last;\n // Child's duration is absolute in its own \"system\"\n // Its duration within the parent (this) group's frame of reference depends\n // on whether the parent's duration is absolute or as a multiplier\n //\n // realChildDuration = case (group.durationIsMultiper) {\n // | true => child.duration / this._duration\n // | false => child.duration * this._duration / total child duration\n // }\n const childDuration = lastChild.duration.times(durationFactor);\n const newDuration = remainingDur.minus(childDuration);\n if (newDuration.isGTE(requiredDuration)) {\n // remove ourselves and add to target\n // in both cases duration will be adjusted if need be\n this.removeAtoms(true, lastChild);\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, lastChild);\n if (newDuration.equals(requiredDuration)) {\n // we have reached the end so return\n return targetGroup;\n }\n } else {\n // our scenario is now this:\n //\n // totalParentDuration = 10\n // required = 8\n // lastChildDuration (relative to parent) is 5\n //\n // durWithoutLast = 10 - 5\n // newRequired = requiredDur - durWithoutLast = 3\n //\n // However 3 is a duration in the parent's frame of reference\n // this has to be converted back to the child's FoR\n const newRequiredDur = requiredDuration.minus(newDuration, true).divby(durationFactor, true);\n // console.log( \"newRequiredDur: \", newRequiredDur, \"requiedDur: \", requiredDuration, \"remainingDur: \", remainingDur,);\n // then the last item needs to be split, and by how much?\n const spillOver = lastChild.splitAt(newRequiredDur);\n if (spillOver == null) {\n throw new Error(\"Spill over cannot be null here\");\n }\n if (!this.durationIsMultiplier) {\n // Our own duration has also now changed\n this._duration = requiredDuration;\n } else {\n if (this._duration.isZero) throw new Error(\"How can this be?\");\n }\n spillOver.isContinuation = true;\n // Add spill over to the target\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, spillOver);\n return targetGroup;\n }\n remainingDur = newDuration;\n }\n return targetGroup;\n }\n\n /**\n * Gets the total duration of all child atoms.\n * @returns The sum of durations of all atoms in this group\n */\n get totalChildDuration(): Fraction {\n let out = ZERO;\n this.atoms.forEach((atom) => (out = out.plus(atom.duration)));\n return out;\n }\n\n /**\n * Inserts atoms before a given cursor atom.\n * If the cursor atom is null, the atoms are appended at the end.\n *\n * @param beforeAtom The atom before which to insert the new atoms, or null to append\n * @param adjustDuration Whether to adjust this group's duration based on the new atoms\n * @param atoms The atoms to insert\n * @returns This Group instance for method chaining\n */\n insertAtomsAt(beforeAtom: TSU.Nullable<Atom>, adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n // First form a chain of the given atoms\n for (const atom of atoms) {\n if (atom.parentGroup != null) {\n if (atom.parentGroup != this) {\n throw new Error(\"Atom belongs to another parent. Remove it first\");\n }\n atom.parentGroup.removeAtoms(false, atom);\n }\n if (atom.TYPE == AtomType.REST) {\n const last = this.atoms.last;\n if (last && last.TYPE != AtomType.GROUP && last.TYPE != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n atom.parentGroup = this;\n this.atoms.add(atom, beforeAtom);\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n return this;\n }\n\n /**\n * Adds atoms to the end of this group's atom list.\n *\n * @param adjustDuration Whether to adjust this group's duration based on the new atoms\n * @param atoms The atoms to add\n * @returns This Group instance for method chaining\n */\n addAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n return this.insertAtomsAt(null, adjustDuration, ...atoms);\n }\n\n /**\n * Removes atoms from this group's child list.\n *\n * @param adjustDuration Whether to adjust this group's duration after removing atoms\n * @param atoms The atoms to remove\n * @returns This Group instance for method chaining\n */\n removeAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n for (const atom of atoms) {\n if (atom.parentGroup == this) {\n this.atoms.remove(atom);\n atom.parentGroup = null;\n } else if (atom.parentGroup != null) {\n throw new Error(\"Atom cannot be removed as it does not belong to this group\");\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n return this;\n }\n}\n\n/**\n * Represents a line of notation containing multiple roles.\n * A line can have atoms starting before or after the cycle.\n */\nexport class Line extends Entity {\n readonly TYPE: string = \"Line\";\n\n /**\n * Offset tells how many notes before or after the cycle this line's atoms start at.\n */\n offset: Fraction = ZERO;\n\n /**\n * The roles contained in this line.\n */\n roles: Role[] = [];\n\n /**\n * Text to be displayed in the margin of the line.\n * This is a hacky solution to doing left side pre-margin text typically\n * found in notations - e.g., line X of a pallavi has this. This makes vertical\n * space less wasteful.\n *\n * A better solution is inter-beat annotation but it is very complex for now.\n */\n marginText = \"\";\n\n /**\n * The LayoutParams associated with this line.\n */\n layoutParams: LayoutParams;\n\n /**\n * Finds the index of a role with the given name.\n * @param name The name of the role to find\n * @returns The index of the role, or -1 if not found\n */\n indexOfRole(name: string): number {\n for (let i = 0; i < this.roles.length; i++) {\n if (this.roles[i].name == name) return i;\n }\n return -1;\n }\n\n /**\n * Checks if this line is empty (has no content in any role).\n */\n get isEmpty(): boolean {\n for (const r of this.roles) if (!r.isEmpty) return false;\n return true;\n }\n\n /**\n * Returns a debug-friendly representation of this Line.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = {\n ...super.debugValue(),\n roles: this.roles.map((r) => r.debugValue()),\n };\n if (!this.offset.isZero) {\n out.offset = this.offset.toString();\n }\n return out;\n }\n\n /**\n * Copies the properties of this Line to another Line.\n * @param another The target Line to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.roles = this.roles.map((r) => r.clone());\n }\n\n /**\n * Adds atoms to a role in this line.\n * @param roleName The name of the role to add atoms to\n * @param defaultToNotes Whether to default to notes for this role\n * @param atoms The atoms to add\n * @returns This Line instance for method chaining\n */\n addAtoms(roleName: string, defaultToNotes: boolean, ...atoms: Atom[]): this {\n const role = this.ensureRole(roleName, defaultToNotes);\n role.addAtoms(...atoms);\n return this;\n }\n\n /**\n * Ensures a role with the given name exists in this line, creating it if needed.\n * @param roleName The name of the role to ensure\n * @param defaultToNotes Whether to default to notes for this role\n * @returns The role with the specified name\n */\n ensureRole(roleName: string, defaultToNotes: boolean): Role {\n // Ensure we have this many roles\n let ri = this.roles.findIndex((r) => r.name == roleName);\n if (ri < 0) {\n ri = this.roles.length;\n const role = new Role(this, roleName);\n role.defaultToNotes = defaultToNotes;\n this.roles.push(role);\n }\n return this.roles[ri];\n }\n\n /**\n * Gets the maximum duration across all roles in this line.\n */\n get duration(): Fraction {\n let max = ZERO;\n for (const role of this.roles) {\n max = TSU.Num.Fraction.max(role.duration, max);\n }\n return max;\n }\n}\n\n/**\n * Represents a specific role or voice in a line of notation.\n * Each role contains a sequence of atoms.\n */\nexport class Role extends Entity {\n readonly TYPE = \"Role\";\n\n /**\n * Whether this role represents notes by default.\n */\n defaultToNotes = true;\n\n /**\n * The atoms in this role.\n */\n atoms: Atom[] = [];\n\n /**\n * Creates a new Role with the specified line and name.\n * @param line The line this role belongs to\n * @param name The name of the role\n */\n constructor(\n public readonly line: Line,\n public readonly name: string,\n ) {\n super();\n }\n\n /**\n * Checks if this role is empty (has no atoms).\n */\n get isEmpty(): boolean {\n return this.atoms.length == 0;\n }\n\n /**\n * Returns a debug-friendly representation of this Role.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { name: this.name, atoms: this.atoms.map((a) => a.debugValue()) };\n }\n\n /**\n * Adds atoms to this role.\n * @param atoms The atoms to add\n */\n addAtoms(...atoms: Atom[]): void {\n let last: null | Atom = null;\n for (const atom of atoms) {\n if (atom.TYPE == AtomType.REST) {\n if (last && last.TYPE != AtomType.GROUP && last.TYPE != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n this.atoms.push(atom);\n }\n last = atom;\n }\n }\n\n /**\n * Copies the properties of this Role to another Role.\n * @param another The target Role to copy properties to\n */\n copyTo(another: Role): void {\n another.addAtoms(...this.atoms);\n }\n\n /**\n * Gets the total duration of all atoms in this role.\n */\n get duration(): Fraction {\n return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC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AC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\nimport { LayoutParams } from \"./layouts\";\nimport { AtomChangeType, GroupObserver, RoleObserver, LineObserver } from \"./events\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nexport const ZERO = TSU.Num.Fraction.ZERO;\nexport const ONE = TSU.Num.Fraction.ONE;\n\n/**\n * AtomType enums are used to denote specific Atoms\n * Each type represents a specific musical or notational element.\n * @enum\n */\nexport enum AtomType {\n NOTE = \"Note\",\n LITERAL = \"Literal\",\n SYLLABLE = \"Syllable\",\n SPACE = \"Space\",\n GROUP = \"Group\",\n LABEL = \"Label\",\n REST = \"Rest\",\n MARKER = \"Marker\",\n}\n\n/**\n * Atoms are the base class for all timed entities that can appear in a Notation.\n * An Atom represents the fundamental building block of the notation system.\n */\nexport abstract class Atom extends TimedEntity {\n readonly TYPE: string = \"Atom\";\n\n protected _duration: Fraction;\n /** Markers to be displayed before this atom */\n markersBefore: Marker[];\n /** Markers to be displayed after this atom */\n markersAfter: Marker[];\n /** Next atom in the sequence */\n nextSibling: TSU.Nullable<Atom> = null;\n /** Previous atom in the sequence */\n prevSibling: TSU.Nullable<Atom> = null;\n /** The Group this Atom belongs to, if any */\n parentGroup: TSU.Nullable<Group> = null;\n\n /** Indicates if this Atom is a continuation from a previous atom */\n isContinuation = false;\n\n /**\n * Creates a new Atom with the specified duration.\n * @param duration The duration of the atom, defaults to ONE (1/1)\n */\n constructor(duration = ONE) {\n super();\n this._duration = duration || ONE;\n }\n\n /**\n * Splits this atom at the specified duration.\n * @param requiredDuration The duration at which to split the atom\n * @returns A new atom representing the portion beyond the split point, or null if no split is needed\n */\n abstract splitAt(requiredDuration: Fraction): TSU.Nullable<Atom>;\n\n /**\n * Returns a debug-friendly representation of this Atom.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = super.debugValue();\n if (!this.duration.isOne) {\n out.duration = this.duration.factorized.toString();\n }\n if (this.isContinuation) {\n out.isContinuation = true;\n }\n if ((this.markersBefore || []).length > 0) {\n out.mbef = this.markersBefore.map((m) => m.debugValue());\n }\n if ((this.markersAfter || []).length > 0) {\n out.maft = this.markersAfter.map((m) => m.debugValue());\n }\n return out;\n }\n\n /**\n * Copies the properties of this atom to another atom.\n * @param another The target atom to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another._duration = new TSU.Num.Fraction(this.duration.num, this.duration.den);\n }\n\n /**\n * Gets the duration of this atom.\n */\n get duration(): Fraction {\n return this._duration;\n }\n\n /**\n * Sets the duration of this atom.\n */\n set duration(d: Fraction) {\n this._duration = d;\n }\n}\n\n/**\n * Base class for atoms that cannot contain other atoms.\n * LeafAtom represents atomic elements that can't be further subdivided.\n */\nexport abstract class LeafAtom extends Atom {\n readonly TYPE: string = \"LeafAtom\";\n\n /** Indicates if this atom is followed by a rest */\n beforeRest = false;\n\n /**\n * Splits this atom at a certain duration.\n * If this atom's duration is longer than the given duration, it's truncated\n * to the given duration and a continuation space is returned.\n *\n * @param duration The duration at which to split the atom\n * @returns A new Space atom representing the spillover if needed, otherwise null\n */\n splitAt(duration: Fraction): TSU.Nullable<Atom> {\n if (this.duration.cmp(duration) > 0) {\n const spillOver = this.createSpilloverSpace(this.duration.minus(duration));\n spillOver.isContinuation = true;\n this.duration = duration;\n // TODO - Here we need to move the markersAfter to the spill-over as it doesnt belong to this any more\n return spillOver;\n }\n return null;\n }\n\n /**\n * Creates a Space atom to represent spillover duration when splitting.\n * @param duration The duration of the spillover\n * @returns A new Space atom\n */\n protected createSpilloverSpace(duration: Fraction): Space {\n return new Space(duration);\n }\n\n /**\n * Returns a debug-friendly representation of this LeafAtom.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return this.beforeRest ? { ...super.debugValue(), beforeRest: true } : super.debugValue();\n }\n}\n\n/**\n * Represents a marker or annotation in the notation.\n * Markers can be placed before or after atoms to provide additional context.\n */\nexport class Marker extends Entity {\n readonly TYPE = \"Marker\";\n\n /**\n * Creates a new Marker with the specified text.\n * @param text The text content of the marker\n * @param isBefore Whether the marker should appear before (true) or after (false) its associated atom\n */\n constructor(\n public text: string,\n public isBefore = true,\n ) {\n super();\n }\n\n /**\n * Returns a debug-friendly representation of this Marker.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { ...super.debugValue(), text: this.text, before: this.isBefore };\n }\n\n /**\n * Returns a string representation of this Marker.\n * @returns A string representation\n */\n toString(): string {\n return `Marker(${this.text}-${this.isBefore})`;\n }\n}\n\n/**\n * Represents a rest (silence) in the notation.\n * Rests are zero-length atoms that indicate a pause.\n */\nexport class Rest extends LeafAtom {\n readonly TYPE = \"Rest\";\n\n /**\n * Creates a new Rest.\n * Rests are zero length by default.\n */\n constructor() {\n super(ZERO);\n }\n}\n\n/**\n * Represents a space or silence in the notation.\n * Spaces can be used to denote either silence or continuations of previous notes.\n */\nexport class Space extends LeafAtom {\n readonly TYPE = \"Space\";\n\n /**\n * Indicates whether this is a silent space or a continuation of the previous note.\n */\n isSilent = false;\n\n /**\n * Creates a new Space with the specified duration and silence property.\n * @param duration The duration of the space, defaults to ONE (1/1)\n * @param isSilent Whether the space represents silence (true) or a continuation (false)\n */\n constructor(duration = ONE, isSilent = false) {\n super(duration);\n this.isSilent = isSilent;\n }\n\n /**\n * Returns a debug-friendly representation of this Space.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { ...super.debugValue(), isSilent: this.isSilent };\n }\n\n /**\n * Returns a string representation of this Space.\n * @returns A string representation\n */\n toString(): string {\n return `Space(${this.duration}-${this.isSilent})`;\n }\n\n /**\n * Copies the properties of this Space to another Space.\n * @param another The target Space to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.isSilent = this.isSilent;\n }\n\n /**\n * Checks if this Space is equal to another Space.\n * @param another The Space to compare with\n * @returns True if the Spaces are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.isSilent == another.isSilent;\n }\n\n /**\n * Creates a Space atom to represent spillover duration when splitting.\n * @param duration The duration of the spillover\n * @returns A new Space atom with the same silence property as this Space\n */\n protected createSpilloverSpace(duration: Fraction): Space {\n const out = super.createSpilloverSpace(duration);\n out.isSilent = this.isSilent;\n return out;\n }\n}\n\n/**\n * Represents a literal value in the notation.\n * Literals are the basic building blocks for notes and syllables.\n */\nexport class Literal extends LeafAtom {\n readonly TYPE: string = \"Literal\";\n\n /**\n * The embellishments applied to this Literal.\n */\n embelishments: any[] = [];\n\n /**\n * Creates a new Literal with the specified value and duration.\n * @param value The string value of the literal\n * @param duration The duration of the literal, defaults to ONE (1/1)\n */\n constructor(\n public value: string,\n duration = ONE,\n ) {\n super(duration);\n }\n\n /**\n * Returns a debug-friendly representation of this Literal.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = { ...super.debugValue(), value: this.value };\n if (this.embelishments.length > 0) {\n out.embs = this.embelishments.map((e) => (\"debugValue\" in e ? e.debugValue() : e));\n }\n return out;\n }\n\n /**\n * Returns a string representation of this Literal.\n * @returns A string representation\n */\n toString(): string {\n return `Lit(${this.duration}-${this.value})`;\n }\n\n /**\n * Checks if this Literal is equal to another Literal.\n * @param another The Literal to compare with\n * @returns True if the Literals are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.value == another.value;\n }\n\n /**\n * Copies the properties of this Literal to another Literal.\n * @param another The target Literal to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.value = this.value;\n }\n}\n\n/**\n * Represents a syllable in lyrics or text to be sung.\n * Extends Literal to provide specialized handling for sung text.\n */\nexport class Syllable extends Literal {\n readonly TYPE = \"Syllable\";\n\n /**\n * Creates a Syllable from a Literal.\n * @param lit The Literal to convert to a Syllable\n * @returns A new Syllable with the properties of the Literal\n */\n static fromLit(lit: Literal): Syllable {\n if (lit.TYPE == AtomType.SYLLABLE) return lit as Syllable;\n const out = new Syllable(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n out.beforeRest = lit.beforeRest;\n return out;\n }\n\n /**\n * Returns a string representation of this Syllable.\n * @returns A string representation\n */\n toString(): string {\n return `Syll(${this.duration}-${this.value})`;\n }\n}\n\n/**\n * Represents a musical note in the notation.\n * Extends Literal to add properties specific to musical notes.\n */\nexport class Note extends Literal {\n readonly TYPE = \"Note\";\n\n /**\n * Which octave the note is in. Can be positive or negative to indicate higher or lower octaves.\n */\n octave = 0;\n\n /**\n * How the note is shifted - i.e., shifted towards major or minor by # of semi-tones.\n */\n shift: number | boolean = 0;\n\n /**\n * Creates a new Note with the specified properties.\n * @param value The string value of the note\n * @param duration The duration of the note, defaults to ONE (1/1)\n * @param octave The octave of the note, defaults to 0\n * @param shift The shift of the note, defaults to 0\n */\n constructor(value: string, duration = ONE, octave = 0, shift = 0) {\n super(value, duration);\n this.octave = octave;\n this.shift = shift;\n }\n\n /**\n * Creates a Note from a Literal.\n * @param lit The Literal to convert to a Note\n * @returns A new Note with the properties of the Literal\n */\n static fromLit(lit: Literal): Note {\n if (lit.TYPE == AtomType.NOTE) return lit as Note;\n const out = new Note(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n out.beforeRest = lit.beforeRest;\n return out;\n }\n\n /**\n * Returns a debug-friendly representation of this Note.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = { ...super.debugValue() };\n if (this.octave != 0) out.octave = this.octave;\n if (this.shift != 0) out.shift = this.shift;\n return out;\n }\n\n /**\n * Returns a string representation of this Note.\n * @returns A string representation\n */\n toString(): string {\n return `Note(${this.duration}-${this.value}-${this.octave})`;\n }\n\n /**\n * Checks if this Note is equal to another Note.\n * @param another The Note to compare with\n * @returns True if the Notes are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.octave == another.octave && this.shift == another.shift;\n }\n\n /**\n * Copies the properties of this Note to another Note.\n * @param another The target Note to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.octave = this.octave;\n another.shift = this.shift;\n }\n}\n\n/**\n * Represents a group of atoms that are treated as a single unit.\n * Groups can contain any number of atoms, including other groups.\n */\nexport class Group extends Atom {\n readonly TYPE = \"Group\";\n\n /**\n * Indicates whether the duration is static or linear to the number of atoms in this group.\n * When true, the duration is used as a multiplier for the total child duration.\n * When false, the duration is absolute.\n */\n durationIsSpeedMultiplier = false;\n\n /**\n * The list of atoms in this group.\n */\n readonly atoms = new TSU.Lists.ValueList<Atom>();\n\n /**\n * Observers that receive notifications when atoms change.\n */\n private _observers: GroupObserver<Atom, Group>[] = [];\n\n /**\n * Creates a new Group containing the specified atoms.\n * @param atoms The atoms to include in this group\n */\n constructor(...atoms: Atom[]) {\n super(atoms.length == 0 ? ZERO : ONE);\n this.addAtoms(false, ...atoms);\n }\n\n /**\n * Adds an observer to receive atom change notifications.\n * @param observer The observer to add\n * @returns A function to remove the observer\n */\n addObserver(observer: GroupObserver<Atom, Group>): () => void {\n this._observers.push(observer);\n return () => this.removeObserver(observer);\n }\n\n /**\n * Removes an observer.\n * @param observer The observer to remove\n */\n removeObserver(observer: GroupObserver<Atom, Group>): void {\n const index = this._observers.indexOf(observer);\n if (index >= 0) {\n this._observers.splice(index, 1);\n }\n }\n\n /**\n * Notifies observers of atom changes.\n */\n private notifyObservers(type: AtomChangeType, atoms: Atom[], index: number): void {\n if (!this._eventsEnabled) return;\n for (const observer of this._observers) {\n switch (type) {\n case AtomChangeType.ADD:\n observer.onAtomsAdded?.(this, atoms, index);\n break;\n case AtomChangeType.INSERT:\n observer.onAtomsInserted?.(this, atoms, index);\n break;\n case AtomChangeType.REMOVE:\n observer.onAtomsRemoved?.(this, atoms);\n break;\n }\n }\n }\n\n /**\n * Checks if this Group is equal to another Group.\n * @param another The Group to compare with\n * @param expect Optional parameter\n * @returns True if the Groups are equal, false otherwise\n */\n equals(another: this, expect = false): boolean {\n if (!super.equals(another)) return false;\n return this.atoms.equals(another.atoms, (a1, a2) => a1.equals(a2));\n }\n\n /**\n * Copies the properties of this Group to another Group.\n * @param another The target Group to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.durationIsSpeedMultiplier = this.durationIsSpeedMultiplier;\n for (const atom of this.atoms.values()) {\n another.atoms.add(atom.clone());\n }\n }\n\n /**\n * Gets the duration of this group.\n * If durationIsSpeedMultiplier is true, returns the total child duration divided by the multiplier.\n * Otherwise, returns the absolute duration.\n */\n get duration(): Fraction {\n if (this.durationIsSpeedMultiplier) {\n return this.totalChildDuration.divby(this._duration);\n } else {\n return this._duration;\n }\n }\n\n /**\n * Sets this group to use a multiplier for duration calculations.\n * @param asSpeedMultiplier Whether to use the duration as a speed multiplier. Eg If our duration was 2 and this was\n * set then since the speed is doubled - then the actual duration is halved.\n * @returns This Group instance for method chaining\n */\n setDurationAsMultiplier(asSpeedMultiplier = true): this {\n this.durationIsSpeedMultiplier = asSpeedMultiplier;\n return this;\n }\n\n /**\n * Sets the duration of this group.\n * @param d The new duration\n * @param asSpeedMultiplier Whether to use the duration as a speed multiplier. Eg If our duration was 2 and this was\n * set then since the speed is doubled - then the actual duration is halved.\n * @returns This Group instance for method chaining\n */\n setDuration(d: Fraction, asSpeedMultiplier = false): this {\n this._duration = d;\n this.durationIsSpeedMultiplier = asSpeedMultiplier;\n return this;\n }\n\n /**\n * Returns a debug-friendly representation of this Group.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = { ...super.debugValue(), atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) };\n if (this.durationIsSpeedMultiplier) out.durationIsSpeedMultiplier = true;\n return out;\n }\n\n /**\n * Splits this group into two parts.\n * The first part (this group) fits within the given duration and everything else\n * longer than the given duration is returned as a new Group.\n *\n * @param requiredDuration The duration at which to split the group\n * @returns A new Group containing the atoms beyond the split point, or null if no split is needed\n */\n splitAt(requiredDuration: Fraction): TSU.Nullable<Group> {\n if (this.duration.isLTE(requiredDuration) || requiredDuration.isLTE(ZERO)) {\n return null;\n }\n const targetGroup = new Group();\n if (this.durationIsSpeedMultiplier) {\n targetGroup.durationIsSpeedMultiplier = true;\n targetGroup._duration = this._duration;\n }\n\n let remainingDur = this.duration;\n const totalChildDuration = this.totalChildDuration;\n const durationFactor = this.durationIsSpeedMultiplier\n ? ONE.divby(this._duration)\n : this._duration.divby(totalChildDuration, true);\n while (remainingDur.isGT(requiredDuration) && this.atoms.last) {\n const lastChild = this.atoms.last;\n // Child's duration is absolute in its own \"system\"\n // Its duration within the parent (this) group's frame of reference depends\n // on whether the parent's duration is absolute or as a multiplier\n //\n // realChildDuration = case (group.durationIsMultiper) {\n // | true => child.duration / this._duration\n // | false => child.duration * this._duration / total child duration\n // }\n const childDuration = lastChild.duration.times(durationFactor);\n const newDuration = remainingDur.minus(childDuration);\n if (newDuration.isGTE(requiredDuration)) {\n // remove ourselves and add to target\n // in both cases duration will be adjusted if need be\n this.removeAtoms(true, lastChild);\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, lastChild);\n if (newDuration.equals(requiredDuration)) {\n // we have reached the end so return\n return targetGroup;\n }\n } else {\n // our scenario is now this:\n //\n // totalParentDuration = 10\n // required = 8\n // lastChildDuration (relative to parent) is 5\n //\n // durWithoutLast = 10 - 5\n // newRequired = requiredDur - durWithoutLast = 3\n //\n // However 3 is a duration in the parent's frame of reference\n // this has to be converted back to the child's FoR\n const newRequiredDur = requiredDuration.minus(newDuration, true).divby(durationFactor, true);\n // console.log( \"newRequiredDur: \", newRequiredDur, \"requiedDur: \", requiredDuration, \"remainingDur: \", remainingDur,);\n // then the last item needs to be split, and by how much?\n const spillOver = lastChild.splitAt(newRequiredDur);\n if (spillOver == null) {\n throw new Error(\"Spill over cannot be null here\");\n }\n if (!this.durationIsSpeedMultiplier) {\n // Our own duration has also now changed\n this._duration = requiredDuration;\n } else {\n if (this._duration.isZero) throw new Error(\"How can this be?\");\n }\n spillOver.isContinuation = true;\n // Add spill over to the target\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, spillOver);\n return targetGroup;\n }\n remainingDur = newDuration;\n }\n return targetGroup;\n }\n\n /**\n * Gets the total duration of all child atoms.\n * @returns The sum of durations of all atoms in this group\n */\n get totalChildDuration(): Fraction {\n let out = ZERO;\n for (const atom of this.atoms.values()) {\n out = out.plus(atom.duration);\n }\n return out;\n }\n\n /**\n * Inserts atoms before a given cursor atom.\n * If the cursor atom is null, the atoms are appended at the end.\n *\n * @param beforeAtom The atom before which to insert the new atoms, or null to append\n * @param adjustDuration Whether to adjust this group's duration based on the new atoms\n * @param atoms The atoms to insert\n * @returns This Group instance for method chaining\n */\n insertAtomsAt(beforeAtom: TSU.Nullable<Atom>, adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsSpeedMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n\n // Calculate insertion index for event notification\n let insertIndex: number;\n if (beforeAtom) {\n // Find index of beforeAtom using for loop\n insertIndex = 0;\n for (const a of this.atoms.values()) {\n if (a === beforeAtom) break;\n insertIndex++;\n }\n } else {\n // Appending to end - use size property\n insertIndex = this.atoms.size;\n }\n\n // Track which atoms were actually added (excluding REST atoms)\n const addedAtoms: Atom[] = [];\n\n // First form a chain of the given atoms\n for (const atom of atoms) {\n if (atom.parentGroup != null) {\n if (atom.parentGroup != this) {\n throw new Error(\"Atom belongs to another parent. Remove it first\");\n }\n atom.parentGroup.removeAtoms(false, atom);\n }\n if (atom.TYPE == AtomType.REST) {\n const last = this.atoms.last;\n if (last && last.TYPE != AtomType.GROUP && last.TYPE != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n atom.parentGroup = this;\n this.atoms.add(atom, beforeAtom);\n addedAtoms.push(atom);\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsSpeedMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n\n // Notify observers if atoms were added\n if (addedAtoms.length > 0) {\n const type = beforeAtom ? AtomChangeType.INSERT : AtomChangeType.ADD;\n this.notifyObservers(type, addedAtoms, insertIndex);\n }\n\n return this;\n }\n\n /**\n * Adds atoms to the end of this group's atom list.\n *\n * @param adjustDuration Whether to adjust this group's duration based on the new atoms\n * @param atoms The atoms to add\n * @returns This Group instance for method chaining\n */\n addAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n return this.insertAtomsAt(null, adjustDuration, ...atoms);\n }\n\n /**\n * Removes atoms from this group's child list.\n *\n * @param adjustDuration Whether to adjust this group's duration after removing atoms\n * @param atoms The atoms to remove\n * @returns This Group instance for method chaining\n */\n removeAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsSpeedMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n\n // Track which atoms were actually removed\n const removedAtoms: Atom[] = [];\n\n for (const atom of atoms) {\n if (atom.parentGroup == this) {\n this.atoms.remove(atom);\n atom.parentGroup = null;\n removedAtoms.push(atom);\n } else if (atom.parentGroup != null) {\n throw new Error(\"Atom cannot be removed as it does not belong to this group\");\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsSpeedMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n\n // Notify observers if atoms were removed\n if (removedAtoms.length > 0) {\n this.notifyObservers(AtomChangeType.REMOVE, removedAtoms, -1);\n }\n\n return this;\n }\n}\n\n/**\n * Represents a line of notation containing multiple roles.\n * A line can have atoms starting before or after the cycle.\n */\nexport class Line extends Entity {\n readonly TYPE: string = \"Line\";\n\n /**\n * Offset tells how many notes before or after the cycle this line's atoms start at.\n */\n offset: Fraction = ZERO;\n\n /**\n * The roles contained in this line.\n */\n roles: Role[] = [];\n\n /**\n * Text to be displayed in the margin of the line.\n * This is a hacky solution to doing left side pre-margin text typically\n * found in notations - e.g., line X of a pallavi has this. This makes vertical\n * space less wasteful.\n *\n * A better solution is inter-beat annotation but it is very complex for now.\n */\n marginText = \"\";\n\n /**\n * The LayoutParams associated with this line.\n */\n layoutParams: LayoutParams;\n\n /**\n * Observers that receive notifications when roles change.\n */\n private _observers: LineObserver<Role, Line>[] = [];\n\n /**\n * Adds an observer to receive role change notifications.\n * @param observer The observer to add\n * @returns A function to remove the observer\n */\n addObserver(observer: LineObserver<Role, Line>): () => void {\n this._observers.push(observer);\n return () => this.removeObserver(observer);\n }\n\n /**\n * Removes an observer.\n * @param observer The observer to remove\n */\n removeObserver(observer: LineObserver<Role, Line>): void {\n const index = this._observers.indexOf(observer);\n if (index >= 0) {\n this._observers.splice(index, 1);\n }\n }\n\n /**\n * Finds the index of a role with the given name.\n * @param name The name of the role to find\n * @returns The index of the role, or -1 if not found\n */\n indexOfRole(name: string): number {\n for (let i = 0; i < this.roles.length; i++) {\n if (this.roles[i].name == name) return i;\n }\n return -1;\n }\n\n /**\n * Checks if this line is empty (has no content in any role).\n */\n get isEmpty(): boolean {\n for (const r of this.roles) if (!r.isEmpty) return false;\n return true;\n }\n\n /**\n * Returns a debug-friendly representation of this Line.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = {\n ...super.debugValue(),\n roles: this.roles.map((r) => r.debugValue()),\n };\n if (!this.offset.isZero) {\n out.offset = this.offset.toString();\n }\n return out;\n }\n\n /**\n * Copies the properties of this Line to another Line.\n * @param another The target Line to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.roles = this.roles.map((r) => r.clone());\n }\n\n /**\n * Adds atoms to a role in this line.\n * @param roleName The name of the role to add atoms to\n * @param defaultToNotes Whether to default to notes for this role\n * @param atoms The atoms to add\n * @returns This Line instance for method chaining\n */\n addAtoms(roleName: string, defaultToNotes: boolean, ...atoms: Atom[]): this {\n const role = this.ensureRole(roleName, defaultToNotes);\n role.addAtoms(...atoms);\n return this;\n }\n\n /**\n * Ensures a role with the given name exists in this line, creating it if needed.\n * @param roleName The name of the role to ensure\n * @param defaultToNotes Whether to default to notes for this role\n * @returns The role with the specified name\n */\n ensureRole(roleName: string, defaultToNotes: boolean): Role {\n // Ensure we have this many roles\n let ri = this.roles.findIndex((r) => r.name == roleName);\n if (ri < 0) {\n ri = this.roles.length;\n const role = new Role(this, roleName);\n role.defaultToNotes = defaultToNotes;\n this.roles.push(role);\n\n // Notify observers of new role\n if (this._eventsEnabled) {\n for (const observer of this._observers) {\n observer.onRoleAdded?.(this, roleName, role);\n }\n }\n }\n return this.roles[ri];\n }\n\n /**\n * Removes a role from this line.\n * @param roleName The name of the role to remove\n * @returns True if the role was removed, false if not found\n */\n removeRole(roleName: string): boolean {\n const ri = this.roles.findIndex((r) => r.name == roleName);\n if (ri >= 0) {\n this.roles.splice(ri, 1);\n\n // Notify observers of removed role\n if (this._eventsEnabled) {\n for (const observer of this._observers) {\n observer.onRoleRemoved?.(this, roleName);\n }\n }\n return true;\n }\n return false;\n }\n\n /**\n * Gets the maximum duration across all roles in this line.\n */\n get duration(): Fraction {\n let max = ZERO;\n for (const role of this.roles) {\n max = TSU.Num.Fraction.max(role.duration, max);\n }\n return max;\n }\n}\n\n/**\n * Represents a specific role or voice in a line of notation.\n * Each role contains a sequence of atoms.\n */\nexport class Role extends Entity {\n readonly TYPE = \"Role\";\n\n /**\n * Whether this role represents notes by default.\n */\n defaultToNotes = true;\n\n /**\n * The atoms in this role.\n */\n atoms: Atom[] = [];\n\n /**\n * Observers that receive notifications when atoms change.\n */\n private _observers: RoleObserver<Atom, Role>[] = [];\n\n /**\n * Creates a new Role with the specified line and name.\n * @param line The line this role belongs to\n * @param name The name of the role\n */\n constructor(\n public readonly line: Line,\n public readonly name: string,\n ) {\n super();\n }\n\n /**\n * Adds an observer to receive atom change notifications.\n * @param observer The observer to add\n * @returns A function to remove the observer\n */\n addObserver(observer: RoleObserver<Atom, Role>): () => void {\n this._observers.push(observer);\n return () => this.removeObserver(observer);\n }\n\n /**\n * Removes an observer.\n * @param observer The observer to remove\n */\n removeObserver(observer: RoleObserver<Atom, Role>): void {\n const index = this._observers.indexOf(observer);\n if (index >= 0) {\n this._observers.splice(index, 1);\n }\n }\n\n /**\n * Notifies observers of atom changes.\n */\n private notifyObservers(type: AtomChangeType, atoms: Atom[], index: number): void {\n if (!this._eventsEnabled) return;\n for (const observer of this._observers) {\n switch (type) {\n case AtomChangeType.ADD:\n observer.onAtomsAdded?.(this, atoms, index);\n break;\n case AtomChangeType.INSERT:\n observer.onAtomsInserted?.(this, atoms, index);\n break;\n case AtomChangeType.REMOVE:\n observer.onAtomsRemoved?.(this, atoms);\n break;\n }\n }\n }\n\n /**\n * Checks if this role is empty (has no atoms).\n */\n get isEmpty(): boolean {\n return this.atoms.length == 0;\n }\n\n /**\n * Returns a debug-friendly representation of this Role.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { name: this.name, atoms: this.atoms.map((a) => a.debugValue()) };\n }\n\n /**\n * Adds atoms to the end of this role.\n * @param atoms The atoms to add\n */\n addAtoms(...atoms: Atom[]): void {\n this.insertAtomsAt(this.atoms.length, ...atoms);\n }\n\n /**\n * Inserts atoms at a specific index in this role.\n * @param index The index at which to insert\n * @param atoms The atoms to insert\n */\n insertAtomsAt(index: number, ...atoms: Atom[]): void {\n // Track which atoms were actually added (excluding REST atoms)\n const addedAtoms: Atom[] = [];\n let last: null | Atom = index > 0 ? this.atoms[index - 1] : null;\n\n for (const atom of atoms) {\n if (atom.TYPE == AtomType.REST) {\n if (last && last.TYPE != AtomType.GROUP && last.TYPE != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n this.atoms.splice(index + addedAtoms.length, 0, atom);\n addedAtoms.push(atom);\n }\n last = atom;\n }\n\n // Notify observers if atoms were added\n if (addedAtoms.length > 0) {\n const isAppend = index >= this.atoms.length - addedAtoms.length;\n const type = isAppend ? AtomChangeType.ADD : AtomChangeType.INSERT;\n this.notifyObservers(type, addedAtoms, index);\n }\n }\n\n /**\n * Removes atoms from this role.\n * @param atoms The atoms to remove\n */\n removeAtoms(...atoms: Atom[]): void {\n const removedAtoms: Atom[] = [];\n\n for (const atom of atoms) {\n const idx = this.atoms.indexOf(atom);\n if (idx >= 0) {\n this.atoms.splice(idx, 1);\n removedAtoms.push(atom);\n }\n }\n\n // Notify observers if atoms were removed\n if (removedAtoms.length > 0) {\n this.notifyObservers(AtomChangeType.REMOVE, removedAtoms, -1);\n }\n }\n\n /**\n * Copies the properties of this Role to another Role.\n * @param another The target Role to copy properties to\n */\n copyTo(another: Role): void {\n another.addAtoms(...this.atoms);\n }\n\n /**\n * Gets the total duration of all atoms in this role.\n */\n get duration(): Fraction {\n return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);\n }\n}\n"]}
|
package/lib/esm/entity.d.ts
CHANGED
|
@@ -4,7 +4,11 @@ export declare class Entity {
|
|
|
4
4
|
private static counter;
|
|
5
5
|
readonly uuid: number;
|
|
6
6
|
protected _parent: TSU.Nullable<Entity>;
|
|
7
|
+
protected _eventsEnabled: boolean;
|
|
7
8
|
constructor(config?: any);
|
|
9
|
+
enableEvents(): this;
|
|
10
|
+
disableEvents(): this;
|
|
11
|
+
get eventsEnabled(): boolean;
|
|
8
12
|
get parent(): TSU.Nullable<Entity>;
|
|
9
13
|
setParent(parent: TSU.Nullable<Entity>): void;
|
|
10
14
|
debugValue(): any;
|
package/lib/esm/entity.js
CHANGED
|
@@ -3,10 +3,22 @@ export class Entity {
|
|
|
3
3
|
this.TYPE = "Entity";
|
|
4
4
|
this.uuid = Entity.counter++;
|
|
5
5
|
this._parent = null;
|
|
6
|
+
this._eventsEnabled = false;
|
|
6
7
|
config = config || {};
|
|
7
8
|
if (config.metadata)
|
|
8
9
|
throw new Error("See where metadata is being passed");
|
|
9
10
|
}
|
|
11
|
+
enableEvents() {
|
|
12
|
+
this._eventsEnabled = true;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
disableEvents() {
|
|
16
|
+
this._eventsEnabled = false;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
get eventsEnabled() {
|
|
20
|
+
return this._eventsEnabled;
|
|
21
|
+
}
|
|
10
22
|
get parent() {
|
|
11
23
|
return this._parent;
|
|
12
24
|
}
|
package/lib/esm/entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/entity.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,MAAM;IAmBjB,YAAY,SAAc,IAAI;QAlBrB,SAAI,GAAW,QAAQ,CAAC;QAIxB,SAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAEvB,YAAO,GAAyB,IAAI,CAAC;QAMrC,mBAAc,GAAG,KAAK,CAAC;QAO/B,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC7E,CAAC;IAOD,YAAY;QACV,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAMD,aAAa;QACX,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAKD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAMD,SAAS,CAAC,MAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAOD,UAAU;QACR,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAMD,QAAQ;QACN,OAAO,eAAe,IAAI,CAAC,IAAI,GAAG,CAAC;IACrC,CAAC;IAQD,MAAM,CAAC,OAAa,EAAE,MAAM,GAAG,KAAK;QAClC,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IAUD,KAAK;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,GAAG,CAAC;IACb,CAAC;IAMD,MAAM,CAAC,OAAa;IAEpB,CAAC;IAMS,WAAW;QACnB,OAAO,IAAK,IAAI,CAAC,WAAmB,EAAE,CAAC;IACzC,CAAC;;AAtHc,cAAO,GAAG,CAAC,AAAJ,CAAK;AA6H7B,MAAM,OAAgB,WAAY,SAAQ,MAAM;IAAhD;;QACW,SAAI,GAAW,aAAa,CAAC;IAgBxC,CAAC;IAHC,MAAM,CAAC,OAAa;QAClB,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\n\n/**\n * A common Entity base class with support for unique IDs, parent references,\n * copying, and debug info. This serves as the foundation for all entities\n * in the notation system.\n *\n * Note: Child management is intentionally NOT included here. Each container type\n * (BlockContainer, Line, Group, etc.) defines its own child management with\n * appropriate types.\n *\n * Observer Pattern:\n * Each observable entity subclass (Group, Role, Line, Block) manages its own\n * typed observer list. This provides type safety and clear contracts between\n * observables and observers.\n */\nexport class Entity {\n readonly TYPE: string = \"Entity\";\n\n private static counter = 0;\n /** Unique identifier for this entity */\n readonly uuid = Entity.counter++;\n /** Parent entity in the tree hierarchy */\n protected _parent: TSU.Nullable<Entity> = null;\n\n /**\n * Whether events/observer notifications are enabled for this entity.\n * Subclasses check this flag before notifying observers.\n */\n protected _eventsEnabled = false;\n\n /**\n * Creates a new Entity.\n * @param config Optional configuration object\n */\n constructor(config: any = null) {\n config = config || {};\n if (config.metadata) throw new Error(\"See where metadata is being passed\");\n }\n\n /**\n * Enables observer notifications for this entity.\n * Call this to activate change notifications on entities that support them.\n * @returns This entity for method chaining\n */\n enableEvents(): this {\n this._eventsEnabled = true;\n return this;\n }\n\n /**\n * Disables observer notifications for this entity.\n * @returns This entity for method chaining\n */\n disableEvents(): this {\n this._eventsEnabled = false;\n return this;\n }\n\n /**\n * Checks if events/observer notifications are enabled.\n */\n get eventsEnabled(): boolean {\n return this._eventsEnabled;\n }\n\n /**\n * Gets the parent entity.\n */\n get parent(): TSU.Nullable<Entity> {\n return this._parent;\n }\n\n /**\n * Sets the parent entity.\n * @param parent The parent entity to set\n */\n setParent(parent: TSU.Nullable<Entity>): void {\n this._parent = parent;\n }\n\n /**\n * Returns a debug-friendly representation of this entity.\n * Usually overridden by children to add more debug info.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { type: this.TYPE };\n }\n\n /**\n * Returns a simple string representation of this Entity.\n * @returns A string representation\n */\n toString(): string {\n return `Entity(id = ${this.uuid})`;\n }\n\n /**\n * Checks if this Entity is equal to another Entity.\n * @param another The Entity to compare with\n * @param expect Optional parameter\n * @returns True if the Entities are equal, false otherwise\n */\n equals(another: this, expect = false): boolean {\n if (this.TYPE != another.TYPE) return false;\n return true;\n }\n\n /**\n * Creates a clone of this entity.\n * Cloning is a two-part process:\n * 1. Creation of a new instance via this.newInstance()\n * 2. Copying of data into the new instance via this.copyTo()\n *\n * @returns A new instance of the same type with the same properties\n */\n clone(): this {\n const out = this.newInstance();\n this.copyTo(out);\n return out;\n }\n\n /**\n * Copies information about this instance into another instance of the same type.\n * @param another The target instance to copy properties to\n */\n copyTo(another: this): void {\n // Subclasses override to copy their specific properties\n }\n\n /**\n * First part of the cloning process where the instance is created.\n * @returns A new instance of the same type\n */\n protected newInstance(): this {\n return new (this.constructor as any)();\n }\n}\n\n/**\n * Music is all about timing! TimedEntities are base of all entities that\n * have a duration. This is an abstract class that all timed entities inherit from.\n */\nexport abstract class TimedEntity extends Entity {\n readonly TYPE: string = \"TimedEntity\";\n\n /**\n * Gets the duration of this entity in terms of beats.\n * By default, entity durations are readonly.\n */\n abstract get duration(): TSU.Num.Fraction;\n\n /**\n * Checks if this TimedEntity is equal to another TimedEntity.\n * @param another The TimedEntity to compare with\n * @returns True if the TimedEntities are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.duration.equals(another.duration);\n }\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare enum AtomChangeType {
|
|
2
|
+
ADD = "add",
|
|
3
|
+
INSERT = "insert",
|
|
4
|
+
REMOVE = "remove",
|
|
5
|
+
UPDATE = "update"
|
|
6
|
+
}
|
|
7
|
+
export interface AtomChangeEvent<T = any> {
|
|
8
|
+
type: AtomChangeType;
|
|
9
|
+
atoms: T[];
|
|
10
|
+
index?: number;
|
|
11
|
+
property?: string;
|
|
12
|
+
oldValue?: any;
|
|
13
|
+
newValue?: any;
|
|
14
|
+
}
|
|
15
|
+
export declare enum RoleChangeType {
|
|
16
|
+
ADD = "add",
|
|
17
|
+
REMOVE = "remove"
|
|
18
|
+
}
|
|
19
|
+
export interface RoleChangeEvent {
|
|
20
|
+
type: RoleChangeType;
|
|
21
|
+
roleName: string;
|
|
22
|
+
}
|
|
23
|
+
export declare enum BlockItemChangeType {
|
|
24
|
+
ADD = "add",
|
|
25
|
+
REMOVE = "remove"
|
|
26
|
+
}
|
|
27
|
+
export interface BlockItemChangeEvent<T = any> {
|
|
28
|
+
type: BlockItemChangeType;
|
|
29
|
+
item: T;
|
|
30
|
+
index?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface GroupObserver<TAtom = any, TGroup = any> {
|
|
33
|
+
onAtomsAdded?(group: TGroup, atoms: TAtom[], index: number): void;
|
|
34
|
+
onAtomsInserted?(group: TGroup, atoms: TAtom[], index: number): void;
|
|
35
|
+
onAtomsRemoved?(group: TGroup, atoms: TAtom[]): void;
|
|
36
|
+
}
|
|
37
|
+
export interface RoleObserver<TAtom = any, TRole = any> {
|
|
38
|
+
onAtomsAdded?(role: TRole, atoms: TAtom[], index: number): void;
|
|
39
|
+
onAtomsInserted?(role: TRole, atoms: TAtom[], index: number): void;
|
|
40
|
+
onAtomsRemoved?(role: TRole, atoms: TAtom[]): void;
|
|
41
|
+
}
|
|
42
|
+
export interface LineObserver<TRole = any, TLine = any> {
|
|
43
|
+
onRoleAdded?(line: TLine, roleName: string, role: TRole): void;
|
|
44
|
+
onRoleRemoved?(line: TLine, roleName: string): void;
|
|
45
|
+
}
|
|
46
|
+
export interface BlockObserver<TItem = any, TBlock = any> {
|
|
47
|
+
onItemAdded?(block: TBlock, item: TItem, index: number): void;
|
|
48
|
+
onItemRemoved?(block: TBlock, item: TItem, index: number): void;
|
|
49
|
+
}
|
|
50
|
+
export declare const ModelEvents: {
|
|
51
|
+
readonly ATOMS_CHANGED: "atomsChanged";
|
|
52
|
+
readonly ROLES_CHANGED: "rolesChanged";
|
|
53
|
+
readonly ITEMS_CHANGED: "itemsChanged";
|
|
54
|
+
readonly DURATION_CHANGED: "durationChanged";
|
|
55
|
+
};
|
|
56
|
+
export type ModelEventName = (typeof ModelEvents)[keyof typeof ModelEvents];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export var AtomChangeType;
|
|
2
|
+
(function (AtomChangeType) {
|
|
3
|
+
AtomChangeType["ADD"] = "add";
|
|
4
|
+
AtomChangeType["INSERT"] = "insert";
|
|
5
|
+
AtomChangeType["REMOVE"] = "remove";
|
|
6
|
+
AtomChangeType["UPDATE"] = "update";
|
|
7
|
+
})(AtomChangeType || (AtomChangeType = {}));
|
|
8
|
+
export var RoleChangeType;
|
|
9
|
+
(function (RoleChangeType) {
|
|
10
|
+
RoleChangeType["ADD"] = "add";
|
|
11
|
+
RoleChangeType["REMOVE"] = "remove";
|
|
12
|
+
})(RoleChangeType || (RoleChangeType = {}));
|
|
13
|
+
export var BlockItemChangeType;
|
|
14
|
+
(function (BlockItemChangeType) {
|
|
15
|
+
BlockItemChangeType["ADD"] = "add";
|
|
16
|
+
BlockItemChangeType["REMOVE"] = "remove";
|
|
17
|
+
})(BlockItemChangeType || (BlockItemChangeType = {}));
|
|
18
|
+
export const ModelEvents = {
|
|
19
|
+
ATOMS_CHANGED: "atomsChanged",
|
|
20
|
+
ROLES_CHANGED: "rolesChanged",
|
|
21
|
+
ITEMS_CHANGED: "itemsChanged",
|
|
22
|
+
DURATION_CHANGED: "durationChanged",
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IAExB,6BAAW,CAAA;IAEX,mCAAiB,CAAA;IAEjB,mCAAiB,CAAA;IAEjB,mCAAiB,CAAA;AACnB,CAAC,EATW,cAAc,KAAd,cAAc,QASzB;AAwBD,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IAExB,6BAAW,CAAA;IAEX,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAeD,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAE7B,kCAAW,CAAA;IAEX,wCAAiB,CAAA;AACnB,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AAgJD,MAAM,CAAC,MAAM,WAAW,GAAG;IAEzB,aAAa,EAAE,cAAc;IAE7B,aAAa,EAAE,cAAc;IAE7B,aAAa,EAAE,cAAc;IAE7B,gBAAgB,EAAE,iBAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Model change events for incremental updates.\n *\n * This module defines the event types, interfaces, and observer patterns for\n * change notifications on model entities (Group, Role, Line, Block). These\n * events enable incremental updates to the rendering pipeline without full\n * re-renders.\n *\n * Uses the Observer pattern instead of pub/sub EventHub for:\n * - Type safety: Observers have strongly-typed method signatures\n * - Traceability: Easy to see who is observing what\n * - Explicit contracts: Clear interface between observable and observers\n *\n * Note: This module uses generic types to avoid circular dependencies with\n * core.ts and block.ts. The actual types are enforced at the call sites.\n */\n\n// ============================================\n// Event Types and Payloads\n// ============================================\n\n/**\n * Event types for Atom-related changes.\n */\nexport enum AtomChangeType {\n /** Atoms were added to the end */\n ADD = \"add\",\n /** Atoms were inserted at a specific position */\n INSERT = \"insert\",\n /** Atoms were removed */\n REMOVE = \"remove\",\n /** An atom's properties changed (duration, value, etc.) */\n UPDATE = \"update\",\n}\n\n/**\n * Event payload for atom changes in a Group or Role.\n * Generic T is typically Atom from core.ts.\n */\nexport interface AtomChangeEvent<T = any> {\n /** The type of change */\n type: AtomChangeType;\n /** The atoms that were added, inserted, or removed */\n atoms: T[];\n /** For INSERT: the index where atoms were inserted */\n index?: number;\n /** For UPDATE: the specific property that changed */\n property?: string;\n /** For UPDATE: the old value of the property */\n oldValue?: any;\n /** For UPDATE: the new value of the property */\n newValue?: any;\n}\n\n/**\n * Event types for Role-related changes on a Line.\n */\nexport enum RoleChangeType {\n /** A role was added to the line */\n ADD = \"add\",\n /** A role was removed from the line */\n REMOVE = \"remove\",\n}\n\n/**\n * Event payload for role changes on a Line.\n */\nexport interface RoleChangeEvent {\n /** The type of change */\n type: RoleChangeType;\n /** The role that was added or removed */\n roleName: string;\n}\n\n/**\n * Event types for BlockItem changes on a Block.\n */\nexport enum BlockItemChangeType {\n /** An item was added to the block */\n ADD = \"add\",\n /** An item was removed from the block */\n REMOVE = \"remove\",\n}\n\n/**\n * Event payload for block item changes.\n * Generic T is typically BlockItem (Block | Line | RawBlock) from block.ts.\n */\nexport interface BlockItemChangeEvent<T = any> {\n /** The type of change */\n type: BlockItemChangeType;\n /** The item that was added or removed */\n item: T;\n /** For ADD: the index where the item was added */\n index?: number;\n}\n\n// ============================================\n// Observer Interfaces\n// ============================================\n\n/**\n * Observer interface for Group atom changes.\n * Implement this interface to receive notifications when atoms are\n * added, inserted, or removed from a Group.\n *\n * @template TAtom The atom type (defaults to any to avoid circular deps)\n * @template TGroup The group type (defaults to any to avoid circular deps)\n */\nexport interface GroupObserver<TAtom = any, TGroup = any> {\n /**\n * Called when atoms are added to the end of the group.\n * @param group The group that changed\n * @param atoms The atoms that were added\n * @param index The index where atoms were added\n */\n onAtomsAdded?(group: TGroup, atoms: TAtom[], index: number): void;\n\n /**\n * Called when atoms are inserted at a specific position.\n * @param group The group that changed\n * @param atoms The atoms that were inserted\n * @param index The index where atoms were inserted\n */\n onAtomsInserted?(group: TGroup, atoms: TAtom[], index: number): void;\n\n /**\n * Called when atoms are removed from the group.\n * @param group The group that changed\n * @param atoms The atoms that were removed\n */\n onAtomsRemoved?(group: TGroup, atoms: TAtom[]): void;\n}\n\n/**\n * Observer interface for Role atom changes.\n * Implement this interface to receive notifications when atoms are\n * added, inserted, or removed from a Role.\n *\n * @template TAtom The atom type (defaults to any to avoid circular deps)\n * @template TRole The role type (defaults to any to avoid circular deps)\n */\nexport interface RoleObserver<TAtom = any, TRole = any> {\n /**\n * Called when atoms are added to the end of the role.\n * @param role The role that changed\n * @param atoms The atoms that were added\n * @param index The index where atoms were added\n */\n onAtomsAdded?(role: TRole, atoms: TAtom[], index: number): void;\n\n /**\n * Called when atoms are inserted at a specific position.\n * @param role The role that changed\n * @param atoms The atoms that were inserted\n * @param index The index where atoms were inserted\n */\n onAtomsInserted?(role: TRole, atoms: TAtom[], index: number): void;\n\n /**\n * Called when atoms are removed from the role.\n * @param role The role that changed\n * @param atoms The atoms that were removed\n */\n onAtomsRemoved?(role: TRole, atoms: TAtom[]): void;\n}\n\n/**\n * Observer interface for Line role changes.\n * Implement this interface to receive notifications when roles are\n * added or removed from a Line.\n *\n * @template TRole The role type (defaults to any to avoid circular deps)\n * @template TLine The line type (defaults to any to avoid circular deps)\n */\nexport interface LineObserver<TRole = any, TLine = any> {\n /**\n * Called when a role is added to the line.\n * @param line The line that changed\n * @param roleName The name of the added role\n * @param role The role that was added\n */\n onRoleAdded?(line: TLine, roleName: string, role: TRole): void;\n\n /**\n * Called when a role is removed from the line.\n * @param line The line that changed\n * @param roleName The name of the removed role\n */\n onRoleRemoved?(line: TLine, roleName: string): void;\n}\n\n/**\n * Observer interface for Block item changes.\n * Implement this interface to receive notifications when items are\n * added or removed from a Block.\n *\n * @template TItem The block item type (defaults to any to avoid circular deps)\n * @template TBlock The block type (defaults to any to avoid circular deps)\n */\nexport interface BlockObserver<TItem = any, TBlock = any> {\n /**\n * Called when an item is added to the block.\n * @param block The block that changed\n * @param item The item that was added\n * @param index The index where the item was added\n */\n onItemAdded?(block: TBlock, item: TItem, index: number): void;\n\n /**\n * Called when an item is removed from the block.\n * @param block The block that changed\n * @param item The item that was removed\n * @param index The index where the item was located\n */\n onItemRemoved?(block: TBlock, item: TItem, index: number): void;\n}\n\n// ============================================\n// Legacy Event Names (kept for compatibility)\n// ============================================\n\n/**\n * Model event names as constants.\n * @deprecated Use observer interfaces instead\n */\nexport const ModelEvents = {\n /** Emitted when atoms change in a Group or Role */\n ATOMS_CHANGED: \"atomsChanged\",\n /** Emitted when roles change on a Line */\n ROLES_CHANGED: \"rolesChanged\",\n /** Emitted when block items change on a Block */\n ITEMS_CHANGED: \"itemsChanged\",\n /** Emitted when an atom's duration changes */\n DURATION_CHANGED: \"durationChanged\",\n} as const;\n\n/**\n * Type for model event names.\n * @deprecated Use observer interfaces instead\n */\nexport type ModelEventName = (typeof ModelEvents)[keyof typeof ModelEvents];\n"]}
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC","sourcesContent":["export * from \"./entity\";\nexport * from \"./cycle\";\nexport * from \"./core\";\nexport * from \"./iterators\";\nexport * from \"./layouts\";\nexport * from \"./grids\";\nexport * from \"./beats\";\nexport * from \"./notation\";\nexport * from \"./parser\";\nexport * from \"./shapes\";\nexport * from \"./loader\";\nexport * as Utils from \"./utils\";\nexport * as Carnatic from \"./carnatic\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC","sourcesContent":["export * from \"./entity\";\nexport * from \"./events\";\nexport * from \"./cycle\";\nexport * from \"./core\";\nexport * from \"./iterators\";\nexport * from \"./layouts\";\nexport * from \"./grids\";\nexport * from \"./beats\";\nexport * from \"./notation\";\nexport * from \"./parser\";\nexport * from \"./shapes\";\nexport * from \"./loader\";\nexport * as Utils from \"./utils\";\nexport * as Carnatic from \"./carnatic\";\n"]}
|
package/lib/esm/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;
|
|
@@ -65,7 +76,7 @@ export declare abstract class LeafAtomView extends AtomView {
|
|
|
65
76
|
export declare abstract class GroupView extends AtomView {
|
|
66
77
|
group: Group;
|
|
67
78
|
protected atomSpacing: number;
|
|
68
|
-
|
|
79
|
+
groupElement: SVGGElement;
|
|
69
80
|
protected atomViews: AtomView[];
|
|
70
81
|
private _embelishments;
|
|
71
82
|
defaultToNotes: boolean;
|
|
@@ -73,6 +84,7 @@ export declare abstract class GroupView extends AtomView {
|
|
|
73
84
|
scaleFactor: number;
|
|
74
85
|
showContinuationMarkers: boolean;
|
|
75
86
|
protected continuationMarkerElements: SVGTextElement[];
|
|
87
|
+
contentWidth: number;
|
|
76
88
|
constructor(group: Group, config?: any);
|
|
77
89
|
get totalDuration(): TSU.Num.Fraction;
|
|
78
90
|
createElements(parent: SVGGraphicsElement): void;
|
package/lib/esm/shapes.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
2
|
import { ZERO } from "./core";
|
|
3
|
+
export function computeCollisionLayout(items, totalDuration, containerWidth) {
|
|
4
|
+
const results = [];
|
|
5
|
+
let prevItemEndX = 0;
|
|
6
|
+
let currTime = ZERO;
|
|
7
|
+
for (const item of items) {
|
|
8
|
+
const glyphX = totalDuration.isZero ? 0 : currTime.timesNum(containerWidth).divby(totalDuration).floor;
|
|
9
|
+
let realX = glyphX - item.glyphOffset;
|
|
10
|
+
const wasCollision = realX < prevItemEndX;
|
|
11
|
+
if (wasCollision) {
|
|
12
|
+
realX = prevItemEndX;
|
|
13
|
+
}
|
|
14
|
+
results.push({ x: realX, wasCollision });
|
|
15
|
+
prevItemEndX = realX + item.minWidth;
|
|
16
|
+
currTime = currTime.plus(item.duration);
|
|
17
|
+
}
|
|
18
|
+
return results;
|
|
19
|
+
}
|
|
3
20
|
export class Shape {
|
|
4
21
|
constructor() {
|
|
5
22
|
this.shapeId = Shape.idCounter++;
|
|
@@ -198,13 +215,14 @@ export class GroupView extends AtomView {
|
|
|
198
215
|
this.defaultToNotes = true;
|
|
199
216
|
this.needsLayout = true;
|
|
200
217
|
this.scaleFactor = 1.0;
|
|
201
|
-
this.showContinuationMarkers =
|
|
218
|
+
this.showContinuationMarkers = false;
|
|
202
219
|
this.continuationMarkerElements = [];
|
|
203
|
-
this.
|
|
220
|
+
this.contentWidth = 0;
|
|
221
|
+
this.atomSpacing = 2;
|
|
204
222
|
this.setStyles(config || {});
|
|
205
223
|
}
|
|
206
224
|
get totalDuration() {
|
|
207
|
-
return this.group.
|
|
225
|
+
return this.group.duration;
|
|
208
226
|
}
|
|
209
227
|
createElements(parent) {
|
|
210
228
|
this.groupElement = TSU.DOM.createSVGNode("g", {
|
|
@@ -241,7 +259,7 @@ export class GroupView extends AtomView {
|
|
|
241
259
|
});
|
|
242
260
|
const totalDuration = this.group.totalChildDuration;
|
|
243
261
|
const totalDurValue = totalDuration.num / totalDuration.den;
|
|
244
|
-
const totalWidth = minWidthPerDuration * totalDurValue;
|
|
262
|
+
const totalWidth = Math.max(0, minWidthPerDuration * totalDurValue - this.atomSpacing);
|
|
245
263
|
return new TSU.Geom.Size(totalWidth * this.scaleFactor, maxHeight * this.scaleFactor);
|
|
246
264
|
}
|
|
247
265
|
updateBounds(x, y, w, h) {
|
|
@@ -253,16 +271,24 @@ export class GroupView extends AtomView {
|
|
|
253
271
|
transform += " scale(" + this.scaleFactor + ")";
|
|
254
272
|
}
|
|
255
273
|
this.groupElement.setAttribute("transform", transform);
|
|
256
|
-
const
|
|
274
|
+
const unscaledContentHeight = this.minSize.height / this.scaleFactor;
|
|
275
|
+
const unscaledAllocatedHeight = this.hasHeight ? this.height / this.scaleFactor : unscaledContentHeight;
|
|
276
|
+
const currY = unscaledAllocatedHeight - unscaledContentHeight;
|
|
257
277
|
const totalDur = this.group.totalChildDuration;
|
|
258
278
|
const unscaledMinWidth = this.minSize.width / this.scaleFactor;
|
|
259
279
|
const groupWidth = this.hasWidth ? this.width / this.scaleFactor : unscaledMinWidth;
|
|
260
280
|
this.clearContinuationMarkers();
|
|
261
281
|
let currTime = ZERO;
|
|
282
|
+
let prevNoteEndX = 0;
|
|
262
283
|
this.atomViews.forEach((av, index) => {
|
|
263
284
|
const glyphX = totalDur.isZero ? 0 : currTime.timesNum(groupWidth).divby(totalDur).floor;
|
|
264
|
-
|
|
265
|
-
|
|
285
|
+
let realX = glyphX - av.glyphOffset;
|
|
286
|
+
if (realX < prevNoteEndX) {
|
|
287
|
+
realX = prevNoteEndX;
|
|
288
|
+
}
|
|
289
|
+
av.setBounds(realX, currY, null, null, true);
|
|
290
|
+
const avWidth = av.contentWidth || av.bbox.width;
|
|
291
|
+
prevNoteEndX = realX + avWidth;
|
|
266
292
|
if (this.showContinuationMarkers && !totalDur.isZero) {
|
|
267
293
|
const atomDur = av.totalDuration;
|
|
268
294
|
const durValue = atomDur.num / atomDur.den;
|
|
@@ -277,6 +303,7 @@ export class GroupView extends AtomView {
|
|
|
277
303
|
}
|
|
278
304
|
currTime = currTime.plus(av.totalDuration);
|
|
279
305
|
});
|
|
306
|
+
this.contentWidth = prevNoteEndX;
|
|
280
307
|
this.invalidateBounds();
|
|
281
308
|
for (const e of this.embelishments)
|
|
282
309
|
e.refreshLayout();
|