@tspro/web-music-score 5.4.0 → 5.4.1

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 (40) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +1 -1
  3. package/README.md +4 -4
  4. package/dist/audio/index.d.ts +1 -1
  5. package/dist/audio/index.js +1 -1
  6. package/dist/audio/index.mjs +3 -3
  7. package/dist/audio-cg/index.js +1 -1
  8. package/dist/audio-cg/index.mjs +3 -3
  9. package/dist/audio-synth/index.js +1 -1
  10. package/dist/audio-synth/index.mjs +3 -3
  11. package/dist/{chunk-QGMOI7AP.mjs → chunk-5I5KENEC.mjs} +2 -2
  12. package/dist/{chunk-ZWUBO5EW.mjs → chunk-6P4ECBUH.mjs} +3 -3
  13. package/dist/{chunk-MHDBTCVG.mjs → chunk-A5SMODAT.mjs} +3 -3
  14. package/dist/{chunk-AUT4C6TY.mjs → chunk-U2ACCEHX.mjs} +2 -2
  15. package/dist/core/index.js +2 -2
  16. package/dist/core/index.mjs +4 -4
  17. package/dist/{guitar-CarHGDAt.d.ts → guitar-CNOxM4ZK.d.ts} +1 -1
  18. package/dist/iife/audio-cg.global.js +1 -1
  19. package/dist/iife/index.global.js +11 -11
  20. package/dist/{music-objects-ONIuVUgs.d.mts → music-objects-DYMqx839.d.mts} +18 -17
  21. package/dist/{music-objects-3Esbz7ij.d.ts → music-objects-DumXKWJp.d.ts} +20 -19
  22. package/dist/{note-CJuq5aBy.d.ts → note-RVXvpfyV.d.ts} +1 -1
  23. package/dist/pieces/index.d.mts +1 -1
  24. package/dist/pieces/index.d.ts +3 -3
  25. package/dist/pieces/index.js +1 -1
  26. package/dist/pieces/index.mjs +2 -2
  27. package/dist/react-ui/index.d.mts +1 -1
  28. package/dist/react-ui/index.d.ts +5 -5
  29. package/dist/react-ui/index.js +1 -1
  30. package/dist/react-ui/index.mjs +2 -2
  31. package/dist/{scale-DulPFco_.d.ts → scale-CUYFBo-8.d.ts} +2 -2
  32. package/dist/score/index.d.mts +2 -2
  33. package/dist/score/index.d.ts +5 -5
  34. package/dist/score/index.js +162 -113
  35. package/dist/score/index.mjs +187 -138
  36. package/dist/{tempo-BnUjm25M.d.ts → tempo-DwuZsv2T.d.ts} +1 -1
  37. package/dist/theory/index.d.ts +6 -6
  38. package/dist/theory/index.js +1 -1
  39. package/dist/theory/index.mjs +3 -3
  40. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
