notations 0.0.48 → 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 +73 -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 +6 -1
- package/lib/cjs/core.js +288 -493
- 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 +124 -1
- package/lib/cjs/grids.js +546 -6
- package/lib/cjs/grids.js.map +1 -1
- 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 +217 -219
- 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 +71 -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 +6 -1
- package/lib/esm/core.js +286 -502
- 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 +124 -1
- package/lib/esm/grids.js +515 -5
- package/lib/esm/grids.js.map +1 -1
- 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 +211 -214
- 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 +2 -1
package/lib/esm/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAY,QAAQ,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAE3E;IAAkC,gCAAO;IAAzC;;IASA,CAAC;IARC,sBAAI,qCAAW;aAAf;YACE,OAAO,IAAI,CAAC,UAA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SU from \"@panyam/tsutils\";\nimport { Atom } from \"./core\";\nimport { parseCycle } from \"./utils\";\nimport { Command, RawBlock, Notation, MetaData as Meta } from \"./notation\";\n\nexport class RawEmbedding extends Command {\n get rawContents(): string {\n return this.getParamAt(0);\n }\n\n applyToNotation(notation: Notation): void {\n const raw = new RawBlock(this.rawContents);\n notation.addRawBlock(raw);\n }\n}\n\nexport class MetaData extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.addMetaData(this.meta);\n }\n\n get meta(): Meta {\n const out = new Meta(this.key, this.value);\n return out;\n }\n\n get key(): string {\n return this.getParamAt(0);\n }\n\n get value(): string {\n return this.getParamAt(1);\n }\n}\n\nexport class ActivateRole extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.setCurrRole(this.roleName);\n // const line = notation.ensureLine();\n }\n\n get roleName(): string {\n return this.getParamAt(0);\n }\n}\n\nexport class AddAtoms extends Command {\n index: number;\n atoms: Atom[];\n\n constructor(...atoms: Atom[]) {\n super();\n this.atoms = atoms;\n this.index = 0;\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n atoms: this.atoms.map((a) => a.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n let roleDef = notation.currRoleDef;\n if (roleDef == null) {\n // By default create a role for swaras\n roleDef = notation.newRoleDef(\"Sw\", true);\n // throw new Error(\"Current role is invalid\");\n }\n // Ensure a line exists\n const lpForLine = notation.layoutParamsForLine(notation.currentLine);\n if (lpForLine == null) {\n notation.setLayoutParamsForLine(notation.currentLine, notation.layoutParams);\n } else {\n TSU.assert(\n lpForLine == notation.layoutParams,\n \"Layout parameters have changed so a new line should have been started\",\n );\n }\n const finalised = this.atoms;\n notation.currentLine.addAtoms(roleDef.name, roleDef.notesOnly, ...finalised);\n }\n}\n\nexport class CreateLine extends Command {\n applyToNotation(notation: Notation): void {\n // We are not calling a newLine here just to avoid\n // a series of \\line commands creating wasteful empty lines\n // TODO - how do we consider offsets in line create\n const line = notation.newLine();\n line.offset = this.offset;\n line.marginText = this.marginText;\n }\n\n get offset(): TSU.Num.Fraction {\n let offset = this.getParam(\"offset\") || TSU.Num.Fraction.ZERO;\n if (typeof offset === \"number\") offset = new TSU.Num.Fraction(offset);\n return offset;\n }\n\n get marginText(): string {\n if (this.params.length > 0) {\n if (this.params[0].key == null && typeof this.params[0].value === \"string\") {\n return this.params[0].value.trim();\n }\n }\n return this.getParam(\"marginText\") || \"\";\n }\n}\n\nexport class CreateRole extends Command {\n applyToNotation(notation: Notation): void {\n // Create the role\n const name = this.getParamAt(0);\n notation.newRoleDef(name, this.notesOnly);\n }\n\n get notesOnly(): boolean {\n const notesOnly = this.getParam(\"notes\");\n return notesOnly == \"true\" || notesOnly == \"yes\" || notesOnly == true;\n }\n}\n\nexport abstract class LayoutParamCommand extends Command {}\n\n/**\n * Saves the current layout with the given name.\n * Typically users can change layout params (currently cycle, APB and line layout)\n * with the \\cycle, \\layout and \\beatDuration commands. Each time these are\n * changed, the current layout params is set to null. So the next time layout\n * params are needed we look at saved layout params and search by by the unique\n * combination of cycle, apb and line layout. This prevetns users from creating\n * too many layouts with the same config. Each layout is associated with an\n * AtomLayout instance.\n *\n * For example consider this:\n *\n * \\apb(4)\n * \\breaks(4)\n * \\cycle(\"|4|2|2|\")\n * \\apb(5)\n * \\breaks(3)\n *\n * In all these cases LayoutParams are *not* created. Instead they are reset to null.\n *\n *\n * When we do an AddAtoms command, this is where a LineView is created and along with this\n * a layoutParams is created taking the latest state of the layout params resulting an\n * LP (instance id = 1) of (layout = 3, cycle = \"4|2|2\", apb = 5)\n *\n * Now after this say we had the following commands:\n *\n * \\cycle(x)\n * \\cycle(|4|2|2)\n * \\apb(10)\n * \\apb(5)\n *\n * Sw: a b c\n *\n * Here again since the LP was set to null, \"creating\" layout params results in returning\n * the LP created previously (at the end of these commands the cycle, apb and layout params\n * are the same).\n *\n * eg doing\n *\n * \\layout(\"layout1\")\n *\n * This ensures that a *new* LP instance is created (even if another one exists with the same\n * apb, cycle, layout combo). This allows us to group different sectiosn that are identical\n * in layout but to be processed by different atom layouts.\n *\n * To use a saved layout simply do:\n *\n * \\layout(\"layout\")\n *\n * Note the use and saving commands are same - as we cannot override existing\n * layouts so referring to it the first time creates and saves it too\n */\nexport class ApplyLayout extends Command {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"string\") {\n throw new Error(\"layout command must contain one string argument\");\n }\n }\n\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n notation.ensureNamedLayoutParams(value);\n }\n}\n\n/**\n * Allows use (and creation) of layouts.\n */\nexport class SetBreaks extends LayoutParamCommand {\n get pattern(): number[] {\n return this.params.map((cmd) => cmd.value as number);\n }\n\n /**\n * called to validate parameters.\n */\n validateParams(): void {\n for (const param of this.params) {\n if (param.key != null) {\n throw new Error(\"Breaks command cannot have keyword params\");\n }\n if (typeof param.value !== \"number\") {\n throw new Error(\"Breaks command must be a list of integers\");\n }\n }\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentBreaks = this.pattern;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetCycle extends LayoutParamCommand {\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n // TODO - move the parsing to validation\n const cycle = parseCycle(value);\n notation.currentCycle = cycle;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetBeatDuration extends LayoutParamCommand {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"number\") {\n throw new Error(\"beatDuration command must contain one number\");\n }\n }\n\n get beatDuration(): number {\n return this.params[0].value;\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentAPB = this.beatDuration;\n notation.resetLayoutParams();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAA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AI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE;YACvE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;SACjE;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,eAAe,CAAC,QAAkB;QAChC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;QACxC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom } from \"./core\";\nimport { parseCycle } from \"./utils\";\nimport { Command, RawBlock, Notation, MetaData as Meta } from \"./notation\";\n\nexport class RawEmbedding extends Command {\n get rawContents(): string {\n return this.getParamAt(0);\n }\n\n applyToNotation(notation: Notation): void {\n const raw = new RawBlock(this.rawContents);\n notation.addRawBlock(raw);\n }\n}\n\nexport class MetaData extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.addMetaData(this.meta);\n }\n\n get meta(): Meta {\n const out = new Meta(this.key, this.value);\n return out;\n }\n\n get key(): string {\n return this.getParamAt(0);\n }\n\n get value(): string {\n return this.getParamAt(1);\n }\n}\n\nexport class ActivateRole extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.setCurrRole(this.roleName);\n // const line = notation.ensureLine();\n }\n\n get roleName(): string {\n return this.getParamAt(0);\n }\n}\n\nexport class AddAtoms extends Command {\n index: number;\n atoms: Atom[];\n\n constructor(...atoms: Atom[]) {\n super();\n this.atoms = atoms;\n this.index = 0;\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n atoms: this.atoms.map((a) => a.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n let roleDef = notation.currRoleDef;\n if (roleDef == null) {\n // By default create a role for swaras\n roleDef = notation.newRoleDef(\"Sw\", true);\n // throw new Error(\"Current role is invalid\");\n }\n // Ensure a line exists\n const lpForLine = notation.currentLine.layoutParams;\n if (lpForLine == null) {\n notation.currentLine.layoutParams = notation.layoutParams;\n } else {\n TSU.assert(\n lpForLine == notation.layoutParams,\n \"Layout parameters have changed so a new line should have been started\",\n );\n }\n const finalised = this.atoms;\n notation.currentLine.addAtoms(roleDef.name, roleDef.notesOnly, ...finalised);\n }\n}\n\nexport class CreateLine extends Command {\n applyToNotation(notation: Notation): void {\n // We are not calling a newLine here just to avoid\n // a series of \\line commands creating wasteful empty lines\n // TODO - how do we consider offsets in line create\n const line = notation.newLine();\n line.offset = this.offset;\n line.marginText = this.marginText;\n }\n\n get offset(): TSU.Num.Fraction {\n let offset = this.getParam(\"offset\") || TSU.Num.Fraction.ZERO;\n if (typeof offset === \"number\") offset = new TSU.Num.Fraction(offset);\n return offset;\n }\n\n get marginText(): string {\n if (this.params.length > 0) {\n if (this.params[0].key == null && typeof this.params[0].value === \"string\") {\n return this.params[0].value.trim();\n }\n }\n return this.getParam(\"marginText\") || \"\";\n }\n}\n\nexport class CreateRole extends Command {\n applyToNotation(notation: Notation): void {\n // Create the role\n const name = this.getParamAt(0);\n notation.newRoleDef(name, this.notesOnly);\n }\n\n get notesOnly(): boolean {\n const notesOnly = this.getParam(\"notes\");\n return notesOnly == \"true\" || notesOnly == \"yes\" || notesOnly == true;\n }\n}\n\nexport abstract class LayoutParamCommand extends Command {}\n\n/**\n * Saves the current layout with the given name.\n * Typically users can change layout params (currently cycle, APB and line layout)\n * with the \\cycle, \\layout and \\beatDuration commands. Each time these are\n * changed, the current layout params is set to null. So the next time layout\n * params are needed we look at saved layout params and search by by the unique\n * combination of cycle, apb and line layout. This prevetns users from creating\n * too many layouts with the same config. Each layout is associated with an\n * AtomLayout instance.\n *\n * For example consider this:\n *\n * \\apb(4)\n * \\breaks(4)\n * \\cycle(\"|4|2|2|\")\n * \\apb(5)\n * \\breaks(3)\n *\n * In all these cases LayoutParams are *not* created. Instead they are reset to null.\n *\n *\n * When we do an AddAtoms command, this is where a LineView is created and along with this\n * a layoutParams is created taking the latest state of the layout params resulting an\n * LP (instance id = 1) of (layout = 3, cycle = \"4|2|2\", apb = 5)\n *\n * Now after this say we had the following commands:\n *\n * \\cycle(x)\n * \\cycle(|4|2|2)\n * \\apb(10)\n * \\apb(5)\n *\n * Sw: a b c\n *\n * Here again since the LP was set to null, \"creating\" layout params results in returning\n * the LP created previously (at the end of these commands the cycle, apb and layout params\n * are the same).\n *\n * eg doing\n *\n * \\layout(\"layout1\")\n *\n * This ensures that a *new* LP instance is created (even if another one exists with the same\n * apb, cycle, layout combo). This allows us to group different sectiosn that are identical\n * in layout but to be processed by different atom layouts.\n *\n * To use a saved layout simply do:\n *\n * \\layout(\"layout\")\n *\n * Note the use and saving commands are same - as we cannot override existing\n * layouts so referring to it the first time creates and saves it too\n */\nexport class ApplyLayout extends Command {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"string\") {\n throw new Error(\"layout command must contain one string argument\");\n }\n }\n\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n notation.ensureNamedLayoutParams(value);\n }\n}\n\n/**\n * Allows use (and creation) of layouts.\n */\nexport class SetBreaks extends LayoutParamCommand {\n get pattern(): number[] {\n return this.params.map((cmd) => cmd.value as number);\n }\n\n /**\n * called to validate parameters.\n */\n validateParams(): void {\n for (const param of this.params) {\n if (param.key != null) {\n throw new Error(\"Breaks command cannot have keyword params\");\n }\n if (typeof param.value !== \"number\") {\n throw new Error(\"Breaks command must be a list of integers\");\n }\n }\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentBreaks = this.pattern;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetCycle extends LayoutParamCommand {\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n // TODO - move the parsing to validation\n const cycle = parseCycle(value);\n notation.currentCycle = cycle;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetBeatDuration extends LayoutParamCommand {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"number\") {\n throw new Error(\"beatDuration command must contain one number\");\n }\n }\n\n get beatDuration(): number {\n return this.params[0].value;\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentAPB = this.beatDuration;\n notation.resetLayoutParams();\n }\n}\n"]}
|
package/lib/esm/core.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
2
|
import { Entity, TimedEntity } from "./entity";
|
|
3
|
+
import { LayoutParams } from "./layouts";
|
|
3
4
|
declare type Fraction = TSU.Num.Fraction;
|
|
4
5
|
export declare enum AtomType {
|
|
5
6
|
NOTE = "Note",
|
|
@@ -13,6 +14,8 @@ export declare enum AtomType {
|
|
|
13
14
|
}
|
|
14
15
|
export declare abstract class Atom extends TimedEntity {
|
|
15
16
|
protected _duration: Fraction;
|
|
17
|
+
markersBefore: Marker[];
|
|
18
|
+
markersAfter: Marker[];
|
|
16
19
|
nextSibling: TSU.Nullable<Atom>;
|
|
17
20
|
prevSibling: TSU.Nullable<Atom>;
|
|
18
21
|
parentGroup: TSU.Nullable<Group>;
|
|
@@ -30,7 +33,7 @@ export declare abstract class LeafAtom extends Atom {
|
|
|
30
33
|
protected createSpilloverSpace(duration: Fraction): Space;
|
|
31
34
|
debugValue(): any;
|
|
32
35
|
}
|
|
33
|
-
export declare class Marker extends
|
|
36
|
+
export declare class Marker extends Entity {
|
|
34
37
|
text: string;
|
|
35
38
|
isBefore: boolean;
|
|
36
39
|
constructor(text: string, isBefore?: boolean);
|
|
@@ -92,6 +95,8 @@ export declare class Line extends Entity {
|
|
|
92
95
|
offset: Fraction;
|
|
93
96
|
roles: Role[];
|
|
94
97
|
marginText: string;
|
|
98
|
+
layoutParams: LayoutParams;
|
|
99
|
+
indexOfRole(name: string): number;
|
|
95
100
|
get isEmpty(): boolean;
|
|
96
101
|
debugValue(): any;
|
|
97
102
|
copyTo(another: this): void;
|