livedesk 0.1.28 → 0.1.30
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/hub/src/remote-hub.js +26 -3
- package/hub/src/server.js +24 -0
- package/package.json +2 -2
- package/web/dist/assets/index-C6lHXKlO.js +38 -0
- package/web/dist/assets/index-CpW1Oh74.css +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BXufaiJR.js +0 -38
- package/web/dist/assets/index-CEUc35qd.css +0 -1
package/hub/src/remote-hub.js
CHANGED
|
@@ -474,6 +474,10 @@ function normalizeSlotNumber(value) {
|
|
|
474
474
|
return Number.isInteger(number) && number >= 1 && number <= 999 ? number : 0;
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
+
function normalizeMonitorIndex(value) {
|
|
478
|
+
return clampNumber(value, 0, 63, 0);
|
|
479
|
+
}
|
|
480
|
+
|
|
477
481
|
function parseManagerEndpoint(value) {
|
|
478
482
|
const endpoint = safeString(value, 256);
|
|
479
483
|
const match = endpoint.match(/^(\[[^\]]+\]|[^:\s]+):(\d{1,5})$/);
|
|
@@ -1636,6 +1640,8 @@ export function createRemoteHub(options = {}) {
|
|
|
1636
1640
|
contentHash: SYNTHETIC_FRAME_HASH,
|
|
1637
1641
|
captureMs: 0,
|
|
1638
1642
|
sameContentStreak: 0,
|
|
1643
|
+
monitorIndex: normalizeMonitorIndex(options.monitorIndex ?? 0),
|
|
1644
|
+
monitorCount: clampNumber(options.monitorCount, 1, 64, 1),
|
|
1639
1645
|
dataUrl: SYNTHETIC_FRAME_DATA_URL,
|
|
1640
1646
|
payload: SYNTHETIC_FRAME_PAYLOAD,
|
|
1641
1647
|
accessToken: createFrameAccessToken()
|
|
@@ -1676,6 +1682,8 @@ export function createRemoteHub(options = {}) {
|
|
|
1676
1682
|
commandId: options.commandId || device.activeLiveStream.commandId,
|
|
1677
1683
|
width: options.maxWidth || 960,
|
|
1678
1684
|
height: options.maxHeight || 540,
|
|
1685
|
+
monitorIndex: options.monitorIndex ?? device.activeLiveStream.monitorIndex ?? 0,
|
|
1686
|
+
monitorCount: options.monitorCount ?? device.activeLiveStream.monitorCount ?? 1,
|
|
1679
1687
|
fps: options.fps || device.activeLiveStream.fps
|
|
1680
1688
|
});
|
|
1681
1689
|
device.latestLiveFrame = frame;
|
|
@@ -2667,6 +2675,8 @@ export function createRemoteHub(options = {}) {
|
|
|
2667
2675
|
handshake: transfer.handshake,
|
|
2668
2676
|
width: Number.isFinite(Number(message.width)) ? Number(message.width) : Number(device.activeLiveStream.width || 0),
|
|
2669
2677
|
height: Number.isFinite(Number(message.height)) ? Number(message.height) : Number(device.activeLiveStream.height || 0),
|
|
2678
|
+
monitorIndex: Number.isFinite(Number(message.monitorIndex)) ? normalizeMonitorIndex(message.monitorIndex) : Number(device.activeLiveStream.monitorIndex || 0),
|
|
2679
|
+
monitorCount: Number.isFinite(Number(message.monitorCount)) ? clampNumber(message.monitorCount, 1, 64, 1) : Number(device.activeLiveStream.monitorCount || 1),
|
|
2670
2680
|
openedFrameSeq: Number.isFinite(Number(message.frameSeq)) ? Number(message.frameSeq) : Number(device.activeLiveStream.openedFrameSeq || 0)
|
|
2671
2681
|
};
|
|
2672
2682
|
emitRemoteEvent('RemoteLiveStreamOpened', device, {
|
|
@@ -2756,6 +2766,8 @@ export function createRemoteHub(options = {}) {
|
|
|
2756
2766
|
durationUs: Number.isFinite(Number(message.durationUs)) ? Number(message.durationUs) : 0,
|
|
2757
2767
|
hardwareEncoder: safeString(message.hardwareEncoder, 80),
|
|
2758
2768
|
platformProfile: safeString(message.platformProfile, 80),
|
|
2769
|
+
monitorIndex: Number.isFinite(Number(message.monitorIndex)) ? normalizeMonitorIndex(message.monitorIndex) : Number(device.activeLiveStream.monitorIndex || 0),
|
|
2770
|
+
monitorCount: Number.isFinite(Number(message.monitorCount)) ? clampNumber(message.monitorCount, 1, 64, 1) : Number(device.activeLiveStream.monitorCount || 1),
|
|
2759
2771
|
transferProtocol: transfer.transferProtocol,
|
|
2760
2772
|
transferProtocolVersion: transfer.transferProtocolVersion,
|
|
2761
2773
|
handshake: transfer.handshake,
|
|
@@ -2791,6 +2803,8 @@ export function createRemoteHub(options = {}) {
|
|
|
2791
2803
|
device.activeLiveStream.transferProtocol = transfer.transferProtocol;
|
|
2792
2804
|
device.activeLiveStream.transferProtocolVersion = transfer.transferProtocolVersion;
|
|
2793
2805
|
device.activeLiveStream.handshake = transfer.handshake;
|
|
2806
|
+
device.activeLiveStream.monitorIndex = device.latestLiveFrame.monitorIndex;
|
|
2807
|
+
device.activeLiveStream.monitorCount = device.latestLiveFrame.monitorCount;
|
|
2794
2808
|
device.counters.liveFramesReceived += 1;
|
|
2795
2809
|
emitRemoteEvent('RemoteFrameReceived', device, {
|
|
2796
2810
|
streamId,
|
|
@@ -3655,6 +3669,7 @@ export function createRemoteHub(options = {}) {
|
|
|
3655
3669
|
const now = new Date().toISOString();
|
|
3656
3670
|
const streamId = safeString(options.streamId, 128) || `live-${Date.now()}`;
|
|
3657
3671
|
const fps = clampNumber(options.fps, 1, 24, 2);
|
|
3672
|
+
const monitorIndex = normalizeMonitorIndex(options.monitorIndex ?? options.screenIndex ?? options.displayIndex);
|
|
3658
3673
|
const commandId = safeString(options.commandId, 128) || crypto.randomUUID();
|
|
3659
3674
|
const transfer = buildRemoteFrameTransferDescriptor(options.mode || DEFAULT_REMOTE_FRAME_MODE);
|
|
3660
3675
|
device.counters.commandsSent += 1;
|
|
@@ -3675,6 +3690,8 @@ export function createRemoteHub(options = {}) {
|
|
|
3675
3690
|
transferProtocolVersion: transfer.transferProtocolVersion,
|
|
3676
3691
|
handshake: transfer.handshake,
|
|
3677
3692
|
fps,
|
|
3693
|
+
monitorIndex,
|
|
3694
|
+
monitorCount: 1,
|
|
3678
3695
|
startedAt: now,
|
|
3679
3696
|
stoppedAt: '',
|
|
3680
3697
|
stopReason: '',
|
|
@@ -3687,6 +3704,7 @@ export function createRemoteHub(options = {}) {
|
|
|
3687
3704
|
commandId,
|
|
3688
3705
|
maxWidth: options.maxWidth,
|
|
3689
3706
|
maxHeight: options.maxHeight,
|
|
3707
|
+
monitorIndex,
|
|
3690
3708
|
fps
|
|
3691
3709
|
});
|
|
3692
3710
|
emitRemoteEvent('RemoteLiveStreamStarted', device, {
|
|
@@ -3696,7 +3714,7 @@ export function createRemoteHub(options = {}) {
|
|
|
3696
3714
|
mode: transfer.mode,
|
|
3697
3715
|
synthetic: true
|
|
3698
3716
|
});
|
|
3699
|
-
return { ok: true, commandId, streamId, fps, mode: transfer.mode, frameMode: transfer.frameMode, synthetic: true };
|
|
3717
|
+
return { ok: true, commandId, streamId, fps, mode: transfer.mode, frameMode: transfer.frameMode, monitorIndex, synthetic: true };
|
|
3700
3718
|
}
|
|
3701
3719
|
|
|
3702
3720
|
if (!device?.socket || device.socket.destroyed || !device.connected) {
|
|
@@ -3709,6 +3727,7 @@ export function createRemoteHub(options = {}) {
|
|
|
3709
3727
|
const now = new Date().toISOString();
|
|
3710
3728
|
const streamId = safeString(options.streamId, 128) || `live-${Date.now()}`;
|
|
3711
3729
|
const fps = clampNumber(options.fps, 1, 24, 8);
|
|
3730
|
+
const monitorIndex = normalizeMonitorIndex(options.monitorIndex ?? options.screenIndex ?? options.displayIndex);
|
|
3712
3731
|
const commandId = safeString(options.commandId, 128) || crypto.randomUUID();
|
|
3713
3732
|
const transfer = buildRemoteFrameTransferDescriptor(options.mode || DEFAULT_REMOTE_FRAME_MODE);
|
|
3714
3733
|
const result = sendCommand(deviceId, {
|
|
@@ -3729,6 +3748,7 @@ export function createRemoteHub(options = {}) {
|
|
|
3729
3748
|
maxWidth: clampNumber(options.maxWidth, 320, 2560, 640),
|
|
3730
3749
|
maxHeight: clampNumber(options.maxHeight, 180, 1440, 360),
|
|
3731
3750
|
quality: clampNumber(options.quality, 20, 95, 45),
|
|
3751
|
+
monitorIndex,
|
|
3732
3752
|
requestedAt: now
|
|
3733
3753
|
}
|
|
3734
3754
|
});
|
|
@@ -3754,6 +3774,8 @@ export function createRemoteHub(options = {}) {
|
|
|
3754
3774
|
transferProtocolVersion: transfer.transferProtocolVersion,
|
|
3755
3775
|
handshake: transfer.handshake,
|
|
3756
3776
|
fps,
|
|
3777
|
+
monitorIndex,
|
|
3778
|
+
monitorCount: 1,
|
|
3757
3779
|
startedAt: now,
|
|
3758
3780
|
stoppedAt: '',
|
|
3759
3781
|
stopReason: '',
|
|
@@ -3767,10 +3789,11 @@ export function createRemoteHub(options = {}) {
|
|
|
3767
3789
|
commandId,
|
|
3768
3790
|
fps,
|
|
3769
3791
|
mode: transfer.mode,
|
|
3770
|
-
frameMode: transfer.frameMode
|
|
3792
|
+
frameMode: transfer.frameMode,
|
|
3793
|
+
monitorIndex
|
|
3771
3794
|
});
|
|
3772
3795
|
|
|
3773
|
-
return { ok: true, commandId, streamId, fps, mode: transfer.mode, frameMode: transfer.frameMode };
|
|
3796
|
+
return { ok: true, commandId, streamId, fps, mode: transfer.mode, frameMode: transfer.frameMode, monitorIndex };
|
|
3774
3797
|
}
|
|
3775
3798
|
|
|
3776
3799
|
function stopLiveStream(deviceId, options = {}) {
|
package/hub/src/server.js
CHANGED
|
@@ -79,6 +79,24 @@ function clampNumber(value, min, max, fallback) {
|
|
|
79
79
|
return Math.max(min, Math.min(max, Math.round(number)));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
function normalizeMonitorIndex(value, fallback = 0) {
|
|
83
|
+
return clampNumber(value, 0, 63, fallback);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function normalizeMonitorSelections(value) {
|
|
87
|
+
const result = {};
|
|
88
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
for (const [deviceId, monitorIndex] of Object.entries(value)) {
|
|
92
|
+
const id = String(deviceId || '').trim();
|
|
93
|
+
if (id) {
|
|
94
|
+
result[id] = normalizeMonitorIndex(monitorIndex);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
82
100
|
function normalizeDeviceIds(value) {
|
|
83
101
|
const raw = Array.isArray(value)
|
|
84
102
|
? value
|
|
@@ -140,6 +158,8 @@ function normalizeLiveOptions(payload = {}) {
|
|
|
140
158
|
maxWidth: clampNumber(payload.maxWidth, 320, 2560, 640),
|
|
141
159
|
maxHeight: clampNumber(payload.maxHeight, 180, 1440, 360),
|
|
142
160
|
quality: clampNumber(payload.quality, 20, 95, 45),
|
|
161
|
+
monitorIndex: normalizeMonitorIndex(payload.monitorIndex ?? payload.screenIndex ?? payload.displayIndex),
|
|
162
|
+
monitorSelections: normalizeMonitorSelections(payload.monitorSelections),
|
|
143
163
|
mode,
|
|
144
164
|
frameMode: mode
|
|
145
165
|
};
|
|
@@ -180,8 +200,12 @@ function updateFrameSubscription(ws, payload = {}) {
|
|
|
180
200
|
skipped.push({ deviceId, reason: device?.connected ? 'live-unavailable' : 'not-connected' });
|
|
181
201
|
continue;
|
|
182
202
|
}
|
|
203
|
+
const monitorIndex = Object.prototype.hasOwnProperty.call(ws.liveDeskLiveOptions.monitorSelections || {}, deviceId)
|
|
204
|
+
? ws.liveDeskLiveOptions.monitorSelections[deviceId]
|
|
205
|
+
: ws.liveDeskLiveOptions.monitorIndex;
|
|
183
206
|
const result = remoteHub.startLiveStream(deviceId, {
|
|
184
207
|
...ws.liveDeskLiveOptions,
|
|
208
|
+
monitorIndex,
|
|
185
209
|
streamId: `livedesk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`
|
|
186
210
|
});
|
|
187
211
|
if (result?.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livedesk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "LiveDesk Hub and client launcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"node": ">=20"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@livedesk/client": "0.1.
|
|
33
|
+
"@livedesk/client": "0.1.33",
|
|
34
34
|
"cors": "^2.8.5",
|
|
35
35
|
"express": "^4.21.2",
|
|
36
36
|
"ws": "^8.18.3"
|