@virtualdisplay.io/client 4.0.0-alpha.10 → 4.0.0-alpha.11
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/src/ui/action-bar.d.ts +1 -1
- package/dist/src/ui/action-bar.d.ts.map +1 -1
- package/dist/src/ui/standard-interface.d.ts +0 -1
- package/dist/src/ui/standard-interface.d.ts.map +1 -1
- package/dist/src/ui/styles.d.ts.map +1 -1
- package/dist/virtualdisplay.client.cjs.js +1 -9
- package/dist/virtualdisplay.client.es.js +7 -20
- package/dist/virtualdisplay.client.umd.js +1 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.0-alpha.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
Hide the fullscreen button on iPhone Safari, where the browser has no Fullscreen API for non-video elements. The button continues to work on desktop, iPad, and Android Chrome.
|
|
8
|
+
|
|
3
9
|
## 4.0.0-alpha.10
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -10,7 +10,7 @@ export declare class ActionBar {
|
|
|
10
10
|
private fullscreenBtn;
|
|
11
11
|
private readonly onFullscreenChange;
|
|
12
12
|
constructor(options: ActionBarOptions);
|
|
13
|
-
setFullscreenIcon
|
|
13
|
+
private setFullscreenIcon;
|
|
14
14
|
private syncButton;
|
|
15
15
|
applySettings(settings: ViewerSettings): void;
|
|
16
16
|
destroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-bar.d.ts","sourceRoot":"","sources":["../../../src/ui/action-bar.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,qBAAa,SAAS;IAMR,OAAO,CAAC,QAAQ,CAAC,OAAO;IALpC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;gBAEnB,OAAO,EAAE,gBAAgB;IAWtD,
|
|
1
|
+
{"version":3,"file":"action-bar.d.ts","sourceRoot":"","sources":["../../../src/ui/action-bar.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,qBAAa,SAAS;IAMR,OAAO,CAAC,QAAQ,CAAC,OAAO;IALpC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;gBAEnB,OAAO,EAAE,gBAAgB;IAWtD,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,UAAU;IAalB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAgB7C,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -26,7 +26,6 @@ export declare class StandardInterface {
|
|
|
26
26
|
constructor(options: StandardInterfaceOptions);
|
|
27
27
|
attach(container: HTMLElement): void;
|
|
28
28
|
onReady(): void;
|
|
29
|
-
private pseudoFullscreen;
|
|
30
29
|
private mountToolbar;
|
|
31
30
|
private toggleFullscreen;
|
|
32
31
|
updateProgress(progress: number, phase: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-interface.d.ts","sourceRoot":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C,MAAM,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI;IAYpC,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,gBAAgB;IASxB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIrD,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIhC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAanD,uBAAuB,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,GAAG,IAAI;IAqCzF,IAAI,cAAc,IAAI,cAAc,CAA0B;IAE9D,OAAO,IAAI,IAAI;IAWf,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,qBAAqB;CAQ9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/ui/styles.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/ui/styles.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM,QAsFlB,CAAC;AAEF,wBAAgB,YAAY,IAAI,IAAI,CAOnC"}
|
|
@@ -220,14 +220,6 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
220
220
|
background: oklch(100% 0 0);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
/* Pseudo-fullscreen fallback for iPhone Safari, which lacks the Fullscreen API on non-video elements */
|
|
224
|
-
.vd-container.vd-pseudo-fullscreen {
|
|
225
|
-
position: fixed;
|
|
226
|
-
inset: 0;
|
|
227
|
-
z-index: 2147483647;
|
|
228
|
-
background: oklch(100% 0 0);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
223
|
/* Layout slots — four corners */
|
|
232
224
|
.vd-slot-top-right {
|
|
233
225
|
${$}
|
|
@@ -308,4 +300,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
308
300
|
font-family: ${Dn};
|
|
309
301
|
}
|
|
310
302
|
|
|
311
|
-
`;function kn(){if(dn(),document.getElementById(`vd-styles`)!==null)return;let e=document.createElement(`style`);e.id=`vd-styles`,e.textContent=On,document.head.appendChild(e)}function An(e,t){let n=document.createElement(`a`);n.href=`data:image/png;base64,${e}`,n.download=t,n.click()}var jn=class{options;settings={};container=null;loading=null;slots={topRight:null,bottomLeft:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;constructor(e){this.options=e}attach(e){kn(),this.container=e,this.loading=new bn(e),this.slots.topRight=this.createSlot(e,`vd-slot-top-right`),this.slots.bottomLeft=this.createSlot(e,`vd-slot-bottom-left`),this.slots.bottomRight=this.createSlot(e,`vd-slot-bottom-right`)}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display=`flex`),this.attributes!==null&&(this.attributes.style.display=`flex`)}
|
|
303
|
+
`;function kn(){if(dn(),document.getElementById(`vd-styles`)!==null)return;let e=document.createElement(`style`);e.id=`vd-styles`,e.textContent=On,document.head.appendChild(e)}function An(e,t){let n=document.createElement(`a`);n.href=`data:image/png;base64,${e}`,n.download=t,n.click()}var jn=class{options;settings={};container=null;loading=null;slots={topRight:null,bottomLeft:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;constructor(e){this.options=e}attach(e){kn(),this.container=e,this.loading=new bn(e),this.slots.topRight=this.createSlot(e,`vd-slot-top-right`),this.slots.bottomLeft=this.createSlot(e,`vd-slot-bottom-left`),this.slots.bottomRight=this.createSlot(e,`vd-slot-bottom-right`)}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display=`flex`),this.attributes!==null&&(this.attributes.style.display=`flex`)}mountToolbar(){if(this.actionBar!==null||this.slots.bottomRight===null||this.container===null)return;let e=typeof this.container.requestFullscreen==`function`;this.actionBar=new xn({onAr:this.options.onAr,onFullscreen:e?()=>{this.toggleFullscreen()}:void 0}),this.actionBar.applySettings(this.settings),this.slots.bottomRight.appendChild(this.actionBar.element),this.syncScreenshotButton(),this.placeScreenshotButton()}toggleFullscreen(){this.container!==null&&(document.fullscreenElement===null?this.container.requestFullscreen():document.exitFullscreen())}updateProgress(e,t){this.loading?.updateProgress(e,t)}showError(e){this.loading?.showError(e)}applyViewerSettings(e){this.settings=e,e.language!==void 0&&O(e.language,{reload:!1}),this.syncScreenshotButton(),this.actionBar?.applySettings(e),this.cameraControls!==null&&(this.cameraControls.element.style.display=e.cameraControls===!0?`flex`:`none`),this.placeScreenshotButton()}renderAttributeControls(e,t){if(!(this.container===null||this.slots.topRight===null)&&(this.cameraControls?.element.remove(),this.cameraControls=null,this.attributes?.remove(),this.attributes=null,this.settings.cameraControls===!0&&(this.cameraControls=new Sn(this.options.cameraApi,this.options.cameraPositionApi),this.cameraControls.element.style.display=`none`,this.slots.topRight.appendChild(this.cameraControls.element)),this.placeScreenshotButton(),!(t.length===0||this.settings.attributeControls===!1))){this.attributes=document.createElement(`div`),this.attributes.className=`vd-attributes`,this.attributes.style.display=`none`;for(let n of t)this.attributes.appendChild(En(n,e,this.options.eventBus,this.options.onSelect,this.options.onSubscribe));this.slots.bottomLeft.appendChild(this.attributes)}}get viewerSettings(){return this.settings}destroy(){this.loading?.destroy(),this.screenshotBtn?.element.remove(),this.actionBar?.destroy(),this.actionBar?.element.remove(),this.cameraControls?.element.remove(),this.attributes?.remove();for(let e of Object.values(this.slots))e?.remove();this.container=null}createSlot(e,t){let n=document.createElement(`div`);return n.className=t,e.appendChild(n),n}syncScreenshotButton(){let e=this.settings.screenshot===!0;e&&this.screenshotBtn===null&&(this.screenshotBtn=new R({variant:`outline`,size:`icon`,label:gt(),icon:L.screenshot(),onClick:()=>{this.options.snapshotApi.take(`snapshot.png`).onDeveloped(({data:e,filename:t})=>{An(e,t)})}})),!e&&this.screenshotBtn!==null&&(this.screenshotBtn.element.remove(),this.screenshotBtn=null)}placeScreenshotButton(){this.screenshotBtn===null||this.slots.topRight===null||(this.cameraControls===null?this.slots.topRight.appendChild(this.screenshotBtn.element):this.cameraControls.element.appendChild(this.screenshotBtn.element))}},Mn=class{attributes;readyStateTracker;messenger;cameraApi;cameraPositionApi;snapshotApi;annotationsApi;eventBus;ui;qrModal;options;iframe;container;readyCallbacks=[];mutationFailedCallbacks=[];constructor(e){this.options=e,this.initializeLogging(),this.messenger=new ge(()=>this.iframe?.contentWindow??null);let t=e=>{this.messenger.send(e)};this.attributes=new ye(t,(e,t)=>{for(let n of this.mutationFailedCallbacks)n({attribute:e,value:t})}),this.snapshotApi=new Ce(t),this.annotationsApi=new S(t),this.cameraApi=new be(t),this.cameraPositionApi=new xe,this.eventBus=new we,this.qrModal=new cn,this.readyStateTracker=new ie(()=>{let e=this.readyCallbacks;this.readyCallbacks=[];for(let t of e)t(this);this.ui.onReady()}),this.ui=new jn({snapshotApi:this.snapshotApi,cameraApi:this.cameraApi,cameraPositionApi:this.cameraPositionApi,eventBus:this.eventBus,onSelect:(e,t)=>this.attributes.select(e,t),onSubscribe:(e,t)=>this.attributes.onChange(e,t),onAr:()=>{this.activateAr()}}),this.registerHandlers(),this.messenger.start(),this.createAndConnectIframe()}registerHandlers(){this.messenger.on(b.HANDSHAKE,e=>{se(e)&&(y.info(`Server handshake received, flushing publisher queue`),this.messenger.markReady())}),this.messenger.on(b.MUTATION,e=>{ce(e)&&this.attributes.handleMutationResult(e)}),this.messenger.on(b.SNAPSHOT,e=>{le(e)&&this.snapshotApi.handleSnapshotResult(e)}),this.messenger.on(b.CAMERA,e=>{ue(e)&&this.cameraPositionApi.handlePositionUpdate(e)}),this.messenger.on(b.LOADING_INDICATOR,e=>{fe(e)&&(e.error===void 0?this.ui.updateProgress(e.progress,e.phase):this.ui.showError(e.error))}),this.messenger.on(b.CONFIG,e=>{pe(e)&&this.handleConfig(e)}),this.messenger.on(b.ANNOTATION_PLACED,e=>{me(e)&&this.annotationsApi.handlePlaced(e.position)}),this.messenger.on(b.MAPPING,e=>{de(e)&&(this.attributes.handleMappingReceived(e),this.ui.renderAttributeControls(this.attributes,e.attributes),this.readyStateTracker.handleMappingReceived())})}handleConfig(e){let t=e.viewerSettings,n=this.options.viewerSettings;if(t!==void 0||n!==void 0){let e=n===void 0?t:{...t??{},...n};if(n!==void 0&&t!==void 0){let e=Object.entries(n).filter(([e,n])=>t[e]!==n).map(([e,n])=>`${e} (metadata: ${t[e]??`undefined`}, override: ${n})`);e.length>0&&y.warn(`Viewer settings override active: ${e.join(`, `)}`)}this.ui.applyViewerSettings(e),this.annotationsApi.setEnabled(e.annotations!==!1)}this.cameraPositionApi.applyLimits(e.cameraLimits)}activateAr(){if(h()){this.messenger.send({type:b.AR_ACTIVATE});return}this.qrModal.show(this.iframe?.src??``)}initializeLogging(){this.options.debug===!0&&ne(),y.info(`Initializing Virtualdisplay client`,{model:this.options.model})}createAndConnectIframe(){let e=new r(this.options).create();this.container=e.container,this.iframe=e.iframe,this.eventBus.attach(this.container),this.ui.attach(this.container);try{let e=new URL(this.iframe.src).origin;this.messenger.setTargetOrigin(e)}catch{}}select(e,t){this.attributes.select(e,t)}getValues(e){return this.attributes.getValues(e)}getValue(e,t){return this.attributes.getValue(e,t)}onChange(e,t){this.attributes.onChange(e,t)}getAttribute(e){return this.attributes.getAttribute(e)}get isReady(){return this.readyStateTracker.isReady}onReady(e){if(this.readyStateTracker.isReady){e(this);return}this.readyCallbacks.push(e)}onMutationFailed(e){this.mutationFailedCallbacks.push(e)}on(e,t){this.eventBus.on(e,t)}get annotations(){return this.annotationsApi}get camera(){return this.cameraApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}get viewerSettings(){return this.ui.viewerSettings}destroy(){this.readyStateTracker.clear(),this.readyCallbacks=[],this.messenger.destroy(),this.qrModal.hide(),this.ui.destroy(),this.container?.parentElement!==null&&this.container?.parentElement!==void 0&&this.container.parentElement.removeChild(this.container),this.container=void 0,this.iframe=void 0}};exports.Annotations=S,exports.Attribute=_e,exports.AttributeValue=C,exports.Camera=be,exports.ERROR_CODES=t,exports.Photo=Se,exports.Snapshot=Ce,exports.VirtualdisplayClient=Mn,exports.VirtualdisplayError=n,exports.enableDebugMode=ne,exports.isDebugMode=re,Object.defineProperty(exports,`logger`,{enumerable:!0,get:function(){return y}});
|
|
@@ -1891,14 +1891,6 @@ var Dn = V.fontFamily.sans.join(", "), $ = "\n position: absolute;\n display:
|
|
|
1891
1891
|
background: oklch(100% 0 0);
|
|
1892
1892
|
}
|
|
1893
1893
|
|
|
1894
|
-
/* Pseudo-fullscreen fallback for iPhone Safari, which lacks the Fullscreen API on non-video elements */
|
|
1895
|
-
.vd-container.vd-pseudo-fullscreen {
|
|
1896
|
-
position: fixed;
|
|
1897
|
-
inset: 0;
|
|
1898
|
-
z-index: 2147483647;
|
|
1899
|
-
background: oklch(100% 0 0);
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
1894
|
/* Layout slots — four corners */
|
|
1903
1895
|
.vd-slot-top-right {
|
|
1904
1896
|
${$}
|
|
@@ -2014,23 +2006,18 @@ var jn = class {
|
|
|
2014
2006
|
onReady() {
|
|
2015
2007
|
this.loading?.hide(), this.loading = null, this.mountToolbar(), this.cameraControls !== null && (this.cameraControls.element.style.display = "flex"), this.attributes !== null && (this.attributes.style.display = "flex");
|
|
2016
2008
|
}
|
|
2017
|
-
pseudoFullscreen = !1;
|
|
2018
2009
|
mountToolbar() {
|
|
2019
|
-
this.actionBar !== null || this.slots.bottomRight === null ||
|
|
2010
|
+
if (this.actionBar !== null || this.slots.bottomRight === null || this.container === null) return;
|
|
2011
|
+
let e = typeof this.container.requestFullscreen == "function";
|
|
2012
|
+
this.actionBar = new xn({
|
|
2020
2013
|
onAr: this.options.onAr,
|
|
2021
|
-
onFullscreen: () => {
|
|
2014
|
+
onFullscreen: e ? () => {
|
|
2022
2015
|
this.toggleFullscreen();
|
|
2023
|
-
}
|
|
2024
|
-
}), this.actionBar.applySettings(this.settings), this.slots.bottomRight.appendChild(this.actionBar.element), this.syncScreenshotButton(), this.placeScreenshotButton()
|
|
2016
|
+
} : void 0
|
|
2017
|
+
}), this.actionBar.applySettings(this.settings), this.slots.bottomRight.appendChild(this.actionBar.element), this.syncScreenshotButton(), this.placeScreenshotButton();
|
|
2025
2018
|
}
|
|
2026
2019
|
toggleFullscreen() {
|
|
2027
|
-
|
|
2028
|
-
if (typeof this.container.requestFullscreen == "function") {
|
|
2029
|
-
document.fullscreenElement === null ? this.container.requestFullscreen() : document.exitFullscreen();
|
|
2030
|
-
return;
|
|
2031
|
-
}
|
|
2032
|
-
this.pseudoFullscreen = !this.pseudoFullscreen, this.container.classList.toggle("vd-pseudo-fullscreen", this.pseudoFullscreen), this.actionBar?.setFullscreenIcon(this.pseudoFullscreen);
|
|
2033
|
-
}
|
|
2020
|
+
this.container !== null && (document.fullscreenElement === null ? this.container.requestFullscreen() : document.exitFullscreen());
|
|
2034
2021
|
}
|
|
2035
2022
|
updateProgress(e, t) {
|
|
2036
2023
|
this.loading?.updateProgress(e, t);
|
|
@@ -227,14 +227,6 @@ Minimum version required to store current data is: `+c+`.
|
|
|
227
227
|
background: oklch(100% 0 0);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
/* Pseudo-fullscreen fallback for iPhone Safari, which lacks the Fullscreen API on non-video elements */
|
|
231
|
-
.vd-container.vd-pseudo-fullscreen {
|
|
232
|
-
position: fixed;
|
|
233
|
-
inset: 0;
|
|
234
|
-
z-index: 2147483647;
|
|
235
|
-
background: oklch(100% 0 0);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
230
|
/* Layout slots — four corners */
|
|
239
231
|
.vd-slot-top-right {
|
|
240
232
|
${$}
|
|
@@ -315,4 +307,4 @@ Minimum version required to store current data is: `+c+`.
|
|
|
315
307
|
font-family: ${ur};
|
|
316
308
|
}
|
|
317
309
|
|
|
318
|
-
`;function fr(){if(Yn(),document.getElementById(`vd-styles`)!==null)return;let e=document.createElement(`style`);e.id=`vd-styles`,e.textContent=dr,document.head.appendChild(e)}function pr(e,t){let n=document.createElement(`a`);n.href=`data:image/png;base64,${e}`,n.download=t,n.click()}var mr=class{options;settings={};container=null;loading=null;slots={topRight:null,bottomLeft:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;constructor(e){this.options=e}attach(e){fr(),this.container=e,this.loading=new rr(e),this.slots.topRight=this.createSlot(e,`vd-slot-top-right`),this.slots.bottomLeft=this.createSlot(e,`vd-slot-bottom-left`),this.slots.bottomRight=this.createSlot(e,`vd-slot-bottom-right`)}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display=`flex`),this.attributes!==null&&(this.attributes.style.display=`flex`)}
|
|
310
|
+
`;function fr(){if(Yn(),document.getElementById(`vd-styles`)!==null)return;let e=document.createElement(`style`);e.id=`vd-styles`,e.textContent=dr,document.head.appendChild(e)}function pr(e,t){let n=document.createElement(`a`);n.href=`data:image/png;base64,${e}`,n.download=t,n.click()}var mr=class{options;settings={};container=null;loading=null;slots={topRight:null,bottomLeft:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;constructor(e){this.options=e}attach(e){fr(),this.container=e,this.loading=new rr(e),this.slots.topRight=this.createSlot(e,`vd-slot-top-right`),this.slots.bottomLeft=this.createSlot(e,`vd-slot-bottom-left`),this.slots.bottomRight=this.createSlot(e,`vd-slot-bottom-right`)}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display=`flex`),this.attributes!==null&&(this.attributes.style.display=`flex`)}mountToolbar(){if(this.actionBar!==null||this.slots.bottomRight===null||this.container===null)return;let e=typeof this.container.requestFullscreen==`function`;this.actionBar=new ir({onAr:this.options.onAr,onFullscreen:e?()=>{this.toggleFullscreen()}:void 0}),this.actionBar.applySettings(this.settings),this.slots.bottomRight.appendChild(this.actionBar.element),this.syncScreenshotButton(),this.placeScreenshotButton()}toggleFullscreen(){this.container!==null&&(document.fullscreenElement===null?this.container.requestFullscreen():document.exitFullscreen())}updateProgress(e,t){this.loading?.updateProgress(e,t)}showError(e){this.loading?.showError(e)}applyViewerSettings(e){this.settings=e,e.language!==void 0&&Ve(e.language,{reload:!1}),this.syncScreenshotButton(),this.actionBar?.applySettings(e),this.cameraControls!==null&&(this.cameraControls.element.style.display=e.cameraControls===!0?`flex`:`none`),this.placeScreenshotButton()}renderAttributeControls(e,t){if(!(this.container===null||this.slots.topRight===null)&&(this.cameraControls?.element.remove(),this.cameraControls=null,this.attributes?.remove(),this.attributes=null,this.settings.cameraControls===!0&&(this.cameraControls=new ar(this.options.cameraApi,this.options.cameraPositionApi),this.cameraControls.element.style.display=`none`,this.slots.topRight.appendChild(this.cameraControls.element)),this.placeScreenshotButton(),!(t.length===0||this.settings.attributeControls===!1))){this.attributes=document.createElement(`div`),this.attributes.className=`vd-attributes`,this.attributes.style.display=`none`;for(let n of t)this.attributes.appendChild(lr(n,e,this.options.eventBus,this.options.onSelect,this.options.onSubscribe));this.slots.bottomLeft.appendChild(this.attributes)}}get viewerSettings(){return this.settings}destroy(){this.loading?.destroy(),this.screenshotBtn?.element.remove(),this.actionBar?.destroy(),this.actionBar?.element.remove(),this.cameraControls?.element.remove(),this.attributes?.remove();for(let e of Object.values(this.slots))e?.remove();this.container=null}createSlot(e,t){let n=document.createElement(`div`);return n.className=t,e.appendChild(n),n}syncScreenshotButton(){let e=this.settings.screenshot===!0;e&&this.screenshotBtn===null&&(this.screenshotBtn=new P({variant:`outline`,size:`icon`,label:Et(),icon:N.screenshot(),onClick:()=>{this.options.snapshotApi.take(`snapshot.png`).onDeveloped(({data:e,filename:t})=>{pr(e,t)})}})),!e&&this.screenshotBtn!==null&&(this.screenshotBtn.element.remove(),this.screenshotBtn=null)}placeScreenshotButton(){this.screenshotBtn===null||this.slots.topRight===null||(this.cameraControls===null?this.slots.topRight.appendChild(this.screenshotBtn.element):this.cameraControls.element.appendChild(this.screenshotBtn.element))}},hr=class{attributes;readyStateTracker;messenger;cameraApi;cameraPositionApi;snapshotApi;annotationsApi;eventBus;ui;qrModal;options;iframe;container;readyCallbacks=[];mutationFailedCallbacks=[];constructor(e){this.options=e,this.initializeLogging(),this.messenger=new ye(()=>this.iframe?.contentWindow??null);let t=e=>{this.messenger.send(e)};this.attributes=new we(t,(e,t)=>{for(let n of this.mutationFailedCallbacks)n({attribute:e,value:t})}),this.snapshotApi=new Oe(t),this.annotationsApi=new be(t),this.cameraApi=new Te(t),this.cameraPositionApi=new Ee,this.eventBus=new ke,this.qrModal=new Kn,this.readyStateTracker=new se(()=>{let e=this.readyCallbacks;this.readyCallbacks=[];for(let t of e)t(this);this.ui.onReady()}),this.ui=new mr({snapshotApi:this.snapshotApi,cameraApi:this.cameraApi,cameraPositionApi:this.cameraPositionApi,eventBus:this.eventBus,onSelect:(e,t)=>this.attributes.select(e,t),onSubscribe:(e,t)=>this.attributes.onChange(e,t),onAr:()=>{this.activateAr()}}),this.registerHandlers(),this.messenger.start(),this.createAndConnectIframe()}registerHandlers(){this.messenger.on(E.HANDSHAKE,e=>{ue(e)&&(T.info(`Server handshake received, flushing publisher queue`),this.messenger.markReady())}),this.messenger.on(E.MUTATION,e=>{de(e)&&this.attributes.handleMutationResult(e)}),this.messenger.on(E.SNAPSHOT,e=>{fe(e)&&this.snapshotApi.handleSnapshotResult(e)}),this.messenger.on(E.CAMERA,e=>{pe(e)&&this.cameraPositionApi.handlePositionUpdate(e)}),this.messenger.on(E.LOADING_INDICATOR,e=>{he(e)&&(e.error===void 0?this.ui.updateProgress(e.progress,e.phase):this.ui.showError(e.error))}),this.messenger.on(E.CONFIG,e=>{ge(e)&&this.handleConfig(e)}),this.messenger.on(E.ANNOTATION_PLACED,e=>{_e(e)&&this.annotationsApi.handlePlaced(e.position)}),this.messenger.on(E.MAPPING,e=>{me(e)&&(this.attributes.handleMappingReceived(e),this.ui.renderAttributeControls(this.attributes,e.attributes),this.readyStateTracker.handleMappingReceived())})}handleConfig(e){let t=e.viewerSettings,n=this.options.viewerSettings;if(t!==void 0||n!==void 0){let e=n===void 0?t:{...t??{},...n};if(n!==void 0&&t!==void 0){let e=Object.entries(n).filter(([e,n])=>t[e]!==n).map(([e,n])=>`${e} (metadata: ${t[e]??`undefined`}, override: ${n})`);e.length>0&&T.warn(`Viewer settings override active: ${e.join(`, `)}`)}this.ui.applyViewerSettings(e),this.annotationsApi.setEnabled(e.annotations!==!1)}this.cameraPositionApi.applyLimits(e.cameraLimits)}activateAr(){if(ee()){this.messenger.send({type:E.AR_ACTIVATE});return}this.qrModal.show(this.iframe?.src??``)}initializeLogging(){this.options.debug===!0&&ae(),T.info(`Initializing Virtualdisplay client`,{model:this.options.model})}createAndConnectIframe(){let e=new f(this.options).create();this.container=e.container,this.iframe=e.iframe,this.eventBus.attach(this.container),this.ui.attach(this.container);try{let e=new URL(this.iframe.src).origin;this.messenger.setTargetOrigin(e)}catch{}}select(e,t){this.attributes.select(e,t)}getValues(e){return this.attributes.getValues(e)}getValue(e,t){return this.attributes.getValue(e,t)}onChange(e,t){this.attributes.onChange(e,t)}getAttribute(e){return this.attributes.getAttribute(e)}get isReady(){return this.readyStateTracker.isReady}onReady(e){if(this.readyStateTracker.isReady){e(this);return}this.readyCallbacks.push(e)}onMutationFailed(e){this.mutationFailedCallbacks.push(e)}on(e,t){this.eventBus.on(e,t)}get annotations(){return this.annotationsApi}get camera(){return this.cameraApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}get viewerSettings(){return this.ui.viewerSettings}destroy(){this.readyStateTracker.clear(),this.readyCallbacks=[],this.messenger.destroy(),this.qrModal.hide(),this.ui.destroy(),this.container?.parentElement!==null&&this.container?.parentElement!==void 0&&this.container.parentElement.removeChild(this.container),this.container=void 0,this.iframe=void 0}};e.Annotations=be,e.Attribute=Se,e.AttributeValue=xe,e.Camera=Te,e.ERROR_CODES=u,e.Photo=De,e.Snapshot=Oe,e.VirtualdisplayClient=hr,e.VirtualdisplayError=d,e.enableDebugMode=ae,e.isDebugMode=oe,Object.defineProperty(e,`logger`,{enumerable:!0,get:function(){return T}})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtualdisplay.io/client",
|
|
3
3
|
"description": "TypeScript-first 3D model integration library with iframe-based architecture",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.11",
|
|
5
5
|
"author": "Virtualdisplay <support@virtualdisplay.io>",
|
|
6
6
|
"homepage": "https://virtualdisplay.io",
|
|
7
7
|
"license": "MIT",
|