notations 0.0.69 → 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.
- package/dist/notations.umd.js +17409 -23615
- package/dist/notations.umd.min.js +8 -3
- package/dist/notations.umd.min.js.LICENSE.txt +0 -14
- package/dist/notations.umd.min.js.map +1 -1
- package/lib/cjs/beats.d.ts +4 -0
- package/lib/cjs/beats.js +19 -2
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/block.d.ts +73 -0
- package/lib/cjs/block.js +247 -0
- package/lib/cjs/block.js.map +1 -0
- package/lib/cjs/carnatic/NotationView.d.ts +11 -4
- package/lib/cjs/carnatic/NotationView.js +26 -11
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/commands.d.ts +25 -11
- package/lib/cjs/commands.js +87 -34
- package/lib/cjs/commands.js.map +1 -1
- package/lib/cjs/entity.d.ts +3 -7
- package/lib/cjs/entity.js +7 -37
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/grids.d.ts +32 -3
- package/lib/cjs/grids.js +96 -9
- package/lib/cjs/grids.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/loader.js +1 -41
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.d.ts +28 -33
- package/lib/cjs/notation.js +144 -122
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/parser.d.ts +21 -6
- package/lib/cjs/parser.js +122 -23
- package/lib/cjs/parser.js.map +1 -1
- package/lib/esm/beats.d.ts +4 -0
- package/lib/esm/beats.js +19 -2
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/block.d.ts +73 -0
- package/lib/esm/block.js +230 -0
- package/lib/esm/block.js.map +1 -0
- package/lib/esm/carnatic/NotationView.d.ts +11 -4
- package/lib/esm/carnatic/NotationView.js +26 -11
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/commands.d.ts +25 -11
- package/lib/esm/commands.js +84 -34
- package/lib/esm/commands.js.map +1 -1
- package/lib/esm/entity.d.ts +3 -7
- package/lib/esm/entity.js +7 -37
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/grids.d.ts +32 -3
- package/lib/esm/grids.js +96 -9
- package/lib/esm/grids.js.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/loader.js +1 -8
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.d.ts +28 -33
- package/lib/esm/notation.js +129 -118
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/parser.d.ts +21 -6
- package/lib/esm/parser.js +122 -24
- package/lib/esm/parser.js.map +1 -1
- package/package.json +3 -2
package/lib/cjs/grids.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
|
+
export interface LayoutChangeEvent {
|
|
3
|
+
affectedRowRange: {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
} | null;
|
|
7
|
+
affectedColRange: {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
} | null;
|
|
11
|
+
columnWidthsChanged: boolean;
|
|
12
|
+
rowHeightsChanged: boolean;
|
|
13
|
+
affectedGridModels: GridModel[];
|
|
14
|
+
}
|
|
15
|
+
export type LayoutChangeCallback = (event: LayoutChangeEvent) => void;
|
|
2
16
|
export declare class GridModel extends TSU.Events.EventEmitter {
|
|
3
17
|
private static idCounter;
|
|
4
18
|
readonly uuid: number;
|
|
@@ -111,6 +125,12 @@ export declare class RowAlign extends AlignedLine {
|
|
|
111
125
|
}
|
|
112
126
|
export declare class GridLayoutGroup {
|
|
113
127
|
gridModels: GridModel[];
|
|
128
|
+
private layoutChangeSubscribers;
|
|
129
|
+
private previousColumnWidths;
|
|
130
|
+
private previousRowHeights;
|
|
131
|
+
onLayoutChange(callback: LayoutChangeCallback): () => void;
|
|
132
|
+
protected notifyLayoutChange(event: LayoutChangeEvent): void;
|
|
133
|
+
get subscriberCount(): number;
|
|
114
134
|
private eventHandler;
|
|
115
135
|
addGridModel(gridModel: GridModel): boolean;
|
|
116
136
|
startingRowAligns(): RowAlign[];
|
|
@@ -119,9 +139,18 @@ export declare class GridLayoutGroup {
|
|
|
119
139
|
getCellView: (cell: GridCell) => GridCellView;
|
|
120
140
|
get startingRows(): RowAlign[];
|
|
121
141
|
get startingCols(): ColAlign[];
|
|
122
|
-
refreshLayout(): void;
|
|
142
|
+
refreshLayout(notify?: boolean): void;
|
|
123
143
|
protected applyModelEvents(events: TSU.Events.TEvent[]): void;
|
|
124
|
-
protected
|
|
144
|
+
protected calculateAffectedRowRange(changedRowAligns: any): {
|
|
145
|
+
start: number;
|
|
146
|
+
end: number;
|
|
147
|
+
} | null;
|
|
148
|
+
protected calculateAffectedColRange(changedColAligns: any): {
|
|
149
|
+
start: number;
|
|
150
|
+
end: number;
|
|
151
|
+
} | null;
|
|
152
|
+
private checkAndUpdateLength;
|
|
153
|
+
protected changesForEvents(events: TSU.Events.TEvent[]): [any, any, GridModel[]];
|
|
125
154
|
protected ensureGetCellView(align: AlignedLine): ((value: any) => GridCellView) | null;
|
|
126
|
-
protected doBfsLayout<T extends AlignedLine>(startingLines: T[], changedAligns: any):
|
|
155
|
+
protected doBfsLayout<T extends AlignedLine>(startingLines: T[], changedAligns: any, previousLengths?: Map<number, number>): boolean;
|
|
127
156
|
}
|
package/lib/cjs/grids.js
CHANGED
|
@@ -406,10 +406,32 @@ exports.RowAlign = RowAlign;
|
|
|
406
406
|
class GridLayoutGroup {
|
|
407
407
|
constructor() {
|
|
408
408
|
this.gridModels = [];
|
|
409
|
+
this.layoutChangeSubscribers = new Set();
|
|
410
|
+
this.previousColumnWidths = new Map();
|
|
411
|
+
this.previousRowHeights = new Map();
|
|
409
412
|
this.eventHandler = (event) => {
|
|
410
413
|
this.applyModelEvents(event.payload);
|
|
411
414
|
};
|
|
412
415
|
}
|
|
416
|
+
onLayoutChange(callback) {
|
|
417
|
+
this.layoutChangeSubscribers.add(callback);
|
|
418
|
+
return () => {
|
|
419
|
+
this.layoutChangeSubscribers.delete(callback);
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
notifyLayoutChange(event) {
|
|
423
|
+
for (const callback of this.layoutChangeSubscribers) {
|
|
424
|
+
try {
|
|
425
|
+
callback(event);
|
|
426
|
+
}
|
|
427
|
+
catch (e) {
|
|
428
|
+
console.error("Error in layout change callback:", e);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
get subscriberCount() {
|
|
433
|
+
return this.layoutChangeSubscribers.size;
|
|
434
|
+
}
|
|
413
435
|
addGridModel(gridModel) {
|
|
414
436
|
var _a;
|
|
415
437
|
(_a = gridModel.eventHub) === null || _a === void 0 ? void 0 : _a.on(TSU.Events.EventHub.BATCH_EVENTS, this.eventHandler);
|
|
@@ -452,7 +474,7 @@ class GridLayoutGroup {
|
|
|
452
474
|
get startingCols() {
|
|
453
475
|
return this.startingColAligns();
|
|
454
476
|
}
|
|
455
|
-
refreshLayout() {
|
|
477
|
+
refreshLayout(notify = true) {
|
|
456
478
|
const changedRowAligns = {};
|
|
457
479
|
const changedColAligns = {};
|
|
458
480
|
for (const rowAlign of this.startingRowAligns()) {
|
|
@@ -471,18 +493,77 @@ class GridLayoutGroup {
|
|
|
471
493
|
};
|
|
472
494
|
}
|
|
473
495
|
}
|
|
474
|
-
this.doBfsLayout(this.startingRows, changedRowAligns);
|
|
475
|
-
this.doBfsLayout(this.startingCols, changedColAligns);
|
|
496
|
+
const rowHeightsChanged = this.doBfsLayout(this.startingRows, changedRowAligns, this.previousRowHeights);
|
|
497
|
+
const columnWidthsChanged = this.doBfsLayout(this.startingCols, changedColAligns, this.previousColumnWidths);
|
|
498
|
+
if (notify && this.layoutChangeSubscribers.size > 0) {
|
|
499
|
+
this.notifyLayoutChange({
|
|
500
|
+
affectedRowRange: null,
|
|
501
|
+
affectedColRange: null,
|
|
502
|
+
columnWidthsChanged,
|
|
503
|
+
rowHeightsChanged,
|
|
504
|
+
affectedGridModels: this.gridModels,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
476
507
|
}
|
|
477
508
|
applyModelEvents(events) {
|
|
478
|
-
const [changedRowAligns, changedColAligns] = this.changesForEvents(events);
|
|
479
|
-
|
|
480
|
-
|
|
509
|
+
const [changedRowAligns, changedColAligns, affectedGridModels] = this.changesForEvents(events);
|
|
510
|
+
const hadRowChanges = Object.keys(changedRowAligns).length > 0;
|
|
511
|
+
const hadColChanges = Object.keys(changedColAligns).length > 0;
|
|
512
|
+
const rowHeightsChanged = this.doBfsLayout(this.startingRows, changedRowAligns, this.previousRowHeights);
|
|
513
|
+
const columnWidthsChanged = this.doBfsLayout(this.startingCols, changedColAligns, this.previousColumnWidths);
|
|
514
|
+
if (this.layoutChangeSubscribers.size > 0 && (hadRowChanges || hadColChanges)) {
|
|
515
|
+
const affectedRowRange = this.calculateAffectedRowRange(changedRowAligns);
|
|
516
|
+
const affectedColRange = this.calculateAffectedColRange(changedColAligns);
|
|
517
|
+
this.notifyLayoutChange({
|
|
518
|
+
affectedRowRange,
|
|
519
|
+
affectedColRange,
|
|
520
|
+
columnWidthsChanged,
|
|
521
|
+
rowHeightsChanged,
|
|
522
|
+
affectedGridModels: affectedGridModels,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
calculateAffectedRowRange(changedRowAligns) {
|
|
527
|
+
let minRow = Infinity;
|
|
528
|
+
let maxRow = -Infinity;
|
|
529
|
+
for (const alignId in changedRowAligns) {
|
|
530
|
+
const { cells } = changedRowAligns[alignId];
|
|
531
|
+
for (const cell of cells) {
|
|
532
|
+
const rowIndex = cell.gridRow.rowIndex;
|
|
533
|
+
minRow = Math.min(minRow, rowIndex);
|
|
534
|
+
maxRow = Math.max(maxRow, rowIndex);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (minRow === Infinity)
|
|
538
|
+
return null;
|
|
539
|
+
return { start: minRow, end: maxRow };
|
|
540
|
+
}
|
|
541
|
+
calculateAffectedColRange(changedColAligns) {
|
|
542
|
+
let minCol = Infinity;
|
|
543
|
+
let maxCol = -Infinity;
|
|
544
|
+
for (const alignId in changedColAligns) {
|
|
545
|
+
const { cells } = changedColAligns[alignId];
|
|
546
|
+
for (const cell of cells) {
|
|
547
|
+
const colIndex = cell.colIndex;
|
|
548
|
+
minCol = Math.min(minCol, colIndex);
|
|
549
|
+
maxCol = Math.max(maxCol, colIndex);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (minCol === Infinity)
|
|
553
|
+
return null;
|
|
554
|
+
return { start: minCol, end: maxCol };
|
|
555
|
+
}
|
|
556
|
+
checkAndUpdateLength(align, previousMap) {
|
|
557
|
+
const previous = previousMap.get(align.uuid);
|
|
558
|
+
const current = align.maxLength;
|
|
559
|
+
previousMap.set(align.uuid, current);
|
|
560
|
+
return previous === undefined || previous !== current;
|
|
481
561
|
}
|
|
482
562
|
changesForEvents(events) {
|
|
483
563
|
const cellVisited = {};
|
|
484
564
|
const changedRowAligns = {};
|
|
485
565
|
const changedColAligns = {};
|
|
566
|
+
const affectedGridModelsSet = new Set();
|
|
486
567
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
487
568
|
const event = events[i];
|
|
488
569
|
const loc = event.payload.loc;
|
|
@@ -491,6 +572,7 @@ class GridLayoutGroup {
|
|
|
491
572
|
cellVisited[loc] = true;
|
|
492
573
|
const [row, col] = loc.split(":").map((x) => parseInt(x));
|
|
493
574
|
const gridModel = event.source;
|
|
575
|
+
affectedGridModelsSet.add(gridModel);
|
|
494
576
|
const cell = gridModel.getRow(row).cellAt(col);
|
|
495
577
|
if (cell) {
|
|
496
578
|
if (!(cell.rowAlign.uuid in changedRowAligns)) {
|
|
@@ -509,7 +591,7 @@ class GridLayoutGroup {
|
|
|
509
591
|
changedColAligns[cell.colAlign.uuid]["cells"].push(cell);
|
|
510
592
|
}
|
|
511
593
|
}
|
|
512
|
-
return [changedRowAligns, changedColAligns];
|
|
594
|
+
return [changedRowAligns, changedColAligns, Array.from(affectedGridModelsSet)];
|
|
513
595
|
}
|
|
514
596
|
ensureGetCellView(align) {
|
|
515
597
|
if (!align.getCellView) {
|
|
@@ -520,13 +602,17 @@ class GridLayoutGroup {
|
|
|
520
602
|
}
|
|
521
603
|
return align.getCellView;
|
|
522
604
|
}
|
|
523
|
-
doBfsLayout(startingLines, changedAligns) {
|
|
605
|
+
doBfsLayout(startingLines, changedAligns, previousLengths) {
|
|
524
606
|
if (!this.getCellView)
|
|
525
|
-
return;
|
|
607
|
+
return false;
|
|
608
|
+
let anyDimensionChanged = false;
|
|
526
609
|
for (const alignId in changedAligns) {
|
|
527
610
|
const val = changedAligns[alignId];
|
|
528
611
|
this.ensureGetCellView(val.align);
|
|
529
612
|
val.align.evalMaxLength(val.cells);
|
|
613
|
+
if (previousLengths && this.checkAndUpdateLength(val.align, previousLengths)) {
|
|
614
|
+
anyDimensionChanged = true;
|
|
615
|
+
}
|
|
530
616
|
}
|
|
531
617
|
let lineQueue = [];
|
|
532
618
|
const visitedLines = {};
|
|
@@ -559,6 +645,7 @@ class GridLayoutGroup {
|
|
|
559
645
|
}
|
|
560
646
|
lineQueue = nextQueue;
|
|
561
647
|
}
|
|
648
|
+
return anyDimensionChanged;
|
|
562
649
|
}
|
|
563
650
|
}
|
|
564
651
|
exports.GridLayoutGroup = GridLayoutGroup;
|
package/lib/cjs/grids.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grids.js","sourceRoot":"","sources":["../../src/grids.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAYvC,MAAa,SAAU,SAAQ,GAAG,CAAC,MAAM,CAAC,YAAY;IAAtD;;QAEW,SAAI,GAAG,SAAS,CAAC,SAA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ic grid layout system for hosting child views (similar to GridBagLayout).\n * This provides a framework for hosting BeatViews in a structured grid arrangement,\n * with support for rows, columns, and alignment.\n *\n * Grid \"cells\" can be referred to by cell indexes. Additionally, grid rows and\n * columns can have names (like in spreadsheets) so that even when rows and columns\n * are inserted, though indexes may change, the \"addresses\" remain fixed and immovable.\n */\nexport class GridModel extends TSU.Events.EventEmitter {\n private static idCounter = 0;\n readonly uuid = GridModel.idCounter++;\n /** Timestamp of the last update to this grid */\n lastUpdatedAt = 0;\n // cells = new SparseArray<SparseArray<GridCell>>();\n /** The rows in this grid */\n rows: GridRow[] = [];\n /** Mapping of row indices to row alignment objects */\n rowAligns = new Map<number, RowAlign>();\n /** Mapping of column indices to column alignment objects */\n colAligns = new Map<number, ColAlign>();\n\n /**\n * Returns a debug-friendly representation of this GridModel.\n * @returns An object containing debug information\n */\n debugValue() {\n const out = {\n rows: this.rows.map((r) => r.debugValue()),\n lastUpdatedAt: this.lastUpdatedAt,\n } as any;\n return out;\n }\n\n /**\n * Gets the index of the first non-empty row.\n * @returns The index of the first row containing cells, or -1 if none\n */\n get firstRow(): number {\n for (const gr of this.rows) {\n if (gr.numCells > 0) return gr.rowIndex;\n }\n return -1;\n }\n\n /**\n * Gets the index of the leftmost column containing cells.\n * @returns The index of the first column containing cells, or -1 if none\n */\n get firstCol(): number {\n let minCol = -1;\n for (const gr of this.rows) {\n const fc = gr.firstCol;\n if (fc >= 0) {\n if (minCol < 0 || fc < minCol) {\n minCol = fc;\n }\n }\n }\n return minCol;\n }\n\n /**\n * Gets all non-empty cells in a specific row.\n * @param row The index of the row\n * @returns An array of cells in the row\n */\n cellsInRow(row: number): GridCell[] {\n const out = [] as GridCell[];\n const gr = this.rows[row];\n if (gr) {\n for (const cell of gr.cells) {\n if (cell?.value) out.push(cell);\n }\n }\n return out;\n }\n\n /**\n * Gets all non-empty cells in a specific column.\n * @param col The index of the column\n * @returns An array of cells in the column\n */\n cellsInCol(col: number): GridCell[] {\n const out = [] as GridCell[];\n for (const gr of this.rows) {\n const cell = gr.cellAt(col);\n if (cell?.value) out.push(cell);\n }\n return out;\n }\n\n /**\n * Adds a row alignment object to the grid.\n * @param align The row alignment to add\n */\n addRowAlign(align: RowAlign): void {\n this.rowAligns.set(align.uuid, align);\n }\n\n /**\n * Adds a column alignment object to the grid.\n * @param align The column alignment to add\n */\n addColAlign(align: ColAlign): void {\n this.colAligns.set(align.uuid, align);\n }\n\n /**\n * Adds rows to the grid.\n * @param insertBefore The index before which to insert the rows, or -1 to append\n * @param numRows The number of rows to add\n * @returns This grid instance for method chaining\n */\n addRows(insertBefore = -1, numRows = 1): this {\n if (insertBefore < 0) {\n insertBefore = this.rows.length;\n }\n let next = this.rows[insertBefore] || null;\n const prev = this.rows[insertBefore - 1] || null;\n for (let i = numRows - 1; i >= 0; i--) {\n const newRow = new GridRow(this, insertBefore + i);\n this.rows.splice(insertBefore, 0, newRow);\n if (next != null) {\n newRow.defaultRowAlign.addSuccessor(next.defaultRowAlign);\n }\n if (i == 0 && insertBefore > 0) {\n prev.defaultRowAlign.addSuccessor(newRow.defaultRowAlign);\n }\n next = newRow;\n }\n for (let i = insertBefore + numRows; i < this.rows.length; i++) {\n this.rows[i].rowIndex += numRows;\n }\n return this;\n }\n\n /**\n * Gets a row at the specified index, creating it if necessary.\n * @param row The index of the row to get\n * @returns The row at the specified index\n */\n getRow(row: number): GridRow {\n if (row >= this.rows.length) {\n this.addRows(-1, 1 + row - this.rows.length);\n }\n return this.rows[row];\n }\n\n /**\n * Sets a value in a cell at the specified row and column.\n * @param row The row index\n * @param col The column index\n * @param value The value to set\n * @param cellCreator Optional function to create a custom cell\n * @returns The previous value of the cell\n */\n setValue(row: number, col: number, value: any, cellCreator?: (row: GridRow, col: number) => GridCell): any {\n const grow = this.getRow(row);\n if (!cellCreator) {\n cellCreator = (row: GridRow, col: number) => {\n return new GridCell(row, col);\n };\n }\n if (value == null) {\n const out = grow.clearCellAt(col);\n if (out != null) {\n this.eventHub?.emit(GridCellEvent.CLEARED, this, {\n loc: out.location,\n });\n }\n return out;\n } else {\n const cell = grow.cellAt(col, cellCreator) as GridCell;\n const oldValue = cell.value;\n this.eventHub?.emit(GridCellEvent.UPDATED, this, {\n loc: cell.location,\n cell: cell,\n oldValue: cell.value,\n });\n cell.value = value;\n return oldValue;\n }\n }\n\n /**\n * Handles changes to the event hub.\n */\n protected eventHubChanged(): void {\n console.log(\"Event Hub Changed for GridModel\");\n }\n}\n\n/**\n * Interface for a view associated with a grid cell.\n * GridCellView defines the contract for views that can be placed in grid cells.\n */\nexport interface GridCellView {\n /** The grid cell this view is associated with */\n readonly cell: GridCell;\n /** X-coordinate of the view */\n x: number;\n /** Y-coordinate of the view */\n y: number;\n /** Width of the view */\n width: number;\n /** Height of the view */\n height: number;\n\n /**\n * Sets the bounds of the view.\n * @param x New x-coordinate, or null to keep current value\n * @param y New y-coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @param applyLayout Whether to apply layout immediately\n * @returns The new bounds values\n */\n setBounds(\n x: number | null,\n y: number | null,\n w: number | null,\n h: number | null,\n applyLayout: boolean,\n ): [number | null, number | null, number | null, number | null];\n\n /** Whether this view needs layout */\n readonly needsLayout: boolean;\n\n /** The minimum size this view requires */\n readonly minSize: TSU.Geom.Size;\n\n /** The bounding box of this view */\n readonly bbox: TSU.Geom.Rect;\n}\n\n/**\n * Enum defining the events that can occur on grid cells.\n */\nexport enum GridCellEvent {\n ADDED = \"CellAdded\",\n CLEARED = \"CellCleared\",\n REMOVED = \"CellRemoved\",\n UPDATED = \"CellUpdated\",\n MOVED = \"CellMoved\",\n}\n\n/**\n * Represents a cell in the grid.\n * GridCell holds a value and manages alignment with rows and columns.\n */\nexport class GridCell {\n private static idCounter = 0;\n readonly uuid = GridCell.idCounter++;\n /** The view associated with this cell */\n cellView: GridCellView | null;\n private _rowAlign: RowAlign;\n private _colAlign: ColAlign;\n\n /**\n * Creates a new GridCell.\n * @param gridRow The row this cell belongs to\n * @param colIndex The column index of this cell\n * @param value Optional initial value for the cell\n */\n constructor(\n public gridRow: GridRow,\n public colIndex: number,\n public value: any = null,\n ) {\n this.rowAlign = gridRow.defaultRowAlign;\n }\n\n /**\n * Gets the row alignment for this cell.\n */\n get rowAlign(): RowAlign {\n return this._rowAlign;\n }\n\n /**\n * Sets the row alignment for this cell.\n */\n set rowAlign(val: RowAlign) {\n val.addCell(this);\n this._rowAlign = val;\n }\n\n /**\n * Gets the column alignment for this cell.\n */\n get colAlign(): ColAlign {\n return this._colAlign;\n }\n\n /**\n * Sets the column alignment for this cell.\n */\n set colAlign(val: ColAlign) {\n val.addCell(this);\n this._colAlign = val;\n }\n\n /**\n * Gets the location string for this cell (rowIndex:colIndex).\n */\n get location(): string {\n return this.gridRow.rowIndex + \":\" + this.colIndex;\n }\n\n /**\n * Gets the grid this cell belongs to.\n */\n get grid(): GridModel {\n return this.gridRow.grid;\n }\n\n /**\n * Gets the row index of this cell.\n */\n get rowIndex(): number {\n return this.gridRow.rowIndex;\n }\n\n /**\n * Returns a debug-friendly representation of this GridCell.\n * @returns An object containing debug information\n */\n debugValue() {\n const out = {\n r: this.gridRow.rowIndex,\n c: this.colIndex,\n value: this.value,\n y: this.rowAlign.coordOffset,\n h: this.rowAlign.maxLength,\n } as any;\n if (this.colAlign) {\n out.x = this.colAlign.coordOffset;\n out.w = this.colAlign.maxLength;\n }\n return out;\n }\n}\n\n/**\n * Represents a row of grid cells in a GridModel.\n */\nexport class GridRow {\n /** The cells in this row */\n cells: (null | GridCell)[] = [];\n /** The default vertical alignment for all cells in this row */\n defaultRowAlign: RowAlign;\n\n /**\n * Creates a new GridRow.\n * @param grid The grid this row belongs to\n * @param rowIndex The index of this row\n */\n constructor(\n public grid: GridModel,\n public rowIndex: number,\n ) {\n this.defaultRowAlign = new RowAlign();\n this.grid.addRowAlign(this.defaultRowAlign);\n }\n\n /**\n * Gets the index of the first non-empty column in this row.\n */\n get firstCol() {\n for (let i = 0; i < this.cells.length; i++) {\n if (this.cells[i]?.value) {\n return i;\n }\n }\n return -1;\n }\n\n /**\n * Gets the number of columns in this row.\n */\n get numCols() {\n return this.cells.length;\n }\n\n /**\n * Gets the number of cells that contain values.\n */\n get numCells() {\n let i = 0;\n for (const cell of this.cells) {\n if (cell != null && cell.value != null) i++;\n }\n return i;\n }\n\n /**\n * Gets the cell at the specified column index, optionally creating it if it doesn't exist.\n * @param col The column index\n * @param creator Optional function to create the cell if it doesn't exist\n * @returns The cell at the specified index, or null if it doesn't exist and no creator was provided\n */\n cellAt(col: number, creator?: (row: GridRow, col: number) => GridCell): GridCell | null {\n let out = this.cells[col] || null;\n if (!out && creator) {\n this.cells[col] = out = creator(this, col);\n out.gridRow = this;\n out.colIndex = col;\n if (out.rowAlign) {\n this.grid.addRowAlign(out.rowAlign);\n }\n if (out.colAlign) {\n this.grid.addColAlign(out.colAlign);\n }\n }\n return out;\n }\n\n /**\n * Clears the cell at the given column.\n * Note this is not the same as \"removing\" a cell.\n * Removing a cell would require all cells to the \"right\" to be shifted left.\n * @param col The column index\n * @returns The cell that was cleared, or null if none existed\n */\n clearCellAt(col: number): GridCell | null {\n const out = this.cells[col] || null;\n if (out) {\n this.cells[col] = null;\n }\n return out;\n }\n\n /**\n * Returns a debug-friendly representation of this GridRow.\n * @returns An object containing debug information\n */\n debugValue() {\n return {\n r: this.rowIndex,\n cells: this.cells.filter((c) => c).map((c) => c?.debugValue()),\n };\n }\n}\n\n/**\n * Base class for row and column alignment objects.\n * AlignedLine manages the alignment of cells along a line (row or column).\n */\nexport abstract class AlignedLine {\n private static idCounter = 0;\n readonly uuid = AlignedLine.idCounter++;\n /** Whether this line needs layout */\n needsLayout = false;\n /** The coordinate offset of this line */\n protected _coordOffset = 0;\n /** The maximum length of this line */\n protected _maxLength = 0;\n /** Padding before this line */\n paddingBefore = 5;\n /** Padding after this line */\n paddingAfter = 5;\n /** The cells that belong to this line */\n cells: GridCell[] = [];\n /** Function to get a view for a cell value */\n getCellView: (value: any) => GridCellView;\n\n /**\n * Sets the offset of this line.\n * @param val The new offset value\n */\n abstract setOffset(val: number): void;\n\n /**\n * Evaluates the maximum length required for this line.\n * @param changedCells Cells that have changed and need re-evaluation\n * @returns The maximum length\n */\n abstract evalMaxLength(changedCells: GridCell[]): number;\n\n /**\n * Gets the coordinate offset of this line.\n */\n get coordOffset(): number {\n return this._coordOffset;\n }\n\n /**\n * Gets the maximum length of this line, including padding.\n */\n get maxLength(): number {\n return this._maxLength + this.paddingBefore + this.paddingAfter;\n }\n\n /**\n * Sets the maximum length of this line.\n * @param length The new maximum length\n */\n setMaxLength(length: number) {\n this._maxLength = length;\n }\n\n /**\n * Sets the padding before and after this line.\n * @param before Padding before the line\n * @param after Padding after the line\n */\n setPadding(before: number, after: number): void {\n if (before >= 0) {\n this.paddingBefore = before;\n }\n if (after >= 0) {\n this.paddingAfter = after;\n }\n }\n\n /**\n * Adds a cell to this line.\n * @param cell The cell to add\n * @returns This line instance for method chaining\n */\n addCell(cell: GridCell): this {\n if (this.beforeAddingCell(cell)) {\n this.cells.push(cell);\n }\n return this;\n }\n\n /**\n * Called before adding a cell to perform validation or preparation.\n * @param cell The cell to be added\n * @returns Whether the cell should be added\n */\n protected abstract beforeAddingCell(cell: GridCell): boolean;\n\n /**\n * Removes a cell from this line.\n * @param cell The cell to remove\n * @returns This line instance for method chaining\n */\n removeCell(cell: GridCell): this {\n if (this.beforeRemovingCell(cell)) {\n for (let i = 0; i < this.cells.length; i++) {\n if (this.cells[i].uuid == cell.uuid) {\n this.cells.splice(i, 1);\n break;\n }\n }\n }\n return this;\n }\n\n /**\n * Called before removing a cell to perform validation.\n * @param cell The cell to be removed\n * @returns Whether the cell should be removed\n */\n protected abstract beforeRemovingCell(cell: GridCell): boolean;\n\n // The \"neighboring\" lines that depend on this line to be placed\n // before they are placed\n /** Lines that must be positioned before this line */\n prevLines = [] as this[];\n /** Lines that must be positioned after this line */\n nextLines = [] as this[];\n\n /**\n * Adds a successor line to this line.\n * @param next The line to add as a successor\n */\n addSuccessor(next: this): void {\n // Set nextCol as a successor of this col\n // TODO - Ensure no cycles\n for (const c of this.nextLines) {\n if (c == next) return;\n }\n this.nextLines.push(next);\n next.prevLines.push(this);\n }\n\n /* TODO: Disabling only to improve test coverage as this method is\n * not used.\n * When we have mutable grids where we can insert/remove neighbors\n * we can enable this again.\n */\n /*\n removeSuccessor(next: this): void {\n // Set nextCol as a successor of this col\n // TODO - Ensure no cycles\n for (let i = 0; i < this.nextLines.length; i++) {\n if (this.nextLines[i] == next) {\n this.nextLines.splice(i, 1);\n break;\n }\n }\n for (let i = 0; i < next.prevLines.length; i++) {\n if (next.prevLines[i] == this) {\n next.prevLines.splice(i, 1);\n break;\n }\n }\n }\n */\n}\n\n/**\n * Manages the alignment of cells in a column.\n */\nexport class ColAlign extends AlignedLine {\n paddingBefore = 10;\n /** Padding after this line */\n paddingAfter = 10;\n\n /**\n * Sets the offset of this column and updates all associated cells.\n * @param val The new offset value\n */\n setOffset(val: number): void {\n this._coordOffset = val;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n if (this._maxLength <= 0) {\n // this hasnt been evaluated yet so do it!\n this.evalMaxLength();\n }\n cellView.setBounds(val, null, this.maxLength, null, true);\n }\n }\n }\n\n /**\n * Evaluates the maximum width required for this column.\n * @param changedCells Cells that have changed and need re-evaluation\n * @returns The maximum width\n */\n evalMaxLength(changedCells: GridCell[] = []): number {\n this._maxLength = 0;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n this._maxLength = Math.max(cellView.minSize.width, this._maxLength);\n }\n }\n return this._maxLength;\n }\n\n /**\n * Called before adding a cell to perform validation or preparation.\n * @param cell The cell to be added\n * @returns Whether the cell should be added\n */\n protected beforeAddingCell(cell: GridCell): boolean {\n if (cell.colAlign && cell.colAlign != this) {\n cell.colAlign.removeCell(cell);\n }\n return cell.colAlign != this;\n }\n\n /**\n * Called before removing a cell to perform validation.\n * @param cell The cell to be removed\n * @returns Whether the cell should be removed\n */\n beforeRemovingCell(cell: GridCell): boolean {\n return cell.colAlign == this;\n }\n}\n\n/**\n * Manages the alignment of cells in a row.\n */\nexport class RowAlign extends AlignedLine {\n /**\n * Sets the Y coordinate of all cells in this row.\n * @param val The new Y coordinate\n */\n setOffset(val: number): void {\n this._coordOffset = val;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n if (this._maxLength <= 0) {\n // this hasnt been evaluated yet so do it!\n this.evalMaxLength();\n }\n cellView.setBounds(null, val, null, this.maxLength, true);\n }\n }\n }\n\n /**\n * Evaluates the maximum height required for this row.\n * @param changedCells Cells that have changed and need re-evaluation\n * @returns The maximum height\n */\n evalMaxLength(changedCells: GridCell[] = []): number {\n this._maxLength = 0;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n this._maxLength = Math.max(cellView.minSize.height, this._maxLength);\n }\n }\n return this._maxLength;\n }\n\n /**\n * Called before adding a cell to perform validation or preparation.\n * @param cell The cell to be added\n * @returns Whether the cell should be added\n */\n protected beforeAddingCell(cell: GridCell): boolean {\n if (cell.rowAlign && cell.rowAlign != this) {\n cell.rowAlign.removeCell(cell);\n }\n return cell.rowAlign != this;\n }\n\n /**\n * Called before removing a cell to perform validation.\n * @param cell The cell to be removed\n * @returns Whether the cell should be removed\n */\n beforeRemovingCell(cell: GridCell): boolean {\n return cell.rowAlign == this;\n }\n}\n\n/**\n * The layout manager for a collection of GridViews bound by common alignment objects.\n * Manages the layout of multiple grid models, ensuring proper alignment between them.\n */\nexport class GridLayoutGroup {\n // rowAligns = new Map<number, RowAlign>();\n // colAligns = new Map<number, ColAlign>();\n /** The grid models managed by this layout group */\n gridModels = [] as GridModel[];\n\n /**\n * Event handler for processing events from grid models.\n */\n private eventHandler = (event: TSU.Events.TEvent) => {\n this.applyModelEvents(event.payload);\n };\n\n /**\n * Adds a grid model to this layout group.\n * @param gridModel The grid model to add\n * @returns True if the model was added successfully\n */\n addGridModel(gridModel: GridModel): boolean {\n gridModel.eventHub?.on(TSU.Events.EventHub.BATCH_EVENTS, this.eventHandler);\n this.gridModels.push(gridModel);\n return true;\n }\n\n /**\n * Gets all row alignment objects that have no predecessors.\n * @returns An array of starting row alignments\n */\n startingRowAligns(): RowAlign[] {\n const out = [] as RowAlign[];\n const visited = {} as any;\n for (const gm of this.gridModels) {\n for (const cell of gm.cellsInRow(gm.firstRow)) {\n if (cell.rowAlign && !visited[cell.rowAlign.uuid]) {\n visited[cell.rowAlign.uuid] = true;\n out.push(cell.rowAlign);\n }\n }\n }\n return out;\n }\n\n /**\n * Gets all column alignment objects that have no predecessors.\n * @returns An array of starting column alignments\n */\n startingColAligns(): ColAlign[] {\n const out = [] as ColAlign[];\n const visited = {} as any;\n for (const gm of this.gridModels) {\n for (const cell of gm.cellsInCol(gm.firstCol)) {\n if (cell.colAlign && !visited[cell.colAlign.uuid]) {\n visited[cell.colAlign.uuid] = true;\n out.push(cell.colAlign);\n }\n }\n }\n return out;\n }\n\n /**\n * Removes a grid model from this layout group.\n * @param gridModel The grid model to remove\n */\n removeGridModel(gridModel: GridModel): void {\n gridModel.eventHub?.removeOn(TSU.Events.EventHub.BATCH_EVENTS, this.eventHandler);\n }\n\n /**\n * Function to get a view for a cell value.\n */\n getCellView: (cell: GridCell) => GridCellView;\n\n /**\n * Gets the starting row alignments.\n */\n get startingRows(): RowAlign[] {\n return this.startingRowAligns();\n }\n\n /**\n * Gets the starting column alignments.\n */\n get startingCols(): ColAlign[] {\n return this.startingColAligns();\n }\n\n /**\n * Forces a full refresh of the layout.\n * This recalculates all row and column sizes and positions.\n */\n refreshLayout() {\n const changedRowAligns = {} as any;\n const changedColAligns = {} as any;\n\n for (const rowAlign of this.startingRowAligns()) {\n if (!(rowAlign.uuid in changedRowAligns)) {\n changedRowAligns[rowAlign.uuid] = {\n align: rowAlign,\n cells: [],\n };\n }\n }\n\n for (const colAlign of this.startingColAligns()) {\n if (!(colAlign.uuid in changedColAligns)) {\n changedColAligns[colAlign.uuid] = {\n align: colAlign,\n cells: [],\n };\n }\n }\n\n this.doBfsLayout(this.startingRows, changedRowAligns);\n this.doBfsLayout(this.startingCols, changedColAligns);\n }\n\n /**\n * Applies model events to update the layout.\n * @param events The events to process\n */\n protected applyModelEvents(events: TSU.Events.TEvent[]) {\n // As the grid model changes (cell content changed, cleared etc) we need\n // to refresh our layout based on this.\n // As a first step the new height and width of all changed cells is\n // evaluted to see which rows and/or columns are affected (and need to be\n // resized/repositioned).\n const [changedRowAligns, changedColAligns] = this.changesForEvents(events);\n this.doBfsLayout(this.startingRows, changedRowAligns);\n this.doBfsLayout(this.startingCols, changedColAligns);\n }\n\n /**\n * Determines which rows and columns need to be updated based on events.\n * @param events The events to process\n * @returns A tuple containing the changed row and column alignments\n */\n protected changesForEvents(events: TSU.Events.TEvent[]): [any, any] {\n // Step 1 - topologically sort RowAligns of changed cells\n // Step 2 - topologically sort ColAligns of changed cells\n // Step 3 -\n const cellVisited = {} as any;\n const changedRowAligns = {} as any;\n const changedColAligns = {} as any;\n // Going in reverse means we only get the latest event affecting a cell\n // instead of going through every change.\n // Later on we can revisit this if the events are edge triggered instead\n // of level triggered\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n const loc = event.payload.loc;\n if (cellVisited[loc]) continue;\n cellVisited[loc] = true;\n const [row, col] = loc.split(\":\").map((x: string) => parseInt(x));\n const gridModel = event.source;\n const cell = gridModel.getRow(row).cellAt(col);\n if (cell) {\n // TODO - For now we are marking both row and col as having\n // changed for a cell. We can optimize this to only row or\n // col based on whether height or width has changed.\n if (!(cell.rowAlign.uuid in changedRowAligns)) {\n changedRowAligns[cell.rowAlign.uuid] = {\n align: cell.rowAlign,\n cells: [],\n };\n }\n changedRowAligns[cell.rowAlign.uuid][\"cells\"].push(cell);\n\n if (!(cell.colAlign.uuid in changedColAligns)) {\n changedColAligns[cell.colAlign.uuid] = {\n align: cell.colAlign,\n cells: [],\n };\n }\n changedColAligns[cell.colAlign.uuid][\"cells\"].push(cell);\n }\n }\n return [changedRowAligns, changedColAligns];\n }\n\n /**\n * Ensures that a cell view getter function is available for an alignment.\n * @param align The alignment to check\n * @returns The cell view getter function\n */\n protected ensureGetCellView(align: AlignedLine) {\n if (!align.getCellView) {\n if (!this.getCellView) {\n return null;\n }\n align.getCellView = this.getCellView;\n }\n return align.getCellView;\n }\n\n /**\n * Performs a breadth-first layout of aligned lines.\n * @param startingLines The lines to start from\n * @param changedAligns Map of alignment IDs to changed alignments\n */\n protected doBfsLayout<T extends AlignedLine>(startingLines: T[], changedAligns: any) {\n // 1. start from the starting lines and do a BF traversal\n // 2. If a line not visited (ie laid out):\n // if it is in the changedAlign list then reval its length (w/h)\n // set its offset and length if either width or offset has changed\n // offset can be thought of changed if the preceding line's offset has changed\n // first do above for rows\n if (!this.getCellView) return;\n for (const alignId in changedAligns) {\n const val = changedAligns[alignId];\n this.ensureGetCellView(val.align);\n val.align.evalMaxLength(val.cells);\n }\n let lineQueue = [] as [null | T, T][];\n const visitedLines = {} as any;\n for (const line of startingLines) lineQueue.push([null, line]);\n const lineOffsetChanged = {} as any;\n while (lineQueue.length > 0) {\n const nextQueue = [] as [null | T, T][];\n for (let i = 0; i < lineQueue.length; i++) {\n const [prevLineAlign, lineAlign] = lineQueue[i];\n visitedLines[lineAlign.uuid] = true;\n let newOffset = lineAlign.coordOffset;\n let lineChanged = lineAlign.uuid in changedAligns;\n if (prevLineAlign) {\n if (lineOffsetChanged[prevLineAlign.uuid]) {\n newOffset = prevLineAlign.coordOffset + prevLineAlign.maxLength;\n lineChanged = true;\n }\n }\n if (lineChanged) {\n this.ensureGetCellView(lineAlign);\n lineAlign.setOffset(newOffset);\n lineOffsetChanged[lineAlign.uuid] = true;\n }\n\n // Add next neighbors now\n for (const next of lineAlign.nextLines) {\n if (!visitedLines[next.uuid]) {\n nextQueue.push([lineAlign, next]);\n }\n }\n }\n lineQueue = nextQueue;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grids.js","sourceRoot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AAC,EAAE,CAAC;wBAC7B,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;oBACpC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,SAAS,GAAG,SAAS,CAAC;QACxB,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AA1YD,0CA0YC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\n// import * as kiwi from \"@lume/kiwi\";\n\n/**\n * Event emitted when layout changes occur in a GridLayoutGroup.\n * Subscribers can use this to update their views incrementally.\n */\nexport interface LayoutChangeEvent {\n /** The range of rows affected by the change */\n affectedRowRange: { start: number; end: number } | null;\n /** The range of columns affected by the change */\n affectedColRange: { start: number; end: number } | null;\n /** Whether column widths changed (requires horizontal re-layout) */\n columnWidthsChanged: boolean;\n /** Whether row heights changed (requires vertical re-layout) */\n rowHeightsChanged: boolean;\n /** The grid models that were affected */\n affectedGridModels: GridModel[];\n}\n\n/**\n * Callback type for layout change subscribers.\n */\nexport type LayoutChangeCallback = (event: LayoutChangeEvent) => void;\n\n/**\n * A generic grid layout system for hosting child views (similar to GridBagLayout).\n * This provides a framework for hosting BeatViews in a structured grid arrangement,\n * with support for rows, columns, and alignment.\n *\n * Grid \"cells\" can be referred to by cell indexes. Additionally, grid rows and\n * columns can have names (like in spreadsheets) so that even when rows and columns\n * are inserted, though indexes may change, the \"addresses\" remain fixed and immovable.\n */\nexport class GridModel extends TSU.Events.EventEmitter {\n private static idCounter = 0;\n readonly uuid = GridModel.idCounter++;\n /** Timestamp of the last update to this grid */\n lastUpdatedAt = 0;\n // cells = new SparseArray<SparseArray<GridCell>>();\n /** The rows in this grid */\n rows: GridRow[] = [];\n /** Mapping of row indices to row alignment objects */\n rowAligns = new Map<number, RowAlign>();\n /** Mapping of column indices to column alignment objects */\n colAligns = new Map<number, ColAlign>();\n\n /**\n * Returns a debug-friendly representation of this GridModel.\n * @returns An object containing debug information\n */\n debugValue() {\n const out = {\n rows: this.rows.map((r) => r.debugValue()),\n lastUpdatedAt: this.lastUpdatedAt,\n } as any;\n return out;\n }\n\n /**\n * Gets the index of the first non-empty row.\n * @returns The index of the first row containing cells, or -1 if none\n */\n get firstRow(): number {\n for (const gr of this.rows) {\n if (gr.numCells > 0) return gr.rowIndex;\n }\n return -1;\n }\n\n /**\n * Gets the index of the leftmost column containing cells.\n * @returns The index of the first column containing cells, or -1 if none\n */\n get firstCol(): number {\n let minCol = -1;\n for (const gr of this.rows) {\n const fc = gr.firstCol;\n if (fc >= 0) {\n if (minCol < 0 || fc < minCol) {\n minCol = fc;\n }\n }\n }\n return minCol;\n }\n\n /**\n * Gets all non-empty cells in a specific row.\n * @param row The index of the row\n * @returns An array of cells in the row\n */\n cellsInRow(row: number): GridCell[] {\n const out = [] as GridCell[];\n const gr = this.rows[row];\n if (gr) {\n for (const cell of gr.cells) {\n if (cell?.value) out.push(cell);\n }\n }\n return out;\n }\n\n /**\n * Gets all non-empty cells in a specific column.\n * @param col The index of the column\n * @returns An array of cells in the column\n */\n cellsInCol(col: number): GridCell[] {\n const out = [] as GridCell[];\n for (const gr of this.rows) {\n const cell = gr.cellAt(col);\n if (cell?.value) out.push(cell);\n }\n return out;\n }\n\n /**\n * Adds a row alignment object to the grid.\n * @param align The row alignment to add\n */\n addRowAlign(align: RowAlign): void {\n this.rowAligns.set(align.uuid, align);\n }\n\n /**\n * Adds a column alignment object to the grid.\n * @param align The column alignment to add\n */\n addColAlign(align: ColAlign): void {\n this.colAligns.set(align.uuid, align);\n }\n\n /**\n * Adds rows to the grid.\n * @param insertBefore The index before which to insert the rows, or -1 to append\n * @param numRows The number of rows to add\n * @returns This grid instance for method chaining\n */\n addRows(insertBefore = -1, numRows = 1): this {\n if (insertBefore < 0) {\n insertBefore = this.rows.length;\n }\n let next = this.rows[insertBefore] || null;\n const prev = this.rows[insertBefore - 1] || null;\n for (let i = numRows - 1; i >= 0; i--) {\n const newRow = new GridRow(this, insertBefore + i);\n this.rows.splice(insertBefore, 0, newRow);\n if (next != null) {\n newRow.defaultRowAlign.addSuccessor(next.defaultRowAlign);\n }\n if (i == 0 && insertBefore > 0) {\n prev.defaultRowAlign.addSuccessor(newRow.defaultRowAlign);\n }\n next = newRow;\n }\n for (let i = insertBefore + numRows; i < this.rows.length; i++) {\n this.rows[i].rowIndex += numRows;\n }\n return this;\n }\n\n /**\n * Gets a row at the specified index, creating it if necessary.\n * @param row The index of the row to get\n * @returns The row at the specified index\n */\n getRow(row: number): GridRow {\n if (row >= this.rows.length) {\n this.addRows(-1, 1 + row - this.rows.length);\n }\n return this.rows[row];\n }\n\n /**\n * Sets a value in a cell at the specified row and column.\n * @param row The row index\n * @param col The column index\n * @param value The value to set\n * @param cellCreator Optional function to create a custom cell\n * @returns The previous value of the cell\n */\n setValue(row: number, col: number, value: any, cellCreator?: (row: GridRow, col: number) => GridCell): any {\n const grow = this.getRow(row);\n if (!cellCreator) {\n cellCreator = (row: GridRow, col: number) => {\n return new GridCell(row, col);\n };\n }\n if (value == null) {\n const out = grow.clearCellAt(col);\n if (out != null) {\n this.eventHub?.emit(GridCellEvent.CLEARED, this, {\n loc: out.location,\n });\n }\n return out;\n } else {\n const cell = grow.cellAt(col, cellCreator) as GridCell;\n const oldValue = cell.value;\n this.eventHub?.emit(GridCellEvent.UPDATED, this, {\n loc: cell.location,\n cell: cell,\n oldValue: cell.value,\n });\n cell.value = value;\n return oldValue;\n }\n }\n\n /**\n * Handles changes to the event hub.\n */\n protected eventHubChanged(): void {\n console.log(\"Event Hub Changed for GridModel\");\n }\n}\n\n/**\n * Interface for a view associated with a grid cell.\n * GridCellView defines the contract for views that can be placed in grid cells.\n */\nexport interface GridCellView {\n /** The grid cell this view is associated with */\n readonly cell: GridCell;\n /** X-coordinate of the view */\n x: number;\n /** Y-coordinate of the view */\n y: number;\n /** Width of the view */\n width: number;\n /** Height of the view */\n height: number;\n\n /**\n * Sets the bounds of the view.\n * @param x New x-coordinate, or null to keep current value\n * @param y New y-coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @param applyLayout Whether to apply layout immediately\n * @returns The new bounds values\n */\n setBounds(\n x: number | null,\n y: number | null,\n w: number | null,\n h: number | null,\n applyLayout: boolean,\n ): [number | null, number | null, number | null, number | null];\n\n /** Whether this view needs layout */\n readonly needsLayout: boolean;\n\n /** The minimum size this view requires */\n readonly minSize: TSU.Geom.Size;\n\n /** The bounding box of this view */\n readonly bbox: TSU.Geom.Rect;\n}\n\n/**\n * Enum defining the events that can occur on grid cells.\n */\nexport enum GridCellEvent {\n ADDED = \"CellAdded\",\n CLEARED = \"CellCleared\",\n REMOVED = \"CellRemoved\",\n UPDATED = \"CellUpdated\",\n MOVED = \"CellMoved\",\n}\n\n/**\n * Represents a cell in the grid.\n * GridCell holds a value and manages alignment with rows and columns.\n */\nexport class GridCell {\n private static idCounter = 0;\n readonly uuid = GridCell.idCounter++;\n /** The view associated with this cell */\n cellView: GridCellView | null;\n private _rowAlign: RowAlign;\n private _colAlign: ColAlign;\n\n /**\n * Creates a new GridCell.\n * @param gridRow The row this cell belongs to\n * @param colIndex The column index of this cell\n * @param value Optional initial value for the cell\n */\n constructor(\n public gridRow: GridRow,\n public colIndex: number,\n public value: any = null,\n ) {\n this.rowAlign = gridRow.defaultRowAlign;\n }\n\n /**\n * Gets the row alignment for this cell.\n */\n get rowAlign(): RowAlign {\n return this._rowAlign;\n }\n\n /**\n * Sets the row alignment for this cell.\n */\n set rowAlign(val: RowAlign) {\n val.addCell(this);\n this._rowAlign = val;\n }\n\n /**\n * Gets the column alignment for this cell.\n */\n get colAlign(): ColAlign {\n return this._colAlign;\n }\n\n /**\n * Sets the column alignment for this cell.\n */\n set colAlign(val: ColAlign) {\n val.addCell(this);\n this._colAlign = val;\n }\n\n /**\n * Gets the location string for this cell (rowIndex:colIndex).\n */\n get location(): string {\n return this.gridRow.rowIndex + \":\" + this.colIndex;\n }\n\n /**\n * Gets the grid this cell belongs to.\n */\n get grid(): GridModel {\n return this.gridRow.grid;\n }\n\n /**\n * Gets the row index of this cell.\n */\n get rowIndex(): number {\n return this.gridRow.rowIndex;\n }\n\n /**\n * Returns a debug-friendly representation of this GridCell.\n * @returns An object containing debug information\n */\n debugValue() {\n const out = {\n r: this.gridRow.rowIndex,\n c: this.colIndex,\n value: this.value,\n y: this.rowAlign.coordOffset,\n h: this.rowAlign.maxLength,\n } as any;\n if (this.colAlign) {\n out.x = this.colAlign.coordOffset;\n out.w = this.colAlign.maxLength;\n }\n return out;\n }\n}\n\n/**\n * Represents a row of grid cells in a GridModel.\n */\nexport class GridRow {\n /** The cells in this row */\n cells: (null | GridCell)[] = [];\n /** The default vertical alignment for all cells in this row */\n defaultRowAlign: RowAlign;\n\n /**\n * Creates a new GridRow.\n * @param grid The grid this row belongs to\n * @param rowIndex The index of this row\n */\n constructor(\n public grid: GridModel,\n public rowIndex: number,\n ) {\n this.defaultRowAlign = new RowAlign();\n this.grid.addRowAlign(this.defaultRowAlign);\n }\n\n /**\n * Gets the index of the first non-empty column in this row.\n */\n get firstCol() {\n for (let i = 0; i < this.cells.length; i++) {\n if (this.cells[i]?.value) {\n return i;\n }\n }\n return -1;\n }\n\n /**\n * Gets the number of columns in this row.\n */\n get numCols() {\n return this.cells.length;\n }\n\n /**\n * Gets the number of cells that contain values.\n */\n get numCells() {\n let i = 0;\n for (const cell of this.cells) {\n if (cell != null && cell.value != null) i++;\n }\n return i;\n }\n\n /**\n * Gets the cell at the specified column index, optionally creating it if it doesn't exist.\n * @param col The column index\n * @param creator Optional function to create the cell if it doesn't exist\n * @returns The cell at the specified index, or null if it doesn't exist and no creator was provided\n */\n cellAt(col: number, creator?: (row: GridRow, col: number) => GridCell): GridCell | null {\n let out = this.cells[col] || null;\n if (!out && creator) {\n this.cells[col] = out = creator(this, col);\n out.gridRow = this;\n out.colIndex = col;\n if (out.rowAlign) {\n this.grid.addRowAlign(out.rowAlign);\n }\n if (out.colAlign) {\n this.grid.addColAlign(out.colAlign);\n }\n }\n return out;\n }\n\n /**\n * Clears the cell at the given column.\n * Note this is not the same as \"removing\" a cell.\n * Removing a cell would require all cells to the \"right\" to be shifted left.\n * @param col The column index\n * @returns The cell that was cleared, or null if none existed\n */\n clearCellAt(col: number): GridCell | null {\n const out = this.cells[col] || null;\n if (out) {\n this.cells[col] = null;\n }\n return out;\n }\n\n /**\n * Returns a debug-friendly representation of this GridRow.\n * @returns An object containing debug information\n */\n debugValue() {\n return {\n r: this.rowIndex,\n cells: this.cells.filter((c) => c).map((c) => c?.debugValue()),\n };\n }\n}\n\n/**\n * Base class for row and column alignment objects.\n * AlignedLine manages the alignment of cells along a line (row or column).\n */\nexport abstract class AlignedLine {\n private static idCounter = 0;\n readonly uuid = AlignedLine.idCounter++;\n /** Whether this line needs layout */\n needsLayout = false;\n /** The coordinate offset of this line */\n protected _coordOffset = 0;\n /** The maximum length of this line */\n protected _maxLength = 0;\n /** Padding before this line */\n paddingBefore = 5;\n /** Padding after this line */\n paddingAfter = 5;\n /** The cells that belong to this line */\n cells: GridCell[] = [];\n /** Function to get a view for a cell value */\n getCellView: (value: any) => GridCellView;\n\n /**\n * Sets the offset of this line.\n * @param val The new offset value\n */\n abstract setOffset(val: number): void;\n\n /**\n * Evaluates the maximum length required for this line.\n * @param changedCells Cells that have changed and need re-evaluation\n * @returns The maximum length\n */\n abstract evalMaxLength(changedCells: GridCell[]): number;\n\n /**\n * Gets the coordinate offset of this line.\n */\n get coordOffset(): number {\n return this._coordOffset;\n }\n\n /**\n * Gets the maximum length of this line, including padding.\n */\n get maxLength(): number {\n return this._maxLength + this.paddingBefore + this.paddingAfter;\n }\n\n /**\n * Sets the maximum length of this line.\n * @param length The new maximum length\n */\n setMaxLength(length: number) {\n this._maxLength = length;\n }\n\n /**\n * Sets the padding before and after this line.\n * @param before Padding before the line\n * @param after Padding after the line\n */\n setPadding(before: number, after: number): void {\n if (before >= 0) {\n this.paddingBefore = before;\n }\n if (after >= 0) {\n this.paddingAfter = after;\n }\n }\n\n /**\n * Adds a cell to this line.\n * @param cell The cell to add\n * @returns This line instance for method chaining\n */\n addCell(cell: GridCell): this {\n if (this.beforeAddingCell(cell)) {\n this.cells.push(cell);\n }\n return this;\n }\n\n /**\n * Called before adding a cell to perform validation or preparation.\n * @param cell The cell to be added\n * @returns Whether the cell should be added\n */\n protected abstract beforeAddingCell(cell: GridCell): boolean;\n\n /**\n * Removes a cell from this line.\n * @param cell The cell to remove\n * @returns This line instance for method chaining\n */\n removeCell(cell: GridCell): this {\n if (this.beforeRemovingCell(cell)) {\n for (let i = 0; i < this.cells.length; i++) {\n if (this.cells[i].uuid == cell.uuid) {\n this.cells.splice(i, 1);\n break;\n }\n }\n }\n return this;\n }\n\n /**\n * Called before removing a cell to perform validation.\n * @param cell The cell to be removed\n * @returns Whether the cell should be removed\n */\n protected abstract beforeRemovingCell(cell: GridCell): boolean;\n\n // The \"neighboring\" lines that depend on this line to be placed\n // before they are placed\n /** Lines that must be positioned before this line */\n prevLines = [] as this[];\n /** Lines that must be positioned after this line */\n nextLines = [] as this[];\n\n /**\n * Adds a successor line to this line.\n * @param next The line to add as a successor\n */\n addSuccessor(next: this): void {\n // Set nextCol as a successor of this col\n // TODO - Ensure no cycles\n for (const c of this.nextLines) {\n if (c == next) return;\n }\n this.nextLines.push(next);\n next.prevLines.push(this);\n }\n\n /* TODO: Disabling only to improve test coverage as this method is\n * not used.\n * When we have mutable grids where we can insert/remove neighbors\n * we can enable this again.\n */\n /*\n removeSuccessor(next: this): void {\n // Set nextCol as a successor of this col\n // TODO - Ensure no cycles\n for (let i = 0; i < this.nextLines.length; i++) {\n if (this.nextLines[i] == next) {\n this.nextLines.splice(i, 1);\n break;\n }\n }\n for (let i = 0; i < next.prevLines.length; i++) {\n if (next.prevLines[i] == this) {\n next.prevLines.splice(i, 1);\n break;\n }\n }\n }\n */\n}\n\n/**\n * Manages the alignment of cells in a column.\n */\nexport class ColAlign extends AlignedLine {\n paddingBefore = 10;\n /** Padding after this line */\n paddingAfter = 10;\n\n /**\n * Sets the offset of this column and updates all associated cells.\n * @param val The new offset value\n */\n setOffset(val: number): void {\n this._coordOffset = val;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n if (this._maxLength <= 0) {\n // this hasnt been evaluated yet so do it!\n this.evalMaxLength();\n }\n cellView.setBounds(val, null, this.maxLength, null, true);\n }\n }\n }\n\n /**\n * Evaluates the maximum width required for this column.\n * @param changedCells Cells that have changed and need re-evaluation\n * @returns The maximum width\n */\n evalMaxLength(changedCells: GridCell[] = []): number {\n this._maxLength = 0;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n this._maxLength = Math.max(cellView.minSize.width, this._maxLength);\n }\n }\n return this._maxLength;\n }\n\n /**\n * Called before adding a cell to perform validation or preparation.\n * @param cell The cell to be added\n * @returns Whether the cell should be added\n */\n protected beforeAddingCell(cell: GridCell): boolean {\n if (cell.colAlign && cell.colAlign != this) {\n cell.colAlign.removeCell(cell);\n }\n return cell.colAlign != this;\n }\n\n /**\n * Called before removing a cell to perform validation.\n * @param cell The cell to be removed\n * @returns Whether the cell should be removed\n */\n beforeRemovingCell(cell: GridCell): boolean {\n return cell.colAlign == this;\n }\n}\n\n/**\n * Manages the alignment of cells in a row.\n */\nexport class RowAlign extends AlignedLine {\n /**\n * Sets the Y coordinate of all cells in this row.\n * @param val The new Y coordinate\n */\n setOffset(val: number): void {\n this._coordOffset = val;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n if (this._maxLength <= 0) {\n // this hasnt been evaluated yet so do it!\n this.evalMaxLength();\n }\n cellView.setBounds(null, val, null, this.maxLength, true);\n }\n }\n }\n\n /**\n * Evaluates the maximum height required for this row.\n * @param changedCells Cells that have changed and need re-evaluation\n * @returns The maximum height\n */\n evalMaxLength(changedCells: GridCell[] = []): number {\n this._maxLength = 0;\n for (const cell of this.cells) {\n if (cell.value) {\n const cellView = this.getCellView(cell);\n this._maxLength = Math.max(cellView.minSize.height, this._maxLength);\n }\n }\n return this._maxLength;\n }\n\n /**\n * Called before adding a cell to perform validation or preparation.\n * @param cell The cell to be added\n * @returns Whether the cell should be added\n */\n protected beforeAddingCell(cell: GridCell): boolean {\n if (cell.rowAlign && cell.rowAlign != this) {\n cell.rowAlign.removeCell(cell);\n }\n return cell.rowAlign != this;\n }\n\n /**\n * Called before removing a cell to perform validation.\n * @param cell The cell to be removed\n * @returns Whether the cell should be removed\n */\n beforeRemovingCell(cell: GridCell): boolean {\n return cell.rowAlign == this;\n }\n}\n\n/**\n * The layout manager for a collection of GridViews bound by common alignment objects.\n * Manages the layout of multiple grid models, ensuring proper alignment between them.\n */\nexport class GridLayoutGroup {\n // rowAligns = new Map<number, RowAlign>();\n // colAligns = new Map<number, ColAlign>();\n /** The grid models managed by this layout group */\n gridModels = [] as GridModel[];\n\n /** Subscribers to layout change events */\n private layoutChangeSubscribers = new Set<LayoutChangeCallback>();\n\n /** Previous column widths by ColAlign uuid - for detecting actual changes */\n private previousColumnWidths = new Map<number, number>();\n\n /** Previous row heights by RowAlign uuid - for detecting actual changes */\n private previousRowHeights = new Map<number, number>();\n\n /**\n * Subscribes to layout change events.\n * @param callback Function to call when layout changes\n * @returns Unsubscribe function\n */\n onLayoutChange(callback: LayoutChangeCallback): () => void {\n this.layoutChangeSubscribers.add(callback);\n return () => {\n this.layoutChangeSubscribers.delete(callback);\n };\n }\n\n /**\n * Notifies all subscribers of a layout change.\n * @param event The layout change event\n */\n protected notifyLayoutChange(event: LayoutChangeEvent): void {\n for (const callback of this.layoutChangeSubscribers) {\n try {\n callback(event);\n } catch (e) {\n console.error(\"Error in layout change callback:\", e);\n }\n }\n }\n\n /**\n * Gets the number of layout change subscribers.\n */\n get subscriberCount(): number {\n return this.layoutChangeSubscribers.size;\n }\n\n /**\n * Event handler for processing events from grid models.\n */\n private eventHandler = (event: TSU.Events.TEvent) => {\n this.applyModelEvents(event.payload);\n };\n\n /**\n * Adds a grid model to this layout group.\n * @param gridModel The grid model to add\n * @returns True if the model was added successfully\n */\n addGridModel(gridModel: GridModel): boolean {\n gridModel.eventHub?.on(TSU.Events.EventHub.BATCH_EVENTS, this.eventHandler);\n this.gridModels.push(gridModel);\n return true;\n }\n\n /**\n * Gets all row alignment objects that have no predecessors.\n * @returns An array of starting row alignments\n */\n startingRowAligns(): RowAlign[] {\n const out = [] as RowAlign[];\n const visited = {} as any;\n for (const gm of this.gridModels) {\n for (const cell of gm.cellsInRow(gm.firstRow)) {\n if (cell.rowAlign && !visited[cell.rowAlign.uuid]) {\n visited[cell.rowAlign.uuid] = true;\n out.push(cell.rowAlign);\n }\n }\n }\n return out;\n }\n\n /**\n * Gets all column alignment objects that have no predecessors.\n * @returns An array of starting column alignments\n */\n startingColAligns(): ColAlign[] {\n const out = [] as ColAlign[];\n const visited = {} as any;\n for (const gm of this.gridModels) {\n for (const cell of gm.cellsInCol(gm.firstCol)) {\n if (cell.colAlign && !visited[cell.colAlign.uuid]) {\n visited[cell.colAlign.uuid] = true;\n out.push(cell.colAlign);\n }\n }\n }\n return out;\n }\n\n /**\n * Removes a grid model from this layout group.\n * @param gridModel The grid model to remove\n */\n removeGridModel(gridModel: GridModel): void {\n gridModel.eventHub?.removeOn(TSU.Events.EventHub.BATCH_EVENTS, this.eventHandler);\n }\n\n /**\n * Function to get a view for a cell value.\n */\n getCellView: (cell: GridCell) => GridCellView;\n\n /**\n * Gets the starting row alignments.\n */\n get startingRows(): RowAlign[] {\n return this.startingRowAligns();\n }\n\n /**\n * Gets the starting column alignments.\n */\n get startingCols(): ColAlign[] {\n return this.startingColAligns();\n }\n\n /**\n * Forces a full refresh of the layout.\n * This recalculates all row and column sizes and positions.\n * @param notify Whether to notify subscribers of the change (default: true)\n */\n refreshLayout(notify = true): void {\n const changedRowAligns = {} as any;\n const changedColAligns = {} as any;\n\n for (const rowAlign of this.startingRowAligns()) {\n if (!(rowAlign.uuid in changedRowAligns)) {\n changedRowAligns[rowAlign.uuid] = {\n align: rowAlign,\n cells: [],\n };\n }\n }\n\n for (const colAlign of this.startingColAligns()) {\n if (!(colAlign.uuid in changedColAligns)) {\n changedColAligns[colAlign.uuid] = {\n align: colAlign,\n cells: [],\n };\n }\n }\n\n // Pass the previous dimension maps for O(1) inline change detection\n const rowHeightsChanged = this.doBfsLayout(this.startingRows, changedRowAligns, this.previousRowHeights);\n const columnWidthsChanged = this.doBfsLayout(this.startingCols, changedColAligns, this.previousColumnWidths);\n\n // Notify subscribers of full refresh\n if (notify && this.layoutChangeSubscribers.size > 0) {\n this.notifyLayoutChange({\n affectedRowRange: null, // null means all rows\n affectedColRange: null, // null means all columns\n columnWidthsChanged,\n rowHeightsChanged,\n affectedGridModels: this.gridModels,\n });\n }\n }\n\n /**\n * Applies model events to update the layout.\n * @param events The events to process\n */\n protected applyModelEvents(events: TSU.Events.TEvent[]): void {\n // As the grid model changes (cell content changed, cleared etc) we need\n // to refresh our layout based on this.\n // As a first step the new height and width of all changed cells is\n // evaluted to see which rows and/or columns are affected (and need to be\n // resized/repositioned).\n const [changedRowAligns, changedColAligns, affectedGridModels] = this.changesForEvents(events);\n const hadRowChanges = Object.keys(changedRowAligns).length > 0;\n const hadColChanges = Object.keys(changedColAligns).length > 0;\n\n // Pass the previous dimension maps for O(1) inline change detection\n const rowHeightsChanged = this.doBfsLayout(this.startingRows, changedRowAligns, this.previousRowHeights);\n const columnWidthsChanged = this.doBfsLayout(this.startingCols, changedColAligns, this.previousColumnWidths);\n\n // Notify subscribers of incremental changes\n if (this.layoutChangeSubscribers.size > 0 && (hadRowChanges || hadColChanges)) {\n // Calculate affected ranges from the changed alignments\n const affectedRowRange = this.calculateAffectedRowRange(changedRowAligns);\n const affectedColRange = this.calculateAffectedColRange(changedColAligns);\n\n this.notifyLayoutChange({\n affectedRowRange,\n affectedColRange,\n columnWidthsChanged,\n rowHeightsChanged,\n affectedGridModels: affectedGridModels,\n });\n }\n }\n\n /**\n * Calculates the range of affected rows from changed row alignments.\n * Returns null if no rows changed or range cannot be determined.\n */\n protected calculateAffectedRowRange(changedRowAligns: any): { start: number; end: number } | null {\n let minRow = Infinity;\n let maxRow = -Infinity;\n\n for (const alignId in changedRowAligns) {\n const { cells } = changedRowAligns[alignId];\n for (const cell of cells) {\n const rowIndex = cell.gridRow.rowIndex;\n minRow = Math.min(minRow, rowIndex);\n maxRow = Math.max(maxRow, rowIndex);\n }\n }\n\n if (minRow === Infinity) return null;\n return { start: minRow, end: maxRow };\n }\n\n /**\n * Calculates the range of affected columns from changed column alignments.\n * Returns null if no columns changed or range cannot be determined.\n */\n protected calculateAffectedColRange(changedColAligns: any): { start: number; end: number } | null {\n let minCol = Infinity;\n let maxCol = -Infinity;\n\n for (const alignId in changedColAligns) {\n const { cells } = changedColAligns[alignId];\n for (const cell of cells) {\n const colIndex = cell.colIndex;\n minCol = Math.min(minCol, colIndex);\n maxCol = Math.max(maxCol, colIndex);\n }\n }\n\n if (minCol === Infinity) return null;\n return { start: minCol, end: maxCol };\n }\n\n /**\n * Checks if an alignment's maxLength changed from previous value.\n * Updates the stored previous value. O(1) cost.\n * @param align The alignment to check\n * @param previousMap Map storing previous lengths\n * @returns true if length changed (or is new)\n */\n private checkAndUpdateLength<T extends AlignedLine>(align: T, previousMap: Map<number, number>): boolean {\n const previous = previousMap.get(align.uuid);\n const current = align.maxLength;\n previousMap.set(align.uuid, current);\n return previous === undefined || previous !== current;\n }\n\n /**\n * Determines which rows and columns need to be updated based on events.\n * @param events The events to process\n * @returns A tuple containing the changed row alignments, column alignments, and affected grid models\n */\n protected changesForEvents(events: TSU.Events.TEvent[]): [any, any, GridModel[]] {\n // Step 1 - topologically sort RowAligns of changed cells\n // Step 2 - topologically sort ColAligns of changed cells\n // Step 3 -\n const cellVisited = {} as any;\n const changedRowAligns = {} as any;\n const changedColAligns = {} as any;\n const affectedGridModelsSet = new Set<GridModel>();\n // Going in reverse means we only get the latest event affecting a cell\n // instead of going through every change.\n // Later on we can revisit this if the events are edge triggered instead\n // of level triggered\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n const loc = event.payload.loc;\n if (cellVisited[loc]) continue;\n cellVisited[loc] = true;\n const [row, col] = loc.split(\":\").map((x: string) => parseInt(x));\n const gridModel = event.source as GridModel;\n affectedGridModelsSet.add(gridModel);\n const cell = gridModel.getRow(row).cellAt(col);\n if (cell) {\n // TODO - For now we are marking both row and col as having\n // changed for a cell. We can optimize this to only row or\n // col based on whether height or width has changed.\n if (!(cell.rowAlign.uuid in changedRowAligns)) {\n changedRowAligns[cell.rowAlign.uuid] = {\n align: cell.rowAlign,\n cells: [],\n };\n }\n changedRowAligns[cell.rowAlign.uuid][\"cells\"].push(cell);\n\n if (!(cell.colAlign.uuid in changedColAligns)) {\n changedColAligns[cell.colAlign.uuid] = {\n align: cell.colAlign,\n cells: [],\n };\n }\n changedColAligns[cell.colAlign.uuid][\"cells\"].push(cell);\n }\n }\n return [changedRowAligns, changedColAligns, Array.from(affectedGridModelsSet)];\n }\n\n /**\n * Ensures that a cell view getter function is available for an alignment.\n * @param align The alignment to check\n * @returns The cell view getter function\n */\n protected ensureGetCellView(align: AlignedLine) {\n if (!align.getCellView) {\n if (!this.getCellView) {\n return null;\n }\n align.getCellView = this.getCellView;\n }\n return align.getCellView;\n }\n\n /**\n * Performs a breadth-first layout of aligned lines.\n * @param startingLines The lines to start from\n * @param changedAligns Map of alignment IDs to changed alignments\n * @param previousLengths Map to track previous lengths for change detection\n * @returns true if any dimension (width/height) actually changed\n */\n protected doBfsLayout<T extends AlignedLine>(\n startingLines: T[],\n changedAligns: any,\n previousLengths?: Map<number, number>,\n ): boolean {\n // 1. start from the starting lines and do a BF traversal\n // 2. If a line not visited (ie laid out):\n // if it is in the changedAlign list then reval its length (w/h)\n // set its offset and length if either width or offset has changed\n // offset can be thought of changed if the preceding line's offset has changed\n // first do above for rows\n if (!this.getCellView) return false;\n let anyDimensionChanged = false;\n\n for (const alignId in changedAligns) {\n const val = changedAligns[alignId];\n this.ensureGetCellView(val.align);\n val.align.evalMaxLength(val.cells);\n\n // Check if this alignment's length actually changed (O(1))\n if (previousLengths && this.checkAndUpdateLength(val.align, previousLengths)) {\n anyDimensionChanged = true;\n }\n }\n\n let lineQueue = [] as [null | T, T][];\n const visitedLines = {} as any;\n for (const line of startingLines) lineQueue.push([null, line]);\n const lineOffsetChanged = {} as any;\n while (lineQueue.length > 0) {\n const nextQueue = [] as [null | T, T][];\n for (let i = 0; i < lineQueue.length; i++) {\n const [prevLineAlign, lineAlign] = lineQueue[i];\n visitedLines[lineAlign.uuid] = true;\n let newOffset = lineAlign.coordOffset;\n let lineChanged = lineAlign.uuid in changedAligns;\n if (prevLineAlign) {\n if (lineOffsetChanged[prevLineAlign.uuid]) {\n newOffset = prevLineAlign.coordOffset + prevLineAlign.maxLength;\n lineChanged = true;\n }\n }\n if (lineChanged) {\n this.ensureGetCellView(lineAlign);\n lineAlign.setOffset(newOffset);\n lineOffsetChanged[lineAlign.uuid] = true;\n }\n\n // Add next neighbors now\n for (const next of lineAlign.nextLines) {\n if (!visitedLines[next.uuid]) {\n nextQueue.push([lineAlign, next]);\n }\n }\n }\n lineQueue = nextQueue;\n }\n\n return anyDimensionChanged;\n }\n}\n"]}
|
package/lib/cjs/index.d.ts
CHANGED
package/lib/cjs/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __exportStar(require("./cycle"), exports);
|
|
|
42
42
|
__exportStar(require("./core"), exports);
|
|
43
43
|
__exportStar(require("./iterators"), exports);
|
|
44
44
|
__exportStar(require("./layouts"), exports);
|
|
45
|
+
__exportStar(require("./grids"), exports);
|
|
45
46
|
__exportStar(require("./beats"), exports);
|
|
46
47
|
__exportStar(require("./notation"), exports);
|
|
47
48
|
__exportStar(require("./parser"), exports);
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,0CAAwB;AACxB,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,iDAAiC;AACjC,uDAAuC","sourcesContent":["export * from \"./entity\";\nexport * from \"./cycle\";\nexport * from \"./core\";\nexport * from \"./iterators\";\nexport * from \"./layouts\";\nexport * from \"./beats\";\nexport * from \"./notation\";\nexport * from \"./parser\";\nexport * from \"./shapes\";\nexport * from \"./loader\";\nexport * as Utils from \"./utils\";\nexport * as Carnatic from \"./carnatic\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,iDAAiC;AACjC,uDAAuC","sourcesContent":["export * from \"./entity\";\nexport * from \"./cycle\";\nexport * from \"./core\";\nexport * from \"./iterators\";\nexport * from \"./layouts\";\nexport * from \"./grids\";\nexport * from \"./beats\";\nexport * from \"./notation\";\nexport * from \"./parser\";\nexport * from \"./shapes\";\nexport * from \"./loader\";\nexport * as Utils from \"./utils\";\nexport * as Carnatic from \"./carnatic\";\n"]}
|
package/lib/cjs/loader.js
CHANGED
|
@@ -1,41 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.parse = parse;
|
|
37
4
|
exports.load = load;
|
|
38
|
-
const TSU = __importStar(require("@panyam/tsutils"));
|
|
39
5
|
const beats_1 = require("./beats");
|
|
40
6
|
const parser_1 = require("./parser");
|
|
41
7
|
function parse(input) {
|
|
@@ -47,13 +13,7 @@ function load(codeText, config = {}) {
|
|
|
47
13
|
const startTime = performance.now();
|
|
48
14
|
const [notation, errors] = parse(codeText);
|
|
49
15
|
const parseTime = performance.now();
|
|
50
|
-
|
|
51
|
-
if (block.TYPE == "Line" && !block.isEmpty) {
|
|
52
|
-
const line = block;
|
|
53
|
-
TSU.assert(line.layoutParams != null, "Layout params for a non empty line *SHOULD* exist");
|
|
54
|
-
beatLayout.addLine(line);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
16
|
+
beatLayout.processBlock(notation);
|
|
57
17
|
const buildTime = performance.now();
|
|
58
18
|
if (config.log) {
|
|
59
19
|
console.log(`V4 Document, Parse Time: ${parseTime - startTime}ms, Build Time: ${buildTime - parseTime}ms`);
|
package/lib/cjs/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":";;AAYA,sBAEC;AASD,oBA2BC;AAhDD,mCAA2C;AAC3C,qCAAkC;AASlC,SAAgB,KAAK,CAAC,KAAa;IACjC,OAAO,IAAI,eAAM,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AASD,SAAgB,IAAI,CAClB,QAAgB,EAChB,SAAc,EAAE;IAEhB,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,IAAI,wBAAgB,EAAE,CAAC;IAC1C,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAIpC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAElC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,GAAG,SAAS,mBAAmB,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC;IAC7G,CAAC;IACD,OAAO;QACL,QAAQ;QACR,UAAU;QACV,MAAM;QACN;YACE,SAAS,EAAE,SAAS,GAAG,SAAS;YAChC,SAAS,EAAE,SAAS,GAAG,SAAS;SACjC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport { GlobalBeatLayout } from \"./beats\";\nimport { Parser } from \"./parser\";\nimport { Notation } from \"./notation\";\n\n/**\n * Parses a notation string into a Notation object.\n *\n * @param input The notation string to parse\n * @returns A tuple containing the parsed Notation and any parsing errors\n */\nexport function parse(input: string): [Notation, G.ParseError[]] {\n return new Parser().parseAndBuild(input);\n}\n\n/**\n * Loads a notation from a string and builds the beat layout.\n *\n * @param codeText The notation string to load\n * @param config Optional configuration object\n * @returns A tuple containing the Notation, GlobalBeatLayout, parsing errors, and timing information\n */\nexport function load(\n codeText: string,\n config: any = {},\n): [Notation, GlobalBeatLayout, G.ParseError[], TSU.StringMap<number>] {\n codeText = codeText || \"\";\n const beatLayout = new GlobalBeatLayout();\n const startTime = performance.now();\n const [notation, errors] = parse(codeText);\n const parseTime = performance.now();\n\n // Process all blocks recursively using block.children()\n // This handles nested blocks like \\repeat { }, \\section { }, etc.\n beatLayout.processBlock(notation);\n\n const buildTime = performance.now();\n if (config.log) {\n console.log(`V4 Document, Parse Time: ${parseTime - startTime}ms, Build Time: ${buildTime - parseTime}ms`);\n }\n return [\n notation,\n beatLayout,\n errors,\n {\n parseTime: parseTime - startTime,\n buildTime: buildTime - parseTime,\n },\n ];\n}\n"]}
|