@viritura/score-engine 0.2.1-next.33 → 0.2.1-next.34

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
@@ -2214,9 +2214,9 @@ function interpolateBeatAnchors(bounds, beat, endX) {
2214
2214
 
2215
2215
  // packages/score-engine/src/buildInfo.ts
2216
2216
  init_define_import_meta_env();
2217
- var PACKAGE_VERSION = "0.2.1-next.33", BUNDLE_WORKER_FILE = "score-engine.worker.js";
2217
+ var PACKAGE_VERSION = "0.2.1-next.34", BUNDLE_WORKER_FILE = "score-engine.worker.js";
2218
2218
  function buildCommit() {
2219
- return "fc9d89cc757e0e14d86159774496b6a49a9e2b7c";
2219
+ return "8164ae9c9c954a817a39c240b583d1e5b93e70f0";
2220
2220
  }
2221
2221
  function bundledAssetBase() {
2222
2222
  let moduleUrl = import.meta.url;
@@ -16670,8 +16670,8 @@ function nextInstruction(measure, cursor, length, state, fine, taken, initialOrd
16670
16670
  };
16671
16671
  }
16672
16672
  function compileNavigation(measures, initialOrder, measureLengths) {
16673
- let { markers, required } = resolveDestinations(measures, measureLengths), result = [], taken = /* @__PURE__ */ new Set(), state = { fineArmed: !1, codaArmed: !1, replay: !1, orderIndex: 0 }, cursor = { measureIndex: initialOrder[0] ?? 0, beat: 0 }, transitions = 0;
16674
- for (; cursor.measureIndex < measures.length && (state.replay || state.orderIndex < initialOrder.length); ) {
16673
+ let { markers, required } = resolveDestinations(measures, measureLengths), result = [], order = initialOrder, taken = /* @__PURE__ */ new Set(), state = { fineArmed: !1, codaArmed: !1, replay: !1, orderIndex: 0 }, cursor = { measureIndex: order[0] ?? 0, beat: 0 }, transitions = 0;
16674
+ for (; cursor.measureIndex < measures.length && (state.replay || state.orderIndex < order.length); ) {
16675
16675
  if (++transitions > MAX_SPANS)
16676
16676
  throw new NavigationError("Navigation exceeds the safe playback traversal limit", ["/global/measures"]);
16677
16677
  let index = cursor.measureIndex, measure = measures[index], length = measureLengths[index], { type, jumpActive, jumpBeat, fineReached, endBeat } = nextInstruction(
@@ -16681,17 +16681,26 @@ function compileNavigation(measures, initialOrder, measureLengths) {
16681
16681
  state,
16682
16682
  markers.fine[0],
16683
16683
  taken,
16684
- initialOrder
16684
+ order
16685
16685
  );
16686
16686
  if (endBeat > cursor.beat + EPS && result.push({ measureIndex: index, startBeat: cursor.beat, endBeat, measureBeats: length }), state.fineArmed && fineReached) {
16687
16687
  state.fineArmed = !1;
16688
16688
  break;
16689
16689
  }
16690
16690
  if (jumpActive && jumpBeat <= endBeat + EPS) {
16691
- taken.add(index), state.replay = !0, type === "toCoda" ? (state.codaArmed = !1, cursor = required("coda", index)) : (state.fineArmed = type === "dcAlFine" || type === "dsAlFine", state.codaArmed = type === "dcAlCoda" || type === "dsAlCoda", cursor = ["segno", "dsAlFine", "dsAlCoda"].includes(type) ? required("segno", index) : { measureIndex: 0, beat: 0 });
16691
+ if (taken.add(index), type === "toCoda") {
16692
+ if (state.codaArmed = !1, cursor = required("coda", index), state.orderIndex = order.indexOf(cursor.measureIndex), state.orderIndex < 0) {
16693
+ let nextRepeat = measures.findIndex(
16694
+ (measure2, measureIndex) => measureIndex > cursor.measureIndex && measure2.repeatStart && order.includes(measureIndex)
16695
+ ), end = nextRepeat < 0 ? measures.length : nextRepeat;
16696
+ order = [...Array.from({ length: end - cursor.measureIndex }, (_, offset) => cursor.measureIndex + offset), ...nextRepeat < 0 ? [] : order.slice(order.indexOf(nextRepeat))], state.orderIndex = 0;
16697
+ }
16698
+ state.replay = !1;
16699
+ } else
16700
+ state.replay = !0, state.fineArmed = type === "dcAlFine" || type === "dsAlFine", state.codaArmed = type === "dcAlCoda" || type === "dsAlCoda", cursor = ["segno", "dsAlFine", "dsAlCoda"].includes(type) ? required("segno", index) : { measureIndex: 0, beat: 0 };
16692
16701
  continue;
16693
16702
  }
16694
- state.orderIndex++, cursor = { measureIndex: state.replay ? index + 1 : initialOrder[state.orderIndex] ?? measures.length, beat: 0 };
16703
+ state.orderIndex++, cursor = { measureIndex: state.replay ? index + 1 : order[state.orderIndex] ?? measures.length, beat: 0 };
16695
16704
  }
16696
16705
  if (state.fineArmed || state.codaArmed)
16697
16706
  throw new NavigationError("The armed Fine or To Coda instruction is not reachable on replay", ["/global/measures"]);