@virtualdisplay.io/client 3.4.1 → 3.5.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [3.5.1](https://github.com/virtualdisplay-io/client/compare/v3.5.0...v3.5.1) (2025-07-18)
6
+
7
+ ### ♻️ Code Refactoring
8
+
9
+ * remove validation of outgoing message types ([#5](https://github.com/virtualdisplay-io/client/issues/5)) ([5f4f985](https://github.com/virtualdisplay-io/client/commit/5f4f9853d65af676aec3a865864f43461fdb6ca5))
10
+
11
+ ## [3.5.0](https://github.com/virtualdisplay-io/client/compare/v3.4.1...v3.5.0) (2025-07-16)
12
+
13
+ ### ✨ Features
14
+
15
+ * camera control API ([#4](https://github.com/virtualdisplay-io/client/issues/4)) ([1e4c147](https://github.com/virtualdisplay-io/client/commit/1e4c14747cad2a4617c4cc763522b50941adaa7f))
16
+
5
17
  ## [3.4.1](https://github.com/virtualdisplay-io/client/compare/v3.4.0...v3.4.1) (2025-07-10)
6
18
 
7
19
  ### 🐛 Bug Fixes
package/dist/index.d.ts CHANGED
@@ -121,6 +121,56 @@ export declare interface AttributeValueConfig {
121
121
  readonly isSelected?: boolean;
122
122
  }
123
123
 
124
+ /**
125
+ * Camera control API for positioning and zoom
126
+ * Uses chaining pattern for building commands
127
+ */
128
+ export declare class Camera {
129
+ private readonly eventBus;
130
+ private commands;
131
+ constructor(eventBus: EventBus);
132
+ /**
133
+ * Rotate camera horizontally
134
+ * @param degrees - Absolute rotation in degrees (0 = front view)
135
+ */
136
+ rotate(degrees: number): this;
137
+ /**
138
+ * Tilt camera vertically
139
+ * @param degrees - Absolute tilt in degrees (0 = top view, 90 = horizontal)
140
+ */
141
+ tilt(degrees: number): this;
142
+ /**
143
+ * Zoom camera
144
+ * @param percentage - Zoom percentage (100 = normal, >100 = zoom in, <100 = zoom out)
145
+ */
146
+ zoom(percentage: number): this;
147
+ /**
148
+ * Execute accumulated camera commands
149
+ */
150
+ set(): void;
151
+ /**
152
+ * Reset camera to initial position
153
+ * This is not chainable and executes immediately
154
+ */
155
+ reset(): void;
156
+ }
157
+
158
+ /**
159
+ * Camera command
160
+ */
161
+ export declare interface CameraCommand {
162
+ readonly action: 'rotate' | 'tilt' | 'zoom' | 'reset';
163
+ readonly value?: number;
164
+ }
165
+
166
+ /**
167
+ * Camera message sent to server
168
+ */
169
+ export declare interface CameraMessage {
170
+ readonly type: typeof MESSAGE_TYPES.CAMERA;
171
+ readonly commands: CameraCommand[];
172
+ }
173
+
124
174
  /**
125
175
  * Configuration options for VirtualdisplayClient
126
176
  */
@@ -157,6 +207,7 @@ export declare interface DomainEvents extends Record<string, unknown> {
157
207
  [EVENT_NAMES.IFRAME_READY]: VoidEvent;
158
208
  [EVENT_NAMES.MUTATION_MESSAGE]: MessageEvent_2<MutationMessage>;
159
209
  [EVENT_NAMES.CONFIG_MESSAGE]: MessageEvent_2<ConfigMessage>;
210
+ [EVENT_NAMES.CAMERA_MESSAGE]: MessageEvent_2<CameraMessage>;
160
211
  [EVENT_NAMES.MESSAGE_RECEIVED]: MessageEvent_2;
161
212
  [EVENT_NAMES.STATE_CHANGED]: StateChangedEvent;
162
213
  [EVENT_NAMES.INITIAL_STATE_RECEIVED]: VoidEvent;
@@ -174,6 +225,7 @@ export declare const ERROR_CODES: {
174
225
  readonly INVALID_MAPPING: "INVALID_MAPPING";
175
226
  readonly PARENT_NOT_FOUND: "PARENT_NOT_FOUND";
176
227
  readonly INVALID_MUTATIONS: "INVALID_MUTATIONS";
228
+ readonly INVALID_PARAMETER: "INVALID_PARAMETER";
177
229
  };
178
230
 
179
231
  export declare type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];
@@ -185,9 +237,12 @@ export declare const EVENT_NAMES: {
185
237
  readonly IFRAME_READY: "iframe:ready";
186
238
  readonly MUTATION_MESSAGE: "mutation:message";
187
239
  readonly CONFIG_MESSAGE: "config:message";
240
+ readonly CAMERA_MESSAGE: "camera:message";
188
241
  readonly MESSAGE_RECEIVED: "message:received";
189
242
  readonly STATE_CHANGED: "state:changed";
190
243
  readonly INITIAL_STATE_RECEIVED: "state:initial-received";
244
+ readonly SNAPSHOT_MESSAGE: "snapshot:take";
245
+ readonly SNAPSHOT_DEVELOPED: "snapshot:developed";
191
246
  };
192
247
 
193
248
  /**
@@ -306,7 +361,7 @@ export declare class MappingValidator {
306
361
  /**
307
362
  * Union of all possible messages
308
363
  */
309
- export declare type Message = MutationMessage | StateMessage | ConfigMessage;
364
+ export declare type Message = MutationMessage | StateMessage | ConfigMessage | CameraMessage | SnapshotRequestMessage | SnapshotDevelopedMessage;
310
365
 
311
366
  /**
312
367
  * Types of messages exchanged between client and server
@@ -316,6 +371,8 @@ export declare const MESSAGE_TYPES: {
316
371
  readonly MUTATION: "mutation";
317
372
  readonly STATE: "state";
318
373
  readonly CONFIG: "config";
374
+ readonly CAMERA: "camera";
375
+ readonly SNAPSHOT: "snapshot";
319
376
  };
320
377
 
321
378
  /**
@@ -423,6 +480,80 @@ export declare class NodeSelector {
423
480
 
424
481
  declare type NodeType = typeof NODE_TYPES[keyof typeof NODE_TYPES];
425
482
 
483
+ /**
484
+ * Represents a photo being captured
485
+ * Pure domain object that manages callbacks for when the photo is developed
486
+ */
487
+ export declare class Photo {
488
+ private readonly filename;
489
+ private readonly callbacks;
490
+ private developed;
491
+ private photoData;
492
+ constructor(filename: string);
493
+ /**
494
+ * Register a callback for when the photo is developed
495
+ * If the photo is already developed, the callback is called immediately
496
+ *
497
+ * @param callback Function to call with photo data
498
+ * @returns This Photo instance for chaining
499
+ */
500
+ onDeveloped(callback: (photo: PhotoData) => void): this;
501
+ /**
502
+ * Get the filename for this photo
503
+ */
504
+ getFilename(): string;
505
+ /**
506
+ * Mark the photo as developed and notify all callbacks
507
+ * This method is called by the SnapshotMessageHandler when the photo data arrives
508
+ */
509
+ develop(photoData: PhotoData): void;
510
+ }
511
+
512
+ export declare interface PhotoData {
513
+ readonly filename: string;
514
+ readonly data: string;
515
+ }
516
+
517
+ /**
518
+ * API for taking screenshots of the 3D model
519
+ * Following the camera analogy: take() triggers capture, onDeveloped() gets result
520
+ */
521
+ export declare class Snapshot {
522
+ private readonly eventBus;
523
+ private readonly validExtensions;
524
+ private readonly messageHandler;
525
+ constructor(eventBus: EventBus);
526
+ /**
527
+ * Take a snapshot of the current 3D model view
528
+ *
529
+ * @param filename The filename for the snapshot (must include valid extension)
530
+ * @returns Photo object for registering callbacks
531
+ * @throws VirtualdisplayError if filename is invalid
532
+ */
533
+ take(filename: string): Photo;
534
+ /**
535
+ * Validate filename has a valid image extension
536
+ */
537
+ private validateFilename;
538
+ }
539
+
540
+ /**
541
+ * Snapshot developed message received from server
542
+ */
543
+ export declare interface SnapshotDevelopedMessage {
544
+ readonly type: typeof MESSAGE_TYPES.SNAPSHOT;
545
+ readonly filename: string;
546
+ readonly data: string;
547
+ }
548
+
549
+ /**
550
+ * Snapshot request message sent to server
551
+ */
552
+ export declare interface SnapshotRequestMessage {
553
+ readonly type: typeof MESSAGE_TYPES.SNAPSHOT;
554
+ readonly filename: string;
555
+ }
556
+
426
557
  declare interface StateChangedEvent {
427
558
  nodes: ModelNode[];
428
559
  }
@@ -483,6 +614,8 @@ export declare class VirtualdisplayClient {
483
614
  private readonly stateService;
484
615
  private readonly messageHandler;
485
616
  private readonly viewerService;
617
+ private readonly cameraApi;
618
+ private readonly snapshotApi;
486
619
  private readonly options;
487
620
  private iframe;
488
621
  constructor(options: ClientOptions);
@@ -520,6 +653,14 @@ export declare class VirtualdisplayClient {
520
653
  * Get the viewer service for UI configuration
521
654
  */
522
655
  get viewer(): VirtualdisplayViewerService;
656
+ /**
657
+ * Get the camera control API
658
+ */
659
+ get camera(): Camera;
660
+ /**
661
+ * Get the snapshot API for taking screenshots
662
+ */
663
+ get snapshot(): Snapshot;
523
664
  destroy(): void;
524
665
  }
525
666