@virtualdisplay.io/client 3.5.1 → 3.6.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.
@@ -7576,50 +7576,88 @@ class VirtualdisplayViewerService {
7576
7576
  }
7577
7577
  /**
7578
7578
  * Send initial configuration based on client options
7579
- * Only sends config when values are false (server defaults to true)
7579
+ * Supports both individual properties and ui object
7580
7580
  */
7581
7581
  sendInitialConfig(options) {
7582
- const config = {};
7583
- if (options.arEnabled === false) {
7584
- config.arEnabled = false;
7582
+ const uiConfig = this.buildUIConfig(options);
7583
+ const viewerConfig = this.buildViewerConfig(uiConfig, options.camera);
7584
+ if (viewerConfig !== void 0) {
7585
+ this.sendConfig(viewerConfig);
7585
7586
  }
7586
- if (options.fullscreenEnabled === false) {
7587
- config.fullscreenEnabled = false;
7588
- }
7589
- if (options.loadingIndicatorEnabled === false) {
7590
- config.loadingIndicatorEnabled = false;
7587
+ }
7588
+ /**
7589
+ * Build UI configuration from client options
7590
+ *
7591
+ * Supports both legacy properties (options.arEnabled) and the newer ui object
7592
+ * for backward compatibility. Legacy properties take precedence when both exist.
7593
+ */
7594
+ buildUIConfig(options) {
7595
+ const uiValues = this.extractUIValues(options);
7596
+ const hasUIConfig = Object.values(uiValues).some((value) => value !== void 0);
7597
+ if (!hasUIConfig) {
7598
+ return void 0;
7591
7599
  }
7592
- if (Object.keys(config).length > 0) {
7593
- this.sendUIConfig(config);
7600
+ return {
7601
+ ...uiValues.arEnabled !== void 0 && { arEnabled: uiValues.arEnabled },
7602
+ ...uiValues.fullscreenEnabled !== void 0 && {
7603
+ fullscreenEnabled: uiValues.fullscreenEnabled
7604
+ },
7605
+ ...uiValues.loadingIndicatorEnabled !== void 0 && {
7606
+ loadingIndicatorEnabled: uiValues.loadingIndicatorEnabled
7607
+ }
7608
+ };
7609
+ }
7610
+ /**
7611
+ * Extract UI values from options, with legacy properties taking precedence
7612
+ */
7613
+ extractUIValues(options) {
7614
+ return {
7615
+ arEnabled: options.arEnabled ?? options.ui?.arEnabled,
7616
+ fullscreenEnabled: options.fullscreenEnabled ?? options.ui?.fullscreenEnabled,
7617
+ loadingIndicatorEnabled: options.loadingIndicatorEnabled ?? options.ui?.loadingIndicatorEnabled
7618
+ };
7619
+ }
7620
+ /**
7621
+ * Build viewer configuration from UI config and camera config
7622
+ */
7623
+ buildViewerConfig(uiConfig, cameraConfig) {
7624
+ if (uiConfig === void 0 && cameraConfig === void 0) {
7625
+ return void 0;
7594
7626
  }
7627
+ return {
7628
+ ...uiConfig !== void 0 && { ui: uiConfig },
7629
+ ...cameraConfig !== void 0 && { camera: cameraConfig }
7630
+ };
7595
7631
  }
7596
7632
  /**
7597
7633
  * Update AR button visibility
7598
7634
  */
7599
7635
  setArEnabled(enabled) {
7600
7636
  logger.debug(`Setting AR button enabled: ${enabled}`);
7601
- this.sendUIConfig({ arEnabled: enabled });
7637
+ this.updateUIConfig({ arEnabled: enabled });
7602
7638
  }
7603
7639
  /**
7604
7640
  * Update fullscreen button visibility
7605
7641
  */
7606
7642
  setFullscreenEnabled(enabled) {
7607
7643
  logger.debug(`Setting fullscreen button enabled: ${enabled}`);
7608
- this.sendUIConfig({ fullscreenEnabled: enabled });
7644
+ this.updateUIConfig({ fullscreenEnabled: enabled });
7609
7645
  }
7610
7646
  /**
7611
7647
  * Update loading indicator visibility
7612
7648
  */
7613
7649
  setLoadingIndicatorEnabled(enabled) {
7614
7650
  logger.debug(`Setting loading indicator enabled: ${enabled}`);
7615
- this.sendUIConfig({ loadingIndicatorEnabled: enabled });
7651
+ this.updateUIConfig({ loadingIndicatorEnabled: enabled });
7616
7652
  }
7617
7653
  /**
7618
7654
  * Update multiple UI settings at once
7619
7655
  */
7620
7656
  updateUIConfig(config) {
7621
7657
  logger.debug("Updating UI configuration", config);
7622
- this.sendUIConfig(config);
7658
+ if (Object.keys(config).length > 0) {
7659
+ this.sendConfig({ ui: config });
7660
+ }
7623
7661
  }
7624
7662
  /**
7625
7663
  * Hide all UI elements
@@ -7647,11 +7685,17 @@ class VirtualdisplayViewerService {
7647
7685
  * Send UI configuration to server
7648
7686
  */
7649
7687
  sendUIConfig(uiConfig) {
7650
- const config = { ui: uiConfig };
7688
+ this.sendConfig({ ui: uiConfig });
7689
+ }
7690
+ /**
7691
+ * Send full viewer configuration to server
7692
+ */
7693
+ sendConfig(config) {
7651
7694
  const message = {
7652
7695
  type: MESSAGE_TYPES.CONFIG,
7653
7696
  config
7654
7697
  };
7698
+ logger.debug("Sending config", message);
7655
7699
  this.eventBus.emit(EVENT_NAMES.CONFIG_MESSAGE, { message });
7656
7700
  }
7657
7701
  }