diff --git a/src/enums/ua-parser-enums.js b/src/enums/ua-parser-enums.js index 692fe0e..d994a38 100644 --- a/src/enums/ua-parser-enums.js +++ b/src/enums/ua-parser-enums.js @@ -179,7 +179,8 @@ const Device = Object.freeze({ MOBILE: 'mobile', SMARTTV: 'smarttv', TABLET: 'tablet', - WEARABLE: 'wearable' + WEARABLE: 'wearable', + XR: 'xr' }); const Vendor = Object.freeze({ diff --git a/src/main/ua-parser.d.ts b/src/main/ua-parser.d.ts index b37c67c..9f06b21 100644 --- a/src/main/ua-parser.d.ts +++ b/src/main/ua-parser.d.ts @@ -23,7 +23,7 @@ declare namespace UAParser { } interface IDevice extends IData { - type?: 'mobile' | 'tablet' | 'console' | 'smarttv' | 'wearable'; + type?: 'mobile' | 'tablet' | 'console' | 'smarttv' | 'wearable' | 'xr' | 'embedded'; vendor?: string; model?: string; } @@ -76,6 +76,7 @@ declare namespace UAParser { SMARTTV: 'smarttv'; TABLET: 'tablet'; WEARABLE: 'wearable'; + XR: 'xr'; EMBEDDED: 'embedded'; }; static readonly ENGINE: { diff --git a/src/main/ua-parser.js b/src/main/ua-parser.js index 2217759..26038e1 100755 --- a/src/main/ua-parser.js +++ b/src/main/ua-parser.js @@ -38,6 +38,7 @@ TABLET = 'tablet', SMARTTV = 'smarttv', WEARABLE = 'wearable', + XR = 'xr', EMBEDDED = 'embedded', USER_AGENT = 'user-agent', UA_MAX_LENGTH = 500, @@ -274,7 +275,8 @@ 'mobile' : 'Mobile', 'tablet' : ['Tablet', 'EInk'], 'smarttv' : 'TV', - 'wearable' : ['VR', 'XR', 'Watch'], + 'wearable' : 'Watch', + 'xr' : ['VR', 'XR'], '?' : ['Desktop', 'Unknown'], '*' : undefined }; @@ -711,12 +713,17 @@ ], [VENDOR, MODEL, [TYPE, WEARABLE]], [ /(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i // Apple Watch ], [MODEL, [VENDOR, APPLE], [TYPE, WEARABLE]], [ - /droid.+; (glass) \d/i // Google Glass - ], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [ /droid.+; (wt63?0{2,3})\)/i ], [MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]], [ + + /////////////////// + // XR + /////////////////// + + /droid.+; (glass) \d/i // Google Glass + ], [MODEL, [VENDOR, GOOGLE], [TYPE, XR]], [ /(quest( \d| pro)?)/i // Oculus Quest - ], [MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]], [ + ], [MODEL, [VENDOR, FACEBOOK], [TYPE, XR]], [ /////////////////// // EMBEDDED diff --git a/test/mocha-test.js b/test/mocha-test.js index 184a847..ead59a8 100644 --- a/test/mocha-test.js +++ b/test/mocha-test.js @@ -479,7 +479,7 @@ describe('Map UA-CH headers', function () { }; UAParser(FFVR).withClientHints().then(function (ua) { - assert.strictEqual(ua.device.type, 'wearable'); + assert.strictEqual(ua.device.type, 'xr'); }); UAParser(FFEInk).withClientHints().then(function (ua) { diff --git a/test/specs/device-all.json b/test/specs/device-all.json index 3927c2a..252782c 100644 --- a/test/specs/device-all.json +++ b/test/specs/device-all.json @@ -1373,7 +1373,7 @@ "expect": { "vendor": "Facebook", "model": "Quest", - "type": "wearable" + "type": "xr" } }, { @@ -1382,7 +1382,7 @@ "expect": { "vendor": "Facebook", "model": "Quest 2", - "type": "wearable" + "type": "xr" } }, { @@ -1391,7 +1391,7 @@ "expect": { "vendor": "Facebook", "model": "Quest 3", - "type": "wearable" + "type": "xr" } }, { @@ -1400,7 +1400,7 @@ "expect": { "vendor": "Facebook", "model": "Quest Pro", - "type": "wearable" + "type": "xr" } }, {