ohzi-core 10.4.2 → 10.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohzi-core",
3
- "version": "10.4.2",
3
+ "version": "10.5.0",
4
4
  "description": "OHZI Core Library",
5
5
  "source": "src/index.js",
6
6
  "module": "build/index.module.js",
package/src/Browser.js CHANGED
@@ -6,6 +6,12 @@ class Browser
6
6
  this.browser_name = '';
7
7
  this.agent = window.navigator.userAgent.toLowerCase();
8
8
 
9
+ // vr specific
10
+ this.vrBrowserKeywords = ['oculus', 'vive', 'rift', 'windowsmr', 'cardboard', 'daydream'];
11
+ this.vrBrowser = this.vrBrowserKeywords.find(keyword => this.agent.includes(keyword));
12
+ // Check for WebXR support (indicating VR capabilities)
13
+ this.hasWebXRSupport = 'xr' in navigator;
14
+
9
15
  switch (true)
10
16
  {
11
17
  case this.agent.indexOf('edge') > -1:
@@ -29,6 +35,9 @@ class Browser
29
35
  case this.agent.indexOf('safari') > -1:
30
36
  this.browser_name = 'safari';
31
37
  break;
38
+ case this.vrBrowser && this.hasWebXRSupport:
39
+ this.browser_name = this.vrBrowser;
40
+ break;
32
41
  default:
33
42
  this.browser_name = 'other';
34
43
  break;
@@ -62,6 +71,11 @@ class Browser
62
71
  return this.browser_name === 'edge_chromium';
63
72
  }
64
73
 
74
+ get is_vr()
75
+ {
76
+ return this.vrBrowserKeywords.includes(this.browser_name);
77
+ }
78
+
65
79
  get has_webm()
66
80
  {
67
81
  return !!(this.is_chrome || this.is_firefox || this.is_edge_chromium);