Skip to content

Commit

Permalink
Merge pull request #47 from mgroenhoff/typings
Browse files Browse the repository at this point in the history
Update typings
  • Loading branch information
hgoebl committed Nov 14, 2016
2 parents f9bc265 + 94fcf9a commit bbe2d48
Showing 1 changed file with 47 additions and 41 deletions.
88 changes: 47 additions & 41 deletions mobile-detect.d.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,9 @@

export interface MobileDetectRules {
[key: string]: string|RegExp;
}

export interface MobileDetectComplexRules {
[key: string]: string|RegExp|string[]|RegExp[];
}

export interface MobileDetectImpl {
mobileDetectRules: {
phones: MobileDetectRules;
tablets: MobileDetectRules;
oss: MobileDetectRules;
uas: MobileDetectRules;
props: MobileDetectComplexRules;
utils: MobileDetectRules;
};
detectMobileBrowsers: {
fullPattern: RegExp;
shortPattern: RegExp;
tabletPattern: RegExp;
};
FALLBACK_PHONE: string;
FALLBACK_TABLET: string;
FALLBACK_MOBILE: string;

findMatch(rules: MobileDetectRules, userAgent: string): string;
findMatches(rules: MobileDetectRules, userAgent: string): string[];
getVersionStr(propertyName: string, userAgent: string): string;
getVersion(propertyName: string, userAgent: string): number;
prepareVersionNo(version: string): number;
isMobileFallback(userAgent: string): boolean;
isTabletFallback(userAgent: string): boolean;
prepareDetectionCache(cache: Object, userAgent: string, maxPhoneWidth?: number): void;
mobileGrade(md: MobileDetect): string;
detectOS(userAgent: string): string;
getDeviceSmallerSide(): number;
}

export declare class MobileDetect {
declare class MobileDetect {
static version: string;
static isPhoneSized(maxPhoneWidth?: number): boolean;
// only used internally; if necessary, one can replace, intercept or augment particular methods or values
static _impl: MobileDetectImpl;
static _impl: MobileDetect.MobileDetectImpl;

constructor(userAgent: string, maxPhoneWidth?: number);

Expand All @@ -62,3 +23,48 @@ export declare class MobileDetect {
isPhoneSized(maxPhoneWidth?: number): boolean;
mobileGrade(): string;
}

declare namespace MobileDetect {
interface MobileDetectRules {
[key: string]: string|RegExp;
}

interface MobileDetectComplexRules {
[key: string]: string|RegExp|string[]|RegExp[];
}

interface MobileDetectImpl {
mobileDetectRules: {
phones: MobileDetectRules;
tablets: MobileDetectRules;
oss: MobileDetectRules;
uas: MobileDetectRules;
props: MobileDetectComplexRules;
utils: MobileDetectRules;
};
detectMobileBrowsers: {
fullPattern: RegExp;
shortPattern: RegExp;
tabletPattern: RegExp;
};
FALLBACK_PHONE: string;
FALLBACK_TABLET: string;
FALLBACK_MOBILE: string;

findMatch(rules: MobileDetectRules, userAgent: string): string;
findMatches(rules: MobileDetectRules, userAgent: string): string[];
getVersionStr(propertyName: string, userAgent: string): string;
getVersion(propertyName: string, userAgent: string): number;
prepareVersionNo(version: string): number;
isMobileFallback(userAgent: string): boolean;
isTabletFallback(userAgent: string): boolean;
prepareDetectionCache(cache: Object, userAgent: string, maxPhoneWidth?: number): void;
mobileGrade(md: MobileDetect): string;
detectOS(userAgent: string): string;
getDeviceSmallerSide(): number;
}
}

export = MobileDetect;

export as namespace MobileDetect;

0 comments on commit bbe2d48

Please sign in to comment.