@shopware-ag/dive
Version:
Shopware Spatial Framework
2 lines (1 loc) • 3.41 kB
JavaScript
;var d=Object.defineProperty;var p=(t,e,r)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e,r)=>p(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var i=(t=>(t.IOS="iOS",t.ANDROID="Android",t.WINDOWS="Windows",t.MACOS="MacOS",t.LINUX="Linux",t.UNKNOWN="Unknown",t))(i||{}),n=(t=>(t.NO_WEBXR_API="NO_WEBXR_API",t.NO_HTTPS="NO_HTTPS",t.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE="IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE",t.AR_PERMISSION_DENIED="AR_PERMISSION_DENIED",t.UNKNOWN_ERROR="UNKNOWN_ERROR",t))(n||{}),c=(t=>(t.CHROMIUM="Chromium",t.SAFARI="Safari",t.WEBKIT="WebKit",t.FIREFOX="Firefox",t.EDGE_LEGACY="EdgeLegacy",t.UNKNOWN="Unknown",t))(c||{});class u{static getSystem(){if(typeof window>"u"||!window.navigator)return i.UNKNOWN;const e=window.navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")?i.IOS:e.includes("android")?i.ANDROID:e.includes("windows")?i.WINDOWS:e.includes("macintosh")?i.MACOS:e.includes("linux")?i.LINUX:i.UNKNOWN}static async getSupportsWebXR(){if(this._supportsWebXR!==!1)return this._supportsWebXR;if(!window.isSecureContext)return this._supportsWebXR=!1,this._webXRUnsupportedReason=n.NO_HTTPS,this._supportsWebXR;if(!navigator.xr)return this._supportsWebXR=!1,this._webXRUnsupportedReason=n.NO_WEBXR_API,this._supportsWebXR;try{const e=await navigator.xr.isSessionSupported("immersive-ar");this._supportsWebXR=e,this._supportsWebXR||(this._webXRUnsupportedReason=n.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE)}catch{this._supportsWebXR=!1,this._webXRUnsupportedReason=n.AR_PERMISSION_DENIED}return this._supportsWebXR}static getWebXRUnsupportedReason(){return this._supportsWebXR?(console.log("WebXR is supported."),null):this._webXRUnsupportedReason}static getSupportsARQuickLook(){return!!document.createElement("a").relList.supports("ar")}static getSupportsSceneViewer(){if(typeof window>"u"||!window.navigator)return!1;const e=window.navigator.userAgent.toLowerCase();if(!e.includes("android")||!e.includes("chrome"))return!1;const r=e.match(/chrome\/(\d+)/);return!(!r||parseInt(r[1])<89)}static get isMobile(){return this.getSystem()===i.ANDROID||this.getSystem()===i.IOS}static get isDesktop(){return!this.isMobile}static getSupportsAR(){return this.getSupportsARQuickLook()||this.getSupportsSceneViewer()}static getBrowser(){var s;if(typeof window>"u"||!window.navigator)return"Unknown";const e=window.navigator.userAgent.toLowerCase(),r=(s=window.navigator.vendor)==null?void 0:s.toLowerCase();return e.includes("fxios/")?"Firefox":e.includes("crios/")?"Chromium":e.includes("firefox/")?"Firefox":e.includes("safari/")&&e.includes("version/")&&!e.includes("chrome/")&&!e.includes("edg/")&&!e.includes("opr/")?"Safari":e.includes("edg/")?"Chromium":e.includes("edge/")?"EdgeLegacy":e.includes("chrome/")||r!=null&&r.includes("google inc.")?"Chromium":e.includes("applewebkit")?"WebKit":"Unknown"}static getIOSVersion(){if(this.getSystem()!==i.IOS||typeof window>"u"||!window.navigator)return null;const r=window.navigator.userAgent.match(/(?:iPhone OS|iPad OS|OS) (\d+[._\d]*)/i);if(r&&r[1]){const s=r[1].replace(/_/g,"."),a=parseInt(s.split(".")[0],10);if(!isNaN(a))return{major:a,full:s}}return null}}o(u,"_supportsWebXR",!1),o(u,"_webXRUnsupportedReason",null);exports.EBrowser=c;exports.ESystem=i;exports.EWebXRUnsupportedReason=n;exports.SystemInfo=u;