notations 0.0.68 → 0.0.70

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.
Files changed (69) hide show
  1. package/README.md +56 -26
  2. package/dist/NotationView.css +7 -0
  3. package/dist/NotationView.css.map +1 -1
  4. package/dist/NotationView.min.css +1 -1
  5. package/dist/NotationView.min.css.map +1 -1
  6. package/dist/notations.umd.js +17409 -23615
  7. package/dist/notations.umd.min.js +8 -3
  8. package/dist/notations.umd.min.js.LICENSE.txt +0 -14
  9. package/dist/notations.umd.min.js.map +1 -1
  10. package/lib/cjs/beats.d.ts +4 -0
  11. package/lib/cjs/beats.js +19 -2
  12. package/lib/cjs/beats.js.map +1 -1
  13. package/lib/cjs/block.d.ts +73 -0
  14. package/lib/cjs/block.js +247 -0
  15. package/lib/cjs/block.js.map +1 -0
  16. package/lib/cjs/carnatic/NotationView.d.ts +11 -4
  17. package/lib/cjs/carnatic/NotationView.js +26 -11
  18. package/lib/cjs/carnatic/NotationView.js.map +1 -1
  19. package/lib/cjs/commands.d.ts +25 -11
  20. package/lib/cjs/commands.js +87 -34
  21. package/lib/cjs/commands.js.map +1 -1
  22. package/lib/cjs/entity.d.ts +3 -7
  23. package/lib/cjs/entity.js +7 -37
  24. package/lib/cjs/entity.js.map +1 -1
  25. package/lib/cjs/grids.d.ts +32 -3
  26. package/lib/cjs/grids.js +96 -9
  27. package/lib/cjs/grids.js.map +1 -1
  28. package/lib/cjs/index.d.ts +1 -0
  29. package/lib/cjs/index.js +1 -0
  30. package/lib/cjs/index.js.map +1 -1
  31. package/lib/cjs/loader.js +1 -41
  32. package/lib/cjs/loader.js.map +1 -1
  33. package/lib/cjs/notation.d.ts +28 -33
  34. package/lib/cjs/notation.js +144 -122
  35. package/lib/cjs/notation.js.map +1 -1
  36. package/lib/cjs/parser.d.ts +21 -6
  37. package/lib/cjs/parser.js +122 -23
  38. package/lib/cjs/parser.js.map +1 -1
  39. package/lib/esm/beats.d.ts +4 -0
  40. package/lib/esm/beats.js +19 -2
  41. package/lib/esm/beats.js.map +1 -1
  42. package/lib/esm/block.d.ts +73 -0
  43. package/lib/esm/block.js +230 -0
  44. package/lib/esm/block.js.map +1 -0
  45. package/lib/esm/carnatic/NotationView.d.ts +11 -4
  46. package/lib/esm/carnatic/NotationView.js +26 -11
  47. package/lib/esm/carnatic/NotationView.js.map +1 -1
  48. package/lib/esm/commands.d.ts +25 -11
  49. package/lib/esm/commands.js +84 -34
  50. package/lib/esm/commands.js.map +1 -1
  51. package/lib/esm/entity.d.ts +3 -7
  52. package/lib/esm/entity.js +7 -37
  53. package/lib/esm/entity.js.map +1 -1
  54. package/lib/esm/grids.d.ts +32 -3
  55. package/lib/esm/grids.js +96 -9
  56. package/lib/esm/grids.js.map +1 -1
  57. package/lib/esm/index.d.ts +1 -0
  58. package/lib/esm/index.js +1 -0
  59. package/lib/esm/index.js.map +1 -1
  60. package/lib/esm/loader.js +1 -8
  61. package/lib/esm/loader.js.map +1 -1
  62. package/lib/esm/notation.d.ts +28 -33
  63. package/lib/esm/notation.js +129 -118
  64. package/lib/esm/notation.js.map +1 -1
  65. package/lib/esm/parser.d.ts +21 -6
  66. package/lib/esm/parser.js +122 -24
  67. package/lib/esm/parser.js.map +1 -1
  68. package/package.json +3 -2
  69. package/styles/NotationView.scss +7 -0
@@ -2,13 +2,8 @@ import { Entity } from "./entity";
2
2
  import { Cycle } from "./cycle";
3
3
  import { Line } from "./core";
4
4
  import { LayoutParams } from "./layouts";