- /* WebMusicScore v5.4.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.4.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  import {
3
3
  MusicError
4
- } from "../chunk-ZWUBO5EW.mjs";
4
+ } from "../chunk-6P4ECBUH.mjs";
5
5
  import {
6
6
  NoteLengthProps,
7
7
  RhythmProps,
8
8
  validateNoteLength
9
- } from "../chunk-MHDBTCVG.mjs";
9
+ } from "../chunk-A5SMODAT.mjs";
10
10
  import {
11
11
  __publicField
12
- } from "../chunk-AUT4C6TY.mjs";
12
+ } from "../chunk-U2ACCEHX.mjs";
13
13
 
14
14
  // src/score/pub/div-rect.ts
15
15
  import { Utils } from "@tspro/ts-utils-lib";
@@ -588,6 +588,8 @@ var DebugSettings = {
588
588
  var DocumentSettings = {
589
589
  DocumentScale: 1,
590
590
  DocumentMinWidth: 75,
591
+ MinColumnsWidth: 10,
592
+ ColumnWidthScale: 1.7,
591
593
  PostMeasureBreakWidth: 10,
592
594
  NoteDotSpace: 0.5,
593
595
  NoteAccSpace: 0.5,
@@ -1209,10 +1211,10 @@ var RenderContext = class {
1209
1211
 
1210
1212
  // src/score/engine/obj-staff-and-tab.ts
1211
1213
  import { MusicError as MusicError15, MusicErrorType as MusicErrorType15 } from "@tspro/web-music-score/core";
1212
- import { AnchoredRect as AnchoredRect23, Guard as Guard9, UniMap as UniMap7, Utils as Utils10 } from "@tspro/ts-utils-lib";
1214
+ import { AnchoredRect as AnchoredRect22, Guard as Guard9, UniMap as UniMap7, Utils as Utils10 } from "@tspro/ts-utils-lib";
1213
1215
 
1214
1216
  // src/score/engine/obj-measure.ts
1215
- import { Guard as Guard8, IndexArray as IndexArray2, UniMap as UniMap5, TriMap as TriMap2, ValueSet, Utils as Utils9, asMulti, AnchoredRect as AnchoredRect21 } from "@tspro/ts-utils-lib";
1217
+ import { Guard as Guard8, IndexArray as IndexArray2, UniMap as UniMap5, TriMap as TriMap2, ValueSet, Utils as Utils9, asMulti, AnchoredRect as AnchoredRect20 } from "@tspro/ts-utils-lib";
1216
1218
  import { getScale, Scale, validateScaleType, Note as Note7, RhythmProps as RhythmProps5, KeySignature as KeySignature2, getDefaultKeySignature, PitchNotation, SymbolSet, validateNoteLength as validateNoteLength2, NoteLengthProps as NoteLengthProps5 } from "@tspro/web-music-score/theory";
1217
1219
  import { getDefaultTempo, getDefaultTimeSignature } from "@tspro/web-music-score/theory";
1218
1220
 
@@ -2948,23 +2950,6 @@ var ObjRhythmColumn = class extends MusicObject {
2948
2950
  addLyricsObject(lyricsObj) {
2949
2951
  this.lyricsObject.set(lyricsObj.verse, lyricsObj.line, lyricsObj.vpos, lyricsObj);
2950
2952
  }
2951
- getMinWidth() {
2952
- let maxNoteSize = Math.max(...this.voiceSymbol.mapToArray((s) => s.rhythmProps.noteSize));
2953
- let w = DocumentSettings.NoteHeadWidth;
2954
- switch (maxNoteSize) {
2955
- case 1:
2956
- return w * 5;
2957
- // whole note
2958
- case 2:
2959
- return w * 3;
2960
- // half note
2961
- case 4:
2962
- return w * 2;
2963
- // quarter note
2964
- default:
2965
- return w;
2966
- }
2967
- }
2968
2953
  updateNoteDisplacements() {
2969
2954
  let data = [];
2970
2955
  this.voiceSymbol.forEach((symbol) => {
@@ -3055,13 +3040,9 @@ var ObjRhythmColumn = class extends MusicObject {
3055
3040
  if (!this.needLayout) {
3056
3041
  return;
3057
3042
  }
3058
- this.requestRectUpdate();
3059
- this.rect = new AnchoredRect10();
3060
3043
  let { row } = this;
3061
- let { unitSize } = ctx;
3062
- let halfMinWidth = this.getMinWidth() * unitSize / 2;
3063
- let leftw = halfMinWidth;
3064
- let rightw = halfMinWidth;
3044
+ let leftw = 0;
3045
+ let rightw = 0;
3065
3046
  this.voiceSymbol.forEach((symbol) => {
3066
3047
  symbol.layout(ctx, accState);
3067
3048
  let r = symbol.getRect();
@@ -3069,31 +3050,28 @@ var ObjRhythmColumn = class extends MusicObject {
3069
3050
  rightw = Math.max(rightw, r.rightw);
3070
3051
  });
3071
3052
  if (this.arpeggioDir !== void 0) {
3072
- let arpeggioWidth = 0;
3073
- this.arpeggios = row.getNotationLines().map((line) => {
3074
- let arpeggio = new ObjArpeggio(this, line, this.getArpeggioDir());
3075
- arpeggio.layout(ctx);
3076
- arpeggio.offset(-leftw - arpeggio.getRect().right, line.getRect().anchorY - arpeggio.getRect().anchorY);
3077
- arpeggioWidth = Math.max(arpeggioWidth, arpeggio.getRect().width);
3078
- line.addObject(arpeggio);
3079
- this.measure.addStaticObject(line, arpeggio);
3080
- return arpeggio;
3053
+ this.arpeggios = row.getNotationLines().map((line) => new ObjArpeggio(this, line, this.getArpeggioDir()));
3054
+ this.arpeggios.forEach((a) => a.layout(ctx));
3055
+ const arpeggioWidth = this.arpeggios.map((a) => a.getRect().width).reduce((accState2, cur) => Math.max(accState2, cur)) + ctx.unitSize;
3056
+ this.arpeggios.forEach((a) => {
3057
+ a.offset(-leftw - arpeggioWidth + a.getRect().leftw, a.line.getRect().anchorY - a.getRect().anchorY);
3058
+ a.line.addObject(a);
3059
+ this.measure.addStaticObject(a.line, a);
3081
3060
  });
3082
3061
  leftw += arpeggioWidth;
3083
3062
  } else {
3084
3063
  this.arpeggios = [];
3085
3064
  }
3086
- let widenColumnObjs = this.getAnchoredLayoutObjects().filter((layoutObj) => layoutObj.layoutGroup.widensColumn);
3087
- if (widenColumnObjs.length > 0) {
3088
- widenColumnObjs.forEach((layoutObj) => {
3089
- leftw = Math.max(leftw, layoutObj.musicObj.getRect().leftw);
3090
- rightw = Math.max(rightw, layoutObj.musicObj.getRect().rightw);
3091
- });
3092
- }
3065
+ const noteSizes = this.voiceSymbol.mapToArray((s) => s.rhythmProps.noteSize);
3066
+ const maxNoteSize = Math.min(8, Math.max(1, ...noteSizes));
3067
+ const MinColumnWidth = Math.ceil(8 / maxNoteSize) * DocumentSettings.NoteHeadWidth * ctx.unitSize * 0.75;
3068
+ leftw = Math.max(leftw, MinColumnWidth / 2);
3069
+ rightw = Math.max(rightw, MinColumnWidth / 2);
3070
+ leftw *= DocumentSettings.ColumnWidthScale;
3071
+ rightw *= DocumentSettings.ColumnWidthScale;
3072
+ this.rect = new AnchoredRect10(-leftw, 0, rightw, 0, 0, 0);
3073
+ this.requestRectUpdate();
3093
3074
  this.voiceSymbol.forEach((symbol) => symbol.updateAccidentalState(accState));
3094
- this.rect.left = -leftw;
3095
- this.rect.anchorX = 0;
3096
- this.rect.right = rightw;
3097
3075
  this.row.getStaves().forEach((staff) => {
3098
3076
  let minDiatonicId = void 0;
3099
3077
  let maxDiatonicId = void 0;
@@ -3121,12 +3099,48 @@ var ObjRhythmColumn = class extends MusicObject {
3121
3099
  }
3122
3100
  });
3123
3101
  }
3102
+ layoutReserveSpace(ctx) {
3103
+ const columns = this.measure.getColumns();
3104
+ const extraSpace = ctx.unitSize;
3105
+ this.getAnchoredLayoutObjects().forEach((obj) => {
3106
+ if (obj.layoutGroup.reserveSpace) {
3107
+ const i = columns.indexOf(this);
3108
+ if (i < 0) return;
3109
+ const leftOverflow = obj.getRect().leftw - this.getRect().leftw;
3110
+ if (leftOverflow > 0) {
3111
+ const prevCol = columns[i - 1];
3112
+ if (prevCol) {
3113
+ prevCol.getAnchoredLayoutObjects().forEach((prevObj) => {
3114
+ if (prevObj.layoutGroupId === obj.layoutGroupId) {
3115
+ const rightOverflow2 = prevObj.getRect().rightw - prevCol.getRect().rightw;
3116
+ this.rect.left -= Math.max(rightOverflow2 + leftOverflow, 0) + extraSpace;
3117
+ this.requestRectUpdate();
3118
+ }
3119
+ });
3120
+ }
3121
+ }
3122
+ const rightOverflow = obj.getRect().rightw - this.getRect().rightw;
3123
+ if (rightOverflow > 0) {
3124
+ const nextCol = columns[i + 1];
3125
+ if (nextCol) {
3126
+ nextCol.getAnchoredLayoutObjects().forEach((nextObj) => {
3127
+ if (nextObj.layoutGroupId === obj.layoutGroupId) {
3128
+ const leftOverflow2 = nextObj.getRect().leftw - nextCol.getRect().leftw;
3129
+ this.rect.right += Math.max(rightOverflow + leftOverflow2, 0) + extraSpace;
3130
+ this.requestRectUpdate();
3131
+ }
3132
+ });
3133
+ }
3134
+ }
3135
+ }
3136
+ });
3137
+ }
3124
3138
  layoutDone() {
3125
3139
  this.needLayout = false;
3126
3140
  }
3127
3141
  updateRect() {
3128
3142
  this.shapeRects = [
3129
- ...this.voiceSymbol.filter((s) => !!s).mapToArray((s) => s.getRect().clone()),
3143
+ ...this.voiceSymbol.filter((s) => s !== void 0).mapToArray((s) => s.getRect().clone()),
3130
3144
  ...this.arpeggios.map((a) => a.getRect().clone())
3131
3145
  ];
3132
3146
  this.rect.top = Math.min(...this.shapeRects.map((r) => r.top));
@@ -5076,7 +5090,7 @@ var ConnectiveProps = class {
5076
5090
  };
5077
5091
 
5078
5092
  // src/score/engine/obj-lyrics.ts
5079
- import { AnchoredRect as AnchoredRect19, Guard as Guard7 } from "@tspro/ts-utils-lib";
5093
+ import { Guard as Guard7 } from "@tspro/ts-utils-lib";
5080
5094
  var ObjLyrics = class extends MusicObject {
5081
5095
  constructor(col, verse, line, vpos, lyricsLength, lyricsText, lyricsOptions) {
5082
5096
  super(col);
@@ -5094,7 +5108,7 @@ var ObjLyrics = class extends MusicObject {
5094
5108
  let halign = (lyricsOptions == null ? void 0 : lyricsOptions.align) === "left" /* Left */ ? 0 : (lyricsOptions == null ? void 0 : lyricsOptions.align) === "right" /* Right */ ? 1 : 0.5;
