@livedesk/hub 0.1.24 → 0.1.25

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/remote-hub.js +28 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/hub",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "LiveDesk local Hub API and browser frame bridge",
5
5
  "type": "module",
6
6
  "main": "src/server.js",
package/src/remote-hub.js CHANGED
@@ -690,21 +690,39 @@ const SUPPORTED_AGENT_OPERATIONS = new Set([
690
690
  'logs.collect'
691
691
  ]);
692
692
 
693
- function normalizeAgentOperation(value) {
694
- const operation = safeString(value, 80).toLowerCase();
695
- return SUPPORTED_AGENT_OPERATIONS.has(operation) ? operation : '';
696
- }
697
-
698
- function normalizeRemoteInputEvent(value = {}) {
699
- const input = value && typeof value === 'object' ? value : {};
700
- const type = safeString(input.type || input.Type, 48);
693
+ function normalizeAgentOperation(value) {
694
+ const operation = safeString(value, 80).toLowerCase();
695
+ return SUPPORTED_AGENT_OPERATIONS.has(operation) ? operation : '';
696
+ }
697
+
698
+ const REMOTE_INPUT_MONITOR_KEYS = Object.freeze([
699
+ 'monitorIndex',
700
+ 'MonitorIndex',
701
+ 'screenIndex',
702
+ 'ScreenIndex',
703
+ 'displayIndex',
704
+ 'DisplayIndex'
705
+ ]);
706
+
707
+ function readRawRemoteInputMonitorIndex(input) {
708
+ for (const key of REMOTE_INPUT_MONITOR_KEYS) {
709
+ if (Object.prototype.hasOwnProperty.call(input, key)) {
710
+ return input[key];
711
+ }
712
+ }
713
+ return undefined;
714
+ }
715
+
716
+ function normalizeRemoteInputEvent(value = {}) {
717
+ const input = value && typeof value === 'object' ? value : {};
718
+ const type = safeString(input.type || input.Type, 48);
701
719
  const normalizedX = Number(input.normalizedX ?? input.NormalizedX);
702
720
  const normalizedY = Number(input.normalizedY ?? input.NormalizedY);
703
721
  const deltaX = Number(input.deltaX ?? input.DeltaX);
704
722
  const deltaY = Number(input.deltaY ?? input.DeltaY);
705
723
  const keyCode = Number(input.keyCode ?? input.KeyCode);
706
724
  const location = Number(input.location ?? input.Location);
707
- const monitorIndex = Number(input.monitorIndex ?? input.MonitorIndex ?? input.screenIndex ?? input.ScreenIndex ?? input.displayIndex ?? input.DisplayIndex);
725
+ const monitorIndex = parseExactLiveStreamMonitorIndex(readRawRemoteInputMonitorIndex(input));
708
726
  const inputSeq = Number(input.inputSeq ?? input.InputSeq);
709
727
  const issuedAtEpochMs = Number(input.issuedAtEpochMs ?? input.IssuedAtEpochMs);
710
728
  const hubReceivedAtEpochMs = Number(input.hubReceivedAtEpochMs ?? input.HubReceivedAtEpochMs);
@@ -720,7 +738,7 @@ function normalizeRemoteInputEvent(value = {}) {
720
738
  type,
721
739
  // A missing monitor is not equivalent to the primary display. Control
722
740
  // input must prove the exact monitor owned by its capture generation.
723
- monitorIndex: Number.isFinite(monitorIndex) ? normalizeMonitorIndex(monitorIndex) : null,
741
+ monitorIndex,
724
742
  normalizedX: Number.isFinite(normalizedX) ? Math.max(0, Math.min(1, normalizedX)) : undefined,
725
743
  normalizedY: Number.isFinite(normalizedY) ? Math.max(0, Math.min(1, normalizedY)) : undefined,
726
744
  button: safeString(input.button || input.Button, 24),