1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.getHighestUnreleased = getHighestUnreleased;
|
---|
7 | exports.getLowestImplementedVersion = getLowestImplementedVersion;
|
---|
8 | exports.getLowestUnreleased = getLowestUnreleased;
|
---|
9 | exports.isUnreleasedVersion = isUnreleasedVersion;
|
---|
10 | exports.semverMin = semverMin;
|
---|
11 | exports.semverify = semverify;
|
---|
12 | var _semver = require("semver");
|
---|
13 | var _helperValidatorOption = require("@babel/helper-validator-option");
|
---|
14 | var _targets = require("./targets.js");
|
---|
15 | const versionRegExp = /^(?:\d+|\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?))$/;
|
---|
16 | const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
|
---|
17 | function semverMin(first, second) {
|
---|
18 | return first && _semver.lt(first, second) ? first : second;
|
---|
19 | }
|
---|
20 | function semverify(version) {
|
---|
21 | if (typeof version === "string" && _semver.valid(version)) {
|
---|
22 | return version;
|
---|
23 | }
|
---|
24 | v.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`);
|
---|
25 | version = version.toString();
|
---|
26 | let pos = 0;
|
---|
27 | let num = 0;
|
---|
28 | while ((pos = version.indexOf(".", pos + 1)) > 0) {
|
---|
29 | num++;
|
---|
30 | }
|
---|
31 | return version + ".0".repeat(2 - num);
|
---|
32 | }
|
---|
33 | function isUnreleasedVersion(version, env) {
|
---|
34 | const unreleasedLabel = _targets.unreleasedLabels[env];
|
---|
35 | return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase();
|
---|
36 | }
|
---|
37 | function getLowestUnreleased(a, b, env) {
|
---|
38 | const unreleasedLabel = _targets.unreleasedLabels[env];
|
---|
39 | if (a === unreleasedLabel) {
|
---|
40 | return b;
|
---|
41 | }
|
---|
42 | if (b === unreleasedLabel) {
|
---|
43 | return a;
|
---|
44 | }
|
---|
45 | return semverMin(a, b);
|
---|
46 | }
|
---|
47 | function getHighestUnreleased(a, b, env) {
|
---|
48 | return getLowestUnreleased(a, b, env) === a ? b : a;
|
---|
49 | }
|
---|
50 | function getLowestImplementedVersion(plugin, environment) {
|
---|
51 | const result = plugin[environment];
|
---|
52 | if (!result && environment === "android") {
|
---|
53 | return plugin.chrome;
|
---|
54 | }
|
---|
55 | return result;
|
---|
56 | }
|
---|
57 |
|
---|
58 | //# sourceMappingURL=utils.js.map
|
---|