UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 1.38 kB
import f from"bowser";import g from"debug";import w from"../utils/is-webview";const h=g("efp:device");export async function logDeviceInfo(){try{h(v(await p()))}catch{}}async function p(){const n=navigator.userAgentData;if(!n)return;const o={brands:n.brands,mobile:n.mobile,platform:n.platform};try{const i=await n.getHighEntropyValues(["platformVersion","model","architecture","fullVersionList"]);o.platformVersion=i.platformVersion,o.model=i.model,o.architecture=i.architecture,i.fullVersionList?.length&&(o.brands=i.fullVersionList)}catch{}return o}function v(n){const o=window.navigator.userAgent,{browser:i,os:r,platform:a,engine:c}=f.parse(o,n),l=[],e=(m,u)=>{u&&l.push(`${m}: ${u}`)},t=__BUILD_INFO__;t&&e("SDK",`${t.version} (${t.commit} on ${t.branch}, built ${t.built})`);const d=window.devicePixelRatio||1;return e("OS",s(r.name,r.version,r.versionName&&`(${r.versionName})`)),e("Browser",s(i.name,i.version,c.name&&`(${c.name})`)),e("Device",s(a.type,a.vendor,a.model)),e("Arch",n?.architecture),e("WebView",w?"yes":"no"),e("Language",navigator.languages?.[0]||navigator.language),e("Screen",`${window.screen.width}x${window.screen.height} (DPR ${d})`),e("Viewport",`${window.innerWidth}x${window.innerHeight}`),e("Online",navigator.onLine?"yes":"no"),e("URL",document.location.href),e("User-Agent",o),l.join(" | ")}function s(...n){return n.filter(Boolean).join(" ")}