alphatheta-connect 0.21.6 → 0.21.7

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/lib/cli.js CHANGED
@@ -6838,9 +6838,13 @@ async function bringOnline(config) {
6838
6838
  tx.finish();
6839
6839
  throw err;
6840
6840
  }
6841
+ // Stagehand's experimental packet parsing (0x39 mixer state, 0x58 VU) is
6842
+ // gated to Stagehand mode only. In 'active'/passive mode these emitters
6843
+ // behave as they did before Stagehand was added.
6844
+ const stagehandMode = (config === null || config === void 0 ? void 0 : config.connectMethod) === 'stagehand';
6841
6845
  const deviceManager = new devices_1.default(announceSocket);
6842
- const statusEmitter = new status_1.default(statusSocket);
6843
- const positionEmitter = new position_1.default(beatSocket);
6846
+ const statusEmitter = new status_1.default(statusSocket, stagehandMode);
6847
+ const positionEmitter = new position_1.default(beatSocket, stagehandMode);
6844
6848
  tx.finish();
6845
6849
  const network = new ProlinkNetwork({
6846
6850
  config,
@@ -9753,7 +9757,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9753
9757
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
9754
9758
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9755
9759
  };
9756
- var _StatusEmitter_statusSocket, _StatusEmitter_emitter, _StatusEmitter_mediaSlotQueryLock, _StatusEmitter_handleStatus;
9760
+ var _StatusEmitter_statusSocket, _StatusEmitter_emitter, _StatusEmitter_mediaSlotQueryLock, _StatusEmitter_stagehandMode, _StatusEmitter_handleStatus;
9757
9761
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9758
9762
  const async_mutex_1 = __webpack_require__(/*! async-mutex */ "async-mutex");
9759
9763
  const events_1 = __webpack_require__(/*! events */ "events");
@@ -9767,8 +9771,13 @@ const utils_1 = __webpack_require__(/*! ./utils */ "./src/status/utils.ts");
9767
9771
  class StatusEmitter {
9768
9772
  /**
9769
9773
  * @param statusSocket A UDP socket to receive CDJ status packets on
9774
+ * @param stagehandMode Enable Stagehand-only mixer-state parsing. Off by
9775
+ * default so 'active' and passive connections behave exactly as they did
9776
+ * before Stagehand was added — the 0x39 layout is reverse-engineered from a
9777
+ * DJM-A9 and must not be applied to other mixers (e.g. XDJ-AZ) that were
9778
+ * never captured.
9770
9779
  */
9771
- constructor(statusSocket) {
9780
+ constructor(statusSocket, stagehandMode = false) {
9772
9781
  _StatusEmitter_statusSocket.set(this, void 0);
9773
9782
  /**
9774
9783
  * The EventEmitter which reports the device status
@@ -9778,6 +9787,11 @@ class StatusEmitter {
9778
9787
  * Lock used to avoid media slot query races
9779
9788
  */
9780
9789
  _StatusEmitter_mediaSlotQueryLock.set(this, new async_mutex_1.Mutex());
9790
+ /**
9791
+ * Whether the experimental Stagehand mixer-state (0x39) parsing is active.
9792
+ * Only true when the network was brought online in 'stagehand' mode.
9793
+ */
9794
+ _StatusEmitter_stagehandMode.set(this, void 0);
9781
9795
  // Bind public event emitter interface. Use explicit generic signatures keyed
9782
9796
  // on StatusEvents rather than `Emitter['on']`: extracting the indexed `on`
9783
9797
  // type out of strict-event-emitter-types degrades to its unique-symbol
@@ -9787,8 +9801,11 @@ class StatusEmitter {
9787
9801
  this.off = __classPrivateFieldGet(this, _StatusEmitter_emitter, "f").removeListener.bind(__classPrivateFieldGet(this, _StatusEmitter_emitter, "f"));
9788
9802
  this.once = __classPrivateFieldGet(this, _StatusEmitter_emitter, "f").once.bind(__classPrivateFieldGet(this, _StatusEmitter_emitter, "f"));
9789
9803
  _StatusEmitter_handleStatus.set(this, (message) => {
9790
- // Stagehand mixer state (type 0x39)
9791
- if (message.length >= 11 && message[10] === 0x39) {
9804
+ // Stagehand mixer state (type 0x39). Only parsed in Stagehand mode — the
9805
+ // layout is DJM-A9-specific and applying it to other mixers misreads their
9806
+ // faders (NP3-327). In 'active'/passive mode we fall back to the on-air
9807
+ // flag, which is how on-air detection worked before Stagehand.
9808
+ if (__classPrivateFieldGet(this, _StatusEmitter_stagehandMode, "f") && message.length >= 11 && message[10] === 0x39) {
9792
9809
  const mixerState = (0, utils_1.mixerStateFromPacket)(message);
9793
9810
  if (mixerState !== undefined) {
9794
9811
  return __classPrivateFieldGet(this, _StatusEmitter_emitter, "f").emit('mixerState', mixerState);
@@ -9811,6 +9828,7 @@ class StatusEmitter {
9811
9828
  return undefined;
9812
9829
  });
9813
9830
  __classPrivateFieldSet(this, _StatusEmitter_statusSocket, statusSocket, "f");
9831
+ __classPrivateFieldSet(this, _StatusEmitter_stagehandMode, stagehandMode, "f");
9814
9832
  statusSocket.on('message', __classPrivateFieldGet(this, _StatusEmitter_handleStatus, "f"));
9815
9833
  }
9816
9834
  /**
@@ -9842,7 +9860,7 @@ class StatusEmitter {
9842
9860
  return media;
9843
9861
  }
9844
9862
  }
9845
- _StatusEmitter_statusSocket = new WeakMap(), _StatusEmitter_emitter = new WeakMap(), _StatusEmitter_mediaSlotQueryLock = new WeakMap(), _StatusEmitter_handleStatus = new WeakMap();
9863
+ _StatusEmitter_statusSocket = new WeakMap(), _StatusEmitter_emitter = new WeakMap(), _StatusEmitter_mediaSlotQueryLock = new WeakMap(), _StatusEmitter_stagehandMode = new WeakMap(), _StatusEmitter_handleStatus = new WeakMap();
9846
9864
  exports["default"] = StatusEmitter;
9847
9865
 
9848
9866
 
@@ -9888,12 +9906,18 @@ exports.makeMediaSlotRequest = makeMediaSlotRequest;
9888
9906
 
9889
9907
  "use strict";
9890
9908
 
9909
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9910
+ if (kind === "m") throw new TypeError("Private method is not writable");
9911
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9912
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
9913
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9914
+ };
9891
9915
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9892
9916
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9893
9917
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
9894
9918
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9895
9919
  };
9896
- var _PositionEmitter_emitter, _PositionEmitter_handlePosition;
9920
+ var _PositionEmitter_emitter, _PositionEmitter_stagehandMode, _PositionEmitter_handlePosition;
9897
9921
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9898
9922
  const events_1 = __webpack_require__(/*! events */ "events");
9899
9923
  const utils_1 = __webpack_require__(/*! ./utils */ "./src/status/utils.ts");
@@ -9906,19 +9930,25 @@ const utils_1 = __webpack_require__(/*! ./utils */ "./src/status/utils.ts");
9906
9930
  class PositionEmitter {
9907
9931
  /**
9908
9932
  * @param beatSocket A UDP socket to receive position packets on port 50001
9933
+ * @param stagehandMode Enable Stagehand-only VU-meter parsing. Off by default
9934
+ * so non-Stagehand connections behave as they did before Stagehand.
9909
9935
  */
9910
- constructor(beatSocket) {
9936
+ constructor(beatSocket, stagehandMode = false) {
9911
9937
  /**
9912
9938
  * The EventEmitter which reports position updates
9913
9939
  */
9914
9940
  _PositionEmitter_emitter.set(this, new events_1.EventEmitter());
9941
+ /**
9942
+ * Whether experimental Stagehand VU-meter (0x58) parsing is active.
9943
+ */
9944
+ _PositionEmitter_stagehandMode.set(this, void 0);
9915
9945
  // Bind public event emitter interface
9916
9946
  this.on = __classPrivateFieldGet(this, _PositionEmitter_emitter, "f").addListener.bind(__classPrivateFieldGet(this, _PositionEmitter_emitter, "f"));
9917
9947
  this.off = __classPrivateFieldGet(this, _PositionEmitter_emitter, "f").removeListener.bind(__classPrivateFieldGet(this, _PositionEmitter_emitter, "f"));
9918
9948
  this.once = __classPrivateFieldGet(this, _PositionEmitter_emitter, "f").once.bind(__classPrivateFieldGet(this, _PositionEmitter_emitter, "f"));
9919
9949
  _PositionEmitter_handlePosition.set(this, (message) => {
9920
- // Stagehand VU meter (type 0x58)
9921
- if (message.length >= 11 && message[10] === 0x58) {
9950
+ // Stagehand VU meter (type 0x58) — only parsed in Stagehand mode.
9951
+ if (__classPrivateFieldGet(this, _PositionEmitter_stagehandMode, "f") && message.length >= 11 && message[10] === 0x58) {
9922
9952
  const vu = (0, utils_1.vuFromPacket)(message);
9923
9953
  if (vu !== undefined) {
9924
9954
  __classPrivateFieldGet(this, _PositionEmitter_emitter, "f").emit('vu', vu);
@@ -9930,10 +9960,11 @@ class PositionEmitter {
9930
9960
  __classPrivateFieldGet(this, _PositionEmitter_emitter, "f").emit('position', position);
9931
9961
  }
9932
9962
  });
9963
+ __classPrivateFieldSet(this, _PositionEmitter_stagehandMode, stagehandMode, "f");
9933
9964
  beatSocket.on('message', __classPrivateFieldGet(this, _PositionEmitter_handlePosition, "f"));
9934
9965
  }
9935
9966
  }
9936
- _PositionEmitter_emitter = new WeakMap(), _PositionEmitter_handlePosition = new WeakMap();
9967
+ _PositionEmitter_emitter = new WeakMap(), _PositionEmitter_stagehandMode = new WeakMap(), _PositionEmitter_handlePosition = new WeakMap();
9937
9968
  exports["default"] = PositionEmitter;
9938
9969
 
9939
9970