aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@babel/helper-compilation-targets/lib/index.js
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
commit5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch)
tree360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/@babel/helper-compilation-targets/lib/index.js
parentb500a50f1b97d93c98b36ed9a980f8188d648147 (diff)
downloadLYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz
LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/@babel/helper-compilation-targets/lib/index.js')
-rw-r--r--node_modules/@babel/helper-compilation-targets/lib/index.js255
1 files changed, 255 insertions, 0 deletions
diff --git a/node_modules/@babel/helper-compilation-targets/lib/index.js b/node_modules/@babel/helper-compilation-targets/lib/index.js
new file mode 100644
index 0000000..c186599
--- /dev/null
+++ b/node_modules/@babel/helper-compilation-targets/lib/index.js
@@ -0,0 +1,255 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+Object.defineProperty(exports, "TargetNames", {
+ enumerable: true,
+ get: function () {
+ return _options.TargetNames;
+ }
+});
+exports.default = getTargets;
+Object.defineProperty(exports, "filterItems", {
+ enumerable: true,
+ get: function () {
+ return _filterItems.default;
+ }
+});
+Object.defineProperty(exports, "getInclusionReasons", {
+ enumerable: true,
+ get: function () {
+ return _debug.getInclusionReasons;
+ }
+});
+exports.isBrowsersQueryValid = isBrowsersQueryValid;
+Object.defineProperty(exports, "isRequired", {
+ enumerable: true,
+ get: function () {
+ return _filterItems.isRequired;
+ }
+});
+Object.defineProperty(exports, "prettifyTargets", {
+ enumerable: true,
+ get: function () {
+ return _pretty.prettifyTargets;
+ }
+});
+Object.defineProperty(exports, "unreleasedLabels", {
+ enumerable: true,
+ get: function () {
+ return _targets.unreleasedLabels;
+ }
+});
+
+var _browserslist = require("browserslist");
+
+var _helperValidatorOption = require("@babel/helper-validator-option");
+
+var _nativeModules = require("@babel/compat-data/native-modules");
+
+var _utils = require("./utils");
+
+var _targets = require("./targets");
+
+var _options = require("./options");
+
+var _pretty = require("./pretty");
+
+var _debug = require("./debug");
+
+var _filterItems = require("./filter-items");
+
+const ESM_SUPPORT = _nativeModules["es6.module"];
+const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
+
+function validateTargetNames(targets) {
+ const validTargets = Object.keys(_options.TargetNames);
+
+ for (const target of Object.keys(targets)) {
+ if (!(target in _options.TargetNames)) {
+ throw new Error(v.formatMessage(`'${target}' is not a valid target
+- Did you mean '${(0, _helperValidatorOption.findSuggestion)(target, validTargets)}'?`));
+ }
+ }
+
+ return targets;
+}
+
+function isBrowsersQueryValid(browsers) {
+ return typeof browsers === "string" || Array.isArray(browsers) && browsers.every(b => typeof b === "string");
+}
+
+function validateBrowsers(browsers) {
+ v.invariant(browsers === undefined || isBrowsersQueryValid(browsers), `'${String(browsers)}' is not a valid browserslist query`);
+ return browsers;
+}
+
+function getLowestVersions(browsers) {
+ return browsers.reduce((all, browser) => {
+ const [browserName, browserVersion] = browser.split(" ");
+ const normalizedBrowserName = _targets.browserNameMap[browserName];
+
+ if (!normalizedBrowserName) {
+ return all;
+ }
+
+ try {
+ const splitVersion = browserVersion.split("-")[0].toLowerCase();
+ const isSplitUnreleased = (0, _utils.isUnreleasedVersion)(splitVersion, browserName);
+
+ if (!all[normalizedBrowserName]) {
+ all[normalizedBrowserName] = isSplitUnreleased ? splitVersion : (0, _utils.semverify)(splitVersion);
+ return all;
+ }
+
+ const version = all[normalizedBrowserName];
+ const isUnreleased = (0, _utils.isUnreleasedVersion)(version, browserName);
+
+ if (isUnreleased && isSplitUnreleased) {
+ all[normalizedBrowserName] = (0, _utils.getLowestUnreleased)(version, splitVersion, browserName);
+ } else if (isUnreleased) {
+ all[normalizedBrowserName] = (0, _utils.semverify)(splitVersion);
+ } else if (!isUnreleased && !isSplitUnreleased) {
+ const parsedBrowserVersion = (0, _utils.semverify)(splitVersion);
+ all[normalizedBrowserName] = (0, _utils.semverMin)(version, parsedBrowserVersion);
+ }
+ } catch (e) {}
+
+ return all;
+ }, {});
+}
+
+function outputDecimalWarning(decimalTargets) {
+ if (!decimalTargets.length) {
+ return;
+ }
+
+ console.warn("Warning, the following targets are using a decimal version:\n");
+ decimalTargets.forEach(({
+ target,
+ value
+ }) => console.warn(` ${target}: ${value}`));
+ console.warn(`
+We recommend using a string for minor/patch versions to avoid numbers like 6.10
+getting parsed as 6.1, which can lead to unexpected behavior.
+`);
+}
+
+function semverifyTarget(target, value) {
+ try {
+ return (0, _utils.semverify)(value);
+ } catch (error) {
+ throw new Error(v.formatMessage(`'${value}' is not a valid value for 'targets.${target}'.`));
+ }
+}
+
+const targetParserMap = {
+ __default(target, value) {
+ const version = (0, _utils.isUnreleasedVersion)(value, target) ? value.toLowerCase() : semverifyTarget(target, value);
+ return [target, version];
+ },
+
+ node(target, value) {
+ const parsed = value === true || value === "current" ? process.versions.node : semverifyTarget(target, value);
+ return [target, parsed];
+ }
+
+};
+
+function generateTargets(inputTargets) {
+ const input = Object.assign({}, inputTargets);
+ delete input.esmodules;
+ delete input.browsers;
+ return input;
+}
+
+function resolveTargets(queries, env) {
+ const resolved = _browserslist(queries, {
+ mobileToDesktop: true,
+ env
+ });
+
+ return getLowestVersions(resolved);
+}
+
+function getTargets(inputTargets = {}, options = {}) {
+ var _browsers;
+
+ let {
+ browsers,
+ esmodules
+ } = inputTargets;
+ const {
+ configPath = "."
+ } = options;
+ validateBrowsers(browsers);
+ const input = generateTargets(inputTargets);
+ let targets = validateTargetNames(input);
+ const shouldParseBrowsers = !!browsers;
+ const hasTargets = shouldParseBrowsers || Object.keys(targets).length > 0;
+ const shouldSearchForConfig = !options.ignoreBrowserslistConfig && !hasTargets;
+
+ if (!browsers && shouldSearchForConfig) {
+ browsers = _browserslist.loadConfig({
+ config: options.configFile,
+ path: configPath,
+ env: options.browserslistEnv
+ });
+
+ if (browsers == null) {
+ {
+ browsers = [];
+ }
+ }
+ }
+
+ if (esmodules && (esmodules !== "intersect" || !((_browsers = browsers) != null && _browsers.length))) {
+ browsers = Object.keys(ESM_SUPPORT).map(browser => `${browser} >= ${ESM_SUPPORT[browser]}`).join(", ");
+ esmodules = false;
+ }
+
+ if (browsers) {
+ const queryBrowsers = resolveTargets(browsers, options.browserslistEnv);
+
+ if (esmodules === "intersect") {
+ for (const browser of Object.keys(queryBrowsers)) {
+ const version = queryBrowsers[browser];
+
+ if (ESM_SUPPORT[browser]) {
+ queryBrowsers[browser] = (0, _utils.getHighestUnreleased)(version, (0, _utils.semverify)(ESM_SUPPORT[browser]), browser);
+ } else {
+ delete queryBrowsers[browser];
+ }
+ }
+ }
+
+ targets = Object.assign(queryBrowsers, targets);
+ }
+
+ const result = {};
+ const decimalWarnings = [];
+
+ for (const target of Object.keys(targets).sort()) {
+ var _targetParserMap$targ;
+
+ const value = targets[target];
+
+ if (typeof value === "number" && value % 1 !== 0) {
+ decimalWarnings.push({
+ target,
+ value
+ });
+ }
+
+ const parser = (_targetParserMap$targ = targetParserMap[target]) != null ? _targetParserMap$targ : targetParserMap.__default;
+ const [parsedTarget, parsedValue] = parser(target, value);
+
+ if (parsedValue) {
+ result[parsedTarget] = parsedValue;
+ }
+ }
+
+ outputDecimalWarning(decimalWarnings);
+ return result;
+} \ No newline at end of file