alphatheta-connect 0.25.3 → 0.26.0

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/index.js CHANGED
@@ -7187,7 +7187,12 @@ class ProlinkNetwork {
7187
7187
  }
7188
7188
  const tx = Telemetry.startTransaction({ name: 'connect' });
7189
7189
  const connectMethod = (_a = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").connectMethod) !== null && _a !== void 0 ? _a : 'active';
7190
+ // Pick the device number once and keep it. A CDJ-3000 that already holds
7191
+ // a record for our IP ignores a re-claim under a different number, so a
7192
+ // disconnect/connect cycle must present the same identity (see
7193
+ // getStagehandMac).
7190
7194
  const vcdjId = (_b = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").vcdjId) !== null && _b !== void 0 ? _b : (connectMethod === 'stagehand' ? (0, virtualcdj_1.generateStagehandDeviceId)() : constants_1.DEFAULT_VCDJ_ID);
7195
+ __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").vcdjId = vcdjId;
7191
7196
  const vcdjName = (_c = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").vcdjName) !== null && _c !== void 0 ? _c : (connectMethod === 'stagehand' ? 'Stagehand' : undefined);
7192
7197
  // Create VCDJ or Stagehand device
7193
7198
  const vcdj = connectMethod === 'stagehand'
@@ -14146,7 +14151,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
14146
14151
  var _StagehandAnnouncer_instances, _StagehandAnnouncer_announceSocket, _StagehandAnnouncer_vcdj, _StagehandAnnouncer_intervalHandle, _StagehandAnnouncer_currentStage, _StagehandAnnouncer_stageCounter, _StagehandAnnouncer_iface, _StagehandAnnouncer_logger, _StagehandAnnouncer_onStartupComplete, _StagehandAnnouncer_mac, _StagehandAnnouncer_startStartup, _StagehandAnnouncer_sendPacket, _StagehandAnnouncer_sendStagePackets, _StagehandAnnouncer_advanceStage, _StagehandAnnouncer_startKeepAlive;
14147
14152
  Object.defineProperty(exports, "__esModule", ({ value: true }));
14148
14153
  exports.StagehandAnnouncer = exports.getVirtualStagehand = exports.StagehandStartupStage = exports.STAGEHAND_KEEP_ALIVE_INTERVAL = exports.STAGEHAND_STARTUP_INTERVAL = void 0;
14149
- exports.generateStagehandMac = generateStagehandMac;
14154
+ exports.getStagehandMac = getStagehandMac;
14150
14155
  exports.generateStagehandDeviceId = generateStagehandDeviceId;
14151
14156
  exports.makeStagehand0aPacket = makeStagehand0aPacket;
14152
14157
  exports.makeStagehand02Packet = makeStagehand02Packet;
@@ -14165,17 +14170,21 @@ var StagehandStartupStage;
14165
14170
  StagehandStartupStage[StagehandStartupStage["KeepAlive"] = 6] = "KeepAlive";
14166
14171
  })(StagehandStartupStage || (exports.StagehandStartupStage = StagehandStartupStage = {}));
14167
14172
  /**
14168
- * Generates a randomized MAC address with the AlphaTheta OUI (c8:3d:fc).
14173
+ * The protocol-layer MAC a Stagehand device embeds in its 0x02 claim and 0x06
14174
+ * keep-alive: the AlphaTheta OUI (c8:3d:fc) followed by the low three bytes of
14175
+ * the interface's own MAC.
14176
+ *
14177
+ * This must stay stable for the life of the host. A CDJ-3000 records a peer by
14178
+ * the identity in its claim, and once it holds a record for our IP it ignores
14179
+ * later claims from the same IP that carry a different MAC or device number:
14180
+ * the new peer never receives the unicast status/position stream. Observed on
14181
+ * emulated CDJ-3000 firmware 3.20: a freshly randomized identity on every
14182
+ * connect() was served once and then never again until the player rebooted,
14183
+ * while the previously registered identity kept being served immediately.
14169
14184
  */
14170
- function generateStagehandMac() {
14171
- const mac = new Uint8Array(6);
14172
- mac[0] = 0xc8;
14173
- mac[1] = 0x3d;
14174
- mac[2] = 0xfc;
14175
- mac[3] = Math.floor(Math.random() * 256);
14176
- mac[4] = Math.floor(Math.random() * 256);
14177
- mac[5] = Math.floor(Math.random() * 256);
14178
- return mac;
14185
+ function getStagehandMac(iface) {
14186
+ const ifaceMac = iface.mac.split(':').map(s => parseInt(s, 16));
14187
+ return Uint8Array.from([0xc8, 0x3d, 0xfc, ...ifaceMac.slice(3, 6)]);
14179
14188
  }
14180
14189
  /**
14181
14190
  * Generates a random Stagehand device ID in the observed range of 141 to 211.
@@ -14189,9 +14198,9 @@ function generateStagehandDeviceId() {
14189
14198
  * @param iface - The network interface to use
14190
14199
  * @param id - The device ID to use (defaults to random Stagehand ID)
14191
14200
  * @param name - The device name (defaults to 'Stagehand')
14192
- * @param macAddr - The optional randomized MAC address
14201
+ * @param macAddr - The protocol-layer MAC (defaults to one derived from iface)
14193
14202
  */
14194
- const getVirtualStagehand = (iface, id = generateStagehandDeviceId(), name = 'Stagehand', macAddr = generateStagehandMac()) => ({
14203
+ const getVirtualStagehand = (iface, id = generateStagehandDeviceId(), name = 'Stagehand', macAddr = getStagehandMac(iface)) => ({
14195
14204
  id,
14196
14205
  name,
14197
14206
  type: types_1.DeviceType.Stagehand,