@waveform-playlist/core 13.0.0-next.2 → 13.0.0-next.3

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.mjs CHANGED
@@ -1604,6 +1604,66 @@ function audioTrack(options) {
1604
1604
  return track;
1605
1605
  }
1606
1606
 
1607
+ // src/mixerGesture.ts
1608
+ var RANGE_KEYS = /* @__PURE__ */ new Set([
1609
+ "ArrowUp",
1610
+ "ArrowDown",
1611
+ "ArrowLeft",
1612
+ "ArrowRight",
1613
+ "PageUp",
1614
+ "PageDown",
1615
+ "Home",
1616
+ "End"
1617
+ ]);
1618
+ var ID_PREFIX = Math.random().toString(36).slice(2, 10);
1619
+ var idCount = 0;
1620
+ function nextId() {
1621
+ idCount += 1;
1622
+ return `mg-${ID_PREFIX}-${idCount}`;
1623
+ }
1624
+ function createMixerGesture() {
1625
+ let id = nextId();
1626
+ const end = () => {
1627
+ id = nextId();
1628
+ };
1629
+ const attach = (input) => {
1630
+ let heldKey = null;
1631
+ const onKeyDown = (event) => {
1632
+ const { key } = event;
1633
+ if (RANGE_KEYS.has(key)) heldKey = key;
1634
+ };
1635
+ const onKeyUp = (event) => {
1636
+ if (event.key !== heldKey) return;
1637
+ heldKey = null;
1638
+ end();
1639
+ };
1640
+ const onChange = () => {
1641
+ if (heldKey === null) end();
1642
+ };
1643
+ const onBlur = () => {
1644
+ heldKey = null;
1645
+ end();
1646
+ };
1647
+ input.addEventListener("keydown", onKeyDown);
1648
+ input.addEventListener("keyup", onKeyUp);
1649
+ input.addEventListener("change", onChange);
1650
+ input.addEventListener("blur", onBlur);
1651
+ return () => {
1652
+ input.removeEventListener("keydown", onKeyDown);
1653
+ input.removeEventListener("keyup", onKeyUp);
1654
+ input.removeEventListener("change", onChange);
1655
+ input.removeEventListener("blur", onBlur);
1656
+ };
1657
+ };
1658
+ return {
1659
+ get id() {
1660
+ return id;
1661
+ },
1662
+ end,
1663
+ attach
1664
+ };
1665
+ }
1666
+
1607
1667
  // src/effects/registry.ts
1608
1668
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@waveform-playlist/core/effect-registry/v1");
1609
1669
  function registryState() {
@@ -1745,6 +1805,7 @@ export {
1745
1805
  createClipFromSeconds,
1746
1806
  createClipFromTicks,
1747
1807
  createEffectInstance,
1808
+ createMixerGesture,
1748
1809
  createPanStage,
1749
1810
  createSourceLoader,
1750
1811
  createTimeline,