@visulima/cerebro 3.0.4 → 3.0.6
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 +25 -0
- package/LICENSE.md +346 -0
- package/dist/commands/completion-command.js +1 -1
- package/dist/commands/help-command.js +1 -1
- package/dist/commands/readme-command.js +1 -1
- package/dist/index.js +1 -1
- package/dist/logger/create-pail-logger.js +1 -1
- package/dist/packem_chunks/has-new-version.js +1 -1
- package/dist/packem_shared/Cerebro-58LHN3_T.js +4 -0
- package/dist/packem_shared/VisulimaError-k1qGkvab.js +76 -0
- package/dist/packem_shared/cerebro-error-DWpjBY_M.js +1 -0
- package/dist/packem_shared/{index-BAKCiGjO.js → index-Dpm7gUHe.js} +12 -12
- package/dist/packem_shared/renderError-BISXNU8L-B47ZikMV.js +27 -0
- package/dist/packem_shared/runtime-process-BEw54Ar-.js +1 -0
- package/dist/packem_shared/split-by-case-BZ6XOTIf.js +1 -0
- package/dist/plugins/error-handler-plugin.js +1 -1
- package/dist/plugins/runtime-version-check-plugin.js +1 -1
- package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
- package/dist/util/general/heap-tuning.js +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/Cerebro-CHB2i5uf.js +0 -4
- package/dist/packem_shared/VisulimaError-BheWBD7j.js +0 -76
- package/dist/packem_shared/cerebro-error-DnA3fjrR.js +0 -1
- package/dist/packem_shared/renderError-DjesnVYT-pHitCa3e.js +0 -25
- package/dist/packem_shared/runtime-process-Dmz0vCJy.js +0 -1
- package/dist/packem_shared/split-by-case-DpyL5bdy.js +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const q=globalThis.process??Object.create(null),M={versions:{}},w=new Proxy(q,{get(e,t){if(t in e)return e[t];if(t in M)return M[t]}}),D=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
+
`),Y=(e,t,r,n)=>{const o={column:0,line:-1,...e.start},i={...o,...e.end},l=o.line,s=o.column,a=i.line,d=i.column;let c=Math.max(l-(r+1),0),m=Math.min(t.length,a+n);l===-1&&(c=0),a===-1&&(m=t.length);const p=a-l,f={};if(p)for(let u=0;u<=p;u++){const h=u+l;if(!s)f[h]=!0;else if(u===0){const $=t[h-1]?.length;f[h]=[s,($??0)-s+1]}else if(u===p)f[h]=[0,d];else{const $=t[h-u]?.length;f[h]=[0,$]}}else s===d?f[l]=s?[s,0]:!0:f[l]=[s,(d??0)-(s??0)];return{end:m,markerLines:f,start:c}},H=w.platform==="win32"&&!w.env?.WT_SESSION?">":"❯",K=(e,t,r)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...r,color:{gutter:u=>u,marker:u=>u,message:u=>u,...r?.color}},o=typeof t.start.column=="number";let i=(e.includes("\r")?D(e):e).split(`
|
|
3
|
+
`);typeof n.tabWidth=="number"&&e.includes(" ")&&(i=i.map(u=>u.replaceAll(" "," ".repeat(n.tabWidth))));const{end:l,markerLines:s,start:a}=Y(t,i,n.linesAbove,n.linesBelow),d=String(l).length,{gutter:c,marker:m,message:p}=n.color;let f=i.slice(a,l).map((u,h)=>{const $=a+1+h,x=s[$],R=String($).padStart(d),_=!s[$+1],N=` ${R}${n.showGutter?" |":""}`;if(x){let E="";if(Array.isArray(x)){const z=u.replaceAll(/[^\t]/g," ").slice(0,Math.max(x[0]-1,0)),U=x[1]||1;E=[`
|
|
4
|
+
`,n.prefix+c(N.replaceAll(/\d/g," "))," ",z,m("^").repeat(U)].join(""),_&&n.message&&(E+=` ${p(n.message)}`)}return[n.prefix+m(H),c(N),u.length>0?` ${u}`:"",E].join("")}return`${n.prefix} ${c(N)}${u.length>0?` ${u}`:""}`}).join(`
|
|
5
|
+
`);return n.message&&!o&&(f=`${n.prefix+" ".repeat(d+1)+n.message}
|
|
6
|
+
${f}`),f},b=e=>{let t;return()=>{if(t===void 0){if(typeof w.getBuiltinModule!="function")throw new TypeError(`[@visulima/error] Cannot load ${e}: this runtime implements no process.getBuiltinModule(). Requires Node ^22.14.0 || >=24.10.0, or another runtime providing process.getBuiltinModule().`);t=w.getBuiltinModule(e)}return t}},Q=()=>w.env?.DEBUG==="true",g=(e,...t)=>{if(Q()){const r=t.map(n=>typeof n=="function"?n():n);console.debug(`error:parse-stacktrace: ${e}`,...r)}},y="<unknown>",X=/^(?:node:internal\/|node:|internal\/)/,Z=e=>e!==void 0&&X.test(e),ee=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,te=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,re=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,ne=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,ie=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,oe=/in\s(.*)\s\(at\s(.+)\)\sat/,se=/^(?:.*@)?(.*):(\d+):(\d+)$/,le=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ae=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ce=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,L=/\(error: ([^)]*)\)/,de=/at\s/,ue=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,fe=/Error: |AggregateError:/,C=/^Anonymous function$/,me=/^\s*in\s.*/,pe=/^.*?\s*at\s.*/,he=/^.*?\s*@.*|\[native code\]/,O=(e,t)=>{const r=e.includes("safari-extension"),n=e.includes("safari-web-extension");return r||n?[e.includes("@")?e.split("@")[0]:y,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},B=(e,t)=>{const r=re.exec(t);r&&(e.file=r[1],e.line=+r[2],e.column=+r[3])},ve=e=>{const t=oe.exec(e);if(t){g(`parse nested node error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n=t[2].split(":");return{column:n[2]?+n[2]:void 0,file:n[0],line:n[1]?+n[1]:void 0,methodName:t[1]??y,raw:e,type:void 0}}const r=ie.exec(e);if(r){g(`parse node error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`);const n={column:r[4]?+r[4]:void 0,file:r[2]?r[2].replace(de,""):void 0,line:r[3]?+r[3]:void 0,methodName:r[1]??y,raw:e,type:e.startsWith("internal")?"internal":void 0};return B(n,`${r[2]}:${r[3]}:${r[4]}`),n}},$e=e=>{const t=ee.exec(e);if(t){g(`parse chrome error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const r=t[2]?.startsWith("native"),n=t[2]?.startsWith("eval")||t[1]?.startsWith("eval");let o,i;if(n){const d=te.exec(e);if(d){const c=ue.exec(d[1]);c?(t[2]=c[4]??c[1],t[3]=c[5]??c[2],t[4]=c[3]):d[2]&&(t[2]=d[1]),d[2]&&(o={column:d[4]?+d[4]:void 0,file:d[2],line:d[3]?+d[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const c=ne.exec(e);c&&(i={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0},o={column:c[6]?+c[6]:void 0,file:c[1],line:c[5]?+c[5]:void 0,methodName:"eval",raw:c[0],type:"eval"})}}const[l,s]=O(t[1]?t[1].replace(C,"<anonymous>"):y,t[2]),a={column:t[4]?+t[4]:void 0,evalOrigin:o,file:s,line:t[3]?+t[3]:void 0,methodName:l,raw:e,type:n?"eval":r?"native":Z(s)?"internal":void 0};return i?(a.column=i.column,a.file=i.file,a.line=i.line):B(a,`${s}:${t[3]}:${t[4]}`),a}},ge=(e,t)=>{const r=le.exec(e);if(r){g(`parse gecko error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`);const n=r[3]?.includes(" > eval"),o=n&&r[3]&&ae.exec(r[3]);let i;n&&o&&(r[3]=o[1],i={column:r[5]?+r[5]:void 0,file:r[3],line:r[4]?+r[4]:void 0,methodName:"eval",raw:e,type:"eval"},r[4]=o[2]);const[l,s]=O(r[1]?r[1].replace(C,"<anonymous>"):y,r[3]);let a;(t?.type==="safari"||!n&&t?.type==="firefox")&&t.column?a=t.column:!n&&r[5]&&(a=+r[5]);let d;return(t?.type==="safari"||!n&&t?.type==="firefox")&&t.line?d=t.line:r[4]&&(d=+r[4]),{column:a,evalOrigin:i,file:s,line:d,methodName:l,raw:e,type:n?"eval":s.includes("[native code]")?"native":void 0}}},ye=(e,t)=>{const r=ce.exec(e);if(!(r&&r[2].includes(" > eval"))&&r)return g(`parse firefox error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`),{column:r[4]?+r[4]:t?.column??void 0,file:r[2],line:r[3]?+r[3]:t?.line??void 0,methodName:r[1]||y,raw:e,type:void 0}},we=e=>{const t=se.exec(e);if(t)return g(`parse react android native error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`),{column:t[3]?+t[3]:void 0,file:t[1],line:t[2]?+t[2]:void 0,methodName:y,raw:e,type:void 0}},xe=/(?:^|[(@\s])(?:node:internal\/|node:|internal\/)/,Se=/node_modules[/\\]/,Oe={internals:e=>!xe.test(e),nodeModules:e=>!Se.test(e)},Be=(...e)=>t=>e.every(r=>r(t)),j=(e,{filter:t,frameLimit:r=50}={})=>{const n=e;let o=(typeof n.stacktrace=="string"?n.stacktrace:e.stack??"").split(`
|
|
7
|
+
`).map(i=>(L.test(i)?i.replace(L,"$1"):i).trim()).filter(i=>!fe.test(i)&&i!=="eval code");return t&&(o=o.filter(i=>t(i))),o=o.slice(0,r),o.reduce((i,l,s)=>{if(!l||l.length>1024)return i;let a;if(me.test(l))a=ve(l);else if(pe.test(l))a=$e(l);else if(he.test(l)){let d;if(s===0){const c=e,m=c.columnNumber,p=c.lineNumber,f=c.line,u=c.column;m||p?d={column:m,line:p,type:"firefox"}:(f||u)&&(d={column:u,line:f,type:"safari"})}a=ye(l,d)??ge(l,d)}else a=we(l);return a?i.push(a):g(`parse error stack line: "${l}"`,"not parser found"),i},[])},W=b("node:fs"),S=b("node:path"),be=b("node:process"),Ne=b("node:url"),v=(e,t,r)=>r===0?e:t===" "?e+" ".repeat(r):e+" ".repeat(t*r),T=e=>e.replaceAll("\\","/"),Ee=e=>{if(!e.startsWith("file:"))return e;try{return Ne().fileURLToPath(e)}catch{return e}},ke=(e,t)=>{const r=e.replace("async file:","file:");return T(S().relative(t,Ee(r)))},Ae=(e,t,r)=>{if(t)return r.title(e.message);const n=e.message?`: ${e.message}`:"";return r.title(e.name+n)},P=(e,{color:t,hideErrorTitle:r,indentation:n,prefix:o},i)=>`${v(o,n,i)}${Ae(e,r,t)}
|
|
8
|
+
`,G=(e,{color:t,indentation:r,prefix:n},o)=>{if(e.hint===void 0)return;const i=v(n,r,o);let l="";if(Array.isArray(e.hint))for(const s of e.hint)l+=`${i+s}
|
|
9
|
+
`;else l+=i+e.hint;return t.hint(l)},k=(e,t)=>{if(!t||e.file===void 0||e.line===void 0)return{trace:e};try{const r=t({column:e.column,file:e.file,line:e.line});return r?{source:r.source,trace:{...e,column:r.column??e.column,file:r.file??e.file,line:r.line??e.line}}:{trace:e}}catch{return{trace:e}}},A=(e,t,r=0)=>{const{color:n,cwd:o,displayShortPath:i,indentation:l,prefix:s}=t,{trace:a}=e;let d;a.file===void 0?d="<unknown>":d=i?ke(a.file,o):T(a.file);const{fileLine:c,method:m}=n;return`${v(s,l,r)}at ${a.methodName?`${m(a.methodName)} `:""}${c(d)}:${c(a.line?.toString()??"")}`},Me=(e,t)=>{if(t.allowAllFilePaths)return!0;const r=S().resolve(t.cwd),n=S().resolve(r,e);return n===r||n.startsWith(r+S().sep)},Le=e=>{try{return W().existsSync(e)?W().readFileSync(e,"utf8"):void 0}catch{return}},I=(e,t,r)=>{const{color:n,indentation:o,linesAbove:i,linesBelow:l,prefix:s,showGutter:a,showLineNumbers:d,tabWidth:c}=t,{source:m,trace:p}=e;if(p.file===void 0)return;let f;if(m===void 0){const u=p.file.replace("file://","");if(!Me(u,t))return;const h=Le(u);if(h===void 0)return;f=h}else f=m;return K(f,{start:{column:p.column,line:p.line}},{color:n,linesAbove:i,linesBelow:l,prefix:v(s,o,r),showGutter:a,showLineNumbers:d,tabWidth:c})},J=(e,t,r)=>{if(e.errors.length===0)return;let n=`${v(t.prefix,t.indentation,r)}Errors:
|
|
10
|
+
|
|
11
|
+
`,o=!0;for(const i of e.errors)o?o=!1:n+=`
|
|
12
|
+
|
|
13
|
+
`,n+=F(i,{...t,framesMaxLimit:1,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
|
|
14
|
+
${n}`},We=e=>{if(typeof e=="object"&&e!==null)try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return String(e)},V=(e,t,r,n=new Set)=>{n.add(e);let o=`${v(t.prefix,t.indentation,r)}Caused by:
|
|
15
|
+
|
|
16
|
+
`;const{cause:i}=e;if(!(i instanceof Error)){const a=We(i);return o+=`${v(t.prefix,t.indentation,r)}${t.color.title(a)}
|
|
17
|
+
`,`
|
|
18
|
+
${o}`}o+=P(i,t,r);const l=j(i).shift(),s=G(i,t,r);if(s&&(o+=`${s}
|
|
19
|
+
`),l){const a=k(l,t.sourceMap);if(o+=A(a,t,r),!t.hideErrorCauseCodeView){const d=I(a,t,r);d!==void 0&&(o+=`
|
|
20
|
+
${d}`)}}if(i instanceof AggregateError){const a=J(i,t,r);a!==void 0&&(o+=`
|
|
21
|
+
${a}`)}return i.cause&&(o+=n.has(i)?`
|
|
22
|
+
${v(t.prefix,t.indentation,r+1)}Caused by: [Circular]`:`
|
|
23
|
+
${V(i,t,r+1,n)}`),`
|
|
24
|
+
${o}`},Ce=(e,t)=>(e.length>0?`
|
|
25
|
+
`:"")+e.map(r=>A(k(r,t.sourceMap),t)).join(`
|
|
26
|
+
`),F=(e,t,r)=>{const n={allowAllFilePaths:!1,cwd:be().cwd(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:s=>s,gutter:s=>s,hint:s=>s,marker:s=>s,message:s=>s,method:s=>s,title:s=>s,...t.color}},o=j(e,{filter:t.filterStacktrace,frameLimit:n.framesMaxLimit}),i=o.shift(),l=i?k(i,n.sourceMap):void 0;return[t.hideMessage?void 0:P(e,n,r),G(e,n,r),l?A(l,n,r):void 0,l&&!n.hideErrorCodeView?I(l,n,r):void 0,e instanceof AggregateError?J(e,n,r):void 0,e.cause===void 0||e.cause===null?void 0:V(e,n,r),o.length>0?Ce(o,n):void 0].filter(Boolean).join(`
|
|
27
|
+
`)},je=(e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return F(e,t,0)};export{je as G,Oe as R,H as S,K as W,Be as X,j as Y,b as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=e=>"Deno"in e,t=e=>"Bun"in e,i=()=>{if(r(globalThis)){const e=globalThis.Deno,s=e.execPath();let o=s;try{const{importMeta:n}=globalThis;n?.url&&(o=n.url)}catch{}return[s,o,...e.args]}return process.argv},a=()=>r(globalThis)?globalThis.Deno.cwd():process.cwd(),l=()=>{if(r(globalThis)){const e=globalThis.Deno;return new Proxy(e.env.toObject(),{get:(s,o)=>typeof o=="string"?e.env.get(o):s[o],has:(s,o)=>typeof o=="string"?e.env.has(o):o in s,set:(s,o,n)=>typeof o=="string"?(n===void 0||e.env.set(o,n),!0):!1})}return process.env},c=()=>r(globalThis)?[]:process.execArgv,g=()=>r(globalThis)?globalThis.Deno.execPath():process.execPath,h=()=>{if(r(globalThis)){const e=globalThis.Deno.build?.os??"unknown";return e==="windows"?"win32":e}return process.platform},b=()=>{if(r(globalThis)){const e=globalThis.Deno.build?.arch??"unknown";return e==="x86_64"?"x64":e==="aarch64"?"arm64":e}return process.arch},v=()=>{if(r(globalThis)){const e=globalThis.Deno,s={};return e.version?.deno&&(s.deno=e.version.deno),e.version?.v8&&(s.v8=e.version.v8),e.version?.typescript&&(s.typescript=e.version.typescript),s}if(t(globalThis)){const e=globalThis.Bun,s={...process.versions};return e.version&&(s.bun=e.version),s}return process.versions},p=(e=0)=>{if(r(globalThis))throw globalThis.Deno.exit(e),new Error("Deno exit failed");process.exit(e)},u=(e,s)=>{if(r(globalThis))return()=>{};const o=process;return o.on(e,s),()=>{o.removeListener(e,s)}};export{h as a,b,l as c,i as d,p as e,a as f,v as g,g as h,c as i,u as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const M=String.raw,z=M`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,J=()=>new RegExp(M`\p{RI}{2}|(?)${z}(?:\u200D${z})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const Ue=/^[ \t]*(?:\r\n|\r|\n)/,We=/(?:\r\n|\r|\n)[ \t]*$/,ye=/^(?:[\r\n]|$)/,Ae=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,be=/^[ \t]*[\r\n][ \t\r\n]*$/,$e=/\r\n|\n|\r/g,me=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Be=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,W=J(),N=/[-_./\s]+/g,A=/(\u001B\[[0-9;]*[a-z])/i,F=new RegExp("\\p{Script=Arabic}","u"),Q=new RegExp("\\p{Script=Bengali}","u"),y=new RegExp("\\p{Script=Cyrillic}","u"),V=new RegExp("\\p{Script=Devanagari}","u"),X=new RegExp("\\p{Script=Ethiopic}","u"),b=new RegExp("\\p{Script=Greek}","u"),I=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Y=new RegExp("\\p{Script=Gujarati}","u"),ee=new RegExp("\\p{Script=Gurmukhi}","u"),O=new RegExp("\\p{Script=Hangul}","u"),T=new RegExp("\\p{Script=Hebrew}","u"),te=new RegExp("\\p{Script=Hiragana}","u"),v=new RegExp("\\p{Script=Han}","u"),se=new RegExp("\\p{Script=Kannada}","u"),ne=new RegExp("\\p{Script=Katakana}","u"),ae=new RegExp("\\p{Script=Khmer}","u"),ie=new RegExp("\\p{Script=Lao}","u"),S=new RegExp("\\p{Script=Latin}","u"),le=new RegExp("\\p{Script=Malayalam}","u"),re=new RegExp("\\p{Script=Myanmar}","u"),pe=new RegExp("\\p{Script=Oriya}","u"),ce=new RegExp("\\p{Script=Sinhala}","u"),oe=new RegExp("\\p{Script=Tamil}","u"),ue=new RegExp("\\p{Script=Telugu}","u"),he=new RegExp("\\p{Script=Thai}","u"),fe=new RegExp("\\p{Script=Tibetan}","u"),G=/[\u02BB\u02BC\u0027]/u,ge=e=>e.replace(W,"");class xe{capacity;cache;constructor(s){this.capacity=s,this.cache=new Map}get(s){if(!this.cache.has(s))return;const o=this.cache.get(s);return this.cache.delete(s),this.cache.set(s,o),o}has(s){return this.cache.has(s)}set(s,o){if(this.cache.has(s))this.cache.delete(s);else if(this.cache.size>=this.capacity){const f=this.cache.keys().next().value;f!==void 0&&this.cache.delete(f)}this.cache.set(s,o)}delete(s){this.cache.delete(s)}clear(){this.cache.clear()}size(){return this.cache.size}}const de=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),we=e=>{if(typeof e!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof e}`);return e.replaceAll(de,"")},$=new xe(1e3),Ee=/[.*+?^${}()|[\]\\]/g,ke=e=>{const s=e.join("");if($.has(s)){const x=$.get(s);return x.lastIndex=0,x}const o=e.map(x=>x.replaceAll(Ee,String.raw`\$&`)).join("|"),f=new RegExp(o,"g");return $.set(s,f),f},Se=e=>{const s=[];let o=0,f;for(W.lastIndex=0;(f=W.exec(e))!==null;)f.index>o&&s.push(e.slice(o,f.index)),s.push(f[0]),o=W.lastIndex;return o<e.length&&s.push(e.slice(o)),s.filter(Boolean)},Re=/[ČŠŽĐ]/i,P=new Uint8Array(128),Z=new Uint8Array(128),K=new Uint8Array(128);for(let e=0;e<128;e++)P[e]=e>=65&&e<=90?1:0,Z[e]=e>=97&&e<=122?1:0,K[e]=e>=48&&e<=57?1:0;const m=e=>P[e],H=e=>Z[e],B=e=>K[e],U=(e,s,o,f,x)=>{if(e.length===0)return[];let h=!1;const k=Object.values(s);for(const i of k)if(i(e[0])){h=!0;break}if(!h&&!o)return[e];const g=[...e],w=[];let n=g[0],l="other";const c=Object.entries(s);for(const i of c){const[a,p]=i;if(p(g[0])){l=a;break}}let t=o&&f?g[0]===g[0].toLocaleUpperCase(f):!1;for(let i=1;i<g.length;i++){const a=g[i];let p="other";for(const d of c){const[E,R]=d;if(R(a)){p=E;break}}const u=o&&f?a===a.toLocaleUpperCase(f):!1;let r=!1;x?r=x(l,p,t,u,a,i,g):(l!==p&&l!=="other"&&p!=="other"&&(r=!0),o&&p!=="other"&&!t&&u&&(r=!0)),r?(w.push(n),n=a):n+=a,l=p,o&&(t=u)}return n&&n.length>0&&w.push(n),w.length>0?w:[e]},Ce=(e,s,o,f)=>{if(o.size===0)return s;for(const x of o)if(e.startsWith(x,s))return f.push(x),s+x.length;return s},q=(e,s=new Set)=>{if(e.length===0)return[];if(e.toUpperCase()===e)return[e];let o=0;const f=[],x=e.length;for(let h=1;h<x;h++){const k=Ce(e,o,s,f);if(k!==o){o=k,h=o-1;continue}const g=e.codePointAt(h-1),w=e.codePointAt(h),n=g&&g<128&&m(g),l=w&&w<128&&m(w),c=g&&g<128&&H(g),t=g&&g<128&&B(g),i=w&&w<128&&B(w);if(c&&l){f.push(e.slice(o,h)),o=h;continue}if(t&&!i||!t&&i){f.push(e.slice(o,h)),o=h;continue}if(i&&!t){let a=!1,p=!1;if(h+1<x){const u=e.codePointAt(h+1);a=u&&u<128&&m(u),p=u&&u<128&&B(u)}if(!p&&a){f.push(e.slice(o,h),e.slice(h,h+1)),o=h+1;continue}}if(h+1<x){const a=e.codePointAt(h+1),p=a&&a<128&&H(a);if(n&&l&&p){const u=e.slice(o,h+1);s.has(u)||(f.push(e.slice(o,h)),o=h)}}}return o<x&&f.push(e.slice(o)),f.filter(h=>h!=="")},D=(e,s,o)=>{if(e.length===0)return[];const f=e===e.toLocaleUpperCase(s);if(s.startsWith("de")){if(!f&&e.replaceAll("ß","SS")===e.toLocaleUpperCase(s))return[e];const n=[...e],l=n.length,c=[];let t=n[0],i=n[0]===n[0].toLocaleUpperCase(s),a=i,p=i?0:-1;for(let u=1;u<l;u++){const r=n[u],d=r===r.toLocaleUpperCase(s);if(d===i)t+=r;else if(d)t&&t.length>0&&(c.push(t),t=r),a=!0,p=u;else{if(a&&u-p>1){const E=n[u-1],R=t.slice(0,-1);R&&R.length>0&&c.push(R),t=E+r}else t+=r;a=!1,p=-1}i=d}return t&&t.length>0&&c.push(t),c}if(s.startsWith("uk")||s.startsWith("ru")||s.startsWith("bg")||s.startsWith("sr")||s.startsWith("mk")||s.startsWith("be")){if(!y.test(e)&&!S.test(e))return[e];const n=[...e],l=n.length,c=[];let t=n[0];const i=n[0];let a;y.test(i)?a=1:S.test(i)?a=2:a=0;let p=i===i.toLocaleUpperCase(s);for(let r=1;r<l;r++){const d=n[r];let E;y.test(d)?E=1:S.test(d)?E=2:E=0;const R=d===d.toLocaleUpperCase(s);a!==E&&(a===1||a===2)&&(E===1||E===2)||E===a&&!p&&R?(c.push(t),t=d):t+=d,a=E,p=R}t&&t.length>0&&c.push(t);const u=[];for(let r=0;r<c.length;r++)r<c.length-1&&c[r].length===1&&S.test(c[r])&&y.test(c[r+1][0])?(u.push(c[r]+c[r+1]),r+=1):u.push(c[r]);return u}if(s.startsWith("el")){if(!b.test(e)&&!S.test(e))return[e];const n=[];I.lastIndex=0;let l;for(;(l=I.exec(e))!==null;)n.push(l[0]);n.length===0&&n.push(e);const c=[];if(n.length===1){const t=n[0];if(!t||!b.test(t[0])||t.length===1)return[t??e]}for(const t of n){if(!t)continue;if(!b.test(t[0])||t.length===1){c.push(t);continue}const i=t.length;let a=t[0],p=t[0]===t[0].toLocaleUpperCase(s);for(let u=1;u<i;u++){const r=t[u],d=r===r.toLocaleUpperCase(s);!p&&d?(c.push(a),a=r):a+=r,p=d}a&&c.push(a)}return c}if(s.startsWith("ja")||s.startsWith("ko")){const n=s.startsWith("ja"),l=n?{hiragana:t=>te.test(t),kanji:t=>v.test(t),katakana:t=>ne.test(t),latin:t=>S.test(t)}:{hangul:t=>O.test(t),latin:t=>S.test(t)},c=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(n){const t=U(e,l,!1,s,(a,p)=>a==="hiragana"&&p==="katakana"||a==="katakana"&&p==="hiragana"||a==="hiragana"&&p==="latin"||a==="katakana"&&p==="latin"||a==="kanji"&&p==="latin"||a==="latin"&&(p==="hiragana"||p==="katakana"||p==="kanji")),i=[];for(const a of t){const p=a;p.length===1&&c.has(p)&&i.length>0?i[i.length-1]=i.at(-1)+p:i.push(p)}return i.length>0?i:[e]}return U(e,l,!1,s,(t,i)=>t==="hangul"&&i==="latin"||t==="latin"&&i==="hangul")}if(s.startsWith("sl")){const n=[...e],l=n.length,c=[];let t=n[0],i=n[0]===n[0].toLocaleUpperCase(s);for(let a=1;a<l;a++){const p=n[a],u=p===p.toLocaleUpperCase(s),r=Re.test(p),d=a<l-1&&n[a+1]===n[a+1].toLocaleUpperCase(s);!i&&u||r&&d?(c.push(t),t=p,r&&d&&(c.push(t),t="")):t+=p,i=u}return t&&t.length>0&&c.push(t),c}if(s.startsWith("zh"))return U(e,{han:n=>v.test(n),latin:n=>S.test(n)},!1,s);if(["ar","fa","he","ur"].includes(s.split("-")[0])){const n=l=>T.test(l)||F.test(l);return U(e,{latin:l=>S.test(l),rtl:l=>n(l)},!1,s)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(s.split("-")[0])){const n=l=>V.test(l)||Q.test(l)||Y.test(l)||ee.test(l)||se.test(l)||oe.test(l)||ue.test(l)||le.test(l)||ce.test(l)||he.test(l)||ie.test(l)||fe.test(l)||re.test(l)||X.test(l)||ae.test(l)||pe.test(l);return U(e,{indic:l=>n(l),latin:l=>S.test(l)},!1,s)}if(["be","bg","ru","sr","uk"].includes(s))return U(e,{cyrillic:n=>y.test(n),latin:n=>S.test(n)},!0,s);if(["ar","fa","he"].includes(s))return U(e,{latin:n=>S.test(n),rtl:n=>T.test(n)||F.test(n)},!1,s);if(s.startsWith("ko"))return U(e,{hangul:n=>O.test(n),latin:n=>S.test(n)},!1,s);if(s.startsWith("uz")){if(!y.test(e)&&!S.test(e))return[e];const n=[...e],l=n.length,c=[];let t=n[0],i=n[0]===n[0].toLocaleUpperCase(s);for(let a=1;a<l;a++){const p=n[a],u=p===p.toLocaleUpperCase(s);if(G.test(p)||G.test(n[a-1])){t+=p;continue}!i&&u?(c.push(t),t=p):t+=p,i=u}return t&&t.length>0&&c.push(t),c}const x=[...e],h=x.length,k=[];let g=x[0],w=x[0]===x[0].toLocaleUpperCase(s);for(const n of o)if(e.startsWith(n)){k.push(n),g=x[n.length],w=g===g.toLocaleUpperCase(s);break}for(let n=1;n<h;n++){const l=x[n],c=l===l.toLocaleUpperCase(s);let t=0;for(const i of o)if(e.startsWith(i,n)){k.push(g,i),t=i.length,g="";const a=i.at(-1);a&&(w=a===a.toLocaleUpperCase(s));break}if(t>0){n+=t-1;continue}!w&&c?(k.push(g),g=l):g+=l,w=c}return g&&k.push(g),k},Le=(e,s,o)=>{const f=[],x=A.test(e)?e.split(A).filter(Boolean):[e];for(const h of x){const k=h;if(A.test(k))f.push(k);else{W.lastIndex=0;const g=W.test(k)?Se(k).filter(Boolean):[k];for(const w of g)if(W.lastIndex=0,W.test(w))f.push(w);else if(s){const n=s.toLowerCase().split("-")[0];f.push(...D(w,n,o))}else f.push(...q(w,o))}}return f},je=(e,s={})=>{if(!e||typeof e!="string")return[];const{handleAnsi:o=!1,handleEmoji:f=!1,knownAcronyms:x=[],locale:h,normalize:k=!1,separators:g,stripAnsi:w=!1,stripEmoji:n=!1}=s,l=new Set([...x].toSorted((r,d)=>d.length-r.length));let c=e;w&&(c=we(c)),n&&(c=ge(c));let t;Array.isArray(g)?t=ke(g):g instanceof RegExp?t=g:t=N;const i=[];let a=c;const p=t.flags.includes("g")?t:new RegExp(t.source,`${t.flags}g`);for(;a.length>0;){const r=p.exec(a);if(!r){a===".."?i.push(".."):a==="."?i.push("."):a.length>0&&i.push(a);break}const d=r.index,E=r[0],R=E.length,j=a.slice(0,d),_=a.slice(d+R);if(E.startsWith("../"))i.push(".."),a=a.slice(d+3);else if(E.startsWith("./"))i.push("."),a=a.slice(d+2);else if(d===0&&E==="..")i.push(".."),a=a.slice(2);else if(d===0&&E===".")i.push("."),a=a.slice(1);else{j.length>0&&i.push(j);let C=0;for(;(C=E.indexOf("../",C))!==-1;)i.push(".."),C+=3;for(C=0;(C=E.indexOf("./",C))!==-1;)(C===0||E[C-1]!==".")&&i.push("."),C+=2;let L=_;for(;L.startsWith("../");)i.push(".."),L=L.slice(3);for(;L.startsWith("./");)i.push("."),L=L.slice(2);if(L===".."){i.push("..");break}else if(L==="."){i.push(".");break}else a=L}p.lastIndex=0}if(i.length===0){const r=c.split(t).filter(Boolean);i.push(...r)}let u=[];for(const r of i)o||f?u.push(...Le(r,h,l)):h?u.push(...D(r,h,l)):u.push(...q(r,l));return k&&(u=u.map(r=>l.has(r)?r:h&&r===r.toLocaleUpperCase(h)?r[0]+r.slice(1).toLocaleLowerCase(h):r.toUpperCase()===r&&!l.has(r)?r.slice(0,1)+r.slice(1).toLowerCase():r)),u};export{ye as B,Ae as F,We as R,je as W,me as d,A as k,be as l,$e as m,W as n,Ue as x,Be as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{G as m}from"../packem_shared/renderError-BISXNU8L-B47ZikMV.js";import{e as h}from"../packem_shared/runtime-process-BEw54Ar-.js";const u=(s={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:r,runtime:t}=n,{concise:l,detailed:o=!1,exitOnError:a=!0,formatter:i,logErrors:d=!0,renderOptions:f={}}=s;if(d)if(i)r.error(i(e));else if(!o&&l?.(e))r.error(e.message);else if(o){const c=t.getCwd(),g=m(e,{cwd:c,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...f});r.error(g)}else r.error(e);a&&h(1)},version:"1.0.0"});export{u as errorHandlerPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as p,e as c,g as v}from"../packem_shared/runtime-process-
|
|
1
|
+
import{c as p,e as c,g as v}from"../packem_shared/runtime-process-BEw54Ar-.js";const i=r=>{if(!r||typeof r!="string")return 0;const o=r.split(".");if(o.length===0||!o[0])return 0;const e=Number.parseInt(o[0],10);return Number.isNaN(e)?0:e},a=r=>!r||typeof r!="string"?"":r.replace("v",""),d=()=>{if(typeof Bun<"u"){const e=Bun.version||"";return{major:i(e),type:"bun",version:e}}if(typeof Deno<"u"){const e=Deno.version?.deno||"";return{major:i(e),type:"deno",version:e}}const r=v().node??"",o=a(r);return{major:i(o),type:"node",version:o}},y=(r={})=>({description:"Checks if the current runtime version meets the minimum requirement",init:o=>{const e=d(),m={bun:1,deno:1,node:18};let n;try{const s=p().CEREBRO_MIN_NODE_VERSION,u=s===void 0?void 0:Number.parseInt(s,10);n=Number.isNaN(u)?void 0:u}catch{n=void 0}let t;r.runtimes?.[e.type]?.minVersion!==void 0?t=r.runtimes[e.type].minVersion:e.type==="node"&&n!==void 0?t=n:t=m[e.type],e.major<t&&(o.logger.error(`cerebro requires ${e.type} version ${String(t)} or higher. You have ${e.type} ${e.version}. Read our version support policy: https://github.com/visulima/visulima#supported-runtimes`),c(1)),o.logger.debug(`Runtime version check passed: ${e.type} ${e.version} >= ${String(t)}`)},name:"runtime-version-check",version:"1.0.0"});export{y as runtimeVersionCheckPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as A}from"../../packem_shared/runtime-process-
|
|
1
|
+
import{VERBOSITY_DEBUG as p}from"../../packem_shared/VERBOSITY_DEBUG-XPultrIA.js";import{c as A}from"../../packem_shared/runtime-process-BEw54Ar-.js";var R={},i,C;function m(){return C||(C=1,i=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Alpic",constant:"ALPIC",env:"ALPIC_HOST"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]),i}var U;function l(){return U||(U=1,(function(a){const r=m(),e=process.env;Object.defineProperty(a,"_vendors",{value:r.map(function(n){return n.constant})}),a.name=null,a.isPR=null,a.id=null,e.CI!=="false"&&r.forEach(function(n){const t=(Array.isArray(n.env)?n.env:[n.env]).every(function(o){return E(o)});a[n.constant]=t,t&&(a.name=n.name,a.isPR=I(n),a.id=n.constant)}),a.isCI=!!(e.CI!=="false"&&(e.BUILD_ID||e.BUILD_NUMBER||e.CI||e.CI_APP_ID||e.CI_BUILD_ID||e.CI_BUILD_NUMBER||e.CI_NAME||e.CONTINUOUS_INTEGRATION||e.RUN_ID||a.name));function E(n){return typeof n=="string"?!!e[n]:"env"in n?e[n.env]&&e[n.env].includes(n.includes):"any"in n?n.any.some(function(t){return!!e[t]}):Object.keys(n).every(function(t){return e[t]===n[t]})}function I(n){switch(typeof n.pr){case"string":return!!e[n.pr];case"object":return"env"in n.pr?"any"in n.pr?n.pr.any.some(function(t){return e[n.pr.env]===t}):n.pr.env in e&&e[n.pr.env]!==n.pr.ne:"any"in n.pr?n.pr.any.some(function(t){return!!e[t]}):E(n.pr);default:return null}}})(R)),R}var P=l();const d=5e3,N=(a={})=>({beforeCommand:async r=>{const{fs:e,logger:E,runtime:I}=r,n=I.getPackageName(),t=I.getPackageVersion();if(!n||!t){E.debug("Update notifier: package name or version not provided, skipping...");return}const o=A(),c={alwaysRun:!1,debug:o.CEREBRO_OUTPUT_LEVEL===String(p),distTag:"latest",fs:e,pkg:{name:n,version:t},timeout:d,updateCheckInterval:1e3*60*60*24,...a};if(!(c.alwaysRun||!(o.NO_UPDATE_NOTIFIER||o.NODE_ENV==="test"||r.argv.includes("--no-update-notifier")||P.isCI))){E.debug("Update notifier: skipping check (disabled by environment or flags)");return}try{const _=await(await import("../../packem_chunks/has-new-version.js").then(s=>s.default))(c);if(_){const[{boxen:s},{dim:L,green:v,reset:T,yellow:u}]=await Promise.all([import("@visulima/boxen"),import("@visulima/colorize")]),D=`Update available ${L(t)}${T(" → ")}${v(_)}`;E.log(s(D,{borderColor:S=>u(S),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}catch(_){E.debug("Update notifier: failed to check for updates",_)}},description:"Checks for package updates and notifies users",name:"update-notifier",version:"1.0.0"});export{N as updateNotifierPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as g}from"node:module";import{d as y,h as b,c as j,e as d,i as M}from"../../packem_shared/runtime-process-
|
|
1
|
+
import{createRequire as g}from"node:module";import{d as y,h as b,c as j,e as d,i as M}from"../../packem_shared/runtime-process-BEw54Ar-.js";let _;const h=e=>(_??=g(import.meta.url))(e),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,s]=o.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return o.getBuiltinModule(e)}return h(e)},{execFileSync:v}=u("node:child_process"),{totalmem:x}=u("node:os"),q=/--max-old-space-size=(\d+)/,z=/--max-semi-space-size=(\d+)/,E=e=>Math.floor(x()/1024/1024*e),P=e=>e<=512?4:e<=1024?8:e<=2048?16:e<=4096?32:e<=8192?64:Math.floor(Math.log2(e))*8,l=(e,t)=>{for(const s of t){const r=e.exec(s);if(r)return Number.parseInt(r[1],10)}},A=e=>{const t=e?.maxOldSpacePercent??.75,s=[...M()],r=[...y()],n=l(q,s),c=l(z,s);if(n!==void 0&&c!==void 0)return;const a=n??E(t),m=c??P(a),i=[];if(n===void 0&&i.push(`--max-old-space-size=${String(a)}`),c===void 0&&i.push(`--max-semi-space-size=${String(m)}`),i.length!==0)try{v(b(),[...i,...s,...r.slice(1)],{env:j(),stdio:"inherit"}),d(0)}catch(f){const p=f.status;d(typeof p=="number"?p:1)}};export{A as applyHeapTuning};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/cerebro",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ansi",
|
|
@@ -119,15 +119,15 @@
|
|
|
119
119
|
"provenance": true
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
|
-
"@visulima/colorize": "2.
|
|
123
|
-
"@visulima/tabular": "4.
|
|
122
|
+
"@visulima/colorize": "2.1.1",
|
|
123
|
+
"@visulima/tabular": "4.1.0",
|
|
124
124
|
"fastest-levenshtein": "^1.0.16"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
127
|
"@bomb.sh/tab": ">=0.0.16",
|
|
128
|
-
"@visulima/boxen": "
|
|
129
|
-
"@visulima/find-cache-dir": "3.0.
|
|
130
|
-
"@visulima/pail": "4.
|
|
128
|
+
"@visulima/boxen": "4.0.0",
|
|
129
|
+
"@visulima/find-cache-dir": "3.0.1",
|
|
130
|
+
"@visulima/pail": "4.1.1",
|
|
131
131
|
"github-slugger": ">=2.0.0"
|
|
132
132
|
},
|
|
133
133
|
"peerDependenciesMeta": {
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{createRequire as Te}from"node:module";import{VERBOSITY_DEBUG as T,POSITIONALS_KEY as Q,VERBOSITY_NORMAL as te,VERBOSITY_QUIET as He,VERBOSITY_VERBOSE as Ye}from"./VERBOSITY_DEBUG-XPultrIA.js";import{t as w}from"./cerebro-error-DnA3fjrR.js";import{c as X,d as se,o as ce,e as F,a as Je,b as Ke,f as Ze,h as Qe,i as Xe}from"./runtime-process-Dmz0vCJy.js";import"./renderError-DjesnVYT-pHitCa3e.js";import{h as H}from"./VisulimaError-DTMgXonA-CzaryRgZ.js";import{distance as et}from"fastest-levenshtein";import{k as tt,w as nt}from"./split-by-case-DpyL5bdy.js";let je;const Ue=t=>(je??=Te(import.meta.url))(t),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=t=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[e,n]=W.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return W.getBuiltinModule(t)}return Ue(t)},{writeFile:Re,stat:ze,rm:Fe,readFile:le,readdir:qe,mkdir:We,access:Ge}=Be("node:fs/promises"),J=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let U=class extends w{commandName;constructor(e,n=[]){const o=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(o,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}},xe=class extends w{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}},ot=class extends w{unknownOptions;constructor(e,n){const o=e.join(", "),s=`Found unknown ${e.length===1?"option":"options"}: ${o}`;super(s,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}},it=class extends w{pluginName;constructor(e,n,o){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:o,pluginName:e}),this.name="PluginError",this.pluginName=e,o&&(this.cause=o)}},st=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);X().CEREBRO_OUTPUT_LEVEL===String(T)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const o of n)if(typeof o.init=="function"){this.logger.debug(`initializing plugin: ${o.name}`);try{await o.init(e)}catch(s){const i=new it(o.name,`Failed to initialize: ${s instanceof Error?s.message:String(s)}`,s instanceof Error?s:void 0);throw this.logger.error(i.message),i}}this.initialized=!0}async executeLifecycle(e,n,o){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const s=this.getDependencyOrder();for(const i of s){const l=i[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${i.name}`);try{await(e==="afterCommand"?l(n,o):l(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${i.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const o=this.getDependencyOrder();for(const s of o)if(typeof s.onError=="function"){this.logger.debug(`executing error handler for plugin: ${s.name}`);try{await s.onError(e,n)}catch(i){this.logger.error(`Error in error handler for plugin "${s.name}":`,i)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,o=new Set,s=i=>{if(n.has(i))return;if(o.has(i))throw new Error(`Circular dependency detected involving plugin "${i}"`);const l=this.plugins.get(i);if(!l)throw new Error(`Plugin "${i}" not found`);if(o.add(i),l.dependencies)for(const a of l.dependencies)s(a);o.delete(i),n.add(i),e.push(l)};for(const i of this.plugins.keys())s(i);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}};const G=t=>t.type?.name==="Boolean",at=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},ue=t=>(G(t)||(t.typeLabel=t.typeLabel??at(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),rt=new RegExp(/^-([^\d-])$/),lt=new RegExp(/^--(\S+)/),ct=new RegExp(/^-([^\d-]{2,})$/),ut=t=>rt.test(t)||lt.test(t)||ct.test(t),dt=(t,e)=>{const n=e[0]&&ut(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}};class re extends H{optionName;value;constructor(e,n,o){super({hint:`Pass a valid ${o} value for '${e}'.`,message:`Invalid ${o} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,re.prototype)}}let mt=class Ie extends H{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,Ie.prototype)}},de=class ke extends H{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,ke.prototype)}},ht=class Ee extends H{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,Ee.prototype)}};class x extends H{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,x.prototype)}}const me=(t,e,n)=>{const o=Number(t);if(e&&Number.isNaN(o)&&String(t).trim().toLowerCase()!=="nan")throw new re(n??"",String(t),"Number");return o},he=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",pe=t=>t===Number||typeof t=="function"&&t.name==="Number",fe=t=>t===String||typeof t=="function"&&t.name==="String",pt=(t,e,n={})=>{const{optionName:o,strictTypes:s}=n;return Array.isArray(t)?he(e)?t.map(Boolean):pe(e)?t.map(i=>me(i,s,o)):fe(e)?t.map(String):t.map(i=>e(String(i))):t===null?null:he(e)?!!t:pe(e)?me(t,s,o):fe(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},b=(t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},ft=/-([a-z])/g,gt=/^\d+$/,K=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",wt=t=>t.codePointAt(0)===95,ge=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],we=t=>t==="__proto__"||t==="constructor"||t==="prototype",ye=(t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},ve=(t,e,n,o,s)=>{let i=e.get(t)??n.get(t);if(!i&&o){const l=t.toLowerCase();i=o.get(l)??s?.get(l)}return i},yt=(t,e,n,o)=>{const s=n.debug??!1;b(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),b(s,"Starting argument resolution","resolver"),b(s,"Tokens:","resolver",t),b(s,"Definitions:","resolver",e),b(s,"Processing tokens...","resolver");const i=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,m=n.camelCase?new Map:void 0;for(const c of e)if(i.set(c.name,c),c.alias&&l.set(c.alias,c),n.caseInsensitive&&a&&(a.set(c.name.toLowerCase(),c),c.alias&&u&&u.set(c.alias.toLowerCase(),c)),n.camelCase&&r&&m){const d=c.name.replaceAll(ft,(p,C)=>C.toUpperCase());r.set(c.name,d),m.set(d,c.name)}const h=Object.create(null),f=Object.create(null),y=[],E=[],A=new Set;let I=!1;const O=e.find(c=>c.defaultOption),v=e.some(c=>c.group),$=e.find(c=>c.type===Number);for(let c=0;c<t.length;c++){const d=t[c];if(d.kind==="option-terminator"){h._unknown=o.slice(d.index),I=!0;break}if(d.kind==="option"&&d.name){let p=ve(d.name,i,l,a,u);!p&&d.value===void 0&&$&>.test(d.name)&&(p=$,d.value=d.name,d.name=$.name);let C=!1;if(!p&&n.negation&&d.value===void 0&&d.name.startsWith("no-")){const N=d.name.slice(3),P=ve(N,i,l,a,u);P?.type&&K(P.type)&&(p=P,C=!0)}const g=p?p.name:d.name,k=p?.multiple,D=p?.lazyMultiple;if(Object.hasOwn(f,g)&&f[g]!==void 0&&!k&&!D&&!n.partial)throw new mt(g);if(!p&&n.partial){const N=d.rawName??`--${d.name}${d.value!==void 0&&d.inlineValue?`=${d.value}`:""}`;y.push({index:d.index,value:N});continue}if(!p&&n.stopAtFirstUnknown){h._unknown=o.slice(d.index);break}if(!p&&!n.partial)throw new de(d.name);if(d.value===void 0){const N=t[c+1],P=N?.kind==="option"&&!("name"in N)&&N.value!==void 0,M=N&&p&&!(p.type&&K(p.type))&&(N.kind==="positional"||P),Se=p&&p.defaultOption&&!p.multiple&&!p.lazyMultiple;if(M&&(!p?.defaultOption||Se))if(k){let S=c+1;const ee=[];for(;S<t.length&&(t[S].kind==="positional"||t[S].kind==="option"&&!("name"in t[S])&&t[S].value!==void 0);)ee.push(t[S].value),A.add(t[S].index),S++;f[g]=f[g]===void 0?ee:ge(f[g],ee),c=S-1}else D?(ye(f,g,N.value,!0),A.add(N.index),c++):(f[g]=N.value,A.add(N.index),c++);else p?.type&&K(p.type)?ye(f,g,!C,k):f[g]=k?[]:null}else{let{value:N}=d;if(p?.type&&K(p.type))switch(N){case"":{if(n.partial){f._unknown??=[];const M=`${d.rawName??`--${d.name}`}${d.value?`=${d.value}`:""}`;f._unknown.push(M),E.push({index:d.index,value:M}),N=!0}else throw new de(d.name);break}case"false":{N=!1;break}case"true":{N=!0;break}default:N=!0}const P=[N];if(k){let M=c+1;for(;M<t.length&&t[M].kind==="positional";)P.push(t[M].value),A.add(t[M].index),M++;c=M-1}f[g]===void 0?f[g]=k||D?P:N:k||D?f[g]=ge(f[g],P):f[g]=N}}else if(d.kind==="positional"&&n.stopAtFirstUnknown&&!A.has(d.index)&&!O){b(s,`Found unconsumed positional token at index ${String(d.index)}, stopping processing`,"resolver"),h._unknown=o.slice(d.index);break}}for(const[c,d]of Object.entries(f)){const p=i.get(c);p&&(p.multiple||p.lazyMultiple)&&!Array.isArray(d)&&(f[c]=[d])}const _=c=>c.kind==="option"&&!i.has(c.name??"")&&!l.has(c.name??"")&&(!n.caseInsensitive||!a?.has(c.name?.toLowerCase()??"")&&!u?.has(c.name?.toLowerCase()??""));let L=-1,V=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!I&&(L=t.findIndex(c=>_(c)),L!==-1&&(V=t[L].index)),O){const c=[],d=[];for(const p of t)p.kind==="positional"&&!A.has(p.index)&&p.index<V&&(c.push(p.value),d.push(p));if(c.length>0){const p=f[O.name],C=O.multiple??O.lazyMultiple;p===void 0?C?(d.forEach(g=>A.add(g.index)),f[O.name]=c):(A.add(d[0].index),f[O.name]=c[0]):C&&(d.forEach(g=>A.add(g.index)),f[O.name]=Array.isArray(p)?[...c,...p]:[...c,p])}}if(!n.partial){for(const c of t)if(c.kind==="positional"&&!A.has(c.index))throw new ht(o[c.index])}if(n.partial&&!n.stopAtFirstUnknown){const c=[...y];if(f._unknown)for(const d of E)c.push({index:d.index,value:d.value});for(const d of t)d.kind==="positional"&&!A.has(d.index)&&c.push({index:d.index,value:o[d.index]});c.length>0&&(c.sort((d,p)=>d.index-p.index),h._unknown=c.map(d=>d.value))}if(n.stopAtFirstUnknown&&!I){const c=t.findIndex(p=>p.kind==="positional"&&!A.has(p.index));let d=-1;if(L!==-1&&c!==-1?d=Math.min(L,c):L!==-1?d=L:c!==-1&&(d=c),d>=0){const p=t[d].index;h._unknown=o.slice(p)}}else y.length>0&&!n.partial&&(h._unknown=y.map(c=>c.value));for(const[c,d]of Object.entries(f)){const p=n.camelCase?r?.get(c)??c:c,C=i.get(c);C?.type?h[p]=pt(d,C.type,{optionName:C.name,strictTypes:n.strictTypes}):h[p]=d===void 0?null:d}for(const c of e){const d=n.camelCase?r?.get(c.name)??c.name:c.name;!(d in h)&&c.defaultValue!==void 0&&(c.multiple??c.lazyMultiple?h[d]=Array.isArray(c.defaultValue)?[...c.defaultValue]:[c.defaultValue]:h[d]=c.defaultValue)}if(v){const c={},d={},p={};for(const g of e)if(g.group){const k=Array.isArray(g.group)?g.group:[g.group];for(const D of k)we(D)||(c[D]??={})}for(const g of Object.keys(h))if(!wt(g)){d[g]=h[g];let k=g;n.camelCase&&(k=m?.get(g)??g);const D=i.get(k);if(D?.group){const N=Array.isArray(D.group)?D.group:[D.group];for(const P of N)we(P)||c[P]&&(c[P][g]=h[g])}else p[g]=h[g]}const C={_all:d};for(const[g,k]of Object.entries(c))C[g]=k;Object.keys(p).length>0&&(C._none=p),h._unknown&&(C._unknown=h._unknown),Object.keys(h).forEach(g=>delete h[g]),Object.assign(h,C)}const Y=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));return b(s,"Final parsed result:","resolver",Y),Y},q="-".codePointAt(0),R="=",vt=R.codePointAt(0),Nt="--",$t="-",bt="--",Pe=t=>t.length>2&&t.startsWith(bt),At=t=>Pe(t)&&!t.includes(R,3),Ot=t=>Pe(t)&&t.includes(R,3),_t=t=>{if(t.length!==2||t.codePointAt(0)!==q||t.codePointAt(1)===q)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Ct=t=>!(t.length<=2||t.codePointAt(0)!==q||t.codePointAt(1)===q),xt=t=>{const e=[];let n=0,o=[],s=0,i=-1,l=0;for(;s<o.length||n<t.length;){let a;if(s<o.length?(a=o[s],s++):(a=t[n],n++),l>0?l--:i++,a===Nt){e.push({index:i,kind:"option-terminator"});const u=[...o.slice(s),...t.slice(n)],r=u.map((m,h)=>({index:i+h+1,kind:"positional",value:m}));e.push(...r),i+=u.length;break}if(_t(a)){const u=a.charAt(1);e.push({index:i,kind:"option",name:u,rawName:a});continue}if(Ct(a)&&!a.includes(R)){const u=[];let r="",m=!1;for(let h=1;h<a.length;h++){const f=a.charAt(h);m?r+=f:f.codePointAt(0)===vt?m=!0:u.push(`${$t}${f}`)}if(m)if(u.length>0){const h=u.pop();u.push(`${h}=${r}`)}else u.push(r);o=s<o.length?[...u,...o.slice(s)]:u,s=0,l=u.length;continue}if(At(a)){const u=a.slice(2);e.push({index:i,kind:"option",name:u,rawName:a});continue}if(Ot(a)){const u=a.indexOf(R),r=a.slice(2,u),m=a.slice(u+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:m});continue}if(a.length>2&&a.codePointAt(0)===q&&a.codePointAt(1)!==q&&a.includes(R)){const u=a.indexOf(R),r=a.charAt(1),m=a.slice(u+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:m});continue}e.push({index:i,kind:"positional",value:a})}return e},It=/\d/,kt=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Et=t=>typeof t=="function",Pt=(t,e,n)=>{const o=n?.debug??!1;b(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,i=new Set,l=new Set,a=new Set;let u=0;for(const r of t){if(b(o,"Checking definition:","validation",r),!r.name)throw b(o,"Validation failed: name is required","validation"),new x("Invalid option definition: name is required");if(typeof r.name!="string")throw new x("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new x("Invalid option definition: name cannot be empty");const m=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&l.has(m))throw new x(`Invalid option definition: duplicate name '${r.name}'`);if(i.has(r.name)||e&&a.has(m))throw new x(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&l.add(m),r.alias!==void 0){if(typeof r.alias!="string")throw new x("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new x("Invalid option definition: alias must be a single character");if(It.test(r.alias))throw new x("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new x('Invalid option definition: alias cannot be "-"');const h=e?r.alias.toLowerCase():"";if(i.has(r.alias)||e&&a.has(h))throw new x(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&l.has(h))throw new x(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);i.add(r.alias),e&&a.add(h)}if(r.defaultOption&&(u++,r.type!==void 0&&kt(r.type)))throw new x("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&Et(r.type)))throw new x("Invalid option definition: invalid type")}if(u>1)throw b(o,"Validation failed: multiple defaultOptions not allowed","validation"),new x("Invalid option definition: multiple defaultOptions not allowed");b(o,"Validation completed successfully","validation")};function Lt(t,e={}){const n=e.debug??!1;b(n,"Starting command-line-args parsing","index"),b(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const s=Array.isArray(t)?t:[t];b(n,"Normalized definitions:","index",s),Pt(s,o.caseInsensitive,n?o:void 0);let{argv:i}=o;if(!i&&(i=process.argv.slice(2),process.execArgv.length>0)){const r=new Set(process.execArgv);i=i.filter(m=>!r.has(m))}b(n,"Using argv:","index",i);let l=i;o.caseInsensitive&&(l=i.map(r=>{if(r.startsWith("--")){const m=r.indexOf("="),h=(m===-1?r.slice(2):r.slice(2,m)).toLowerCase();return m===-1?`--${h}`:`--${h}${r.slice(m)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const m=r.slice(1).split("=",2),h=m[0],f=m[1];if(!h)return r;const y=h.toLowerCase();return f===void 0?`-${y}`:`-${y}=${f}`}return r}));const a=xt(l.map(String));b(n,"Tokenized arguments:","index",a);const u=yt(a,s,o,i);return b(n,"Command-line-args parsing completed","index"),u}class Dt{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let ne=class extends w{commandName;constructor(e,n,o){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",o!==void 0&&(this.cause=o)}};const Mt=/^-{1,2}(\w+)(=(.+))?$/,Le=(t,e,n,o)=>{const s=Mt.exec(t);if(s===null)return{};const i=s[1];if(!i)return{};const l=n&&o?n.get(i)??o.get(i):e.find(a=>a.name===i||a.alias===i);return l!==void 0?{argName:l.name,argValue:s[3],option:l}:{}},Ne=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},Vt=new Set(["0","1","false","true"]),St=(t,e,n,o)=>{if(e.length===0||t.length===0)return{};const s=(i,l)=>{const{argName:a,argValue:u,option:r}=Le(l,e,n,o),{lastOption:m}=i;return r&&G(r)&&u&&a?i.partial[a]=Ne(u,r):i.lastName&&m&&G(m)&&Vt.has(l)&&(i.partial[i.lastName]=Ne(l,m)),{lastName:a,lastOption:r,partial:i.partial}};return t.reduce(s,{partial:{}}).partial},Tt=new Set(["0","1","false","true"]),jt=(t,e,n,o)=>{if(e.length===0||t.length===0)return t;const s=(i,l)=>{const{argValue:a,option:u}=Le(l,e,n,o),{lastOption:r}=i;if(r&&G(r)&&Tt.has(l)){const{args:m}=i;return{args:m.slice(0,-1)}}return u&&G(u)&&a?{args:i.args}:{args:[...i.args,l],lastOption:u}};return t.reduce(s,{args:[]}).args},$e=t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},Ut=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Bt=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return Ut(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},Rt=/_./g,zt=/^[A-Z]/,Ft=t=>t.toLowerCase().replaceAll(Rt,e=>e[1]?.toUpperCase()??e).replace(zt,e=>e.toLowerCase()),qt=t=>{if(!t||t.length===0)return{};const e={},n=X();for(const o of t){const s=n[o.name],i=Bt(o,s),l=i===void 0?o.defaultValue:i,a=Ft(o.name);e[a]=l}return e},Wt=t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const s=Array.isArray(o.alias)?o.alias:[o.alias];for(const i of s)n.set(i,o)}return{optionMapByAlias:n,optionMapByName:e}},De=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ne(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new ne(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new ne(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},Gt=(t,e,n,o)=>{const s=new Dt(t.name,t),{_all:i,_unknown:l,positionals:a}=e,u=Object.keys(n).length>0?{...i,...n}:i;Q in u&&delete u[Q],s.argument=a?.[Q]??[],s.rawUnknown=[...l??[]];const r=Object.keys(o).length>0;return s.options=r?{...u,...o}:u,s.env=qt(t.env),s},Ht=(t,e,n)=>{const o=t.options??[],s=o.length>0;let i=$e(s?[...o,...n]:n);if(i.length>0){for(const r of i)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:Q,type:t.argument.type,typeLabel:t.argument.typeLabel},...i]);let l,a;if(s){const{optionMapByAlias:r,optionMapByName:m}=Wt(o);l=jt(e,o,m,r),a=St(e,o,m,r)}else l=e,a={};const u=Lt(i,{argv:l,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:a,parsedArgs:u}},z=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await De(t))(e);let Yt=class extends w{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}},Jt=class extends w{choices;option;value;constructor(e,n,o){super(`Invalid value "${n}" for option "${e}". Allowed values: ${o.join(", ")}`,"INVALID_CHOICE",{choices:o,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=o,this.hint=`Use one of: ${o.map(s=>`--${e} ${s}`).join(", ")}`}};const be=(t,e,n=!1)=>{const o=[];for(const s of t)if(!(!n&&!s.required)&&e[s.name]===void 0){if(s.type?.name==="Boolean"){e[s.name]=!1;continue}o.push(s)}return o},Kt=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:et(t,e)<=t.length/3,j=(t,e)=>{const n=t.toLowerCase();return e.filter(o=>Kt(o.toLowerCase(),n))},Zt=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const s=o.startsWith("--");let i=`Found unknown ${s?"option":"argument"} "${o}"`;if(s){const l=j(o.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...u]=l.map(r=>`--${r}`);i+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
|
|
2
|
-
`))},Qt=(t,e,n)=>{const o=n.__requiredOptions__,s=o?be(o,e,!0):be(t,e,!1);if(s.length>0)throw new Yt(n.name,s.map(i=>i.name));e._unknown&&e._unknown.length>0&&!n.argument&&Zt(e,n)},Xt=(t,e,n)=>{const o=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(o.length>0){const s=o.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(l=>e[l]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(s)throw new xe(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},en=(t,e)=>{const n=e.options;if(n)for(const o of n){if(!o.choices||o.choices.length===0)continue;const s=t[o.name];if(s==null)continue;const i=Array.isArray(s)?s:[s];for(const l of i){const a=String(l);if(!o.choices.includes(a))throw new Jt(o.name,a,o.choices)}}},tn=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const i=e.get(s.name)??[];i.push(s),e.set(s.name,i)}if(typeof s.alias=="string"&&s.alias.length>0){const i=n.get(s.alias)??[];i.push(s),n.set(s.alias,i)}else if(Array.isArray(s.alias)){for(const i of s.alias)if(i.length>0){const l=n.get(i)??[];l.push(s),n.set(i,l)}}}const o=[];for(const[s,i]of e)i.length>1&&o.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[s,i]of n)i.length>1&&o.push(`Duplicate option alias "-${s}" used by options ${i.map(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(o.length>0)throw new Error(o.join(`
|
|
3
|
-
`))},nn=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let o;for(let s=1;s<=e.length;s+=1){const i=e[s-1];if(i===void 0||i.startsWith("-"))break;n.push(i);const l=n.join(" ");t.has(l)&&(o={commandPath:[...n],depth:s})}return o?{argv:e.slice(o.depth),commandPath:o.commandPath}:{argv:e,commandPath:void 0}},B=t=>t.join(" "),Ae=(t,e)=>e&&e.length>0?[...e,t]:[t],on=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),sn=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),an=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let s="",i="";for(let l=0;l<n;l++){const a=t[l];if(tt.test(a)){s?(o.push(s+i+a),s="",i=""):(o.length>0&&o.push(e),s=a);continue}s?(i&&(i+=e),i+=a):(o.length>0&&o.push(e),o.push(a))}return o.join("")},Me=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return an(nt(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(s=>{const i=s,l=i.toLowerCase();return n?(n=!1,on(l)):sn(l)}),"")},rn=/^no-/,ln=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Me(e.name)})},cn=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const o of t.options)e.add(o.name);const n=[];for(const o of t.options)if(o.name.startsWith("no-")){const s=o.name.replace(rn,"");if(!e.has(s)){if(o.type!==Boolean)throw new Error(`Cannot add negated option "${o.name}" to command "${t.name}" because it is not a boolean.`);const i={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:s};n.push(i),e.add(s)}}n.length>0&&t.options.push(...n)},un=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,o=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const l=Me(i.name);o.set(l,i)}const s=Object.keys(n).filter(i=>o.has(i));if(s.length!==0)for(const i of s){const l=i.charAt(2);if(!l)continue;const a=l.toLowerCase()+i.slice(3),u=o.get(i);u&&(u.__negated__=!0),n[a]=!n[i],Reflect.deleteProperty(n,i)}},dn=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:o}=t;for(const s of Object.keys(o)){const i=n.get(s);if(i?.implies){const{implies:l}=i;for(const[a,u]of Object.entries(l))o[a]===void 0&&(o[a]=u)}}},mn=()=>!!process.versions.electron,hn=()=>mn()&&!process.defaultApp,pn=()=>hn()?0:1,fn=t=>t.slice(pn()+1),gn=" ",wn=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,o)=>n===e[o]),yn=t=>{if(typeof t=="string")return t.split(gn);const e=se();return wn(t,e)?fn(t):t},vn=t=>{const e=i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),F(1)},n=(i,l)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let a;if(typeof i=="string")a=i;else try{a=JSON.stringify(i)}catch{a=String(i)}t.error(`Promise rejection: ${a}`)}F(1)},o=ce("uncaughtException",e),s=ce("unhandledRejection",n);return()=>{o(),s()}},Oe=100,Nn=/^[a-z][\w-]*$/i,ae=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new w(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},_e=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new w(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},oe=(t,e)=>{if(typeof t!="object"||t===null)throw new w(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},Z=t=>{const e=ae(t,"Command name");if(e.length>Oe)throw new w(`Command name is too long (maximum ${String(Oe)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new w(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Nn.test(e))throw new w(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},$n=new Set([`
|
|
4
|
-
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),bn=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArgumentLength??1e6;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Argument is too long (maximum ${String(o)} characters)`);if(n.checkDangerousChars){for(const s of t)if($n.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},Ce=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArguments??1e5;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Too many arguments (maximum ${String(o)})`);return t.map(s=>bn(s,n))},An=/^-([^\d-])$/,On=/^--(\S+)/,_n=/^-([^\d-]{2,})$/,ie=t=>An.test(t)||On.test(t)||_n.test(t),Cn={access:(t,e)=>Ge(t,e),mkdir:(t,e)=>We(t,e),readdir:t=>qe(t),readFile:(async(t,e)=>e===void 0?le(t):le(t,e)),rm:(t,e)=>Fe(t,e),stat:t=>ze(t),writeFile:(t,e,n)=>Re(t,e,n)},xn=(t,e,n)=>{const o=e.indexOf("--"),s=o===-1?new Set:new Set(e.slice(o+1)),i=n.filter(u=>u.startsWith("--")&&u!=="--"&&!s.has(u));if(i.length===0)return;const l=(t.options??[]).map(u=>u.name),a=i.flatMap(u=>j(u.slice(2),l).map(r=>`--${r}`));throw new ot(i,a)};class Ve{#t;#e;#u;#d;#p;#f;#O;#_;#C;#N;#x;#$;#I;#k=te;#m;#n;#o;#i;#s;#a;#g=!1;#E;#P=!1;#w;#y;#v;#l=[];#S(){return this.#w===void 0&&(this.#w=[...this.#o.keys()]),this.#w}#L(){return this.#y===void 0&&(this.#y=[...this.#n.keys()]),this.#y}#r(){return this.#v===void 0&&(this.#v=[...this.#S(),...this.#L()]),this.#v}#D(){return this.#l.length===0?J:[...J,...this.#l]}#M(){this.#w=void 0,this.#y=void 0,this.#v=void 0}#b(){if(this.#u===void 0){const e=yn(this.#e.argv);this.#u=Ce(e,{maxArguments:this.#$}),this.#T()}return this.#u}#A(){return this.#N??X()}#h(e){this.#k=e,this.#A().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){const e=this.#A().CEREBRO_OUTPUT_LEVEL,n=e===void 0?Number.NaN:Number(e);return Number.isNaN(n)?this.#k:n}#T(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#h(He),e=!0;break}if(n==="--verbose"||n==="-v"){this.#h(Ye),e=!0;break}if(n==="--debug"){this.#h(T),e=!0;break}}e||this.#h(Object.hasOwn(this.#A(),"DEBUG")?T:te)}#j(){this.#P||(this.#E=vn(this.#t),this.#P=!0)}#U(){return{arch:Ke(),argv:this.#b(),cwd:this.#d,env:this.#N??X(),exit:this.#C??(e=>F(e??0)),platform:Je(),stdin:this.#x}}#V(e,n,o,s){this.#c()===T&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:l,parsedArgs:a}=Ht(e,n,this.#D()),u=Object.keys(l).length>0;let r=a;u&&(r={...a,_all:{...a._all,...l}}),Qt(i,r,e);const m=Gt(e,a,l,o);m.runtime=this,m.argv=this.#b(),m.fs=this.#_??Cn,m.process=this.#U(),m.console=this.#t;const h=e.options&&e.options.length>0;if(h&&e.options){const f=e.options.filter(y=>y.name.startsWith("no-"));for(const y of f){const E=y.name.slice(3),A=`--${y.name}`,I=`--${E}`,O=n.includes(A),v=n.includes(I);if(O&&v)throw new xe(E,y.name)}}return h&&(un(m,e),dn(m,e)),Xt(i,m.options,e),en(m.options,e),this.#I&&xn(e,n,m.rawUnknown),this.#c()===T&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(m.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(m.argument,null,2))),{arguments_:i,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:m}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new w("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#p=e.trim();const o=n.argv??se(),s=n.cwd??Ze();if(this.#e={...n,argv:o,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new w("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new w("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new w("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new w("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const r=["debug","error","info","log","warn"],m=[],h=this.#e.logger;for(const f of r)typeof h[f]!="function"&&m.push(f);if(m.length>0)throw new w(`Logger object is missing required methods: ${m.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:m});this.#t=this.#e.logger}else this.#t={...console,debug:(...r)=>{this.#c()===T&&console.debug(...r)}};this.#f=this.#e.packageVersion,this.#O=this.#e.packageName,this.#d=this.#e.cwd,this.#s="help",this.#a={};const i=n.fs;if(i!==void 0&&(typeof i!="object"||i===null))throw new w("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new w("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new w("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new w("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#_=n.fs,this.#C=n.exit,this.#N=n.env,this.#x=n.stdin??"",this.#$=n.maxArguments,this.#I=n.strictOptions??!1,this.#h(te),this.#n=new Map,this.#o=new Map,this.#i=new Map}setCommandSection(e){return this.#a=e,this}getCommandSection(){return this.#a.header||(this.#a.header=`${this.#p}${this.#f?` v${this.#f}`:""}`),this.#a}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){oe(e,"Command"),Z(e.name);const n=typeof e.execute=="function",o=typeof e.loader=="function";if(n&&o)throw new w(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!o)throw new w(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?Z(e.alias):_e(e.alias,"Command alias").forEach(r=>Z(r))),e.argument&&oe(e.argument,"Command argument"),e.options&&oe(e.options,"Command options"),e.commandPath&&(_e(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{Z(r)}));const s=Ae(e.name,e.commandPath),i=B(s);if(this.#o.has(i))throw new w(`Command with path "${i}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const l=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!l&&u)throw new w(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)ue(r);if(tn(e),cn(e),ln(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),l&&a!==void 0)this.#n.set(i,e);else{if(!l&&a!==void 0&&!u){const r=Ae(a.name,a.commandPath);this.#n.set(B(r),a)}this.#n.set(e.name,e)}if(this.#o.set(i,s),this.#i.set(i,e),this.#M(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const m of r){if(this.#c()===T&&this.#t.debug("adding alias",m),this.#n.has(m))throw new w(`Command alias "${m}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:m,commandName:e.name});this.#n.set(m,e)}}return this}addGlobalOption(e){const n=e,o=new Set(J.map(i=>i.name)),s=new Set(J.map(i=>i.alias).filter(Boolean));if(o.has(n.name))throw new w(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new w(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(i=>i.name)).has(n.name))throw new w(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",ue(n),this.#l.push(n),this}getGlobalOptions(){return this.#D()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#m?this.#m:(this.#m=new st(this.#t),this.#m.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#m)}getCliName(){return this.#p}getPackageVersion(){return this.#f}getPackageName(){return this.#O}getCommands(){return this.#n}getCwd(){return this.#d}dispose(){this.#E?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...s}=e;if(!this.#n.has("help")){const{default:v}=await import("../commands/help-command.js");this.addCommand(new v(this.#n))}const i=this.#L(),l=this.#o;this.#j();const a=this.#b();let u,r=[...a];this.#c()===T&&(this.#t.debug(`process.execPath: ${Qe()}`),this.#t.debug(`process.execArgv: ${Xe().join(" ")}`),this.#t.debug(`process.argv: ${se().join(" ")}`));const m=nn(l,[...a]);if(m.commandPath)u=m.commandPath,r=m.argv;else{if(a.length>1&&a[0]&&a[1]&&!ie(a[0])&&!ie(a[1])){const $=[];let _=0;for(;_<a.length;){const V=a[_];if(!V||ie(V))break;$.push(V),_+=1}const L=B($);if($[0]&&!i.includes($[0])){const V=this.#r(),Y=j(L,V);throw new U(L,Y)}}let v;try{v=dt([null,...i],[...a])}catch($){if($ instanceof Error&&$.name==="INVALID_COMMAND"&&"command"in $){const _=$.command,L=this.#r(),V=j(_,L);throw new U(_,V)}throw $}v.command&&(u=[v.command],r=v.argv)}if(!u)if(this.#s)u=[this.#s];else{const v=this.#r();throw new U("",v)}const h=B(u),f=this.#o.get(h);let y;if(f){if(y=this.#i.get(h),!y||B(f)!==h){const v=this.#r(),$=j(h,v);throw new U(h,$)}}else{const v=u.at(-1);if(y=v?this.#n.get(v):void 0,!y){const $=this.#r(),_=j(h,$);throw new U(h,_)}}if(typeof y.execute!="function"&&typeof y.loader!="function")return this.#t.error(`Command "${y.name}" has no function to execute.`),o?F(1):void 0;const E=r;let A,I;try{({commandArgs:A,toolbox:I}=this.#V(y,E,s,h))}catch(v){if(this.#t.error(v),o)return F(1);throw v}const O=this.getPluginManager();try{!this.#g&&O.hasPlugins()&&(await O.init({cli:this,cwd:this.#d,logger:this.#t}),this.#g=!0),await O.executeLifecycle("execute",I),await O.executeLifecycle("beforeCommand",I);let v;const $=A.global;if($?.help){const _=this.#n.get("help");if(!_)throw new w("Help command not found","COMMAND_NOT_FOUND");v=await z(_,I)}else if($?.version??$?.V){const _=this.#n.get("version");if(!_)throw new w("Version command not found","COMMAND_NOT_FOUND");v=await z(_,I)}else v=await z(y,I);return await O.executeLifecycle("afterCommand",I,v),o?F(0):void 0}catch(v){throw await O.executeErrorHandlers(v,I),v}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...s}=n;ae(e,"Command name");const i=e.split(" ").filter(Boolean),l=B(i),a=this.#o.get(l)?this.#i.get(l):this.#n.get(e);if(!a){const f=this.#r(),y=j(l||e,f);throw new U(e,y)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new w(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...Ce(o,{maxArguments:this.#$})];this.#c()===T&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:m}=this.#V(a,u,s,l||e),h=this.getPluginManager();try{!this.#g&&h.hasPlugins()&&(await h.init({cli:this,cwd:this.#d,logger:this.#t}),this.#g=!0),await h.executeLifecycle("execute",m),await h.executeLifecycle("beforeCommand",m);let f;const y=r.global;if(y?.help){const E=this.#n.get("help");if(!E)throw new w("Help command not found","COMMAND_NOT_FOUND");f=await z(E,m)}else if(y?.version??y?.V){const E=this.#n.get("version");if(!E)throw new w("Version command not found","COMMAND_NOT_FOUND");f=await z(E,m)}else f=await z(a,m);return await h.executeLifecycle("afterCommand",m,f),f}catch(f){throw await h.executeErrorHandlers(f,m),f}}clone(e){const n={...this.#e,...e},o=new Ve(this.#p,n);for(const[s,i]of this.#n)o.#n.set(s,i);for(const[s,i]of this.#o)o.#o.set(s,[...i]);for(const[s,i]of this.#i)o.#i.set(s,i);for(const s of this.#l)o.#l.push(s);return o.#s=this.#s,o.#a={...this.#a},o.#M(),o}async getAction(e){ae(e,"Command name");const n=e.split(" ").filter(Boolean),o=B(n),s=this.#o.get(o)?this.#i.get(o):this.#n.get(e);if(!s){const i=this.#r(),l=j(o||e,i);throw new U(e,l)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return De(s);throw new w(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}export{Ve as Cli};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import{g as b,n as N}from"./renderError-DjesnVYT-pHitCa3e.js";import{S as re,s as ne,W as oe,X as ae,l as ie,Y as se,_ as ue,R as le}from"./renderError-DjesnVYT-pHitCa3e.js";import{h as fe,c as pe}from"./VisulimaError-DTMgXonA-CzaryRgZ.js";const S=(e,t)=>{let r=0,o=t.length-2;for(;r<o;){const n=r+(o-r>>1);if(e<t[n])o=n-1;else if(e>=t[n+1])r=n+1;else{r=n;break}}return r},E=/\n|\r(?!\n)/,P=e=>e.split(E).reduce((t,r)=>(t.push(t.at(-1)+r.length+1),t),[0]),K=(e,t,r)=>{const o=r?.skipChecks??!1;if(!o&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return{column:0,line:0};if(!o&&(typeof t!="number"||typeof e=="string"&&t>=e.length||Array.isArray(e)&&t+1>=e.at(-1)))return{column:0,line:0};if(typeof e=="string"){const a=P(e),i=S(t,a);return{column:t-a[i]+1,line:i+1}}const n=S(t,e);return{column:t-e[n]+1,line:n+1}},B=({applicationType:e,error:t,file:r})=>`You are a very skilled ${r.language??"unknown"} programmer.
|
|
2
|
-
|
|
3
|
-
${e?`You are working on a ${e} application.`:""}
|
|
4
|
-
|
|
5
|
-
Use the following context to find a possible fix for the exception message at the end. Limit your answer to 4 or 5 sentences. Also include a few links to documentation that might help.
|
|
6
|
-
|
|
7
|
-
Use this format in your answer, make sure links are json:
|
|
8
|
-
|
|
9
|
-
FIX
|
|
10
|
-
insert the possible fix here
|
|
11
|
-
ENDFIX
|
|
12
|
-
LINKS
|
|
13
|
-
{"title": "Title link 1", "url": "URL link 1"}
|
|
14
|
-
{"title": "Title link 2", "url": "URL link 2"}
|
|
15
|
-
ENDLINKS
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
Here comes the context and the exception message:
|
|
19
|
-
|
|
20
|
-
Line: ${String(r.line)}
|
|
21
|
-
|
|
22
|
-
File:
|
|
23
|
-
${r.file}
|
|
24
|
-
|
|
25
|
-
Snippet including line numbers:
|
|
26
|
-
${r.snippet??""}
|
|
27
|
-
|
|
28
|
-
Exception class:
|
|
29
|
-
${t.name}
|
|
30
|
-
|
|
31
|
-
Exception message:
|
|
32
|
-
${t.message}`,j=(e,t,r)=>{const o=r.indexOf(e);if(o===-1)return"";const n=o+e.length,a=r.indexOf(t,n);return a===-1?"":r.slice(n,a).trim()},X=e=>{const t=j("FIX","ENDFIX",e);if(!t)return["No solution found.",'Provide this response to the Maintainer of <a href="https://github.com/visulima/visulima/issues/new?assignees=&labels=s%3A+pending+triage%2Cc%3A+bug&projects=&template=bug_report.yml" target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline inline-flex items-center text-sm">@visulima/error</a>.',`"${e}"`].join("</br></br>");const r=j("LINKS","ENDLINKS",e),o=r?r.split(`
|
|
33
|
-
`).map(a=>a.trim()).filter(Boolean).map(a=>{try{return JSON.parse(a)}catch{return}}).filter(a=>a!==void 0):[],n=o.length>0?`
|
|
34
|
-
|
|
35
|
-
## Links
|
|
36
|
-
|
|
37
|
-
${o.map(a=>`- <a href="${a.url}" target="_blank" rel="noopener noreferrer">${a.title}</a>`).join(`
|
|
38
|
-
`)}`:"";return`${t.replaceAll(/"([^"]*)"(?:\s|\.)/g,"<code>$1</code> ")}${n}
|
|
39
|
-
|
|
40
|
-
--------------------
|
|
41
|
-
This solution was generated with the <a href="https://sdk.vercel.ai/" target="_blank" rel="noopener noreferrer">AI SDK</a> and may not be 100% accurate.`},q={handle:e=>e.hint===void 0?Promise.resolve(void 0):typeof e.hint=="string"&&e.hint!==""?Promise.resolve({body:e.hint}):typeof e.hint=="object"&&typeof e.hint.body=="string"?Promise.resolve(e.hint):Array.isArray(e.hint)?Promise.resolve({body:e.hint.join(`
|
|
42
|
-
`)}):Promise.resolve(void 0),name:"errorHint",priority:1},A=e=>`\`\`\`
|
|
43
|
-
${e.trim()}
|
|
44
|
-
\`\`\``,d=e=>`\`\`\`bash
|
|
45
|
-
${e.trim()}
|
|
46
|
-
\`\`\``,h=e=>`\`\`\`ts
|
|
47
|
-
${e.trim()}
|
|
48
|
-
\`\`\``,I=e=>`\`\`\`js
|
|
49
|
-
${e.trim()}
|
|
50
|
-
\`\`\``,c=(e,...t)=>{const r=e.toLowerCase();return t.some(o=>r.includes(o.toLowerCase()))},T=[{name:"esm-cjs-interop",test:e=>{const{message:t}=e;if(c(t,"err_require_esm","cannot use import statement outside a module","must use import to load es module","require() of es module","does not provide an export named"))return{md:["Your project or a dependency may be mixing CommonJS and ES Modules.","","Try:","- Ensure package.json has the correct `type` (either `module` or `commonjs`).","- Use dynamic `import()` when requiring ESM from CJS.","- Prefer ESM-compatible entrypoints from dependencies.","- In Node, align `module` resolution with your bundler config.","","Check Node resolution:",d(`node -v
|
|
51
|
-
cat package.json | jq .type`),"","Example dynamic import in CJS:",I("(async () => { const mod = await import('some-esm'); mod.default(); })();")].join(`
|
|
52
|
-
`),title:"ESM/CJS interop"}}},{name:"missing-default-export",test:e=>{const{message:t}=e;if(c(t,"default export not found","has no default export","does not provide an export named 'default'","is not exported from"))return{md:["Verify your import/export shapes.","","Default export example:",h(`export default function Component() {}
|
|
53
|
-
// import Component from './file'`),"","Named export example:",h(`export function Component() {}
|
|
54
|
-
// import { Component } from './file'`)].join(`
|
|
55
|
-
`),title:"Export mismatch (default vs named)"}}},{name:"port-in-use",test:e=>{const{message:t}=e;if(c(t,"eaddrinuse","address already in use","listen eaddrinuse"))return{md:["Another process is using the port.","","Change the port or stop the other process.","","On macOS/Linux:",d(`lsof -i :3000
|
|
56
|
-
kill -9 <PID>`),"","On Windows (PowerShell):",d(`netstat -ano | findstr :3000
|
|
57
|
-
taskkill /PID <PID> /F`)].join(`
|
|
58
|
-
`),title:"Port already in use"}}},{name:"file-not-found-or-case",test:(e,t)=>{const{message:r}=e;if(c(r,"enoent","module not found","cannot find module"))return{md:["Check the import path and filename case (Linux/macOS are case-sensitive).","If using TS path aliases, verify `tsconfig.paths` and bundler aliases.","","Current file:",A(`${t.file}:${String(t.line)}`)].join(`
|
|
59
|
-
`),title:"Missing file or path case mismatch"}}},{name:"ts-path-mapping",test:e=>{const{message:t}=e;if(c(t,"ts2307","cannot find module")||t.includes("TS2307"))return{md:["If you use path aliases, align TS `paths` with Vite/Webpack resolve aliases.","Ensure file extensions are correct and included in resolver.","","tsconfig.json excerpt:",h(`{
|
|
60
|
-
"compilerOptions": {
|
|
61
|
-
"baseUrl": ".",
|
|
62
|
-
"paths": { "@/*": ["src/*"] }
|
|
63
|
-
}
|
|
64
|
-
}`)].join(`
|
|
65
|
-
`),title:"TypeScript path mapping / resolution"}}},{name:"network-dns-enotfound",test:e=>{const{message:t}=e;if(c(t,"enotfound","getaddrinfo enotfound","dns","fetch failed","ecconnrefused","econnrefused"))return{md:["The host may be unreachable or misconfigured.","","Try:","- Verify the hostname and protocol (http/https).","- Check VPN/proxy and firewall.","- Confirm the service is running and listening on the expected port.","",d(`ping <host>
|
|
66
|
-
nslookup <host>
|
|
67
|
-
curl -v http://<host>:<port>`)].join(`
|
|
68
|
-
`),title:"Network/DNS connection issue"}}},{name:"undefined-property",test:e=>{const{message:t}=e;if(c(t,"cannot read properties of undefined","reading '"))return{md:["A variable or function returned `undefined`.","","Mitigations:","- Add nullish checks before property access.","- Validate function return values and input props/state.","",h("const value = maybe?.prop; // or: if (maybe) { use(maybe.prop) }")].join(`
|
|
69
|
-
`),title:"Accessing property of undefined"}}}],H={handle:(e,t)=>{try{const r=T.map(n=>({match:n.test(e,t),rule:n})).filter(n=>!!n.match);if(r.length===0)return Promise.resolve(void 0);const o=r.toSorted((n,a)=>(n.match.priority??0)-(a.match.priority??0)).map(n=>`#### ${n.match.title}
|
|
70
|
-
|
|
71
|
-
${n.match.md}`).join(`
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
`);return o===""?Promise.resolve(void 0):Promise.resolve({body:o,header:"### Potential fixes detected"})}catch{return Promise.resolve(void 0)}},name:"ruleBasedHints",priority:0};let p=class extends Error{constructor(t){super(t),this.name="NonError"}};const z=()=>{if(!Error.captureStackTrace)return;const e=new Error;return Error.captureStackTrace(e),e.stack},x=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},_={maxDepth:Number.POSITIVE_INFINITY},$=(e,t,r=0)=>b(e)?v(e,t,r):t.maxDepth!==void 0&&r>=t.maxDepth?new p(JSON.stringify(e)):new p(JSON.stringify(e)),C=(e,t,r,o,n)=>{const a=t.map(i=>l(i,o,n+1));return new e(a,r)},v=(e,t,r)=>{if(t.maxDepth!==void 0&&r>=t.maxDepth)return new p(JSON.stringify(e));const{cause:o,errors:n,message:a,name:i,stack:s,...m}=e,O=N(i)??Error,u=i==="AggregateError"&&Array.isArray(n)?C(O,n,a,t,r):new O(a);return!u.name&&i&&(u.name=i),a!==void 0&&(u.message=a),s&&(u.stack=s),D(u,m,o,i,t,r),o!==void 0&&(u.cause=l(o,t,r+1)),J(u,e),u},l=(e,t,r)=>{if(x(e)){if(e.__dataType==="Map"&&Array.isArray(e.value))return new Map(e.value.map(([n,a])=>[l(n,t,r+1),l(a,t,r+1)]));if(e.__dataType==="Set"&&Array.isArray(e.value))return new Set(e.value.map(n=>l(n,t,r+1)));if(b(e))return $(e,t,r);const o={};for(const[n,a]of Object.entries(e))n==="__proto__"||n==="constructor"||n==="prototype"||(o[n]=l(a,t,r+1));return o}return Array.isArray(e)?e.map(o=>l(o,t,r)):e},D=(e,t,r,o,n,a)=>{const i=e;for(const[s,m]of Object.entries(t))if(!(s==="__proto__"||s==="constructor"||s==="prototype")){if(s==="cause"&&r!==void 0||s==="errors"&&o==="AggregateError")continue;Object.defineProperty(i,s,{configurable:!0,enumerable:!0,value:l(m,n,a+1),writable:!0})}},J=(e,t)=>{const r=new Set(["message","name","stack"]);for(const o of Object.keys(t))r.add(o);for(const o of r)if(o in e){const n=Object.getOwnPropertyDescriptor(e,o);n&&!n.enumerable&&Object.defineProperty(e,o,{...n,enumerable:!0})}},w=e=>new p(JSON.stringify(e)),F=e=>new p(JSON.stringify(e)),L=(e,t)=>b(e)?v(e,t,0):$(e,t),G=(e,t={})=>{const r={..._,...t};return e instanceof Error?e:e===null?w(null):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?w(e):Array.isArray(e)?F(e):b(e)?v(e,r,0):x(e)?L(e,r):new p(JSON.stringify(e))},M=e=>{const t=e.methodName&&e.methodName!=="<unknown>"?`${e.methodName} `:"",r=e.file??"<unknown>",o=String(e.line??0),n=String(e.column??0);return t.trim()?` at ${t}(${r}:${o}:${n})`:` at ${r}:${o}:${n}`},Q=(e,t)=>{const r=[];if(t?.header&&(t.header.name||t.header.message)){const o=t.header.name??"Error",n=t.header.message??"";r.push(`${o}${n?": ":""}${n}`)}for(const o of e)r.push(M(o));return r.join(`
|
|
76
|
-
`)},R=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),V=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},g=new WeakSet,k=e=>{const t=Object.getOwnPropertyNames(e);for(const r of t){const o=Object.getOwnPropertyDescriptor(e,r);o&&(o.enumerable||Object.defineProperty(e,r,{...o,enumerable:!0}),o.value&&typeof o.value=="object"&&!Array.isArray(o.value)&&(Object.getPrototypeOf(o.value)===Object.prototype||Object.getPrototypeOf(o.value)===null)&&k(o.value))}},U=e=>{g.add(e);const t=e.toJSON();return g.delete(e),Object.isExtensible(t)&&k(t),t},f=(e,t,r,o,n=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.has(e)?"[Circular]":(r+=1,y(e,o,t,r));if(o.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const a=[];for(const[i,s]of e.entries())a.push([f(i,t,r,o,n),f(s,t,r,o,n)]);return{__dataType:"Map",value:a}}if(e instanceof Set){const a=[];for(const i of e.values())a.push(f(i,t,r,o,n));return{__dataType:"Set",value:a}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(V(e)){if(n.has(e))return"[Circular]";if(o.maxDepth!==void 0&&o.maxDepth!==Number.POSITIVE_INFINITY&&r+1>=o.maxDepth)return{};r+=1,n.add(e);const a={};for(const i in e)a[i]=f(e[i],t,r,o,n);return n.delete(e),a}try{return e}catch{return"[Not Available]"}},y=(e,t,r,o)=>{if(r.add(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!g.has(e))return U(e);const n=Object.create(R);if(Object.defineProperty(n,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(n,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(n,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const i=[];for(const s of e.errors){if(!(s instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.has(s))return Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),n;i.push(y(s,t,r,o))}Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:i,writable:!0})}const a=e.cause;if(a!=null)if(a instanceof Error)r.has(a)?Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:y(a,t,r,o),writable:!0});else{const i=f(a,r,o,t);Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:i,writable:!0})}for(const i in e){if(i==="name"||i==="message"||i==="stack"||i==="cause"||i==="errors")continue;const s=e[i],m=f(s,r,o,t);Object.defineProperty(n,i,{configurable:!0,enumerable:!0,value:m,writable:!0})}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const i of t.exclude)try{delete n[i]}catch{}return n},Z=(e,t={})=>y(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},new Set,0);export{re as CODE_FRAME_POINTER,p as NonError,fe as VisulimaError,ne as addKnownErrorConstructor,B as aiPrompt,X as aiSolutionResponse,z as captureRawStackTrace,oe as codeFrame,ae as composeFilters,G as deserializeError,q as errorHintFinder,M as formatStackFrameLine,Q as formatStacktrace,ie as getErrorCauses,K as indexToLineColumn,b as isErrorLike,pe as isVisulimaError,se as parseStacktrace,ue as renderError,H as ruleBasedFinder,Z as serializeError,le as stackFilters};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./renderError-DjesnVYT-pHitCa3e.js";import{h as r}from"./VisulimaError-DTMgXonA-CzaryRgZ.js";class n extends r{code;context;constructor(e,t,o){super({message:e,name:"CerebroError"}),this.code=t,this.context=o}}export{n as t};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{createRequire as K}from"node:module";let Q;const X=e=>(Q??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[r,t]=b.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return b.getBuiltinModule(e)}return X(e)},{createRequire:W}=Z("node:module"),ee=globalThis.process??Object.create(null),_={versions:{}},A=new Proxy(ee,{get(e,r){if(r in e)return e[r];if(r in _)return _[r]}}),re=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
-
`),te=(e,r,t,n)=>{const s={column:0,line:-1,...e.start},i={...s,...e.end},o=s.line,d=s.column,l=i.line,c=i.column;let a=Math.max(o-(t+1),0),m=Math.min(r.length,l+n);o===-1&&(a=0),l===-1&&(m=r.length);const p=l-o,f={};if(p)for(let u=0;u<=p;u++){const h=u+o;if(!d)f[h]=!0;else if(u===0){const $=r[h-1]?.length;f[h]=[d,($??0)-d+1]}else if(u===p)f[h]=[0,c];else{const $=r[h-u]?.length;f[h]=[0,$]}}else d===c?f[o]=d?[d,0]:!0:f[o]=[d,(c??0)-(d??0)];return{end:m,markerLines:f,start:a}},ne=A.platform==="win32"&&!A.env?.WT_SESSION?">":"❯",ie=(e,r,t)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...t,color:{gutter:u=>u,marker:u=>u,message:u=>u,...t?.color}},s=typeof r.start.column=="number";let i=(e.includes("\r")?re(e):e).split(`
|
|
3
|
-
`);typeof n.tabWidth=="number"&&e.includes(" ")&&(i=i.map(u=>u.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:d,start:l}=te(r,i,n.linesAbove,n.linesBelow),c=String(o).length,{gutter:a,marker:m,message:p}=n.color;let f=i.slice(l,o).map((u,h)=>{const $=l+1+h,E=d[$],Y=String($).padStart(c),z=!d[$+1],N=` ${Y}${n.showGutter?" |":""}`;if(E){let k="";if(Array.isArray(E)){const D=u.replaceAll(/[^\t]/g," ").slice(0,Math.max(E[0]-1,0)),H=E[1]||1;k=[`
|
|
4
|
-
`,n.prefix+a(N.replaceAll(/\d/g," "))," ",D,m("^").repeat(H)].join(""),z&&n.message&&(k+=` ${p(n.message)}`)}return[n.prefix+m(ne),a(N),u.length>0?` ${u}`:"",k].join("")}return`${n.prefix} ${a(N)}${u.length>0?` ${u}`:""}`}).join(`
|
|
5
|
-
`);return n.message&&!s&&(f=`${n.prefix+" ".repeat(c+1)+n.message}
|
|
6
|
-
${f}`),f},S=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&S.set("AggregateError",AggregateError);const He=(e,r)=>{let t;try{t=new e}catch(s){throw new Error(`The error constructor "${e.name}" is not compatible`,{cause:s})}const n=r??t.name;if(S.has(n))throw new Error(`The error constructor "${n}" is already known.`);S.set(n,e)},oe=e=>S.get(e),Ke=e=>e!==null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.message=="string"&&(oe(e.name)!==void 0||e.name==="Error");let se;const le=e=>(se??=W(import.meta.url))(e),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ae=e=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[r,t]=x.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return x.getBuiltinModule(e)}return le(e)},{inspect:ce}=ae("node:util"),Qe=e=>{const r=new Set,t=[];let n=e;for(;n;){if(r.has(n)){console.error(`Circular reference detected in error causes: ${ce(e)}`);break}if(t.push(n),r.add(n),typeof n!="object"||!("cause"in n))break;n=n.cause}return t},de=()=>A.env?.DEBUG==="true",v=(e,...r)=>{if(de()){const t=r.map(n=>typeof n=="function"?n():n);console.debug(`error:parse-stacktrace: ${e}`,...t)}},g="<unknown>",ue=/^(?:node:internal\/|node:|internal\/)/,fe=e=>e!==void 0&&ue.test(e),me=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,pe=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,he=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,$e=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,ve=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,ge=/in\s(.*)\s\(at\s(.+)\)\sat/,ye=/^(?:.*@)?(.*):(\d+):(\d+)$/,we=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,be=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,xe=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,j=/\(error: ([^)]*)\)/,Ee=/at\s/,Se=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,Ne=/Error: |AggregateError:/,C=/^Anonymous function$/,ke=/^\s*in\s.*/,Ae=/^.*?\s*at\s.*/,Me=/^.*?\s*@.*|\[native code\]/,R=(e,r)=>{const t=e.includes("safari-extension"),n=e.includes("safari-web-extension");return t||n?[e.includes("@")?e.split("@")[0]:g,t?`safari-extension:${r}`:`safari-web-extension:${r}`]:[e,r]},B=(e,r)=>{const t=he.exec(r);t&&(e.file=t[1],e.line=+t[2],e.column=+t[3])},Te=e=>{const r=ge.exec(e);if(r){v(`parse nested node error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`);const n=r[2].split(":");return{column:n[2]?+n[2]:void 0,file:n[0],line:n[1]?+n[1]:void 0,methodName:r[1]??g,raw:e,type:void 0}}const t=ve.exec(e);if(t){v(`parse node error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n={column:t[4]?+t[4]:void 0,file:t[2]?t[2].replace(Ee,""):void 0,line:t[3]?+t[3]:void 0,methodName:t[1]??g,raw:e,type:e.startsWith("internal")?"internal":void 0};return B(n,`${t[2]}:${t[3]}:${t[4]}`),n}},_e=e=>{const r=me.exec(e);if(r){v(`parse chrome error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`);const t=r[2]?.startsWith("native"),n=r[2]?.startsWith("eval")||r[1]?.startsWith("eval");let s,i;if(n){const c=pe.exec(e);if(c){const a=Se.exec(c[1]);a?(r[2]=a[4]??a[1],r[3]=a[5]??a[2],r[4]=a[3]):c[2]&&(r[2]=c[1]),c[2]&&(s={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const a=$e.exec(e);a&&(i={column:a[4]?+a[4]:void 0,file:a[2],line:a[3]?+a[3]:void 0},s={column:a[6]?+a[6]:void 0,file:a[1],line:a[5]?+a[5]:void 0,methodName:"eval",raw:a[0],type:"eval"})}}const[o,d]=R(r[1]?r[1].replace(C,"<anonymous>"):g,r[2]),l={column:r[4]?+r[4]:void 0,evalOrigin:s,file:d,line:r[3]?+r[3]:void 0,methodName:o,raw:e,type:n?"eval":t?"native":fe(d)?"internal":void 0};return i?(l.column=i.column,l.file=i.file,l.line=i.line):B(l,`${d}:${r[3]}:${r[4]}`),l}},je=(e,r)=>{const t=we.exec(e);if(t){v(`parse gecko error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n=t[3]?.includes(" > eval"),s=n&&t[3]&&be.exec(t[3]);let i;n&&s&&(t[3]=s[1],i={column:t[5]?+t[5]:void 0,file:t[3],line:t[4]?+t[4]:void 0,methodName:"eval",raw:e,type:"eval"},t[4]=s[2]);const[o,d]=R(t[1]?t[1].replace(C,"<anonymous>"):g,t[3]);let l;(r?.type==="safari"||!n&&r?.type==="firefox")&&r.column?l=r.column:!n&&t[5]&&(l=+t[5]);let c;return(r?.type==="safari"||!n&&r?.type==="firefox")&&r.line?c=r.line:t[4]&&(c=+t[4]),{column:l,evalOrigin:i,file:d,line:c,methodName:o,raw:e,type:n?"eval":d.includes("[native code]")?"native":void 0}}},Le=(e,r)=>{const t=xe.exec(e);if(!(t&&t[2].includes(" > eval"))&&t)return v(`parse firefox error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`),{column:t[4]?+t[4]:r?.column??void 0,file:t[2],line:t[3]?+t[3]:r?.line??void 0,methodName:t[1]||g,raw:e,type:void 0}},We=e=>{const r=ye.exec(e);if(r)return v(`parse react android native error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`),{column:r[3]?+r[3]:void 0,file:r[1],line:r[2]?+r[2]:void 0,methodName:g,raw:e,type:void 0}},Ce=/(?:^|[(@\s])(?:node:internal\/|node:|internal\/)/,Re=/node_modules[/\\]/,Xe={internals:e=>!Ce.test(e),nodeModules:e=>!Re.test(e)},Ze=(...e)=>r=>e.every(t=>t(r)),O=(e,{filter:r,frameLimit:t=50}={})=>{const n=e;let s=(typeof n.stacktrace=="string"?n.stacktrace:e.stack??"").split(`
|
|
7
|
-
`).map(i=>(j.test(i)?i.replace(j,"$1"):i).trim()).filter(i=>!Ne.test(i)&&i!=="eval code");return r&&(s=s.filter(i=>r(i))),s=s.slice(0,t),s.reduce((i,o,d)=>{if(!o||o.length>1024)return i;let l;if(ke.test(o))l=Te(o);else if(Ae.test(o))l=_e(o);else if(Me.test(o)){let c;if(d===0){const a=e,m=a.columnNumber,p=a.lineNumber,f=a.line,u=a.column;m||p?c={column:m,line:p,type:"firefox"}:(f||u)&&(c={column:u,line:f,type:"safari"})}l=Le(o,c)??je(o,c)}else l=We(o);return l?i.push(l):v(`parse error stack line: "${o}"`,"not parser found"),i},[])};let Be;const Oe=e=>(Be??=W(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[r,t]=w.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return w.getBuiltinModule(e)}return Oe(e)},{existsSync:Ie,readFileSync:Pe}=M("node:fs"),{relative:Ve,resolve:L,sep:Ge}=M("node:path"),{cwd:qe}=w,{fileURLToPath:Je}=M("node:url"),y=(e,r,t)=>t===0?e:r===" "?e+" ".repeat(t):e+" ".repeat(r*t),I=e=>e.replaceAll("\\","/"),Fe=(e,r)=>{const t=e.replace("async file:","file:");return I(Ve(r,t.startsWith("file:")?Je(t):t))},Ue=(e,r,t)=>{if(r)return t.title(e.message);const n=e.message?`: ${e.message}`:"";return t.title(e.name+n)},P=(e,{color:r,hideErrorTitle:t,indentation:n,prefix:s},i)=>`${y(s,n,i)}${Ue(e,t,r)}
|
|
8
|
-
`,V=(e,{color:r,indentation:t,prefix:n},s)=>{if(e.hint===void 0)return;const i=y(n,t,s);let o="";if(Array.isArray(e.hint))for(const d of e.hint)o+=`${i+d}
|
|
9
|
-
`;else o+=i+e.hint;return r.hint(o)},G=(e,r)=>{if(!r||e.file===void 0||e.line===void 0)return{trace:e};try{const t=r({column:e.column,file:e.file,line:e.line});return t?{source:t.source,trace:{...e,column:t.column??e.column,file:t.file??e.file,line:t.line??e.line}}:{trace:e}}catch{return{trace:e}}},T=(e,r,t=0)=>{const{color:n,cwd:s,displayShortPath:i,indentation:o,prefix:d}=r,{trace:l}=G(e,r.sourceMap),c=i?Fe(l.file,s):I(l.file),{fileLine:a,method:m}=n;return`${y(d,o,t)}at ${l.methodName?`${m(l.methodName)} `:""}${a(c)}:${a(l.line?.toString()??"")}`},Ye=(e,r)=>{if(r.allowAllFilePaths)return!0;const t=L(r.cwd),n=L(t,e);return n===t||n.startsWith(t+Ge)},q=(e,r,t)=>{const{color:n,indentation:s,linesAbove:i,linesBelow:o,prefix:d,showGutter:l,showLineNumbers:c,tabWidth:a}=r,{source:m,trace:p}=G(e,r.sourceMap);if(p.file===void 0)return;let f;if(m===void 0){const u=p.file.replace("file://","");if(!Ye(u,r)||!Ie(u))return;f=Pe(u,"utf8")}else f=m;return ie(f,{start:{column:p.column,line:p.line}},{color:n,linesAbove:i,linesBelow:o,prefix:y(d,s,t),showGutter:l,showLineNumbers:c,tabWidth:a})},J=(e,r,t)=>{if(e.errors.length===0)return;let n=`${y(r.prefix,r.indentation,t)}Errors:
|
|
10
|
-
|
|
11
|
-
`,s=!0;for(const i of e.errors)s?s=!1:n+=`
|
|
12
|
-
|
|
13
|
-
`,n+=U(i,{...r,framesMaxLimit:1,hideErrorCodeView:r.hideErrorErrorsCodeView},t+1);return`
|
|
14
|
-
${n}`},F=(e,r,t,n=new Set)=>{n.add(e);let s=`${y(r.prefix,r.indentation,t)}Caused by:
|
|
15
|
-
|
|
16
|
-
`;const i=e.cause;s+=P(i,r,t);const o=O(i).shift(),d=V(i,r,t);if(d&&(s+=`${d}
|
|
17
|
-
`),o&&(s+=T(o,r,t),!r.hideErrorCauseCodeView)){const l=q(o,r,t);l!==void 0&&(s+=`
|
|
18
|
-
${l}`)}if(i instanceof AggregateError){const l=J(i,r,t);l!==void 0&&(s+=`
|
|
19
|
-
${l}`)}return i.cause&&(s+=n.has(i)?`
|
|
20
|
-
${y(r.prefix,r.indentation,t+1)}Caused by: [Circular]`:`
|
|
21
|
-
${F(i,r,t+1,n)}`),`
|
|
22
|
-
${s}`},ze=(e,r)=>(e.length>0?`
|
|
23
|
-
`:"")+e.map(t=>T(t,r)).join(`
|
|
24
|
-
`),U=(e,r,t)=>{const n={allowAllFilePaths:!1,cwd:qe(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...r,color:{fileLine:o=>o,gutter:o=>o,hint:o=>o,marker:o=>o,message:o=>o,method:o=>o,title:o=>o,...r.color}},s=O(e,{filter:r.filterStacktrace,frameLimit:n.framesMaxLimit}),i=s.shift();return[r.hideMessage?void 0:P(e,n,t),V(e,n,t),i?T(i,n,t):void 0,i&&!n.hideErrorCodeView?q(i,n,t):void 0,e instanceof AggregateError?J(e,n,t):void 0,e.cause===void 0?void 0:F(e,n,t),s.length>0?ze(s,n):void 0].filter(Boolean).join(`
|
|
25
|
-
`)},er=(e,r={})=>{if(r.framesMaxLimit!==void 0&&r.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return U(e,r,0)};export{Xe as R,ne as S,ie as W,Ze as X,O as Y,er as _,Ke as g,Qe as l,oe as n,He as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const n=s=>"Deno"in s,l=s=>"Bun"in s,i=()=>{if(n(globalThis)){const s=globalThis.Deno,e=s.execPath();let o=e;try{const{importMeta:r}=globalThis;r?.url&&(o=r.url)}catch{}return[e,o,...s.args]}return l(globalThis)?globalThis.Bun.process.argv:process.argv},t=()=>n(globalThis)?globalThis.Deno.cwd():l(globalThis)?globalThis.Bun.process.cwd():process.cwd(),a=()=>{if(n(globalThis)){const s=globalThis.Deno;return new Proxy(s.env.toObject(),{get:(e,o)=>typeof o=="string"?s.env.get(o):e[o],has:(e,o)=>typeof o=="string"?s.env.has(o):o in e,set:(e,o,r)=>typeof o=="string"?(r===void 0||s.env.set(o,r),!0):!1})}return l(globalThis)?globalThis.Bun.process.env:process.env},c=()=>n(globalThis)?[]:l(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,g=()=>n(globalThis)?globalThis.Deno.execPath():l(globalThis)?globalThis.Bun.process.execPath:process.execPath,h=()=>{if(n(globalThis)){const s=globalThis.Deno.build?.os??"unknown";return s==="windows"?"win32":s}return l(globalThis)?globalThis.Bun.platform??"unknown":process.platform},b=()=>{if(n(globalThis)){const s=globalThis.Deno.build?.arch??"unknown";return s==="x86_64"?"x64":s==="aarch64"?"arm64":s}return l(globalThis)?globalThis.Bun.process.arch:process.arch},T=()=>{if(n(globalThis)){const s=globalThis.Deno,e={};return s.version?.deno&&(e.deno=s.version.deno),s.version?.v8&&(e.v8=s.version.v8),s.version?.typescript&&(e.typescript=s.version.typescript),e}if(l(globalThis)){const s=globalThis.Bun,e={...s.process.versions};return s.version&&(e.bun=s.version),e}return process.versions},u=(s=0)=>{if(n(globalThis))throw globalThis.Deno.exit(s),new Error("Deno exit failed");if(l(globalThis))throw globalThis.Bun.process.exit(s),new Error("Bun exit failed");process.exit(s)},p=(s,e)=>{if(n(globalThis))return()=>{};if(l(globalThis)){try{const r=globalThis.Bun;if(r.process?.on)return r.process.on(s,e),()=>{r.process?.removeListener&&r.process.removeListener(s,e)}}catch{}return()=>{}}const o=process;return o.on(s,e),()=>{o.removeListener(s,e)}};export{h as a,b,a as c,i as d,u as e,t as f,T as g,g as h,c as i,p as o};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as J}from"node:module";let Q;const X=e=>(Q??=J(import.meta.url))(e),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Y=e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[t,a]=W.versions.node.split(".").map(Number);if(t>22||t===22&&a>=3||t===20&&a>=16)return W.getBuiltinModule(e)}return X(e)},{createRequire:ee}=Y("node:module"),H=String.raw,T=H`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,te=()=>new RegExp(H`\p{RI}{2}|(?)${T}(?:\u200D${T})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const ve=/^[ \t]*(?:\r\n|\r|\n)/,Te=/(?:\r\n|\r|\n)[ \t]*$/,Fe=/^(?:[\r\n]|$)/,ze=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,Me=/^[ \t]*[\r\n][ \t\r\n]*$/,Ie=/\r\n|\n|\r/g,qe=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Oe=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,m=te(),se=/[-_./\s]+/g,$=/(\u001B\[[0-9;]*[a-z])/i,F=new RegExp("\\p{Script=Arabic}","u"),ne=new RegExp("\\p{Script=Bengali}","u"),b=new RegExp("\\p{Script=Cyrillic}","u"),re=new RegExp("\\p{Script=Devanagari}","u"),ie=new RegExp("\\p{Script=Ethiopic}","u"),j=new RegExp("\\p{Script=Greek}","u"),z=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),le=new RegExp("\\p{Script=Gujarati}","u"),ce=new RegExp("\\p{Script=Gurmukhi}","u"),M=new RegExp("\\p{Script=Hangul}","u"),I=new RegExp("\\p{Script=Hebrew}","u"),oe=new RegExp("\\p{Script=Hiragana}","u"),q=new RegExp("\\p{Script=Han}","u"),ae=new RegExp("\\p{Script=Kannada}","u"),pe=new RegExp("\\p{Script=Katakana}","u"),ue=new RegExp("\\p{Script=Khmer}","u"),he=new RegExp("\\p{Script=Lao}","u"),R=new RegExp("\\p{Script=Latin}","u"),fe=new RegExp("\\p{Script=Malayalam}","u"),ge=new RegExp("\\p{Script=Myanmar}","u"),de=new RegExp("\\p{Script=Oriya}","u"),xe=new RegExp("\\p{Script=Sinhala}","u"),we=new RegExp("\\p{Script=Tamil}","u"),Ee=new RegExp("\\p{Script=Telugu}","u"),ke=new RegExp("\\p{Script=Thai}","u"),Re=new RegExp("\\p{Script=Tibetan}","u"),O=/[\u02BB\u02BC\u0027]/u,Se=e=>e.replace(m,"");class Ce{capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const a=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,a),a}has(t){return this.cache.has(t)}set(t,a){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const f=this.cache.keys().next().value;f!==void 0&&this.cache.delete(f)}this.cache.set(t,a)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}let Le;const Ue=e=>(Le??=ee(import.meta.url))(e),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,me=e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[t,a]=y.versions.node.split(".").map(Number);if(t>22||t===22&&a>=3||t===20&&a>=16)return y.getBuiltinModule(e)}return Ue(e)},{stripVTControlCharacters:be}=me("node:util"),A=new Ce(1e3),We=/[.*+?^${}()|[\]\\]/g,ye=e=>{const t=e.join("");if(A.has(t)){const d=A.get(t);return d.lastIndex=0,d}const a=e.map(d=>d.replaceAll(We,String.raw`\$&`)).join("|"),f=new RegExp(a,"g");return A.set(t,f),f},$e=e=>{const t=[];let a=0,f;for(m.lastIndex=0;(f=m.exec(e))!==null;)f.index>a&&t.push(e.slice(a,f.index)),t.push(f[0]),a=m.lastIndex;return a<e.length&&t.push(e.slice(a)),t.filter(Boolean)},je=/[ČŠŽĐ]/i,P=new Uint8Array(128),D=new Uint8Array(128),K=new Uint8Array(128);for(let e=0;e<128;e++)P[e]=e>=65&&e<=90?1:0,D[e]=e>=97&&e<=122?1:0,K[e]=e>=48&&e<=57?1:0;const B=e=>P[e],G=e=>D[e],_=e=>K[e],U=(e,t,a,f,d)=>{if(e.length===0)return[];let h=!1;const k=Object.values(t);for(const i of k)if(i(e[0])){h=!0;break}if(!h&&!a)return[e];const g=[...e],w=[];let n=g[0],l="other";const p=Object.entries(t);for(const i of p){const[r,o]=i;if(o(g[0])){l=r;break}}let s=a&&f?g[0]===g[0].toLocaleUpperCase(f):!1;for(let i=1;i<g.length;i++){const r=g[i];let o="other";for(const x of p){const[E,S]=x;if(S(r)){o=E;break}}const u=a&&f?r===r.toLocaleUpperCase(f):!1;let c=!1;d?c=d(l,o,s,u,r,i,g):(l!==o&&l!=="other"&&o!=="other"&&(c=!0),a&&o!=="other"&&!s&&u&&(c=!0)),c?(w.push(n),n=r):n+=r,l=o,a&&(s=u)}return n&&n.length>0&&w.push(n),w.length>0?w:[e]},Ae=(e,t,a,f)=>{if(a.size===0)return t;for(const d of a)if(e.startsWith(d,t))return f.push(d),t+d.length;return t},N=(e,t=new Set)=>{if(e.length===0)return[];if(e.toUpperCase()===e)return[e];let a=0;const f=[],d=e.length;for(let h=1;h<d;h++){const k=Ae(e,a,t,f);if(k!==a){a=k,h=a-1;continue}const g=e.codePointAt(h-1),w=e.codePointAt(h),n=g&&g<128&&B(g),l=w&&w<128&&B(w),p=g&&g<128&&G(g),s=g&&g<128&&_(g),i=w&&w<128&&_(w);if(p&&l){f.push(e.slice(a,h)),a=h;continue}if(s&&!i||!s&&i){f.push(e.slice(a,h)),a=h;continue}if(i&&!s){let r=!1,o=!1;if(h+1<d){const u=e.codePointAt(h+1);r=u&&u<128&&B(u),o=u&&u<128&&_(u)}if(!o&&r){f.push(e.slice(a,h),e.slice(h,h+1)),a=h+1;continue}}if(h+1<d){const r=e.codePointAt(h+1),o=r&&r<128&&G(r);if(n&&l&&o){const u=e.slice(a,h+1);t.has(u)||(f.push(e.slice(a,h)),a=h)}}}return a<d&&f.push(e.slice(a)),f.filter(h=>h!=="")},V=(e,t,a)=>{if(e.length===0)return[];const f=e===e.toLocaleUpperCase(t);if(t.startsWith("de")){if(!f&&e.replaceAll("ß","SS")===e.toLocaleUpperCase(t))return[e];const n=[...e],l=n.length,p=[];let s=n[0],i=n[0]===n[0].toLocaleUpperCase(t),r=i,o=i?0:-1;for(let u=1;u<l;u++){const c=n[u],x=c===c.toLocaleUpperCase(t);if(x===i)s+=c;else if(x)s&&s.length>0&&(p.push(s),s=c),r=!0,o=u;else{if(r&&u-o>1){const E=n[u-1],S=s.slice(0,-1);S&&S.length>0&&p.push(S),s=E+c}else s+=c;r=!1,o=-1}i=x}return s&&s.length>0&&p.push(s),p}if(t.startsWith("uk")||t.startsWith("ru")||t.startsWith("bg")||t.startsWith("sr")||t.startsWith("mk")||t.startsWith("be")){if(!b.test(e)&&!R.test(e))return[e];const n=[...e],l=n.length,p=[];let s=n[0];const i=n[0];let r;b.test(i)?r=1:R.test(i)?r=2:r=0;let o=i===i.toLocaleUpperCase(t);for(let c=1;c<l;c++){const x=n[c];let E;b.test(x)?E=1:R.test(x)?E=2:E=0;const S=x===x.toLocaleUpperCase(t);r!==E&&(r===1||r===2)&&(E===1||E===2)||E===r&&!o&&S?(p.push(s),s=x):s+=x,r=E,o=S}s&&s.length>0&&p.push(s);const u=[];for(let c=0;c<p.length;c++)c<p.length-1&&p[c].length===1&&R.test(p[c])&&b.test(p[c+1][0])?(u.push(p[c]+p[c+1]),c+=1):u.push(p[c]);return u}if(t.startsWith("el")){if(!j.test(e)&&!R.test(e))return[e];const n=[];z.lastIndex=0;let l;for(;(l=z.exec(e))!==null;)n.push(l[0]);n.length===0&&n.push(e);const p=[];if(n.length===1){const s=n[0];if(!s||!j.test(s[0])||s.length===1)return[s??e]}for(const s of n){if(!s)continue;if(!j.test(s[0])||s.length===1){p.push(s);continue}const i=s.length;let r=s[0],o=s[0]===s[0].toLocaleUpperCase(t);for(let u=1;u<i;u++){const c=s[u],x=c===c.toLocaleUpperCase(t);!o&&x?(p.push(r),r=c):r+=c,o=x}r&&p.push(r)}return p}if(t.startsWith("ja")||t.startsWith("ko")){const n=t.startsWith("ja"),l=n?{hiragana:s=>oe.test(s),kanji:s=>q.test(s),katakana:s=>pe.test(s),latin:s=>R.test(s)}:{hangul:s=>M.test(s),latin:s=>R.test(s)},p=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(n){const s=U(e,l,!1,t,(r,o)=>r==="hiragana"&&o==="katakana"||r==="katakana"&&o==="hiragana"||r==="hiragana"&&o==="latin"||r==="katakana"&&o==="latin"||r==="kanji"&&o==="latin"||r==="latin"&&(o==="hiragana"||o==="katakana"||o==="kanji")),i=[];for(const r of s){const o=r;o.length===1&&p.has(o)&&i.length>0?i[i.length-1]=i.at(-1)+o:i.push(o)}return i.length>0?i:[e]}return U(e,l,!1,t,(s,i)=>s==="hangul"&&i==="latin"||s==="latin"&&i==="hangul")}if(t.startsWith("sl")){const n=[...e],l=n.length,p=[];let s=n[0],i=n[0]===n[0].toLocaleUpperCase(t);for(let r=1;r<l;r++){const o=n[r],u=o===o.toLocaleUpperCase(t),c=je.test(o),x=r<l-1&&n[r+1]===n[r+1].toLocaleUpperCase(t);!i&&u||c&&x?(p.push(s),s=o,c&&x&&(p.push(s),s="")):s+=o,i=u}return s&&s.length>0&&p.push(s),p}if(t.startsWith("zh"))return U(e,{han:n=>q.test(n),latin:n=>R.test(n)},!1,t);if(["ar","fa","he","ur"].includes(t.split("-")[0])){const n=l=>I.test(l)||F.test(l);return U(e,{latin:l=>R.test(l),rtl:l=>n(l)},!1,t)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(t.split("-")[0])){const n=l=>re.test(l)||ne.test(l)||le.test(l)||ce.test(l)||ae.test(l)||we.test(l)||Ee.test(l)||fe.test(l)||xe.test(l)||ke.test(l)||he.test(l)||Re.test(l)||ge.test(l)||ie.test(l)||ue.test(l)||de.test(l);return U(e,{indic:l=>n(l),latin:l=>R.test(l)},!1,t)}if(["be","bg","ru","sr","uk"].includes(t))return U(e,{cyrillic:n=>b.test(n),latin:n=>R.test(n)},!0,t);if(["ar","fa","he"].includes(t))return U(e,{latin:n=>R.test(n),rtl:n=>I.test(n)||F.test(n)},!1,t);if(t.startsWith("ko"))return U(e,{hangul:n=>M.test(n),latin:n=>R.test(n)},!1,t);if(t.startsWith("uz")){if(!b.test(e)&&!R.test(e))return[e];const n=[...e],l=n.length,p=[];let s=n[0],i=n[0]===n[0].toLocaleUpperCase(t);for(let r=1;r<l;r++){const o=n[r],u=o===o.toLocaleUpperCase(t);if(O.test(o)||O.test(n[r-1])){s+=o;continue}!i&&u?(p.push(s),s=o):s+=o,i=u}return s&&s.length>0&&p.push(s),p}const d=[...e],h=d.length,k=[];let g=d[0],w=d[0]===d[0].toLocaleUpperCase(t);for(const n of a)if(e.startsWith(n)){k.push(n),g=d[n.length],w=g===g.toLocaleUpperCase(t);break}for(let n=1;n<h;n++){const l=d[n],p=l===l.toLocaleUpperCase(t);let s=0;for(const i of a)if(e.startsWith(i,n)){k.push(g,i),s=i.length,g="";const r=i.at(-1);r&&(w=r===r.toLocaleUpperCase(t));break}if(s>0){n+=s-1;continue}!w&&p?(k.push(g),g=l):g+=l,w=p}return g&&k.push(g),k},Be=(e,t,a)=>{const f=[],d=$.test(e)?e.split($).filter(Boolean):[e];for(const h of d){const k=h;if($.test(k))f.push(k);else{m.lastIndex=0;const g=m.test(k)?$e(k).filter(Boolean):[k];for(const w of g)if(m.lastIndex=0,m.test(w))f.push(w);else if(t){const n=t.toLowerCase().split("-")[0];f.push(...V(w,n,a))}else f.push(...N(w,a))}}return f},Ge=(e,t={})=>{if(!e||typeof e!="string")return[];const{handleAnsi:a=!1,handleEmoji:f=!1,knownAcronyms:d=[],locale:h,normalize:k=!1,separators:g,stripAnsi:w=!1,stripEmoji:n=!1}=t,l=new Set([...d].toSorted((c,x)=>x.length-c.length));let p=e;w&&(p=be(p)),n&&(p=Se(p));let s;Array.isArray(g)?s=ye(g):g instanceof RegExp?s=g:s=se;const i=[];let r=p;const o=s.flags.includes("g")?s:new RegExp(s.source,`${s.flags}g`);for(;r.length>0;){const c=o.exec(r);if(!c){r===".."?i.push(".."):r==="."?i.push("."):r.length>0&&i.push(r);break}const x=c.index,E=c[0],S=E.length,v=r.slice(0,x),Z=r.slice(x+S);if(E.startsWith("../"))i.push(".."),r=r.slice(x+3);else if(E.startsWith("./"))i.push("."),r=r.slice(x+2);else if(x===0&&E==="..")i.push(".."),r=r.slice(2);else if(x===0&&E===".")i.push("."),r=r.slice(1);else{v.length>0&&i.push(v);let C=0;for(;(C=E.indexOf("../",C))!==-1;)i.push(".."),C+=3;for(C=0;(C=E.indexOf("./",C))!==-1;)(C===0||E[C-1]!==".")&&i.push("."),C+=2;let L=Z;for(;L.startsWith("../");)i.push(".."),L=L.slice(3);for(;L.startsWith("./");)i.push("."),L=L.slice(2);if(L===".."){i.push("..");break}else if(L==="."){i.push(".");break}else r=L}o.lastIndex=0}if(i.length===0){const c=p.split(s).filter(Boolean);i.push(...c)}let u=[];for(const c of i)a||f?u.push(...Be(c,h,l)):h?u.push(...V(c,h,l)):u.push(...N(c,l));return k&&(u=u.map(c=>l.has(c)?c:h&&c===c.toLocaleUpperCase(h)?c[0]+c.slice(1).toLocaleLowerCase(h):c.toUpperCase()===c&&!l.has(c)?c.slice(0,1)+c.slice(1).toLowerCase():c)),u};export{Fe as B,ze as F,Te as R,qe as d,$ as k,Me as l,Ie as m,m as n,Ge as w,ve as x,Oe as y};
|