alphatheta-connect 0.23.1 → 0.25.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/cli.js +389 -46
- package/lib/cli.js.map +1 -1
- package/lib/constants.d.ts +4 -2
- package/lib/db/getMetadata.d.ts +23 -1
- package/lib/db/index.d.ts +2 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +391 -47
- package/lib/index.js.map +1 -1
- package/lib/network.d.ts +10 -9
- package/lib/remotedb/fields.d.ts +6 -6
- package/lib/remotedb/index.d.ts +12 -1
- package/lib/status/types.d.ts +54 -6
- package/lib/types.js +20 -1
- package/lib/types.js.map +1 -1
- package/lib/virtualcdj/device-id.d.ts +36 -7
- package/lib/virtualcdj/heartbeat.d.ts +51 -0
- package/lib/virtualcdj/heartbeat.test.d.ts +1 -0
- package/lib/virtualcdj/index.d.ts +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -631,8 +631,10 @@ exports.MAX_CDJ_DEVICE_ID = exports.MIN_CDJ_DEVICE_ID = exports.VIRTUAL_CDJ_FIRM
|
|
|
631
631
|
/**
|
|
632
632
|
* The default virtual CDJ ID to use.
|
|
633
633
|
*
|
|
634
|
-
*
|
|
635
|
-
* metadata
|
|
634
|
+
* Out of the 1-6 player range, so it can never collide with a real CDJ.
|
|
635
|
+
* Remotedb metadata still works from here: the 1-6 restriction applies to the
|
|
636
|
+
* device-ID byte inside remotedb messages, which RemoteDatabase picks
|
|
637
|
+
* per-connection independently of the announced ID.
|
|
636
638
|
*/
|
|
637
639
|
exports.DEFAULT_VCDJ_ID = 0x07;
|
|
638
640
|
/**
|
|
@@ -1272,11 +1274,11 @@ async function viaLocal(local, device, opts) {
|
|
|
1272
1274
|
}
|
|
1273
1275
|
const adapter = await local.get(deviceId, trackSlot);
|
|
1274
1276
|
if (adapter === null) {
|
|
1275
|
-
return null;
|
|
1277
|
+
return { track: null, miss: 'no-database' };
|
|
1276
1278
|
}
|
|
1277
1279
|
const dbTrack = adapter.findTrack(trackId);
|
|
1278
1280
|
if (dbTrack === null) {
|
|
1279
|
-
return null;
|
|
1281
|
+
return { track: null, miss: 'track-absent' };
|
|
1280
1282
|
}
|
|
1281
1283
|
const anlz = await (0, rekordbox_1.loadAnlz)(dbTrack, 'DAT', (0, utils_1.anlzLoader)({ device, slot: trackSlot }));
|
|
1282
1284
|
const track = {
|
|
@@ -1284,7 +1286,7 @@ async function viaLocal(local, device, opts) {
|
|
|
1284
1286
|
beatGrid: anlz.beatGrid,
|
|
1285
1287
|
waveformHd: null,
|
|
1286
1288
|
};
|
|
1287
|
-
return track;
|
|
1289
|
+
return { track, miss: null };
|
|
1288
1290
|
}
|
|
1289
1291
|
|
|
1290
1292
|
|
|
@@ -1534,8 +1536,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
1534
1536
|
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");
|
|
1535
1537
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1536
1538
|
};
|
|
1537
|
-
var _Database_deviceManager, _Database_localDatabase, _Database_remoteDatabase, _Database_getTrackLookupStrategy, _Database_getMediaLookupStrategy;
|
|
1539
|
+
var _Database_instances, _Database_deviceManager, _Database_localDatabase, _Database_remoteDatabase, _Database_logger, _Database_getTrackLookupStrategy, _Database_getMediaLookupStrategy, _Database_metadataViaRemoteFallback;
|
|
1538
1540
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1541
|
+
const logger_1 = __webpack_require__(/*! src/logger */ "./src/logger.ts");
|
|
1539
1542
|
const types_1 = __webpack_require__(/*! src/types */ "./src/types.ts");
|
|
1540
1543
|
const utils_1 = __webpack_require__(/*! src/utils */ "./src/utils/index.ts");
|
|
1541
1544
|
const Telemetry = __importStar(__webpack_require__(/*! src/utils/telemetry */ "./src/utils/telemetry.ts"));
|
|
@@ -1558,7 +1561,8 @@ var LookupStrategy;
|
|
|
1558
1561
|
* network for information from their databases.
|
|
1559
1562
|
*/
|
|
1560
1563
|
class Database {
|
|
1561
|
-
constructor(local, remote, deviceManager) {
|
|
1564
|
+
constructor(local, remote, deviceManager, logger = logger_1.noopLogger) {
|
|
1565
|
+
_Database_instances.add(this);
|
|
1562
1566
|
_Database_deviceManager.set(this, void 0);
|
|
1563
1567
|
/**
|
|
1564
1568
|
* The local database service, used when querying media devices connected
|
|
@@ -1570,6 +1574,7 @@ class Database {
|
|
|
1570
1574
|
* CDJ with an unanalyzed media device connected (when possible).
|
|
1571
1575
|
*/
|
|
1572
1576
|
_Database_remoteDatabase.set(this, void 0);
|
|
1577
|
+
_Database_logger.set(this, void 0);
|
|
1573
1578
|
_Database_getTrackLookupStrategy.set(this, (device, type) => {
|
|
1574
1579
|
const isUnanalyzed = type === types_1.TrackType.AudioCD || type === types_1.TrackType.Unanalyzed;
|
|
1575
1580
|
const isStreaming = type === types_1.TrackType.Streaming;
|
|
@@ -1592,6 +1597,7 @@ class Database {
|
|
|
1592
1597
|
__classPrivateFieldSet(this, _Database_localDatabase, local, "f");
|
|
1593
1598
|
__classPrivateFieldSet(this, _Database_remoteDatabase, remote, "f");
|
|
1594
1599
|
__classPrivateFieldSet(this, _Database_deviceManager, deviceManager, "f");
|
|
1600
|
+
__classPrivateFieldSet(this, _Database_logger, logger, "f");
|
|
1595
1601
|
}
|
|
1596
1602
|
/**
|
|
1597
1603
|
* Get the database type (oneLibrary or pdb) for a loaded device slot.
|
|
@@ -1622,7 +1628,18 @@ class Database {
|
|
|
1622
1628
|
track = await GetMetadata.viaRemote(__classPrivateFieldGet(this, _Database_remoteDatabase, "f"), callOpts);
|
|
1623
1629
|
}
|
|
1624
1630
|
if (strategy === LookupStrategy.Local) {
|
|
1625
|
-
|
|
1631
|
+
const local = await GetMetadata.viaLocal(__classPrivateFieldGet(this, _Database_localDatabase, "f"), device, callOpts);
|
|
1632
|
+
track = local.track;
|
|
1633
|
+
// A local miss used to end the lookup, so the DJ's track silently never
|
|
1634
|
+
// reached the overlay for the rest of the set (NP3-361). Say what was
|
|
1635
|
+
// missed, then give the CDJ's own database a chance to answer.
|
|
1636
|
+
if (local.miss !== null) {
|
|
1637
|
+
__classPrivateFieldGet(this, _Database_logger, "f").warn(`Local metadata lookup missed track ${opts.trackId} on device ${deviceId} ` +
|
|
1638
|
+
`${(0, utils_1.getSlotName)(trackSlot)}: ${local.miss === 'no-database'
|
|
1639
|
+
? 'no rekordbox database is loaded for that slot'
|
|
1640
|
+
: 'the loaded database holds no track with that id'}`);
|
|
1641
|
+
track = await __classPrivateFieldGet(this, _Database_instances, "m", _Database_metadataViaRemoteFallback).call(this, callOpts);
|
|
1642
|
+
}
|
|
1626
1643
|
}
|
|
1627
1644
|
if (strategy === LookupStrategy.NoneAvailable) {
|
|
1628
1645
|
tx.setStatus(telemetry_1.SpanStatus.Unavailable);
|
|
@@ -1816,7 +1833,34 @@ class Database {
|
|
|
1816
1833
|
return contents;
|
|
1817
1834
|
}
|
|
1818
1835
|
}
|
|
1819
|
-
_Database_deviceManager = new WeakMap(), _Database_localDatabase = new WeakMap(), _Database_remoteDatabase = new WeakMap(), _Database_getTrackLookupStrategy = new WeakMap(), _Database_getMediaLookupStrategy = new WeakMap()
|
|
1836
|
+
_Database_deviceManager = new WeakMap(), _Database_localDatabase = new WeakMap(), _Database_remoteDatabase = new WeakMap(), _Database_logger = new WeakMap(), _Database_getTrackLookupStrategy = new WeakMap(), _Database_getMediaLookupStrategy = new WeakMap(), _Database_instances = new WeakSet(), _Database_metadataViaRemoteFallback =
|
|
1837
|
+
/**
|
|
1838
|
+
* Second chance for a track the local database could not answer for.
|
|
1839
|
+
*
|
|
1840
|
+
* Available regardless of the virtual CDJ's announced ID: CDJs restrict
|
|
1841
|
+
* remote database queries to a device-ID byte in the 1-6 range, but that
|
|
1842
|
+
* byte lives inside the remotedb messages and RemoteDatabase picks an
|
|
1843
|
+
* in-range one per connection — the announced ID never constrains this
|
|
1844
|
+
* lookup. A failure here is logged rather than thrown, so a field report
|
|
1845
|
+
* says what actually went wrong.
|
|
1846
|
+
*/
|
|
1847
|
+
async function _Database_metadataViaRemoteFallback(opts) {
|
|
1848
|
+
try {
|
|
1849
|
+
const track = await GetMetadata.viaRemote(__classPrivateFieldGet(this, _Database_remoteDatabase, "f"), opts);
|
|
1850
|
+
if (track === null) {
|
|
1851
|
+
__classPrivateFieldGet(this, _Database_logger, "f").warn(`Remote fallback found no track ${opts.trackId} on device ${opts.deviceId}`);
|
|
1852
|
+
return null;
|
|
1853
|
+
}
|
|
1854
|
+
__classPrivateFieldGet(this, _Database_logger, "f").info(`Remote fallback recovered track ${opts.trackId} from device ${opts.deviceId}`);
|
|
1855
|
+
return track;
|
|
1856
|
+
}
|
|
1857
|
+
catch (e) {
|
|
1858
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
1859
|
+
__classPrivateFieldGet(this, _Database_logger, "f").warn(`Remote fallback failed for track ${opts.trackId} on device ` +
|
|
1860
|
+
`${opts.deviceId}: ${message}`);
|
|
1861
|
+
return null;
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1820
1864
|
exports["default"] = Database;
|
|
1821
1865
|
|
|
1822
1866
|
|
|
@@ -2085,7 +2129,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
2085
2129
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2086
2130
|
};
|
|
2087
2131
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2088
|
-
exports.noopLogger = exports.REMOTEDB_MAX_DEVICE_ID = exports.playerNumberCeiling = exports.pickAvailableDeviceId = exports.MIXER_PLAYER_CEILING = exports.MAX_DEVICE_ID = exports.DEFAULT_MIXER_PLAYER_CEILING = exports.OneLibraryAdapter = exports.fetchFile = exports.loadAnlz = exports.isMetadataExtractionSupported = exports.extractMetadataFromDevice = exports.extractFullMetadata = exports.PictureType = exports.isArtworkExtractionSupported = exports.extractArtworkFromDevice = exports.extractArtwork = exports.PositionEmitter = void 0;
|
|
2132
|
+
exports.noopLogger = exports.REMOTEDB_MAX_DEVICE_ID = exports.playerNumberCeiling = exports.pickRemoteDbQueryId = exports.pickAvailableDeviceId = exports.MIXER_PLAYER_CEILING = exports.MAX_DEVICE_ID = exports.DEFAULT_MIXER_PLAYER_CEILING = exports.OneLibraryAdapter = exports.fetchFile = exports.loadAnlz = exports.isMetadataExtractionSupported = exports.extractMetadataFromDevice = exports.extractFullMetadata = exports.PictureType = exports.isArtworkExtractionSupported = exports.extractArtworkFromDevice = exports.extractArtwork = exports.PositionEmitter = void 0;
|
|
2089
2133
|
__exportStar(__webpack_require__(/*! ./entities */ "./src/entities.ts"), exports);
|
|
2090
2134
|
__exportStar(__webpack_require__(/*! ./mixstatus */ "./src/mixstatus/index.ts"), exports);
|
|
2091
2135
|
__exportStar(__webpack_require__(/*! ./network */ "./src/network.ts"), exports);
|
|
@@ -2113,6 +2157,7 @@ Object.defineProperty(exports, "DEFAULT_MIXER_PLAYER_CEILING", ({ enumerable: tr
|
|
|
2113
2157
|
Object.defineProperty(exports, "MAX_DEVICE_ID", ({ enumerable: true, get: function () { return device_id_1.MAX_DEVICE_ID; } }));
|
|
2114
2158
|
Object.defineProperty(exports, "MIXER_PLAYER_CEILING", ({ enumerable: true, get: function () { return device_id_1.MIXER_PLAYER_CEILING; } }));
|
|
2115
2159
|
Object.defineProperty(exports, "pickAvailableDeviceId", ({ enumerable: true, get: function () { return device_id_1.pickAvailableDeviceId; } }));
|
|
2160
|
+
Object.defineProperty(exports, "pickRemoteDbQueryId", ({ enumerable: true, get: function () { return device_id_1.pickRemoteDbQueryId; } }));
|
|
2116
2161
|
Object.defineProperty(exports, "playerNumberCeiling", ({ enumerable: true, get: function () { return device_id_1.playerNumberCeiling; } }));
|
|
2117
2162
|
Object.defineProperty(exports, "REMOTEDB_MAX_DEVICE_ID", ({ enumerable: true, get: function () { return device_id_1.REMOTEDB_MAX_DEVICE_ID; } }));
|
|
2118
2163
|
var logger_1 = __webpack_require__(/*! ./logger */ "./src/logger.ts");
|
|
@@ -6744,7 +6789,7 @@ class MixstatusProcessor {
|
|
|
6744
6789
|
// able to report it as live
|
|
6745
6790
|
const startedAt = __classPrivateFieldGet(this, _MixstatusProcessor_lastStartTime, "f").get(deviceId);
|
|
6746
6791
|
const requiredPlayTime = __classPrivateFieldGet(this, _MixstatusProcessor_config, "f").beatsUntilReported *
|
|
6747
|
-
(0, utils_1.bpmToSeconds)(state.trackBPM, state.
|
|
6792
|
+
(0, utils_1.bpmToSeconds)(state.trackBPM, state.effectivePitch) *
|
|
6748
6793
|
1000;
|
|
6749
6794
|
if (__classPrivateFieldGet(this, _MixstatusProcessor_config, "f").mode === types_1.MixstatusMode.SmartTiming &&
|
|
6750
6795
|
startedAt !== undefined &&
|
|
@@ -6755,7 +6800,7 @@ class MixstatusProcessor {
|
|
|
6755
6800
|
// we can mark the track as truly stopped.
|
|
6756
6801
|
const stoppedAt = __classPrivateFieldGet(this, _MixstatusProcessor_lastStoppedTimes, "f").get(deviceId);
|
|
6757
6802
|
const requiredStopTime = __classPrivateFieldGet(this, _MixstatusProcessor_config, "f").allowedInterruptBeats *
|
|
6758
|
-
(0, utils_1.bpmToSeconds)(state.trackBPM, state.
|
|
6803
|
+
(0, utils_1.bpmToSeconds)(state.trackBPM, state.effectivePitch) *
|
|
6759
6804
|
1000;
|
|
6760
6805
|
if (stoppedAt !== undefined && requiredStopTime <= Date.now() - stoppedAt) {
|
|
6761
6806
|
__classPrivateFieldGet(this, _MixstatusProcessor_markPlayerStopped, "f").call(this, state);
|
|
@@ -7046,31 +7091,40 @@ class ProlinkNetwork {
|
|
|
7046
7091
|
announcer = new virtualcdj_1.Announcer(vcdj, __classPrivateFieldGet(this, _ProlinkNetwork_announceSocket, "f"), this.deviceManager, __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").iface, (_d = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").fullStartup) !== null && _d !== void 0 ? _d : false, (_e = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").announceToStagehand) !== null && _e !== void 0 ? _e : false, __classPrivateFieldGet(this, _ProlinkNetwork_logger, "f"));
|
|
7047
7092
|
}
|
|
7048
7093
|
announcer.start();
|
|
7094
|
+
// In Stagehand mode, unicast keep-alives to discovered players and the
|
|
7095
|
+
// mixer so they push live state to us (mixer 0x39/0x58, CDJ 0x69/waveforms).
|
|
7096
|
+
// Broadcast presence alone does not bootstrap that stream.
|
|
7097
|
+
let heartbeat = null;
|
|
7098
|
+
if (connectMethod === 'stagehand') {
|
|
7099
|
+
heartbeat = new virtualcdj_1.StagehandHeartbeat(vcdj, __classPrivateFieldGet(this, _ProlinkNetwork_statusSocket, "f"), __classPrivateFieldGet(this, _ProlinkNetwork_deviceManager, "f"), __classPrivateFieldGet(this, _ProlinkNetwork_logger, "f"));
|
|
7100
|
+
heartbeat.start();
|
|
7101
|
+
}
|
|
7049
7102
|
// Create remote and local databases
|
|
7050
7103
|
const remotedb = new remotedb_1.default(__classPrivateFieldGet(this, _ProlinkNetwork_deviceManager, "f"), vcdj);
|
|
7051
7104
|
const localdb = new localdb_1.default(vcdj, __classPrivateFieldGet(this, _ProlinkNetwork_deviceManager, "f"), __classPrivateFieldGet(this, _ProlinkNetwork_statusEmitter, "f"), (_f = __classPrivateFieldGet(this, _ProlinkNetwork_config, "f").databasePreference) !== null && _f !== void 0 ? _f : 'auto');
|
|
7052
7105
|
// Create unified database
|
|
7053
|
-
const database = new db_1.default(localdb, remotedb, __classPrivateFieldGet(this, _ProlinkNetwork_deviceManager, "f"));
|
|
7106
|
+
const database = new db_1.default(localdb, remotedb, __classPrivateFieldGet(this, _ProlinkNetwork_deviceManager, "f"), __classPrivateFieldGet(this, _ProlinkNetwork_logger, "f"));
|
|
7054
7107
|
// Create controller service
|
|
7055
7108
|
const control = new control_1.default(__classPrivateFieldGet(this, _ProlinkNetwork_beatSocket, "f"), vcdj);
|
|
7056
7109
|
__classPrivateFieldSet(this, _ProlinkNetwork_state, types_1.NetworkState.Connected, "f");
|
|
7057
|
-
__classPrivateFieldSet(this, _ProlinkNetwork_connection, { announcer, control, remotedb, localdb, database }, "f");
|
|
7110
|
+
__classPrivateFieldSet(this, _ProlinkNetwork_connection, { announcer, heartbeat, control, remotedb, localdb, database }, "f");
|
|
7058
7111
|
tx.finish();
|
|
7059
7112
|
}
|
|
7060
7113
|
/**
|
|
7061
7114
|
* Disconnect from the network
|
|
7062
7115
|
*/
|
|
7063
7116
|
disconnect() {
|
|
7064
|
-
var _a, _b, _c;
|
|
7117
|
+
var _a, _b, _c, _d, _e;
|
|
7065
7118
|
if (__classPrivateFieldGet(this, _ProlinkNetwork_config, "f") === null) {
|
|
7066
7119
|
throw new Error(connectErrorHelp);
|
|
7067
7120
|
}
|
|
7068
7121
|
// Stop announcing ourself
|
|
7069
7122
|
(_a = __classPrivateFieldGet(this, _ProlinkNetwork_connection, "f")) === null || _a === void 0 ? void 0 : _a.announcer.stop();
|
|
7123
|
+
(_c = (_b = __classPrivateFieldGet(this, _ProlinkNetwork_connection, "f")) === null || _b === void 0 ? void 0 : _b.heartbeat) === null || _c === void 0 ? void 0 : _c.stop();
|
|
7070
7124
|
// Disconnect devices from the remote and local databases
|
|
7071
7125
|
for (const device of this.deviceManager.devices.values()) {
|
|
7072
|
-
(
|
|
7073
|
-
(
|
|
7126
|
+
(_d = this.remotedb) === null || _d === void 0 ? void 0 : _d.disconnectFromDevice(device);
|
|
7127
|
+
(_e = this.localdb) === null || _e === void 0 ? void 0 : _e.disconnectForDevice(device);
|
|
7074
7128
|
}
|
|
7075
7129
|
return this.close;
|
|
7076
7130
|
}
|
|
@@ -10600,15 +10654,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10600
10654
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10601
10655
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10602
10656
|
};
|
|
10603
|
-
var _Connection_socket, _Connection_txId, _Connection_lock, _QueryInterface_conn, _QueryInterface_hostDevice, _QueryInterface_lock, _RemoteDatabase_hostDevice, _RemoteDatabase_deviceManager, _RemoteDatabase_connections, _RemoteDatabase_deviceLocks;
|
|
10657
|
+
var _Connection_socket, _Connection_txId, _Connection_lock, _QueryInterface_conn, _QueryInterface_hostDevice, _QueryInterface_lock, _RemoteDatabase_instances, _RemoteDatabase_hostDevice, _RemoteDatabase_deviceManager, _RemoteDatabase_connections, _RemoteDatabase_deviceLocks, _RemoteDatabase_queryIds, _RemoteDatabase_pickQueryId, _RemoteDatabase_queryIdFor;
|
|
10604
10658
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10605
10659
|
exports.QueryInterface = exports.Connection = exports.Query = exports.MenuTarget = void 0;
|
|
10606
10660
|
exports.getQueryName = getQueryName;
|
|
10607
10661
|
const async_mutex_1 = __webpack_require__(/*! async-mutex */ "async-mutex");
|
|
10608
10662
|
const promise_socket_1 = __importDefault(__webpack_require__(/*! promise-socket */ "promise-socket"));
|
|
10609
10663
|
const net_1 = __webpack_require__(/*! net */ "net");
|
|
10664
|
+
const types_1 = __webpack_require__(/*! src/types */ "./src/types.ts");
|
|
10610
10665
|
const Telemetry = __importStar(__webpack_require__(/*! src/utils/telemetry */ "./src/utils/telemetry.ts"));
|
|
10611
|
-
const
|
|
10666
|
+
const device_id_1 = __webpack_require__(/*! src/virtualcdj/device-id */ "./src/virtualcdj/device-id.ts");
|
|
10667
|
+
const types_2 = __webpack_require__(/*! ./message/types */ "./src/remotedb/message/types.ts");
|
|
10612
10668
|
const constants_1 = __webpack_require__(/*! ./constants */ "./src/remotedb/constants.ts");
|
|
10613
10669
|
const fields_1 = __webpack_require__(/*! ./fields */ "./src/remotedb/fields.ts");
|
|
10614
10670
|
const message_1 = __webpack_require__(/*! ./message */ "./src/remotedb/message/index.ts");
|
|
@@ -10621,7 +10677,7 @@ var MenuTarget;
|
|
|
10621
10677
|
(function (MenuTarget) {
|
|
10622
10678
|
MenuTarget[MenuTarget["Main"] = 1] = "Main";
|
|
10623
10679
|
})(MenuTarget || (exports.MenuTarget = MenuTarget = {}));
|
|
10624
|
-
exports.Query =
|
|
10680
|
+
exports.Query = types_2.Request;
|
|
10625
10681
|
const QueryInverse = Object.fromEntries(Object.entries(exports.Query).map(e => [e[1], e[0]]));
|
|
10626
10682
|
/**
|
|
10627
10683
|
* Returns a string representation of a remote query
|
|
@@ -10667,7 +10723,7 @@ class Connection {
|
|
|
10667
10723
|
var _a;
|
|
10668
10724
|
const tx = span.startChild({
|
|
10669
10725
|
op: 'writeMessage',
|
|
10670
|
-
description: (0,
|
|
10726
|
+
description: (0, types_2.getMessageName)(message.type),
|
|
10671
10727
|
});
|
|
10672
10728
|
message.transactionId = __classPrivateFieldSet(this, _Connection_txId, (_a = __classPrivateFieldGet(this, _Connection_txId, "f"), ++_a), "f");
|
|
10673
10729
|
await __classPrivateFieldGet(this, _Connection_socket, "f").write(message.buffer);
|
|
@@ -10728,7 +10784,8 @@ _QueryInterface_conn = new WeakMap(), _QueryInterface_hostDevice = new WeakMap()
|
|
|
10728
10784
|
* Service that maintains remote database connections with devices on the network.
|
|
10729
10785
|
*/
|
|
10730
10786
|
class RemoteDatabase {
|
|
10731
|
-
constructor(deviceManager, hostDevice) {
|
|
10787
|
+
constructor(deviceManager, hostDevice, { pickQueryId = true } = {}) {
|
|
10788
|
+
_RemoteDatabase_instances.add(this);
|
|
10732
10789
|
_RemoteDatabase_hostDevice.set(this, void 0);
|
|
10733
10790
|
_RemoteDatabase_deviceManager.set(this, void 0);
|
|
10734
10791
|
/**
|
|
@@ -10739,6 +10796,17 @@ class RemoteDatabase {
|
|
|
10739
10796
|
* Locks for each device when locating the connection
|
|
10740
10797
|
*/
|
|
10741
10798
|
_RemoteDatabase_deviceLocks.set(this, new Map());
|
|
10799
|
+
/**
|
|
10800
|
+
* The device ID each connection introduced itself with. Queries on that
|
|
10801
|
+
* connection must carry the same ID.
|
|
10802
|
+
*/
|
|
10803
|
+
_RemoteDatabase_queryIds.set(this, new Map());
|
|
10804
|
+
/**
|
|
10805
|
+
* Whether to substitute an in-range query ID when the host device sits
|
|
10806
|
+
* outside 1-6. Disabled only by protocol probes that need to observe how a
|
|
10807
|
+
* device treats the raw announced ID (see examples/remotedb-id-probe.ts).
|
|
10808
|
+
*/
|
|
10809
|
+
_RemoteDatabase_pickQueryId.set(this, void 0);
|
|
10742
10810
|
/**
|
|
10743
10811
|
* Open a connection to the specified device for querying
|
|
10744
10812
|
*/
|
|
@@ -10763,20 +10831,22 @@ class RemoteDatabase {
|
|
|
10763
10831
|
throw new Error(`Expected 0x01 during preamble handshake. Got ${data.value}`);
|
|
10764
10832
|
}
|
|
10765
10833
|
// Send introduction message to set context for querying
|
|
10834
|
+
const queryId = __classPrivateFieldGet(this, _RemoteDatabase_instances, "m", _RemoteDatabase_queryIdFor).call(this, device);
|
|
10766
10835
|
const intro = new message_1.Message({
|
|
10767
10836
|
transactionId: 0xfffffffe,
|
|
10768
|
-
type:
|
|
10769
|
-
args: [new fields_1.UInt32(
|
|
10837
|
+
type: types_2.MessageType.Introduce,
|
|
10838
|
+
args: [new fields_1.UInt32(queryId)],
|
|
10770
10839
|
});
|
|
10771
10840
|
await socket.write(intro.buffer);
|
|
10772
|
-
const resp = await message_1.Message.fromStream(socket,
|
|
10773
|
-
if (resp.type !==
|
|
10841
|
+
const resp = await message_1.Message.fromStream(socket, types_2.MessageType.Success, tx);
|
|
10842
|
+
if (resp.type !== types_2.MessageType.Success) {
|
|
10774
10843
|
throw new Error(`Failed to introduce self to device ID: ${device.id}`);
|
|
10775
10844
|
}
|
|
10776
10845
|
// Clear socket timeout after successful connection — the per-device mutex
|
|
10777
10846
|
// and application-level Promise.race timeouts handle query timeouts
|
|
10778
10847
|
socket.stream.setTimeout(0);
|
|
10779
10848
|
__classPrivateFieldGet(this, _RemoteDatabase_connections, "f").set(device.id, new Connection(device, socket));
|
|
10849
|
+
__classPrivateFieldGet(this, _RemoteDatabase_queryIds, "f").set(device.id, queryId);
|
|
10780
10850
|
tx.finish();
|
|
10781
10851
|
};
|
|
10782
10852
|
/**
|
|
@@ -10790,16 +10860,29 @@ class RemoteDatabase {
|
|
|
10790
10860
|
}
|
|
10791
10861
|
const goodbye = new message_1.Message({
|
|
10792
10862
|
transactionId: 0xfffffffe,
|
|
10793
|
-
type:
|
|
10863
|
+
type: types_2.MessageType.Disconnect,
|
|
10794
10864
|
args: [],
|
|
10795
10865
|
});
|
|
10796
10866
|
await conn.writeMessage(goodbye, tx);
|
|
10797
10867
|
conn.close();
|
|
10798
10868
|
__classPrivateFieldGet(this, _RemoteDatabase_connections, "f").delete(device.id);
|
|
10869
|
+
__classPrivateFieldGet(this, _RemoteDatabase_queryIds, "f").delete(device.id);
|
|
10799
10870
|
tx.finish();
|
|
10800
10871
|
};
|
|
10801
10872
|
__classPrivateFieldSet(this, _RemoteDatabase_deviceManager, deviceManager, "f");
|
|
10802
10873
|
__classPrivateFieldSet(this, _RemoteDatabase_hostDevice, hostDevice, "f");
|
|
10874
|
+
__classPrivateFieldSet(this, _RemoteDatabase_pickQueryId, pickQueryId, "f");
|
|
10875
|
+
}
|
|
10876
|
+
/**
|
|
10877
|
+
* The device this service belongs to — the virtual CDJ announced on the
|
|
10878
|
+
* network. Note that this is NOT necessarily the ID carried inside remotedb
|
|
10879
|
+
* messages: CDJs only answer queries whose in-protocol device-ID byte is
|
|
10880
|
+
* 1-6, so when this device sits outside that range (announced above the
|
|
10881
|
+
* player range to avoid collisions), each connection picks an in-range
|
|
10882
|
+
* query ID via {@link pickRemoteDbQueryId} instead.
|
|
10883
|
+
*/
|
|
10884
|
+
get hostDevice() {
|
|
10885
|
+
return __classPrivateFieldGet(this, _RemoteDatabase_hostDevice, "f");
|
|
10803
10886
|
}
|
|
10804
10887
|
/**
|
|
10805
10888
|
* Gets the remote database query interface for the given device.
|
|
@@ -10810,7 +10893,7 @@ class RemoteDatabase {
|
|
|
10810
10893
|
* @returns null if the device does not export a remote database service
|
|
10811
10894
|
*/
|
|
10812
10895
|
async get(deviceId) {
|
|
10813
|
-
var _a;
|
|
10896
|
+
var _a, _b;
|
|
10814
10897
|
const device = __classPrivateFieldGet(this, _RemoteDatabase_deviceManager, "f").devices.get(deviceId);
|
|
10815
10898
|
if (device === undefined) {
|
|
10816
10899
|
return null;
|
|
@@ -10825,14 +10908,28 @@ class RemoteDatabase {
|
|
|
10825
10908
|
conn = __classPrivateFieldGet(this, _RemoteDatabase_connections, "f").get(deviceId);
|
|
10826
10909
|
// NOTE: We pass the same lock we use for this device to the query
|
|
10827
10910
|
// interface to ensure all query interfaces use the same lock.
|
|
10828
|
-
|
|
10911
|
+
// Queries must carry the same device ID the connection introduced
|
|
10912
|
+
// itself with, which is not always the announced host ID.
|
|
10913
|
+
const queryId = (_b = __classPrivateFieldGet(this, _RemoteDatabase_queryIds, "f").get(device.id)) !== null && _b !== void 0 ? _b : __classPrivateFieldGet(this, _RemoteDatabase_hostDevice, "f").id;
|
|
10914
|
+
return new QueryInterface(conn, lock, { ...__classPrivateFieldGet(this, _RemoteDatabase_hostDevice, "f"), id: queryId });
|
|
10829
10915
|
}
|
|
10830
10916
|
finally {
|
|
10831
10917
|
releaseLock();
|
|
10832
10918
|
}
|
|
10833
10919
|
}
|
|
10834
10920
|
}
|
|
10835
|
-
_RemoteDatabase_hostDevice = new WeakMap(), _RemoteDatabase_deviceManager = new WeakMap(), _RemoteDatabase_connections = new WeakMap(), _RemoteDatabase_deviceLocks = new WeakMap()
|
|
10921
|
+
_RemoteDatabase_hostDevice = new WeakMap(), _RemoteDatabase_deviceManager = new WeakMap(), _RemoteDatabase_connections = new WeakMap(), _RemoteDatabase_deviceLocks = new WeakMap(), _RemoteDatabase_queryIds = new WeakMap(), _RemoteDatabase_pickQueryId = new WeakMap(), _RemoteDatabase_instances = new WeakSet(), _RemoteDatabase_queryIdFor = function _RemoteDatabase_queryIdFor(device) {
|
|
10922
|
+
const hostId = __classPrivateFieldGet(this, _RemoteDatabase_hostDevice, "f").id;
|
|
10923
|
+
// An announced ID already inside the answered range keeps working exactly
|
|
10924
|
+
// as it always has. Rekordbox (which numbers itself far above 6) answers
|
|
10925
|
+
// queries regardless, so only CDJ targets need an in-range stand-in.
|
|
10926
|
+
if (!__classPrivateFieldGet(this, _RemoteDatabase_pickQueryId, "f") ||
|
|
10927
|
+
hostId <= device_id_1.REMOTEDB_MAX_DEVICE_ID ||
|
|
10928
|
+
device.type !== types_1.DeviceType.CDJ) {
|
|
10929
|
+
return hostId;
|
|
10930
|
+
}
|
|
10931
|
+
return (0, device_id_1.pickRemoteDbQueryId)(device.id, __classPrivateFieldGet(this, _RemoteDatabase_deviceManager, "f").devices.values());
|
|
10932
|
+
};
|
|
10836
10933
|
exports["default"] = RemoteDatabase;
|
|
10837
10934
|
|
|
10838
10935
|
|
|
@@ -12126,10 +12223,29 @@ exports["default"] = PositionEmitter;
|
|
|
12126
12223
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12127
12224
|
exports.PlayState = exports.StatusFlag = void 0;
|
|
12128
12225
|
/**
|
|
12129
|
-
* Status flag bitmasks
|
|
12226
|
+
* Status flag bitmasks (byte 0x89 of the CDJ status packet).
|
|
12227
|
+
*
|
|
12228
|
+
* Verified against CDJ-3000 firmware (EP122 FW3.20): the deck assembles this
|
|
12229
|
+
* byte in `sub_d7d3c8` (0xd7d3c8) from the BeatSyncMaster state struct, one
|
|
12230
|
+
* source boolean per bit. The bits not named here:
|
|
12231
|
+
*
|
|
12232
|
+
* - bit 0 (0x01): structurally unused — no code path ever sets it (always 0).
|
|
12233
|
+
* - bit 2 (0x04): a real, dedicated beat-sync boolean (struct +5), but its
|
|
12234
|
+
* name did not survive in the stripped `usecase::sync` async-task code. It
|
|
12235
|
+
* is normally 0, which is why it has never been observed on the wire.
|
|
12236
|
+
* - bit 7 (0x80): a real bit (struct +0xa) that is default-set at init and
|
|
12237
|
+
* whose de-assertion itself triggers a state-change notification — best read
|
|
12238
|
+
* as a "sync-master active / handoff-in-progress" toggle. Also normally 0 in
|
|
12239
|
+
* steady state.
|
|
12130
12240
|
*/
|
|
12131
12241
|
var StatusFlag;
|
|
12132
12242
|
(function (StatusFlag) {
|
|
12243
|
+
/**
|
|
12244
|
+
* Degraded to BPM Sync: the player is still tracking the master's tempo, but
|
|
12245
|
+
* beat alignment was dropped after a pitch-bend / jog nudge. Firmware sources
|
|
12246
|
+
* this from BeatSyncMaster struct +4.
|
|
12247
|
+
*/
|
|
12248
|
+
StatusFlag[StatusFlag["BpmSync"] = 2] = "BpmSync";
|
|
12133
12249
|
StatusFlag[StatusFlag["OnAir"] = 8] = "OnAir";
|
|
12134
12250
|
StatusFlag[StatusFlag["Sync"] = 16] = "Sync";
|
|
12135
12251
|
StatusFlag[StatusFlag["Master"] = 32] = "Master";
|
|
@@ -12202,14 +12318,24 @@ function statusFromPacket(packet) {
|
|
|
12202
12318
|
playState: packet[0x7b],
|
|
12203
12319
|
isOnAir: (packet[0x89] & types_1.CDJStatus.StatusFlag.OnAir) !== 0,
|
|
12204
12320
|
isSync: (packet[0x89] & types_1.CDJStatus.StatusFlag.Sync) !== 0,
|
|
12321
|
+
isBpmSync: (packet[0x89] & types_1.CDJStatus.StatusFlag.BpmSync) !== 0,
|
|
12205
12322
|
isMaster: (packet[0x89] & types_1.CDJStatus.StatusFlag.Master) !== 0,
|
|
12206
12323
|
isEmergencyMode: !!packet[0xba],
|
|
12207
12324
|
trackBPM,
|
|
12208
|
-
|
|
12209
|
-
|
|
12325
|
+
// The CDJ status packet carries four pitch values (firmware CDJ-3000 FW3.20,
|
|
12326
|
+
// sub_d7d610): Pitch1@0x8c and Pitch3@0xc0 are the *effective* pitch (in
|
|
12327
|
+
// effect / on the BPM display, from the fader or a synced master), while
|
|
12328
|
+
// Pitch2@0x98 and Pitch4@0xc4 track the *local fader* position. We expose
|
|
12329
|
+
// Pitch1 as `effectivePitch` and Pitch2 as `sliderPitch`.
|
|
12330
|
+
effectivePitch: calcPitch(packet.slice(0x8d, 0x8d + 3)),
|
|
12331
|
+
sliderPitch: calcPitch(packet.slice(0x99, 0x99 + 3)),
|
|
12210
12332
|
beatInMeasure: packet[0xa6],
|
|
12211
12333
|
beatsUntilCue,
|
|
12212
12334
|
beat,
|
|
12335
|
+
// Player-type / capability byte (dysentery's "nx"). Guarded because the
|
|
12336
|
+
// length check above only guarantees 0xc8; older/short packets may not
|
|
12337
|
+
// reach 0xcc, in which case the field reads as 0 (version-gated to 0 anyway).
|
|
12338
|
+
deviceType: packet.length > 0xcc ? packet[0xcc] : 0,
|
|
12213
12339
|
packetNum: packet.readUInt32BE(0xc8),
|
|
12214
12340
|
};
|
|
12215
12341
|
return status;
|
|
@@ -12954,11 +13080,17 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
12954
13080
|
exports.DEFAULT_MIXER_PLAYER_CEILING = exports.MIXER_PLAYER_CEILING = exports.MAX_DEVICE_ID = exports.REMOTEDB_MAX_DEVICE_ID = void 0;
|
|
12955
13081
|
exports.playerNumberCeiling = playerNumberCeiling;
|
|
12956
13082
|
exports.pickAvailableDeviceId = pickAvailableDeviceId;
|
|
13083
|
+
exports.pickRemoteDbQueryId = pickRemoteDbQueryId;
|
|
12957
13084
|
/**
|
|
12958
13085
|
* The highest device ID a CDJ will answer remotedb queries from.
|
|
12959
13086
|
*
|
|
12960
|
-
*
|
|
12961
|
-
*
|
|
13087
|
+
* This limit applies to the device-ID byte inside the remotedb protocol (the
|
|
13088
|
+
* Introduce message and every query header), NOT to the ID we announce on the
|
|
13089
|
+
* network. Hardware-verified on a CDJ-3000 (2026-08-30, two players + DJM-V5,
|
|
13090
|
+
* announced as VCDJ 7 throughout): queries carrying 1-6 are all answered —
|
|
13091
|
+
* including IDs of absent players and the target's own ID — while 7 and above
|
|
13092
|
+
* are silently ignored (the TCP connection and Introduce succeed, the query
|
|
13093
|
+
* never gets a response). See {@link pickRemoteDbQueryId}.
|
|
12962
13094
|
*/
|
|
12963
13095
|
exports.REMOTEDB_MAX_DEVICE_ID = 6;
|
|
12964
13096
|
/**
|
|
@@ -12966,11 +13098,13 @@ exports.REMOTEDB_MAX_DEVICE_ID = 6;
|
|
|
12966
13098
|
*/
|
|
12967
13099
|
exports.MAX_DEVICE_ID = 32;
|
|
12968
13100
|
/**
|
|
12969
|
-
* `DeviceType.Mixer`, inlined so this module stays free
|
|
12970
|
-
* it is re-exported into consumers' test environments,
|
|
12971
|
-
* whole type module (and its ip-address dependency) is
|
|
13101
|
+
* `DeviceType.Mixer` and `DeviceType.CDJ`, inlined so this module stays free
|
|
13102
|
+
* of runtime imports — it is re-exported into consumers' test environments,
|
|
13103
|
+
* where pulling in the whole type module (and its ip-address dependency) is
|
|
13104
|
+
* dead weight.
|
|
12972
13105
|
*/
|
|
12973
13106
|
const MIXER_DEVICE_TYPE = 0x03;
|
|
13107
|
+
const CDJ_DEVICE_TYPE = 0x01;
|
|
12974
13108
|
/**
|
|
12975
13109
|
* How many player numbers each mixer can hand out.
|
|
12976
13110
|
*
|
|
@@ -13069,24 +13203,233 @@ const ascending = (from, to) => {
|
|
|
13069
13203
|
* Returns null when every ID from 1 to 32 is occupied, in which case there is
|
|
13070
13204
|
* no safe ID and the caller must not join the network.
|
|
13071
13205
|
*/
|
|
13072
|
-
function pickAvailableDeviceId(usedIds, {
|
|
13206
|
+
function pickAvailableDeviceId(usedIds, { preferPlayerRange = false, playerCeiling } = {}) {
|
|
13073
13207
|
var _a;
|
|
13074
13208
|
const used = new Set(usedIds);
|
|
13075
13209
|
const aboveThePlayers = playerCeiling === undefined
|
|
13076
13210
|
? descending(exports.REMOTEDB_MAX_DEVICE_ID, 1)
|
|
13077
13211
|
: ascending(playerCeiling + 1, exports.REMOTEDB_MAX_DEVICE_ID);
|
|
13078
|
-
const
|
|
13212
|
+
const outsidePlayerRange = ascending(exports.REMOTEDB_MAX_DEVICE_ID + 1, exports.MAX_DEVICE_ID);
|
|
13079
13213
|
// Numbers a player on this rig could be assigned. Last resort: better to
|
|
13080
13214
|
// contend for a slot than not to join at all, and the announcer moves us if
|
|
13081
13215
|
// the player that owns it shows up.
|
|
13082
13216
|
const amongThePlayers = playerCeiling === undefined
|
|
13083
13217
|
? []
|
|
13084
13218
|
: descending(Math.min(playerCeiling, exports.REMOTEDB_MAX_DEVICE_ID), 1);
|
|
13085
|
-
const search =
|
|
13086
|
-
? [...aboveThePlayers, ...
|
|
13087
|
-
: [...
|
|
13219
|
+
const search = preferPlayerRange
|
|
13220
|
+
? [...aboveThePlayers, ...outsidePlayerRange, ...amongThePlayers]
|
|
13221
|
+
: [...outsidePlayerRange, ...aboveThePlayers, ...amongThePlayers];
|
|
13088
13222
|
return (_a = search.find(id => !used.has(id))) !== null && _a !== void 0 ? _a : null;
|
|
13089
13223
|
}
|
|
13224
|
+
/**
|
|
13225
|
+
* Choose the device ID to carry inside remotedb messages when querying a CDJ.
|
|
13226
|
+
*
|
|
13227
|
+
* CDJs only answer remotedb queries whose in-protocol device-ID byte is in
|
|
13228
|
+
* 1-6, but that byte is independent of the ID we announce on the network — so
|
|
13229
|
+
* a virtual CDJ announced safely above the player range (say 7 behind a
|
|
13230
|
+
* DJM-V10) can still query metadata by carrying an in-range ID here. Verified
|
|
13231
|
+
* on a CDJ-3000 (2026-08-30): absent IDs and even the target's own ID are
|
|
13232
|
+
* answered; 7+ is silently dropped.
|
|
13233
|
+
*
|
|
13234
|
+
* Older players are documented (dysentery, nexus era) as stricter: the byte
|
|
13235
|
+
* had to be 1-4, belong to a player actually on the network, and not be the
|
|
13236
|
+
* player being queried. The preference order below satisfies those rules
|
|
13237
|
+
* whenever the rig makes it possible, then falls back through choices newer
|
|
13238
|
+
* players accept.
|
|
13239
|
+
*/
|
|
13240
|
+
function pickRemoteDbQueryId(targetId, devices) {
|
|
13241
|
+
const playerIds = new Set();
|
|
13242
|
+
for (const device of devices) {
|
|
13243
|
+
if (device.type === CDJ_DEVICE_TYPE && device.id <= exports.REMOTEDB_MAX_DEVICE_ID) {
|
|
13244
|
+
playerIds.add(device.id);
|
|
13245
|
+
}
|
|
13246
|
+
}
|
|
13247
|
+
// A live player that isn't the target, lowest first — 1-4 satisfies every
|
|
13248
|
+
// documented era of the restriction.
|
|
13249
|
+
const otherPlayers = [...playerIds].filter(id => id !== targetId).sort((a, b) => a - b);
|
|
13250
|
+
if (otherPlayers.length > 0) {
|
|
13251
|
+
return otherPlayers[0];
|
|
13252
|
+
}
|
|
13253
|
+
// No other player on the rig: take the lowest 1-6 ID no player holds.
|
|
13254
|
+
for (let id = 1; id <= exports.REMOTEDB_MAX_DEVICE_ID; id++) {
|
|
13255
|
+
if (id !== targetId && !playerIds.has(id)) {
|
|
13256
|
+
return id;
|
|
13257
|
+
}
|
|
13258
|
+
}
|
|
13259
|
+
// Six players and every one of them is the target? Impossible, but the
|
|
13260
|
+
// target's own ID is answered too, so it is a safe closing fallback.
|
|
13261
|
+
return targetId;
|
|
13262
|
+
}
|
|
13263
|
+
|
|
13264
|
+
|
|
13265
|
+
/***/ },
|
|
13266
|
+
|
|
13267
|
+
/***/ "./src/virtualcdj/heartbeat.ts"
|
|
13268
|
+
/*!*************************************!*\
|
|
13269
|
+
!*** ./src/virtualcdj/heartbeat.ts ***!
|
|
13270
|
+
\*************************************/
|
|
13271
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
13272
|
+
|
|
13273
|
+
"use strict";
|
|
13274
|
+
|
|
13275
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13276
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13277
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13278
|
+
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");
|
|
13279
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
13280
|
+
};
|
|
13281
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
13282
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13283
|
+
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");
|
|
13284
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
13285
|
+
};
|
|
13286
|
+
var _StagehandHeartbeat_instances, _StagehandHeartbeat_statusSocket, _StagehandHeartbeat_vcdj, _StagehandHeartbeat_deviceManager, _StagehandHeartbeat_logger, _StagehandHeartbeat_intervalHandle, _StagehandHeartbeat_sendHeartbeats;
|
|
13287
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
13288
|
+
exports.StagehandHeartbeat = exports.STAGEHAND_HEARTBEAT_INTERVAL = void 0;
|
|
13289
|
+
exports.makeStagehandMixerHeartbeat = makeStagehandMixerHeartbeat;
|
|
13290
|
+
exports.makeStagehandPlayerHeartbeat = makeStagehandPlayerHeartbeat;
|
|
13291
|
+
const constants_1 = __webpack_require__(/*! src/constants */ "./src/constants.ts");
|
|
13292
|
+
const logger_1 = __webpack_require__(/*! src/logger */ "./src/logger.ts");
|
|
13293
|
+
const types_1 = __webpack_require__(/*! src/types */ "./src/types.ts");
|
|
13294
|
+
/**
|
|
13295
|
+
* Cadence of the Stagehand unicast keep-alive, in milliseconds.
|
|
13296
|
+
*
|
|
13297
|
+
* The real iOS Stagehand app heartbeats every discovered player and the mixer
|
|
13298
|
+
* at ~4 Hz (250ms median inter-packet gap in captured traffic). This is the
|
|
13299
|
+
* stream that keeps AlphaTheta hardware unicasting live state (`0x39` mixer
|
|
13300
|
+
* fader/EQ, `0x58` VU on the mixer; `0x69` slim status, waveform families on
|
|
13301
|
+
* the CDJs) to our IP — subnet-broadcast presence alone (the `0x06` keep-alive)
|
|
13302
|
+
* is not enough to bootstrap it.
|
|
13303
|
+
*/
|
|
13304
|
+
exports.STAGEHAND_HEARTBEAT_INTERVAL = 250;
|
|
13305
|
+
/**
|
|
13306
|
+
* Builds a Stagehand name field for a unicast frame.
|
|
13307
|
+
*
|
|
13308
|
+
* Unlike the 20-byte {@link buildName} used by the broadcast announce/claim
|
|
13309
|
+
* frames, unicast frames carry a 19-byte name field (offsets 11..29) with the
|
|
13310
|
+
* device type / model bytes beginning at offset 30. The name is ASCII, NUL
|
|
13311
|
+
* padded.
|
|
13312
|
+
*/
|
|
13313
|
+
function buildUnicastName(name) {
|
|
13314
|
+
const field = new Uint8Array(19);
|
|
13315
|
+
field.set(Buffer.from(name, 'ascii').subarray(0, 19));
|
|
13316
|
+
return field;
|
|
13317
|
+
}
|
|
13318
|
+
/**
|
|
13319
|
+
* Build the Stagehand mixer keep-alive (`0x3a`, 40 bytes).
|
|
13320
|
+
*
|
|
13321
|
+
* Verified byte-for-byte against the real iOS Stagehand app unicasting to a
|
|
13322
|
+
* DJM-A9 at 4 Hz (Phase 4/5 captures §4.14.2). The 10-byte trailer
|
|
13323
|
+
* `21 02 00 fe 00 04 00 1c 00 00` is constant across every observed sample —
|
|
13324
|
+
* byte 33 (`0xfe`) is a VCDJ sentinel, not our runtime device number, so no
|
|
13325
|
+
* per-device bytes vary here.
|
|
13326
|
+
*/
|
|
13327
|
+
function makeStagehandMixerHeartbeat(vcdj) {
|
|
13328
|
+
const parts = [
|
|
13329
|
+
...constants_1.PROLINK_HEADER, // 0-9: magic
|
|
13330
|
+
0x3a, // 10: type 0x3a (mixer keep-alive)
|
|
13331
|
+
...buildUnicastName(vcdj.name), // 11-29: name (19 bytes)
|
|
13332
|
+
0x21,
|
|
13333
|
+
0x02,
|
|
13334
|
+
0x00,
|
|
13335
|
+
0xfe,
|
|
13336
|
+
0x00,
|
|
13337
|
+
0x04,
|
|
13338
|
+
0x00,
|
|
13339
|
+
0x1c,
|
|
13340
|
+
0x00,
|
|
13341
|
+
0x00, // 30-39: constant trailer
|
|
13342
|
+
];
|
|
13343
|
+
return Uint8Array.from(parts);
|
|
13344
|
+
}
|
|
13345
|
+
/**
|
|
13346
|
+
* Build the Stagehand player keep-alive (`0x68`, 36 bytes).
|
|
13347
|
+
*
|
|
13348
|
+
* Verified byte-for-byte against the real iOS Stagehand app unicasting to a
|
|
13349
|
+
* CDJ-3000 at ~2-4 Hz. Body (offsets 30-35) is `03 01 00 3a 00 00`: `0x03`
|
|
13350
|
+
* persona/channel, `0x01` device subkind, `0x00` flag, `0x3a` Stagehand
|
|
13351
|
+
* model-code stamp, two reserved bytes. Constant across every observed sample.
|
|
13352
|
+
*/
|
|
13353
|
+
function makeStagehandPlayerHeartbeat(vcdj) {
|
|
13354
|
+
const parts = [
|
|
13355
|
+
...constants_1.PROLINK_HEADER, // 0-9: magic
|
|
13356
|
+
0x68, // 10: type 0x68 (player keep-alive)
|
|
13357
|
+
...buildUnicastName(vcdj.name), // 11-29: name (19 bytes)
|
|
13358
|
+
0x03,
|
|
13359
|
+
0x01,
|
|
13360
|
+
0x00,
|
|
13361
|
+
0x3a,
|
|
13362
|
+
0x00,
|
|
13363
|
+
0x00, // 30-35: constant body
|
|
13364
|
+
];
|
|
13365
|
+
return Uint8Array.from(parts);
|
|
13366
|
+
}
|
|
13367
|
+
/**
|
|
13368
|
+
* Unicasts Stagehand keep-alive frames to every discovered player and mixer so
|
|
13369
|
+
* that AlphaTheta hardware begins (and keeps) pushing live state to our IP.
|
|
13370
|
+
*
|
|
13371
|
+
* The {@link StagehandAnnouncer} makes us *visible* on the network via subnet
|
|
13372
|
+
* broadcast; this heartbeat is what makes hardware actually *talk back*. It
|
|
13373
|
+
* targets the mixer with `0x3a` and each CDJ with `0x68`, mirroring the real
|
|
13374
|
+
* iOS Stagehand app. Frames are sent from the status socket (port 50002) to
|
|
13375
|
+
* each device's port 50002, which is where their unicast state replies land and
|
|
13376
|
+
* where {@link StatusEmitter} listens for them.
|
|
13377
|
+
*/
|
|
13378
|
+
class StagehandHeartbeat {
|
|
13379
|
+
constructor(vcdj, statusSocket, deviceManager, logger = logger_1.noopLogger) {
|
|
13380
|
+
_StagehandHeartbeat_instances.add(this);
|
|
13381
|
+
_StagehandHeartbeat_statusSocket.set(this, void 0);
|
|
13382
|
+
_StagehandHeartbeat_vcdj.set(this, void 0);
|
|
13383
|
+
_StagehandHeartbeat_deviceManager.set(this, void 0);
|
|
13384
|
+
_StagehandHeartbeat_logger.set(this, void 0);
|
|
13385
|
+
_StagehandHeartbeat_intervalHandle.set(this, void 0);
|
|
13386
|
+
__classPrivateFieldSet(this, _StagehandHeartbeat_vcdj, vcdj, "f");
|
|
13387
|
+
__classPrivateFieldSet(this, _StagehandHeartbeat_statusSocket, statusSocket, "f");
|
|
13388
|
+
__classPrivateFieldSet(this, _StagehandHeartbeat_deviceManager, deviceManager, "f");
|
|
13389
|
+
__classPrivateFieldSet(this, _StagehandHeartbeat_logger, logger, "f");
|
|
13390
|
+
}
|
|
13391
|
+
start() {
|
|
13392
|
+
if (__classPrivateFieldGet(this, _StagehandHeartbeat_intervalHandle, "f") !== undefined) {
|
|
13393
|
+
return;
|
|
13394
|
+
}
|
|
13395
|
+
__classPrivateFieldGet(this, _StagehandHeartbeat_logger, "f").info('Starting Stagehand heartbeat (unicast keep-alive)');
|
|
13396
|
+
__classPrivateFieldGet(this, _StagehandHeartbeat_instances, "m", _StagehandHeartbeat_sendHeartbeats).call(this);
|
|
13397
|
+
__classPrivateFieldSet(this, _StagehandHeartbeat_intervalHandle, setInterval(() => __classPrivateFieldGet(this, _StagehandHeartbeat_instances, "m", _StagehandHeartbeat_sendHeartbeats).call(this), exports.STAGEHAND_HEARTBEAT_INTERVAL), "f");
|
|
13398
|
+
}
|
|
13399
|
+
stop() {
|
|
13400
|
+
__classPrivateFieldGet(this, _StagehandHeartbeat_logger, "f").info('Stopping Stagehand heartbeat');
|
|
13401
|
+
if (__classPrivateFieldGet(this, _StagehandHeartbeat_intervalHandle, "f") !== undefined) {
|
|
13402
|
+
clearInterval(__classPrivateFieldGet(this, _StagehandHeartbeat_intervalHandle, "f"));
|
|
13403
|
+
__classPrivateFieldSet(this, _StagehandHeartbeat_intervalHandle, undefined, "f");
|
|
13404
|
+
}
|
|
13405
|
+
}
|
|
13406
|
+
}
|
|
13407
|
+
exports.StagehandHeartbeat = StagehandHeartbeat;
|
|
13408
|
+
_StagehandHeartbeat_statusSocket = new WeakMap(), _StagehandHeartbeat_vcdj = new WeakMap(), _StagehandHeartbeat_deviceManager = new WeakMap(), _StagehandHeartbeat_logger = new WeakMap(), _StagehandHeartbeat_intervalHandle = new WeakMap(), _StagehandHeartbeat_instances = new WeakSet(), _StagehandHeartbeat_sendHeartbeats = function _StagehandHeartbeat_sendHeartbeats() {
|
|
13409
|
+
for (const device of __classPrivateFieldGet(this, _StagehandHeartbeat_deviceManager, "f").devices.values()) {
|
|
13410
|
+
// Never heartbeat ourselves.
|
|
13411
|
+
if (device.id === __classPrivateFieldGet(this, _StagehandHeartbeat_vcdj, "f").id) {
|
|
13412
|
+
continue;
|
|
13413
|
+
}
|
|
13414
|
+
let packet = null;
|
|
13415
|
+
switch (device.type) {
|
|
13416
|
+
case types_1.DeviceType.Mixer:
|
|
13417
|
+
packet = makeStagehandMixerHeartbeat(__classPrivateFieldGet(this, _StagehandHeartbeat_vcdj, "f"));
|
|
13418
|
+
break;
|
|
13419
|
+
case types_1.DeviceType.CDJ:
|
|
13420
|
+
packet = makeStagehandPlayerHeartbeat(__classPrivateFieldGet(this, _StagehandHeartbeat_vcdj, "f"));
|
|
13421
|
+
break;
|
|
13422
|
+
default:
|
|
13423
|
+
// Rekordbox / other Stagehand peers are not heartbeat targets.
|
|
13424
|
+
continue;
|
|
13425
|
+
}
|
|
13426
|
+
__classPrivateFieldGet(this, _StagehandHeartbeat_statusSocket, "f").send(packet, constants_1.STATUS_PORT, device.ip.address, err => {
|
|
13427
|
+
if (err) {
|
|
13428
|
+
__classPrivateFieldGet(this, _StagehandHeartbeat_logger, "f").debug(`Stagehand heartbeat to ${device.name} (${device.ip.address}) failed: ${err.message}`);
|
|
13429
|
+
}
|
|
13430
|
+
});
|
|
13431
|
+
}
|
|
13432
|
+
};
|
|
13090
13433
|
|
|
13091
13434
|
|
|
13092
13435
|
/***/ },
|
|
@@ -13515,16 +13858,16 @@ _Announcer_announceSocket = new WeakMap(), _Announcer_deviceManager = new WeakMa
|
|
|
13515
13858
|
}, _Announcer_handleConflict = function _Announcer_handleConflict() {
|
|
13516
13859
|
// Stop announcing under the contested ID
|
|
13517
13860
|
__classPrivateFieldGet(this, _Announcer_instances, "m", _Announcer_clearTimer).call(this);
|
|
13518
|
-
// Stay in whichever range we were already in
|
|
13519
|
-
//
|
|
13520
|
-
//
|
|
13861
|
+
// Stay in whichever range we were already in, so a conflict on player 5
|
|
13862
|
+
// looks for another free player number first rather than jumping the
|
|
13863
|
+
// whole device out of the range the DJ configured it into.
|
|
13521
13864
|
//
|
|
13522
13865
|
// The mixer decides which of those numbers are actually safe: a player can
|
|
13523
13866
|
// only be assigned a number its mixer has a channel for, so anything above
|
|
13524
13867
|
// that is out of reach of the rig that just contested us.
|
|
13525
13868
|
const devices = [...__classPrivateFieldGet(this, _Announcer_deviceManager, "f").devices.values()];
|
|
13526
13869
|
const newId = (0, device_id_1.pickAvailableDeviceId)(devices.map(d => d.id), {
|
|
13527
|
-
|
|
13870
|
+
preferPlayerRange: __classPrivateFieldGet(this, _Announcer_vcdj, "f").id <= device_id_1.REMOTEDB_MAX_DEVICE_ID,
|
|
13528
13871
|
playerCeiling: (0, device_id_1.playerNumberCeiling)(devices),
|
|
13529
13872
|
});
|
|
13530
13873
|
if (newId === null) {
|
|
@@ -13627,6 +13970,7 @@ _Announcer_announceSocket = new WeakMap(), _Announcer_deviceManager = new WeakMa
|
|
|
13627
13970
|
__classPrivateFieldSet(this, _Announcer_intervalHandle, setInterval(sendKeepAlive, constants_1.ANNOUNCE_INTERVAL), "f");
|
|
13628
13971
|
};
|
|
13629
13972
|
__exportStar(__webpack_require__(/*! ./device-id */ "./src/virtualcdj/device-id.ts"), exports);
|
|
13973
|
+
__exportStar(__webpack_require__(/*! ./heartbeat */ "./src/virtualcdj/heartbeat.ts"), exports);
|
|
13630
13974
|
__exportStar(__webpack_require__(/*! ./stagehand */ "./src/virtualcdj/stagehand.ts"), exports);
|
|
13631
13975
|
|
|
13632
13976
|
|