ua-browser 1.3.1 → 1.4.0-beta.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/README.en.md ADDED
@@ -0,0 +1,226 @@
1
+ # ua-browser
2
+
3
+ [![npm version](https://img.shields.io/npm/v/ua-browser?color=cb3837)](https://www.npmjs.com/package/ua-browser)
4
+ [![npm downloads](https://img.shields.io/npm/dm/ua-browser)](https://www.npmjs.com/package/ua-browser)
5
+ [![license](https://img.shields.io/npm/l/ua-browser)](./LICENSE)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-ready-3178c6)](https://www.typescriptlang.org/)
7
+
8
+ Detect browser, OS, device type, rendering engine, CPU architecture, bots, headless browsers, and Mini Programs from User Agent strings. Zero dependencies. Works in both browser and Node.js environments.
9
+
10
+ **[📖 Documentation](https://yangtianxia.github.io/ua-browser/)** · **[🎮 Playground](https://yangtianxia.github.io/ua-browser/playground)** · **[中文](./README.md)**
11
+
12
+ ## Features
13
+
14
+ - **Comprehensive UA detection** — browser (incl. Arc / Brave), OS (incl. visionOS / tvOS), engine, device type (Mobile / Tablet / PC / TV / Console / XR), CPU arch, bots, headless browsers
15
+ - **Robust device detection** — hardware signals (WebGL GPU renderer, CSS safe-area-inset, DPR, vibration/motion APIs) correctly identify mobile devices even when desktop mode is enabled
16
+ - **Multi-signal arch detection** — `getEnvContext()` collects Client Hints, WebGL renderer, and font probes to accurately distinguish Apple Silicon from Intel Mac
17
+ - **SSR Client Hints** — `parseHeaders()` + `ACCEPT_CH` for precise server-side detection (CPU arch, platform) in Chrome / Edge 90+
18
+ - **AI bot recognition** — 40+ built-in bot rules: GPTBot, ClaudeBot, PerplexityBot, CCBot, messaging link-preview bots (Slack, Discord, Telegram, WhatsApp), and more
19
+ - **Condition matching** — `satisfies(info, { os: 'iOS', device: 'Mobile' })` helper with TypeScript type checking
20
+ - **Zero dependencies** — no runtime dependencies, tiny bundle size after gzip
21
+ - **Pure function** — `parseUA()` has no global state, works seamlessly with SSR / Node.js
22
+ - **TypeScript** — full type definitions with precise literal union types (`BrowserName`, `OsName`, etc.)
23
+ - **Tree-shakeable** — named exports + `sideEffects: false`, unused code eliminated by Vite / Rollup / webpack 5+
24
+
25
+ ## Installation
26
+
27
+ ```sh
28
+ npm i ua-browser
29
+ # pnpm
30
+ pnpm add ua-browser
31
+ # yarn
32
+ yarn add ua-browser
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ```typescript
38
+ import uaBrowser from 'ua-browser'
39
+
40
+ const info = uaBrowser()
41
+
42
+ console.log(info)
43
+ // {
44
+ // browser: 'Chrome',
45
+ // version: '124.0.0.0',
46
+ // versionMajor: 124,
47
+ // engine: 'Blink',
48
+ // os: 'Windows',
49
+ // osVersion: '10',
50
+ // device: 'PC',
51
+ // arch: 'x86_64',
52
+ // isWebview: false,
53
+ // isHeadless: false,
54
+ // isBot: false,
55
+ // botName: 'unknown',
56
+ // language: 'en-US',
57
+ // platform: 'Win32',
58
+ // connectionType: 'unknown'
59
+ // }
60
+ ```
61
+
62
+ > To parse an arbitrary UA string, use the named export: `parseUA('Mozilla/5.0 ...')`
63
+
64
+ ## Usage
65
+
66
+ ### Browser (recommended: `detect`)
67
+
68
+ Use `detect()` for accurate device and arch detection — it collects hardware signals in addition to parsing the UA string:
69
+
70
+ ```typescript
71
+ import uaBrowser from 'ua-browser'
72
+
73
+ const result = await uaBrowser.detect()
74
+ console.log(result.device) // 'Mobile' — correct even in desktop mode
75
+ console.log(result.arch) // 'arm64' or 'x86_64'
76
+
77
+ if (result.device === 'Mobile') {
78
+ // redirect to mobile version
79
+ }
80
+ ```
81
+
82
+ ### Browser (sync: `uaBrowser`)
83
+
84
+ ```typescript
85
+ import uaBrowser from 'ua-browser'
86
+
87
+ const { browser, os, device } = uaBrowser()
88
+
89
+ if (device === 'Mobile') {
90
+ // redirect to mobile version
91
+ }
92
+ ```
93
+
94
+ ### Node.js / SSR
95
+
96
+ ```typescript
97
+ import { parseUA } from 'ua-browser'
98
+
99
+ const ua = req.headers['user-agent'] ?? ''
100
+ const { browser, os, isBot } = parseUA(ua)
101
+
102
+ if (isBot) {
103
+ // block or allow crawlers
104
+ }
105
+ ```
106
+
107
+ ### CDN
108
+
109
+ ```html
110
+ <script src="https://cdn.jsdelivr.net/npm/ua-browser/dist/index.min.js"></script>
111
+ <script>
112
+ const { browser, os } = uaBrowser()
113
+ </script>
114
+ ```
115
+
116
+ ### Multi-signal Detection
117
+
118
+ `getEnvContext()` collects Client Hints, WebGL renderer, and other browser signals in one async call. Use it when you need to reuse the context object or compose it with other options:
119
+
120
+ ```typescript
121
+ import { getEnvContext, parseUA } from 'ua-browser'
122
+
123
+ const ctx = await getEnvContext()
124
+ const result = parseUA(navigator.userAgent, { ctx })
125
+
126
+ console.log(result.device) // 'Mobile' — correct even in desktop mode
127
+ console.log(result.arch) // 'arm64' or 'x86_64'
128
+ ```
129
+
130
+ ### SSR Client Hints
131
+
132
+ Set the `ACCEPT_CH` response header so Chrome / Edge 90+ browsers send Client Hints on subsequent requests, then use `parseHeaders` for precise server-side detection:
133
+
134
+ ```typescript
135
+ import { parseHeaders, ACCEPT_CH } from 'ua-browser'
136
+
137
+ // First response — tell the browser to send Client Hints
138
+ res.setHeader('Accept-CH', ACCEPT_CH)
139
+
140
+ // Subsequent requests — accurate arch / OS detection
141
+ const result = parseHeaders(req.headers)
142
+ console.log(result.arch) // 'x86_64' (from Sec-CH-UA-Arch)
143
+ ```
144
+
145
+ ### Accurate Windows 10 / 11 Detection
146
+
147
+ Windows 10 and 11 share the same UA string. Use the Client Hints API to distinguish them:
148
+
149
+ ```typescript
150
+ import { parseUA, getWindowsVersion, getNavContext } from 'ua-browser'
151
+
152
+ const nav = getNavContext()
153
+ const windowsVersion = await getWindowsVersion(nav)
154
+ const result = parseUA(navigator.userAgent, { nav, windowsVersion })
155
+
156
+ console.log(result.osVersion) // '10' or '11'
157
+ ```
158
+
159
+ ## API
160
+
161
+ ### Default export `uaBrowser()`
162
+
163
+ Detects the current browser environment, automatically injecting the `navigator` context (language, platform, MIME types, etc.).
164
+
165
+ ```typescript
166
+ uaBrowser() // reads navigator.userAgent automatically
167
+ parseUA(customUA) // parse any UA string without browser context
168
+ ```
169
+
170
+ ### Named exports (tree-shakeable)
171
+
172
+ ```typescript
173
+ import {
174
+ parseUA, // pure function, ideal for SSR / Node.js
175
+ getNavContext, // read current browser navigator context
176
+ getWindowsVersion, // async: accurately distinguish Windows 10 / 11
177
+ getLanguage, // extract browser language from NavContext
178
+ getEnvContext, // collect all browser signals (Client Hints, WebGL, etc.)
179
+ parseHeaders, // parse UA and Client Hints from HTTP headers (SSR)
180
+ ACCEPT_CH, // response header constant to request Client Hints
181
+ isWebview, // detect Android Webview / iOS WKWebView
182
+ detectBot, // standalone bot detection
183
+ detectBrowser, // standalone browser detection
184
+ detectOS, // standalone OS detection
185
+ detectArch, // standalone CPU architecture detection
186
+ detectHeadless, // standalone headless browser detection
187
+ satisfies, // condition-matching helper
188
+ VERSION, // current library version
189
+ } from 'ua-browser'
190
+ ```
191
+
192
+ ### Return value `EnvOption`
193
+
194
+ | Field | Type | Description |
195
+ | :-- | :-- | :-- |
196
+ | `browser` | `BrowserName` | Browser name |
197
+ | `version` | `string` | Browser version |
198
+ | `versionMajor` | `number` | Browser major version (`parseInt(version)`) |
199
+ | `engine` | `EngineName` | Rendering engine |
200
+ | `os` | `OsName` | Operating system |
201
+ | `osVersion` | `string` | OS version |
202
+ | `device` | `DeviceName` | Device type: `Mobile` \| `Tablet` \| `PC` \| `TV` \| `Console` \| `XR` |
203
+ | `arch` | `ArchName` | CPU architecture |
204
+ | `isWebview` | `boolean` | Whether running in Android Webview or iOS WKWebView |
205
+ | `isHeadless` | `boolean` | Whether running in a headless / automated browser |
206
+ | `isBot` | `boolean` | Whether the UA belongs to a bot / crawler |
207
+ | `botName` | `BotName` | Bot name |
208
+ | `language` | `string` | Browser language, e.g. `en-US` |
209
+ | `platform` | `string` | Platform identifier, e.g. `Win32` |
210
+ | `connectionType` | `string` | Network type: `4g` \| `3g` \| `2g` \| `slow-2g` \| `unknown` |
211
+
212
+ > All fields return `'unknown'` when undetected — never an empty string or `null`.
213
+
214
+ ## Supported
215
+
216
+ Over 70 browsers, 20 operating systems, and 40+ bot rules built in. See the **[full support list](https://yangtianxia.github.io/ua-browser/guide/support-list)**.
217
+
218
+ Highlights:
219
+ - **Browsers** — Chrome, Safari, Arc, Brave, Firefox, Edge, Samsung Internet, UC, WeChat, DingTalk, TikTok, Bilibili, Kuaishou, Xiaohongshu, Feishu and more
220
+ - **OS** — Windows, macOS, Android, iOS, visionOS, tvOS, HarmonyOS, OpenHarmony, Tizen, KaiOS and more
221
+ - **Bots** — GPTBot, ClaudeBot, PerplexityBot, CCBot; messaging bots (Slack, Discord, Telegram, WhatsApp) and more
222
+ - **Devices** — Mobile, Tablet, PC, TV (Samsung Smart TV, HbbTV), Console (PS5, Xbox, Switch), XR (Vision Pro, Quest)
223
+
224
+ ## License
225
+
226
+ [MIT](./LICENSE) © yangtianxia
package/README.md CHANGED
@@ -5,22 +5,23 @@
5
5
  [![license](https://img.shields.io/npm/l/ua-browser)](./LICENSE)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-ready-3178c6)](https://www.typescriptlang.org/)
7
7
 
8
- Detect browser, OS, device type, rendering engine, CPU architecture, bots, headless browsers, and Mini Programs from User Agent strings. Zero dependencies. Works in both browser and Node.js environments.
8
+ 通过 User Agent 检测浏览器、操作系统、设备类型、渲染内核、CPU 架构、爬虫、无头浏览器及小程序运行环境。零依赖,支持浏览器与 Node.js 双环境。
9
9
 
10
- **[📖 Documentation](https://yangtianxia.github.io/ua-browser/)** · **[🎮 Playground](https://yangtianxia.github.io/ua-browser/playground)** · **[中文](./README.zh-CN.md)**
10
+ **[📖 文档](https://yangtianxia.github.io/ua-browser/)** · **[🎮 Playground](https://yangtianxia.github.io/ua-browser/playground)** · **[English](./README.en.md)**
11
11
 
12
- ## Features
12
+ ## 特性
13
13
 
14
- - **Comprehensive UA detection**browser, OS, engine, device type (Mobile / Tablet / TV / PC), CPU arch, bots, headless browsers
15
- - **Multi-signal arch detection** — `getEnvContext()` collects Client Hints, WebGL renderer, and font probes to accurately distinguish Apple Silicon from Intel Mac
16
- - **SSR Client Hints** — `parseHeaders()` + `ACCEPT_CH` for precise server-side detection (CPU arch, platform) in Chrome / Edge 90+
17
- - **AI bot recognition** built-in support for GPTBot, ClaudeBot, PerplexityBot, CCBot and more
18
- - **Zero dependencies** no runtime dependencies, tiny bundle size after gzip
19
- - **Pure function** `parseUA()` has no global state, works seamlessly with SSR / Node.js
20
- - **TypeScript**full type definitions with precise literal union types (`BrowserName`, `OsName`, etc.)
21
- - **Tree-shakeable** — named exports + `sideEffects: false`, unused code eliminated by Vite / Rollup / webpack 5+
14
+ - **全面 UA 检测**浏览器(含 Arc / Brave)、OS(含 visionOS / tvOS)、渲染内核、设备类型(Mobile / Tablet / TV / PC / Console / XR)、CPU 架构、爬虫、无头浏览器
15
+ - **多信号架构检测** — `getEnvContext()` 采集 Client HintsWebGL 渲染器、字体探针,精确区分 Apple Silicon Intel Mac
16
+ - **SSR Client Hints** — `parseHeaders()` + `ACCEPT_CH`,在 Chrome / Edge 90+ 中实现服务端精准检测(CPU 架构、平台等)
17
+ - **AI 爬虫识别**内置 GPTBotClaudeBotPerplexityBotCCBot 40+ 种爬虫规则,含消息应用链接预览 Bot(Slack、Discord、Telegram)
18
+ - **条件匹配**`satisfies(info, { os: 'iOS', device: 'Mobile' })` 辅助函数,支持 TypeScript 类型检查
19
+ - **零依赖**无任何运行时依赖,gzip 后体积极小
20
+ - **纯函数**`parseUA()` 无全局状态,天然支持 SSR / Node.js
21
+ - **TypeScript** — 完整类型定义,`BrowserName`、`OsName` 等均为精确字面量联合类型
22
+ - **Tree-shakeable** — 所有功能按需导入,不引入多余代码
22
23
 
23
- ## Installation
24
+ ## 安装
24
25
 
25
26
  ```sh
26
27
  npm i ua-browser
@@ -30,7 +31,7 @@ pnpm add ua-browser
30
31
  yarn add ua-browser
31
32
  ```
32
33
 
33
- ## Quick Start
34
+ ## 快速上手
34
35
 
35
36
  ```typescript
36
37
  import uaBrowser from 'ua-browser'
@@ -39,27 +40,29 @@ const info = uaBrowser()
39
40
 
40
41
  console.log(info)
41
42
  // {
42
- // browser: 'Chrome',
43
- // version: '124.0.0.0',
44
- // engine: 'Blink',
45
- // os: 'Windows',
46
- // osVersion: '10',
47
- // device: 'PC',
48
- // arch: 'x86_64',
49
- // isWebview: false,
50
- // isHeadless: false,
51
- // isBot: false,
52
- // botName: 'unknown',
53
- // language: 'en-US',
54
- // platform: 'Win32'
43
+ // browser: 'Chrome',
44
+ // version: '124.0.0.0',
45
+ // versionMajor: 124,
46
+ // engine: 'Blink',
47
+ // os: 'Windows',
48
+ // osVersion: '10',
49
+ // device: 'PC',
50
+ // arch: 'x86_64',
51
+ // isWebview: false,
52
+ // isHeadless: false,
53
+ // isBot: false,
54
+ // botName: 'unknown',
55
+ // language: 'zh-CN',
56
+ // platform: 'Win32',
57
+ // connectionType: 'unknown'
55
58
  // }
56
59
  ```
57
60
 
58
- > Pass a custom UA string: `uaBrowser('Mozilla/5.0 ...')`
61
+ > 解析任意 UA 字符串请使用命名导出:`parseUA('Mozilla/5.0 ...')`
59
62
 
60
- ## Usage
63
+ ## 使用
61
64
 
62
- ### Browser
65
+ ### 浏览器环境
63
66
 
64
67
  ```typescript
65
68
  import uaBrowser from 'ua-browser'
@@ -67,7 +70,7 @@ import uaBrowser from 'ua-browser'
67
70
  const { browser, os, device } = uaBrowser()
68
71
 
69
72
  if (device === 'Mobile') {
70
- // redirect to mobile version
73
+ // 跳转移动版
71
74
  }
72
75
  ```
73
76
 
@@ -80,7 +83,7 @@ const ua = req.headers['user-agent'] ?? ''
80
83
  const { browser, os, isBot } = parseUA(ua)
81
84
 
82
85
  if (isBot) {
83
- // block or allow crawlers
86
+ // 拦截或放行爬虫
84
87
  }
85
88
  ```
86
89
 
@@ -93,9 +96,9 @@ if (isBot) {
93
96
  </script>
94
97
  ```
95
98
 
96
- ### Multi-signal Architecture Detection
99
+ ### 多信号架构检测
97
100
 
98
- `getEnvContext()` collects Client Hints, WebGL renderer, and other browser signals in one async call — enough to distinguish Apple Silicon from Intel Mac:
101
+ `getEnvContext()` 一次性采集 Client HintsWebGL 渲染器等多维信号,可区分 Apple Silicon Intel Mac
99
102
 
100
103
  ```typescript
101
104
  import { getEnvContext, parseUA } from 'ua-browser'
@@ -103,27 +106,27 @@ import { getEnvContext, parseUA } from 'ua-browser'
103
106
  const ctx = await getEnvContext()
104
107
  const result = parseUA(navigator.userAgent, { ctx })
105
108
 
106
- console.log(result.arch) // 'arm64' or 'x86_64'
109
+ console.log(result.arch) // 'arm64' 'x86_64'
107
110
  ```
108
111
 
109
112
  ### SSR Client Hints
110
113
 
111
- Set the `ACCEPT_CH` response header so Chrome / Edge 90+ browsers send Client Hints on subsequent requests, then use `parseHeaders` for precise server-side detection:
114
+ 通过响应头告知 Chrome / Edge 90+ 上报 Client Hints,再用 `parseHeaders` 在服务端精准解析:
112
115
 
113
116
  ```typescript
114
117
  import { parseHeaders, ACCEPT_CH } from 'ua-browser'
115
118
 
116
- // First response — tell the browser to send Client Hints
119
+ // 第一次响应时写入 Accept-CH
117
120
  res.setHeader('Accept-CH', ACCEPT_CH)
118
121
 
119
- // Subsequent requests accurate arch / OS detection
122
+ // 后续请求携带 Client Hints 后,精准识别架构等信息
120
123
  const result = parseHeaders(req.headers)
121
- console.log(result.arch) // 'x86_64' (from Sec-CH-UA-Arch)
124
+ console.log(result.arch) // 'x86_64'(来自 Sec-CH-UA-Arch
122
125
  ```
123
126
 
124
- ### Accurate Windows 10 / 11 Detection
127
+ ### 精确区分 Windows 10 / 11
125
128
 
126
- Windows 10 and 11 share the same UA string. Use the Client Hints API to distinguish them:
129
+ Windows 10 11 UA 字符串相同,需借助 Client Hints API 异步获取:
127
130
 
128
131
  ```typescript
129
132
  import { parseUA, getWindowsVersion, getNavContext } from 'ua-browser'
@@ -132,68 +135,73 @@ const nav = getNavContext()
132
135
  const windowsVersion = await getWindowsVersion(nav)
133
136
  const result = parseUA(navigator.userAgent, { nav, windowsVersion })
134
137
 
135
- console.log(result.osVersion) // '10' or '11'
138
+ console.log(result.osVersion) // '10' '11'
136
139
  ```
137
140
 
138
141
  ## API
139
142
 
140
- ### Default export `uaBrowser(ua?)`
143
+ ### 默认导出 `uaBrowser()`
141
144
 
142
- Automatically injects the `navigator` context (language, platform, MIME types, etc.) in browser environments.
145
+ 检测当前浏览器环境,自动注入 `navigator` 上下文(语言、平台、MIME 类型等)。
143
146
 
144
147
  ```typescript
145
- uaBrowser() // reads navigator.userAgent automatically
146
- uaBrowser(customUA) // custom UA string, still injects browser context
148
+ uaBrowser() // 自动读取 navigator.userAgent
149
+ parseUA(customUA) // 解析任意 UA 字符串(无浏览器上下文依赖)
147
150
  ```
148
151
 
149
- ### Named exports (tree-shakeable)
152
+ ### 命名导出(按需引入)
150
153
 
151
154
  ```typescript
152
155
  import {
153
- parseUA, // pure function, ideal for SSR / Node.js
154
- getNavContext, // read current browser navigator context
155
- getWindowsVersion, // async: accurately distinguish Windows 10 / 11
156
- getLanguage, // extract browser language from NavContext
157
- getEnvContext, // collect all browser signals (Client Hints, WebGL, etc.)
158
- parseHeaders, // parse UA and Client Hints from HTTP headers (SSR)
159
- ACCEPT_CH, // response header constant to request Client Hints
160
- isWebview, // detect Android Webview / iOS WKWebView
161
- detectBot, // standalone bot detection
162
- detectArch, // standalone CPU architecture detection
163
- detectHeadless, // standalone headless browser detection
164
- VERSION, // current library version
156
+ parseUA, // 纯函数,适合 SSR / Node.js
157
+ getNavContext, // 读取当前浏览器 navigator 上下文
158
+ getWindowsVersion, // 异步精确区分 Windows 10 / 11
159
+ getLanguage, // NavContext 获取浏览器语言
160
+ getEnvContext, // 采集所有浏览器环境信号(Client HintsWebGL 等)
161
+ parseHeaders, // HTTP 请求头解析 UA Client HintsSSR
162
+ ACCEPT_CH, // 响应头常量,告知浏览器上报 Client Hints
163
+ isWebview, // 检测 Android Webview / iOS WKWebView
164
+ detectBot, // 独立爬虫检测
165
+ detectBrowser, // 独立浏览器检测
166
+ detectOS, // 独立操作系统检测
167
+ detectArch, // 独立 CPU 架构检测
168
+ detectHeadless, // 独立无头浏览器检测
169
+ satisfies, // 条件匹配辅助函数
170
+ VERSION, // 当前版本号
165
171
  } from 'ua-browser'
166
172
  ```
167
173
 
168
- ### Return value `EnvOption`
174
+ ### 返回值 `EnvOption`
169
175
 
170
- | Field | Type | Description |
176
+ | 字段 | 类型 | 说明 |
171
177
  | :-- | :-- | :-- |
172
- | `browser` | `BrowserName` | Browser name |
173
- | `version` | `string` | Browser version |
174
- | `engine` | `EngineName` | Rendering engine |
175
- | `os` | `OsName` | Operating system |
176
- | `osVersion` | `string` | OS version |
177
- | `device` | `DeviceName` | Device type: `Mobile` \| `Tablet` \| `TV` \| `PC` |
178
- | `arch` | `ArchName` | CPU architecture |
179
- | `isWebview` | `boolean` | Whether running in Android Webview or iOS WKWebView |
180
- | `isHeadless` | `boolean` | Whether running in a headless / automated browser |
181
- | `isBot` | `boolean` | Whether the UA belongs to a bot / crawler |
182
- | `botName` | `BotName` | Bot name |
183
- | `language` | `string` | Browser language, e.g. `en-US` |
184
- | `platform` | `string` | Platform identifier, e.g. `Win32` |
185
-
186
- > All fields return `'unknown'` when undetected never an empty string or `null`.
187
-
188
- ## Supported
189
-
190
- Over 70 browsers, 17 operating systems, and 19 bot rules built in. See the **[full support list](https://yangtianxia.github.io/ua-browser/guide/support-list)**.
191
-
192
- Highlights:
193
- - **Browsers** — Chrome, Safari, Firefox, Edge, Samsung Internet, UC, WeChat, DingTalk, TikTok, Bilibili, Kuaishou, Xiaohongshu, Feishu and more
194
- - **OS** — Windows, macOS, Android, iOS, HarmonyOS, OpenHarmony, Tizen, KaiOS and more
195
- - **AI bots** GPTBot, ClaudeBot, PerplexityBot, CCBot and more
196
- - **Devices**Mobile, Tablet, TV (Samsung Smart TV, HbbTV), PC
178
+ | `browser` | `BrowserName` | 浏览器名称 |
179
+ | `version` | `string` | 浏览器版本 |
180
+ | `versionMajor` | `number` | 浏览器主版本号(`parseInt(version)`) |
181
+ | `engine` | `EngineName` | 渲染内核 |
182
+ | `os` | `OsName` | 操作系统 |
183
+ | `osVersion` | `string` | 系统版本 |
184
+ | `device` | `DeviceName` | 设备类型:`Mobile` \| `Tablet` \| `PC` \| `TV` \| `Console` \| `XR` |
185
+ | `arch` | `ArchName` | CPU 架构 |
186
+ | `isWebview` | `boolean` | 是否为 Android Webview / iOS WKWebView |
187
+ | `isHeadless` | `boolean` | 是否为无头 / 自动化浏览器 |
188
+ | `isBot` | `boolean` | 是否为爬虫 / 机器人 |
189
+ | `botName` | `BotName` | 爬虫名称 |
190
+ | `language` | `string` | 浏览器语言,如 `zh-CN` |
191
+ | `platform` | `string` | 平台标识,如 `Win32` |
192
+ | `connectionType` | `string` | 网络类型:`4g` \| `3g` \| `2g` \| `slow-2g` \| `unknown` |
193
+
194
+ > 所有字段在无法识别时统一返回 `'unknown'`,不返回空字符串或 `null`。
195
+
196
+ ## 支持范围
197
+
198
+ 内置超过 70 种浏览器、20 种操作系统、40+ 种爬虫规则,详见 **[内置支持列表](https://yangtianxia.github.io/ua-browser/guide/support-list)**。
199
+
200
+ 部分覆盖:
201
+ - **浏览器**Chrome、Safari、Arc、Brave、Firefox、Edge、Samsung Internet、UC、微信、钉钉、抖音、哔哩哔哩、快手、小红书、飞书等
202
+ - **操作系统**Windows、macOS、Android、iOS、visionOS、tvOS、HarmonyOS、OpenHarmony、Tizen、KaiOS
203
+ - **AI 爬虫** — GPTBot、ClaudeBot、PerplexityBot、CCBot;消息应用 Bot(Slack、Discord、Telegram、WhatsApp)等
204
+ - **设备** — Mobile、Tablet、PC、TV(含三星 Smart TV、HbbTV 标准)、Console(PS5、Xbox、Switch)、XR(Vision Pro、Quest)
197
205
 
198
206
  ## License
199
207