You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: changelog.md
+48-20Lines changed: 48 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,42 @@
1
1
# UAParser.js Changelog
2
2
3
+
# Version 2.0.0-alpha.1
4
+
- Breaking changes:
5
+
- Browser detection on mobile device: `Chrome => Mobile Chrome`, `Firefox => Mobile Firefox`
6
+
- OS detection: `Mac OS => macOS`, `Chromium OS => Chrome OS`
7
+
- Add some new methods in result object:
8
+
- Add support for client hints: `withClientHints()`
9
+
- Utility for easy comparison: `is()`
10
+
- Utility to print full-name: `toString()`
11
+
- Add support for ES module `import { UAParser } from 'ua-parser-js'`
12
+
- Provide Enums `'ua-parser-js/enums'`
13
+
- Provide Extensions `'ua-parser-js/extensions'`
14
+
- Add new browser: Heytap, TikTok
15
+
- Add new engine: LibWeb
16
+
- Add new OS: SerenityOS
17
+
- Improve browser detection: Yandex
18
+
- Improve device detection: iPhone, Amazon Echo
19
+
- Improve OS detection: iOS
20
+
3
21
# Version 0.7 / 1.0
4
22
5
23
Version 1.0.x is basically the equivalent of version 0.7.x. See [#536](https://github.com/faisalman/ua-parser-js/issues/536) for the reason behind this confusion.
6
24
7
-
## Version 0.7.30 / 1.0.1
25
+
## Version 0.7.34 / 1.0.34
26
+
- Fix Sharp Mobile detected as Huawei Tablet
27
+
- Fix IE8 bug
28
+
- Add new devices : Kobo e-Reader, Apple Watch, and some new SmartTV devices
29
+
- Add new OS : watchOS
30
+
- Improve browser detection : Kakao, Naver, Brave
31
+
- Improve device detection : Oculus, iPad
32
+
- Improve OS detection : Chrome OS
33
+
- Using navigator.userAgentData as fallback for device.type & os.name
"build": "uglifyjs src/ua-parser.js -o dist/ua-parser.min.js --comments '/^ UA/' && uglifyjs src/ua-parser.js -o dist/ua-parser.pack.js --comments '/^ UA/' --compress --mangle && uglifyjs src/ua-parser-enum.js -o dist/ua-parser-enum.min.js --comments '/^ Enum/' && node -e \"const fs=require('fs');fs.writeFileSync('src/ua-parser.mjs','// Generated ESM version of UAParser.js\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/ua-parser.js\\n\\nconst window = undefined;\\n\\n'+fs.readFileSync('src/ua-parser.js','utf-8').replace(/\\(func[\\s\\S]+strict\\';/ig,'').replace(/\\/[\\/\\s]+export[\\s\\S]+/ig,'export {UAParser};'),'utf-8');fs.writeFileSync('src/ua-parser-enum.mjs','// Generated ESM version of UAParser.js enums\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/ua-parser-enum.js\\n\\n'+fs.readFileSync('src/ua-parser-enum.js','utf-8').replace(/module\\.exports =/ig,'export'),'utf-8');fs.writeFileSync('src/ua-parser-extension.mjs','// Generated ESM version of UAParser.js extensions\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/ua-parser-extension.js\\n\\n'+fs.readFileSync('src/ua-parser-extension.js','utf-8').replace(/module\\.exports =/ig,'export'),'utf-8')\"",
165
+
"build": "uglifyjs src/ua-parser.js -o dist/ua-parser.min.js --comments '/^ UA/' && uglifyjs src/ua-parser.js -o dist/ua-parser.pack.js --comments '/^ UA/' --compress --mangle && node -e \"const fs=require('fs');fs.writeFileSync('src/ua-parser.mjs','// Generated ESM version of UAParser.js\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/ua-parser.js\\n\\nconst window = undefined;\\n\\n'+fs.readFileSync('src/ua-parser.js','utf-8').replace(/\\(func[\\s\\S]+strict\\';/ig,'').replace(/\\/[\\/\\s]+export[\\s\\S]+/ig,'export {UAParser};'),'utf-8');fs.writeFileSync('src/enum/ua-parser-enum.mjs','// Generated ESM version of UAParser.js enums\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/enum/ua-parser-enum.js\\n\\n'+fs.readFileSync('src/enum/ua-parser-enum.js','utf-8').replace(/module\\.exports =/ig,'export'),'utf-8');fs.writeFileSync('src/extension/ua-parser-extension.mjs','// Generated ESM version of UAParser.js extensions\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/extension/ua-parser-extension.js\\n\\n'+fs.readFileSync('src/extension/ua-parser-extension.js','utf-8').replace(/const UA.+\\)/ig,'import UAParser from \\'ua-parser-js\\'').replace(/module\\.exports =/ig,'export'),'utf-8')\"",
In the browser environment you dont need to pass the user-agent string to the function, you can just call the funtion and it should automatically get the string from the `window.navigator.userAgent`, but that is not the case in nodejs. The user-agent string must be passed in' nodejs for the function to work. Usually you can find the user agent in: `request.headers["user-agent"]`.
50
53
51
54
52
55
## Constructor
53
56
When you call `UAParser` with the `new` keyword, `UAParser` will return a new instance with an empty result object, you have to call one of the available methods to get the information from the user-agent string.
Unlike reading user-agent data, accessing client-hints data in browser-environmentmust be done in an asynchronous way. Worry not, you can chain the UAParser's `get*` method with `withClientHints()` to read the client-hints data as well that will return the updated data as a `Promise`. In nodejs-environment / browser-environment with non-secure context or without client-hints support (basically anything that's not chromium-based) this will return the updated data as a `Thenable` (can be chained with `then()`).
292
+
Recently Chrome limits the information exposed through user-agent and introduces a new experimental set of data called "client-hints". In browser-environment, obtaining the client-hints data via JavaScript must be done in an asynchronous way. In `UAParser` you can chain the result object from `get*` method with `withClientHints()` to also read the client-hints data from the browser and return the updated data as a `Promise`.
297
293
298
294
```js
295
+
// client-side example
299
296
(asyncfunction () {
300
297
let ua =newUAParser();
301
298
@@ -314,12 +311,43 @@ Unlike reading user-agent data, accessing client-hints data in browser-environme
314
311
})();
315
312
```
316
313
314
+
Along with `User-Agent` HTTP header, Chrome also sends this client-hints data by default under `Sec-CH-UA-*` HTTP headers in each request. In server-side development, you can capture this extra information by passing the `req.headers` to `UAParser()` (see examples below). When using `withClientHints()` in nodejs environment and browser without client-hints support (basically anything that's not Chromium-based) the updated data will be returned as a `Thenable` (has `then()` method).
315
+
316
+
```js
317
+
// server-side example
318
+
319
+
// Suppose we got a request having these HTTP headers:
320
+
constrequest= {
321
+
headers : {
322
+
'user-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
323
+
324
+
'sec-ch-ua-mobile':'?1',
325
+
'sec-ch-ua-model':'Galaxy S3 Marketing',
326
+
'sec-ch-ua-platform':'Android'
327
+
}
328
+
};
329
+
330
+
constresult1=UAParser(request.headers); // parse only "user-agent" header
331
+
constresult2=UAParser(request.headers).withClientHints(); // update with "sec-ch-ua" headers
If you want to detect something that's not currently provided by UAParser.js (eg: `bots`, specific apps, etc), you can pass a list of regexes to extend internal UAParser.js regexes with your own.
0 commit comments