5
- export class RoleDef {
6
- constructor() {
7
- this.name = "";
8
- this.notesOnly = false;
9
- this.index = 0;
10
- }
11
- }
5
+ import { RoleDef, RawBlock, Block, SectionBlock, RepeatBlock, CycleBlock, BeatDurationBlock, BreaksBlock, RoleBlock, GroupBlock, isBlock, isLine, isRawBlock, findContainingBlock, } from "./block";
6
+ export { RoleDef, RawBlock, Block, SectionBlock, RepeatBlock, CycleBlock, BeatDurationBlock, BreaksBlock, RoleBlock, GroupBlock, isBlock, isLine, isRawBlock, findContainingBlock, };
12
7
  export class Command extends Entity {
13
8
  constructor(params = []) {
14
9
  super();
@@ -37,16 +32,8 @@ export class Command extends Entity {
37
32
  getParamAt(index) {
38
33
  return index < this.params.length ? this.params[index].value : null;
39
34
  }
40
- }
41
- export class RawBlock extends Entity {
42
- constructor(content, contentType = "md") {
43
- super();
44
- this.content = content;
45
- this.contentType = contentType;
46
- this.TYPE = "RawBlock";
47
- }
48
- debugValue() {
49
- return Object.assign(Object.assign({}, super.debugValue()), { content: this.content, contentType: this.contentType });
35
+ applyToNotation(notation) {
36
+ this.applyToBlock(notation);
50
37
  }
51
38
  }
52
39
  export class MetaData {
@@ -57,124 +44,53 @@ export class MetaData {
57
44
  params = params || {};
58
45
  }
59
46
  }
60
- export class Notation extends Entity {
47
+ export class Notation extends Block {
61
48
  constructor() {
62
- super(...arguments);
49
+ super("notation", null);
63
50
  this.TYPE = "Notation";
51
+ this.metadata = new Map();
52
+ this.onMissingRole = (name) => this.newRoleDef(name, name == "sw");
64
53
  this._unnamedLayoutParams = [];
65
54
  this._namedLayoutParams = new Map();
55
+ this._layoutParams = null;
66
56
  this._currRoleDef = null;
67
- this.roles = [];
68
- this.blocks = [];
69
- this.currentAPB = 1;
70
- this.currentCycle = Cycle.DEFAULT;
71
- this.currentBreaks = [];
72
- this.metadata = new Map();
73
- this.onMissingRole = (name) => this.newRoleDef(name, name == "sw");
74
57
  this._currentLine = null;
75
- this._layoutParams = null;
76
- }
77
- get unnamedLayoutParams() {
78
- return this._unnamedLayoutParams;
58
+ this.localCycle = Cycle.DEFAULT;
59
+ this.localAtomsPerBeat = 1;
60
+ this.localBreaks = [];
79
61
  }
80
- get namedLayoutParams() {
81
- return this._namedLayoutParams;
82
- }
83
- addLine(line) {
84
- this.blocks.push(line);
62
+ get blocks() {
63
+ return this.blockItems;
85
64
  }
86
- removeLine(line) {
87
- const index = this.blocks.findIndex((l) => l == line);
88
- if (index >= 0) {
89
- this.blocks.splice(index, 1);
90
- }
91
- return index;
92
- }
93
- addRawBlock(raw) {
94
- this.blocks.push(raw);
95
- this.resetLine();
96
- }
97
- addMetaData(meta, addBlock = true) {
98
- if (addBlock && !this.metadata.has(meta.key)) {
99
- const raw = new RawBlock(meta.key, "metadata");
100
- this.addRawBlock(raw);
101
- }
102
- this.metadata.set(meta.key, meta);
103
- }
104
- debugValue() {
65
+ get currentAPB() {
105
66
  var _a;
106
- return Object.assign(Object.assign({}, super.debugValue), { roles: this.roles, blocks: this.blocks.map((b) => b.debugValue()), currentAPB: this.currentAPB, currentCycle: (_a = this.currentCycle) === null || _a === void 0 ? void 0 : _a.uuid, currentBreaks: this.currentBreaks });
67
+ return (_a = this.localAtomsPerBeat) !== null && _a !== void 0 ? _a : 1;
107
68
  }
108
- getRoleDef(name) {
109
- name = name.trim().toLowerCase();
110
- if (name == "") {
111
- return this.roles[this.roles.length - 1] || null;
112
- }
113
- for (let i = 0; i < this.roles.length; i++) {
114
- const rd = this.roles[i];
115
- if (name == rd.name)
116
- return rd;
117
- }
118
- return null;
69
+ set currentAPB(value) {
70
+ this.localAtomsPerBeat = value;
119
71
  }
120
- newRoleDef(name, notesOnly = false) {
121
- name = name.trim().toLowerCase();
122
- if (name.trim() == "") {
123
- throw new Error("Role name cannot be empty");
124
- }
125
- const roleDef = this.getRoleDef(name);
126
- if (roleDef != null) {
127
- throw new Error("Role already exists");
128
- }
129
- const rd = new RoleDef();
130
- rd.name = name;
131
- rd.notesOnly = notesOnly;
132
- rd.index = this.roles.length;
133
- this.roles.push(rd);
134
- return rd;
72
+ get currentCycle() {
73
+ var _a;
74
+ return (_a = this.localCycle) !== null && _a !== void 0 ? _a : Cycle.DEFAULT;
135
75
  }
136
- get currRoleDef() {
137
- if (this._currRoleDef == null) {
138
- if (this.roles.length == 0) {
139
- return null;
140
- }
141
- else {
142
- this._currRoleDef = this.roles[this.roles.length - 1];
143
- }
144
- }
145
- return this._currRoleDef;
76
+ set currentCycle(value) {
77
+ this.localCycle = value;
146
78
  }
147
- setCurrRole(name) {
148
- name = name.trim().toLowerCase();
149
- if (name.trim() == "") {
150
- throw new Error("Role name cannot be empty");
151
- }
152
- const roleDef = this.getRoleDef(name) || (this.onMissingRole ? this.onMissingRole(name) || null : null);
153
- if (roleDef == null) {
154
- throw new Error("Role not found: " + name);
155
- }
156
- this._currRoleDef = roleDef;
79
+ get currentBreaks() {
80
+ var _a;
81
+ return (_a = this.localBreaks) !== null && _a !== void 0 ? _a : [];
157
82
  }
158
- get currentLine() {
159
- if (this._currentLine == null) {
160
- return this.newLine();
161
- }
162
- return this._currentLine;
83
+ set currentBreaks(value) {
84
+ this.localBreaks = value;
163
85
  }
164
- resetLine() {
165
- this._currentLine = null;
86
+ get roles() {
87
+ return Array.from(this.localRoles.values());
166
88
  }
167
- newLine() {
168
- if (this._currentLine && this._currentLine.isEmpty) {
169
- this.removeLine(this._currentLine);
170
- }
171
- this._currentLine = new Line();
172
- this.addLine(this._currentLine);
173
- return this._currentLine;
89
+ get unnamedLayoutParams() {
90
+ return this._unnamedLayoutParams;
174
91
  }
175
- resetLayoutParams() {
176
- this._layoutParams = null;
177
- this.resetLine();
92
+ get namedLayoutParams() {
93
+ return this._namedLayoutParams;
178
94
  }
179
95
  get layoutParams() {
180
96
  if (this._layoutParams == null) {
@@ -186,6 +102,10 @@ export class Notation extends Entity {
186
102
  }
187
103
  return this._layoutParams;
188
104
  }
105
+ resetLayoutParams() {
106
+ this._layoutParams = null;
107
+ this.resetLine();
108
+ }
189
109
  ensureNamedLayoutParams(name) {
190
110
  let lp = this._namedLayoutParams.get(name) || null;
191
111
  if (lp == null || this._layoutParams != lp) {
@@ -217,5 +137,96 @@ export class Notation extends Entity {
217
137
  lp.lineBreaksEqual(this.currentBreaks));
218
138
  }) || null);
219
139
  }
140
+ setCurrRole(name) {
141
+ name = name.trim().toLowerCase();
142
+ if (name.trim() == "") {
143
+ throw new Error("Role name cannot be empty");
144
+ }
145
+ const roleDef = this.getRole(name) || (this.onMissingRole ? this.onMissingRole(name) || null : null);
146
+ if (roleDef == null) {
147
+ throw new Error("Role not found: " + name);
148
+ }
149
+ this._currRoleDef = roleDef;
150
+ }
151
+ getRoleDef(name) {
152
+ var _a;
153
+ name = name.trim().toLowerCase();
154
+ if (name === "") {
155
+ const roles = Array.from(this.localRoles.values());
156
+ return roles[roles.length - 1] || null;
157
+ }
158
+ return (_a = this.localRoles.get(name)) !== null && _a !== void 0 ? _a : null;
159
+ }
160
+ newRoleDef(name, notesOnly = false) {
161
+ name = name.trim().toLowerCase();
162
+ if (name === "") {
163
+ throw new Error("Role name cannot be empty");
164
+ }
165
+ if (this.localRoles.has(name)) {
166
+ throw new Error("Role already exists: " + name);
167
+ }
168
+ const rd = new RoleDef();
169
+ rd.name = name;
170
+ rd.notesOnly = notesOnly;
171
+ rd.index = this.localRoles.size;
172
+ this.localRoles.set(name, rd);
173
+ return rd;
174
+ }
175
+ addLine(line) {
176
+ this.addBlockItem(line);
177
+ }
178
+ removeLine(line) {
179
+ return this.removeBlockItem(line);
180
+ }
181
+ addRawBlock(raw) {
182
+ this.addBlockItem(raw);
183
+ this.resetLine();
184
+ }
185
+ addMetaData(meta, addBlock = true) {
186
+ if (addBlock && !this.metadata.has(meta.key)) {
187
+ const raw = new RawBlock(meta.key, "metadata");
188
+ this.addRawBlock(raw);
189
+ }
190
+ this.metadata.set(meta.key, meta);
191
+ }
192
+ resetLine() {
193
+ this._currentLine = null;
194
+ }
195
+ debugValue() {
196
+ var _a;
197
+ return {
198
+ blocks: this.blocks.map((b) => b.debugValue()),
199
+ currentAPB: this.currentAPB,
200
+ currentBreaks: this.currentBreaks,
201
+ currentCycle: (_a = this.currentCycle) === null || _a === void 0 ? void 0 : _a.uuid,
202
+ roles: this.roles,
203
+ };
204
+ }
205
+ get currRoleDef() {
206
+ if (this._currRoleDef == null) {
207
+ const roles = Array.from(this.localRoles.values());
208
+ if (roles.length === 0) {
209
+ return null;
210
+ }
211
+ else {
212
+ this._currRoleDef = roles[roles.length - 1];
213
+ }
214
+ }
215
+ return this._currRoleDef;
216
+ }
217
+ get currentLine() {
218
+ if (this._currentLine == null) {
219
+ return this.newLine();
220
+ }
221
+ return this._currentLine;
222
+ }
223
+ newLine() {
224
+ if (this._currentLine && this._currentLine.isEmpty) {
225
+ this.removeLine(this._currentLine);
226
+ }
227
+ this._currentLine = new Line();
228
+ this.addLine(this._currentLine);
229
+ return this._currentLine;
230
+ }
220
231
  }
221
232
  //# sourceMappingURL=notation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notation.js","sourceRoot":"","sources":["../../src/notation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAMzC,MAAM,OAAO,OAAO;IAApB;QAEE,SAAI,GAAG,EAAE,CAAC;QAGV,cAAS,GAAG,KAAK,CAAC;QAGlB,UAAK,GAAG,CAAC,CAAC;IACZ,CAAC;CAAA;AAYD,MAAM,OAAgB,OAAQ,SAAQ,MAAM;IAoB1C,YAAY,SAAqB,EAAE;QACjC,KAAK,EAAE,CAAC;QAnBV,kBAAa,GAAG,KAAK,CAAC;QAGtB,gBAAW,GAAmB,IAAI,CAAC;QAGnC,gBAAW,GAAmB,IAAI,CAAC;QAcjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAMD,cAAc;IAEd,CAAC;IAKD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAMD,UAAU;QACR,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAA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AAE,CAAC,KAAK,CAAC;gBAClC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CACvC,CAAC;QACJ,CAAC,CAAC,IAAI,IAAI,CACX,CAAC;IACJ,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity } from \"./entity\";\nimport { Cycle } from \"./cycle\";\nimport { Line } from \"./core\";\nimport { LayoutParams } from \"./layouts\";\n\n/**\n * Definition of a role in the notation.\n * A role represents a specific voice or part in the music notation.\n */\nexport class RoleDef {\n /** Name of the role */\n name = \"\";\n\n /** Whether this role contains only notes (true) or can also contain syllables/text (false) */\n notesOnly = false;\n\n /** Index of this role in the notation */\n index = 0;\n}\n\n/**\n * Type representing a command parameter with optional key and value.\n */\nexport type CmdParam = { key: TSU.Nullable<string>; value: any };\n\n/**\n * Base class for commands in the notation.\n * Commands modify the notation in various ways, such as adding content,\n * changing layout, setting roles, etc.\n */\nexport abstract class Command extends Entity {\n /** Whether this command was auto-generated */\n autoGenerated = false;\n\n /** Previous command in the sequence */\n prevSibling: null | Command = null;\n\n /** Next command in the sequence */\n nextSibling: null | Command = null;\n\n /** Parameters for this command */\n params: CmdParam[];\n\n /** Index of this command in the sequence */\n index: number;\n\n /**\n * Creates a new Command.\n * @param params Optional parameters for the command\n */\n constructor(params: CmdParam[] = []) {\n super();\n this.params = params;\n this.index = 0;\n this.validateParams();\n }\n\n /**\n * Validates the parameters for this command.\n * @throws Error if parameters are invalid\n */\n validateParams(): void {\n //\n }\n\n /**\n * Gets the name of this command.\n */\n get name(): string {\n return this.constructor.name;\n }\n\n /**\n * Returns a debug-friendly representation of this command.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { name: this.name, index: this.index, params: this.params };\n }\n\n /**\n * Gets a parameter value by name.\n * @param name The name of the parameter\n * @returns The parameter value, or null if not found\n */\n getParam(name: string): any {\n for (const param of this.params) {\n if (param.key == name) return param.value;\n }\n return null;\n }\n\n /**\n * Gets a parameter value by index.\n * @param index The index of the parameter\n * @returns The parameter value, or null if not found\n */\n getParamAt(index: number): any {\n return index < this.params.length ? this.params[index].value : null;\n }\n\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\n abstract applyToNotation(notebook: Notation): void;\n}\n\n/**\n * Represents a raw block of content in the notation.\n * Raw blocks can contain arbitrary content like markdown, HTML, etc.\n */\nexport class RawBlock extends Entity {\n readonly TYPE: string = \"RawBlock\";\n\n /**\n * Creates a new RawBlock.\n * @param content The content of the block\n * @param contentType The type of content (e.g., \"md\" for markdown)\n */\n constructor(\n public content: string,\n public contentType: string = \"md\",\n ) {\n super();\n }\n\n /**\n * Returns a debug-friendly representation of this raw block.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { ...super.debugValue(), content: this.content, contentType: this.contentType };\n }\n}\n\n/**\n * Represents metadata for the notation.\n */\nexport class MetaData {\n /**\n * Creates a new MetaData.\n * @param key The key for this metadata\n * @param value The value of this metadata\n * @param params Optional additional parameters\n */\n constructor(\n public readonly key: string,\n public readonly value: string,\n public readonly params?: any,\n ) {\n params = params || {};\n }\n}\n\n/**\n * The main class representing a complete notation.\n * Notation contains all the elements, settings, and layout information for a piece of music.\n */\nexport class Notation extends Entity {\n readonly TYPE = \"Notation\";\n private _unnamedLayoutParams: LayoutParams[] = [];\n private _namedLayoutParams = new Map<string, LayoutParams>();\n private _currRoleDef: TSU.Nullable<RoleDef> = null;\n\n /** Roles defined in this notation */\n roles: RoleDef[] = [];\n\n /** Blocks (lines or raw blocks) in this notation */\n blocks: (Line | RawBlock)[] = [];\n\n /** Current beat duration multiplier */\n currentAPB = 1;\n\n /** Current cycle pattern */\n currentCycle: Cycle = Cycle.DEFAULT;\n\n /** Current line breaks pattern */\n currentBreaks: number[] = [];\n\n /** Metadata associated with this notation */\n metadata = new Map<string, MetaData>();\n\n /** Handler for missing roles */\n onMissingRole: (name: string) => RoleDef | null = (name) => this.newRoleDef(name, name == \"sw\");\n\n /**\n * Gets the unnamed layout parameters.\n */\n get unnamedLayoutParams(): ReadonlyArray<LayoutParams> {\n return this._unnamedLayoutParams;\n }\n\n /**\n * Gets the named layout parameters.\n */\n get namedLayoutParams(): ReadonlyMap<string, LayoutParams> {\n return this._namedLayoutParams;\n }\n\n /**\n * Adds a line to this notation.\n * @param line The line to add\n */\n addLine(line: Line): void {\n this.blocks.push(line);\n }\n\n /**\n * Removes a line from this notation.\n * @param line The line to remove\n * @returns The index of the removed line, or -1 if not found\n */\n removeLine(line: Line): number {\n const index = this.blocks.findIndex((l) => l == line);\n if (index >= 0) {\n this.blocks.splice(index, 1);\n }\n return index;\n }\n\n /**\n * Adds a raw block to this notation.\n * @param raw The raw block to add\n */\n addRawBlock(raw: RawBlock): void {\n this.blocks.push(raw);\n this.resetLine();\n }\n\n /**\n * Adds metadata to this notation.\n * @param meta The metadata to add\n * @param addBlock Whether to add a corresponding raw block, defaults to true\n */\n addMetaData(meta: MetaData, addBlock = true): void {\n if (addBlock && !this.metadata.has(meta.key)) {\n // Add a new raw block here\n // set this by key so even if metadata changes we can\n // get latest value of it\n const raw = new RawBlock(meta.key, \"metadata\");\n this.addRawBlock(raw);\n }\n this.metadata.set(meta.key, meta);\n }\n\n /**\n * Returns a debug-friendly representation of this notation.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return {\n ...super.debugValue,\n roles: this.roles,\n blocks: this.blocks.map((b) => b.debugValue()),\n currentAPB: this.currentAPB,\n currentCycle: this.currentCycle?.uuid,\n currentBreaks: this.currentBreaks,\n };\n }\n\n /**\n * Gets a role definition by name.\n * @param name The name of the role\n * @returns The role definition, or null if not found\n */\n getRoleDef(name: string): TSU.Nullable<RoleDef> {\n name = name.trim().toLowerCase();\n if (name == \"\") {\n return this.roles[this.roles.length - 1] || null;\n }\n for (let i = 0; i < this.roles.length; i++) {\n const rd = this.roles[i];\n if (name == rd.name) return rd;\n }\n return null;\n }\n\n /**\n * Creates a new role definition.\n * @param name The name of the role\n * @param notesOnly Whether the role contains only notes, defaults to false\n * @returns The created role definition\n * @throws Error if the name is empty or the role already exists\n */\n newRoleDef(name: string, notesOnly = false): RoleDef {\n name = name.trim().toLowerCase();\n if (name.trim() == \"\") {\n throw new Error(\"Role name cannot be empty\");\n }\n const roleDef = this.getRoleDef(name);\n if (roleDef != null) {\n throw new Error(\"Role already exists\");\n // roleDef.notesOnly = notesOnly;\n // return roleDef;\n }\n // create new and add\n const rd = new RoleDef();\n rd.name = name;\n rd.notesOnly = notesOnly;\n rd.index = this.roles.length;\n this.roles.push(rd);\n\n return rd;\n }\n\n /**\n * Gets the current role definition.\n */\n get currRoleDef(): RoleDef | null {\n if (this._currRoleDef == null) {\n if (this.roles.length == 0) {\n return null;\n } else {\n this._currRoleDef = this.roles[this.roles.length - 1];\n }\n }\n return this._currRoleDef;\n }\n\n /**\n * Sets the current role by name.\n * @param name The name of the role to set as current\n * @throws Error if the name is empty or the role is not found\n */\n setCurrRole(name: string): void {\n name = name.trim().toLowerCase();\n if (name.trim() == \"\") {\n throw new Error(\"Role name cannot be empty\");\n }\n const roleDef = this.getRoleDef(name) || (this.onMissingRole ? this.onMissingRole(name) || null : null);\n if (roleDef == null) {\n throw new Error(\"Role not found: \" + name);\n }\n this._currRoleDef = roleDef;\n }\n\n // Gets the current line, creating it if needed\n private _currentLine: Line | null = null;\n\n /**\n * Gets the current line, creating it if needed.\n */\n get currentLine(): Line {\n if (this._currentLine == null) {\n return this.newLine();\n }\n return this._currentLine;\n }\n\n /**\n * Resets the current line pointer to null.\n */\n resetLine(): void {\n this._currentLine = null;\n }\n\n /**\n * Creates a new line and makes it the current line.\n * @returns The newly created line\n */\n newLine(): Line {\n if (this._currentLine && this._currentLine.isEmpty) {\n // then remove it first instead of adding another\n // so we dont have a string of empty lines\n this.removeLine(this._currentLine);\n }\n this._currentLine = new Line();\n this.addLine(this._currentLine);\n return this._currentLine;\n }\n\n private _layoutParams: LayoutParams | null = null;\n\n /**\n * Resets the current layout parameters to null.\n */\n resetLayoutParams(): void {\n this._layoutParams = null;\n this.resetLine();\n }\n\n /**\n * Gets the current layout parameters, creating or finding an appropriate one if needed.\n */\n get layoutParams(): LayoutParams {\n if (this._layoutParams == null) {\n // create it or find one that matches current params\n this._layoutParams = this.findUnnamedLayoutParams();\n if (this._layoutParams == null) {\n this._layoutParams = this.snapshotLayoutParams();\n this._unnamedLayoutParams.push(this._layoutParams);\n }\n }\n return this._layoutParams;\n }\n\n /**\n * Ensures that named layout parameters with the given name exist.\n * Creates them if they don't exist, or updates current layout parameters to match.\n *\n * @param name The name of the layout parameters\n * @returns The layout parameters\n */\n ensureNamedLayoutParams(name: string): LayoutParams {\n let lp = this._namedLayoutParams.get(name) || null;\n if (lp == null || this._layoutParams != lp) {\n // no change so go ahead\n if (lp == null) {\n // does not exist so create one by re-snapshotting it\n // and saving it\n lp = this.snapshotLayoutParams();\n this._namedLayoutParams.set(name, lp);\n } else {\n // copy named LPs attributes into our locals\n this.currentCycle = lp.cycle;\n this.currentAPB = lp.beatDuration;\n this.currentBreaks = lp.lineBreaks;\n }\n this._layoutParams = lp;\n this.resetLine(); // since layout params have changed\n }\n return this._layoutParams;\n }\n\n /**\n * Creates a snapshot of the current layout parameters.\n * @returns A new LayoutParams object with the current settings\n */\n protected snapshotLayoutParams(): LayoutParams {\n return new LayoutParams({\n cycle: this.currentCycle,\n beatDuration: this.currentAPB,\n layout: this.currentBreaks,\n });\n }\n\n /**\n * Finds an unnamed layout parameters object that matches the current settings.\n * @returns Matching layout parameters, or null if none found\n */\n protected findUnnamedLayoutParams(): LayoutParams | null {\n return (\n this._unnamedLayoutParams.find((lp) => {\n return (\n lp.beatDuration == this.currentAPB &&\n this.currentCycle.equals(lp.cycle) &&\n lp.lineBreaksEqual(this.currentBreaks)\n );\n }) || null\n );\n }\n}\n"]}
1
+ {"version":3,"file":"notation.js","sourceRoot":"","sources":["../../src/notation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM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Y,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity } from \"./entity\";\nimport { Cycle } from \"./cycle\";\nimport { Line } from \"./core\";\nimport { LayoutParams } from \"./layouts\";\nimport {\n RoleDef,\n RawBlock,\n BlockItem,\n Block,\n SectionBlock,\n RepeatBlock,\n CycleBlock,\n BeatDurationBlock,\n BreaksBlock,\n RoleBlock,\n GroupBlock,\n isBlock,\n isLine,\n isRawBlock,\n findContainingBlock,\n} from \"./block\";\n\n// Re-export for backward compatibility\nexport {\n RoleDef,\n RawBlock,\n BlockItem,\n Block,\n SectionBlock,\n RepeatBlock,\n CycleBlock,\n BeatDurationBlock,\n BreaksBlock,\n RoleBlock,\n GroupBlock,\n isBlock,\n isLine,\n isRawBlock,\n findContainingBlock,\n};\n\n/**\n * Type representing a command parameter with optional key and value.\n */\nexport type CmdParam = { key: TSU.Nullable<string>; value: any };\n\n/**\n * Base class for commands in the notation.\n * Commands modify the notation in various ways, such as adding content,\n * changing layout, setting roles, etc.\n */\nexport abstract class Command extends Entity {\n /** Whether this command was auto-generated */\n autoGenerated = false;\n\n /** Previous command in the sequence */\n prevSibling: null | Command = null;\n\n /** Next command in the sequence */\n nextSibling: null | Command = null;\n\n /** Parameters for this command */\n params: CmdParam[];\n\n /** Index of this command in the sequence */\n index: number;\n\n /**\n * Creates a new Command.\n * @param params Optional parameters for the command\n */\n constructor(params: CmdParam[] = []) {\n super();\n this.params = params;\n this.index = 0;\n this.validateParams();\n }\n\n /**\n * Validates the parameters for this command.\n * @throws Error if parameters are invalid\n */\n validateParams(): void {\n //\n }\n\n /**\n * Gets the name of this command.\n */\n get name(): string {\n return this.constructor.name;\n }\n\n /**\n * Returns a debug-friendly representation of this command.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { name: this.name, index: this.index, params: this.params };\n }\n\n /**\n * Gets a parameter value by name.\n * @param name The name of the parameter\n * @returns The parameter value, or null if not found\n */\n getParam(name: string): any {\n for (const param of this.params) {\n if (param.key == name) return param.value;\n }\n return null;\n }\n\n /**\n * Gets a parameter value by index.\n * @param index The index of the parameter\n * @returns The parameter value, or null if not found\n */\n getParamAt(index: number): any {\n return index < this.params.length ? this.params[index].value : null;\n }\n\n /**\n * Applies this command to a block (the primary method).\n * Since Notation extends Block, this works for both.\n * @param container The block to apply this command to\n */\n abstract applyToBlock(container: Block): void;\n\n /**\n * @deprecated Use applyToBlock instead\n * Applies this command to a notation.\n * Default implementation delegates to applyToBlock.\n * @param notation The notation to apply this command to\n */\n applyToNotation(notation: Notation): void {\n this.applyToBlock(notation);\n }\n}\n\n/**\n * Represents metadata for the notation.\n */\nexport class MetaData {\n /**\n * Creates a new MetaData.\n * @param key The key for this metadata\n * @param value The value of this metadata\n * @param params Optional additional parameters\n */\n constructor(\n public readonly key: string,\n public readonly value: string,\n public readonly params?: any,\n ) {\n params = params || {};\n }\n}\n\n/**\n * The main class representing a complete notation.\n * Notation is the root Block of the notation hierarchy.\n * It contains all the elements, settings, and layout information for a piece of music.\n */\nexport class Notation extends Block {\n readonly TYPE = \"Notation\";\n\n // ============================================\n // Notation-specific properties\n // ============================================\n\n /** Metadata associated with this notation */\n metadata = new Map<string, MetaData>();\n\n /** Handler for missing roles */\n onMissingRole: (name: string) => RoleDef | null = (name) => this.newRoleDef(name, name == \"sw\");\n\n /** Layout parameters management */\n private _unnamedLayoutParams: LayoutParams[] = [];\n private _namedLayoutParams = new Map<string, LayoutParams>();\n private _layoutParams: LayoutParams | null = null;\n\n /**\n * Creates a new Notation.\n */\n constructor() {\n super(\"notation\", null);\n // Set default values for root notation\n this.localCycle = Cycle.DEFAULT;\n this.localAtomsPerBeat = 1;\n this.localBreaks = [];\n }\n\n // ============================================\n // Backward compatibility aliases\n // ============================================\n\n /**\n * @deprecated Use blockItems instead\n * Legacy accessor for blocks array.\n */\n get blocks(): BlockItem[] {\n return this.blockItems;\n }\n\n /**\n * @deprecated Use localAtomsPerBeat instead\n * Legacy accessor for current atoms per beat.\n */\n get currentAPB(): number {\n return this.localAtomsPerBeat ?? 1;\n }\n\n set currentAPB(value: number) {\n this.localAtomsPerBeat = value;\n }\n\n /**\n * @deprecated Use localCycle instead\n * Legacy accessor for current cycle.\n */\n get currentCycle(): Cycle {\n return this.localCycle ?? Cycle.DEFAULT;\n }\n\n set currentCycle(value: Cycle) {\n this.localCycle = value;\n }\n\n /**\n * @deprecated Use localBreaks instead\n * Legacy accessor for current breaks.\n */\n get currentBreaks(): number[] {\n return this.localBreaks ?? [];\n }\n\n set currentBreaks(value: number[]) {\n this.localBreaks = value;\n }\n\n /**\n * @deprecated Use localRoles instead\n * Legacy accessor for roles array.\n */\n get roles(): RoleDef[] {\n return Array.from(this.localRoles.values());\n }\n\n // ============================================\n // Layout parameters management\n // ============================================\n\n /**\n * Gets the unnamed layout parameters.\n */\n get unnamedLayoutParams(): ReadonlyArray<LayoutParams> {\n return this._unnamedLayoutParams;\n }\n\n /**\n * Gets the named layout parameters.\n */\n get namedLayoutParams(): ReadonlyMap<string, LayoutParams> {\n return this._namedLayoutParams;\n }\n\n /**\n * Gets the current layout parameters, creating or finding an appropriate one if needed.\n */\n get layoutParams(): LayoutParams {\n if (this._layoutParams == null) {\n // create it or find one that matches current params\n this._layoutParams = this.findUnnamedLayoutParams();\n if (this._layoutParams == null) {\n this._layoutParams = this.snapshotLayoutParams();\n this._unnamedLayoutParams.push(this._layoutParams);\n }\n }\n return this._layoutParams;\n }\n\n /**\n * Resets the current layout parameters to null.\n */\n resetLayoutParams(): void {\n this._layoutParams = null;\n this.resetLine();\n }\n\n /**\n * Ensures that named layout parameters with the given name exist.\n * Creates them if they don't exist, or updates current layout parameters to match.\n *\n * @param name The name of the layout parameters\n * @returns The layout parameters\n */\n ensureNamedLayoutParams(name: string): LayoutParams {\n let lp = this._namedLayoutParams.get(name) || null;\n if (lp == null || this._layoutParams != lp) {\n // no change so go ahead\n if (lp == null) {\n // does not exist so create one by re-snapshotting it\n // and saving it\n lp = this.snapshotLayoutParams();\n this._namedLayoutParams.set(name, lp);\n } else {\n // copy named LPs attributes into our locals\n this.currentCycle = lp.cycle;\n this.currentAPB = lp.beatDuration;\n this.currentBreaks = lp.lineBreaks;\n }\n this._layoutParams = lp;\n this.resetLine(); // since layout params have changed\n }\n return this._layoutParams;\n }\n\n /**\n * Creates a snapshot of the current layout parameters.\n * @returns A new LayoutParams object with the current settings\n */\n protected snapshotLayoutParams(): LayoutParams {\n return new LayoutParams({\n cycle: this.currentCycle,\n beatDuration: this.currentAPB,\n layout: this.currentBreaks,\n });\n }\n\n /**\n * Finds an unnamed layout parameters object that matches the current settings.\n * @returns Matching layout parameters, or null if none found\n */\n protected findUnnamedLayoutParams(): LayoutParams | null {\n return (\n this._unnamedLayoutParams.find((lp) => {\n return (\n lp.beatDuration == this.currentAPB &&\n this.currentCycle.equals(lp.cycle) &&\n lp.lineBreaksEqual(this.currentBreaks)\n );\n }) || null\n );\n }\n\n // ============================================\n // Overridden methods\n // ============================================\n\n /**\n * Sets the current role by name.\n * Uses onMissingRole callback for auto-creation of missing roles.\n * @param name The name of the role to set as current\n * @throws Error if the name is empty or the role is not found\n */\n setCurrRole(name: string): void {\n name = name.trim().toLowerCase();\n if (name.trim() == \"\") {\n throw new Error(\"Role name cannot be empty\");\n }\n const roleDef = this.getRole(name) || (this.onMissingRole ? this.onMissingRole(name) || null : null);\n if (roleDef == null) {\n throw new Error(\"Role not found: \" + name);\n }\n this._currRoleDef = roleDef;\n }\n\n /**\n * Gets a role definition by name.\n * Handles empty name by returning the last added role.\n * @param name The name of the role\n * @returns The role definition, or null if not found\n */\n getRoleDef(name: string): TSU.Nullable<RoleDef> {\n name = name.trim().toLowerCase();\n if (name === \"\") {\n // Return the last added role if name is empty\n const roles = Array.from(this.localRoles.values());\n return roles[roles.length - 1] || null;\n }\n return this.localRoles.get(name) ?? null;\n }\n\n /**\n * Creates a new role definition.\n * @param name The name of the role\n * @param notesOnly Whether the role contains only notes, defaults to false\n * @returns The created role definition\n * @throws Error if the name is empty or the role already exists\n */\n newRoleDef(name: string, notesOnly = false): RoleDef {\n name = name.trim().toLowerCase();\n if (name === \"\") {\n throw new Error(\"Role name cannot be empty\");\n }\n if (this.localRoles.has(name)) {\n throw new Error(\"Role already exists: \" + name);\n }\n // create new and add\n const rd = new RoleDef();\n rd.name = name;\n rd.notesOnly = notesOnly;\n rd.index = this.localRoles.size;\n this.localRoles.set(name, rd);\n\n return rd;\n }\n\n // ============================================\n // Additional methods\n // ============================================\n\n /**\n * Adds a line to this notation.\n * @param line The line to add\n */\n addLine(line: Line): void {\n this.addBlockItem(line);\n }\n\n /**\n * Removes a line from this notation.\n * @param line The line to remove\n * @returns The index of the removed line, or -1 if not found\n */\n removeLine(line: Line): number {\n return this.removeBlockItem(line);\n }\n\n /**\n * Adds a raw block to this notation.\n * @param raw The raw block to add\n */\n addRawBlock(raw: RawBlock): void {\n this.addBlockItem(raw);\n this.resetLine();\n }\n\n /**\n * Adds metadata to this notation.\n * @param meta The metadata to add\n * @param addBlock Whether to add a corresponding raw block, defaults to true\n */\n addMetaData(meta: MetaData, addBlock = true): void {\n if (addBlock && !this.metadata.has(meta.key)) {\n // Add a new raw block here\n // set this by key so even if metadata changes we can\n // get latest value of it\n const raw = new RawBlock(meta.key, \"metadata\");\n this.addRawBlock(raw);\n }\n this.metadata.set(meta.key, meta);\n }\n\n /**\n * Resets the current line pointer to null.\n */\n resetLine(): void {\n this._currentLine = null;\n }\n\n /**\n * Returns a debug-friendly representation of this notation.\n * Uses Notation-specific property names for backward compatibility.\n * @returns An object containing debug information\n */\n debugValue(): any {\n // Use Notation-specific names (blocks, currentCycle, etc.)\n // instead of Block names (blockItems, localCycle, etc.)\n // to maintain backward compatibility with existing tests\n return {\n blocks: this.blocks.map((b) => b.debugValue()),\n currentAPB: this.currentAPB,\n currentBreaks: this.currentBreaks,\n currentCycle: this.currentCycle?.uuid,\n roles: this.roles,\n };\n }\n\n // Need protected access to _currRoleDef for setCurrRole override\n protected _currRoleDef: TSU.Nullable<RoleDef> = null;\n\n /**\n * Gets the current role definition.\n */\n get currRoleDef(): RoleDef | null {\n if (this._currRoleDef == null) {\n const roles = Array.from(this.localRoles.values());\n if (roles.length === 0) {\n return null;\n } else {\n this._currRoleDef = roles[roles.length - 1];\n }\n }\n return this._currRoleDef;\n }\n\n // Need protected access to _currentLine for resetLine\n protected _currentLine: Line | null = null;\n\n /**\n * Gets the current line, creating it if needed.\n */\n get currentLine(): Line {\n if (this._currentLine == null) {\n return this.newLine();\n }\n return this._currentLine;\n }\n\n /**\n * Creates a new line and makes it the current line.\n * @returns The newly created line\n */\n newLine(): Line {\n if (this._currentLine && this._currentLine.isEmpty) {\n // then remove it first instead of adding another\n // so we dont have a string of empty lines\n this.removeLine(this._currentLine);\n }\n this._currentLine = new Line();\n this.addLine(this._currentLine);\n return this._currentLine;\n }\n}\n"]}
@@ -3,10 +3,22 @@ import * as G from "galore";
3
3
  import * as TLEX from "tlex";
4
4
  import { Literal, Note, Atom, Rest, Space, Group } from "./core";
5
5
  import { Notation, Command, CmdParam } from "./notation";
6
+ import { Block } from "./block";
7
+ export declare class BlockCommand extends Command {
8
+ readonly innerCommand: Command;
9
+ readonly blockCommands: Command[];
10
+ constructor(innerCommand: Command, blockCommands: Command[]);
11
+ get name(): string;
12
+ private createBlock;
13
+ debugValue(): any;
14
+ applyToNotation(notation: Notation): void;
15
+ applyToBlock(container: Block): void;
16
+ }
6
17
  export declare class Parser {
7
18
  errors: (TLEX.TokenizerError | G.ParseError)[];
8
19
  metadata: any;
9
20
  readonly commands: Command[];
21
+ private blockStartStack;
10
22
  protected ruleHandlers: {
11
23
  newFraction: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => TSU.Num.Fraction;
12
24
  newGroup: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Group;
@@ -14,10 +26,10 @@ export declare class Parser {
14
26
  litWithPreEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Literal;
15
27
  litWithPostEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Literal;
16
28
  litToAtom: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => any;
17
- newSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Space;
18
- newRest: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Rest;
19
- newDoubleSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Space;
20
- newSilentSpace: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Space;
29
+ newSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => Space;
30
+ newRest: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => Rest;
31
+ newDoubleSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => Space;
32
+ newSilentSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => Space;
21
33
  applyPreMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Atom;
22
34
  applyPostMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Atom;
23
35
  applyDuration: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Atom;
@@ -29,14 +41,17 @@ export declare class Parser {
29
41
  };
30
42
  newParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => any[];
31
43
  concatParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => any;
32
- newCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Command;
44
+ beginBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => null;
45
+ endBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => Command[];
46
+ nullBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => null;
47
+ newCommandWithBlock: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => Command;
33
48
  appendAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => null;
34
49
  prependFrontMatter: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => any;
35
50
  appendCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => null;
36
51
  appendRoleSelector: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => null;
37
52
  insertEmbedding: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => null;
38
53
  };
39
- constructor(config?: any);
54
+ constructor(_config?: any);
40
55
  createCommand(name: string, params: CmdParam[]): Command;
41
56
  addCommand(cmd: Command): void;
42
57
  parse(input: string): any;