@viritura/score-engine 0.2.1-next.55 → 0.2.1-next.57

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/index.js CHANGED
@@ -1537,6 +1537,41 @@ function readSelectionGroups(r, count) {
1537
1537
  }
1538
1538
  return groups;
1539
1539
  }
1540
+ function readClefSign(r) {
1541
+ let code = r.f32();
1542
+ switch (code) {
1543
+ case 0:
1544
+ return;
1545
+ case 1:
1546
+ return "G";
1547
+ case 2:
1548
+ return "F";
1549
+ case 3:
1550
+ return "C";
1551
+ case 4:
1552
+ return "P";
1553
+ default:
1554
+ throw new Error(`Unknown binary clef sign: ${code}`);
1555
+ }
1556
+ }
1557
+ function readClefContexts(r, bounds) {
1558
+ if (r.f32() !== bounds.length) throw new Error("Binary clef context count does not match measure bounds");
1559
+ for (let bound of bounds) {
1560
+ let sign = readClefSign(r);
1561
+ sign && (bound.clefSign = sign);
1562
+ let changeCount = r.f32();
1563
+ if (!Number.isInteger(changeCount) || changeCount < 0) throw new Error("Invalid binary clef change count");
1564
+ let changes = [];
1565
+ for (let i = 0; i < changeCount; i++) {
1566
+ let x = r.f32();
1567
+ if (!Number.isFinite(x)) throw new Error("Invalid binary clef change position");
1568
+ let changeSign = readClefSign(r);
1569
+ if (!changeSign) throw new Error("Binary clef change has no sign");
1570
+ changes.push({ x, sign: changeSign });
1571
+ }
1572
+ changes.length > 0 && (bound.clefChanges = changes);
1573
+ }
1574
+ }
1540
1575
  function readElementIds(r, numCommands, numStrings) {
1541
1576
  if (numStrings === 0) {
1542
1577
  r.skip(numCommands);
@@ -1588,6 +1623,7 @@ function decodeBinaryDisplayList(data) {
1588
1623
  bounds && (bounds.partId = id);
1589
1624
  }
1590
1625
  }
1626
+ r.pos < data.length && readClefContexts(r, measureBounds);
1591
1627
  let result = { commands, width, height };
1592
1628
  return pages.length > 0 && (result.pages = pages), elementIds && (result.elementIds = elementIds), elementBboxes.length > 0 && (result.elementBboxes = elementBboxes), slurGeometries.length > 0 && (result.slurGeometries = slurGeometries), measureBounds.length > 0 && (result.measureBounds = measureBounds), parts.length > 0 && (result.parts = parts), selectionGroups.length > 0 && (result.selectionGroups = selectionGroups), result;
1593
1629
  }
@@ -1792,6 +1828,8 @@ function normalizeDisplayList(raw) {
1792
1828
  prefixWidth: b.prefixWidth ?? b.prefix_width,
1793
1829
  totalBeats: b.totalBeats ?? b.total_beats,
1794
1830
  beatAnchors: b.beatAnchors ?? b.beat_anchors,
1831
+ clefSign: b.clefSign ?? b.clef_sign,
1832
+ clefChanges: b.clefChanges ?? b.clef_changes,
1795
1833
  ghostStaff: b.ghostStaff ?? b.ghost_staff,
1796
1834
  isHidden: b.isHidden ?? b.is_hidden,
1797
1835
  hasMusicHidden: b.hasMusicHidden ?? b.has_music_hidden,
@@ -2265,9 +2303,9 @@ function interpolateBeatAnchors(bounds, beat, endX) {
2265
2303
 
2266
2304
  // packages/score-engine/src/buildInfo.ts
2267
2305
  init_define_import_meta_env();
2268
- var PACKAGE_VERSION = "0.2.1-next.55", BUNDLE_WORKER_FILE = "score-engine.worker.js";
2306
+ var PACKAGE_VERSION = "0.2.1-next.57", BUNDLE_WORKER_FILE = "score-engine.worker.js";
2269
2307
  function buildCommit() {
2270
- return "4c27c6a82544ba61ca89b4275ecd12b828bc11ae";
2308
+ return "fd20cac3d1d0645faf5ca5fd8bcaa7aedb2919c6";
2271
2309
  }
2272
2310
  function bundledAssetBase() {
2273
2311
  let moduleUrl = import.meta.url;