bowser: Provides its own types (#22381)

This commit is contained in:
Andy
2017-12-21 07:38:43 -08:00
committed by GitHub
parent 5efc5fd329
commit d530396c4a
5 changed files with 6 additions and 143 deletions
+6
View File
@@ -120,6 +120,12 @@
"sourceRepoURL": "https://github.com/peterolson/BigInteger.js",
"asOfVersion": "0.0.31"
},
{
"libraryName": "Bowser",
"typingsPackageName": "bowser",
"sourceRepoURL": "https://github.com/ded/bowser",
"asOfVersion": "1.1.1"
},
{
"libraryName": "Bugsnag Browser",
"typingsPackageName": "bugsnag-js",
-11
View File
@@ -1,11 +0,0 @@
bowser.msedge; // $ExpectType boolean
bowser.test(['msie']); // $ExpectType boolean
bowser.a === bowser.c;
bowser.osversion > 10;
bowser.osversion === '10.1A';
bowser.compareVersions(['9.0', '10']);
bowser().android; // $ExpectType boolean
bowser().x; // $ExpectType boolean
bowser.check({msie: "11"}, window.navigator.userAgent);
bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent);
-101
View File
@@ -1,101 +0,0 @@
// Type definitions for Bowser 1.x
// Project: https://github.com/ded/bowser
// Definitions by: Paulo Cesar <https://github.com/pocesar>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare const bowser: bowser.IBowser;
export = bowser;
export as namespace bowser;
declare namespace bowser {
interface IBowserOS {
mac: boolean;
/** other than Windows Phone */
windows: boolean;
windowsphone: boolean;
/** other than android, chromeos, webos, tizen, and sailfish */
linux: boolean;
chromeos: boolean;
android: boolean;
/** also sets one of iphone/ipad/ipod */
ios: boolean;
blackberry: boolean;
firefoxos: boolean;
/** may also set touchpad */
webos: boolean;
bada: boolean;
tizen: boolean;
sailfish: boolean;
}
interface IBowserVersions {
chrome: boolean;
firefox: boolean;
msie: boolean;
msedge: boolean;
safari: boolean;
android: boolean;
ios: boolean;
opera: boolean;
phantom: boolean;
blackberry: boolean;
webos: boolean;
silk: boolean;
bada: boolean;
tizen: boolean;
seamonkey: boolean;
sailfish: boolean;
ucbrowser: boolean;
qupzilla: boolean;
vivaldi: boolean;
sleipnir: boolean;
kMeleon: boolean;
}
interface IBowserEngines {
/** IE <= 11 */
msie: boolean;
/** Chrome 0-27, Android <4.4, iOs, BB, etc. */
webkit: boolean;
/** Chrome >=28, Android >=4.4, Opera, etc. */
blink: boolean;
/** Firefox, etc. */
gecko: boolean;
/** IE > 11 */
msedge: boolean;
/** If a tablet device is detected, the flag tablet is set instead of mobile. */
tablet: boolean;
/** All detected mobile OSes are additionally flagged mobile, unless it's a tablet */
mobile: boolean;
}
interface IBowserGrade {
/** Grade A browser */
a: boolean;
/** Grade C browser */
c: boolean;
/** Grade X browser */
x: boolean;
/** A human readable name for this browser. E.g. 'Chrome', '' */
name: string;
/** Version number for the browser. E.g. '32.0' */
version: string | number;
osversion: string | number;
}
interface IBowserDetection extends IBowserGrade, IBowserEngines, IBowserOS, IBowserVersions { }
interface IBowserMinVersions {
// { msie: "11", "firefox": "4" }
[index: string]: string;
}
interface IBowser extends IBowserDetection {
(): IBowserDetection;
test(browserList: string[]): boolean;
_detect(ua: string): IBowser;
compareVersions(versions: string[]): number;
check(minVersions: IBowserMinVersions, strictMode?: boolean | string, ua?: string): boolean;
isUnsupportedBrowser(minVersions: IBowserMinVersions, strictMode?: boolean | string, ua?: string): boolean;
}
}
-24
View File
@@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bowser-tests.ts"
]
}
-7
View File
@@ -1,7 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"interface-name": false
}
}