typings.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Type definitions for Bowser 1.x
  2. // Project: https://github.com/lancedikson/bowser
  3. // Definitions by: Paulo Cesar <https://github.com/pocesar>
  4. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  5. declare const bowser: bowser.IBowser;
  6. export = bowser;
  7. export as namespace bowser;
  8. declare namespace bowser {
  9. export interface IBowserPlatform {
  10. ipad: boolean;
  11. ipod: boolean;
  12. iphone: boolean;
  13. /** If a tablet device is detected, the flag tablet is set instead of mobile. */
  14. tablet: boolean;
  15. /** All detected mobile OSes are additionally flagged mobile, unless it's a tablet */
  16. mobile: boolean;
  17. }
  18. export interface IBowserOS {
  19. mac: boolean;
  20. /**other than Windows Phone */
  21. windows: boolean;
  22. windowsphone: boolean;
  23. /**other than android, chromeos, webos, tizen, and sailfish */
  24. linux: boolean;
  25. chromeos: boolean;
  26. android: boolean;
  27. /** also sets one of iphone/ipad/ipod */
  28. ios: boolean;
  29. blackberry: boolean;
  30. firefoxos: boolean;
  31. /** may also set touchpad */
  32. webos: boolean;
  33. bada: boolean;
  34. tizen: boolean;
  35. sailfish: boolean;
  36. }
  37. export interface IBowserVersions {
  38. chrome: boolean;
  39. chromium: boolean;
  40. firefox: boolean;
  41. msie: boolean;
  42. msedge: boolean;
  43. safari: boolean;
  44. android: boolean;
  45. ios: boolean;
  46. opera: boolean;
  47. samsungBrowser: boolean;
  48. phantom: boolean;
  49. blackberry: boolean;
  50. webos: boolean;
  51. silk: boolean;
  52. bada: boolean;
  53. tizen: boolean;
  54. seamonkey: boolean;
  55. sailfish: boolean;
  56. ucbrowser: boolean;
  57. qupzilla: boolean;
  58. vivaldi: boolean;
  59. sleipnir: boolean;
  60. kMeleon: boolean;
  61. whale: boolean;
  62. }
  63. export interface IBowserEngines {
  64. /** IE <= 11 */
  65. msie: boolean;
  66. /**Chrome 0-27, Android <4.4, iOs, BB, etc. */
  67. webkit: boolean;
  68. /**Chrome >=28, Android >=4.4, Opera, etc. */
  69. blink: boolean;
  70. /**Firefox, etc. */
  71. gecko: boolean;
  72. /** IE > 11 */
  73. msedge: boolean;
  74. }
  75. export interface IBowserGrade {
  76. /** Grade A browser */
  77. a: boolean;
  78. /** Grade C browser */
  79. c: boolean;
  80. /** Grade X browser */
  81. x: boolean;
  82. /** A human readable name for this browser. E.g. 'Chrome', '' */
  83. name: string;
  84. /** Version number for the browser. E.g. '32.0' */
  85. version: string|number;
  86. /** Name for this operating system. E.g. 'macOS' */
  87. osname: string;
  88. /** Version number for this operating system. E.g. '10.12.6' */
  89. osversion: string|number;
  90. }
  91. export interface IBowserDetection extends IBowserGrade, IBowserEngines, IBowserOS, IBowserVersions, IBowserPlatform { }
  92. export interface IBowserMinVersions {
  93. // { msie: "11", "firefox": "4" }
  94. [index: string]: string;
  95. }
  96. export interface IBowser extends IBowserDetection {
  97. (): IBowserDetection;
  98. test(browserList: string[]): boolean;
  99. _detect(ua: string): IBowser;
  100. detect(ua: string): IBowser;
  101. compareVersions(versions: string[]): number;
  102. check(minVersions: IBowserMinVersions, strictMode?: boolean|string, ua?: string): Boolean;
  103. isUnsupportedBrowser(minVersions: IBowserMinVersions, strictMode?: boolean|string, ua?: string): boolean;
  104. }
  105. }