@vosjs/studio-core 0.30.0 → 0.30.2

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.d.ts CHANGED
@@ -2404,6 +2404,12 @@ interface PlanOptions {
2404
2404
  dragLevel?: number;
2405
2405
  /** emit spans with focusMode 'auto' (cursor-follow camera). */
2406
2406
  followByDefault?: boolean;
2407
+ /**
2408
+ * the footage's length in seconds: no span runs past it. The cursor
2409
+ * track ends at the last event, before the footage does, so the track
2410
+ * alone cannot say where the footage ends.
2411
+ */
2412
+ duration?: number;
2407
2413
  /** typing sessions plan spans. */
2408
2414
  typingZoom?: boolean;
2409
2415
  /** max silence between `key` pings before the typing session ends. */
package/dist/index.js CHANGED
@@ -1749,8 +1749,10 @@ function planAutoZoom(track, options) {
1749
1749
  typingZoom = style.typingZoom,
1750
1750
  typingGap = style.typingGap,
1751
1751
  typingHold = style.typingHold,
1752
- typingMinLevel = style.typingMinLevel
1752
+ typingMinLevel = style.typingMinLevel,
1753
+ duration
1753
1754
  } = options;
1755
+ const within = (spans2) => duration === void 0 ? spans2 : spans2.map((z) => ({ ...z, out: Math.min(z.out, round(duration)) })).filter((z) => z.out - z.in >= 0.3);
1754
1756
  const grouped = groupTrack(track, {
1755
1757
  width,
1756
1758
  height,
@@ -1801,6 +1803,12 @@ function planAutoZoom(track, options) {
1801
1803
  level: f.level
1802
1804
  });
1803
1805
  }
1806
+ clickSpans.sort((a, b) => a.in - b.in);
1807
+ for (let i = 0; i + 1 < clickSpans.length; i++) {
1808
+ if (clickSpans[i].out > clickSpans[i + 1].in)
1809
+ clickSpans[i].out = clickSpans[i + 1].in;
1810
+ }
1811
+ for (const z of clickSpans) if (z.out - z.in < 0.3) z.dead = true;
1804
1812
  const typingFloor = Math.min(Math.max(minLevel, typingMinLevel), maxLevel);
1805
1813
  let typing = sessions.map((s) => {
1806
1814
  const f = focusFor(
@@ -1864,12 +1872,14 @@ function planAutoZoom(track, options) {
1864
1872
  // the FIELD is the anchor, and a follow would be a no-op at best.
1865
1873
  source: "auto"
1866
1874
  }));
1867
- const spans = [...zSpans, ...kSpans, ...dragSpans].sort((a, b) => a.in - b.in);
1875
+ const spans = within([...zSpans, ...kSpans, ...dragSpans]).sort(
1876
+ (a, b) => a.in - b.in
1877
+ );
1868
1878
  const dwells = dwellSpans(track, width, height, maxLevel, [
1869
1879
  ...spans,
1870
1880
  ...dragReserved
1871
1881
  ]);
1872
- return [...spans, ...dwells].sort((a, b) => a.in - b.in);
1882
+ return within([...spans, ...dwells]).sort((a, b) => a.in - b.in);
1873
1883
  }
1874
1884
  function typingSessions(track, width, height, typingGap) {
1875
1885
  const pings = track.filter((e) => e.type === "key").map((e) => ({ t: e.t / 1e3, rect: e.rect, x: e.x, y: e.y }));