index.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. type BrowserVersion = {
  2. browser: string;
  3. version: string;
  4. release_date?: string;
  5. engine?: string;
  6. engine_version?: string;
  7. };
  8. interface AllBrowsersBrowserVersion extends BrowserVersion {
  9. year: number | string;
  10. supports?: string;
  11. wa_compatible?: boolean;
  12. }
  13. type NestedBrowserVersions = {
  14. [browser: string]: {
  15. [version: string]: AllBrowsersBrowserVersion;
  16. };
  17. };
  18. type Options = {
  19. /**
  20. * Whether to include only the minimum compatible browser versions or all compatible versions.
  21. * Defaults to `false`.
  22. */
  23. listAllCompatibleVersions?: boolean;
  24. /**
  25. * Whether to include browsers that use the same engines as a core Baseline browser.
  26. * Defaults to `false`.
  27. */
  28. includeDownstreamBrowsers?: boolean;
  29. /**
  30. * Pass a date in the format 'YYYY-MM-DD' to get versions compatible with Widely available on the specified date.
  31. * If left undefined and a `targetYear` is not passed, defaults to Widely available as of the current date.
  32. * > NOTE: cannot be used with `targetYear`.
  33. */
  34. widelyAvailableOnDate?: string | number;
  35. /**
  36. * Pass a year between 2015 and the current year to get browser versions compatible with all
  37. * Newly Available features as of the end of the year specified.
  38. * > NOTE: cannot be used with `widelyAvailableOnDate`.
  39. */
  40. targetYear?: number;
  41. /**
  42. * Pass a boolean that determines whether KaiOS is included in browser mappings. KaiOS implements
  43. * the Gecko engine used in Firefox. However, KaiOS also has a different interaction paradigm to
  44. * other browsers and requires extra consideration beyond simple feature compatibility to provide
  45. * an optimal user experience. Defaults to `false`.
  46. */
  47. includeKaiOS?: boolean;
  48. };
  49. /**
  50. * Returns browser versions compatible with specified Baseline targets.
  51. * Defaults to returning the minimum versions of the core browser set that support Baseline Widely available.
  52. * Takes an optional configuration `Object` with four optional properties:
  53. * - `listAllCompatibleVersions`: `false` (default) or `false`
  54. * - `includeDownstreamBrowsers`: `false` (default) or `false`
  55. * - `widelyAvailableOnDate`: date in format `YYYY-MM-DD`
  56. * - `targetYear`: year in format `YYYY`
  57. */
  58. export declare function getCompatibleVersions(userOptions?: Options): BrowserVersion[];
  59. type AllVersionsOptions = {
  60. /**
  61. * Whether to return the output as a JavaScript `Array` (`"array"`), `Object` (`"object"`) or a CSV string (`"csv"`).
  62. * Defaults to `"array"`.
  63. */
  64. outputFormat?: string;
  65. /**
  66. * Whether to include browsers that use the same engines as a core Baseline browser.
  67. * Defaults to `false`.
  68. */
  69. includeDownstreamBrowsers?: boolean;
  70. /**
  71. * Whether to use the new "supports" property in place of "wa_compatible"
  72. * Defaults to `false`
  73. */
  74. useSupports?: boolean;
  75. /**
  76. * Whether to include KaiOS in the output. KaiOS implements the Gecko engine used in Firefox.
  77. * However, KaiOS also has a different interaction paradigm to other browsers and requires extra
  78. * consideration beyond simple feature compatibility to provide an optimal user experience.
  79. */
  80. includeKaiOS?: boolean;
  81. };
  82. /**
  83. * Returns all browser versions known to this module with their level of Baseline support as a JavaScript `Array` (`"array"`), `Object` (`"object"`) or a CSV string (`"csv"`).
  84. * Takes an optional configuration `Object` with three optional properties:
  85. * - `includeDownstreamBrowsers`: `true` (default) or `false`
  86. * - `outputFormat`: `"array"` (default), `"object"` or `"csv"`
  87. * - `useSupports`: `false` (default) or `true`, replaces `wa_compatible` property with optional `supports` property which returns `widely` or `newly` available when present.
  88. */
  89. export declare function getAllVersions(userOptions?: AllVersionsOptions): AllBrowsersBrowserVersion[] | NestedBrowserVersions | string;
  90. export {};