notations 0.0.46 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/beats.d.ts +34 -69
- package/lib/cjs/beats.js +178 -439
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/beatutils.d.ts +3 -0
- package/lib/cjs/beatutils.js +64 -0
- package/lib/cjs/beatutils.js.map +1 -0
- package/lib/cjs/beatview.d.ts +18 -0
- package/lib/cjs/beatview.js +62 -0
- package/lib/cjs/beatview.js.map +1 -0
- package/lib/cjs/carnatic/LineView.d.ts +2 -7
- package/lib/cjs/carnatic/LineView.js +13 -31
- package/lib/cjs/carnatic/LineView.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.d.ts +8 -7
- package/lib/cjs/carnatic/NotationView.js +76 -153
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/atomviews.js +149 -287
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.d.ts +4 -13
- package/lib/cjs/carnatic/beatviews.js +23 -118
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.d.ts +1 -1
- package/lib/cjs/carnatic/embelishments.js +189 -283
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/carnatic/gamakas.js +15 -47
- package/lib/cjs/carnatic/gamakas.js.map +1 -1
- package/lib/cjs/commands.js +111 -271
- package/lib/cjs/commands.js.map +1 -1
- package/lib/cjs/core.d.ts +14 -1
- package/lib/cjs/core.js +291 -477
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.js +175 -367
- package/lib/cjs/cycle.js.map +1 -1
- package/lib/cjs/entity.js +48 -102
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/grids.d.ts +125 -0
- package/lib/cjs/grids.js +550 -0
- package/lib/cjs/grids.js.map +1 -0
- package/lib/cjs/iterators.js +96 -234
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.d.ts +1 -1
- package/lib/cjs/layouts.js +62 -98
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.d.ts +2 -2
- package/lib/cjs/loader.js +23 -123
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.d.ts +0 -3
- package/lib/cjs/notation.js +139 -241
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/parser.d.ts +2 -0
- package/lib/cjs/parser.js +225 -214
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.js +149 -283
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.d.ts +8 -0
- package/lib/cjs/utils.js +60 -55
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/beats.d.ts +34 -69
- package/lib/esm/beats.js +172 -438
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/beatutils.d.ts +3 -0
- package/lib/esm/beatutils.js +37 -0
- package/lib/esm/beatutils.js.map +1 -0
- package/lib/esm/beatview.d.ts +18 -0
- package/lib/esm/beatview.js +35 -0
- package/lib/esm/beatview.js.map +1 -0
- package/lib/esm/carnatic/LineView.d.ts +2 -7
- package/lib/esm/carnatic/LineView.js +12 -31
- package/lib/esm/carnatic/LineView.js.map +1 -1
- package/lib/esm/carnatic/NotationView.d.ts +8 -7
- package/lib/esm/carnatic/NotationView.js +74 -152
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/carnatic/atomviews.js +144 -284
- package/lib/esm/carnatic/atomviews.js.map +1 -1
- package/lib/esm/carnatic/beatviews.d.ts +4 -13
- package/lib/esm/carnatic/beatviews.js +21 -94
- package/lib/esm/carnatic/beatviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.d.ts +1 -1
- package/lib/esm/carnatic/embelishments.js +187 -296
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/carnatic/gamakas.js +14 -48
- package/lib/esm/carnatic/gamakas.js.map +1 -1
- package/lib/esm/commands.js +100 -271
- package/lib/esm/commands.js.map +1 -1
- package/lib/esm/core.d.ts +14 -1
- package/lib/esm/core.js +287 -484
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/cycle.js +172 -367
- package/lib/esm/cycle.js.map +1 -1
- package/lib/esm/entity.js +48 -104
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/grids.d.ts +125 -0
- package/lib/esm/grids.js +517 -0
- package/lib/esm/grids.js.map +1 -0
- package/lib/esm/iterators.js +93 -235
- package/lib/esm/iterators.js.map +1 -1
- package/lib/esm/layouts.d.ts +1 -1
- package/lib/esm/layouts.js +60 -97
- package/lib/esm/layouts.js.map +1 -1
- package/lib/esm/loader.d.ts +2 -2
- package/lib/esm/loader.js +20 -120
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.d.ts +0 -3
- package/lib/esm/notation.js +135 -242
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/parser.d.ts +2 -0
- package/lib/esm/parser.js +220 -210
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.js +148 -288
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/utils.d.ts +8 -0
- package/lib/esm/utils.js +55 -51
- package/lib/esm/utils.js.map +1 -1
- package/package.json +18 -17
package/lib/cjs/cycle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cycle.js","sourceRoot":"","sources":["../../src/cycle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,mCAA+C;AAS/C,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC;IACE,qB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entity, TimedEntity } from \"./entity\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nexport type CyclePosition = [number, number, number];\nexport type CycleIterator = Generator<[CyclePosition, Fraction]>;\n\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class CycleCursor {\n constructor(public readonly cycle: Cycle, public barIndex = 0, public beatIndex = 0, public instance = 0) {}\n\n get next(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n this.instance++;\n if (!currBar.beatCounts[this.beatIndex] || this.instance >= currBar.beatCounts[this.beatIndex]) {\n this.instance = 0;\n this.beatIndex++;\n if (this.beatIndex >= currBar.beatLengths.length) {\n this.beatIndex = 0;\n this.barIndex++;\n if (this.barIndex >= this.cycle.bars.length) {\n this.barIndex = 0;\n }\n }\n }\n return result;\n }\n\n get prev(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n // TODO - result should be set *after* decrementing if we had already\n // done a \"next\" before this otherwise user may have to do a prev twice\n this.instance--;\n if (this.instance < 0) {\n this.beatIndex--;\n if (this.beatIndex < 0) {\n this.barIndex--;\n if (this.barIndex < 0) {\n this.barIndex = this.cycle.bars.length - 1;\n }\n this.beatIndex = this.cycle.bars[this.barIndex].beatCount - 1;\n }\n this.instance = (this.cycle.bars[this.barIndex].beatCounts[this.beatIndex] || 1) - 1;\n }\n return result;\n }\n}\n\nexport class Bar extends TimedEntity {\n name: string;\n // Length/Duration of each beat.\n beatLengths: Fraction[] = [];\n\n // How many times should a beat be repeated - the Kalai!\n beatCounts: number[] = [];\n\n constructor(config: any = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n for (const bl of config.beatLengths || []) {\n if (typeof bl === \"number\") {\n this.beatLengths.push(TSU.Num.Frac(bl));\n } else {\n this.beatLengths.push(bl);\n }\n }\n for (const bc of config.beatCounts || []) {\n this.beatCounts.push(bc);\n }\n while (this.beatCounts.length < this.beatLengths.length) {\n this.beatCounts.push(1);\n }\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, beatLengths: this.beatLengths };\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) return false;\n if (this.beatLengths.length != another.beatLengths.length) return false;\n if (this.beatCounts.length != another.beatCounts.length) return false;\n for (let i = 0; i < this.beatLengths.length; i++) {\n if (!this.beatLengths[i].equals(another.beatLengths[i])) return false;\n }\n for (let i = 0; i < this.beatCounts.length; i++) {\n if (this.beatCounts[i] != another.beatCounts[i]) return false;\n }\n return true;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.beatLengths = [...this.beatLengths];\n another.beatCounts = [...this.beatCounts];\n }\n\n instanceCount(beatIndex: number): number {\n if (beatIndex > this.beatCounts.length) {\n // by default each beat has 1 instance?\n return 1;\n } else {\n return this.beatCounts[beatIndex];\n }\n }\n\n get beatCount(): number {\n return this.beatLengths.length;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (let i = 0; i < this.beatLengths.length; i++) {\n out += this.beatCounts[i] || 1;\n }\n return out;\n }\n\n /**\n * Total duration (of time) across all beats in this bar.\n */\n get duration(): Fraction {\n let total = ZERO;\n for (let i = 0; i < this.beatLengths.length; i++) {\n total = total.plus(this.beatLengths[i].timesNum(this.beatCounts[i] || 1));\n }\n return total;\n }\n}\n\n// Describes the cycle pattern\nexport class Cycle extends TimedEntity {\n name: string;\n bars: Bar[];\n\n static readonly DEFAULT = new Cycle({\n name: \"Adi Thalam\",\n bars: [\n new Bar({ name: \"Laghu\", beatLengths: [1, 1, 1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n ],\n });\n\n constructor(config: null | { name?: string; bars?: Bar[] } = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n this.bars = config.bars || [];\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, bars: this.bars.map((p) => p.debugValue()) };\n }\n\n children(): Entity[] {\n return this.bars;\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) {\n return false;\n }\n if (this.bars.length != another.bars.length) return false;\n for (let i = 0; i < this.bars.length; i++) {\n if (!this.bars[i].equals(another.bars[i])) return false;\n }\n return true;\n }\n\n /**\n * Given a global beat index returns four values [cycle,bar,beat,instance] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global beat\n * index can be greater the number of beats in this cycle this\n * allows us to wrap around. Similarly if beatindex is less than\n * 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the\n * offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - Offset of the beat at this global index.\n */\n getAtIndex(globalIndex: number): [number, CyclePosition, Fraction] {\n let cycle = 0;\n while (globalIndex < 0) {\n globalIndex += this.totalBeatCount;\n cycle--;\n }\n if (globalIndex >= this.totalBeatCount) {\n cycle = Math.floor(globalIndex / this.totalBeatCount);\n }\n globalIndex = globalIndex % this.totalBeatCount;\n let offset = ZERO;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n if (globalIndex >= bar.totalBeatCount) {\n globalIndex -= bar.totalBeatCount;\n offset = offset.plus(bar.duration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n if (globalIndex >= beatCount) {\n globalIndex -= beatCount;\n offset = offset.plus(beatLength.timesNum(beatCount));\n } else {\n // this is it\n const instance = globalIndex;\n return [cycle, [barIndex, beatIndex, instance], offset.plus(beatLength.timesNum(instance))];\n }\n }\n }\n }\n throw new Error(\"Should not be here!\");\n }\n\n /**\n * Given a global offset returns five values [cycle, bar,beat,instance,offset] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global offset can be\n * greater the duration of the cycle this allows us to wrap around.\n * Similarly if globalOffset is less than 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - The note offset within the beat where the global offset lies.\n * globalIndex - The beat index within the entire cycle and not just within the bar.\n */\n getPosition(globalOffset: Fraction): [number, CyclePosition, Fraction, number] {\n const duration = this.duration;\n let cycleNum = 0;\n if (globalOffset.isLT(ZERO)) {\n while (globalOffset.isLT(ZERO)) {\n cycleNum--;\n globalOffset = globalOffset.plus(duration);\n }\n } else if (globalOffset.isGTE(duration)) {\n const realOffset = globalOffset.mod(duration);\n globalOffset = globalOffset.minus(realOffset).divby(duration);\n TSU.assert(globalOffset.isWhole);\n cycleNum = globalOffset.floor;\n globalOffset = realOffset;\n }\n\n // here globalOffset is positive and >= 0 and < this.duration\n let globalIndex = 0;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n const barDuration = bar.duration;\n if (globalOffset.isGTE(barDuration)) {\n globalOffset = globalOffset.minus(barDuration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n for (let instance = 0; instance < beatCount; instance++, globalIndex++) {\n if (globalOffset.isGTE(beatLength)) {\n globalOffset = globalOffset.minus(beatLength);\n } else {\n // this is it\n return [cycleNum, [barIndex, beatIndex, instance], globalOffset, globalIndex];\n }\n }\n }\n }\n globalIndex += bar.totalBeatCount;\n }\n\n throw new Error(\"Should not be here!\");\n }\n\n *iterateBeats(startBar = 0, startBeat = 0, startInstance = 0): CycleIterator {\n let barIndex = startBar;\n let beatIndex = startBeat;\n let instanceIndex = startInstance;\n while (true) {\n const currBar = this.bars[barIndex];\n yield [[barIndex, beatIndex, instanceIndex], currBar.beatLengths[beatIndex]];\n instanceIndex++;\n if (!currBar.beatCounts[beatIndex] || instanceIndex >= currBar.beatCounts[beatIndex]) {\n instanceIndex = 0;\n beatIndex++;\n if (beatIndex >= currBar.beatLengths.length) {\n beatIndex = 0;\n barIndex++;\n if (barIndex >= this.bars.length) {\n barIndex = 0;\n }\n }\n }\n }\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.bars = this.bars.map((x) => x.clone());\n }\n\n get beatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.beatCount;\n return out;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.totalBeatCount;\n return out;\n }\n\n /**\n * Total duration (of time) across all bars in this cycle.\n */\n get duration(): Fraction {\n return this.bars.reduce((x, y) => x.plus(y.duration), ZERO);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cycle.js","sourceRoot":"","sources":["../../src/cycle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,qCAA+C;AAS/C,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC,MAAa,WAAW;IACtB,YAA4B,KAAY,EAAS,WAAW,CAAC,EAAS,YAAY,CAAC,EAAS,WAAW,CAAC;QAA5E,UAAK,GAAL,KAAK,CAAO;QAAS,aAAQ,GAAR,QAAQ,CAAI;QAAS,cAAS,GAAT,SAAS,CAAI;QAAS,aAAQ,GAAR,QAAQ,CAAI;IAAG,CAAC;IAE5G,IAAI,IAAI;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,MAAM,G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CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QACjD,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;KAClD;CACF,CAAC,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nexport type CyclePosition = [number, number, number];\nexport type CycleIterator = Generator<[CyclePosition, Fraction]>;\n\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class CycleCursor {\n constructor(public readonly cycle: Cycle, public barIndex = 0, public beatIndex = 0, public instance = 0) {}\n\n get next(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n this.instance++;\n if (!currBar.beatCounts[this.beatIndex] || this.instance >= currBar.beatCounts[this.beatIndex]) {\n this.instance = 0;\n this.beatIndex++;\n if (this.beatIndex >= currBar.beatLengths.length) {\n this.beatIndex = 0;\n this.barIndex++;\n if (this.barIndex >= this.cycle.bars.length) {\n this.barIndex = 0;\n }\n }\n }\n return result;\n }\n\n get prev(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n // TODO - result should be set *after* decrementing if we had already\n // done a \"next\" before this otherwise user may have to do a prev twice\n this.instance--;\n if (this.instance < 0) {\n this.beatIndex--;\n if (this.beatIndex < 0) {\n this.barIndex--;\n if (this.barIndex < 0) {\n this.barIndex = this.cycle.bars.length - 1;\n }\n this.beatIndex = this.cycle.bars[this.barIndex].beatCount - 1;\n }\n this.instance = (this.cycle.bars[this.barIndex].beatCounts[this.beatIndex] || 1) - 1;\n }\n return result;\n }\n}\n\nexport class Bar extends TimedEntity {\n name: string;\n // Length/Duration of each beat.\n beatLengths: Fraction[] = [];\n\n // How many times should a beat be repeated - the Kalai!\n beatCounts: number[] = [];\n\n constructor(config: any = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n for (const bl of config.beatLengths || []) {\n if (typeof bl === \"number\") {\n this.beatLengths.push(TSU.Num.Frac(bl));\n } else {\n this.beatLengths.push(bl);\n }\n }\n for (const bc of config.beatCounts || []) {\n this.beatCounts.push(bc);\n }\n while (this.beatCounts.length < this.beatLengths.length) {\n this.beatCounts.push(1);\n }\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, beatLengths: this.beatLengths };\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) return false;\n if (this.beatLengths.length != another.beatLengths.length) return false;\n if (this.beatCounts.length != another.beatCounts.length) return false;\n for (let i = 0; i < this.beatLengths.length; i++) {\n if (!this.beatLengths[i].equals(another.beatLengths[i])) return false;\n }\n for (let i = 0; i < this.beatCounts.length; i++) {\n if (this.beatCounts[i] != another.beatCounts[i]) return false;\n }\n return true;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.beatLengths = [...this.beatLengths];\n another.beatCounts = [...this.beatCounts];\n }\n\n instanceCount(beatIndex: number): number {\n if (beatIndex > this.beatCounts.length) {\n // by default each beat has 1 instance?\n return 1;\n } else {\n return this.beatCounts[beatIndex];\n }\n }\n\n get beatCount(): number {\n return this.beatLengths.length;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (let i = 0; i < this.beatLengths.length; i++) {\n out += this.beatCounts[i] || 1;\n }\n return out;\n }\n\n /**\n * Total duration (of time) across all beats in this bar.\n */\n get duration(): Fraction {\n let total = ZERO;\n for (let i = 0; i < this.beatLengths.length; i++) {\n total = total.plus(this.beatLengths[i].timesNum(this.beatCounts[i] || 1));\n }\n return total;\n }\n}\n\n// Describes the cycle pattern\nexport class Cycle extends TimedEntity {\n name: string;\n bars: Bar[];\n\n static readonly DEFAULT = new Cycle({\n name: \"Adi Thalam\",\n bars: [\n new Bar({ name: \"Laghu\", beatLengths: [1, 1, 1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n ],\n });\n\n constructor(config: null | { name?: string; bars?: Bar[] } = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n this.bars = config.bars || [];\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, bars: this.bars.map((p) => p.debugValue()) };\n }\n\n children(): Entity[] {\n return this.bars;\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) {\n return false;\n }\n if (this.bars.length != another.bars.length) return false;\n for (let i = 0; i < this.bars.length; i++) {\n if (!this.bars[i].equals(another.bars[i])) return false;\n }\n return true;\n }\n\n /**\n * Given a global beat index returns four values [cycle,bar,beat,instance] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global beat\n * index can be greater the number of beats in this cycle this\n * allows us to wrap around. Similarly if beatindex is less than\n * 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the\n * offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - Offset of the beat at this global index.\n */\n getAtIndex(globalIndex: number): [number, CyclePosition, Fraction] {\n let cycle = 0;\n while (globalIndex < 0) {\n globalIndex += this.totalBeatCount;\n cycle--;\n }\n if (globalIndex >= this.totalBeatCount) {\n cycle = Math.floor(globalIndex / this.totalBeatCount);\n }\n globalIndex = globalIndex % this.totalBeatCount;\n let offset = ZERO;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n if (globalIndex >= bar.totalBeatCount) {\n globalIndex -= bar.totalBeatCount;\n offset = offset.plus(bar.duration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n if (globalIndex >= beatCount) {\n globalIndex -= beatCount;\n offset = offset.plus(beatLength.timesNum(beatCount));\n } else {\n // this is it\n const instance = globalIndex;\n return [cycle, [barIndex, beatIndex, instance], offset.plus(beatLength.timesNum(instance))];\n }\n }\n }\n }\n throw new Error(\"Should not be here!\");\n }\n\n /**\n * Given a global offset returns five values [cycle, bar,beat,instance,offset] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global offset can be\n * greater the duration of the cycle this allows us to wrap around.\n * Similarly if globalOffset is less than 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - The note offset within the beat where the global offset lies.\n * globalIndex - The beat index within the entire cycle and not just within the bar.\n */\n getPosition(globalOffset: Fraction): [number, CyclePosition, Fraction, number] {\n const duration = this.duration;\n let cycleNum = 0;\n if (globalOffset.isLT(ZERO)) {\n while (globalOffset.isLT(ZERO)) {\n cycleNum--;\n globalOffset = globalOffset.plus(duration);\n }\n } else if (globalOffset.isGTE(duration)) {\n const realOffset = globalOffset.mod(duration);\n globalOffset = globalOffset.minus(realOffset).divby(duration);\n TSU.assert(globalOffset.isWhole);\n cycleNum = globalOffset.floor;\n globalOffset = realOffset;\n }\n\n // here globalOffset is positive and >= 0 and < this.duration\n let globalIndex = 0;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n const barDuration = bar.duration;\n if (globalOffset.isGTE(barDuration)) {\n globalOffset = globalOffset.minus(barDuration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n for (let instance = 0; instance < beatCount; instance++, globalIndex++) {\n if (globalOffset.isGTE(beatLength)) {\n globalOffset = globalOffset.minus(beatLength);\n } else {\n // this is it\n return [cycleNum, [barIndex, beatIndex, instance], globalOffset, globalIndex];\n }\n }\n }\n }\n globalIndex += bar.totalBeatCount;\n }\n\n throw new Error(\"Should not be here!\");\n }\n\n *iterateBeats(startBar = 0, startBeat = 0, startInstance = 0): CycleIterator {\n let barIndex = startBar;\n let beatIndex = startBeat;\n let instanceIndex = startInstance;\n while (true) {\n const currBar = this.bars[barIndex];\n yield [[barIndex, beatIndex, instanceIndex], currBar.beatLengths[beatIndex]];\n instanceIndex++;\n if (!currBar.beatCounts[beatIndex] || instanceIndex >= currBar.beatCounts[beatIndex]) {\n instanceIndex = 0;\n beatIndex++;\n if (beatIndex >= currBar.beatLengths.length) {\n beatIndex = 0;\n barIndex++;\n if (barIndex >= this.bars.length) {\n barIndex = 0;\n }\n }\n }\n }\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.bars = this.bars.map((x) => x.clone());\n }\n\n get beatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.beatCount;\n return out;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.totalBeatCount;\n return out;\n }\n\n /**\n * Total duration (of time) across all bars in this cycle.\n */\n get duration(): Fraction {\n return this.bars.reduce((x, y) => x.plus(y.duration), ZERO);\n }\n}\n"]}
|
package/lib/cjs/entity.js
CHANGED
|
@@ -1,55 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __values = (this && this.__values) || function(o) {
|
|
18
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
19
|
-
if (m) return m.call(o);
|
|
20
|
-
if (o && typeof o.length === "number") return {
|
|
21
|
-
next: function () {
|
|
22
|
-
if (o && i >= o.length) o = void 0;
|
|
23
|
-
return { value: o && o[i++], done: !o };
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
27
|
-
};
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
exports.TimedEntity = exports.Entity = void 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (config === void 0) { config = null; }
|
|
4
|
+
class Entity {
|
|
5
|
+
constructor(config = null) {
|
|
33
6
|
this.uuid = Entity.counter++;
|
|
34
7
|
config = config || {};
|
|
35
8
|
if (config.metadata)
|
|
36
9
|
throw new Error("See where metadata is being passed");
|
|
37
10
|
}
|
|
38
|
-
|
|
11
|
+
debugValue() {
|
|
39
12
|
return { type: this.type };
|
|
40
|
-
}
|
|
41
|
-
|
|
13
|
+
}
|
|
14
|
+
children() {
|
|
42
15
|
return [];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
enumerable: false,
|
|
49
|
-
configurable: true
|
|
50
|
-
});
|
|
51
|
-
Entity.prototype.addChild = function (child, index) {
|
|
52
|
-
if (index === void 0) { index = -1; }
|
|
16
|
+
}
|
|
17
|
+
get childCount() {
|
|
18
|
+
return this.children().length;
|
|
19
|
+
}
|
|
20
|
+
addChild(child, index = -1) {
|
|
53
21
|
if (index < 0) {
|
|
54
22
|
this.children().push(child);
|
|
55
23
|
}
|
|
@@ -57,79 +25,57 @@ var Entity = (function () {
|
|
|
57
25
|
this.children().splice(index, 0, child);
|
|
58
26
|
}
|
|
59
27
|
return this;
|
|
60
|
-
}
|
|
61
|
-
|
|
28
|
+
}
|
|
29
|
+
childAt(index) {
|
|
62
30
|
return this.children()[index];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (child == entity)
|
|
71
|
-
return i;
|
|
72
|
-
i++;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
76
|
-
finally {
|
|
77
|
-
try {
|
|
78
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
79
|
-
}
|
|
80
|
-
finally { if (e_1) throw e_1.error; }
|
|
31
|
+
}
|
|
32
|
+
indexOfChild(entity) {
|
|
33
|
+
let i = 0;
|
|
34
|
+
for (const child of this.children()) {
|
|
35
|
+
if (child == entity)
|
|
36
|
+
return i;
|
|
37
|
+
i++;
|
|
81
38
|
}
|
|
82
39
|
return -1;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
40
|
+
}
|
|
41
|
+
removeChildAt(index) {
|
|
42
|
+
const children = this.children();
|
|
43
|
+
const out = children[index];
|
|
87
44
|
children.splice(index, 1);
|
|
88
45
|
return out;
|
|
89
|
-
}
|
|
90
|
-
|
|
46
|
+
}
|
|
47
|
+
setChildAt(index, entity) {
|
|
91
48
|
this.children()[index] = entity;
|
|
92
49
|
return this;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Entity.prototype.toString = function () {
|
|
102
|
-
return "Entity(id = ".concat(this.uuid, ")");
|
|
103
|
-
};
|
|
104
|
-
Entity.prototype.equals = function (another, expect) {
|
|
105
|
-
if (expect === void 0) { expect = false; }
|
|
50
|
+
}
|
|
51
|
+
get type() {
|
|
52
|
+
return this.constructor.name;
|
|
53
|
+
}
|
|
54
|
+
toString() {
|
|
55
|
+
return `Entity(id = ${this.uuid})`;
|
|
56
|
+
}
|
|
57
|
+
equals(another, expect = false) {
|
|
106
58
|
if (this.type != another.type)
|
|
107
59
|
return false;
|
|
108
60
|
return true;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
61
|
+
}
|
|
62
|
+
clone() {
|
|
63
|
+
const out = this.newInstance();
|
|
112
64
|
this.copyTo(out);
|
|
113
65
|
return out;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
66
|
+
}
|
|
67
|
+
copyTo(another) {
|
|
68
|
+
}
|
|
69
|
+
newInstance() {
|
|
118
70
|
return new this.constructor();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return Entity;
|
|
122
|
-
}());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
123
73
|
exports.Entity = Entity;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return _super.prototype.equals.call(this, another) && this.duration.equals(another.duration);
|
|
131
|
-
};
|
|
132
|
-
return TimedEntity;
|
|
133
|
-
}(Entity));
|
|
74
|
+
Entity.counter = 0;
|
|
75
|
+
class TimedEntity extends Entity {
|
|
76
|
+
equals(another) {
|
|
77
|
+
return super.equals(another) && this.duration.equals(another.duration);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
134
80
|
exports.TimedEntity = TimedEntity;
|
|
135
81
|
//# sourceMappingURL=entity.js.map
|
package/lib/cjs/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":"","s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AQ,CAAC,KAAK,CAAC,CAAC;QAC5B,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC1B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,UAAU,CAAC,KAAa,EAAE,MAAc;QACtC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAwBD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAKD,QAAQ;QACN,OAAO,eAAe,IAAI,CAAC,IAAI,GAAG,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAa,EAAE,MAAM,GAAG,KAAK;QAClC,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QAE5C,OAAO,IAAI,CAAC;IACd,CAAC;IAYD,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;IAKD,MAAM,CAAC,OAAa;IAEpB,CAAC;IAKS,WAAW;QACnB,OAAO,IAAK,IAAI,CAAC,WAAmB,EAAE,CAAC;IACzC,CAAC;;AArJH,wBAsJC;AArJgB,cAAO,GAAG,CAAC,CAAC;AA2J7B,MAAsB,WAAY,SAAQ,MAAM;IAO9C,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;AAVD,kCAUC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\n\n/**\n * A common Entity base class with support for unique IDs, copying, children and\n * debug info.\n */\nexport class Entity {\n private static counter = 0;\n readonly uuid = Entity.counter++;\n // private metadata: TSU.StringMap<any>;\n // parent: TSU.Nullable<Entity> = null;\n\n constructor(config: any = null) {\n config = config || {};\n if (config.metadata) throw new Error(\"See where metadata is being passed\");\n // this.metadata = config.metadata || {};\n }\n\n /**\n * debugValue returns information about this entity to be printed during a debug.\n * Usually overridden by children to add more debug info.\n */\n debugValue(): any {\n // if (Object.keys(this.metadata).length > 0) return { metadata: this.metadata, type: this.type };\n return { type: this.type };\n }\n\n /**\n * Children of this entity.\n */\n children(): Entity[] {\n return [];\n }\n\n /**\n * Property returning the count of child entities.\n */\n get childCount(): number {\n return this.children().length;\n }\n\n /**\n * Adds a child entity at a given index.\n * @param child Child entity to be aded.\n * @param index Index where the child is to be inserted. -1 to append at the end.\n */\n addChild(child: Entity, index = -1): this {\n if (index < 0) {\n this.children().push(child);\n } else {\n this.children().splice(index, 0, child);\n }\n return this;\n }\n\n /**\n * Returns the child at a given index.\n */\n childAt(index: number): Entity {\n return this.children()[index];\n }\n\n /**\n * Returns the index of a given child entity.\n *\n * @return the index where child exists otherwise -1.\n */\n indexOfChild(entity: Entity): number {\n let i = 0;\n for (const child of this.children()) {\n if (child == entity) return i;\n i++;\n }\n return -1;\n }\n\n removeChildAt(index: number): Entity {\n const children = this.children();\n const out = children[index];\n children.splice(index, 1);\n return out;\n }\n\n setChildAt(index: number, entity: Entity): this {\n this.children()[index] = entity;\n return this;\n }\n\n /*\n setMetadata(key: string, value: any): this {\n this.metadata[key] = value;\n return this;\n }\n\n getMetadata(key: string, recurse = true): any {\n if (key in this.metadata) {\n return this.metadata[key];\n }\n if (recurse && this.parent) {\n return this.parent.getMetadata(key);\n }\n return null;\n }\n */\n\n /**\n * Returns the type of this Entity.\n *\n * Type properties are used to identify the class type of Entities.\n */\n get type(): unknown {\n return this.constructor.name;\n }\n\n /**\n * Simple string representation of this Entity.\n */\n toString(): string {\n return `Entity(id = ${this.uuid})`;\n }\n\n equals(another: this, expect = false): boolean {\n if (this.type != another.type) return false;\n // check metadata too\n return true;\n }\n\n /**\n * All entities allow cloning in a way that is specific to the entity.\n * This allows application level \"copy/pasting\" of entities. Cloning\n * is a two part process:\n *\n * * Creation of a new instance of the same type via this.newInstance()\n * * Copying of data into the new instance.\n *\n * Both of these can be overridden.\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 */\n copyTo(another: this): void {\n // another.metadata = { ...this.metadata };\n }\n\n /**\n * First part of the cloning process where the instance is created.\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.\n */\nexport abstract class TimedEntity extends Entity {\n /**\n * Duration of this entity in beats.\n * By default entities durations are readonly\n */\n abstract get duration(): TSU.Num.Fraction;\n\n equals(another: this): boolean {\n return super.equals(another) && this.duration.equals(another.duration);\n }\n}\n"]}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as TSU from "@panyam/tsutils";
|
|
2
|
+
export declare class GridModel extends TSU.Events.EventEmitter {
|
|
3
|
+
private static idCounter;
|
|
4
|
+
readonly uuid: number;
|
|
5
|
+
lastUpdatedAt: number;
|
|
6
|
+
rows: GridRow[];
|
|
7
|
+
rowAligns: Map<number, RowAlign>;
|
|
8
|
+
colAligns: Map<number, ColAlign>;
|
|
9
|
+
debugValue(): any;
|
|
10
|
+
get firstRow(): number;
|
|
11
|
+
get firstCol(): number;
|
|
12
|
+
cellsInRow(row: number): GridCell[];
|
|
13
|
+
cellsInCol(col: number): GridCell[];
|
|
14
|
+
addRowAlign(align: RowAlign): void;
|
|
15
|
+
addColAlign(align: ColAlign): void;
|
|
16
|
+
addRows(insertBefore?: number, numRows?: number): this;
|
|
17
|
+
getRow(row: number): GridRow;
|
|
18
|
+
setValue(row: number, col: number, value: any, cellCreator?: (row: GridRow, col: number) => GridCell): any;
|
|
19
|
+
protected eventHubChanged(): void;
|
|
20
|
+
}
|
|
21
|
+
export interface GridCellView {
|
|
22
|
+
readonly cell: GridCell;
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
setBounds(x: number | null, y: number | null, w: number | null, h: number | null, applyLayout: boolean): [number | null, number | null, number | null, number | null];
|
|
28
|
+
readonly needsLayout: boolean;
|
|
29
|
+
readonly minSize: TSU.Geom.Size;
|
|
30
|
+
readonly bbox: TSU.Geom.Rect;
|
|
31
|
+
}
|
|
32
|
+
export declare enum GridCellEvent {
|
|
33
|
+
ADDED = "CellAdded",
|
|
34
|
+
CLEARED = "CellCleared",
|
|
35
|
+
REMOVED = "CellRemoved",
|
|
36
|
+
UPDATED = "CellUpdated",
|
|
37
|
+
MOVED = "CellMoved"
|
|
38
|
+
}
|
|
39
|
+
export declare class GridCell {
|
|
40
|
+
gridRow: GridRow;
|
|
41
|
+
colIndex: number;
|
|
42
|
+
value: any;
|
|
43
|
+
private static idCounter;
|
|
44
|
+
readonly uuid: number;
|
|
45
|
+
cellView: GridCellView | null;
|
|
46
|
+
private _rowAlign;
|
|
47
|
+
private _colAlign;
|
|
48
|
+
constructor(gridRow: GridRow, colIndex: number, value?: any);
|
|
49
|
+
get rowAlign(): RowAlign;
|
|
50
|
+
set rowAlign(val: RowAlign);
|
|
51
|
+
get colAlign(): ColAlign;
|
|
52
|
+
set colAlign(val: ColAlign);
|
|
53
|
+
get location(): string;
|
|
54
|
+
get grid(): GridModel;
|
|
55
|
+
get rowIndex(): number;
|
|
56
|
+
debugValue(): any;
|
|
57
|
+
}
|
|
58
|
+
export declare class GridRow {
|
|
59
|
+
grid: GridModel;
|
|
60
|
+
rowIndex: number;
|
|
61
|
+
cells: (null | GridCell)[];
|
|
62
|
+
defaultRowAlign: RowAlign;
|
|
63
|
+
constructor(grid: GridModel, rowIndex: number);
|
|
64
|
+
get firstCol(): number;
|
|
65
|
+
get numCols(): number;
|
|
66
|
+
get numCells(): number;
|
|
67
|
+
cellAt(col: number, creator?: (row: GridRow, col: number) => GridCell): GridCell | null;
|
|
68
|
+
clearCellAt(col: number): GridCell | null;
|
|
69
|
+
debugValue(): {
|
|
70
|
+
r: number;
|
|
71
|
+
cells: any[];
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export declare abstract class AlignedLine {
|
|
75
|
+
private static idCounter;
|
|
76
|
+
readonly uuid: number;
|
|
77
|
+
needsLayout: boolean;
|
|
78
|
+
protected _coordOffset: number;
|
|
79
|
+
protected _maxLength: number;
|
|
80
|
+
paddingBefore: number;
|
|
81
|
+
paddingAfter: number;
|
|
82
|
+
cells: GridCell[];
|
|
83
|
+
getCellView: (value: any) => GridCellView;
|
|
84
|
+
abstract setOffset(val: number): void;
|
|
85
|
+
abstract evalMaxLength(changedCells: GridCell[]): number;
|
|
86
|
+
get coordOffset(): number;
|
|
87
|
+
get maxLength(): number;
|
|
88
|
+
setMaxLength(length: number): void;
|
|
89
|
+
setPadding(before: number, after: number): void;
|
|
90
|
+
addCell(cell: GridCell): this;
|
|
91
|
+
protected abstract beforeAddingCell(cell: GridCell): boolean;
|
|
92
|
+
removeCell(cell: GridCell): this;
|
|
93
|
+
protected abstract beforeRemovingCell(cell: GridCell): boolean;
|
|
94
|
+
prevLines: this[];
|
|
95
|
+
nextLines: this[];
|
|
96
|
+
addSuccessor(next: this): void;
|
|
97
|
+
}
|
|
98
|
+
export declare class ColAlign extends AlignedLine {
|
|
99
|
+
setOffset(val: number): void;
|
|
100
|
+
evalMaxLength(changedCells?: GridCell[]): number;
|
|
101
|
+
protected beforeAddingCell(cell: GridCell): boolean;
|
|
102
|
+
beforeRemovingCell(cell: GridCell): boolean;
|
|
103
|
+
}
|
|
104
|
+
export declare class RowAlign extends AlignedLine {
|
|
105
|
+
setOffset(val: number): void;
|
|
106
|
+
evalMaxLength(changedCells?: GridCell[]): number;
|
|
107
|
+
protected beforeAddingCell(cell: GridCell): boolean;
|
|
108
|
+
beforeRemovingCell(cell: GridCell): boolean;
|
|
109
|
+
}
|
|
110
|
+
export declare class GridLayoutGroup {
|
|
111
|
+
gridModels: GridModel[];
|
|
112
|
+
private eventHandler;
|
|
113
|
+
addGridModel(gridModel: GridModel): boolean;
|
|
114
|
+
startingRowAligns(): RowAlign[];
|
|
115
|
+
startingColAligns(): ColAlign[];
|
|
116
|
+
removeGridModel(gridModel: GridModel): void;
|
|
117
|
+
getCellView: (cell: GridCell) => GridCellView;
|
|
118
|
+
get startingRows(): RowAlign[];
|
|
119
|
+
get startingCols(): ColAlign[];
|
|
120
|
+
refreshLayout(): void;
|
|
121
|
+
protected applyModelEvents(events: TSU.Events.TEvent[]): void;
|
|
122
|
+
protected changesForEvents(events: TSU.Events.TEvent[]): [any, any];
|
|
123
|
+
protected ensureGetCellView(align: AlignedLine): ((value: any) => GridCellView) | null;
|
|
124
|
+
protected doBfsLayout<T extends AlignedLine>(startingLines: T[], changedAligns: any): void;
|
|
125
|
+
}
|