UNPKG

5.52 kBTypeScriptView Raw
1declare namespace UAParser {
2 // tslint:disable:interface-name backward compatible exclusion
3
4 interface IBrowser {
5 /**
6 * Possible values :
7 * Amaya, Android Browser, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome,
8 * Chromium, Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Edge, Epiphany, Fennec,
9 * Firebird, Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, IceDragon,
10 * Iceweasel, IE [Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle, Links,
11 * Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, MIUI Browser, [Mobile] Safari,
12 * Mosaic, Mozilla, Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet],
13 * Phoenix, Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox,
14 * Tizen, UCBrowser, Vivaldi, w3m, Yandex
15 */
16 name: string | undefined;
17
18 /**
19 * Determined dynamically
20 */
21 version: string | undefined;
22
23 /**
24 * Determined dynamically
25 * @deprecated
26 */
27 major: string | undefined;
28 }
29
30 interface IDevice {
31 /**
32 * Determined dynamically
33 */
34 model: string | undefined;
35
36 /**
37 * Possible type:
38 * console, mobile, tablet, smarttv, wearable, embedded
39 */
40 type: string | undefined;
41
42 /**
43 * Possible vendor:
44 * Acer, Alcatel, Amazon, Apple, Archos, Asus, BenQ, BlackBerry, Dell, GeeksPhone,
45 * Google, HP, HTC, Huawei, Jolla, Lenovo, LG, Meizu, Microsoft, Motorola, Nexian,
46 * Nintendo, Nokia, Nvidia, Ouya, Palm, Panasonic, Polytron, RIM, Samsung, Sharp,
47 * Siemens, Sony-Ericsson, Sprint, Xbox, ZTE
48 */
49 vendor: string | undefined;
50 }
51
52 interface IEngine {
53 /**
54 * Possible name:
55 * Amaya, EdgeHTML, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto,
56 * Tasman, Trident, w3m, WebKit
57 */
58 name: string | undefined;
59 /**
60 * Determined dynamically
61 */
62 version: string | undefined;
63 }
64
65 interface IOS {
66 /**
67 * Possible 'os.name'
68 * AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS, Contiki,
69 * Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Gentoo, GNU, Haiku, Hurd, iOS,
70 * Joli, Linpus, Linux, Mac OS, Mageia, Mandriva, MeeGo, Minix, Mint, Morph OS, NetBSD,
71 * Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PCLinuxOS, Plan9, Playstation, QNX, RedHat,
72 * RIM Tablet OS, RISC OS, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen,
73 * Ubuntu, UNIX, VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk
74 */
75 name: string | undefined;
76 /**
77 * Determined dynamically
78 */
79 version: string | undefined;
80 }
81
82 interface ICPU {
83 /**
84 * Possible architecture:
85 * 68k, amd64, arm, arm64, avr, ia32, ia64, irix, irix64, mips, mips64, pa-risc,
86 * ppc, sparc, sparc64
87 */
88 architecture: string | undefined;
89 }
90
91 interface IResult {
92 ua: string;
93 browser: IBrowser;
94 device: IDevice;
95 engine: IEngine;
96 os: IOS;
97 cpu: ICPU;
98 }
99
100 interface BROWSER {
101 NAME: "name";
102 /**
103 * @deprecated
104 */
105 MAJOR: "major";
106 VERSION: "version";
107 }
108
109 interface CPU {
110 ARCHITECTURE: "architecture";
111 }
112
113 interface DEVICE {
114 MODEL: "model";
115 VENDOR: "vendor";
116 TYPE: "type";
117 CONSOLE: "console";
118 MOBILE: "mobile";
119 SMARTTV: "smarttv";
120 TABLET: "tablet";
121 WEARABLE: "wearable";
122 EMBEDDED: "embedded";
123 }
124
125 interface ENGINE {
126 NAME: "name";
127 VERSION: "version";
128 }
129
130 interface OS {
131 NAME: "name";
132 VERSION: "version";
133 }
134
135 interface UAParserInstance {
136 /**
137 * Returns browser information
138 */
139 getBrowser(): IBrowser;
140
141 /**
142 * Returns OS information
143 */
144 getOS(): IOS;
145
146 /**
147 * Returns browsers engine information
148 */
149 getEngine(): IEngine;
150
151 /**
152 * Returns device information
153 */
154 getDevice(): IDevice;
155
156 /**
157 * Returns parsed CPU information
158 */
159 getCPU(): ICPU;
160
161 /**
162 * Returns UA string of current instance
163 */
164 getUA(): string;
165
166 /**
167 * Set & parse UA string
168 */
169 setUA(uastring: string): UAParserInstance;
170
171 /**
172 * Returns parse result
173 */
174 getResult(): IResult;
175 }
176}
177
178type UAParser = UAParser.UAParserInstance;
179
180declare const UAParser: {
181 VERSION: string;
182 BROWSER: UAParser.BROWSER;
183 CPU: UAParser.CPU;
184 DEVICE: UAParser.DEVICE;
185 ENGINE: UAParser.ENGINE;
186 OS: UAParser.OS;
187
188 /**
189 * Create a new parser with UA prepopulated and extensions extended
190 */
191 new(uastring?: string, extensions?: Record<string, unknown>): UAParser.UAParserInstance;
192 new(extensions?: Record<string, unknown>): UAParser.UAParserInstance;
193 (uastring?: string, extensions?: Record<string, unknown>): UAParser.IResult;
194 (extensions?: Record<string, unknown>): UAParser.IResult;
195
196 // alias for older syntax
197 UAParser: typeof UAParser;
198};
199
200export as namespace UAParser;
201export = UAParser;