@virtualdisplay.io/client 3.3.0 → 3.4.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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +87 -24
- package/dist/virtualdisplay.client.cjs.js +3 -3
- package/dist/virtualdisplay.client.cjs.js.map +1 -1
- package/dist/virtualdisplay.client.es.js +124 -5
- package/dist/virtualdisplay.client.es.js.map +1 -1
- package/dist/virtualdisplay.client.umd.js +3 -3
- package/dist/virtualdisplay.client.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -54,6 +54,8 @@ const EVENT_NAMES = {
|
|
|
54
54
|
IFRAME_READY: "iframe:ready",
|
|
55
55
|
// Mutation flow (Client → Server)
|
|
56
56
|
MUTATION_MESSAGE: "mutation:message",
|
|
57
|
+
// Config flow (Client → Server)
|
|
58
|
+
CONFIG_MESSAGE: "config:message",
|
|
57
59
|
// State flow (Server → Client)
|
|
58
60
|
MESSAGE_RECEIVED: "message:received",
|
|
59
61
|
STATE_CHANGED: "state:changed",
|
|
@@ -6926,7 +6928,8 @@ class MappingValidator {
|
|
|
6926
6928
|
}
|
|
6927
6929
|
const MESSAGE_TYPES = {
|
|
6928
6930
|
MUTATION: "mutation",
|
|
6929
|
-
STATE: "state"
|
|
6931
|
+
STATE: "state",
|
|
6932
|
+
CONFIG: "config"
|
|
6930
6933
|
};
|
|
6931
6934
|
function createMutationMessage(mutations) {
|
|
6932
6935
|
if (!Array.isArray(mutations)) {
|
|
@@ -6938,7 +6941,7 @@ function createMutationMessage(mutations) {
|
|
|
6938
6941
|
};
|
|
6939
6942
|
}
|
|
6940
6943
|
function isValidMessage(data) {
|
|
6941
|
-
return isMutationMessage(data) || isStateMessage(data);
|
|
6944
|
+
return isMutationMessage(data) || isStateMessage(data) || isConfigMessage(data);
|
|
6942
6945
|
}
|
|
6943
6946
|
function isMutationMessage(data) {
|
|
6944
6947
|
if (typeof data !== "object" || data === null) {
|
|
@@ -6954,6 +6957,13 @@ function isStateMessage(data) {
|
|
|
6954
6957
|
const obj = data;
|
|
6955
6958
|
return obj.type === MESSAGE_TYPES.STATE && Array.isArray(obj.nodes);
|
|
6956
6959
|
}
|
|
6960
|
+
function isConfigMessage(data) {
|
|
6961
|
+
if (typeof data !== "object" || data === null) {
|
|
6962
|
+
return false;
|
|
6963
|
+
}
|
|
6964
|
+
const obj = data;
|
|
6965
|
+
return obj.type === MESSAGE_TYPES.CONFIG && typeof obj.config === "object" && obj.config !== null;
|
|
6966
|
+
}
|
|
6957
6967
|
class AttributeService {
|
|
6958
6968
|
attributes = /* @__PURE__ */ new Map();
|
|
6959
6969
|
eventBus;
|
|
@@ -7149,8 +7159,14 @@ class MessageHandler {
|
|
|
7149
7159
|
logger.debug("Message handler started listening");
|
|
7150
7160
|
}
|
|
7151
7161
|
setupOutgoingMessages() {
|
|
7152
|
-
|
|
7153
|
-
|
|
7162
|
+
const outgoingEvents = [
|
|
7163
|
+
EVENT_NAMES.MUTATION_MESSAGE,
|
|
7164
|
+
EVENT_NAMES.CONFIG_MESSAGE
|
|
7165
|
+
];
|
|
7166
|
+
outgoingEvents.forEach((eventName) => {
|
|
7167
|
+
this.eventBus.on(eventName, (event) => {
|
|
7168
|
+
this.queueOrSend(event.message);
|
|
7169
|
+
});
|
|
7154
7170
|
});
|
|
7155
7171
|
}
|
|
7156
7172
|
setupReadyListener() {
|
|
@@ -7187,7 +7203,7 @@ class NodeSelector {
|
|
|
7187
7203
|
logger.warn(`Cannot toggle node ${this.nodeId}: node not found`);
|
|
7188
7204
|
return;
|
|
7189
7205
|
}
|
|
7190
|
-
if (node.isVisible
|
|
7206
|
+
if (node.isVisible) {
|
|
7191
7207
|
this.hide();
|
|
7192
7208
|
return;
|
|
7193
7209
|
}
|
|
@@ -7337,11 +7353,100 @@ class StateService {
|
|
|
7337
7353
|
this.hasReceivedInitialSync = false;
|
|
7338
7354
|
}
|
|
7339
7355
|
}
|
|
7356
|
+
class VirtualdisplayViewerService {
|
|
7357
|
+
eventBus;
|
|
7358
|
+
constructor(eventBus) {
|
|
7359
|
+
this.eventBus = eventBus;
|
|
7360
|
+
}
|
|
7361
|
+
/**
|
|
7362
|
+
* Send initial configuration based on client options
|
|
7363
|
+
* Only sends config when values are false (server defaults to true)
|
|
7364
|
+
*/
|
|
7365
|
+
sendInitialConfig(options) {
|
|
7366
|
+
const config = {};
|
|
7367
|
+
if (options.arEnabled === false) {
|
|
7368
|
+
config.arEnabled = false;
|
|
7369
|
+
}
|
|
7370
|
+
if (options.fullscreenEnabled === false) {
|
|
7371
|
+
config.fullscreenEnabled = false;
|
|
7372
|
+
}
|
|
7373
|
+
if (options.loadingIndicatorEnabled === false) {
|
|
7374
|
+
config.loadingIndicatorEnabled = false;
|
|
7375
|
+
}
|
|
7376
|
+
if (Object.keys(config).length > 0) {
|
|
7377
|
+
logger.debug("Sending initial UI configuration", config);
|
|
7378
|
+
this.sendUIConfig(config);
|
|
7379
|
+
}
|
|
7380
|
+
}
|
|
7381
|
+
/**
|
|
7382
|
+
* Update AR button visibility
|
|
7383
|
+
*/
|
|
7384
|
+
setArEnabled(enabled) {
|
|
7385
|
+
logger.debug(`Setting AR button enabled: ${enabled}`);
|
|
7386
|
+
this.sendUIConfig({ arEnabled: enabled });
|
|
7387
|
+
}
|
|
7388
|
+
/**
|
|
7389
|
+
* Update fullscreen button visibility
|
|
7390
|
+
*/
|
|
7391
|
+
setFullscreenEnabled(enabled) {
|
|
7392
|
+
logger.debug(`Setting fullscreen button enabled: ${enabled}`);
|
|
7393
|
+
this.sendUIConfig({ fullscreenEnabled: enabled });
|
|
7394
|
+
}
|
|
7395
|
+
/**
|
|
7396
|
+
* Update loading indicator visibility
|
|
7397
|
+
*/
|
|
7398
|
+
setLoadingIndicatorEnabled(enabled) {
|
|
7399
|
+
logger.debug(`Setting loading indicator enabled: ${enabled}`);
|
|
7400
|
+
this.sendUIConfig({ loadingIndicatorEnabled: enabled });
|
|
7401
|
+
}
|
|
7402
|
+
/**
|
|
7403
|
+
* Update multiple UI settings at once
|
|
7404
|
+
*/
|
|
7405
|
+
updateUIConfig(config) {
|
|
7406
|
+
logger.debug("Updating UI configuration", config);
|
|
7407
|
+
this.sendUIConfig(config);
|
|
7408
|
+
}
|
|
7409
|
+
/**
|
|
7410
|
+
* Hide all UI elements
|
|
7411
|
+
*/
|
|
7412
|
+
hideAllUI() {
|
|
7413
|
+
logger.debug("Hiding all UI elements");
|
|
7414
|
+
this.sendUIConfig({
|
|
7415
|
+
arEnabled: false,
|
|
7416
|
+
fullscreenEnabled: false,
|
|
7417
|
+
loadingIndicatorEnabled: false
|
|
7418
|
+
});
|
|
7419
|
+
}
|
|
7420
|
+
/**
|
|
7421
|
+
* Show all UI elements
|
|
7422
|
+
*/
|
|
7423
|
+
showAllUI() {
|
|
7424
|
+
logger.debug("Showing all UI elements");
|
|
7425
|
+
this.sendUIConfig({
|
|
7426
|
+
arEnabled: true,
|
|
7427
|
+
fullscreenEnabled: true,
|
|
7428
|
+
loadingIndicatorEnabled: true
|
|
7429
|
+
});
|
|
7430
|
+
}
|
|
7431
|
+
/**
|
|
7432
|
+
* Send UI configuration to server
|
|
7433
|
+
*/
|
|
7434
|
+
sendUIConfig(uiConfig) {
|
|
7435
|
+
const config = { ui: uiConfig };
|
|
7436
|
+
const message = {
|
|
7437
|
+
type: MESSAGE_TYPES.CONFIG,
|
|
7438
|
+
config
|
|
7439
|
+
};
|
|
7440
|
+
logger.debug("Emitting CONFIG message", message);
|
|
7441
|
+
this.eventBus.emit(EVENT_NAMES.CONFIG_MESSAGE, { message });
|
|
7442
|
+
}
|
|
7443
|
+
}
|
|
7340
7444
|
class VirtualdisplayClient {
|
|
7341
7445
|
eventBus;
|
|
7342
7446
|
attributeService;
|
|
7343
7447
|
stateService;
|
|
7344
7448
|
messageHandler;
|
|
7449
|
+
viewerService;
|
|
7345
7450
|
options;
|
|
7346
7451
|
iframe;
|
|
7347
7452
|
constructor(options) {
|
|
@@ -7350,8 +7455,10 @@ class VirtualdisplayClient {
|
|
|
7350
7455
|
this.attributeService = new AttributeService(this.eventBus);
|
|
7351
7456
|
this.stateService = new StateService(this.eventBus);
|
|
7352
7457
|
this.messageHandler = new MessageHandler(this.eventBus);
|
|
7458
|
+
this.viewerService = new VirtualdisplayViewerService(this.eventBus);
|
|
7353
7459
|
this.initializeLogging();
|
|
7354
7460
|
this.createAndConnectIframe();
|
|
7461
|
+
this.setupInitialConfig();
|
|
7355
7462
|
}
|
|
7356
7463
|
initializeLogging() {
|
|
7357
7464
|
if (this.options.debug === true) {
|
|
@@ -7370,6 +7477,11 @@ class VirtualdisplayClient {
|
|
|
7370
7477
|
logger.debug("Iframe created, setting up messaging");
|
|
7371
7478
|
this.messageHandler.setIframe(this.iframe);
|
|
7372
7479
|
}
|
|
7480
|
+
setupInitialConfig() {
|
|
7481
|
+
this.eventBus.once(EVENT_NAMES.IFRAME_READY, () => {
|
|
7482
|
+
this.viewerService.sendInitialConfig(this.options);
|
|
7483
|
+
});
|
|
7484
|
+
}
|
|
7373
7485
|
/**
|
|
7374
7486
|
* Load attribute mapping configuration
|
|
7375
7487
|
* @throws {VirtualdisplayError} When mapping configuration is invalid
|
|
@@ -7431,6 +7543,12 @@ class VirtualdisplayClient {
|
|
|
7431
7543
|
}
|
|
7432
7544
|
this.eventBus.once(EVENT_NAMES.INITIAL_STATE_RECEIVED, callback);
|
|
7433
7545
|
}
|
|
7546
|
+
/**
|
|
7547
|
+
* Get the viewer service for UI configuration
|
|
7548
|
+
*/
|
|
7549
|
+
get viewer() {
|
|
7550
|
+
return this.viewerService;
|
|
7551
|
+
}
|
|
7434
7552
|
destroy() {
|
|
7435
7553
|
logger.info("Destroying Virtualdisplay client");
|
|
7436
7554
|
this.attributeService.clear();
|
|
@@ -7456,6 +7574,7 @@ export {
|
|
|
7456
7574
|
NodeSelector,
|
|
7457
7575
|
VirtualdisplayClient,
|
|
7458
7576
|
VirtualdisplayError,
|
|
7577
|
+
VirtualdisplayViewerService,
|
|
7459
7578
|
enableDebugMode,
|
|
7460
7579
|
isDebugMode,
|
|
7461
7580
|
logger,
|