5095
5109
  this.hyphen = Guard7.isEnumValue(lyricsOptions == null ? void 0 : lyricsOptions.hyphen, LyricsHyphen) ? lyricsOptions == null ? void 0 : lyricsOptions.hyphen : void 0;
5096
5110
  this.text = new ObjText(this, { text: lyricsText, color: this.color, scale: 0.8 }, halign, 0);
5097
- this.rect = new AnchoredRect19();
5111
+ this.rect = this.text.getRect().clone();
5098
5112
  this.mi = new MLyrics(this);
5099
5113
  }
5100
5114
  getMusicInterface() {
@@ -5110,7 +5124,7 @@ var ObjLyrics = class extends MusicObject {
5110
5124
  this.nextLyricsObject = lyricsObj;
5111
5125
  }
5112
5126
  pick(x, y) {
5113
- return this.rect.contains(x, y) ? [this] : [];
5127
+ return this.getRect().contains(x, y) ? [this] : [];
5114
5128
  }
5115
5129
  layout(ctx) {
5116
5130
  this.text.layout(ctx);
@@ -5131,8 +5145,8 @@ var ObjLyrics = class extends MusicObject {
5131
5145
  let maxw = r ? (r.left - l.right) * 0.85 : hyphenw;
5132
5146
  let w = this.hyphen === "-" /* Hyphen */ ? Math.min(hyphenw, maxw) : maxw;
5133
5147
  if (w > 0) {
5134
- let cx = r ? (r.left + l.right) / 2 : l.right + w / 0.85;
5135
- let cy = l.centerY / 2;
5148
+ let cx = r ? (l.right + r.left) / 2 : l.right + w / 0.85;
5149
+ let cy = l.centerY;
5136
5150
  ctx.moveTo(cx - w / 2, cy);
5137
5151
  ctx.lineTo(cx + w / 2, cy);
5138
5152
  ctx.stroke();
@@ -5142,7 +5156,7 @@ var ObjLyrics = class extends MusicObject {
5142
5156
  };
5143
5157
 
5144
5158
  // src/score/engine/obj-tab-rhythm.ts
5145
- import { AnchoredRect as AnchoredRect20, UniMap as UniMap4, Utils as Utils8 } from "@tspro/ts-utils-lib";
5159
+ import { AnchoredRect as AnchoredRect19, UniMap as UniMap4, Utils as Utils8 } from "@tspro/ts-utils-lib";
5146
5160
  var ObjTabRhythm = class extends MusicObject {
5147
5161
  constructor(measure, tab) {
5148
5162
  super(measure);
@@ -5153,7 +5167,7 @@ var ObjTabRhythm = class extends MusicObject {
5153
5167
  // Keep non-static
5154
5168
  __publicField(this, "tupletPartsTextObjMap", new UniMap4());
5155
5169
  this.voiceId = getVoiceIds().filter((voiceId) => tab.containsVoiceId(voiceId));
5156
- this.rect = new AnchoredRect20();
5170
+ this.rect = new AnchoredRect19();
5157
5171
  this.mi = new MTabRhythm(this);
5158
5172
  }
5159
5173
  getMusicInterface() {
@@ -5166,7 +5180,7 @@ var ObjTabRhythm = class extends MusicObject {
5166
5180
  let columns = this.measure.getColumns();
5167
5181
  let numColsInVoiceId = getVoiceIds().map((voiceId) => Utils8.Math.sum(columns.map((col) => col.getVoiceSymbol(voiceId) ? 1 : 0)));
5168
5182
  this.voiceId.sort((a, b) => Utils8.Math.cmp(numColsInVoiceId[a], numColsInVoiceId[b]));
5169
- this.rect = new AnchoredRect20();
5183
+ this.rect = new AnchoredRect19();
5170
5184
  }
5171
5185
  hasTuplets() {
5172
5186
  return this.measure.getBeamGroups().some((beamGroup) => beamGroup.isTuplet());
@@ -5217,7 +5231,7 @@ var ObjTabRhythm = class extends MusicObject {
5217
5231
  ctx.lineWidth(1);
5218
5232
  if (symbols.length === 1) {
5219
5233
  for (let i = 0; i < sym.rhythmProps.flagCount; i++) {
5220
- ctx.drawFlag(new AnchoredRect20(colX, colX + flagSize, stemTop + i * flagSize, stemTop + (i + 2) * flagSize), "up");
5234
+ ctx.drawFlag(new AnchoredRect19(colX, colX + flagSize, stemTop + i * flagSize, stemTop + (i + 2) * flagSize), "up");
5221
5235
  }
5222
5236
  }
5223
5237
  for (let i = 0; i < sym.rhythmProps.dotCount; i++) {
@@ -5320,7 +5334,27 @@ function getVerseLayoutGroupId(verse) {
5320
5334
  throw new MusicError13(MusicErrorType13.Unknown, "VerseNumber is not 1, 2 or 3.");
5321
5335
  }
5322
5336
  }
5323
- var _ObjMeasure = class _ObjMeasure extends MusicObject {
5337
+ var MeasureRegions = class {
5338
+ constructor() {
5339
+ __publicField(this, "tabTuning_0", 0);
5340
+ __publicField(this, "signature_1", 0);
5341
+ __publicField(this, "leftBarLine_2", 0);
5342
+ __publicField(this, "padding_3", 0);
5343
+ __publicField(this, "columnsMin_4", 0);
5344
+ __publicField(this, "padding_5", 0);
5345
+ __publicField(this, "rightBarLine_6", 0);
5346
+ }
5347
+ get leftSolid() {
5348
+ return this.tabTuning_0 + this.signature_1 + this.leftBarLine_2 + this.padding_3;
5349
+ }
5350
+ get columnsMin() {
5351
+ return this.columnsMin_4;
5352
+ }
5353
+ get rightSolid() {
5354
+ return this.padding_5 + this.rightBarLine_6;
5355
+ }
5356
+ };
5357
+ var ObjMeasure = class extends MusicObject {
5324
5358
  constructor(row, options) {
5325
5359
  super(row);
5326
5360
  this.row = row;
@@ -5340,12 +5374,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5340
5374
  __publicField(this, "barLineRight");
5341
5375
  __publicField(this, "connectives", []);
5342
5376
  __publicField(this, "beamGroups", []);
5343
- __publicField(this, "tabStringNotesWidth", 0);
5344
5377
  __publicField(this, "measureId");
5378
+ __publicField(this, "regions", new MeasureRegions());
5345
5379
  __publicField(this, "needLayout", true);
5346
- __publicField(this, "leftSolidAreaWidth", 0);
5347
- __publicField(this, "minColumnsAreaWidth", 0);
5348
- __publicField(this, "rightSolidAreaWidth", 0);
5349
5380
  __publicField(this, "voiceSymbols", asMulti(new IndexArray2()));
5350
5381
  __publicField(this, "lastAddedRhythmColumn");
5351
5382
  __publicField(this, "lastAddedRhythmSymbol");
@@ -6014,34 +6045,34 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6014
6045
  }
6015
6046
  // Get content rect excluding signature
6016
6047
  getColumnsContentRect() {
6017
- return new AnchoredRect21(
6048
+ return new AnchoredRect20(
6018
6049
  this.barLineLeft.getRect().anchorX,
6019
6050
  this.barLineRight.getRect().anchorX,
6020
6051
  this.getRect().top,
6021
6052
  this.getRect().bottom
6022
6053
  );
6023
6054
  }
6024
- getLeftSolidAreaWidth() {
6025
- return this.leftSolidAreaWidth;
6055
+ getLeftSolidWidth() {
6056
+ return this.regions.leftSolid;
6026
6057
  }
6027
- getMinColumnsAreaWidth() {
6028
- return this.minColumnsAreaWidth;
6058
+ getMinColumnsWidth() {
6059
+ return this.regions.columnsMin;
6029
6060
  }
6030
- getRightSolidAreaWidth() {
6031
- return this.rightSolidAreaWidth;
6061
+ getRightSolidWidth() {
6062
+ return this.regions.rightSolid;
6032
6063
  }
6033
- getSolidAreaWidth() {
6034
- return this.leftSolidAreaWidth + this.rightSolidAreaWidth;
6064
+ getTotalSolidWidth() {
6065
+ return this.getLeftSolidWidth() + this.getRightSolidWidth();
6035
6066
  }
6036
6067
  getMinWidth() {
6037
- return this.leftSolidAreaWidth + this.minColumnsAreaWidth + this.rightSolidAreaWidth;
6068
+ return this.getLeftSolidWidth() + this.getMinColumnsWidth() + this.getRightSolidWidth();
6038
6069
  }
6039
6070
  getStaffLineLeft() {
6040
6071
  let prev = this.getPrevMeasure();
6041
6072
  if (prev && prev.row === this.row && !prev.hasPostMeasureBreak()) {
6042
6073
  return prev.getStaffLineRight();
6043
6074
  } else {
6044
- return this.getRect().left + this.tabStringNotesWidth;
6075
+ return this.getRect().left + this.regions.tabTuning_0;
6045
6076
  }
6046
6077
  }
6047
6078
  getStaffLineRight() {
@@ -6255,7 +6286,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6255
6286
  this.postMeasureBreakWidth = this.hasPostMeasureBreak() ? DocumentSettings.PostMeasureBreakWidth * unitSize : 0;
6256
6287
  let isFirstMeasureInRow = this === this.row.getFirstMeasure();
6257
6288
  let isAfterMeasureBreak = ((_a = this.getPrevMeasure()) == null ? void 0 : _a.hasPostMeasureBreak()) === true;
6258
- this.tabStringNotesWidth = isFirstMeasureInRow && this.row.hasTab ? unitSize * 4 : 0;
6289
+ this.regions.tabTuning_0 = isFirstMeasureInRow && this.row.hasTab ? unitSize * 4 : 0;
6259
6290
  let showClef = isFirstMeasureInRow || isAfterMeasureBreak;
6260
6291
  let showMeasureNumber = this.options.showNumber === false ? false : this.options.showNumber === true || isFirstMeasureInRow && !this.row.isFirstRow();
6261
6292
  let showKeySignature = isFirstMeasureInRow || isAfterMeasureBreak || !!this.alterKeySignature;
@@ -6292,7 +6323,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6292
6323
  let note = tab.getTuningStrings()[stringId].format(PitchNotation.Helmholtz, SymbolSet.Unicode);
6293
6324
  let obj = new ObjText(this, { text: note, scale: 0.8 }, 1, 0.5);
6294
6325
  obj.layout(ctx);
6295
- obj.offset(this.tabStringNotesWidth * 0.8, tab.getStringY(stringId));
6326
+ obj.offset(this.regions.tabTuning_0 * 0.8, tab.getStringY(stringId));
6296
6327
  this.tabStringNotes.push(obj);
6297
6328
  tab.addObject(obj);
6298
6329
  }
@@ -6301,50 +6332,53 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6301
6332
  this.barLineLeft.layout(ctx);
6302
6333
  const accState = new AccidentalState(this);
6303
6334
  this.columns.forEach((col) => col.layout(ctx, accState));
6335
+ this.columns.forEach((col) => col.layoutReserveSpace(ctx));
6304
6336
  this.barLineRight.layout(ctx);
6305
- if (this.endRepeatPlayCountText) {
6337
+ if (this.endRepeatPlayCountText)
6306
6338
  this.endRepeatPlayCountText.layout(ctx);
6307
- }
6308
- this.layoutObjects.forEach((layoutObj) => layoutObj.layout(ctx));
6339
+ this.layoutObjects.forEach((obj) => obj.layout(ctx));
6309
6340
  let padding = ctx.unitSize;
6310
- this.leftSolidAreaWidth = this.tabStringNotesWidth + Math.max(0, ...this.signatures.map((signature) => signature.getRect().width)) + this.barLineLeft.getRect().width + padding;
6311
- this.rightSolidAreaWidth = padding + this.barLineRight.getRect().width;
6312
- this.minColumnsAreaWidth = 0;
6313
- this.columns.forEach((col) => this.minColumnsAreaWidth += col.getRect().width);
6314
- this.minColumnsAreaWidth = Math.max(this.minColumnsAreaWidth, _ObjMeasure.MinFlexContentWidth * unitSize);
6341
+ this.regions.signature_1 = Math.max(0, ...this.signatures.map((signature) => signature.getRect().width));
6342
+ this.regions.leftBarLine_2 = this.barLineLeft.getRect().width;
6343
+ this.regions.padding_3 = padding;
6344
+ this.regions.columnsMin_4 = Math.max(
6345
+ DocumentSettings.MinColumnsWidth * unitSize,
6346
+ this.columns.map((col) => col.getRect().width).reduce((acc, cur) => acc + cur)
6347
+ );
6348
+ this.regions.padding_5 = padding;
6349
+ this.regions.rightBarLine_6 = this.barLineRight.getRect().width;
6315
6350
  }
6316
6351
  layoutWidth(ctx, width) {
6352
+ var _a;
6317
6353
  if (!this.needLayout) {
6318
6354
  return;
6319
6355
  }
6320
6356
  width = Math.max(width, this.getMinWidth());
6321
- this.rect = new AnchoredRect21();
6357
+ this.rect = new AnchoredRect20();
6322
6358
  this.rect.anchorX = this.rect.left + width / 2;
6323
6359
  this.rect.right = this.rect.left + width;
6324
6360
  let rect;
6325
6361
  this.signatures.forEach((signature) => {
6326
6362
  rect = signature.getRect();
6327
- signature.offset(this.rect.left + this.tabStringNotesWidth - rect.left, -rect.anchorY);
6363
+ signature.offset(this.rect.left + this.regions.tabTuning_0 - rect.left, -rect.anchorY);
6328
6364
  });
6329
6365
  let signaturesWidth = Math.max(0, ...this.signatures.map((signature) => signature.getRect().width));
6330
6366
  rect = this.barLineLeft.getRect();
6331
- this.barLineLeft.offset(this.rect.left + this.tabStringNotesWidth + signaturesWidth - rect.left, -rect.anchorY);
6367
+ this.barLineLeft.offset(this.rect.left + this.regions.tabTuning_0 + signaturesWidth - rect.left, -rect.anchorY);
6332
6368
  rect = this.barLineRight.getRect();
6333
6369
  this.barLineRight.offset(this.rect.right - rect.right, -rect.anchorY);
6334
- if (this.endRepeatPlayCountText) {
6335
- this.endRepeatPlayCountText.offset(this.barLineRight.getRect().left, this.barLineRight.getRect().top);
6336
- }
6337
- let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
6338
- let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
6339
- let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
6340
- let columnsWidth = Utils9.Math.sum(this.columns.map((col) => col.getRect().width));
6341
- let columnScale = columnsAreaWidth / columnsWidth;
6342
- let columnLeft = columnsAreaLeft;
6370
+ (_a = this.endRepeatPlayCountText) == null ? void 0 : _a.offset(this.barLineRight.getRect().left, this.barLineRight.getRect().top);
6371
+ let columnsLeft = this.rect.left + this.regions.leftSolid;
6372
+ let columnsRight = this.rect.right - this.regions.rightSolid;
6373
+ let columnsWidth = columnsRight - columnsLeft;
6374
+ let columnsMinWidth = this.regions.columnsMin;
6375
+ let columnScale = columnsWidth / columnsMinWidth;
6376
+ let curColumnLeft = columnsLeft;
6343
6377
  this.columns.forEach((col) => {
6344
6378
  rect = col.getRect();
6345
- let columnAnchorX = columnLeft + rect.leftw * columnScale;
6379
+ let columnAnchorX = curColumnLeft + rect.leftw * columnScale;
6346
6380
  col.offset(columnAnchorX - rect.anchorX, -rect.anchorY);
6347
- columnLeft += rect.width * columnScale;
6381
+ curColumnLeft += rect.width * columnScale;
6348
6382
  });
6349
6383
  getVoiceIds().forEach((voiceId) => {
6350
6384
  const symbols = this.getVoiceSymbols(voiceId);
@@ -6461,12 +6495,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6461
6495
  this.beamGroups.forEach((beam) => beam.draw(ctx));
6462
6496
  }
6463
6497
  };
6464
- __publicField(_ObjMeasure, "MinFlexContentWidth", 10);
6465
- var ObjMeasure = _ObjMeasure;
6466
6498
 
6467
6499
  // src/score/engine/layout-object.ts
6468
6500
  import { MusicError as MusicError14, MusicErrorType as MusicErrorType14 } from "@tspro/web-music-score/core";
6469
- import { AnchoredRect as AnchoredRect22, asMulti as asMulti2, IndexArray as IndexArray3, UniMap as UniMap6 } from "@tspro/ts-utils-lib";
6501
+ import { AnchoredRect as AnchoredRect21, asMulti as asMulti2, IndexArray as IndexArray3, UniMap as UniMap6 } from "@tspro/ts-utils-lib";
6470
6502
  var LayoutGroupId = /* @__PURE__ */ ((LayoutGroupId2) => {
6471
6503
  LayoutGroupId2[LayoutGroupId2["TabRhythm"] = 0] = "TabRhythm";
6472
6504
  LayoutGroupId2[LayoutGroupId2["Fermata"] = 1] = "Fermata";
@@ -6483,16 +6515,16 @@ var LayoutGroupId = /* @__PURE__ */ ((LayoutGroupId2) => {
6483
6515
  })(LayoutGroupId || {});
6484
6516
  var LayoutGroupIdAttrs = new UniMap6([
6485
6517
  [0 /* TabRhythm */, { rowAlign: true }],
6486
- [1 /* Fermata */, {}],
6487
- [2 /* NoteLabel */, { widen: true }],
6518
+ [1 /* Fermata */, { reserveSpace: true }],
6519
+ [2 /* NoteLabel */, { reserveSpace: true }],
6488
6520
  [3 /* Navigation */, { rowAlign: true }],
6489
6521
  [4 /* Ending */, { rowAlign: true, padding: 2 }],
6490
6522
  [5 /* TempoAnnotation */, { rowAlign: true, padding: 2 }],
6491
6523
  [6 /* DynamicsAnnotation */, { rowAlign: true, padding: 2 }],
6492
- [7 /* ChordLabel */, { widen: true, rowAlign: true }],
6493
- [8 /* LyricsVerse1 */, { rowAlign: true }],
6494
- [9 /* LyricsVerse2 */, { rowAlign: true }],
6495
- [10 /* LyricsVerse3 */, { rowAlign: true }]
6524
+ [7 /* ChordLabel */, { reserveSpace: true, rowAlign: true }],
6525
+ [8 /* LyricsVerse1 */, { reserveSpace: true, rowAlign: true }],
6526
+ [9 /* LyricsVerse2 */, { reserveSpace: true, rowAlign: true }],
6527
+ [10 /* LyricsVerse3 */, { reserveSpace: true, rowAlign: true }]
6496
6528
  ]);
6497
6529
  function requireParentMeasure(p) {
6498
6530
  while (p) {
@@ -6553,7 +6585,7 @@ var LayoutObjectWrapper = class {
6553
6585
  let staticShapeRects = staticObj.getShapeRects();
6554
6586
  objShapeRects.forEach((objR) => {
6555
6587
  staticShapeRects.forEach((staticR) => {
6556
- if (AnchoredRect22.overlapX(objR, staticR)) {
6588
+ if (AnchoredRect21.overlapX(objR, staticR)) {
6557
6589
  y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.anchorY) : Math.min(y, staticR.top - objR.bottomh - objR.anchorY);
6558
6590
  }
6559
6591
  });
@@ -6584,11 +6616,11 @@ var LayoutGroup = class {
6584
6616
  // key = VerticalPos
6585
6617
  __publicField(this, "layoutObject", asMulti2(new IndexArray3()));
6586
6618
  __publicField(this, "rowAlign");
6587
- __publicField(this, "widensColumn");
6619
+ __publicField(this, "reserveSpace");
6588
6620
  __publicField(this, "padding");
6589
6621
  var _a, _b, _c, _d;
6590
6622
  this.rowAlign = ((_a = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _a.rowAlign) === true;
6591
- this.widensColumn = ((_b = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _b.widen) === true;
6623
+ this.reserveSpace = ((_b = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _b.reserveSpace) === true;
6592
6624
  this.padding = (_d = (_c = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _c.padding) != null ? _d : 0;
6593
6625
  }
6594
6626
  getLayoutObjects(verticalPos) {
@@ -6815,7 +6847,7 @@ var ObjStaff = class extends ObjNotationLine5 {
6815
6847
  let h = unitSize * DocumentSettings.StaffHeight;
6816
6848
  this.topLineY = -h / 2;
6817
6849
  this.bottomLineY = h / 2;
6818
- this.rect = new AnchoredRect23(0, 0, this.topLineY, this.bottomLineY);
6850
+ this.rect = new AnchoredRect22(0, 0, this.topLineY, this.bottomLineY);
6819
6851
  }
6820
6852
  layoutWidth(ctx) {
6821
6853
  this.rect.left = this.row.getRect().left;
@@ -6921,7 +6953,7 @@ var ObjTab = class extends ObjNotationLine5 {
6921
6953
  let h = unitSize * DocumentSettings.TabHeight;
6922
6954
  this.top = -h / 2;
6923
6955
  this.bottom = h / 2;
6924
- this.rect = new AnchoredRect23(0, 0, this.top, this.bottom);
6956
+ this.rect = new AnchoredRect22(0, 0, this.top, this.bottom);
6925
6957
  }
6926
6958
  layoutWidth(ctx) {
6927
6959
  this.rect.left = this.row.getRect().left;
@@ -6945,7 +6977,7 @@ var ObjTab = class extends ObjNotationLine5 {
6945
6977
 
6946
6978
  // src/score/engine/obj-score-row.ts
6947
6979
  import { MusicError as MusicError16, MusicErrorType as MusicErrorType16 } from "@tspro/web-music-score/core";
6948
- import { AnchoredRect as AnchoredRect24, Guard as Guard10, Utils as Utils11 } from "@tspro/ts-utils-lib";
6980
+ import { AnchoredRect as AnchoredRect23, Guard as Guard10, Utils as Utils11 } from "@tspro/ts-utils-lib";
6949
6981
  var ObjScoreRow = class extends MusicObject {
6950
6982
  constructor(doc, prevRow, scoreConfig) {
6951
6983
  super(doc);
@@ -7083,7 +7115,7 @@ var ObjScoreRow = class extends MusicObject {
7083
7115
  let r = this.getRect();
7084
7116
  let firstMeasure = this.getFirstMeasure();
7085
7117
  let left = firstMeasure ? firstMeasure.getColumnsContentRect().left : r.left;
7086
- return new AnchoredRect24(left, (left + r.right) / 2, r.right, r.top, r.anchorY, r.bottom);
7118
+ return new AnchoredRect23(left, (left + r.right) / 2, r.right, r.top, r.anchorY, r.bottom);
7087
7119
  }
7088
7120
  getDiatonicIdAt(y) {
7089
7121
  for (let i = 0; i < this.notationLines.length; i++) {
@@ -7168,18 +7200,18 @@ var ObjScoreRow = class extends MusicObject {
7168
7200
  if (!this.needLayout) {
7169
7201
  return;
7170
7202
  }
7171
- this.rect = new AnchoredRect24(0, right, 0, 0);
7203
+ this.rect = new AnchoredRect23(0, right, 0, 0);
7172
7204
  this.notationLines.forEach((line) => line.layoutWidth(ctx));
7173
7205
  let targetColumnsAreaWidth = right - left;
7174
7206
  let minColumnsAreaWidth = 0;
7175
7207
  this.measures.forEach((m) => {
7176
- targetColumnsAreaWidth -= m.getSolidAreaWidth() + m.getPostMeasureBreakWidth();
7177
- minColumnsAreaWidth += m.getMinColumnsAreaWidth();
7208
+ targetColumnsAreaWidth -= m.getTotalSolidWidth() + m.getPostMeasureBreakWidth();
7209
+ minColumnsAreaWidth += m.getMinColumnsWidth();
7178
7210
  });
7179
7211
  let columnsAreaScale = targetColumnsAreaWidth / minColumnsAreaWidth;
7180
- let x = this.doc.getInstrumentGroupSize(ctx).braceRight;
7212
+ let x = this.doc.getInstrumentGroupRegions(ctx).braceRight;
7181
7213
  this.measures.forEach((m) => {
7182
- let newMeasureWidth = m.getSolidAreaWidth() + m.getMinColumnsAreaWidth() * columnsAreaScale;
7214
+ let newMeasureWidth = m.getTotalSolidWidth() + m.getMinColumnsWidth() * columnsAreaScale;
7183
7215
  m.layoutWidth(ctx, newMeasureWidth);
7184
7216
  let r = m.getRect();
7185
7217
  m.offset(x - r.left, -r.anchorY);
@@ -7196,7 +7228,7 @@ var ObjScoreRow = class extends MusicObject {
7196
7228
  let right = this.measures.length > 0 ? this.measures[this.measures.length - 1].getRect().right : left;
7197
7229
  let top = this.measures.length > 0 ? Math.min(...this.measures.map((m) => m.getRect().top)) : 0;
7198
7230
  let bottom = this.measures.length > 0 ? Math.max(...this.measures.map((m) => m.getRect().bottom)) : 0;
7199
- this.rect = new AnchoredRect24(left, right, top, bottom);
7231
+ this.rect = new AnchoredRect23(left, right, top, bottom);
7200
7232
  }
7201
7233
  alignStemsToBeams() {
7202
7234
  this.measures.forEach((m) => m.alignStemsToBeams());
@@ -7270,11 +7302,11 @@ var ObjScoreRow = class extends MusicObject {
7270
7302
  }
7271
7303
  this.measures.forEach((m) => m.draw(ctx));
7272
7304
  this.notationLines.forEach((m) => m.draw(ctx));
7273
- let grpSize = this.doc.getInstrumentGroupSize(ctx);
7305
+ let grpSize = this.doc.getInstrumentGroupRegions(ctx);
7274
7306
  this.instrumentNames.forEach((obj, i) => {
7275
7307
  let grp = this.instrumentLineGroups[i];
7276
7308
  if (grp.length > 1) {
7277
- let r = new AnchoredRect24(
7309
+ let r = new AnchoredRect23(
7278
7310
  grpSize.braceLeft,
7279
7311
  grpSize.braceRight,
7280
7312
  grp[0].getTopLineY(),
@@ -7291,7 +7323,7 @@ var ObjScoreRow = class extends MusicObject {
7291
7323
  };
7292
7324
 
7293
7325
  // src/score/engine/obj-header.ts
7294
- import { AnchoredRect as AnchoredRect25 } from "@tspro/ts-utils-lib";
7326
+ import { AnchoredRect as AnchoredRect24 } from "@tspro/ts-utils-lib";
7295
7327
  var ObjHeader = class extends MusicObject {
7296
7328
  constructor(doc, title, composer, arranger) {
7297
7329
  super(doc);
@@ -7336,7 +7368,7 @@ var ObjHeader = class extends MusicObject {
7336
7368
  }
7337
7369
  layoutWidth(ctx, left, right) {
7338
7370
  let top = 0;
7339
- this.rect = new AnchoredRect25(left, right, 0, 0);
7371
+ this.rect = new AnchoredRect24(left, right, 0, 0);
7340
7372
  if (this.titleText) {
7341
7373
  this.titleText.layout(ctx);
7342
7374
  this.titleText.offset((left + right) / 2, top);
@@ -7382,8 +7414,25 @@ var ObjHeader = class extends MusicObject {
7382
7414
  };
7383
7415
 
7384
7416
  // src/score/engine/obj-document.ts
7385
- import { AnchoredRect as AnchoredRect26, Guard as Guard11, UniMap as UniMap8 } from "@tspro/ts-utils-lib";
7417
+ import { AnchoredRect as AnchoredRect25, Guard as Guard11, UniMap as UniMap8 } from "@tspro/ts-utils-lib";
7386
7418
  import { MusicError as MusicError17, MusicErrorType as MusicErrorType17 } from "@tspro/web-music-score/core";
7419
+ var InstrumentGroupRegions = class {
7420
+ constructor() {
7421
+ __publicField(this, "nameLeft", 0);
7422
+ __publicField(this, "nameRight", 0);
7423
+ __publicField(this, "braceLeft", 0);
7424
+ __publicField(this, "braceRight", 0);
7425
+ }
7426
+ get left() {
7427
+ return this.nameLeft;
7428
+ }
7429
+ get right() {
7430
+ return this.braceRight;
7431
+ }
7432
+ get width() {
7433
+ return this.right - this.left;
7434
+ }
7435
+ };
7387
7436
  var ObjDocument = class extends MusicObject {
7388
7437
  constructor() {
7389
7438
  super(void 0);
@@ -7397,6 +7446,7 @@ var ObjDocument = class extends MusicObject {
7397
7446
  __publicField(this, "newRowRequested", false);
7398
7447
  __publicField(this, "allConnectiveProps", []);
7399
7448
  __publicField(this, "staffGroups", new UniMap8());
7449
+ __publicField(this, "instrumentGroupRegions", new InstrumentGroupRegions());
7400
7450
  __publicField(this, "mi");
7401
7451
  this.mi = new MDocument2(this);
7402
7452
  }
@@ -7593,17 +7643,16 @@ var ObjDocument = class extends MusicObject {
7593
7643
  this.ctx.updateCursorRect(cursorRect);
7594
7644
  }
7595
7645
  }
7596
- getInstrumentGroupSize(ctx) {
7646
+ getInstrumentGroupRegions(ctx) {
7597
7647
  let nameWidth = Math.max(0, ...this.rows.map((row) => row.getInstrumentNameWidth(ctx)));
7598
7648
  let hasName = nameWidth > 0;
7599
7649
  let padding = hasName ? ctx.unitSize : 0;
7600
7650
  let braceWidth = hasName ? ctx.unitSize * 5 : 0;
7601
- return {
7602
- nameLeft: 0,
7603
- nameRight: nameWidth,
7604
- braceLeft: nameWidth + padding,
7605
- braceRight: nameWidth + padding + braceWidth + padding
7606
- };
7651
+ this.instrumentGroupRegions.nameLeft = 0;
7652
+ this.instrumentGroupRegions.nameRight = nameWidth;
7653
+ this.instrumentGroupRegions.braceLeft = nameWidth + padding;
7654
+ this.instrumentGroupRegions.braceRight = nameWidth + padding + braceWidth + padding;
7655
+ return this.instrumentGroupRegions;
7607
7656
  }
7608
7657
  requestLayout() {
7609
7658
  this.needLayout = true;
@@ -7633,18 +7682,18 @@ var ObjDocument = class extends MusicObject {
7633
7682
  this.allConnectiveProps.forEach((props) => props.createConnectives());
7634
7683
  this.rows.forEach((row) => row.resetLayoutGroups(ctx));
7635
7684
  this.rows.forEach((row) => row.layout(ctx));
7636
- let left = this.getInstrumentGroupSize(ctx).braceRight;
7637
- let right = Math.max(
7685
+ let rowLeft = this.getInstrumentGroupRegions(ctx).right;
7686
+ let rowRight = rowLeft + Math.max(
7638
7687
  DocumentSettings.DocumentMinWidth * unitSize,
7639
- ...this.rows.map((row) => 1.4 * row.getMinWidth())
7688
+ ...this.rows.map((row) => row.getMinWidth())
7640
7689
  );
7641
- this.rows.forEach((row) => row.layoutWidth(ctx, left, right));
7690
+ this.rows.forEach((row) => row.layoutWidth(ctx, rowLeft, rowRight));
7642
7691
  this.rows.forEach((row) => row.layoutLayoutGroups(ctx));
7643
7692
  this.rows.forEach((row) => row.layoutSetNotationLines(ctx));
7644
7693
  this.rows.forEach((row) => row.layoutPadding(ctx));
7645
- this.rect = new AnchoredRect26();
7694
+ this.rect = new AnchoredRect25();
7646
7695
  if (this.header) {
7647
- this.header.layoutWidth(ctx, left, right);
7696
+ this.header.layoutWidth(ctx, rowLeft, rowRight);
7648
7697
  this.rect.expandInPlace(this.header.getRect());
7649
7698
  }
7650
7699
  this.rows.forEach((row) => {