ua-parser-js 2.0.0-beta.2 → 2.0.0-beta.3
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.md +7 -8
- package/dist/ua-parser.min.js +3 -3
- package/dist/ua-parser.pack.js +3 -3
- package/package.json +5 -3
- package/script/cli.js +4 -0
- package/src/enums/ua-parser-enums.js +18 -5
- package/src/enums/ua-parser-enums.mjs +18 -5
- package/src/extensions/ua-parser-extensions.d.ts +4 -3
- package/src/extensions/ua-parser-extensions.js +119 -23
- package/src/extensions/ua-parser-extensions.mjs +119 -23
- package/src/helpers/ua-parser-helpers.d.ts +1 -1
- package/src/helpers/ua-parser-helpers.js +1 -1
- package/src/helpers/ua-parser-helpers.mjs +1 -1
- package/src/main/ua-parser.d.ts +6 -3
- package/src/main/ua-parser.js +67 -42
- package/src/main/ua-parser.mjs +67 -42
@@ -1,5 +1,5 @@
|
|
1
1
|
///////////////////////////////////////////////
|
2
|
-
/* Extensions for UAParser.js v2.0.0-beta.
|
2
|
+
/* Extensions for UAParser.js v2.0.0-beta.3
|
3
3
|
https://github.com/faisalman/ua-parser-js
|
4
4
|
Author: Faisal Salman <f@faisalman.com>
|
5
5
|
AGPLv3 License */
|
@@ -14,32 +14,73 @@ const VENDOR = 'vendor';
|
|
14
14
|
const VERSION = 'version';
|
15
15
|
const MOBILE = 'mobile';
|
16
16
|
const TABLET = 'tablet';
|
17
|
+
const CRAWLER = 'crawler';
|
18
|
+
const CLI = 'cli';
|
19
|
+
const EMAIL = 'email';
|
20
|
+
const FETCHER = 'fetcher';
|
21
|
+
const INAPP = 'inapp';
|
22
|
+
const MODULE = 'module';
|
17
23
|
|
18
|
-
|
24
|
+
//////////////////////
|
25
|
+
// COMMAND LINE APPS
|
26
|
+
/////////////////////
|
27
|
+
|
28
|
+
const CLIs = Object.freeze({
|
19
29
|
browser : [
|
20
|
-
|
30
|
+
// wget / curl / lynx
|
31
|
+
[/(wget|curl|lynx)[\/ ]([\w\.]+)/i], [NAME, VERSION, [TYPE, CLI]]
|
21
32
|
]
|
22
33
|
});
|
23
34
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
[/((?:google|bing|msn|facebook)bot(?:[\-imagevdo]{0,6})|bingpreview)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']],
|
35
|
+
////////////////////////
|
36
|
+
// CRAWLERS / SPIDERS
|
37
|
+
///////////////////////
|
28
38
|
|
39
|
+
const Crawlers = Object.freeze({
|
40
|
+
browser : [
|
41
|
+
// Amazonbot - https://developer.amazon.com/amazonbot
|
42
|
+
// Applebot - http://apple.com/go/applebot
|
43
|
+
// Bingbot - http://www.bing.com/bingbot.htm
|
44
|
+
// DuckDuckBot - http://duckduckgo.com/duckduckbot.html
|
45
|
+
// FacebookBot - https://developers.facebook.com/docs/sharing/bot/
|
29
46
|
// GPTBot - https://platform.openai.com/docs/gptbot
|
30
|
-
[/(
|
31
|
-
|
32
|
-
|
33
|
-
|
47
|
+
[/((?:amazon|apple|bing|duckduck|facebook|gpt)bot)\/([\w\.]+)/i],
|
48
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
49
|
+
|
50
|
+
// Baiduspider https://help.baidu.com/question?prod_id=99&class=0&id=3001
|
51
|
+
[/(baiduspider)[-imagevdonsfcpr]{0,6}\/([\w\.]+)/i],
|
52
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
53
|
+
|
54
|
+
// Bytespider
|
55
|
+
// Yahoo! Slurp - http://help.yahoo.com/help/us/ysearch/slurp
|
56
|
+
[/((?:bytespider|(?=yahoo! )slurp))/i],
|
57
|
+
[NAME, [TYPE, CRAWLER]],
|
58
|
+
|
59
|
+
// ClaudeBot
|
60
|
+
[/(claude(?:bot|-web))\/([\w\.]+)/i],
|
61
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
62
|
+
|
63
|
+
// Googlebot - http://www.google.com/bot.html
|
64
|
+
[
|
65
|
+
/(google(?:bot|other)(?:-image|-video|-news|-extended)?|(?:storebot-)?google(?:-inspectiontool)?)\/?([\w\.]*)/i
|
66
|
+
],
|
67
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
68
|
+
|
69
|
+
// Sogou Spider
|
70
|
+
[/(sogou (?:pic|head|web|orion|news) spider)\/([\w\.]+)/i],
|
71
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
72
|
+
|
73
|
+
// Yandex Bots - https://yandex.com/bots
|
74
|
+
[
|
75
|
+
/(yandex(?:(?:mobile)?(?:accessibility|additional|renderresources|screenshot|sprav)?bot|image(?:s|resizer)|video(?:parser)?|blogs|adnet|favicons|fordomain|market|media|metrika|news|ontodb(?:api)?|pagechecker|partner|rca|tracker|turbo|vertis|webmaster|antivirus))\/([\w\.]+)/i
|
76
|
+
],
|
77
|
+
[NAME, VERSION, [TYPE, CRAWLER]]
|
34
78
|
]
|
35
79
|
});
|
36
80
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
[/(wget|curl|lynx)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'cli']]
|
41
|
-
]
|
42
|
-
});
|
81
|
+
//////////////////
|
82
|
+
// EXTRA DEVICES
|
83
|
+
/////////////////
|
43
84
|
|
44
85
|
const ExtraDevices = Object.freeze({
|
45
86
|
device : [[
|
@@ -117,13 +158,63 @@ const ExtraDevices = Object.freeze({
|
|
117
158
|
]
|
118
159
|
});
|
119
160
|
|
161
|
+
///////////////
|
162
|
+
// EMAIL APPS
|
163
|
+
//////////////
|
164
|
+
|
120
165
|
const Emails = Object.freeze({
|
121
166
|
browser : [
|
122
|
-
|
123
|
-
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE,
|
167
|
+
// Microsoft Outlook / Thunderbird
|
168
|
+
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, EMAIL]]
|
124
169
|
]
|
125
170
|
});
|
126
171
|
|
172
|
+
///////////////////////
|
173
|
+
// ON-DEMAND SCRAPERS
|
174
|
+
//////////////////////
|
175
|
+
|
176
|
+
const Fetchers = Object.freeze({
|
177
|
+
browser : [
|
178
|
+
// BingPreview / Mastodon / Pinterestbot / Redditbot / Telegrambot / Twitterbot
|
179
|
+
[/(bingpreview|mastodon|(?:discord|linkedin|pinterest|reddit|telegram|twitter)bot)\/([\w\.]+)/i],
|
180
|
+
[NAME, VERSION, [TYPE, FETCHER]],
|
181
|
+
|
182
|
+
// Google Bots / Snapchat
|
183
|
+
[/(feedfetcher-google|google-read-aloud|(?=bot; )snapchat)/i],
|
184
|
+
[NAME, [TYPE, FETCHER]],
|
185
|
+
|
186
|
+
|
187
|
+
// Slackbot - https://api.slack.com/robots
|
188
|
+
[/(slack(?:bot)?(?:-imgproxy|-linkexpanding)?) ([\w\.]+)/i],
|
189
|
+
[NAME, VERSION, [TYPE, FETCHER]],
|
190
|
+
|
191
|
+
// WhatsApp
|
192
|
+
[/(whatsapp)\/([\w\.]+)[\/ ][ianw]/i],
|
193
|
+
[NAME, VERSION, [TYPE, FETCHER]],
|
194
|
+
|
195
|
+
// Yandex Bots - https://yandex.com/bots
|
196
|
+
[
|
197
|
+
/(yandex(?:calendar|direct(?:dyn)?|searchshop)|yadirectfetcher)\/([\w\.]+)/i,
|
198
|
+
/(yandex(?:sitelinks|userproxy))/i
|
199
|
+
],
|
200
|
+
[NAME, VERSION, [TYPE, FETCHER]]
|
201
|
+
]
|
202
|
+
});
|
203
|
+
|
204
|
+
////////////////////
|
205
|
+
// IN-APP BROWSERS
|
206
|
+
///////////////////
|
207
|
+
|
208
|
+
const InApps = Object.freeze({
|
209
|
+
browser : [
|
210
|
+
[/chatlyio\/([\d\.]+)/i], [VERSION, 'Slack', [TYPE, INAPP]]
|
211
|
+
]
|
212
|
+
});
|
213
|
+
|
214
|
+
//////////////////////
|
215
|
+
// MEDIA PLAYER APPS
|
216
|
+
/////////////////////
|
217
|
+
|
127
218
|
const MediaPlayers = Object.freeze({
|
128
219
|
browser : [[
|
129
220
|
|
@@ -230,19 +321,24 @@ const MediaPlayers = Object.freeze({
|
|
230
321
|
]
|
231
322
|
});
|
232
323
|
|
324
|
+
////////////////////////
|
325
|
+
// MODULES / LIBRARIES
|
326
|
+
///////////////////////
|
327
|
+
|
233
328
|
const Modules = Object.freeze({
|
234
329
|
browser : [
|
235
|
-
|
236
|
-
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE,
|
330
|
+
// Axios/jsdom/Scrapy
|
331
|
+
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, MODULE]]
|
237
332
|
]
|
238
333
|
});
|
239
334
|
|
240
335
|
module.exports = {
|
241
|
-
Apps,
|
242
|
-
Bots,
|
243
336
|
CLIs,
|
337
|
+
Crawlers,
|
244
338
|
ExtraDevices,
|
245
339
|
Emails,
|
340
|
+
Fetchers,
|
341
|
+
InApps,
|
246
342
|
MediaPlayers,
|
247
343
|
Modules
|
248
344
|
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
// Source: /src/extensions/ua-parser-extensions.js
|
4
4
|
|
5
5
|
///////////////////////////////////////////////
|
6
|
-
/* Extensions for UAParser.js v2.0.0-beta.
|
6
|
+
/* Extensions for UAParser.js v2.0.0-beta.3
|
7
7
|
https://github.com/faisalman/ua-parser-js
|
8
8
|
Author: Faisal Salman <f@faisalman.com>
|
9
9
|
AGPLv3 License */
|
@@ -18,32 +18,73 @@ const VENDOR = 'vendor';
|
|
18
18
|
const VERSION = 'version';
|
19
19
|
const MOBILE = 'mobile';
|
20
20
|
const TABLET = 'tablet';
|
21
|
+
const CRAWLER = 'crawler';
|
22
|
+
const CLI = 'cli';
|
23
|
+
const EMAIL = 'email';
|
24
|
+
const FETCHER = 'fetcher';
|
25
|
+
const INAPP = 'inapp';
|
26
|
+
const MODULE = 'module';
|
21
27
|
|
22
|
-
|
28
|
+
//////////////////////
|
29
|
+
// COMMAND LINE APPS
|
30
|
+
/////////////////////
|
31
|
+
|
32
|
+
const CLIs = Object.freeze({
|
23
33
|
browser : [
|
24
|
-
|
34
|
+
// wget / curl / lynx
|
35
|
+
[/(wget|curl|lynx)[\/ ]([\w\.]+)/i], [NAME, VERSION, [TYPE, CLI]]
|
25
36
|
]
|
26
37
|
});
|
27
38
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
[/((?:google|bing|msn|facebook)bot(?:[\-imagevdo]{0,6})|bingpreview)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']],
|
39
|
+
////////////////////////
|
40
|
+
// CRAWLERS / SPIDERS
|
41
|
+
///////////////////////
|
32
42
|
|
43
|
+
const Crawlers = Object.freeze({
|
44
|
+
browser : [
|
45
|
+
// Amazonbot - https://developer.amazon.com/amazonbot
|
46
|
+
// Applebot - http://apple.com/go/applebot
|
47
|
+
// Bingbot - http://www.bing.com/bingbot.htm
|
48
|
+
// DuckDuckBot - http://duckduckgo.com/duckduckbot.html
|
49
|
+
// FacebookBot - https://developers.facebook.com/docs/sharing/bot/
|
33
50
|
// GPTBot - https://platform.openai.com/docs/gptbot
|
34
|
-
[/(
|
35
|
-
|
36
|
-
|
37
|
-
|
51
|
+
[/((?:amazon|apple|bing|duckduck|facebook|gpt)bot)\/([\w\.]+)/i],
|
52
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
53
|
+
|
54
|
+
// Baiduspider https://help.baidu.com/question?prod_id=99&class=0&id=3001
|
55
|
+
[/(baiduspider)[-imagevdonsfcpr]{0,6}\/([\w\.]+)/i],
|
56
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
57
|
+
|
58
|
+
// Bytespider
|
59
|
+
// Yahoo! Slurp - http://help.yahoo.com/help/us/ysearch/slurp
|
60
|
+
[/((?:bytespider|(?=yahoo! )slurp))/i],
|
61
|
+
[NAME, [TYPE, CRAWLER]],
|
62
|
+
|
63
|
+
// ClaudeBot
|
64
|
+
[/(claude(?:bot|-web))\/([\w\.]+)/i],
|
65
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
66
|
+
|
67
|
+
// Googlebot - http://www.google.com/bot.html
|
68
|
+
[
|
69
|
+
/(google(?:bot|other)(?:-image|-video|-news|-extended)?|(?:storebot-)?google(?:-inspectiontool)?)\/?([\w\.]*)/i
|
70
|
+
],
|
71
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
72
|
+
|
73
|
+
// Sogou Spider
|
74
|
+
[/(sogou (?:pic|head|web|orion|news) spider)\/([\w\.]+)/i],
|
75
|
+
[NAME, VERSION, [TYPE, CRAWLER]],
|
76
|
+
|
77
|
+
// Yandex Bots - https://yandex.com/bots
|
78
|
+
[
|
79
|
+
/(yandex(?:(?:mobile)?(?:accessibility|additional|renderresources|screenshot|sprav)?bot|image(?:s|resizer)|video(?:parser)?|blogs|adnet|favicons|fordomain|market|media|metrika|news|ontodb(?:api)?|pagechecker|partner|rca|tracker|turbo|vertis|webmaster|antivirus))\/([\w\.]+)/i
|
80
|
+
],
|
81
|
+
[NAME, VERSION, [TYPE, CRAWLER]]
|
38
82
|
]
|
39
83
|
});
|
40
84
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
[/(wget|curl|lynx)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'cli']]
|
45
|
-
]
|
46
|
-
});
|
85
|
+
//////////////////
|
86
|
+
// EXTRA DEVICES
|
87
|
+
/////////////////
|
47
88
|
|
48
89
|
const ExtraDevices = Object.freeze({
|
49
90
|
device : [[
|
@@ -121,13 +162,63 @@ const ExtraDevices = Object.freeze({
|
|
121
162
|
]
|
122
163
|
});
|
123
164
|
|
165
|
+
///////////////
|
166
|
+
// EMAIL APPS
|
167
|
+
//////////////
|
168
|
+
|
124
169
|
const Emails = Object.freeze({
|
125
170
|
browser : [
|
126
|
-
|
127
|
-
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE,
|
171
|
+
// Microsoft Outlook / Thunderbird
|
172
|
+
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, EMAIL]]
|
128
173
|
]
|
129
174
|
});
|
130
175
|
|
176
|
+
///////////////////////
|
177
|
+
// ON-DEMAND SCRAPERS
|
178
|
+
//////////////////////
|
179
|
+
|
180
|
+
const Fetchers = Object.freeze({
|
181
|
+
browser : [
|
182
|
+
// BingPreview / Mastodon / Pinterestbot / Redditbot / Telegrambot / Twitterbot
|
183
|
+
[/(bingpreview|mastodon|(?:discord|linkedin|pinterest|reddit|telegram|twitter)bot)\/([\w\.]+)/i],
|
184
|
+
[NAME, VERSION, [TYPE, FETCHER]],
|
185
|
+
|
186
|
+
// Google Bots / Snapchat
|
187
|
+
[/(feedfetcher-google|google-read-aloud|(?=bot; )snapchat)/i],
|
188
|
+
[NAME, [TYPE, FETCHER]],
|
189
|
+
|
190
|
+
|
191
|
+
// Slackbot - https://api.slack.com/robots
|
192
|
+
[/(slack(?:bot)?(?:-imgproxy|-linkexpanding)?) ([\w\.]+)/i],
|
193
|
+
[NAME, VERSION, [TYPE, FETCHER]],
|
194
|
+
|
195
|
+
// WhatsApp
|
196
|
+
[/(whatsapp)\/([\w\.]+)[\/ ][ianw]/i],
|
197
|
+
[NAME, VERSION, [TYPE, FETCHER]],
|
198
|
+
|
199
|
+
// Yandex Bots - https://yandex.com/bots
|
200
|
+
[
|
201
|
+
/(yandex(?:calendar|direct(?:dyn)?|searchshop)|yadirectfetcher)\/([\w\.]+)/i,
|
202
|
+
/(yandex(?:sitelinks|userproxy))/i
|
203
|
+
],
|
204
|
+
[NAME, VERSION, [TYPE, FETCHER]]
|
205
|
+
]
|
206
|
+
});
|
207
|
+
|
208
|
+
////////////////////
|
209
|
+
// IN-APP BROWSERS
|
210
|
+
///////////////////
|
211
|
+
|
212
|
+
const InApps = Object.freeze({
|
213
|
+
browser : [
|
214
|
+
[/chatlyio\/([\d\.]+)/i], [VERSION, 'Slack', [TYPE, INAPP]]
|
215
|
+
]
|
216
|
+
});
|
217
|
+
|
218
|
+
//////////////////////
|
219
|
+
// MEDIA PLAYER APPS
|
220
|
+
/////////////////////
|
221
|
+
|
131
222
|
const MediaPlayers = Object.freeze({
|
132
223
|
browser : [[
|
133
224
|
|
@@ -234,19 +325,24 @@ const MediaPlayers = Object.freeze({
|
|
234
325
|
]
|
235
326
|
});
|
236
327
|
|
328
|
+
////////////////////////
|
329
|
+
// MODULES / LIBRARIES
|
330
|
+
///////////////////////
|
331
|
+
|
237
332
|
const Modules = Object.freeze({
|
238
333
|
browser : [
|
239
|
-
|
240
|
-
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE,
|
334
|
+
// Axios/jsdom/Scrapy
|
335
|
+
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, MODULE]]
|
241
336
|
]
|
242
337
|
});
|
243
338
|
|
244
339
|
export {
|
245
|
-
Apps,
|
246
|
-
Bots,
|
247
340
|
CLIs,
|
341
|
+
Crawlers,
|
248
342
|
ExtraDevices,
|
249
343
|
Emails,
|
344
|
+
Fetchers,
|
345
|
+
InApps,
|
250
346
|
MediaPlayers,
|
251
347
|
Modules
|
252
348
|
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
// Source: /src/helpers/ua-parser-helpers.js
|
4
4
|
|
5
5
|
///////////////////////////////////////////////
|
6
|
-
/* Helpers for UAParser.js v2.0.0-beta.
|
6
|
+
/* Helpers for UAParser.js v2.0.0-beta.3
|
7
7
|
https://github.com/faisalman/ua-parser-js
|
8
8
|
Author: Faisal Salman <f@faisalman.com>
|
9
9
|
AGPLv3 License */
|
package/src/main/ua-parser.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Type definitions for UAParser.js v2.0.0-beta.
|
1
|
+
// Type definitions for UAParser.js v2.0.0-beta.3
|
2
2
|
// Project: https://github.com/faisalman/ua-parser-js
|
3
3
|
// Definitions by: Faisal Salman <https://github.com/faisalman>
|
4
4
|
|
@@ -15,6 +15,7 @@ declare namespace UAParser {
|
|
15
15
|
name?: string;
|
16
16
|
version?: string;
|
17
17
|
major?: string;
|
18
|
+
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'module';
|
18
19
|
}
|
19
20
|
|
20
21
|
interface ICPU extends IData<ICPU> {
|
@@ -22,7 +23,7 @@ declare namespace UAParser {
|
|
22
23
|
}
|
23
24
|
|
24
25
|
interface IDevice extends IData<IDevice> {
|
25
|
-
type?: 'mobile' | 'tablet' | 'console' | 'smarttv' | 'wearable';
|
26
|
+
type?: 'mobile' | 'tablet' | 'console' | 'smarttv' | 'wearable' | 'xr' | 'embedded';
|
26
27
|
vendor?: string;
|
27
28
|
model?: string;
|
28
29
|
}
|
@@ -48,7 +49,7 @@ declare namespace UAParser {
|
|
48
49
|
|
49
50
|
type RegexMap = ((RegExp | string | (string | RegExp | Function)[])[])[];
|
50
51
|
type UAParserProps = 'browser' | 'cpu' | 'device' | 'engine' | 'os';
|
51
|
-
type UAParserExt = Partial<Record<UAParserProps, RegexMap
|
52
|
+
type UAParserExt = Partial<Record<UAParserProps, RegexMap>> | Partial<Record<UAParserProps, RegexMap>>[];
|
52
53
|
|
53
54
|
export function UAParser(uastring?: string, extensions?: UAParserExt, headers?: Record<string, string>): IResult;
|
54
55
|
export function UAParser(uastring?: string, headers?: Record<string, string>): IResult;
|
@@ -61,6 +62,7 @@ declare namespace UAParser {
|
|
61
62
|
NAME: 'name';
|
62
63
|
VERSION: 'version';
|
63
64
|
MAJOR: 'major';
|
65
|
+
TYPE: 'type';
|
64
66
|
};
|
65
67
|
static readonly CPU: {
|
66
68
|
ARCHITECTURE: 'architecture';
|
@@ -74,6 +76,7 @@ declare namespace UAParser {
|
|
74
76
|
SMARTTV: 'smarttv';
|
75
77
|
TABLET: 'tablet';
|
76
78
|
WEARABLE: 'wearable';
|
79
|
+
XR: 'xr';
|
77
80
|
EMBEDDED: 'embedded';
|
78
81
|
};
|
79
82
|
static readonly ENGINE: {
|