@virtualdisplay.io/client 3.4.1 → 3.5.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.
@@ -56,6 +56,8 @@ const EVENT_NAMES = {
56
56
  MUTATION_MESSAGE: "mutation:message",
57
57
  // Config flow (Client → Server)
58
58
  CONFIG_MESSAGE: "config:message",
59
+ // Camera flow (Client → Server)
60
+ CAMERA_MESSAGE: "camera:message",
59
61
  // State flow (Server → Client)
60
62
  MESSAGE_RECEIVED: "message:received",
61
63
  STATE_CHANGED: "state:changed",
@@ -6928,7 +6930,8 @@ class MappingValidator {
6928
6930
  const MESSAGE_TYPES = {
6929
6931
  MUTATION: "mutation",
6930
6932
  STATE: "state",
6931
- CONFIG: "config"
6933
+ CONFIG: "config",
6934
+ CAMERA: "camera"
6932
6935
  };
6933
6936
  function createMutationMessage(mutations) {
6934
6937
  if (!Array.isArray(mutations)) {
@@ -7052,6 +7055,61 @@ class AttributeService {
7052
7055
  this.isInitialized = false;
7053
7056
  }
7054
7057
  }
7058
+ class Camera {
7059
+ constructor(eventBus) {
7060
+ this.eventBus = eventBus;
7061
+ }
7062
+ commands = [];
7063
+ /**
7064
+ * Rotate camera horizontally
7065
+ * @param degrees - Absolute rotation in degrees (0 = front view)
7066
+ */
7067
+ rotate(degrees) {
7068
+ this.commands.push({ action: "rotate", value: degrees });
7069
+ return this;
7070
+ }
7071
+ /**
7072
+ * Tilt camera vertically
7073
+ * @param degrees - Absolute tilt in degrees (0 = top view, 90 = horizontal)
7074
+ */
7075
+ tilt(degrees) {
7076
+ this.commands.push({ action: "tilt", value: degrees });
7077
+ return this;
7078
+ }
7079
+ /**
7080
+ * Zoom camera
7081
+ * @param percentage - Zoom percentage (100 = normal, >100 = zoom in, <100 = zoom out)
7082
+ */
7083
+ zoom(percentage) {
7084
+ this.commands.push({ action: "zoom", value: percentage });
7085
+ return this;
7086
+ }
7087
+ /**
7088
+ * Execute accumulated camera commands
7089
+ */
7090
+ set() {
7091
+ if (this.commands.length === 0) {
7092
+ return;
7093
+ }
7094
+ const message = {
7095
+ type: MESSAGE_TYPES.CAMERA,
7096
+ commands: this.commands
7097
+ };
7098
+ this.eventBus.emit(EVENT_NAMES.CAMERA_MESSAGE, { message });
7099
+ this.commands = [];
7100
+ }
7101
+ /**
7102
+ * Reset camera to initial position
7103
+ * This is not chainable and executes immediately
7104
+ */
7105
+ reset() {
7106
+ const message = {
7107
+ type: MESSAGE_TYPES.CAMERA,
7108
+ commands: [{ action: "reset" }]
7109
+ };
7110
+ this.eventBus.emit(EVENT_NAMES.CAMERA_MESSAGE, { message });
7111
+ }
7112
+ }
7055
7113
  class EventBus {
7056
7114
  listeners = /* @__PURE__ */ new Map();
7057
7115
  on(event, listener) {
@@ -7168,7 +7226,8 @@ class MessageHandler {
7168
7226
  setupOutgoingMessages() {
7169
7227
  const outgoingEvents = [
7170
7228
  EVENT_NAMES.MUTATION_MESSAGE,
7171
- EVENT_NAMES.CONFIG_MESSAGE
7229
+ EVENT_NAMES.CONFIG_MESSAGE,
7230
+ EVENT_NAMES.CAMERA_MESSAGE
7172
7231
  ];
7173
7232
  outgoingEvents.forEach((eventName) => {
7174
7233
  this.eventBus.on(eventName, (event) => {
@@ -7452,6 +7511,7 @@ class VirtualdisplayClient {
7452
7511
  stateService;
7453
7512
  messageHandler;
7454
7513
  viewerService;
7514
+ cameraApi;
7455
7515
  options;
7456
7516
  iframe;
7457
7517
  constructor(options) {
@@ -7461,6 +7521,7 @@ class VirtualdisplayClient {
7461
7521
  this.stateService = new StateService(this.eventBus);
7462
7522
  this.messageHandler = new MessageHandler(this.eventBus);
7463
7523
  this.viewerService = new VirtualdisplayViewerService(this.eventBus);
7524
+ this.cameraApi = new Camera(this.eventBus);
7464
7525
  this.initializeLogging();
7465
7526
  this.createAndConnectIframe();
7466
7527
  this.setupInitialConfig();
@@ -7554,6 +7615,12 @@ class VirtualdisplayClient {
7554
7615
  get viewer() {
7555
7616
  return this.viewerService;
7556
7617
  }
7618
+ /**
7619
+ * Get the camera control API
7620
+ */
7621
+ get camera() {
7622
+ return this.cameraApi;
7623
+ }
7557
7624
  destroy() {
7558
7625
  logger.info("Destroying Virtualdisplay client");
7559
7626
  this.attributeService.clear();
@@ -7568,6 +7635,7 @@ class VirtualdisplayClient {
7568
7635
  }
7569
7636
  export {
7570
7637
  AttributeSelector,
7638
+ Camera,
7571
7639
  ERROR_CODES,
7572
7640
  EVENT_NAMES,
7573
7641
  MESSAGE_TYPES,