package.src.main.ua-parser.d.ts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ua-parser-js Show documentation
Show all versions of ua-parser-js Show documentation
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent & Client Hints data. Supports browser & node.js environment
The newest version!
// Type definitions for UAParser.js v2.0.0
// Project: https://github.com/faisalman/ua-parser-js
// Definitions by: Faisal Salman
declare namespace UAParser {
interface IData {
is(val: string): boolean;
toString(): string;
withClientHints(): PromiseLike | T;
withFeatureCheck(): PromiseLike | T;
}
interface IBrowser extends IData {
name?: string;
version?: string;
major?: string;
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'library';
}
interface ICPU extends IData {
architecture?: 'ia32' | 'ia64' | 'amd64' | 'arm' | 'arm64' | 'armhf' | 'avr' | 'avr32' | 'irix' | 'irix64' | 'mips' | 'mips64' | '68k' | 'pa-risc' | 'ppc' | 'sparc' | 'sparc64';
}
interface IDevice extends IData {
type?: 'mobile' | 'tablet' | 'console' | 'smarttv' | 'wearable' | 'xr' | 'embedded';
vendor?: string;
model?: string;
}
interface IEngine extends IData {
name?: 'Amaya' | 'ArkWeb' | 'Blink' | 'EdgeHTML' | 'Flow' | 'Gecko' | 'Goanna' | 'iCab' | 'KHTML' | 'LibWeb' | 'Links' | 'Lynx' | 'NetFront' | 'NetSurf' | 'Presto' | 'Servo' | 'Tasman' | 'Trident' | 'w3m' | 'WebKit';
version?: string;
}
interface IOS extends IData {
name?: string;
version?: string;
}
interface IResult extends IData {
ua: string;
browser: IBrowser;
cpu: ICPU;
device: IDevice;
engine: IEngine;
os: IOS;
}
type RegexMap = ((RegExp | string | (string | RegExp | Function)[])[])[];
type UAParserProps = 'browser' | 'cpu' | 'device' | 'engine' | 'os';
type UAParserExt = Partial> | Partial>[];
export function UAParser(uastring?: string, extensions?: UAParserExt, headers?: Record): IResult;
export function UAParser(uastring?: string, headers?: Record): IResult;
export function UAParser(extensions?: UAParserExt, headers?: Record): IResult;
export function UAParser(headers?: Record): IResult;
export class UAParser {
static readonly BROWSER: {
NAME: 'name';
VERSION: 'version';
MAJOR: 'major';
TYPE: 'type';
};
static readonly CPU: {
ARCHITECTURE: 'architecture';
};
static readonly DEVICE: {
TYPE: 'type';
VENDOR: 'vendor';
MODEL: 'model';
CONSOLE: 'console';
MOBILE: 'mobile';
SMARTTV: 'smarttv';
TABLET: 'tablet';
WEARABLE: 'wearable';
XR: 'xr';
EMBEDDED: 'embedded';
};
static readonly ENGINE: {
NAME: 'name';
VERSION: 'version';
};
static readonly OS: {
NAME: 'name';
VERSION: 'version';
};
static readonly VERSION: string;
constructor(uastring?: string, extensions?: UAParserExt, headers?: Record);
constructor(uastring?: string, headers?: Record);
constructor(extensions?: UAParserExt, headers?: Record);
constructor(headers?: Record);
getUA(): string;
getBrowser(): IBrowser;
getCPU(): ICPU;
getDevice(): IDevice;
getEngine(): IEngine;
getOS(): IOS;
getResult(): IResult;
setUA(uastring: string): UAParser;
}
}
export as namespace UAParser;
export = UAParser;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy