AK-21/Graphite-Industrial-Intelligence
0
1/**2 * Return array of browsers by selection queries.3 *4 * ```js5 * browserslist('IE >= 10, IE 8') //=> ['ie 11', 'ie 10', 'ie 8']6 * ```7 *8 * @param queries Browser queries.9 * @param opts Options.10 * @returns Array with browser names in Can I Use.11 */12declare function browserslist(13 queries?: string | readonly string[] | null,14 opts?: browserslist.Options15): string[]16 17declare namespace browserslist {18 interface Query {19 compose: 'or' | 'and'20 type: string21 query: string22 not?: true23 }24 25 interface Options {26 /**27 * Path to processed file. It will be used to find config files.28 */29 path?: string | false30 /**31 * Processing environment. It will be used to take right queries32 * from config file.33 */34 env?: string35 /**36 * Custom browser usage statistics for "> 1% in my stats" query.37 */38 stats?: Stats | string39 /**40 * Path to config file with queries.41 */42 config?: string43 /**44 * Do not throw on unknown version in direct query.45 */46 ignoreUnknownVersions?: boolean47 /**48 * Throw an error if env is not found.49 */50 throwOnMissing?: boolean51 /**52 * Disable security checks for extend query.53 */54 dangerousExtend?: boolean55 /**56 * Alias mobile browsers to the desktop version when Can I Use57 * doesn’t have data about the specified version.58 */59 mobileToDesktop?: boolean60 }61 62 type Config = {63 defaults: string[]64 [section: string]: string[] | undefined65 }66 67 interface Stats {68 [browser: string]: {69 [version: string]: number70 }71 }72 73 /**74 * Browser names aliases.75 */76 let aliases: {77 [alias: string]: string | undefined78 }79 80 /**81 * Aliases to work with joined versions like `ios_saf 7.0-7.1`.82 */83 let versionAliases: {84 [browser: string]:85 | {86 [version: string]: string | undefined87 }88 | undefined89 }90 91 /**92 * Can I Use only provides a few versions for some browsers (e.g. `and_chr`).93 *94 * Fallback to a similar browser for unknown versions.95 */96 let desktopNames: {97 [browser: string]: string | undefined98 }99 100 let data: {101 [browser: string]:102 | {103 name: string104 versions: string[]105 released: string[]106 releaseDate: {107 [version: string]: number | undefined | null108 }109 }110 | undefined111 }112 113 let nodeVersions: string[]114 115 interface Usage {116 [version: string]: number117 }118 119 let usage: {120 global?: Usage121 custom?: Usage | null122 [country: string]: Usage | undefined | null123 }124 125 let cache: {126 [feature: string]: {127 [name: string]: {128 [version: string]: string129 }130 }131 }132 133 /**134 * Default browsers query135 */136 let defaults: readonly string[]137 138 /**139 * Which statistics should be used. Country code or custom statistics.140 * Pass `"my stats"` to load statistics from `Browserslist` files.141 */142 type StatsOptions = string | 'my stats' | Stats | { dataByBrowser: Stats }143 144 /**145 * Return browsers market coverage.146 *147 * ```js148 * browserslist.coverage(browserslist('> 1% in US'), 'US') //=> 83.1149 * ```150 *151 * @param browsers Browsers names in Can I Use.152 * @param stats Which statistics should be used.153 * @returns Total market coverage for all selected browsers.154 */155 function coverage(browsers: readonly string[], stats?: StatsOptions): number156 157 /**158 * Get queries AST to analyze the config content.159 *160 * @param queries Browser queries.161 * @param opts Options.162 * @returns An array of the data of each query in the config.163 */164 function parse(165 queries?: string | readonly string[] | null,166 opts?: browserslist.Options167 ): Query[]168 169 /**170 * Return queries for specific file inside the project.171 *172 * ```js173 * browserslist.loadConfig({174 * file: process.cwd()175 * }) ?? browserslist.defaults176 * ```177 */178 function loadConfig(options: LoadConfigOptions): string[] | undefined179 180 function clearCaches(): void181 182 function parseConfig(string: string): Config183 184 function readConfig(file: string): Config185 186 function findConfig(...pathSegments: string[]): Config | undefined187 188 function findConfigFile(...pathSegments: string[]): string | undefined189 190 interface LoadConfigOptions {191 /**192 * Path to config file193 * */194 config?: string195 196 /**197 * Path to file inside the project to find Browserslist config198 * in closest folder199 */200 path?: string201 202 /**203 * Environment to choose part of config.204 */205 env?: string206 }207}208 209declare global {210 namespace NodeJS {211 interface ProcessEnv {212 BROWSERSLIST?: string213 BROWSERSLIST_CONFIG?: string214 BROWSERSLIST_DANGEROUS_EXTEND?: string215 BROWSERSLIST_DISABLE_CACHE?: string216 BROWSERSLIST_ENV?: string217 BROWSERSLIST_IGNORE_OLD_DATA?: string218 BROWSERSLIST_STATS?: string219 BROWSERSLIST_ROOT_PATH?: string220 }221 }222}223 224export = browserslist225 