rsnext/packages/next/compiled/semver/index.js

1 line
24 KiB
JavaScript
Raw Normal View History

(()=>{var e={544:(e,r,t)=>{const s=Symbol("SemVer ANY");class Comparator{static get ANY(){return s}constructor(e,r){if(!r||typeof r!=="object"){r={loose:!!r,includePrerelease:false}}if(e instanceof Comparator){if(e.loose===!!r.loose){return e}else{e=e.value}}a("comparator",e,r);this.options=r;this.loose=!!r.loose;this.parse(e);if(this.semver===s){this.value=""}else{this.value=this.operator+this.semver.version}a("comp",this)}parse(e){const r=this.options.loose?o[n.COMPARATORLOOSE]:o[n.COMPARATOR];const t=e.match(r);if(!t){throw new TypeError(`Invalid comparator: ${e}`)}this.operator=t[1]!==undefined?t[1]:"";if(this.operator==="="){this.operator=""}if(!t[2]){this.semver=s}else{this.semver=new l(t[2],this.options.loose)}}toString(){return this.value}test(e){a("Comparator.test",e,this.options.loose);if(this.semver===s||e===s){return true}if(typeof e==="string"){try{e=new l(e,this.options)}catch(e){return false}}return i(e,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof Comparator)){throw new TypeError("a Comparator is required")}if(!r||typeof r!=="object"){r={loose:!!r,includePrerelease:false}}if(this.operator===""){if(this.value===""){return true}return new c(e.value,r).test(this.value)}else if(e.operator===""){if(e.value===""){return true}return new c(this.value,r).test(e.semver)}const t=(this.operator===">="||this.operator===">")&&(e.operator===">="||e.operator===">");const s=(this.operator==="<="||this.operator==="<")&&(e.operator==="<="||e.operator==="<");const o=this.semver.version===e.semver.version;const n=(this.operator===">="||this.operator==="<=")&&(e.operator===">="||e.operator==="<=");const a=i(this.semver,"<",e.semver,r)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<");const l=i(this.semver,">",e.semver,r)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return t||s||o&&n||a||l}}e.exports=Comparator;const{re:o,t:n}=t(962);const i=t(344);const a=t(23);const l=t(828);const c=t(349)},349:(e,r,t)=>{class Range{constructor(e,r){if(!r||typeof r!=="object"){r={loose:!!r,includePrerelease:false}}if(e instanceof Range){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease){return e}else{return new Range(e.raw,r)}}if(e instanceof s){this.raw=e.value;this.set=[[e]];this.format();return this}this.options=r;this.loose=!!r.loose;this.includePrerelease=!!r.includePrerelease;this.raw=e;this.set=e.split(/\s*\|\|\s*/).map((e=>this.parseRange(e.trim()))).filter((e=>e.length));if(!this.set.length){throw new TypeError(`Invalid SemVer Range: ${e}`)}this.format()}format(){this.range=this.set.map((e=>e.join(" ").trim())).join("||").trim();return this.range}toString(){return this.range}parseRange(e){const r=this.options.loose;e=e.trim();const t=r?i[a.HYPHENRANGELOOSE]:i[a.HYPHENRANGE];e=e.replace(t,hyphenReplace(this.options.includePrerelease));o("hyphen replace",e);e=e.replace(i[a.COMPARATORTRIM],l);o("comparator trim",e,i[a.COMPARATORTRIM]);e=e.replace(i[a.TILDETRIM],c);e=e.replace(i[a.CARETTRIM],p);e=e.split(/\s+/).join(" ");const n=r?i[a.COMPARATORLOOSE]:i[a.COMPARATOR];return e.split(" ").map((e=>parseComparator(e,this.options))).join(" ").split(/\s+/).map((e=>replaceGTE0(e,this.options))).filter(this.options.loose?e=>!!e.match(n):()=>true).map((e=>new s(e,this.options)))}intersects(e,r){if(!(e instanceof Range)){throw new TypeError("a Range is required")}return this.set.some((t=>isSatisfiable(t,r)&&e.set.some((e=>isSatisfiable(e,r)&&t.every((t=>e.every((e=>t.intersects(e,r)))))))))}test(e){if(!e){return false}if(typeof e==="string"){try{e=new n(e,this.options)}catch(e){return false}}for(let r=0;r<this.set.length;r++){if(testSet(this.set[r],e,this.options)){return true}}return false}}e.exports=Range;const s=t(544);const o=t(23);const n=t(828);const{re:i,t:a,comparatorTrimReplace:l,tildeTrimReplace:c,caretTrimReplace:p}=t(962);const isSatisfiable=(e,r)=>{let t=true;const s=e.slice();let o=s.pop();while(t&&s.length){t=s.every((e=>o.intersects(e,r)));o=s.pop()}return t};const parseComparator=(e,r)=>{o("comp",e,r);e=replaceCa