@visulima/cerebro 1.1.31 → 1.1.33

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## @visulima/cerebro [1.1.33](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.32...@visulima/cerebro@1.1.33) (2025-01-13)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/boxen:** upgraded to 1.0.27
7
+ * **@visulima/colorize:** upgraded to 1.4.18
8
+ * **@visulima/find-cache-dir:** upgraded to 1.0.22
9
+ * **@visulima/pail:** upgraded to 2.1.18
10
+ * **@visulima/path:** upgraded to 1.3.3
11
+
12
+ ## @visulima/cerebro [1.1.32](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.31...@visulima/cerebro@1.1.32) (2025-01-12)
13
+
14
+ ### Bug Fixes
15
+
16
+ * updated @visulima/packem, and all other dev dependencies ([7797a1c](https://github.com/visulima/visulima/commit/7797a1c3e6f1fc532895247bd88285a8a9883c40))
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * **@visulima/boxen:** upgraded to 1.0.26
22
+ * **@visulima/colorize:** upgraded to 1.4.17
23
+ * **@visulima/find-cache-dir:** upgraded to 1.0.21
24
+ * **@visulima/pail:** upgraded to 2.1.17
25
+ * **@visulima/path:** upgraded to 1.3.2
26
+
1
27
  ## @visulima/cerebro [1.1.31](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.30...@visulima/cerebro@1.1.31) (2025-01-09)
2
28
 
3
29
 
package/dist/index.cjs CHANGED
@@ -1 +1,7 @@
1
- "use strict";const e=require("./packem_shared/default-B6w1KajL.cjs");module.exports=e.Cli;
1
+ 'use strict';
2
+
3
+ const _default = require('./packem_shared/default-F355sbNC.cjs');
4
+
5
+
6
+
7
+ module.exports = _default.Cli;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Cli as f}from"./packem_shared/default-DNNnCan-.mjs";export{f as default};
1
+ export { Cli as default } from './packem_shared/default-E15sg8JS.mjs';
@@ -1 +1,243 @@
1
- "use strict";var yt=Object.defineProperty;var M=(t,r)=>yt(t,"name",{value:r,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("node:fs"),bt=require("@visulima/find-cache-dir"),wt=require("node:https");var jt=Object.defineProperty,At=M((t,r)=>jt(t,"name",{value:r,configurable:!0}),"o$1");const Ot=At((t,r)=>{const i=t.split(".").map(Number),l=r.split(".").map(Number);for(const[f,h]of i.entries()){if(h>l[f])return!0;if(h<l[f])return!1}return!1},"semverGt");var Mt=Object.defineProperty,zt=M((t,r)=>Mt(t,"name",{value:r,configurable:!0}),"le"),St=Object.defineProperty,L=zt((t,r)=>St(t,"name",{value:r,configurable:!0}),"Z"),_t=Object.defineProperty,Pt=L((t,r)=>_t(t,"name",{value:r,configurable:!0}),"t");const Ct=/^[A-Z]:\//i,O=Pt((t="")=>t&&t.replaceAll("\\","/").replace(Ct,r=>r.toUpperCase()),"normalizeWindowsPath");var kt=Object.defineProperty,u=L((t,r)=>kt(t,"name",{value:r,configurable:!0}),"u$1");let ae=u(()=>{var t=(()=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,f=Object.prototype.hasOwnProperty,h=u((e,n)=>{for(var o in n)r(e,o,{get:n[o],enumerable:!0})},"q"),m=u((e,n,o,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of l(n))!f.call(e,s)&&s!==o&&r(e,s,{get:u(()=>n[s],"get"),enumerable:!(a=i(n,s))||a.enumerable});return e},"H"),g=u(e=>m(r({},"__esModule",{value:!0}),e),"J"),v={};h(v,{zeptomatch:u(()=>$t,"zeptomatch")});var R=u(e=>Array.isArray(e),"A"),_=u(e=>typeof e=="function","d"),de=u(e=>e.length===0,"Q"),he=u(e=>typeof e=="number","W"),ge=u(e=>typeof e=="object"&&e!==null,"K"),me=u(e=>e instanceof RegExp,"X"),W=u(e=>typeof e=="string","b"),A=u(e=>e===void 0,"h"),xe=u(e=>{const n=new Map;return o=>{const a=n.get(o);if(a)return a;const s=e(o);return n.set(o,s),s}},"Y"),$e=u((e,n,o={})=>{const a={cache:{},input:e,index:0,indexMax:0,options:o,output:[]};if(j(n)(a)&&a.index===e.length)return a.output;throw new Error(`Failed to parse at index ${a.indexMax}`)},"rr"),c=u((e,n)=>R(e)?ve(e,n):W(e)?be(e,n):ye(e,n),"i"),ve=u((e,n)=>{const o={};for(const a of e){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const s=a.charCodeAt(0);o[s]=!0}return a=>{const s=a.index,p=a.input;for(;a.index<p.length&&p.charCodeAt(a.index)in o;)a.index+=1;const d=a.index;if(d>s){if(!A(n)&&!a.options.silent){const $=a.input.slice(s,d),y=_(n)?n($,p,String(s)):n;A(y)||a.output.push(y)}a.indexMax=Math.max(a.indexMax,a.index)}return!0}},"er"),ye=u((e,n)=>{const o=e.source,a=e.flags.replace(/y|$/,"y"),s=new RegExp(o,a);return k(p=>{s.lastIndex=p.index;const d=s.exec(p.input);if(d){if(!A(n)&&!p.options.silent){const $=_(n)?n(...d,p.input,String(p.index)):n;A($)||p.output.push($)}return p.index+=d[0].length,p.indexMax=Math.max(p.indexMax,p.index),!0}else return!1})},"nr"),be=u((e,n)=>o=>{if(o.input.startsWith(e,o.index)){if(!A(n)&&!o.options.silent){const a=_(n)?n(e,o.input,String(o.index)):n;A(a)||o.output.push(a)}return o.index+=e.length,o.indexMax=Math.max(o.indexMax,o.index),!0}else return!1},"tr"),F=u((e,n,o,a)=>{const s=j(e);return k(E(J(p=>{let d=0;for(;d<o;){const $=p.index;if(!s(p)||(d+=1,p.index===$))break}return d>=n}),a))},"C"),we=u((e,n)=>F(e,0,1,n),"ar"),P=u((e,n)=>F(e,0,1/0,n),"f"),C=u((e,n)=>{const o=e.map(j);return k(E(J(a=>{for(let s=0,p=o.length;s<p;s++)if(!o[s](a))return!1;return!0}),n))},"x"),b=u((e,n)=>{const o=e.map(j);return k(E(a=>{for(let s=0,p=o.length;s<p;s++)if(o[s](a))return!0;return!1},n))},"l"),J=u((e,n=!1)=>{const o=j(e);return a=>{const s=a.index,p=a.output.length,d=o(a);return(!d||n)&&(a.index=s,a.output.length!==p&&(a.output.length=p)),d}},"M"),E=u((e,n)=>{const o=j(e);return n?a=>{if(a.options.silent)return o(a);const s=a.output.length;if(o(a)){const p=a.output.splice(s,1/0),d=n(p);return A(d)||a.output.push(d),!0}else return!1}:o},"_"),k=(()=>{let e=0;return n=>{const o=j(n),a=e+=1;return s=>{var p;if(s.options.memoization===!1)return o(s);const d=s.index,$=(p=s.cache)[a]||(p[a]=new Map),y=$.get(d);if(y===!1)return!1;if(he(y))return s.index=y,!0;if(y)return s.index=y.index,y.output?.length&&s.output.push(...y.output),!0;{const re=s.output.length;if(o(s)){const oe=s.index,ie=s.output.length;if(ie>re){const vt=s.output.slice(re,ie);$.set(d,{index:oe,output:vt})}else $.set(d,oe);return!0}else return $.set(d,!1),!1}}}})(),T=u(e=>{let n;return o=>(n||(n=j(e())),n(o))},"E"),j=xe(e=>{if(_(e))return de(e)?T(e):e;if(W(e)||me(e))return c(e);if(R(e))return C(e);if(ge(e))return b(Object.values(e));throw new Error("Invalid rule")}),G="abcdefghijklmnopqrstuvwxyz",je=u(e=>{let n="";for(;e>0;){const o=(e-1)%26;n=G[o]+n,e=Math.floor((e-1)/26)}return n},"ir"),V=u(e=>{let n=0;for(let o=0,a=e.length;o<a;o++)n=n*26+G.indexOf(e[o])+1;return n},"z"),N=u((e,n)=>{if(n<e)return N(n,e);const o=[];for(;e<=n;)o.push(e++);return o},"S"),Ae=u((e,n,o)=>N(e,n).map(a=>String(a).padStart(o,"0")),"or"),B=u((e,n)=>N(V(e),V(n)).map(je),"O"),w=u(e=>e,"p"),H=u(e=>Oe(n=>$e(n,e,{memoization:!1}).join("")),"R"),Oe=u(e=>{const n={};return o=>n[o]??(n[o]=e(o))},"ur"),Me=c(/^\*\*\/\*$/,".*"),ze=c(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,n,o)=>`.*${n?"":"(?:^|/)"}${o.replaceAll(".","\\.")}`),Se=c(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,n,o,a)=>`.*${n?"":"(?:^|/)"}${o.replaceAll(".","\\.")}(?:${a.replaceAll(",","|").replaceAll(".","\\.")})`),Z=c(/\\./,w),_e=c(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Pe=c(/./,w),Ce=c(/^(?:!!)*!(.*)$/,(e,n)=>`(?!^${ne(n)}$).*?`),ke=c(/^(!!)+/,""),Ee=b([Ce,ke]),Ne=c(/\/(\*\*\/)+/,"(?:/.+/|/)"),Ze=c(/^(\*\*\/)+/,"(?:^|.*/)"),Ue=c(/\/(\*\*)$/,"(?:/.*|$)"),De=c(/\*\*/,".*"),K=b([Ne,Ze,Ue,De]),Ie=c(/\*\/(?!\*\*\/)/,"[^/]*/"),Le=c(/\*/,"[^/]*"),Q=b([Ie,Le]),X=c("?","[^/]"),qe=c("[",w),Re=c("]",w),We=c(/[!^]/,"^/"),Fe=c(/[a-z]-[a-z]|[0-9]-[0-9]/i,w),Je=c(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Te=c(/[^\]]/,w),Ge=b([Z,Je,Fe,Te]),Y=C([qe,we(We),P(Ge),Re]),Ve=c("{","(?:"),Be=c("}",")"),He=c(/(\d+)\.\.(\d+)/,(e,n,o)=>Ae(+n,+o,Math.min(n.length,o.length)).join("|")),Ke=c(/([a-z]+)\.\.([a-z]+)/,(e,n,o)=>B(n,o).join("|")),Qe=c(/([A-Z]+)\.\.([A-Z]+)/,(e,n,o)=>B(n.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),Xe=b([He,Ke,Qe]),ee=C([Ve,Xe,Be]),Ye=c("{","(?:"),et=c("}",")"),tt=c(",","|"),nt=c(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),rt=c(/[^}]/,w),ot=T(()=>te),it=b([K,Q,X,Y,ee,ot,Z,nt,tt,rt]),te=C([Ye,P(it),et]),at=P(b([Me,ze,Se,Ee,K,Q,X,Y,ee,te,Z,_e,Pe])),st=at,lt=H(st),ne=lt,ut=c(/\\./,w),ct=c(/./,w),pt=c(/\*\*\*+/,"*"),ft=c(/([^/{[(!])\*\*/,(e,n)=>`${n}*`),dt=c(/(^|.)\*\*(?=[^*/)\]}])/,(e,n)=>`${n}*`),ht=P(b([ut,pt,ft,dt,ct])),gt=ht,mt=H(gt),xt=mt,U=u((e,n)=>{const o=Array.isArray(e)?e:[e];if(!o.length)return!1;const a=o.map(U.compile),s=o.every(d=>/(\/(?:\*\*)?|\[\/\])$/.test(d)),p=n.replace(/[\\\/]+/g,"/").replace(/\/$/,s?"/":"");return a.some(d=>d.test(p))},"$");U.compile=e=>new RegExp(`^${ne(xt(e))}$`,"s");var $t=U;return g(v)})();return t.default||t},"_lazyMatch"),D;const Et=u((t,r)=>(D||(D=ae(),ae=null),D(t,r)),"default");var Nt=Object.defineProperty,x=L((t,r)=>Nt(t,"name",{value:r,configurable:!0}),"r");const Zt=/^[/\\]{2}/,Ut=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,le=/^[A-Z]:$/i,se=/^\/([A-Z]:)?$/i,Dt=/.(\.[^./]+)$/,It=/^[/\\]|^[a-z]:[/\\]/i,Lt=x(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),ue=x((t,r)=>{let i="",l=0,f=-1,h=0,m=null;for(let g=0;g<=t.length;++g){if(g<t.length)m=t[g];else{if(m==="/")break;m="/"}if(m==="/"){if(!(f===g-1||h===1))if(h===2){if(i.length<2||l!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const v=i.lastIndexOf("/");v===-1?(i="",l=0):(i=i.slice(0,v),l=i.length-1-i.lastIndexOf("/")),f=g,h=0;continue}else if(i.length>0){i="",l=0,f=g,h=0;continue}}r&&(i+=i.length>0?"/..":"..",l=2)}else i.length>0?i+=`/${t.slice(f+1,g)}`:i=t.slice(f+1,g),l=g-f-1;f=g,h=0}else m==="."&&h!==-1?++h:h=-1}return i},"normalizeString"),S=x(t=>Ut.test(t),"isAbsolute"),ce=x(function(t){if(t.length===0)return".";t=O(t);const r=Zt.exec(t),i=S(t),l=t.at(-1)==="/";return t=ue(t,!i),t.length===0?i?"/":l?"./":".":(l&&(t+="/"),le.test(t)&&(t+="/"),r?i?`//${t}`:`//./${t}`:i&&!S(t)?`/${t}`:t)},"normalize"),qt=x((...t)=>{let r="";for(const i of t)if(i)if(r.length>0){const l=r[r.length-1]==="/",f=i[0]==="/";l&&f?r+=i.slice(1):r+=l||f?i:`/${i}`}else r+=i;return ce(r)},"join"),I=x(function(...t){t=t.map(l=>O(l));let r="",i=!1;for(let l=t.length-1;l>=-1&&!i;l--){const f=l>=0?t[l]:Lt();!f||f.length===0||(r=`${f}/${r}`,i=S(f))}return r=ue(r,!i),i&&!S(r)?`/${r}`:r.length>0?r:"."},"resolve");x(function(t){return O(t)},"toNamespacedPath");const Rt=x(function(t){return Dt.exec(O(t))?.[1]??""},"extname");x(function(t,r){const i=I(t).replace(se,"$1").split("/"),l=I(r).replace(se,"$1").split("/");if(l[0][1]===":"&&i[0][1]===":"&&i[0]!==l[0])return l.join("/");const f=[...i];for(const h of f){if(l[0]!==h)break;i.shift(),l.shift()}return[...i.map(()=>".."),...l].join("/")},"relative");const pe=x(t=>{const r=O(t).replace(/\/$/,"").split("/").slice(0,-1);return r.length===1&&le.test(r[0])&&(r[0]+="/"),r.join("/")||(S(t)?"/":".")},"dirname");x(function(t){const r=[t.root,t.dir,t.base??t.name+t.ext].filter(Boolean);return O(t.root?I(...r):r.join("/"))},"format");const Wt=x((t,r)=>{const i=O(t).split("/").pop();return r&&i.endsWith(r)?i.slice(0,-r.length):i},"basename");x(function(t){const r=It.exec(t)?.[0]?.replace(/\\/g,"/")??"",i=Wt(t),l=Rt(i);return{base:i,dir:pe(t),ext:l,name:i.slice(0,i.length-l.length),root:r}},"parse");x((t,r)=>Et(r,ce(t)),"matchesGlob");var Ft=Object.defineProperty,q=M((t,r)=>Ft(t,"name",{value:r,configurable:!0}),"r");const Jt="last-update-check.json",fe=q(t=>{const r=bt.findCacheDirSync(t);if(r===void 0)throw new Error("Could not find cache directory");return qt(r,Jt)},"getConfigFile"),Tt=q(t=>{const r=fe(t);try{if(!z.existsSync(r))return;const{lastUpdateCheck:i}=JSON.parse(z.readFileSync(r,"utf8"));return i}catch{return}},"getLastUpdate"),Gt=q(t=>{const r=fe(t),i=pe(r);z.existsSync(i)||z.mkdirSync(i,{recursive:!0}),z.writeFileSync(r,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var Vt=Object.defineProperty,Bt=M((t,r)=>Vt(t,"name",{value:r,configurable:!0}),"g");const Ht=Bt(async(t,r,i)=>{const l=i.replace("__NAME__",t);return await new Promise((f,h)=>{wt.get(l,m=>{let g="";m.on("data",v=>g+=v),m.on("end",()=>{try{const v=JSON.parse(g)[r];v||h(new Error("Error getting version")),f(v)}catch{h(new Error("Could not parse version response"))}})}).on("error",m=>h(m))})},"getDistributionVersion");var Kt=Object.defineProperty,Qt=M((t,r)=>Kt(t,"name",{value:r,configurable:!0}),"i");const Xt=Qt(async({alwaysRun:t,debug:r,distTag:i="latest",pkg:l,registryUrl:f="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const m=Tt(l.name);if(t||!m||m<Date.now()-h){const g=await Ht(l.name,i,f);if(Gt(l.name),Ot(g,l.version))return g;r&&console.error(`Latest version (${g}) not newer than current version (${l.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-m}ms since last check.`);return null},"hasNewVersion");exports.default=Xt;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const node_fs = require('node:fs');
6
+ const findCacheDir = require('@visulima/find-cache-dir');
7
+ const node_https = require('node:https');
8
+
9
+ var __defProp$4 = Object.defineProperty;
10
+ var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
11
+ const semverGt = /* @__PURE__ */ __name$4((version1, version2) => {
12
+ const v1Components = version1.split(".").map(Number);
13
+ const v2Components = version2.split(".").map(Number);
14
+ for (const [index, v1Component] of v1Components.entries()) {
15
+ if (v1Component > v2Components[index]) {
16
+ return true;
17
+ }
18
+ if (v1Component < v2Components[index]) {
19
+ return false;
20
+ }
21
+ }
22
+ return false;
23
+ }, "semverGt");
24
+
25
+ var __defProp$3 = Object.defineProperty;
26
+ var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
27
+ var __defProp$2$1 = Object.defineProperty;
28
+ var __name$2$1 = /* @__PURE__ */ __name$3((target, value) => __defProp$2$1(target, "name", { value, configurable: true }), "__name$2");
29
+ const DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
30
+ const normalizeWindowsPath = /* @__PURE__ */ __name$2$1((input = "") => {
31
+ if (!input) {
32
+ return input;
33
+ }
34
+ return input.replaceAll("\\", "/").replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
35
+ }, "normalizeWindowsPath");
36
+ var __defProp2 = Object.defineProperty;
37
+ var __name2 = /* @__PURE__ */ __name$3((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
38
+ const UNC_REGEX = /^[/\\]{2}/;
39
+ const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
40
+ const DRIVE_LETTER_RE = /^[A-Z]:$/i;
41
+ const normalizeString = /* @__PURE__ */ __name2((path2, allowAboveRoot) => {
42
+ let result = "";
43
+ let lastSegmentLength = 0;
44
+ let lastSlash = -1;
45
+ let dots = 0;
46
+ let char = null;
47
+ for (let index = 0; index <= path2.length; ++index) {
48
+ if (index < path2.length) {
49
+ char = path2[index];
50
+ } else if (char === "/") {
51
+ break;
52
+ } else {
53
+ char = "/";
54
+ }
55
+ if (char === "/") {
56
+ if (lastSlash === index - 1 || dots === 1) ;
57
+ else if (dots === 2) {
58
+ if (result.length < 2 || lastSegmentLength !== 2 || !result.endsWith(".") || result.at(-2) !== ".") {
59
+ if (result.length > 2) {
60
+ const lastSlashIndex = result.lastIndexOf("/");
61
+ if (lastSlashIndex === -1) {
62
+ result = "";
63
+ lastSegmentLength = 0;
64
+ } else {
65
+ result = result.slice(0, lastSlashIndex);
66
+ lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
67
+ }
68
+ lastSlash = index;
69
+ dots = 0;
70
+ continue;
71
+ } else if (result.length > 0) {
72
+ result = "";
73
+ lastSegmentLength = 0;
74
+ lastSlash = index;
75
+ dots = 0;
76
+ continue;
77
+ }
78
+ }
79
+ if (allowAboveRoot) {
80
+ result += result.length > 0 ? "/.." : "..";
81
+ lastSegmentLength = 2;
82
+ }
83
+ } else {
84
+ if (result.length > 0) {
85
+ result += `/${path2.slice(lastSlash + 1, index)}`;
86
+ } else {
87
+ result = path2.slice(lastSlash + 1, index);
88
+ }
89
+ lastSegmentLength = index - lastSlash - 1;
90
+ }
91
+ lastSlash = index;
92
+ dots = 0;
93
+ } else if (char === "." && dots !== -1) {
94
+ ++dots;
95
+ } else {
96
+ dots = -1;
97
+ }
98
+ }
99
+ return result;
100
+ }, "normalizeString");
101
+ const isAbsolute = /* @__PURE__ */ __name2((path2) => IS_ABSOLUTE_RE.test(path2), "isAbsolute");
102
+ const normalize = /* @__PURE__ */ __name2(function(path2) {
103
+ if (path2.length === 0) {
104
+ return ".";
105
+ }
106
+ path2 = normalizeWindowsPath(path2);
107
+ const isUNCPath = UNC_REGEX.exec(path2);
108
+ const isPathAbsolute = isAbsolute(path2);
109
+ const trailingSeparator = path2.at(-1) === "/";
110
+ path2 = normalizeString(path2, !isPathAbsolute);
111
+ if (path2.length === 0) {
112
+ if (isPathAbsolute) {
113
+ return "/";
114
+ }
115
+ return trailingSeparator ? "./" : ".";
116
+ }
117
+ if (trailingSeparator) {
118
+ path2 += "/";
119
+ }
120
+ if (DRIVE_LETTER_RE.test(path2)) {
121
+ path2 += "/";
122
+ }
123
+ if (isUNCPath) {
124
+ if (!isPathAbsolute) {
125
+ return `//./${path2}`;
126
+ }
127
+ return `//${path2}`;
128
+ }
129
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
130
+ }, "normalize");
131
+ const join = /* @__PURE__ */ __name2((...segments) => {
132
+ let path2 = "";
133
+ for (const seg of segments) {
134
+ if (!seg) {
135
+ continue;
136
+ }
137
+ if (path2.length > 0) {
138
+ const pathTrailing = path2[path2.length - 1] === "/";
139
+ const segLeading = seg[0] === "/";
140
+ const both = pathTrailing && segLeading;
141
+ if (both) {
142
+ path2 += seg.slice(1);
143
+ } else {
144
+ path2 += pathTrailing || segLeading ? seg : `/${seg}`;
145
+ }
146
+ } else {
147
+ path2 += seg;
148
+ }
149
+ }
150
+ return normalize(path2);
151
+ }, "join");
152
+ const dirname = /* @__PURE__ */ __name2((path2) => {
153
+ const segments = normalizeWindowsPath(path2).replace(/\/$/, "").split("/").slice(0, -1);
154
+ if (segments.length === 1 && DRIVE_LETTER_RE.test(segments[0])) {
155
+ segments[0] += "/";
156
+ }
157
+ return segments.join("/") || (isAbsolute(path2) ? "/" : ".");
158
+ }, "dirname");
159
+
160
+ var __defProp$2 = Object.defineProperty;
161
+ var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
162
+ const FILE_NAME = "last-update-check.json";
163
+ const getConfigFile = /* @__PURE__ */ __name$2((packageName) => {
164
+ const cacheDirectory = findCacheDir.findCacheDirSync(packageName);
165
+ if (cacheDirectory === undefined) {
166
+ throw new Error("Could not find cache directory");
167
+ }
168
+ return join(cacheDirectory, FILE_NAME);
169
+ }, "getConfigFile");
170
+ const getLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
171
+ const configFile = getConfigFile(packageName);
172
+ try {
173
+ if (!node_fs.existsSync(configFile)) {
174
+ return undefined;
175
+ }
176
+ const { lastUpdateCheck } = JSON.parse(node_fs.readFileSync(configFile, "utf8"));
177
+ return lastUpdateCheck;
178
+ } catch {
179
+ return undefined;
180
+ }
181
+ }, "getLastUpdate");
182
+ const saveLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
183
+ const configFile = getConfigFile(packageName);
184
+ const configDirectory = dirname(configFile);
185
+ if (!node_fs.existsSync(configDirectory)) {
186
+ node_fs.mkdirSync(configDirectory, { recursive: true });
187
+ }
188
+ node_fs.writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));
189
+ }, "saveLastUpdate");
190
+
191
+ var __defProp$1 = Object.defineProperty;
192
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
193
+ const getDistributionVersion = /* @__PURE__ */ __name$1(async (packageName, distributionTag, registryUrl) => {
194
+ const url = registryUrl.replace("__NAME__", packageName);
195
+ return await new Promise((resolve, reject) => {
196
+ node_https.get(url, (message) => {
197
+ let body = "";
198
+ message.on("data", (chunk) => body += chunk);
199
+ message.on("end", () => {
200
+ try {
201
+ const json = JSON.parse(body);
202
+ const version = json[distributionTag];
203
+ if (!version) {
204
+ reject(new Error("Error getting version"));
205
+ }
206
+ resolve(version);
207
+ } catch {
208
+ reject(new Error("Could not parse version response"));
209
+ }
210
+ });
211
+ }).on("error", (error) => reject(error));
212
+ });
213
+ }, "getDistributionVersion");
214
+
215
+ var __defProp = Object.defineProperty;
216
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
217
+ const hasNewVersion = /* @__PURE__ */ __name(async ({
218
+ alwaysRun,
219
+ debug,
220
+ distTag: distributionTag = "latest",
221
+ pkg,
222
+ registryUrl = "https://registry.npmjs.org/-/package/__NAME__/dist-tags",
223
+ updateCheckInterval = 1e3 * 60 * 60 * 24
224
+ }) => {
225
+ const lastUpdateCheck = getLastUpdate(pkg.name);
226
+ if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {
227
+ const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);
228
+ saveLastUpdate(pkg.name);
229
+ if (semverGt(latestVersion, pkg.version)) {
230
+ return latestVersion;
231
+ }
232
+ if (debug) {
233
+ console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);
234
+ }
235
+ } else if (debug) {
236
+ console.error(
237
+ `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${Date.now() - lastUpdateCheck}ms since last check.`
238
+ );
239
+ }
240
+ return null;
241
+ }, "hasNewVersion");
242
+
243
+ exports.default = hasNewVersion;
@@ -1 +1,239 @@
1
- var yt=Object.defineProperty;var M=(t,r)=>yt(t,"name",{value:r,configurable:!0});import{existsSync as se,readFileSync as bt,mkdirSync as wt,writeFileSync as jt}from"node:fs";import{findCacheDirSync as At}from"@visulima/find-cache-dir";import{get as Ot}from"node:https";var Mt=Object.defineProperty,zt=M((t,r)=>Mt(t,"name",{value:r,configurable:!0}),"o$1");const Pt=zt((t,r)=>{const a=t.split(".").map(Number),l=r.split(".").map(Number);for(const[f,h]of a.entries()){if(h>l[f])return!0;if(h<l[f])return!1}return!1},"semverGt");var _t=Object.defineProperty,St=M((t,r)=>_t(t,"name",{value:r,configurable:!0}),"le"),Ct=Object.defineProperty,L=St((t,r)=>Ct(t,"name",{value:r,configurable:!0}),"Z"),kt=Object.defineProperty,Et=L((t,r)=>kt(t,"name",{value:r,configurable:!0}),"t");const Nt=/^[A-Z]:\//i,O=Et((t="")=>t&&t.replaceAll("\\","/").replace(Nt,r=>r.toUpperCase()),"normalizeWindowsPath");var Zt=Object.defineProperty,u=L((t,r)=>Zt(t,"name",{value:r,configurable:!0}),"u$1");let ae=u(()=>{var t=(()=>{var r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,f=Object.prototype.hasOwnProperty,h=u((e,n)=>{for(var o in n)r(e,o,{get:n[o],enumerable:!0})},"q"),m=u((e,n,o,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of l(n))!f.call(e,s)&&s!==o&&r(e,s,{get:u(()=>n[s],"get"),enumerable:!(i=a(n,s))||i.enumerable});return e},"H"),g=u(e=>m(r({},"__esModule",{value:!0}),e),"J"),v={};h(v,{zeptomatch:u(()=>$t,"zeptomatch")});var R=u(e=>Array.isArray(e),"A"),P=u(e=>typeof e=="function","d"),de=u(e=>e.length===0,"Q"),he=u(e=>typeof e=="number","W"),ge=u(e=>typeof e=="object"&&e!==null,"K"),me=u(e=>e instanceof RegExp,"X"),W=u(e=>typeof e=="string","b"),A=u(e=>e===void 0,"h"),xe=u(e=>{const n=new Map;return o=>{const i=n.get(o);if(i)return i;const s=e(o);return n.set(o,s),s}},"Y"),$e=u((e,n,o={})=>{const i={cache:{},input:e,index:0,indexMax:0,options:o,output:[]};if(j(n)(i)&&i.index===e.length)return i.output;throw new Error(`Failed to parse at index ${i.indexMax}`)},"rr"),c=u((e,n)=>R(e)?ve(e,n):W(e)?be(e,n):ye(e,n),"i"),ve=u((e,n)=>{const o={};for(const i of e){if(i.length!==1)throw new Error(`Invalid character: "${i}"`);const s=i.charCodeAt(0);o[s]=!0}return i=>{const s=i.index,p=i.input;for(;i.index<p.length&&p.charCodeAt(i.index)in o;)i.index+=1;const d=i.index;if(d>s){if(!A(n)&&!i.options.silent){const $=i.input.slice(s,d),y=P(n)?n($,p,String(s)):n;A(y)||i.output.push(y)}i.indexMax=Math.max(i.indexMax,i.index)}return!0}},"er"),ye=u((e,n)=>{const o=e.source,i=e.flags.replace(/y|$/,"y"),s=new RegExp(o,i);return C(p=>{s.lastIndex=p.index;const d=s.exec(p.input);if(d){if(!A(n)&&!p.options.silent){const $=P(n)?n(...d,p.input,String(p.index)):n;A($)||p.output.push($)}return p.index+=d[0].length,p.indexMax=Math.max(p.indexMax,p.index),!0}else return!1})},"nr"),be=u((e,n)=>o=>{if(o.input.startsWith(e,o.index)){if(!A(n)&&!o.options.silent){const i=P(n)?n(e,o.input,String(o.index)):n;A(i)||o.output.push(i)}return o.index+=e.length,o.indexMax=Math.max(o.indexMax,o.index),!0}else return!1},"tr"),F=u((e,n,o,i)=>{const s=j(e);return C(k(J(p=>{let d=0;for(;d<o;){const $=p.index;if(!s(p)||(d+=1,p.index===$))break}return d>=n}),i))},"C"),we=u((e,n)=>F(e,0,1,n),"ar"),_=u((e,n)=>F(e,0,1/0,n),"f"),S=u((e,n)=>{const o=e.map(j);return C(k(J(i=>{for(let s=0,p=o.length;s<p;s++)if(!o[s](i))return!1;return!0}),n))},"x"),b=u((e,n)=>{const o=e.map(j);return C(k(i=>{for(let s=0,p=o.length;s<p;s++)if(o[s](i))return!0;return!1},n))},"l"),J=u((e,n=!1)=>{const o=j(e);return i=>{const s=i.index,p=i.output.length,d=o(i);return(!d||n)&&(i.index=s,i.output.length!==p&&(i.output.length=p)),d}},"M"),k=u((e,n)=>{const o=j(e);return n?i=>{if(i.options.silent)return o(i);const s=i.output.length;if(o(i)){const p=i.output.splice(s,1/0),d=n(p);return A(d)||i.output.push(d),!0}else return!1}:o},"_"),C=(()=>{let e=0;return n=>{const o=j(n),i=e+=1;return s=>{var p;if(s.options.memoization===!1)return o(s);const d=s.index,$=(p=s.cache)[i]||(p[i]=new Map),y=$.get(d);if(y===!1)return!1;if(he(y))return s.index=y,!0;if(y)return s.index=y.index,y.output?.length&&s.output.push(...y.output),!0;{const ne=s.output.length;if(o(s)){const re=s.index,oe=s.output.length;if(oe>ne){const vt=s.output.slice(ne,oe);$.set(d,{index:re,output:vt})}else $.set(d,re);return!0}else return $.set(d,!1),!1}}}})(),q=u(e=>{let n;return o=>(n||(n=j(e())),n(o))},"E"),j=xe(e=>{if(P(e))return de(e)?q(e):e;if(W(e)||me(e))return c(e);if(R(e))return S(e);if(ge(e))return b(Object.values(e));throw new Error("Invalid rule")}),G="abcdefghijklmnopqrstuvwxyz",je=u(e=>{let n="";for(;e>0;){const o=(e-1)%26;n=G[o]+n,e=Math.floor((e-1)/26)}return n},"ir"),T=u(e=>{let n=0;for(let o=0,i=e.length;o<i;o++)n=n*26+G.indexOf(e[o])+1;return n},"z"),E=u((e,n)=>{if(n<e)return E(n,e);const o=[];for(;e<=n;)o.push(e++);return o},"S"),Ae=u((e,n,o)=>E(e,n).map(i=>String(i).padStart(o,"0")),"or"),V=u((e,n)=>E(T(e),T(n)).map(je),"O"),w=u(e=>e,"p"),B=u(e=>Oe(n=>$e(n,e,{memoization:!1}).join("")),"R"),Oe=u(e=>{const n={};return o=>n[o]??(n[o]=e(o))},"ur"),Me=c(/^\*\*\/\*$/,".*"),ze=c(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,n,o)=>`.*${n?"":"(?:^|/)"}${o.replaceAll(".","\\.")}`),Pe=c(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,n,o,i)=>`.*${n?"":"(?:^|/)"}${o.replaceAll(".","\\.")}(?:${i.replaceAll(",","|").replaceAll(".","\\.")})`),N=c(/\\./,w),_e=c(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Se=c(/./,w),Ce=c(/^(?:!!)*!(.*)$/,(e,n)=>`(?!^${te(n)}$).*?`),ke=c(/^(!!)+/,""),Ee=b([Ce,ke]),Ne=c(/\/(\*\*\/)+/,"(?:/.+/|/)"),Ze=c(/^(\*\*\/)+/,"(?:^|.*/)"),Ue=c(/\/(\*\*)$/,"(?:/.*|$)"),Ie=c(/\*\*/,".*"),H=b([Ne,Ze,Ue,Ie]),Le=c(/\*\/(?!\*\*\/)/,"[^/]*/"),De=c(/\*/,"[^/]*"),K=b([Le,De]),Q=c("?","[^/]"),Re=c("[",w),We=c("]",w),Fe=c(/[!^]/,"^/"),Je=c(/[a-z]-[a-z]|[0-9]-[0-9]/i,w),qe=c(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ge=c(/[^\]]/,w),Te=b([N,qe,Je,Ge]),X=S([Re,we(Fe),_(Te),We]),Ve=c("{","(?:"),Be=c("}",")"),He=c(/(\d+)\.\.(\d+)/,(e,n,o)=>Ae(+n,+o,Math.min(n.length,o.length)).join("|")),Ke=c(/([a-z]+)\.\.([a-z]+)/,(e,n,o)=>V(n,o).join("|")),Qe=c(/([A-Z]+)\.\.([A-Z]+)/,(e,n,o)=>V(n.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),Xe=b([He,Ke,Qe]),Y=S([Ve,Xe,Be]),Ye=c("{","(?:"),et=c("}",")"),tt=c(",","|"),nt=c(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),rt=c(/[^}]/,w),ot=q(()=>ee),at=b([H,K,Q,X,Y,ot,N,nt,tt,rt]),ee=S([Ye,_(at),et]),it=_(b([Me,ze,Pe,Ee,H,K,Q,X,Y,ee,N,_e,Se])),st=it,lt=B(st),te=lt,ut=c(/\\./,w),ct=c(/./,w),pt=c(/\*\*\*+/,"*"),ft=c(/([^/{[(!])\*\*/,(e,n)=>`${n}*`),dt=c(/(^|.)\*\*(?=[^*/)\]}])/,(e,n)=>`${n}*`),ht=_(b([ut,pt,ft,dt,ct])),gt=ht,mt=B(gt),xt=mt,Z=u((e,n)=>{const o=Array.isArray(e)?e:[e];if(!o.length)return!1;const i=o.map(Z.compile),s=o.every(d=>/(\/(?:\*\*)?|\[\/\])$/.test(d)),p=n.replace(/[\\\/]+/g,"/").replace(/\/$/,s?"/":"");return i.some(d=>d.test(p))},"$");Z.compile=e=>new RegExp(`^${te(xt(e))}$`,"s");var $t=Z;return g(v)})();return t.default||t},"_lazyMatch"),U;const Ut=u((t,r)=>(U||(U=ae(),ae=null),U(t,r)),"default");var It=Object.defineProperty,x=L((t,r)=>It(t,"name",{value:r,configurable:!0}),"r");const Lt=/^[/\\]{2}/,Dt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,le=/^[A-Z]:$/i,ie=/^\/([A-Z]:)?$/i,Rt=/.(\.[^./]+)$/,Wt=/^[/\\]|^[a-z]:[/\\]/i,Ft=x(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),ue=x((t,r)=>{let a="",l=0,f=-1,h=0,m=null;for(let g=0;g<=t.length;++g){if(g<t.length)m=t[g];else{if(m==="/")break;m="/"}if(m==="/"){if(!(f===g-1||h===1))if(h===2){if(a.length<2||l!==2||!a.endsWith(".")||a.at(-2)!=="."){if(a.length>2){const v=a.lastIndexOf("/");v===-1?(a="",l=0):(a=a.slice(0,v),l=a.length-1-a.lastIndexOf("/")),f=g,h=0;continue}else if(a.length>0){a="",l=0,f=g,h=0;continue}}r&&(a+=a.length>0?"/..":"..",l=2)}else a.length>0?a+=`/${t.slice(f+1,g)}`:a=t.slice(f+1,g),l=g-f-1;f=g,h=0}else m==="."&&h!==-1?++h:h=-1}return a},"normalizeString"),z=x(t=>Dt.test(t),"isAbsolute"),ce=x(function(t){if(t.length===0)return".";t=O(t);const r=Lt.exec(t),a=z(t),l=t.at(-1)==="/";return t=ue(t,!a),t.length===0?a?"/":l?"./":".":(l&&(t+="/"),le.test(t)&&(t+="/"),r?a?`//${t}`:`//./${t}`:a&&!z(t)?`/${t}`:t)},"normalize"),Jt=x((...t)=>{let r="";for(const a of t)if(a)if(r.length>0){const l=r[r.length-1]==="/",f=a[0]==="/";l&&f?r+=a.slice(1):r+=l||f?a:`/${a}`}else r+=a;return ce(r)},"join"),I=x(function(...t){t=t.map(l=>O(l));let r="",a=!1;for(let l=t.length-1;l>=-1&&!a;l--){const f=l>=0?t[l]:Ft();!f||f.length===0||(r=`${f}/${r}`,a=z(f))}return r=ue(r,!a),a&&!z(r)?`/${r}`:r.length>0?r:"."},"resolve");x(function(t){return O(t)},"toNamespacedPath");const qt=x(function(t){return Rt.exec(O(t))?.[1]??""},"extname");x(function(t,r){const a=I(t).replace(ie,"$1").split("/"),l=I(r).replace(ie,"$1").split("/");if(l[0][1]===":"&&a[0][1]===":"&&a[0]!==l[0])return l.join("/");const f=[...a];for(const h of f){if(l[0]!==h)break;a.shift(),l.shift()}return[...a.map(()=>".."),...l].join("/")},"relative");const pe=x(t=>{const r=O(t).replace(/\/$/,"").split("/").slice(0,-1);return r.length===1&&le.test(r[0])&&(r[0]+="/"),r.join("/")||(z(t)?"/":".")},"dirname");x(function(t){const r=[t.root,t.dir,t.base??t.name+t.ext].filter(Boolean);return O(t.root?I(...r):r.join("/"))},"format");const Gt=x((t,r)=>{const a=O(t).split("/").pop();return r&&a.endsWith(r)?a.slice(0,-r.length):a},"basename");x(function(t){const r=Wt.exec(t)?.[0]?.replace(/\\/g,"/")??"",a=Gt(t),l=qt(a);return{base:a,dir:pe(t),ext:l,name:a.slice(0,a.length-l.length),root:r}},"parse");x((t,r)=>Ut(r,ce(t)),"matchesGlob");var Tt=Object.defineProperty,D=M((t,r)=>Tt(t,"name",{value:r,configurable:!0}),"r");const Vt="last-update-check.json",fe=D(t=>{const r=At(t);if(r===void 0)throw new Error("Could not find cache directory");return Jt(r,Vt)},"getConfigFile"),Bt=D(t=>{const r=fe(t);try{if(!se(r))return;const{lastUpdateCheck:a}=JSON.parse(bt(r,"utf8"));return a}catch{return}},"getLastUpdate"),Ht=D(t=>{const r=fe(t),a=pe(r);se(a)||wt(a,{recursive:!0}),jt(r,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var Kt=Object.defineProperty,Qt=M((t,r)=>Kt(t,"name",{value:r,configurable:!0}),"g");const Xt=Qt(async(t,r,a)=>{const l=a.replace("__NAME__",t);return await new Promise((f,h)=>{Ot(l,m=>{let g="";m.on("data",v=>g+=v),m.on("end",()=>{try{const v=JSON.parse(g)[r];v||h(new Error("Error getting version")),f(v)}catch{h(new Error("Could not parse version response"))}})}).on("error",m=>h(m))})},"getDistributionVersion");var Yt=Object.defineProperty,en=M((t,r)=>Yt(t,"name",{value:r,configurable:!0}),"i");const an=en(async({alwaysRun:t,debug:r,distTag:a="latest",pkg:l,registryUrl:f="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const m=Bt(l.name);if(t||!m||m<Date.now()-h){const g=await Xt(l.name,a,f);if(Ht(l.name),Pt(g,l.version))return g;r&&console.error(`Latest version (${g}) not newer than current version (${l.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-m}ms since last check.`);return null},"hasNewVersion");export{an as default};
1
+ import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
2
+ import { findCacheDirSync } from '@visulima/find-cache-dir';
3
+ import { get } from 'node:https';
4
+
5
+ var __defProp$4 = Object.defineProperty;
6
+ var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
7
+ const semverGt = /* @__PURE__ */ __name$4((version1, version2) => {
8
+ const v1Components = version1.split(".").map(Number);
9
+ const v2Components = version2.split(".").map(Number);
10
+ for (const [index, v1Component] of v1Components.entries()) {
11
+ if (v1Component > v2Components[index]) {
12
+ return true;
13
+ }
14
+ if (v1Component < v2Components[index]) {
15
+ return false;
16
+ }
17
+ }
18
+ return false;
19
+ }, "semverGt");
20
+
21
+ var __defProp$3 = Object.defineProperty;
22
+ var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
23
+ var __defProp$2$1 = Object.defineProperty;
24
+ var __name$2$1 = /* @__PURE__ */ __name$3((target, value) => __defProp$2$1(target, "name", { value, configurable: true }), "__name$2");
25
+ const DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
26
+ const normalizeWindowsPath = /* @__PURE__ */ __name$2$1((input = "") => {
27
+ if (!input) {
28
+ return input;
29
+ }
30
+ return input.replaceAll("\\", "/").replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
31
+ }, "normalizeWindowsPath");
32
+ var __defProp2 = Object.defineProperty;
33
+ var __name2 = /* @__PURE__ */ __name$3((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
34
+ const UNC_REGEX = /^[/\\]{2}/;
35
+ const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
36
+ const DRIVE_LETTER_RE = /^[A-Z]:$/i;
37
+ const normalizeString = /* @__PURE__ */ __name2((path2, allowAboveRoot) => {
38
+ let result = "";
39
+ let lastSegmentLength = 0;
40
+ let lastSlash = -1;
41
+ let dots = 0;
42
+ let char = null;
43
+ for (let index = 0; index <= path2.length; ++index) {
44
+ if (index < path2.length) {
45
+ char = path2[index];
46
+ } else if (char === "/") {
47
+ break;
48
+ } else {
49
+ char = "/";
50
+ }
51
+ if (char === "/") {
52
+ if (lastSlash === index - 1 || dots === 1) ;
53
+ else if (dots === 2) {
54
+ if (result.length < 2 || lastSegmentLength !== 2 || !result.endsWith(".") || result.at(-2) !== ".") {
55
+ if (result.length > 2) {
56
+ const lastSlashIndex = result.lastIndexOf("/");
57
+ if (lastSlashIndex === -1) {
58
+ result = "";
59
+ lastSegmentLength = 0;
60
+ } else {
61
+ result = result.slice(0, lastSlashIndex);
62
+ lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
63
+ }
64
+ lastSlash = index;
65
+ dots = 0;
66
+ continue;
67
+ } else if (result.length > 0) {
68
+ result = "";
69
+ lastSegmentLength = 0;
70
+ lastSlash = index;
71
+ dots = 0;
72
+ continue;
73
+ }
74
+ }
75
+ if (allowAboveRoot) {
76
+ result += result.length > 0 ? "/.." : "..";
77
+ lastSegmentLength = 2;
78
+ }
79
+ } else {
80
+ if (result.length > 0) {
81
+ result += `/${path2.slice(lastSlash + 1, index)}`;
82
+ } else {
83
+ result = path2.slice(lastSlash + 1, index);
84
+ }
85
+ lastSegmentLength = index - lastSlash - 1;
86
+ }
87
+ lastSlash = index;
88
+ dots = 0;
89
+ } else if (char === "." && dots !== -1) {
90
+ ++dots;
91
+ } else {
92
+ dots = -1;
93
+ }
94
+ }
95
+ return result;
96
+ }, "normalizeString");
97
+ const isAbsolute = /* @__PURE__ */ __name2((path2) => IS_ABSOLUTE_RE.test(path2), "isAbsolute");
98
+ const normalize = /* @__PURE__ */ __name2(function(path2) {
99
+ if (path2.length === 0) {
100
+ return ".";
101
+ }
102
+ path2 = normalizeWindowsPath(path2);
103
+ const isUNCPath = UNC_REGEX.exec(path2);
104
+ const isPathAbsolute = isAbsolute(path2);
105
+ const trailingSeparator = path2.at(-1) === "/";
106
+ path2 = normalizeString(path2, !isPathAbsolute);
107
+ if (path2.length === 0) {
108
+ if (isPathAbsolute) {
109
+ return "/";
110
+ }
111
+ return trailingSeparator ? "./" : ".";
112
+ }
113
+ if (trailingSeparator) {
114
+ path2 += "/";
115
+ }
116
+ if (DRIVE_LETTER_RE.test(path2)) {
117
+ path2 += "/";
118
+ }
119
+ if (isUNCPath) {
120
+ if (!isPathAbsolute) {
121
+ return `//./${path2}`;
122
+ }
123
+ return `//${path2}`;
124
+ }
125
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
126
+ }, "normalize");
127
+ const join = /* @__PURE__ */ __name2((...segments) => {
128
+ let path2 = "";
129
+ for (const seg of segments) {
130
+ if (!seg) {
131
+ continue;
132
+ }
133
+ if (path2.length > 0) {
134
+ const pathTrailing = path2[path2.length - 1] === "/";
135
+ const segLeading = seg[0] === "/";
136
+ const both = pathTrailing && segLeading;
137
+ if (both) {
138
+ path2 += seg.slice(1);
139
+ } else {
140
+ path2 += pathTrailing || segLeading ? seg : `/${seg}`;
141
+ }
142
+ } else {
143
+ path2 += seg;
144
+ }
145
+ }
146
+ return normalize(path2);
147
+ }, "join");
148
+ const dirname = /* @__PURE__ */ __name2((path2) => {
149
+ const segments = normalizeWindowsPath(path2).replace(/\/$/, "").split("/").slice(0, -1);
150
+ if (segments.length === 1 && DRIVE_LETTER_RE.test(segments[0])) {
151
+ segments[0] += "/";
152
+ }
153
+ return segments.join("/") || (isAbsolute(path2) ? "/" : ".");
154
+ }, "dirname");
155
+
156
+ var __defProp$2 = Object.defineProperty;
157
+ var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
158
+ const FILE_NAME = "last-update-check.json";
159
+ const getConfigFile = /* @__PURE__ */ __name$2((packageName) => {
160
+ const cacheDirectory = findCacheDirSync(packageName);
161
+ if (cacheDirectory === undefined) {
162
+ throw new Error("Could not find cache directory");
163
+ }
164
+ return join(cacheDirectory, FILE_NAME);
165
+ }, "getConfigFile");
166
+ const getLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
167
+ const configFile = getConfigFile(packageName);
168
+ try {
169
+ if (!existsSync(configFile)) {
170
+ return undefined;
171
+ }
172
+ const { lastUpdateCheck } = JSON.parse(readFileSync(configFile, "utf8"));
173
+ return lastUpdateCheck;
174
+ } catch {
175
+ return undefined;
176
+ }
177
+ }, "getLastUpdate");
178
+ const saveLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
179
+ const configFile = getConfigFile(packageName);
180
+ const configDirectory = dirname(configFile);
181
+ if (!existsSync(configDirectory)) {
182
+ mkdirSync(configDirectory, { recursive: true });
183
+ }
184
+ writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));
185
+ }, "saveLastUpdate");
186
+
187
+ var __defProp$1 = Object.defineProperty;
188
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
189
+ const getDistributionVersion = /* @__PURE__ */ __name$1(async (packageName, distributionTag, registryUrl) => {
190
+ const url = registryUrl.replace("__NAME__", packageName);
191
+ return await new Promise((resolve, reject) => {
192
+ get(url, (message) => {
193
+ let body = "";
194
+ message.on("data", (chunk) => body += chunk);
195
+ message.on("end", () => {
196
+ try {
197
+ const json = JSON.parse(body);
198
+ const version = json[distributionTag];
199
+ if (!version) {
200
+ reject(new Error("Error getting version"));
201
+ }
202
+ resolve(version);
203
+ } catch {
204
+ reject(new Error("Could not parse version response"));
205
+ }
206
+ });
207
+ }).on("error", (error) => reject(error));
208
+ });
209
+ }, "getDistributionVersion");
210
+
211
+ var __defProp = Object.defineProperty;
212
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
213
+ const hasNewVersion = /* @__PURE__ */ __name(async ({
214
+ alwaysRun,
215
+ debug,
216
+ distTag: distributionTag = "latest",
217
+ pkg,
218
+ registryUrl = "https://registry.npmjs.org/-/package/__NAME__/dist-tags",
219
+ updateCheckInterval = 1e3 * 60 * 60 * 24
220
+ }) => {
221
+ const lastUpdateCheck = getLastUpdate(pkg.name);
222
+ if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {
223
+ const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);
224
+ saveLastUpdate(pkg.name);
225
+ if (semverGt(latestVersion, pkg.version)) {
226
+ return latestVersion;
227
+ }
228
+ if (debug) {
229
+ console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);
230
+ }
231
+ } else if (debug) {
232
+ console.error(
233
+ `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${Date.now() - lastUpdateCheck}ms since last check.`
234
+ );
235
+ }
236
+ return null;
237
+ }, "hasNewVersion");
238
+
239
+ export { hasNewVersion as default };