Innovenergy_trunk/frontend/node_modules/@babel/helper-compilation-targets/lib/index.js.map

1 line
16 KiB
Plaintext

{"version":3,"names":["ESM_SUPPORT","browserModulesData","v","OptionValidator","validateTargetNames","targets","validTargets","Object","keys","TargetNames","target","Error","formatMessage","findSuggestion","isBrowsersQueryValid","browsers","Array","isArray","every","b","validateBrowsers","invariant","undefined","String","getLowestVersions","reduce","all","browser","browserName","browserVersion","split","browserNameMap","splitVersion","toLowerCase","isSplitUnreleased","isUnreleasedVersion","semverify","version","isUnreleased","getLowestUnreleased","parsedBrowserVersion","semverMin","e","outputDecimalWarning","decimalTargets","length","console","warn","forEach","value","semverifyTarget","error","nodeTargetParser","parsed","process","versions","node","defaultTargetParser","generateTargets","inputTargets","input","esmodules","resolveTargets","queries","env","resolved","browserslist","mobileToDesktop","targetsCache","LruCache","max","resolveTargetsCached","cacheKey","join","cached","get","set","getTargets","options","configPath","shouldParseBrowsers","hasTargets","shouldSearchForConfig","ignoreBrowserslistConfig","loadConfig","config","configFile","path","browserslistEnv","map","queryBrowsers","esmSupportVersion","getHighestUnreleased","assign","result","decimalWarnings","sort","push","parsedTarget","parsedValue"],"sources":["../src/index.ts"],"sourcesContent":["import browserslist from \"browserslist\";\nimport { findSuggestion } from \"@babel/helper-validator-option\";\nimport browserModulesData from \"@babel/compat-data/native-modules\";\nimport LruCache from \"lru-cache\";\n\nimport {\n semverify,\n semverMin,\n isUnreleasedVersion,\n getLowestUnreleased,\n getHighestUnreleased,\n} from \"./utils\";\nimport { OptionValidator } from \"@babel/helper-validator-option\";\nimport { browserNameMap } from \"./targets\";\nimport { TargetNames } from \"./options\";\nimport type {\n Target,\n Targets,\n InputTargets,\n Browsers,\n BrowserslistBrowserName,\n TargetsTuple,\n} from \"./types\";\n\nexport type { Target, Targets, InputTargets };\n\nexport { prettifyTargets } from \"./pretty\";\nexport { getInclusionReasons } from \"./debug\";\nexport { default as filterItems, isRequired } from \"./filter-items\";\nexport { unreleasedLabels } from \"./targets\";\nexport { TargetNames };\n\nconst ESM_SUPPORT = browserModulesData[\"es6.module\"];\n\ndeclare const PACKAGE_JSON: { name: string; version: string };\nconst v = new OptionValidator(PACKAGE_JSON.name);\n\nfunction validateTargetNames(targets: Targets): TargetsTuple {\n const validTargets = Object.keys(TargetNames);\n for (const target of Object.keys(targets)) {\n if (!(target in TargetNames)) {\n throw new Error(\n v.formatMessage(`'${target}' is not a valid target\n- Did you mean '${findSuggestion(target, validTargets)}'?`),\n );\n }\n }\n\n return targets;\n}\n\nexport function isBrowsersQueryValid(browsers: unknown): boolean {\n return (\n typeof browsers === \"string\" ||\n (Array.isArray(browsers) && browsers.every(b => typeof b === \"string\"))\n );\n}\n\nfunction validateBrowsers(browsers: Browsers | undefined) {\n v.invariant(\n browsers === undefined || isBrowsersQueryValid(browsers),\n `'${String(browsers)}' is not a valid browserslist query`,\n );\n\n return browsers;\n}\n\nfunction getLowestVersions(browsers: Array<string>): Targets {\n return browsers.reduce((all, browser) => {\n const [browserName, browserVersion] = browser.split(\" \") as [\n BrowserslistBrowserName,\n string,\n ];\n const target = browserNameMap[browserName];\n\n if (!target) {\n return all;\n }\n\n try {\n // Browser version can return as \"10.0-10.2\"\n const splitVersion = browserVersion.split(\"-\")[0].toLowerCase();\n const isSplitUnreleased = isUnreleasedVersion(splitVersion, target);\n\n if (!all[target]) {\n all[target] = isSplitUnreleased\n ? splitVersion\n : semverify(splitVersion);\n return all;\n }\n\n const version = all[target];\n const isUnreleased = isUnreleasedVersion(version, target);\n\n if (isUnreleased && isSplitUnreleased) {\n all[target] = getLowestUnreleased(version, splitVersion, target);\n } else if (isUnreleased) {\n all[target] = semverify(splitVersion);\n } else if (!isUnreleased && !isSplitUnreleased) {\n const parsedBrowserVersion = semverify(splitVersion);\n\n all[target] = semverMin(version, parsedBrowserVersion);\n }\n } catch (e) {}\n\n return all;\n }, {} as Record<Target, string>);\n}\n\nfunction outputDecimalWarning(\n decimalTargets: Array<{ target: string; value: number }>,\n) {\n if (!decimalTargets.length) {\n return;\n }\n\n console.warn(\"Warning, the following targets are using a decimal version:\\n\");\n decimalTargets.forEach(({ target, value }) =>\n console.warn(` ${target}: ${value}`),\n );\n console.warn(`\nWe recommend using a string for minor/patch versions to avoid numbers like 6.10\ngetting parsed as 6.1, which can lead to unexpected behavior.\n`);\n}\n\nfunction semverifyTarget(target: Target, value: string) {\n try {\n return semverify(value);\n } catch (error) {\n throw new Error(\n v.formatMessage(\n `'${value}' is not a valid value for 'targets.${target}'.`,\n ),\n );\n }\n}\n\n// Parse `node: true` and `node: \"current\"` to version\nfunction nodeTargetParser(value: true | string) {\n const parsed =\n value === true || value === \"current\"\n ? process.versions.node\n : semverifyTarget(\"node\", value);\n return [\"node\", parsed] as const;\n}\n\nfunction defaultTargetParser(\n target: Exclude<Target, \"node\">,\n value: string,\n): readonly [Exclude<Target, \"node\">, string] {\n const version = isUnreleasedVersion(value, target)\n ? value.toLowerCase()\n : semverifyTarget(target, value);\n return [target, version] as const;\n}\n\nfunction generateTargets(inputTargets: InputTargets): Targets {\n const input = { ...inputTargets };\n delete input.esmodules;\n delete input.browsers;\n return input;\n}\n\nfunction resolveTargets(queries: Browsers, env?: string): Targets {\n const resolved = browserslist(queries, {\n mobileToDesktop: true,\n env,\n });\n return getLowestVersions(resolved);\n}\n\nconst targetsCache = new LruCache({ max: 64 });\n\nfunction resolveTargetsCached(queries: Browsers, env?: string): Targets {\n const cacheKey = typeof queries === \"string\" ? queries : queries.join() + env;\n let cached = targetsCache.get(cacheKey) as Targets | undefined;\n if (!cached) {\n cached = resolveTargets(queries, env);\n targetsCache.set(cacheKey, cached);\n }\n return { ...cached };\n}\n\ntype GetTargetsOption = {\n // This is not the path of the config file, but the path where start searching it from\n configPath?: string;\n // The path of the config file\n configFile?: string;\n // The env to pass to browserslist\n browserslistEnv?: string;\n // true to disable config loading\n ignoreBrowserslistConfig?: boolean;\n};\n\nexport default function getTargets(\n inputTargets: InputTargets = {},\n options: GetTargetsOption = {},\n): Targets {\n let { browsers, esmodules } = inputTargets;\n const { configPath = \".\" } = options;\n\n validateBrowsers(browsers);\n\n const input = generateTargets(inputTargets);\n let targets = validateTargetNames(input);\n\n const shouldParseBrowsers = !!browsers;\n const hasTargets = shouldParseBrowsers || Object.keys(targets).length > 0;\n const shouldSearchForConfig =\n !options.ignoreBrowserslistConfig && !hasTargets;\n\n if (!browsers && shouldSearchForConfig) {\n browsers = browserslist.loadConfig({\n config: options.configFile,\n path: configPath,\n env: options.browserslistEnv,\n });\n if (browsers == null) {\n if (process.env.BABEL_8_BREAKING) {\n // In Babel 8, if no targets are passed, we use browserslist's defaults\n // and exclude IE 11.\n browsers = [\"defaults, not ie 11\"];\n } else {\n // If no targets are passed, we need to overwrite browserslist's defaults\n // so that we enable all transforms (acting like the now deprecated\n // preset-latest).\n browsers = [];\n }\n }\n }\n\n // `esmodules` as a target indicates the specific set of browsers supporting ES Modules.\n // These values OVERRIDE the `browsers` field.\n if (esmodules && (esmodules !== \"intersect\" || !browsers?.length)) {\n browsers = Object.keys(ESM_SUPPORT)\n .map(\n (browser: keyof typeof ESM_SUPPORT) =>\n `${browser} >= ${ESM_SUPPORT[browser]}`,\n )\n .join(\", \");\n esmodules = false;\n }\n\n // If current value of `browsers` is undefined (`ignoreBrowserslistConfig` should be `false`)\n // or an empty array (without any user config, use default config),\n // we don't need to call `resolveTargets` to execute the related methods of `browserslist` library.\n if (browsers?.length) {\n const queryBrowsers = resolveTargetsCached(\n browsers,\n options.browserslistEnv,\n );\n\n if (esmodules === \"intersect\") {\n for (const browser of Object.keys(queryBrowsers) as Target[]) {\n const version = queryBrowsers[browser];\n const esmSupportVersion =\n // @ts-expect-error ie is not in ESM_SUPPORT\n ESM_SUPPORT[browser];\n\n if (esmSupportVersion) {\n queryBrowsers[browser] = getHighestUnreleased(\n version,\n semverify(esmSupportVersion),\n browser,\n );\n } else {\n delete queryBrowsers[browser];\n }\n }\n }\n\n targets = Object.assign(queryBrowsers, targets);\n }\n\n // Parse remaining targets\n const result: Targets = {};\n const decimalWarnings = [];\n for (const target of Object.keys(targets).sort() as Target[]) {\n const value = targets[target];\n\n // Warn when specifying minor/patch as a decimal\n if (typeof value === \"number\" && value % 1 !== 0) {\n decimalWarnings.push({ target, value });\n }\n\n const [parsedTarget, parsedValue] =\n target === \"node\"\n ? nodeTargetParser(value)\n : defaultTargetParser(target, value as string);\n\n if (parsedValue) {\n // Merge (lowest wins)\n result[parsedTarget] = parsedValue;\n }\n }\n\n outputDecimalWarning(decimalWarnings);\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAEA;AAQA;AACA;AAYA;AACA;AACA;AAIA,MAAMA,WAAW,GAAGC,cAAkB,CAAC,YAAY,CAAC;AAGpD,MAAMC,CAAC,GAAG,IAAIC,sCAAe,qCAAmB;AAEhD,SAASC,mBAAmB,CAACC,OAAgB,EAAgB;EAC3D,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACC,oBAAW,CAAC;EAC7C,KAAK,MAAMC,MAAM,IAAIH,MAAM,CAACC,IAAI,CAACH,OAAO,CAAC,EAAE;IACzC,IAAI,EAAEK,MAAM,IAAID,oBAAW,CAAC,EAAE;MAC5B,MAAM,IAAIE,KAAK,CACbT,CAAC,CAACU,aAAa,CAAE,IAAGF,MAAO;AACnC,kBAAkB,IAAAG,qCAAc,EAACH,MAAM,EAAEJ,YAAY,CAAE,IAAG,CAAC,CACpD;IACH;EACF;EAEA,OAAOD,OAAO;AAChB;AAEO,SAASS,oBAAoB,CAACC,QAAiB,EAAW;EAC/D,OACE,OAAOA,QAAQ,KAAK,QAAQ,IAC3BC,KAAK,CAACC,OAAO,CAACF,QAAQ,CAAC,IAAIA,QAAQ,CAACG,KAAK,CAACC,CAAC,IAAI,OAAOA,CAAC,KAAK,QAAQ,CAAE;AAE3E;AAEA,SAASC,gBAAgB,CAACL,QAA8B,EAAE;EACxDb,CAAC,CAACmB,SAAS,CACTN,QAAQ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