@gjsify/semver 0.3.20 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- const e=/^(0|[1-9]\d*)$/,t=/^(\d+)\.(\d+)\.(\d+)(?:-((?:[0-9A-Za-z-]+)(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;function n(e){try{return new l(e)}catch{return null}}function r(e){let t=n(e);return t?t.version:null}function i(e,t){let n=e instanceof l?e:new l(e),r=t instanceof l?t:new l(t);return n.compare(r)}function a(e,t){let r=t instanceof u?t:new u(t),i=e instanceof l?e:n(String(e));return i?r.test(i):!1}function o(e,t){let r=t instanceof u?t:new u(t),i=null;for(let t of e){let e=n(t);!e||!r.test(e)||(i===null||e.compare(i)>0)&&(i=e)}return i?i.version:null}function s(e,t){let r=t instanceof u?t:new u(t),i=null;for(let t of e){let e=n(t);!e||!r.test(e)||(i===null||e.compare(i)<0)&&(i=e)}return i?i.version:null}function c(e){try{return new u(e).format()}catch{return null}}var l=class{major;minor;patch;prerelease;build;version;constructor(n){let r=String(n).trim().replace(/^v/,``),i=t.exec(r);if(!i)throw TypeError(`Invalid Version: ${n}`);this.major=Number(i[1]),this.minor=Number(i[2]),this.patch=Number(i[3]),this.prerelease=i[4]?i[4].split(`.`).map(t=>e.test(t)?Number(t):t):[],this.build=i[5]?i[5].split(`.`):[],this.version=`${this.major}.${this.minor}.${this.patch}`+(this.prerelease.length?`-${this.prerelease.join(`.`)}`:``)+(this.build.length?`+${this.build.join(`.`)}`:``)}compare(e){return this.major===e.major?this.minor===e.minor?this.patch===e.patch?this.comparePre(e):this.patch<e.patch?-1:1:this.minor<e.minor?-1:1:this.major<e.major?-1:1}comparePre(e){let t=this.prerelease,n=e.prerelease;if(t.length===0&&n.length===0)return 0;if(t.length===0)return 1;if(n.length===0)return-1;for(let e=0;;e++){let r=t[e],i=n[e];if(r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;let a=typeof r==`number`,o=typeof i==`number`;return a&&!o?-1:!a&&o?1:r<i?-1:1}}toString(){return this.version}},u=class e{raw;set;constructor(t){if(t instanceof e){this.raw=t.raw,this.set=t.set;return}this.raw=String(t).trim();let n=this.raw.split(/\s*\|\|\s*/),r=[];for(let e of n){let t=p(e);if(t.length===0)throw TypeError(`Invalid range: ${this.raw}`);r.push(t)}if(r.length===0)throw TypeError(`Invalid range: ${this.raw}`);this.set=r}test(e){let t=e instanceof l?e:n(String(e));if(!t)return!1;for(let e of this.set)if(e.every(e=>d(e,t))){if(t.prerelease.length>0&&!e.some(e=>e.semver!==null&&e.semver.prerelease.length>0&&e.semver.major===t.major&&e.semver.minor===t.minor&&e.semver.patch===t.patch))continue;return!0}return!1}format(){return this.set.map(e=>e.map(f).join(` `)).join(` || `)}toString(){return this.format()}};function d(e,t){if(e.semver===null)return!0;let n=t.compare(e.semver);switch(e.operator){case``:case`=`:return n===0;case`<`:return n<0;case`<=`:return n<=0;case`>`:return n>0;case`>=`:return n>=0}}function f(e){return e.semver===null?`*`:`${e.operator}${e.semver.version}`}function p(e){let t=e.trim();if(t===``||t===`*`||t.toLowerCase()===`latest`)return[{operator:`>=`,semver:new l(`0.0.0`)}];let n=t.match(/^\s*(\S+)\s+-\s+(\S+)\s*$/);if(n)return x(n[1],n[2]);let r=t.replace(/(<=|>=|<|>|=)\s+(?=\S)/g,`$1`).split(/\s+/),i=[];for(let e of r)i.push(...m(e));return i}function m(e){if(e===`*`||e===``||e.toLowerCase()===`latest`)return[{operator:`>=`,semver:new l(`0.0.0`)}];if(e.startsWith(`^`))return v(e.slice(1));if(e.startsWith(`~`))return y(e.slice(1).replace(/^>/,``));let t=e.match(/^(<=|>=|<|>|=)\s*(.+)$/);if(t){let e=t[1];return b(e,t[2])}return _(e)}function h(e){let t=e.trim().replace(/^v/,``);if(t===``||t===`*`)return{major:null,minor:null,patch:null,pre:``,build:``};let n=``,r=``,i=t,a=i.indexOf(`+`);a>=0&&(r=i.slice(a+1),i=i.slice(0,a));let o=i.indexOf(`-`);o>=0&&(n=i.slice(o+1),i=i.slice(0,o));let s=i.split(`.`),c=t=>{if(t===void 0||t===``||t===`x`||t===`X`||t===`*`)return null;if(!/^\d+$/.test(t))throw TypeError(`Invalid partial version: ${e}`);return Number(t)};return{major:c(s[0]),minor:c(s[1]),patch:c(s[2]),pre:n,build:r}}function g(e){return`${e.major??0}.${e.minor??0}.${e.patch??0}${e.pre?`-${e.pre}`:``}${e.build?`+${e.build}`:``}`}function _(e){let t=h(e);return t.major===null?[{operator:`>=`,semver:new l(`0.0.0`)}]:t.minor===null?[{operator:`>=`,semver:new l(`${t.major}.0.0`)},{operator:`<`,semver:new l(`${t.major+1}.0.0`)}]:t.patch===null?[{operator:`>=`,semver:new l(`${t.major}.${t.minor}.0`)},{operator:`<`,semver:new l(`${t.major}.${t.minor+1}.0`)}]:[{operator:`=`,semver:new l(g(t))}]}function v(e){let t=h(e);if(t.major===null)return[{operator:`>=`,semver:new l(`0.0.0`)}];let n=`${t.major}.${t.minor??0}.${t.patch??0}${t.pre?`-${t.pre}`:``}`,r;return r=t.major>0||t.minor===null?`${t.major+1}.0.0`:t.minor>0||t.patch===null?`0.${t.minor+1}.0`:`0.0.${t.patch+1}`,[{operator:`>=`,semver:new l(n)},{operator:`<`,semver:new l(r)}]}function y(e){let t=h(e);if(t.major===null)return[{operator:`>=`,semver:new l(`0.0.0`)}];let n=`${t.major}.${t.minor??0}.${t.patch??0}${t.pre?`-${t.pre}`:``}`,r=t.minor===null?`${t.major+1}.0.0`:`${t.major}.${t.minor+1}.0`;return[{operator:`>=`,semver:new l(n)},{operator:`<`,semver:new l(r)}]}function b(e,t){let n=h(t);return n.major===null?[{operator:`>=`,semver:new l(`0.0.0`)}]:e===`=`||e===``?_(t):e===`>`?n.minor===null?[{operator:`>=`,semver:new l(`${n.major+1}.0.0`)}]:n.patch===null?[{operator:`>=`,semver:new l(`${n.major}.${n.minor+1}.0`)}]:[{operator:`>`,semver:new l(g(n))}]:e===`<`?n.minor===null?[{operator:`<`,semver:new l(`${n.major}.0.0`)}]:n.patch===null?[{operator:`<`,semver:new l(`${n.major}.${n.minor}.0`)}]:[{operator:`<`,semver:new l(g(n))}]:e===`>=`?[{operator:`>=`,semver:new l(g(n))}]:n.minor===null?[{operator:`<`,semver:new l(`${n.major+1}.0.0`)}]:n.patch===null?[{operator:`<`,semver:new l(`${n.major}.${n.minor+1}.0`)}]:[{operator:`<=`,semver:new l(g(n))}]}function x(e,t){let n=h(e),r=h(t),i=n.major===null?{operator:`>=`,semver:new l(`0.0.0`)}:{operator:`>=`,semver:new l(`${n.major}.${n.minor??0}.${n.patch??0}${n.pre?`-${n.pre}`:``}`)},a;return a=r.major===null?{operator:`>=`,semver:new l(`0.0.0`)}:r.minor===null?{operator:`<`,semver:new l(`${r.major+1}.0.0`)}:r.patch===null?{operator:`<`,semver:new l(`${r.major}.${r.minor+1}.0`)}:{operator:`<=`,semver:new l(`${r.major}.${r.minor}.${r.patch}${r.pre?`-${r.pre}`:``}`)},[i,a]}export{u as Range,l as SemVer,i as compare,o as maxSatisfying,s as minSatisfying,n as parse,a as satisfies,r as valid,c as validRange};
1
+ import"./_virtual/_rolldown/runtime.js";const e=/^(0|[1-9]\d*)$/,t=/^(\d+)\.(\d+)\.(\d+)(?:-((?:[0-9A-Za-z-]+)(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;function parse(e){try{return new SemVer(e)}catch{return null}}function valid(e){let t=parse(e);return t?t.version:null}function compare(e,t){let n=e instanceof SemVer?e:new SemVer(e),r=t instanceof SemVer?t:new SemVer(t);return n.compare(r)}function satisfies(e,t){let r=t instanceof n?t:new n(t),i=e instanceof SemVer?e:parse(String(e));return i?r.test(i):!1}function maxSatisfying(e,t){let r=t instanceof n?t:new n(t),i=null;for(let t of e){let e=parse(t);!e||!r.test(e)||(i===null||e.compare(i)>0)&&(i=e)}return i?i.version:null}function minSatisfying(e,t){let r=t instanceof n?t:new n(t),i=null;for(let t of e){let e=parse(t);!e||!r.test(e)||(i===null||e.compare(i)<0)&&(i=e)}return i?i.version:null}function validRange(e){try{return new n(e).format()}catch{return null}}var SemVer=class{major;minor;patch;prerelease;build;version;constructor(n){let r=String(n).trim().replace(/^v/,``),i=t.exec(r);if(!i)throw TypeError(`Invalid Version: ${n}`);this.major=Number(i[1]),this.minor=Number(i[2]),this.patch=Number(i[3]),this.prerelease=i[4]?i[4].split(`.`).map(t=>e.test(t)?Number(t):t):[],this.build=i[5]?i[5].split(`.`):[],this.version=`${this.major}.${this.minor}.${this.patch}`+(this.prerelease.length?`-${this.prerelease.join(`.`)}`:``)+(this.build.length?`+${this.build.join(`.`)}`:``)}compare(e){return this.major===e.major?this.minor===e.minor?this.patch===e.patch?this.comparePre(e):this.patch<e.patch?-1:1:this.minor<e.minor?-1:1:this.major<e.major?-1:1}comparePre(e){let t=this.prerelease,n=e.prerelease;if(t.length===0&&n.length===0)return 0;if(t.length===0)return 1;if(n.length===0)return-1;for(let e=0;;e++){let r=t[e],i=n[e];if(r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;let a=typeof r==`number`,o=typeof i==`number`;return a&&!o?-1:!a&&o?1:r<i?-1:1}}toString(){return this.version}},n=class Range{raw;set;constructor(e){if(e instanceof Range){this.raw=e.raw,this.set=e.set;return}this.raw=String(e).trim();let t=this.raw.split(/\s*\|\|\s*/),n=[];for(let e of t){let t=parseRangePart(e);if(t.length===0)throw TypeError(`Invalid range: ${this.raw}`);n.push(t)}if(n.length===0)throw TypeError(`Invalid range: ${this.raw}`);this.set=n}test(e){let t=e instanceof SemVer?e:parse(String(e));if(!t)return!1;for(let e of this.set)if(e.every(e=>testComparator(e,t))){if(t.prerelease.length>0&&!e.some(e=>e.semver!==null&&e.semver.prerelease.length>0&&e.semver.major===t.major&&e.semver.minor===t.minor&&e.semver.patch===t.patch))continue;return!0}return!1}format(){return this.set.map(e=>e.map(formatComparator).join(` `)).join(` || `)}toString(){return this.format()}};function testComparator(e,t){if(e.semver===null)return!0;let n=t.compare(e.semver);switch(e.operator){case``:case`=`:return n===0;case`<`:return n<0;case`<=`:return n<=0;case`>`:return n>0;case`>=`:return n>=0}}function formatComparator(e){return e.semver===null?`*`:`${e.operator}${e.semver.version}`}function parseRangePart(e){let t=e.trim();if(t===``||t===`*`||t.toLowerCase()===`latest`)return[{operator:`>=`,semver:new SemVer(`0.0.0`)}];let n=t.match(/^\s*(\S+)\s+-\s+(\S+)\s*$/);if(n)return hyphenRange(n[1],n[2]);let r=t.replace(/(<=|>=|<|>|=)\s+(?=\S)/g,`$1`).split(/\s+/),i=[];for(let e of r)i.push(...parseSimple(e));return i}function parseSimple(e){if(e===`*`||e===``||e.toLowerCase()===`latest`)return[{operator:`>=`,semver:new SemVer(`0.0.0`)}];if(e.startsWith(`^`))return caretRange(e.slice(1));if(e.startsWith(`~`))return tildeRange(e.slice(1).replace(/^>/,``));let t=e.match(/^(<=|>=|<|>|=)\s*(.+)$/);if(t){let e=t[1];return primitiveRange(e,t[2])}return partialRange(e)}function parsePartial(e){let t=e.trim().replace(/^v/,``);if(t===``||t===`*`)return{major:null,minor:null,patch:null,pre:``,build:``};let n=``,r=``,i=t,a=i.indexOf(`+`);a>=0&&(r=i.slice(a+1),i=i.slice(0,a));let o=i.indexOf(`-`);o>=0&&(n=i.slice(o+1),i=i.slice(0,o));let s=i.split(`.`),xr=t=>{if(t===void 0||t===``||t===`x`||t===`X`||t===`*`)return null;if(!/^\d+$/.test(t))throw TypeError(`Invalid partial version: ${e}`);return Number(t)};return{major:xr(s[0]),minor:xr(s[1]),patch:xr(s[2]),pre:n,build:r}}function partialToVersion(e){return`${e.major??0}.${e.minor??0}.${e.patch??0}${e.pre?`-${e.pre}`:``}${e.build?`+${e.build}`:``}`}function partialRange(e){let t=parsePartial(e);return t.major===null?[{operator:`>=`,semver:new SemVer(`0.0.0`)}]:t.minor===null?[{operator:`>=`,semver:new SemVer(`${t.major}.0.0`)},{operator:`<`,semver:new SemVer(`${t.major+1}.0.0`)}]:t.patch===null?[{operator:`>=`,semver:new SemVer(`${t.major}.${t.minor}.0`)},{operator:`<`,semver:new SemVer(`${t.major}.${t.minor+1}.0`)}]:[{operator:`=`,semver:new SemVer(partialToVersion(t))}]}function caretRange(e){let t=parsePartial(e);if(t.major===null)return[{operator:`>=`,semver:new SemVer(`0.0.0`)}];let n=`${t.major}.${t.minor??0}.${t.patch??0}${t.pre?`-${t.pre}`:``}`,r;return r=t.major>0||t.minor===null?`${t.major+1}.0.0`:t.minor>0||t.patch===null?`0.${t.minor+1}.0`:`0.0.${t.patch+1}`,[{operator:`>=`,semver:new SemVer(n)},{operator:`<`,semver:new SemVer(r)}]}function tildeRange(e){let t=parsePartial(e);if(t.major===null)return[{operator:`>=`,semver:new SemVer(`0.0.0`)}];let n=`${t.major}.${t.minor??0}.${t.patch??0}${t.pre?`-${t.pre}`:``}`,r=t.minor===null?`${t.major+1}.0.0`:`${t.major}.${t.minor+1}.0`;return[{operator:`>=`,semver:new SemVer(n)},{operator:`<`,semver:new SemVer(r)}]}function primitiveRange(e,t){let n=parsePartial(t);return n.major===null?[{operator:`>=`,semver:new SemVer(`0.0.0`)}]:e===`=`||e===``?partialRange(t):e===`>`?n.minor===null?[{operator:`>=`,semver:new SemVer(`${n.major+1}.0.0`)}]:n.patch===null?[{operator:`>=`,semver:new SemVer(`${n.major}.${n.minor+1}.0`)}]:[{operator:`>`,semver:new SemVer(partialToVersion(n))}]:e===`<`?n.minor===null?[{operator:`<`,semver:new SemVer(`${n.major}.0.0`)}]:n.patch===null?[{operator:`<`,semver:new SemVer(`${n.major}.${n.minor}.0`)}]:[{operator:`<`,semver:new SemVer(partialToVersion(n))}]:e===`>=`?[{operator:`>=`,semver:new SemVer(partialToVersion(n))}]:n.minor===null?[{operator:`<`,semver:new SemVer(`${n.major+1}.0.0`)}]:n.patch===null?[{operator:`<`,semver:new SemVer(`${n.major}.${n.minor+1}.0`)}]:[{operator:`<=`,semver:new SemVer(partialToVersion(n))}]}function hyphenRange(e,t){let n=parsePartial(e),r=parsePartial(t),i=n.major===null?{operator:`>=`,semver:new SemVer(`0.0.0`)}:{operator:`>=`,semver:new SemVer(`${n.major}.${n.minor??0}.${n.patch??0}${n.pre?`-${n.pre}`:``}`)},a;return a=r.major===null?{operator:`>=`,semver:new SemVer(`0.0.0`)}:r.minor===null?{operator:`<`,semver:new SemVer(`${r.major+1}.0.0`)}:r.patch===null?{operator:`<`,semver:new SemVer(`${r.major}.${r.minor+1}.0`)}:{operator:`<=`,semver:new SemVer(`${r.major}.${r.minor}.${r.patch}${r.pre?`-${r.pre}`:``}`)},[i,a]}export{n as Range,SemVer,compare,maxSatisfying,minSatisfying,parse,satisfies,valid,validRange};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/semver",
3
- "version": "0.3.20",
3
+ "version": "0.4.0",
4
4
  "description": "Subset of node-semver for the gjsify install backend — cross-platform Node + GJS",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "license": "MIT",
35
35
  "devDependencies": {
36
- "@gjsify/cli": "^0.3.20",
37
- "@gjsify/unit": "^0.3.20",
36
+ "@gjsify/cli": "^0.4.0",
37
+ "@gjsify/unit": "^0.4.0",
38
38
  "typescript": "^6.0.3"
39
39
  }
40
40
  }