@visulima/cerebro 3.0.0-alpha.31 → 3.0.0-alpha.32

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE.md +841 -6
  3. package/README.md +38 -8
  4. package/dist/commands/completion-command.d.ts +1 -1
  5. package/dist/commands/completion-command.js +1 -1
  6. package/dist/commands/help-command.d.ts +1 -1
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +1 -1
  9. package/dist/commands/readme-command.js +19 -19
  10. package/dist/commands/version-command.d.ts +1 -1
  11. package/dist/index.d.ts +18 -3
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.d.ts +29 -4
  14. package/dist/logger/create-pail-logger.js +1 -1
  15. package/dist/packem_chunks/has-new-version.js +1 -1
  16. package/dist/packem_shared/Cerebro-BsroI2VY.js +4 -0
  17. package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +1 -0
  18. package/dist/packem_shared/VisulimaError-DyMHh9O-.js +76 -0
  19. package/dist/packem_shared/cerebro-error-z8DS5U8c.js +1 -0
  20. package/dist/packem_shared/{plugin-manager.d-BSQtHbWS.d.ts → command.d-DbhtfXF4.d.ts} +235 -216
  21. package/dist/packem_shared/index-BSKOOIL6.js +29 -0
  22. package/dist/packem_shared/{index.d-Br8HpP0A.d.ts → index.d-BL4NtVR3.d.ts} +37 -3
  23. package/dist/packem_shared/renderError-Dqej8k13-BmipVhik.js +25 -0
  24. package/dist/packem_shared/{runtime-process-hJz7FqPN.js → runtime-process-Dmz0vCJy.js} +1 -1
  25. package/dist/packem_shared/split-by-case-C-dbSFCl.js +1 -0
  26. package/dist/plugins/error-handler-plugin.d.ts +2 -2
  27. package/dist/plugins/error-handler-plugin.js +1 -1
  28. package/dist/plugins/runtime-version-check-plugin.d.ts +1 -1
  29. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  30. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +11 -4
  31. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  32. package/dist/util/general/heap-tuning.js +1 -1
  33. package/package.json +7 -7
  34. package/dist/packem_shared/Cerebro-ChUYLbTK.js +0 -4
  35. package/dist/packem_shared/VisulimaError-CVxSPzeQ.js +0 -76
  36. package/dist/packem_shared/cerebro-error-etNTKvnJ.js +0 -1
  37. package/dist/packem_shared/constants-CImsldtV-Ces7vzH9.js +0 -1
  38. package/dist/packem_shared/index-B5zrpT20.js +0 -6
  39. package/dist/packem_shared/isVisulimaError-jVZgumOU-C67qeq6-.js +0 -1
  40. package/dist/packem_shared/renderError-DJiY-69l-s_7rEsoy.js +0 -25
  41. /package/dist/packem_shared/{VERBOSITY_QUIET-XPultrIA.js → VERBOSITY_DEBUG-XPultrIA.js} +0 -0
@@ -71,7 +71,40 @@ declare class VisulimaError extends Error {
71
71
  /**
72
72
  * Will return an array of all causes in the error in the order they occurred.
73
73
  */
74
- type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
74
+ /**
75
+ * The compiled position of a stack frame handed to a {@link SourceMapResolver}.
76
+ */
77
+ interface SourceMapLocation {
78
+ column?: number;
79
+ file: string;
80
+ line: number;
81
+ }
82
+ /**
83
+ * The resolved original position returned by a {@link SourceMapResolver}. Any omitted field falls
84
+ * back to the compiled value. `source`, when provided, is used directly as the code-frame content
85
+ * (e.g. from an inlined `sourcesContent`) instead of reading the resolved file from disk.
86
+ */
87
+ interface ResolvedSourceLocation {
88
+ column?: number;
89
+ file?: string;
90
+ line?: number;
91
+ source?: string;
92
+ }
93
+ /**
94
+ * Pluggable hook that maps a compiled `*.js:line:col` position back to its original source position
95
+ * (e.g. TS/JSX). Return `undefined` (or throw) to leave the frame untouched. Synchronous so it can
96
+ * be used by the synchronous `renderError`; resolve/inline your maps ahead of time.
97
+ */
98
+ type SourceMapResolver = (location: SourceMapLocation) => ResolvedSourceLocation | undefined;
99
+ type Options$1 = {
100
+ /**
101
+ * Read source files for code frames from anywhere on disk, including absolute paths outside
102
+ * `cwd`. Defaults to `false`, in which case only files resolving inside `cwd` are read — this
103
+ * prevents local file disclosure when rendering errors whose stack came from untrusted input
104
+ * (e.g. a deserialized error). Enable only for trusted, locally-thrown errors.
105
+ * @default false
106
+ */
107
+ allowAllFilePaths: boolean;
75
108
  color: CodeFrameOptions["color"] & {
76
109
  fileLine: ColorizeMethod;
77
110
  hint: ColorizeMethod;
@@ -88,6 +121,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
88
121
  hideErrorTitle: boolean;
89
122
  hideMessage: boolean;
90
123
  indentation: number | " ";
91
- prefix: string;
92
- };
124
+ prefix: string; /** Optional source-map resolver to map compiled frame positions back to original source. */
125
+ sourceMap?: SourceMapResolver;
126
+ } & Omit<CodeFrameOptions, "message | prefix">;
93
127
  export { Options$1 as O, VisulimaError as V };
@@ -0,0 +1,25 @@
1
+ import{createRequire as K}from"node:module";const Q=K(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,X=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 Q(e)},{createRequire:_}=X("node:module"),Z=globalThis.process??Object.create(null),L={versions:{}},A=new Proxy(Z,{get(e,r){if(r in e)return e[r];if(r in L)return L[r]}}),ee=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
2
+ `),re=(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 v=r[h-1]?.length;f[h]=[d,(v??0)-d+1]}else if(u===p)f[h]=[0,c];else{const v=r[h-u]?.length;f[h]=[0,v]}}else d===c?f[o]=d?[d,0]:!0:f[o]=[d,(c??0)-(d??0)];return{end:m,markerLines:f,start:a}},te=A.platform==="win32"&&!A.env?.WT_SESSION?">":"❯",ne=(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")?ee(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}=re(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 v=l+1+h,E=d[v],z=String(v).padStart(c),D=!d[v+1],N=` ${z}${n.showGutter?" |":""}`;if(E){let k="";if(Array.isArray(E)){const Y=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," "))," ",Y,m("^").repeat(H)].join(""),D&&n.message&&(k+=` ${p(n.message)}`)}return[n.prefix+m(te),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 ze=(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)},ie=e=>S.get(e),De=e=>e!==null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.message=="string"&&(ie(e.name)!==void 0||e.name==="Error"),oe=_(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=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 oe(e)},{inspect:le}=se("node:util"),Ye=e=>{const r=new Set,t=[];let n=e;for(;n;){if(r.has(n)){console.error(`Circular reference detected in error causes: ${le(e)}`);break}if(t.push(n),r.add(n),typeof n!="object"||!("cause"in n))break;n=n.cause}return t},ae=()=>A.env?.DEBUG==="true",$=(e,...r)=>{if(ae()){const t=r.map(n=>typeof n=="function"?n():n);console.debug(`error:parse-stacktrace: ${e}`,...t)}},g="<unknown>",ce=/^(?:node:internal\/|node:|internal\/)/,de=e=>e!==void 0&&ce.test(e),ue=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,fe=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,me=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,pe=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,he=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,ve=/in\s(.*)\s\(at\s(.+)\)\sat/,$e=/^(?:.*@)?(.*):(\d+):(\d+)$/,ge=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ye=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,we=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,j=/\(error: (.*)\)/,be=/at\s/,xe=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,Ee=/\S*(?:Error: |AggregateError:)/,C=/^Anonymous function$/,Se=/^\s*in\s.*/,Ne=/^.*?\s*at\s.*/,ke=/^.*?\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=me.exec(r);t&&(e.file=t[1],e.line=+t[2],e.column=+t[3])},Ae=e=>{const r=ve.exec(e);if(r){$(`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=he.exec(e);if(t){$(`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(be,""):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}},Me=e=>{const r=ue.exec(e);if(r){$(`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=fe.exec(e);if(c){const a=xe.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=pe.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":de(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}},Te=(e,r)=>{const t=ge.exec(e);if(t){$(`parse gecko error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n=t[3]?.includes(" > eval"),s=n&&t[3]&&ye.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=we.exec(e);if(!(t&&t[2].includes(" > eval"))&&t)return $(`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}},je=e=>{const r=$e.exec(e);if(r)return $(`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}},We=/(?:^|[(@\s])(?:node:internal\/|node:|internal\/)/,_e=/node_modules[/\\]/,He={internals:e=>!We.test(e),nodeModules:e=>!_e.test(e)},Ke=(...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=>!Ee.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(Se.test(o))l=Ae(o);else if(Ne.test(o))l=Me(o);else if(ke.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)??Te(o,c)}else l=je(o);return l?i.push(l):$(`parse error stack line: "${o}"`,"not parser found"),i},[])},Ce=_(import.meta.url),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 Ce(e)},{existsSync:Re,readFileSync:Be}=M("node:fs"),{relative:Oe,resolve:W,sep:Ie}=M("node:path"),{cwd:Pe}=w,{fileURLToPath:Ve}=M("node:url"),y=(e,r,t)=>t===0?e:r===" "?e+" ".repeat(t):e+" ".repeat(r*t),I=e=>e.replaceAll("\\","/"),Ge=(e,r)=>{const t=e.replace("async file:","file:");return I(Oe(r,t.startsWith("file:")?Ve(t):t))},Je=(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)}${Je(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?Ge(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()??"")}`},qe=(e,r)=>{if(r.allowAllFilePaths)return!0;const t=W(r.cwd),n=W(t,e);return n===t||n.startsWith(t+Ie)},J=(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(!qe(u,r)||!Re(u))return;f=Be(u,"utf8")}else f=m;return ne(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})},q=(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=J(o,r,t);l!==void 0&&(s+=`
18
+ ${l}`)}if(i instanceof AggregateError){const l=q(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}`},Fe=(e,r)=>(e.length>0?`
23
+ `:"")+e.map(t=>T(t,r)).join(`
24
+ `),U=(e,r,t)=>{const n={allowAllFilePaths:!1,cwd:Pe(),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?J(i,n,t):void 0,e instanceof AggregateError?q(e,n,t):void 0,e.cause===void 0?void 0:F(e,n,t),s.length>0?Fe(s,n):void 0].filter(Boolean).join(`
25
+ `)},Qe=(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{He as R,te as S,Qe as U,ne as W,Ke as X,O as Y,Ye as c,De as g,ie as n,ze as s};
@@ -1 +1 @@
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{T as a,h as b,b as c,a as d,u as e,i as f,t as g,g as h,c as i,p as o};
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};
@@ -0,0 +1 @@
1
+ import{createRequire as J}from"node:module";const Q=J(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,X=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 Q(e)},{createRequire:Y}=X("node:module"),H=String.raw,T=H`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,ee=()=>new RegExp(H`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${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 Be=/^[ \t]*(?:\r\n|\r|\n)/,_e=/(?:\r\n|\r|\n)[ \t]*$/,ve=/^(?:[\r\n]|$)/,Te=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,Fe=/^[ \t]*[\r\n][ \t\r\n]*$/,ze=/\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,Ie=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,m=ee(),te=/[-_./\s]+/g,$=/(\u001B\[[0-9;]*[a-z])/i,F=new RegExp("\\p{Script=Arabic}","u"),se=new RegExp("\\p{Script=Bengali}","u"),b=new RegExp("\\p{Script=Cyrillic}","u"),ne=new RegExp("\\p{Script=Devanagari}","u"),re=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"),ie=new RegExp("\\p{Script=Gujarati}","u"),le=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"),O=new RegExp("\\p{Script=Han}","u"),ce=new RegExp("\\p{Script=Kannada}","u"),ae=new RegExp("\\p{Script=Katakana}","u"),pe=new RegExp("\\p{Script=Khmer}","u"),ue=new RegExp("\\p{Script=Lao}","u"),S=new RegExp("\\p{Script=Latin}","u"),he=new RegExp("\\p{Script=Malayalam}","u"),fe=new RegExp("\\p{Script=Myanmar}","u"),ge=new RegExp("\\p{Script=Oriya}","u"),de=new RegExp("\\p{Script=Sinhala}","u"),xe=new RegExp("\\p{Script=Tamil}","u"),we=new RegExp("\\p{Script=Telugu}","u"),Ee=new RegExp("\\p{Script=Thai}","u"),ke=new RegExp("\\p{Script=Tibetan}","u"),q=/[\u02BB\u02BC\u0027]/u,Se=e=>e.replace(m,"");class Re{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}}const Ce=Y(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Le=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 Ce(e)},{stripVTControlCharacters:Ue}=Le("node:util"),A=new Re(1e3),me=/[.*+?^${}()|[\]\\]/g,be=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(me,String.raw`\$&`)).join("|"),f=new RegExp(a,"g");return A.set(t,f),f},We=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)},ye=/[ČŠŽĐ]/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,c]=i;if(c(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 c="other";for(const x of p){const[E,R]=x;if(R(r)){c=E;break}}const u=a&&f?r===r.toLocaleUpperCase(f):!1;let o=!1;d?o=d(l,c,s,u,r,i,g):(l!==c&&l!=="other"&&c!=="other"&&(o=!0),a&&c!=="other"&&!s&&u&&(o=!0)),o?(w.push(n),n=r):n+=r,l=c,a&&(s=u)}return n&&n.length>0&&w.push(n),w.length>0?w:[e]},$e=(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=$e(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,c=!1;if(h+1<d){const u=e.codePointAt(h+1);r=u&&u<128&&B(u),c=u&&u<128&&_(u)}if(!c&&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),c=r&&r<128&&G(r);if(n&&l&&c){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,c=i?0:-1;for(let u=1;u<l;u++){const o=n[u],x=o===o.toLocaleUpperCase(t);if(x===i)s+=o;else if(x)s&&s.length>0&&(p.push(s),s=o),r=!0,c=u;else{if(r&&u-c>1){const E=n[u-1],R=s.slice(0,-1);R&&R.length>0&&p.push(R),s=E+o}else s+=o;r=!1,c=-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)&&!S.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:S.test(i)?r=2:r=0;let c=i===i.toLocaleUpperCase(t);for(let o=1;o<l;o++){const x=n[o];let E;b.test(x)?E=1:S.test(x)?E=2:E=0;const R=x===x.toLocaleUpperCase(t);r!==E&&(r===1||r===2)&&(E===1||E===2)||E===r&&!c&&R?(p.push(s),s=x):s+=x,r=E,c=R}s&&s.length>0&&p.push(s);const u=[];for(let o=0;o<p.length;o++)o<p.length-1&&p[o].length===1&&S.test(p[o])&&b.test(p[o+1][0])?(u.push(p[o]+p[o+1]),o+=1):u.push(p[o]);return u}if(t.startsWith("el")){if(!j.test(e)&&!S.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],c=s[0]===s[0].toLocaleUpperCase(t);for(let u=1;u<i;u++){const o=s[u],x=o===o.toLocaleUpperCase(t);!c&&x?(p.push(r),r=o):r+=o,c=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=>O.test(s),katakana:s=>ae.test(s),latin:s=>S.test(s)}:{hangul:s=>M.test(s),latin:s=>S.test(s)},p=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(n){const s=U(e,l,!1,t,(r,c)=>r==="hiragana"&&c==="katakana"||r==="katakana"&&c==="hiragana"||r==="hiragana"&&c==="latin"||r==="katakana"&&c==="latin"||r==="kanji"&&c==="latin"||r==="latin"&&(c==="hiragana"||c==="katakana"||c==="kanji")),i=[];for(const r of s){const c=r;c.length===1&&p.has(c)&&i.length>0?i[i.length-1]=i.at(-1)+c:i.push(c)}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 c=n[r],u=c===c.toLocaleUpperCase(t),o=ye.test(c),x=r<l-1&&n[r+1]===n[r+1].toLocaleUpperCase(t);!i&&u||o&&x?(p.push(s),s=c,o&&x&&(p.push(s),s="")):s+=c,i=u}return s&&s.length>0&&p.push(s),p}if(t.startsWith("zh"))return U(e,{han:n=>O.test(n),latin:n=>S.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=>S.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=>ne.test(l)||se.test(l)||ie.test(l)||le.test(l)||ce.test(l)||xe.test(l)||we.test(l)||he.test(l)||de.test(l)||Ee.test(l)||ue.test(l)||ke.test(l)||fe.test(l)||re.test(l)||pe.test(l)||ge.test(l);return U(e,{indic:l=>n(l),latin:l=>S.test(l)},!1,t)}if(["be","bg","ru","sr","uk"].includes(t))return U(e,{cyrillic:n=>b.test(n),latin:n=>S.test(n)},!0,t);if(["ar","fa","he"].includes(t))return U(e,{latin:n=>S.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=>S.test(n)},!1,t);if(t.startsWith("uz")){if(!b.test(e)&&!S.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 c=n[r],u=c===c.toLocaleUpperCase(t);if(q.test(c)||q.test(n[r-1])){s+=c;continue}!i&&u?(p.push(s),s=c):s+=c,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},je=(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)?We(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},Oe=(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((o,x)=>x.length-o.length));let p=e;w&&(p=Ue(p)),n&&(p=Se(p));let s;Array.isArray(g)?s=be(g):g instanceof RegExp?s=g:s=te;const i=[];let r=p;const c=s.flags.includes("g")?s:new RegExp(s.source,`${s.flags}g`);for(;r.length>0;){const o=c.exec(r);if(!o){r===".."?i.push(".."):r==="."?i.push("."):r.length>0&&i.push(r);break}const x=o.index,E=o[0],R=E.length,v=r.slice(0,x),Z=r.slice(x+R);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}c.lastIndex=0}if(i.length===0){const o=p.split(s).filter(Boolean);i.push(...o)}let u=[];for(const o of i)a||f?u.push(...je(o,h,l)):h?u.push(...V(o,h,l)):u.push(...N(o,l));return k&&(u=u.map(o=>l.has(o)?o:h&&o===o.toLocaleUpperCase(h)?o[0]+o.slice(1).toLocaleLowerCase(h):o.toUpperCase()===o&&!l.has(o)?o.slice(0,1)+o.slice(1).toLowerCase():o)),u};export{Oe as A,ve as B,Fe as F,_e as R,Te as d,$ as k,ze as l,Me as m,m as n,Be as x,Ie as y};
@@ -1,5 +1,5 @@
1
- import { O as Options$1 } from "../packem_shared/index.d-Br8HpP0A.js";
2
- import { P as Plugin } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
1
+ import { O as Options$1 } from "../packem_shared/index.d-BL4NtVR3.js";
2
+ import { P as Plugin } from "../packem_shared/command.d-DbhtfXF4.js";
3
3
  import '@visulima/tabular';
4
4
  type ErrorHandlerOptions = {
5
5
  /** Show detailed error information including stack traces and code frames (default: false) */
@@ -1 +1 @@
1
- import{_ as g}from"../packem_shared/renderError-DJiY-69l-s_7rEsoy.js";import{e as m}from"../packem_shared/runtime-process-hJz7FqPN.js";const E=(i={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:r,runtime:s}=n,{detailed:t=!1,exitOnError:l=!0,formatter:o,logErrors:a=!0,renderOptions:d={}}=i;if(a)if(o)r.error(o(e));else if(t){const f=s.getCwd(),c=g(e,{cwd:f,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...d});r.error(c)}else r.error(e);l&&m(1)},version:"1.0.0"});export{E as errorHandlerPlugin};
1
+ import{U as g}from"../packem_shared/renderError-Dqej8k13-BmipVhik.js";import{e as m}from"../packem_shared/runtime-process-Dmz0vCJy.js";const E=(i={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:r,runtime:s}=n,{detailed:t=!1,exitOnError:l=!0,formatter:o,logErrors:a=!0,renderOptions:d={}}=i;if(a)if(o)r.error(o(e));else if(t){const f=s.getCwd(),c=g(e,{cwd:f,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...d});r.error(c)}else r.error(e);l&&m(1)},version:"1.0.0"});export{E as errorHandlerPlugin};
@@ -1,4 +1,4 @@
1
- import { P as Plugin } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
1
+ import { P as Plugin } from "../packem_shared/command.d-DbhtfXF4.js";
2
2
  import '@visulima/tabular';
3
3
  type RuntimeType = "bun" | "deno" | "node";
4
4
  type RuntimeVersionRequirement = {
@@ -1 +1 @@
1
- import{d as p,e as c,a as v}from"../packem_shared/runtime-process-hJz7FqPN.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}},g=(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{g as runtimeVersionCheckPlugin};
1
+ import{c as p,e as c,g as v}from"../packem_shared/runtime-process-Dmz0vCJy.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,22 +1,29 @@
1
- import { P as Plugin } from "../../packem_shared/plugin-manager.d-BSQtHbWS.js";
1
+ import { a as CerebroFs, P as Plugin } from "../../packem_shared/command.d-DbhtfXF4.js";
2
2
  import '@visulima/tabular';
3
3
  type UpdateNotifierOptions = {
4
4
  alwaysRun?: boolean;
5
5
  debug?: boolean;
6
6
  distTag?: string;
7
+ /**
8
+ * Injectable filesystem adapter used to read/write the last-update-check
9
+ * cache. The plugin passes `toolbox.fs` so MCP / sandboxed runtimes can swap
10
+ * the filesystem; defaults to a `node:fs/promises` wrapper when omitted.
11
+ */
12
+ fs?: Pick<CerebroFs, "access" | "mkdir" | "readFile" | "writeFile">;
7
13
  pkg: {
8
14
  name: string;
9
15
  version: string;
10
16
  };
11
17
  registryUrl?: string;
12
- shouldNotifyInNpmScript?: boolean;
18
+ shouldNotifyInNpmScript?: boolean; /** Timeout (ms) for the registry request. Defaults to 5000. */
19
+ timeout?: number;
13
20
  updateCheckInterval?: number;
14
21
  };
15
- type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
22
+ type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "fs" | "pkg">>;
16
23
  /**
17
24
  * Create an update notifier plugin that checks for package updates.
18
25
  * @param options Update notifier configuration options.
19
26
  * @returns Plugin instance.
20
27
  */
21
28
  declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;
22
- export { UpdateNotifierPluginOptions, updateNotifierPlugin };
29
+ export { type UpdateNotifierPluginOptions, updateNotifierPlugin };
@@ -1 +1 @@
1
- import{d as S}from"../../packem_shared/runtime-process-hJz7FqPN.js";var R={},c,i;function p(){return i||(i=1,c=[{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"}]),c}var C;function A(){return C||(C=1,(function(t){const E=p(),e=process.env;Object.defineProperty(t,"_vendors",{value:E.map(function(n){return n.constant})}),t.name=null,t.isPR=null,t.id=null,e.CI!=="false"&&E.forEach(function(n){const a=(Array.isArray(n.env)?n.env:[n.env]).every(function(I){return r(I)});t[n.constant]=a,a&&(t.name=n.name,t.isPR=o(n),t.id=n.constant)}),t.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||t.name));function r(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(a){return!!e[a]}):Object.keys(n).every(function(a){return e[a]===n[a]})}function o(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(a){return e[n.pr.env]===a}):n.pr.env in e&&e[n.pr.env]!==n.pr.ne:"any"in n.pr?n.pr.any.some(function(a){return!!e[a]}):r(n.pr);default:return null}}})(R)),R}var m=A();const P=(t={})=>({beforeCommand:async E=>{const{logger:e,runtime:r}=E,o=r.getPackageName(),n=r.getPackageVersion();if(!o||!n){e.debug("Update notifier: package name or version not provided, skipping...");return}const a=S(),I={alwaysRun:!1,debug:a.CEREBRO_OUTPUT_LEVEL==="256",distTag:"latest",pkg:{name:o,version:n},updateCheckInterval:1e3*60*60*24,...t};if(!(I.alwaysRun||!(a.NO_UPDATE_NOTIFIER||a.NODE_ENV==="test"||E.argv.includes("--no-update-notifier")||m.isCI))){e.debug("Update notifier: skipping check (disabled by environment or flags)");return}(e.raw??e.log)("Checking for updates...");try{const _=await(await import("../../packem_chunks/has-new-version.js").then(s=>s.default))(I);if(_){const[{boxen:s},{dim:U,green:L,reset:v,yellow:T}]=await Promise.all([import("@visulima/boxen"),import("@visulima/colorize")]),u=`Update available ${U(n)}${v(" → ")}${L(_)}`;e.error(s(u,{borderColor:D=>T(D),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{P as updateNotifierPlugin};
1
+ import{c as A}from"../../packem_shared/runtime-process-Dmz0vCJy.js";var R={},c,C;function p(){return C||(C=1,c=[{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"}]),c}var U;function m(){return U||(U=1,(function(a){const r=p(),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 l=m();const P=5e3,O=(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(),i={alwaysRun:!1,debug:o.CEREBRO_OUTPUT_LEVEL==="256",distTag:"latest",fs:e,pkg:{name:n,version:t},timeout:P,updateCheckInterval:1e3*60*60*24,...a};if(!(i.alwaysRun||!(o.NO_UPDATE_NOTIFIER||o.NODE_ENV==="test"||r.argv.includes("--no-update-notifier")||l.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))(i);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{O as updateNotifierPlugin};
@@ -1 +1 @@
1
- import{createRequire as g}from"node:module";import{f as x,h as y,d as b,e as d,i as j}from"../../packem_shared/runtime-process-hJz7FqPN.js";const h=g(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,s]=t.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return t.getBuiltinModule(e)}return h(e)},{execFileSync:_}=u("node:child_process"),{totalmem:v}=u("node:os"),M=/--max-old-space-size=(\d+)/,z=/--max-semi-space-size=(\d+)/,E=e=>Math.floor(v()/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,o)=>{for(const s of o){const i=e.exec(s);if(i)return Number.parseInt(i[1],10)}},q=e=>{const o=e?.maxOldSpacePercent??.75,s=[...j()],i=[...x()],n=l(M,s),c=l(z,s);if(n!==void 0&&c!==void 0)return;const a=n??E(o),f=c??P(a),r=[];if(n===void 0&&r.push(`--max-old-space-size=${String(a)}`),c===void 0&&r.push(`--max-semi-space-size=${String(f)}`),r.length!==0)try{_(y(),[...r,...s,...i.slice(1)],{env:b(),stdio:"inherit"}),d(0)}catch(m){const p=m.status;d(typeof p=="number"?p:1)}};export{q as applyHeapTuning};
1
+ import{createRequire as g}from"node:module";import{d as x,h as y,c as b,e as d,i as j}from"../../packem_shared/runtime-process-Dmz0vCJy.js";const h=g(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,s]=t.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return t.getBuiltinModule(e)}return h(e)},{execFileSync:_}=u("node:child_process"),{totalmem:v}=u("node:os"),M=/--max-old-space-size=(\d+)/,z=/--max-semi-space-size=(\d+)/,E=e=>Math.floor(v()/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,o)=>{for(const s of o){const i=e.exec(s);if(i)return Number.parseInt(i[1],10)}},q=e=>{const o=e?.maxOldSpacePercent??.75,s=[...j()],i=[...x()],n=l(M,s),c=l(z,s);if(n!==void 0&&c!==void 0)return;const a=n??E(o),m=c??P(a),r=[];if(n===void 0&&r.push(`--max-old-space-size=${String(a)}`),c===void 0&&r.push(`--max-semi-space-size=${String(m)}`),r.length!==0)try{_(y(),[...r,...s,...i.slice(1)],{env:b(),stdio:"inherit"}),d(0)}catch(f){const p=f.status;d(typeof p=="number"?p:1)}};export{q as applyHeapTuning};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/cerebro",
3
- "version": "3.0.0-alpha.31",
3
+ "version": "3.0.0-alpha.32",
4
4
  "description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
5
5
  "keywords": [
6
6
  "ansi",
@@ -109,15 +109,15 @@
109
109
  "LICENSE.md"
110
110
  ],
111
111
  "dependencies": {
112
- "@visulima/colorize": "2.0.0-alpha.13",
113
- "@visulima/tabular": "4.0.0-alpha.13",
112
+ "@visulima/colorize": "2.0.0-alpha.14",
113
+ "@visulima/tabular": "4.0.0-alpha.14",
114
114
  "fastest-levenshtein": "^1.0.16"
115
115
  },
116
116
  "peerDependencies": {
117
- "@bomb.sh/tab": "0.0.15",
118
- "@visulima/boxen": "3.0.0-alpha.13",
119
- "@visulima/find-cache-dir": "3.0.0-alpha.11",
120
- "@visulima/pail": "4.0.0-alpha.21",
117
+ "@bomb.sh/tab": "0.0.16",
118
+ "@visulima/boxen": "3.0.0-alpha.14",
119
+ "@visulima/find-cache-dir": "3.0.0-alpha.12",
120
+ "@visulima/pail": "4.0.0-alpha.22",
121
121
  "github-slugger": "2.0.0"
122
122
  },
123
123
  "peerDependenciesMeta": {
@@ -1,4 +0,0 @@
1
- import{createRequire as lt}from"node:module";import{VERBOSITY_DEBUG as q,POSITIONALS_KEY as te,VERBOSITY_QUIET as gt,VERBOSITY_VERBOSE as wt,VERBOSITY_NORMAL as ve}from"./VERBOSITY_QUIET-XPultrIA.js";import{t as A}from"./cerebro-error-etNTKvnJ.js";import{d as j,f as me,o as be,e as G,b as yt,c as vt,g as bt,h as $t,i as Ot}from"./runtime-process-hJz7FqPN.js";import{E as ie}from"./isVisulimaError-jVZgumOU-C67qeq6-.js";import{distance as At}from"fastest-levenshtein";import{Y as Ct,h as _t,k as ne,n as B,H as W,J as L,T as re,j as $e,_ as Oe,q as kt,C as Ae,A as xt,f as Ne,z as Ce,G as _e,L as It,b as Lt,K as Et,O as Pt,D as Ut,V as Mt,W as Dt,N as Tt,U as Vt,X as St,I as jt,Z as Bt,P as Rt,M as zt,v as Wt,Q as Ft}from"./constants-CImsldtV-Ces7vzH9.js";const ct=lt(import.meta.url),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ze=t=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[e,n]=J.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return J.getBuiltinModule(t)}return ct(t)},{writeFile:ut,stat:ht,rm:pt,readFile:ye,readdir:ft,mkdir:dt,access:mt}=ze("node:fs/promises"),{createRequire:Nt}=ze("node:module"),X=[{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 T=class extends A{commandName;constructor(e,n=[]){const i=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(i,"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(", ")}`)}},We=class extends A{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}`}},qt=class extends A{pluginName;constructor(e,n,i){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:i,pluginName:e}),this.name="PluginError",this.pluginName=e,i&&(this.cause=i)}},Gt=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`);j().CEREBRO_OUTPUT_LEVEL===String(q)&&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 i of n)if(typeof i.init=="function"){this.logger.debug(`initializing plugin: ${i.name}`);try{await i.init(e)}catch(s){const o=new qt(i.name,`Failed to initialize: ${s instanceof Error?s.message:String(s)}`,s instanceof Error?s:void 0);throw this.logger.error(o.message),o}}this.initialized=!0}async executeLifecycle(e,n,i){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const s=this.getDependencyOrder();for(const o of s){const c=o[e];if(typeof c=="function"){this.logger.debug(`executing ${e} hook for plugin: ${o.name}`);try{await(e==="afterCommand"?c(n,i):c(n))}catch(r){throw this.logger.error(`Error in ${e} hook for plugin "${o.name}":`,r),r}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const i=this.getDependencyOrder();for(const s of i)if(typeof s.onError=="function"){this.logger.debug(`executing error handler for plugin: ${s.name}`);try{await s.onError(e,n)}catch(o){this.logger.error(`Error in error handler for plugin "${s.name}":`,o)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,i=new Set,s=o=>{if(n.has(o))return;if(i.has(o))throw new Error(`Circular dependency detected involving plugin "${o}"`);const c=this.plugins.get(o);if(!c)throw new Error(`Plugin "${o}" not found`);if(i.add(o),c.dependencies)for(const r of c.dependencies)s(r);i.delete(o),n.add(o),e.push(c)};for(const o of this.plugins.keys())s(o);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 Z=t=>t.type?.name==="Boolean",Kt=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},ke=t=>(Z(t)||(t.typeLabel=t.typeLabel??Kt(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),Ht=new RegExp(/^-([^\d-])$/),Yt=new RegExp(/^--(\S+)/),Jt=new RegExp(/^-([^\d-]{2,})$/),Qt=t=>Ht.test(t)||Yt.test(t)||Jt.test(t),Zt=(t,e)=>{const n=e[0]&&Qt(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const i=new Error(`Command not recognised: ${String(n)}`);throw i.command=n,i.name="INVALID_COMMAND",i}return{argv:e,command:n}};var Xt=Object.defineProperty,Fe=(t,e)=>Xt(t,"name",{value:e,configurable:!0}),en=Object.defineProperty,tn=Fe((t,e)=>en(t,"name",{value:e,configurable:!0}),"i");let nn=class qe extends ie{static{Fe(this,"t")}static{tn(this,"AlreadySetError")}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,qe.prototype)}};var on=Object.defineProperty,Ge=(t,e)=>on(t,"name",{value:e,configurable:!0}),sn=Object.defineProperty,an=Ge((t,e)=>sn(t,"name",{value:e,configurable:!0}),"e");class oe extends ie{static{Ge(this,"o")}static{an(this,"UnknownOptionError")}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,oe.prototype)}}var rn=Object.defineProperty,Ke=(t,e)=>rn(t,"name",{value:e,configurable:!0}),ln=Object.defineProperty,cn=Ke((t,e)=>ln(t,"name",{value:e,configurable:!0}),"o");let un=class He extends ie{static{Ke(this,"e")}static{cn(this,"UnknownValueError")}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,He.prototype)}};var hn=Object.defineProperty,Ye=(t,e)=>hn(t,"name",{value:e,configurable:!0}),pn=Object.defineProperty,fn=Ye((t,e)=>pn(t,"name",{value:e,configurable:!0}),"i");let E=class Je extends ie{static{Ye(this,"e")}static{fn(this,"InvalidDefinitionsError")}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,Je.prototype)}};var dn=Object.defineProperty,H=(t,e)=>dn(t,"name",{value:e,configurable:!0}),mn=Object.defineProperty,se=H((t,e)=>mn(t,"name",{value:e,configurable:!0}),"o");const xe=se(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),Ie=se(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),Le=se(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),gn=se((t,e)=>Array.isArray(t)?xe(e)?t.map(Boolean):Ie(e)?t.map(Number):Le(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:xe(e)?!!t:Ie(e)?Number(t):Le(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t)),"convertValue");var wn=Object.defineProperty,yn=H((t,e)=>wn(t,"name",{value:e,configurable:!0}),"e");const x=yn((t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},"debug");var vn=Object.defineProperty,z=H((t,e)=>vn(t,"name",{value:e,configurable:!0}),"x$2");const bn=/-([a-z])/g,$n=/^\d+$/,le=z(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),On=z(t=>t.codePointAt(0)===95,"isSpecialKey"),Ee=z((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),Pe=z(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),Ue=z((t,e,n,i=!1)=>{t[e]===void 0?t[e]=i?[n]:n:i&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),An=z((t,e,n,i,s)=>{let o=e.get(t)??n.get(t);if(!o&&i){const c=t.toLowerCase();o=i.get(c)??s?.get(c)}return o},"getDefinition"),Nn=z((t,e,n,i)=>{const s=n.debug??!1;x(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(s,"Starting argument resolution","resolver"),x(s,"Tokens:","resolver",t),x(s,"Definitions:","resolver",e),x(s,"Processing tokens...","resolver");const o=new Map,c=new Map,r=n.caseInsensitive?new Map:void 0,g=n.caseInsensitive?new Map:void 0,a=n.camelCase?new Map:void 0,u=n.camelCase?new Map:void 0;for(const h of e)if(o.set(h.name,h),h.alias&&c.set(h.alias,h),n.caseInsensitive&&r&&(r.set(h.name.toLowerCase(),h),h.alias&&g&&g.set(h.alias.toLowerCase(),h)),n.camelCase&&a&&u){const m=h.name.replaceAll(bn,(w,$)=>$.toUpperCase());a.set(h.name,m),u.set(m,h.name)}const f={},l={},d=[],p=[],v=new Set;let b=!1;const y=e.find(h=>h.defaultOption),N=e.some(h=>h.group),C=e.some(h=>h.type===Number);for(let h=0;h<t.length;h++){const m=t[h];if(m.kind==="option-terminator"){f._unknown=i.slice(m.index),b=!0;break}if(m.kind==="option"&&m.name){let w=An(m.name,o,c,r,g);if(!w&&m.value===void 0&&C&&$n.test(m.name)){const _=e.find(U=>U.type===Number);_&&(w=_,m.value=m.name,m.name=_.name)}const $=w?w.name:m.name,O=w?.multiple,P=w?.lazyMultiple;if(l[$]!==void 0&&!O&&!P&&!n.partial)throw new nn($);if(!w&&n.partial){const _=m.rawName??`--${m.name}${m.value!==void 0&&m.inlineValue?`=${m.value}`:""}`;d.push({index:m.index,value:_});continue}if(!w&&n.stopAtFirstUnknown){f._unknown=i.slice(m.index);break}if(!w&&!n.partial)throw new oe(m.name);if(m.value===void 0){const _=t[h+1],U=_?.kind==="option"&&!("name"in _)&&_.value!==void 0,I=_&&w&&!(w.type&&le(w.type))&&(_.kind==="positional"||U),rt=w&&w.defaultOption&&!w.multiple&&!w.lazyMultiple;if(I&&(!w?.defaultOption||rt))if(O){let M=h+1;const ae=[];for(;M<t.length&&(t[M].kind==="positional"||t[M].kind==="option"&&!("name"in t[M])&&t[M].value!==void 0);)ae.push(t[M].value),v.add(t[M].index),M++;l[$]=l[$]===void 0?ae:Ee(l[$],ae),h=M-1}else P?(Ue(l,$,_.value,!0),v.add(_.index),h++):(l[$]=_.value,v.add(_.index),h++);else w?.type&&le(w.type)?Ue(l,$,!0,O):l[$]=O?[]:null}else{let{value:_}=m;if(w?.type&&le(w.type))switch(_){case"":{if(n.partial){l._unknown??=[];const I=`${m.rawName??`--${m.name}`}${m.value?`=${m.value}`:""}`;l._unknown.push(I),p.push({index:m.index,value:I}),_=!0}else throw new oe(m.name);break}case"false":{_=!1;break}case"true":{_=!0;break}default:_=!0}const U=[_];if(O){let I=h+1;for(;I<t.length&&t[I].kind==="positional";)U.push(t[I].value),v.add(t[I].index),I++;h=I-1}l[$]===void 0?l[$]=O||P?U:_:O||P?l[$]=Ee(l[$],U):l[$]=_}}else if(m.kind==="positional"&&n.stopAtFirstUnknown&&!v.has(m.index)&&!y){x(s,`Found unconsumed positional token at index ${String(m.index)}, stopping processing`,"resolver"),f._unknown=i.slice(m.index);break}}for(const[h,m]of Object.entries(l)){const w=o.get(h);w&&(w.multiple||w.lazyMultiple)&&!Array.isArray(m)&&(l[h]=[m])}let k=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!b){for(const h of t)if(h.kind==="option"&&!o.has(h.name??"")&&!c.has(h.name??"")&&(!n.caseInsensitive||!r?.has(h.name?.toLowerCase()??"")&&!g?.has(h.name?.toLowerCase()??""))){k=h.index;break}}if(y){const h=[],m=[];for(const w of t)w.kind==="positional"&&!v.has(w.index)&&w.index<k&&(h.push(w.value),m.push(w));if(h.length>0){const w=l[y.name],$=y.multiple??y.lazyMultiple;w===void 0?$?(m.forEach(O=>v.add(O.index)),l[y.name]=h):(v.add(m[0].index),l[y.name]=h[0]):$&&(m.forEach(O=>v.add(O.index)),l[y.name]=Array.isArray(w)?[...h,...w]:[...h,w])}}if(!n.partial){for(const h of t)if(h.kind==="positional"&&!v.has(h.index))throw new un(i[h.index])}if(n.partial&&!n.stopAtFirstUnknown){const h=[...d];if(l._unknown)for(const m of p)h.push({index:m.index,value:m.value});for(const m of t)m.kind==="positional"&&!v.has(m.index)&&h.push({index:m.index,value:i[m.index]});h.length>0&&(h.sort((m,w)=>m.index-w.index),f._unknown=h.map(m=>m.value))}if(n.stopAtFirstUnknown&&!b){const h=t.findIndex($=>$.kind==="option"&&!o.has($.name??"")&&!c.has($.name??"")&&(!n.caseInsensitive||!r?.has($.name?.toLowerCase()??"")&&!g?.has($.name?.toLowerCase()??""))),m=t.findIndex($=>$.kind==="positional"&&!v.has($.index));let w=-1;if(h!==-1&&m!==-1?w=Math.min(h,m):h!==-1?w=h:m!==-1&&(w=m),w>=0){const $=t[w].index;f._unknown=i.slice($)}}else d.length>0&&!n.partial&&(f._unknown=d.map(h=>h.value));for(const[h,m]of Object.entries(l)){const w=n.camelCase?a?.get(h)??h:h,$=o.get(h);f[w]=$?.type?gn(m,$.type):m===void 0?null:m}for(const h of e){const m=n.camelCase?a?.get(h.name)??h.name:h.name;!(m in f)&&h.defaultValue!==void 0&&(h.multiple??h.lazyMultiple?f[m]=Array.isArray(h.defaultValue)?[...h.defaultValue]:[h.defaultValue]:f[m]=h.defaultValue)}if(N){const h={},m={},w={};for(const O of e)if(O.group){const P=Array.isArray(O.group)?O.group:[O.group];for(const _ of P)Pe(_)||(h[_]??={})}for(const O of Object.keys(f))if(!On(O)){m[O]=f[O];let P=O;n.camelCase&&(P=u?.get(O)??O);const _=o.get(P);if(_?.group){const U=Array.isArray(_.group)?_.group:[_.group];for(const I of U)Pe(I)||h[I]&&(h[I][O]=f[O])}else w[O]=f[O]}const $={_all:m};for(const[O,P]of Object.entries(h))$[O]=P;Object.keys(w).length>0&&($._none=w),f._unknown&&($._unknown=f._unknown),Object.keys(f).forEach(O=>delete f[O]),Object.assign(f,$)}return x(s,"Final parsed result:","resolver",f),f},"resolveArgs");var Cn=Object.defineProperty,Y=H((t,e)=>Cn(t,"name",{value:e,configurable:!0}),"l");const K="-".codePointAt(0),R="=",_n=R.codePointAt(0),kn="--",xn="-",In="--",Qe=Y(t=>t.length>2&&t.startsWith(In),"hasLongOptionPrefix"),Ln=Y(t=>Qe(t)&&!t.includes(R,3),"isLongOption"),En=Y(t=>Qe(t)&&t.includes(R,3),"isLongOptionAndValue"),Pn=Y(t=>{if(t.length!==2||t.codePointAt(0)!==K||t.codePointAt(1)===K)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},"isShortOption"),Un=Y(t=>!(t.length<=2||t.codePointAt(0)!==K||t.codePointAt(1)===K),"isShortOptionGroup"),Mn=Y(t=>{const e=[],n=[...t];let i=-1,s=0;for(;n.length>0;){const o=n.shift();if(o===void 0)break;if(s>0?s--:i++,o===kn){e.push({index:i,kind:"option-terminator"});const c=n.map((r,g)=>({index:i+g+1,kind:"positional",value:r}));e.push(...c),i+=n.length;break}if(Pn(o)){const c=o.charAt(1);e.push({index:i,kind:"option",name:c,rawName:o});continue}if(Un(o)&&!o.includes(R)){const c=[];let r="",g=!1;for(let a=1;a<o.length;a++){const u=o.charAt(a);g?r+=u:u.codePointAt(0)===_n?g=!0:c.push(`${xn}${u}`)}if(g)if(c.length>0){const a=c.pop();c.push(`${a}=${r}`)}else c.push(r);n.unshift(...c),s=c.length;continue}if(Ln(o)){const c=o.slice(2);e.push({index:i,kind:"option",name:c,rawName:o});continue}if(En(o)){const c=o.indexOf(R),r=o.slice(2,c),g=o.slice(c+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:o,value:g});continue}if(o.length>2&&o.codePointAt(0)===K&&o.codePointAt(1)!==K&&o.includes(R)){const c=o.indexOf(R),r=o.charAt(1),g=o.slice(c+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:o,value:g});continue}e.push({index:i,kind:"positional",value:o})}return e},"parseArgsTokens");var Dn=Object.defineProperty,we=H((t,e)=>Dn(t,"name",{value:e,configurable:!0}),"d");const Tn=/\d/,Vn=we(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),Sn=we(t=>typeof t=="function","isValidCustomTypeFunction"),jn=we((t,e,n)=>{const i=n?.debug??!1;x(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,o=new Set,c=new Set,r=new Set;let g=0;for(const a of t){if(x(i,"Checking definition:","validation",a),!a.name)throw x(i,"Validation failed: name is required","validation"),new E("Invalid option definition: name is required");if(typeof a.name!="string")throw new E("Invalid option definition: name must be a string");if(a.name.trim()==="")throw new E("Invalid option definition: name cannot be empty");const u=e?a.name.toLowerCase():"";if(s.has(a.name)||e&&c.has(u))throw new E(`Invalid option definition: duplicate name '${a.name}'`);if(o.has(a.name)||e&&r.has(u))throw new E(`Invalid option definition: name '${a.name}' conflicts with an existing alias`);if(s.add(a.name),e&&c.add(u),a.alias!==void 0){if(typeof a.alias!="string")throw new E("Invalid option definition: alias must be a string");if(a.alias.length!==1)throw new E("Invalid option definition: alias must be a single character");if(Tn.test(a.alias))throw new E("Invalid option definition: alias cannot be numeric");if(a.alias==="-")throw new E('Invalid option definition: alias cannot be "-"');const f=e?a.alias.toLowerCase():"";if(o.has(a.alias)||e&&r.has(f))throw new E(`Invalid option definition: duplicate alias '${a.alias}'`);if(s.has(a.alias)||e&&c.has(f))throw new E(`Invalid option definition: alias '${a.alias}' conflicts with an existing option name`);o.add(a.alias),e&&r.add(f)}if(a.defaultOption&&(g++,a.type!==void 0&&Vn(a.type)))throw new E("Invalid option definition: defaultOption cannot be Boolean type");if(a.type!==void 0&&!(a.type===Boolean||a.type===Number||a.type===String||typeof a.type=="function"&&Sn(a.type)))throw new E("Invalid option definition: invalid type")}if(g>1)throw x(i,"Validation failed: multiple defaultOptions not allowed","validation"),new E("Invalid option definition: multiple defaultOptions not allowed");x(i,"Validation completed successfully","validation")},"validateDefinitions");var Bn=Object.defineProperty,Rn=H((t,e)=>Bn(t,"name",{value:e,configurable:!0}),"O");const zn=Rn((t,e={})=>{const n=e.debug??!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const s=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",s),jn(s,i.caseInsensitive,n?i:void 0);let{argv:o}=i;if(!o&&(o=process.argv.slice(2),process.execArgv.length>0)){const a=new Set(process.execArgv);o=o.filter(u=>!a.has(u))}x(n,"Using argv:","index",o);let c=o;i.caseInsensitive&&(c=o.map(a=>{if(a.startsWith("--")){const u=a.indexOf("="),f=(u===-1?a.slice(2):a.slice(2,u)).toLowerCase();return u===-1?`--${f}`:`--${f}${a.slice(u)}`}if(a.startsWith("-")&&!a.startsWith("--")&&a.length>1){const u=a.slice(1).split("=",2),f=u[0],l=u[1];if(!f)return a;const d=f.toLowerCase();return l===void 0?`-${d}`:`-${d}=${l}`}return a}));const r=Mn(c.map(String));x(n,"Tokenized arguments:","index",r);const g=Nn(r,s,i,o);return x(n,"Command-line-args parsing completed","index"),g},"commandLineArgs");class Wn{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let ce=class extends A{commandName;constructor(e,n,i){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.",i!==void 0&&(this.cause=i)}};const Fn=/^-{1,2}(\w+)(=(.+))?$/,Ze=(t,e,n,i)=>{const s=Fn.exec(t);if(s===null)return{};const o=s[1];if(!o)return{};const c=n&&i?n.get(o)??i.get(o):e.find(r=>r.name===o||r.alias===o);return c!==void 0?{argName:c.name,argValue:s[3],option:c}:{}},Me=(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)},qn=new Set(["0","1","false","true"]),Gn=(t,e,n,i)=>{if(e.length===0||t.length===0)return{};const s=(o,c)=>{const{argName:r,argValue:g,option:a}=Ze(c,e,n,i),{lastOption:u}=o;return a&&Z(a)&&g&&r?o.partial[r]=Me(g,a):o.lastName&&u&&Z(u)&&qn.has(c)&&(o.partial[o.lastName]=Me(c,u)),{lastName:r,lastOption:a,partial:o.partial}};return t.reduce(s,{partial:{}}).partial},Kn=new Set(["0","1","false","true"]),Hn=(t,e,n,i)=>{if(e.length===0||t.length===0)return t;const s=(o,c)=>{const{argValue:r,option:g}=Ze(c,e,n,i),{lastOption:a}=o;if(a&&Z(a)&&Kn.has(c)){const{args:u}=o;return{args:u.slice(0,-1)}}return g&&Z(g)&&r?{args:o.args}:{args:[...o.args,c],lastOption:g}};return t.reduce(s,{args:[]}).args},De=t=>{const e=new Map;for(const n of t){const i=e.get(n.name);i?e.set(n.name,{...i,...n}):e.set(n.name,n)}return[...e.values()]},Yn=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Jn=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return Yn(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)}},Qn=/_./g,Zn=/^[A-Z]/,Xn=t=>t.toLowerCase().replaceAll(Qn,e=>e[1]?.toUpperCase()??e).replace(Zn,e=>e.toLowerCase()),eo=t=>{if(!t||t.length===0)return{};const e={},n=j();for(const i of t){const s=n[i.name],o=Jn(i,s),c=o===void 0?i.defaultValue:o,r=Xn(i.name);e[r]=c}return e},to=t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const s=Array.isArray(i.alias)?i.alias:[i.alias];for(const o of s)n.set(o,i)}return{optionMapByAlias:n,optionMapByName:e}},Xe=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ce(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new ce(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new ce(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},no=(t,e,n,i)=>{const s=new Wn(t.name,t),{_all:o,_unknown:c,positionals:r}=e,g=Object.keys(n).length>0?{...o,...n}:o;te in g&&delete g[te],s.argument=r?.[te]??[],s.rawUnknown=[...c??[]];const a=Object.keys(i).length>0;return s.options=a?{...g,...i}:g,s.env=eo(t.env),s},oo=(t,e,n)=>{const i=t.options??[],s=i.length>0;let o=De(s?[...i,...n]:n);if(o.length>0){for(const a of o)if(a.multiple&&a.lazyMultiple)throw new Error(`Argument "${a.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(o=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:te,type:t.argument.type,typeLabel:t.argument.typeLabel},...o]);let c,r;if(s){const{optionMapByAlias:a,optionMapByName:u}=to(i);c=Hn(e,i,u,a),r=Gn(e,i,u,a)}else c=e,r={};const g=zn(o,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:r,parsedArgs:g}},F=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await Xe(t))(e);let io=class extends A{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(", ")}`}};const Te=(t,e,n=!1)=>{const i=[];for(const s of t)if(!(!n&&!s.required)&&e[s.name]===void 0){if(s.type?.name==="Boolean"){e[s.name]=!1;continue}i.push(s)}return i},so=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:At(t,e)<=t.length/3,S=(t,e)=>{const n=t.toLowerCase();return e.filter(i=>so(i.toLowerCase(),n))},ao=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const s=i.startsWith("--");let o=`Found unknown ${s?"option":"argument"} "${i}"`;if(s){const c=S(i.replace("--",""),(e.options??[]).map(r=>r.name));if(c.length>0){const[r,...g]=c.map(a=>`--${a}`);o+=g.length>0?`, did you mean ${r??""} or ${g.join(", ")}?`:`, did you mean ${r??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
2
- `))},ro=(t,e,n)=>{const i=n.__requiredOptions__,s=i?Te(i,e,!0):Te(t,e,!1);if(s.length>0)throw new io(n.name,s.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&ao(e,n)},lo=(t,e,n)=>{const i=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(i.length>0){const s=i.find(o=>Array.isArray(o.conflicts)?o.conflicts.some(c=>e[c]!==void 0)&&e[o.name]!==void 0:e[o.conflicts]!==void 0&&e[o.name]!==void 0);if(s)throw new We(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},co=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const o=e.get(s.name)??[];o.push(s),e.set(s.name,o)}if(typeof s.alias=="string"&&s.alias.length>0){const o=n.get(s.alias)??[];o.push(s),n.set(s.alias,o)}else if(Array.isArray(s.alias)){for(const o of s.alias)if(o.length>0){const c=n.get(o)??[];c.push(s),n.set(o,c)}}}const i=[];for(const[s,o]of e)o.length>1&&i.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[s,o]of n)o.length>1&&i.push(`Duplicate option alias "-${s}" used by options ${o.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(i.length>0)throw new Error(i.join(`
3
- `))},uo=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let i;for(let s=1;s<=e.length;s+=1){const o=e[s-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const c=n.join(" ");t.has(c)&&(i={commandPath:[...n],depth:s})}return i?{argv:e.slice(i.depth),commandPath:i.commandPath}:{argv:e,commandPath:void 0}},V=t=>t.join(" "),Ve=(t,e)=>e&&e.length>0?[...e,t]:[t];class ho{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}const po=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),fo=Nt(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mo=t=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[e,n]=Q.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Q.getBuiltinModule(t)}return fo(t)},{stripVTControlCharacters:go}=mo("node:util"),ue=new ho(1e3),wo=/[.*+?^${}()|[\]\\]/g,yo=t=>{const e=t.join("");if(ue.has(e)){const s=ue.get(e);return s.lastIndex=0,s}const n=t.map(s=>s.replaceAll(wo,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return ue.set(e,i),i},vo=t=>{const e=[];let n=0,i;for(B.lastIndex=0;(i=B.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=B.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},bo=/[ČŠŽĐ]/i,et=new Uint8Array(128),tt=new Uint8Array(128),nt=new Uint8Array(128);for(let t=0;t<128;t++)et[t]=t>=65&&t<=90?1:0,tt[t]=t>=97&&t<=122?1:0,nt[t]=t>=48&&t<=57?1:0;const he=t=>et[t],Se=t=>tt[t],pe=t=>nt[t],D=(t,e,n,i,s)=>{if(t.length===0)return[];let o=!1;const c=Object.values(e);for(const d of c)if(d(t[0])){o=!0;break}if(!o&&!n)return[t];const r=[...t],g=[];let a=r[0],u="other";const f=Object.entries(e);for(const d of f){const[p,v]=d;if(v(r[0])){u=p;break}}let l=n&&i?r[0]===r[0].toLocaleUpperCase(i):!1;for(let d=1;d<r.length;d++){const p=r[d];let v="other";for(const N of f){const[C,k]=N;if(k(p)){v=C;break}}const b=n&&i?p===p.toLocaleUpperCase(i):!1;let y=!1;s?y=s(u,v,l,b,p,d,r):(u!==v&&u!=="other"&&v!=="other"&&(y=!0),n&&v!=="other"&&!l&&b&&(y=!0)),y?(g.push(a),a=p):a+=p,u=v,n&&(l=b)}return a&&a.length>0&&g.push(a),g.length>0?g:[t]},$o=(t,e,n,i)=>{if(n.size===0)return e;for(const s of n)if(t.startsWith(s,e))return i.push(s),e+s.length;return e},ot=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],s=t.length;for(let o=1;o<s;o++){const c=$o(t,n,e,i);if(c!==n){n=c,o=n-1;continue}const r=t.codePointAt(o-1),g=t.codePointAt(o),a=r&&r<128&&he(r),u=g&&g<128&&he(g),f=r&&r<128&&Se(r),l=r&&r<128&&pe(r),d=g&&g<128&&pe(g);if(f&&u){i.push(t.slice(n,o)),n=o;continue}if(l&&!d||!l&&d){i.push(t.slice(n,o)),n=o;continue}if(d&&!l){let p=!1,v=!1;if(o+1<s){const b=t.codePointAt(o+1);p=b&&b<128&&he(b),v=b&&b<128&&pe(b)}if(!v&&p){i.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<s){const p=t.codePointAt(o+1),v=p&&p<128&&Se(p);if(a&&u&&v){const b=t.slice(n,o+1);e.has(b)||(i.push(t.slice(n,o)),n=o)}}}return n<s&&i.push(t.slice(n)),i.filter(o=>o!=="")},it=(t,e,n)=>{if(t.length===0)return[];const i=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!i&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const a=[...t],u=a.length,f=[];let l=a[0],d=a[0]===a[0].toLocaleUpperCase(e),p=d,v=d?0:-1;for(let b=1;b<u;b++){const y=a[b],N=y===y.toLocaleUpperCase(e);if(N===d)l+=y;else if(N)l&&l.length>0&&(f.push(l),l=y),p=!0,v=b;else{if(p&&b-v>1){const C=a[b-1],k=l.slice(0,-1);k&&k.length>0&&f.push(k),l=C+y}else l+=y;p=!1,v=-1}d=N}return l&&l.length>0&&f.push(l),f}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!W.test(t)&&!L.test(t))return[t];const a=[...t],u=a.length,f=[];let l=a[0];const d=a[0];let p;W.test(d)?p=1:L.test(d)?p=2:p=0;let v=d===d.toLocaleUpperCase(e);for(let y=1;y<u;y++){const N=a[y];let C;W.test(N)?C=1:L.test(N)?C=2:C=0;const k=N===N.toLocaleUpperCase(e);p!==C&&(p===1||p===2)&&(C===1||C===2)||C===p&&!v&&k?(f.push(l),l=N):l+=N,p=C,v=k}l&&l.length>0&&f.push(l);const b=[];for(let y=0;y<f.length;y++)y<f.length-1&&f[y].length===1&&L.test(f[y])&&W.test(f[y+1][0])?(b.push(f[y]+f[y+1]),y+=1):b.push(f[y]);return b}if(e.startsWith("el")){if(!re.test(t)&&!L.test(t))return[t];const a=[];$e.lastIndex=0;let u;for(;(u=$e.exec(t))!==null;)a.push(u[0]);a.length===0&&a.push(t);const f=[];if(a.length===1){const l=a[0];if(!l||!re.test(l[0])||l.length===1)return[l??t]}for(const l of a){if(!l)continue;if(!re.test(l[0])||l.length===1){f.push(l);continue}const d=l.length;let p=l[0],v=l[0]===l[0].toLocaleUpperCase(e);for(let b=1;b<d;b++){const y=l[b],N=y===y.toLocaleUpperCase(e);!v&&N?(f.push(p),p=y):p+=y,v=N}p&&f.push(p)}return f}if(e.startsWith("ja")||e.startsWith("ko")){const a=e.startsWith("ja"),u=a?{hiragana:l=>xt.test(l),kanji:l=>Ae.test(l),katakana:l=>kt.test(l),latin:l=>L.test(l)}:{hangul:l=>Ne.test(l),latin:l=>L.test(l)},f=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(a){const l=D(t,u,!1,e,(p,v)=>p==="hiragana"&&v==="katakana"||p==="katakana"&&v==="hiragana"||p==="hiragana"&&v==="latin"||p==="katakana"&&v==="latin"||p==="kanji"&&v==="latin"||p==="latin"&&(v==="hiragana"||v==="katakana"||v==="kanji")),d=[];for(const p of l){const v=p;v.length===1&&f.has(v)&&d.length>0?d[d.length-1]=d.at(-1)+v:d.push(v)}return d.length>0?d:[t]}return D(t,u,!1,e,(l,d)=>l==="hangul"&&d==="latin"||l==="latin"&&d==="hangul")}if(e.startsWith("sl")){const a=[...t],u=a.length,f=[];let l=a[0],d=a[0]===a[0].toLocaleUpperCase(e);for(let p=1;p<u;p++){const v=a[p],b=v===v.toLocaleUpperCase(e),y=bo.test(v),N=p<u-1&&a[p+1]===a[p+1].toLocaleUpperCase(e);!d&&b||y&&N?(f.push(l),l=v,y&&N&&(f.push(l),l="")):l+=v,d=b}return l&&l.length>0&&f.push(l),f}if(e.startsWith("zh"))return D(t,{han:a=>Ae.test(a),latin:a=>L.test(a)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const a=u=>Ce.test(u)||_e.test(u);return D(t,{latin:u=>L.test(u),rtl:u=>a(u)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const a=u=>It.test(u)||Lt.test(u)||Et.test(u)||Pt.test(u)||Ut.test(u)||Mt.test(u)||Dt.test(u)||Tt.test(u)||Vt.test(u)||St.test(u)||jt.test(u)||Bt.test(u)||Rt.test(u)||zt.test(u)||Wt.test(u)||Ft.test(u);return D(t,{indic:u=>a(u),latin:u=>L.test(u)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return D(t,{cyrillic:a=>W.test(a),latin:a=>L.test(a)},!0,e);if(["ar","fa","he"].includes(e))return D(t,{latin:a=>L.test(a),rtl:a=>Ce.test(a)||_e.test(a)},!1,e);if(e.startsWith("ko"))return D(t,{hangul:a=>Ne.test(a),latin:a=>L.test(a)},!1,e);if(e.startsWith("uz")){if(!W.test(t)&&!L.test(t))return[t];const a=[...t],u=a.length,f=[];let l=a[0],d=a[0]===a[0].toLocaleUpperCase(e);for(let p=1;p<u;p++){const v=a[p],b=v===v.toLocaleUpperCase(e);if(Oe.test(v)||Oe.test(a[p-1])){l+=v;continue}!d&&b?(f.push(l),l=v):l+=v,d=b}return l&&l.length>0&&f.push(l),f}const s=[...t],o=s.length,c=[];let r=s[0],g=s[0]===s[0].toLocaleUpperCase(e);for(const a of n)if(t.startsWith(a)){c.push(a),r=s[a.length],g=r===r.toLocaleUpperCase(e);break}for(let a=1;a<o;a++){const u=s[a],f=u===u.toLocaleUpperCase(e);let l=0;for(const d of n)if(t.startsWith(d,a)){c.push(r,d),l=d.length,r="";const p=d.at(-1);p&&(g=p===p.toLocaleUpperCase(e));break}if(l>0){a+=l-1;continue}!g&&f?(c.push(r),r=u):r+=u,g=f}return r&&c.push(r),c},Oo=(t,e,n)=>{const i=[],s=ne.test(t)?t.split(ne).filter(Boolean):[t];for(const o of s){const c=o;if(ne.test(c))i.push(c);else{B.lastIndex=0;const r=B.test(c)?vo(c).filter(Boolean):[c];for(const g of r)if(B.lastIndex=0,B.test(g))i.push(g);else if(e){const a=e.toLowerCase().split("-")[0];i.push(...it(g,a,n))}else i.push(...ot(g,n))}}return i},Ao=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:s=[],locale:o,normalize:c=!1,separators:r,stripAnsi:g=!1,stripEmoji:a=!1}=e,u=new Set([...s].toSorted((y,N)=>N.length-y.length));let f=t;g&&(f=go(f)),a&&(f=Ct(f));let l;Array.isArray(r)?l=yo(r):r instanceof RegExp?l=r:l=_t;const d=[];let p=f;const v=l.flags.includes("g")?l:new RegExp(l.source,`${l.flags}g`);for(;p.length>0;){const y=v.exec(p);if(!y){p===".."?d.push(".."):p==="."?d.push("."):p.length>0&&d.push(p);break}const N=y.index,C=y[0],k=C.length,h=p.slice(0,N),m=p.slice(N+k);if(C.startsWith("../"))d.push(".."),p=p.slice(N+3);else if(C.startsWith("./"))d.push("."),p=p.slice(N+2);else if(N===0&&C==="..")d.push(".."),p=p.slice(2);else if(N===0&&C===".")d.push("."),p=p.slice(1);else{h.length>0&&d.push(h);let w=0;for(;(w=C.indexOf("../",w))!==-1;)d.push(".."),w+=3;for(w=0;(w=C.indexOf("./",w))!==-1;)(w===0||C[w-1]!==".")&&d.push("."),w+=2;let $=m;for(;$.startsWith("../");)d.push(".."),$=$.slice(3);for(;$.startsWith("./");)d.push("."),$=$.slice(2);if($===".."){d.push("..");break}else if($==="."){d.push(".");break}else p=$}v.lastIndex=0}if(d.length===0){const y=f.split(l).filter(Boolean);d.push(...y)}let b=[];for(const y of d)n||i?b.push(...Oo(y,o,u)):o?b.push(...it(y,o,u)):b.push(...ot(y,u));return c&&(b=b.map(y=>u.has(y)?y:o&&y===y.toLocaleUpperCase(o)?y[0]+y.slice(1).toLocaleLowerCase(o):y.toUpperCase()===y&&!u.has(y)?y.slice(0,1)+y.slice(1).toLowerCase():y)),b},No=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),Co=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let s="",o="";for(let c=0;c<n;c++){const r=t[c];if(ne.test(r)){s?(i.push(s+o+r),s="",o=""):(i.length>0&&i.push(e),s=r);continue}s?(o&&(o+=e),o+=r):(i.length>0&&i.push(e),i.push(r))}return i.join("")},st=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Co(Ao(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 o=s,c=o.toLowerCase();return n?(n=!1,po(c)):No(c)}),"")},_o=t=>{t.options?.forEach(e=>{e.__camelCaseName__=st(e.name)})},ko=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const i of t.options)e.add(i.name);const n=[];for(const i of t.options)if(i.name.startsWith("no-")){const s=i.name.replace(/^no-/,"");if(!e.has(s)){if(i.type!==Boolean)throw new Error(`Cannot add negated option "${i.name}" to command "${t.name}" because it is not a boolean.`);const o={...i,defaultValue:i.defaultValue===void 0?!0:!i.defaultValue,name:s};n.push(o),e.add(s)}}n.length>0&&t.options.push(...n)},xo=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,i=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const c=st(o.name);i.set(c,o)}const s=Object.keys(n).filter(o=>i.has(o));if(s.length!==0)for(const o of s){const c=o.charAt(2);if(!c)continue;const r=c.toLowerCase()+o.slice(3),g=i.get(o);g&&(g.__negated__=!0),n[r]=!n[o],Reflect.deleteProperty(n,o)}},Io=(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:i}=t;for(const s of Object.keys(i)){const o=n.get(s);if(o?.implies){const{implies:c}=o;for(const[r,g]of Object.entries(c))i[r]===void 0&&(i[r]=g)}}},Lo=()=>!!process.versions.electron,Eo=()=>Lo()&&!process.defaultApp,Po=()=>Eo()?0:1,Uo=t=>t.slice(Po()+1),Mo=" ",Do=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,i)=>n===e[i]),To=t=>{if(typeof t=="string")return t.split(Mo);const e=me();return Do(t,e)?Uo(t):t},Vo=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),G(1)},n=(o,c)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let r;if(typeof o=="string")r=o;else try{r=JSON.stringify(o)}catch{r=String(o)}t.error(`Promise rejection: ${r}`)}G(1)},i=be("uncaughtException",e),s=be("unhandledRejection",n);return()=>{i(),s()}},je=100,So=/^[a-z][\w-]*$/i,ge=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new A(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},Be=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new A(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},fe=(t,e)=>{if(typeof t!="object"||t===null)throw new A(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},ee=t=>{const e=ge(t,"Command name");if(e.length>je)throw new A(`Command name is too long (maximum ${String(je)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new A(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!So.test(e))throw new A(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},jo=new Set([`
4
- `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Bo=(t,e=!0)=>{if(typeof t!="string")throw new TypeError("Argument must be a string");if(t.length>1e4)throw new Error(`Argument is too long (maximum ${String(1e4)} characters)`);if(e){for(const n of t)if(jo.has(n))throw new Error(`Argument contains dangerous character: ${n}`)}return t.trim()},Re=(t,e=!0)=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error(`Too many arguments (maximum ${String(100)})`);return t.map(n=>Bo(n,e))},Ro=/^-([^\d-])$/,zo=/^--(\S+)/,Wo=/^-([^\d-]{2,})$/,de=t=>Ro.test(t)||zo.test(t)||Wo.test(t),Fo={access:(t,e)=>mt(t,e),mkdir:(t,e)=>dt(t,e),readdir:t=>ft(t),readFile:(async(t,e)=>e===void 0?ye(t):ye(t,e)),rm:(t,e)=>pt(t,e),stat:t=>ht(t),writeFile:(t,e,n)=>ut(t,e,n)};class at{#t;#e;#c;#u;#p;#f;#v;#b;#$;#O;#A;#h;#n;#o;#i;#s;#a;#d=!1;#N;#C=!1;#m;#g;#w;#l=[];#L(){return this.#m===void 0&&(this.#m=[...this.#o.keys()]),this.#m}#_(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#r(){return this.#w===void 0&&(this.#w=[...this.#L(),...this.#_()]),this.#w}#k(){return this.#l.length===0?X:[...X,...this.#l]}#x(){this.#m=void 0,this.#g=void 0,this.#w=void 0}#y(){if(this.#c===void 0){const e=To(this.#e.argv);this.#c=Re(e,!1),this.#E()}return this.#c}#E(){if(!this.#c)return;const e=j();let n=!1;for(const i of this.#c){if(i==="--quiet"||i==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(gt),n=!0;break}if(i==="--verbose"||i==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(wt),n=!0;break}if(i==="--debug"){e.CEREBRO_OUTPUT_LEVEL=String(q),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(q):String(ve))}#P(){this.#C||(this.#N=Vo(this.#t),this.#C=!0)}#U(){return{arch:vt(),argv:this.#y(),cwd:this.#u,env:this.#O??j(),exit:this.#$??(e=>G(e??0)),platform:yt(),stdin:this.#A}}#I(e,n,i,s){this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:c,parsedArgs:r}=oo(e,n,this.#k()),g=Object.keys(c).length>0;let a=r;g&&(a={...r,_all:{...r._all,...c}}),ro(o,a,e);const u=no(e,r,c,i);u.runtime=this,u.argv=this.#y(),u.fs=this.#b??Fo,u.process=this.#U(),u.console=this.#t;const f=e.options&&e.options.length>0;if(f&&e.options){const l=e.options.filter(d=>d.name.startsWith("no-"));for(const d of l){const p=d.name.replace(/^no-/,""),v=`--${d.name}`,b=`--${p}`,y=n.includes(v),N=n.includes(b);if(y&&N)throw new We(p,d.name)}}return f&&(xo(u,e),Io(u,e)),lo(o,u.options,e),j().CEREBRO_OUTPUT_LEVEL===String(q)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(u.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(u.argument,null,2))),{arguments_:o,booleanValues:c,commandArgs:a,parsedArgs:r,toolbox:u}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new A("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#p=e.trim();const i=n.argv??me(),s=n.cwd??bt();if(this.#e={...n,argv:i,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new A("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 A("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new A("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new A("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const o=j();if(o.CEREBRO_OUTPUT_LEVEL=String(ve),typeof this.#e.logger=="object"){const u=["debug","error","info","log","warn"],f=[],l=this.#e.logger;for(const d of u)typeof l[d]!="function"&&f.push(d);if(f.length>0)throw new A(`Logger object is missing required methods: ${f.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:f});this.#t=this.#e.logger}else this.#t={...console,debug:(...u)=>{o.CEREBRO_OUTPUT_LEVEL===String(q)&&console.debug(...u)}};this.#f=this.#e.packageVersion,this.#v=this.#e.packageName,this.#u=this.#e.cwd,this.#s="help",this.#a={};const c=n.fs;if(c!==void 0&&(typeof c!="object"||c===null))throw new A("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const r=n.exit;if(r!==void 0&&typeof r!="function")throw new A("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const g=n.env;if(g!==void 0&&(typeof g!="object"||g===null))throw new A("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const a=n.stdin;if(a!==void 0&&typeof a!="string")throw new A("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#b=n.fs,this.#$=n.exit,this.#O=n.env,this.#A=n.stdin??"",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){fe(e,"Command"),ee(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new A(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new A(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?ee(e.alias):Be(e.alias,"Command alias").forEach(a=>ee(a))),e.argument&&fe(e.argument,"Command argument"),e.options&&fe(e.options,"Command options"),e.commandPath&&(Be(e.commandPath,"Command commandPath"),e.commandPath.forEach(a=>{ee(a)}));const s=Ve(e.name,e.commandPath),o=V(s);if(this.#o.has(o))throw new A(`Command with path "${o}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,r=this.#n.get(e.name),g=r!==void 0&&(r.commandPath===void 0||r.commandPath.length===0);if(!c&&g)throw new A(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const a of e.options)ke(a);if(co(e),ko(e),_o(e),e.options&&(e.__conflictingOptions__=e.options.filter(a=>a.conflicts!==void 0),e.__requiredOptions__=e.options.filter(a=>a.required===!0)),c&&r!==void 0)this.#n.set(o,e);else{if(!c&&r!==void 0&&!g){const a=Ve(r.name,r.commandPath);this.#n.set(V(a),r)}this.#n.set(e.name,e)}if(this.#o.set(o,s),this.#i.set(o,e),this.#x(),e.alias!==void 0){const a=typeof e.alias=="string"?[e.alias]:e.alias;for(const u of a){if(j().CEREBRO_OUTPUT_LEVEL===String(q)&&this.#t.debug("adding alias",u),this.#n.has(u))throw new A(`Command alias "${u}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:u,commandName:e.name});this.#n.set(u,e)}}return this}addGlobalOption(e){const n=e,i=new Set(X.map(o=>o.name)),s=new Set(X.map(o=>o.alias).filter(Boolean));if(i.has(n.name))throw new A(`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 A(`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(o=>o.name)).has(n.name))throw new A(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",ke(n),this.#l.push(n),this}getGlobalOptions(){return this.#k()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#h?this.#h:(this.#h=new Gt(this.#t),this.#h.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#h)}getCliName(){return this.#p}getPackageVersion(){return this.#f}getPackageName(){return this.#v}getCommands(){return this.#n}getCwd(){return this.#u}dispose(){this.#N?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...s}=e;if(!this.#n.has("help")){const{default:h}=await import("../commands/help-command.js");this.addCommand(new h(this.#n))}const o=this.#_(),c=this.#o;this.#P();const r=this.#y();let g,a=[...r];const u=$t(),f=Ot(),l=me();this.#t.debug(`process.execPath: ${u}`),this.#t.debug(`process.execArgv: ${f.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const d=uo(c,[...r]);if(d.commandPath)g=d.commandPath,a=d.argv;else{if(r.length>1&&r[0]&&r[1]&&!de(r[0])&&!de(r[1])){const m=[];let w=0;for(;w<r.length;){const O=r[w];if(!O||de(O))break;m.push(O),w+=1}const $=V(m);if(m[0]&&!o.includes(m[0])){const O=this.#r(),P=S($,O);throw new T($,P)}}let h;try{h=Zt([null,...o],[...r])}catch(m){if(m instanceof Error&&m.name==="INVALID_COMMAND"&&"command"in m){const w=m.command,$=this.#r(),O=S(w,$);throw new T(w,O)}throw m}h.command&&(g=[h.command],a=h.argv)}if(!g)if(this.#s)g=[this.#s];else{const h=this.#r();throw new T("",h)}const p=V(g),v=this.#o.get(p);let b;if(v){if(b=this.#i.get(p),!b||V(v)!==p){const h=this.#r(),m=S(p,h);throw new T(p,m)}}else{const h=g.at(-1);if(b=h?this.#n.get(h):void 0,!b){const m=this.#r(),w=S(p,m);throw new T(p,w)}}if(typeof b.execute!="function"&&typeof b.loader!="function")return this.#t.error(`Command "${b.name}" has no function to execute.`),i?G(1):void 0;const y=a;let N,C;try{({commandArgs:N,toolbox:C}=this.#I(b,y,s,p))}catch(h){if(this.#t.error(h),i)return G(1);throw h}const k=this.getPluginManager();try{!this.#d&&k.hasPlugins()&&(await k.init({cli:this,cwd:this.#u,logger:this.#t}),this.#d=!0),await k.executeLifecycle("execute",C),await k.executeLifecycle("beforeCommand",C);let h;const m=N.global;if(m?.help){const w=this.#n.get("help");if(!w)throw new A("Help command not found","COMMAND_NOT_FOUND");h=await F(w,C)}else if(m?.version??m?.V){const w=this.#n.get("version");if(!w)throw new A("Version command not found","COMMAND_NOT_FOUND");h=await F(w,C)}else h=await F(b,C);return await k.executeLifecycle("afterCommand",C,h),i?G(0):void 0}catch(h){throw await k.executeErrorHandlers(h,C),h}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...s}=n;ge(e,"Command name");const o=e.split(" ").filter(Boolean),c=V(o),r=this.#o.get(c)?this.#i.get(c):this.#n.get(e);if(!r){const l=this.#r(),d=S(c||e,l);throw new T(e,d)}if(typeof r.execute!="function"&&typeof r.loader!="function")throw new A(`Command "${r.name}" has no function to execute`,"INVALID_COMMAND",{commandName:r.name});const g=[...Re(i,!1)];this.#t.debug(`running command '${e}' programmatically with args: ${g.join(", ")}`);const{commandArgs:a,toolbox:u}=this.#I(r,g,s,c||e),f=this.getPluginManager();try{!this.#d&&f.hasPlugins()&&(await f.init({cli:this,cwd:this.#u,logger:this.#t}),this.#d=!0),await f.executeLifecycle("execute",u),await f.executeLifecycle("beforeCommand",u);let l;const d=a.global;if(d?.help){const p=this.#n.get("help");if(!p)throw new A("Help command not found","COMMAND_NOT_FOUND");l=await F(p,u)}else if(d?.version??d?.V){const p=this.#n.get("version");if(!p)throw new A("Version command not found","COMMAND_NOT_FOUND");l=await F(p,u)}else l=await F(r,u);return await f.executeLifecycle("afterCommand",u,l),l}catch(l){throw await f.executeErrorHandlers(l,u),l}}clone(e){const n={...this.#e,...e},i=new at(this.#p,n);for(const[s,o]of this.#n)i.#n.set(s,o);for(const[s,o]of this.#o)i.#o.set(s,[...o]);for(const[s,o]of this.#i)i.#i.set(s,o);for(const s of this.#l)i.#l.push(s);return i.#s=this.#s,i.#a={...this.#a},i.#x(),i}async getAction(e){ge(e,"Command name");const n=e.split(" ").filter(Boolean),i=V(n),s=this.#o.get(i)?this.#i.get(i):this.#n.get(e);if(!s){const o=this.#r(),c=S(i||e,o);throw new T(e,c)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return Xe(s);throw new A(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}export{at as Cli};
@@ -1,76 +0,0 @@
1
- import{createRequire as M}from"node:module";import{O as ur,C as cr,V as lr,_ as fr}from"./renderError-DJiY-69l-s_7rEsoy.js";import{E as mr,u as dr}from"./isVisulimaError-jVZgumOU-C67qeq6-.js";const V=M(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=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 V(e)},{createRequire:U}=B("node:module");var q=Object.defineProperty,z=(e,r)=>q(e,"name",{value:r,configurable:!0}),K=Object.defineProperty,w=z((e,r)=>K(e,"name",{value:r,configurable:!0}),"l");const N=w((e,r)=>{let t=0,n=r.length-2;for(;t<n;){const o=t+(n-t>>1);if(e<r[o])n=o-1;else if(e>=r[o+1])t=o+1;else{t=o;break}}return t},"binarySearch"),Y=/\n|\r(?!\n)/,H=w(e=>e.split(Y).reduce((r,t)=>(r.push(r.at(-1)+t.length+1),r),[0]),"getLineStartIndexes"),He=w((e,r,t)=>{const n=t?.skipChecks??!1;if(!n&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return{column:0,line:0};if(!n&&(typeof r!="number"||typeof e=="string"&&r>=e.length||Array.isArray(e)&&r+1>=e.at(-1)))return{column:0,line:0};if(typeof e=="string"){const a=H(e),i=N(r,a);return{column:r-a[i]+1,line:i+1}}const o=N(r,e);return{column:r-e[o]+1,line:o+1}},"indexToLineColumn");var X=Object.defineProperty,W=(e,r)=>X(e,"name",{value:r,configurable:!0}),G=Object.defineProperty,Q=W((e,r)=>G(e,"name",{value:r,configurable:!0}),"t");const Xe=Q(({applicationType:e,error:r,file:t})=>`You are a very skilled ${t.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(t.line)}
21
-
22
- File:
23
- ${t.file}
24
-
25
- Snippet including line numbers:
26
- ${t.snippet??""}
27
-
28
- Exception class:
29
- ${r.name}
30
-
31
- Exception message:
32
- ${r.message}`,"aiPrompt");var Z=Object.defineProperty,ee=(e,r)=>Z(e,"name",{value:r,configurable:!0}),re=Object.defineProperty,I=ee((e,r)=>re(e,"name",{value:r,configurable:!0}),"o");const A=I((e,r,t)=>{const n=t.indexOf(e);if(n===-1)return"";const o=n+e.length,a=t.indexOf(r,o);return a===-1?"":t.slice(o,a).trim()},"between"),We=I(e=>{const r=A("FIX","ENDFIX",e);if(!r)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 t=A("LINKS","ENDLINKS",e),n=t?t.split(`
33
- `).map(a=>a.trim()).filter(Boolean).map(a=>{try{return JSON.parse(a)}catch{return}}).filter(a=>a!==void 0):[],o=n.length>0?`
34
-
35
- ## Links
36
-
37
- ${n.map(a=>`- <a href="${a.url}" target="_blank" rel="noopener noreferrer">${a.title}</a>`).join(`
38
- `)}`:"";return`${r.replaceAll(/"([^"]*)"(?:\s|\.)/g,"<code>$1</code> ")}${o}
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.`},"aiSolutionResponse");var te=Object.defineProperty,ne=(e,r)=>te(e,"name",{value:r,configurable:!0}),oe=Object.defineProperty,ae=ne((e,r)=>oe(e,"name",{value:r,configurable:!0}),"n");const Ge={handle:ae(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),"handle"),name:"errorHint",priority:1};var ie=Object.defineProperty,se=(e,r)=>ie(e,"name",{value:r,configurable:!0}),ue=Object.defineProperty,s=se((e,r)=>ue(e,"name",{value:r,configurable:!0}),"t");const ce=s(e=>`\`\`\`
43
- ${e.trim()}
44
- \`\`\``,"code"),v=s(e=>`\`\`\`bash
45
- ${e.trim()}
46
- \`\`\``,"bash"),$=s(e=>`\`\`\`ts
47
- ${e.trim()}
48
- \`\`\``,"ts"),le=s(e=>`\`\`\`js
49
- ${e.trim()}
50
- \`\`\``,"js"),f=s((e,...r)=>{const t=e.toLowerCase();return r.some(n=>t.includes(n.toLowerCase()))},"has"),fe=[{name:"esm-cjs-interop",test:s(e=>{const{message:r}=e;if(f(r,"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:",v(`node -v
51
- cat package.json | jq .type`),"","Example dynamic import in CJS:",le("(async () => { const mod = await import('some-esm'); mod.default(); })();")].join(`
52
- `),title:"ESM/CJS interop"}},"test")},{name:"missing-default-export",test:s(e=>{const{message:r}=e;if(f(r,"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:",$(`export default function Component() {}
53
- // import Component from './file'`),"","Named export example:",$(`export function Component() {}
54
- // import { Component } from './file'`)].join(`
55
- `),title:"Export mismatch (default vs named)"}},"test")},{name:"port-in-use",test:s(e=>{const{message:r}=e;if(f(r,"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:",v(`lsof -i :3000
56
- kill -9 <PID>`),"","On Windows (PowerShell):",v(`netstat -ano | findstr :3000
57
- taskkill /PID <PID> /F`)].join(`
58
- `),title:"Port already in use"}},"test")},{name:"file-not-found-or-case",test:s((e,r)=>{const{message:t}=e;if(f(t,"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:",ce(`${r.file}:${String(r.line)}`)].join(`
59
- `),title:"Missing file or path case mismatch"}},"test")},{name:"ts-path-mapping",test:s(e=>{const{message:r}=e;if(f(r,"ts2307","cannot find module")||r.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:",$(`{
60
- "compilerOptions": {
61
- "baseUrl": ".",
62
- "paths": { "@/*": ["src/*"] }
63
- }
64
- }`)].join(`
65
- `),title:"TypeScript path mapping / resolution"}},"test")},{name:"network-dns-enotfound",test:s(e=>{const{message:r}=e;if(f(r,"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.","",v(`ping <host>
66
- nslookup <host>
67
- curl -v http://<host>:<port>`)].join(`
68
- `),title:"Network/DNS connection issue"}},"test")},{name:"undefined-property",test:s(e=>{const{message:r}=e;if(f(r,"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.","",$("const value = maybe?.prop; // or: if (maybe) { use(maybe.prop) }")].join(`
69
- `),title:"Accessing property of undefined"}},"test")}],Qe={handle:s((e,r)=>{try{const t=fe.map(o=>({match:o.test(e,r),rule:o})).filter(o=>!!o.match);if(t.length===0)return Promise.resolve(void 0);const n=t.toSorted((o,a)=>(o.match.priority??0)-(a.match.priority??0)).map(o=>`#### ${o.match.title}
70
-
71
- ${o.match.md}`).join(`
72
-
73
- ---
74
-
75
- `);return n===""?Promise.resolve(void 0):Promise.resolve({body:n,header:"### Potential fixes detected"})}catch{return Promise.resolve(void 0)}},"handle"),name:"ruleBasedHints",priority:0};var pe=Object.defineProperty,C=(e,r)=>pe(e,"name",{value:r,configurable:!0}),me=Object.defineProperty,de=C((e,r)=>me(e,"name",{value:r,configurable:!0}),"s");let p=class extends Error{static{C(this,"e")}static{de(this,"NonError")}constructor(r){super(r),this.name="NonError"}};var be=Object.defineProperty,ge=(e,r)=>be(e,"name",{value:r,configurable:!0}),ye=Object.defineProperty,he=ge((e,r)=>ye(e,"name",{value:r,configurable:!0}),"e");const er=he(()=>{if(!Error.captureStackTrace)return;const e=new Error;return Error.captureStackTrace(e),e.stack},"captureRawStackTrace");var ve=Object.defineProperty,$e=(e,r)=>ve(e,"name",{value:r,configurable:!0}),je=Object.defineProperty,O=$e((e,r)=>je(e,"name",{value:r,configurable:!0}),"n");const y=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&y.set("AggregateError",AggregateError);const rr=O((e,r)=>{let t;try{t=new e}catch(o){throw new Error(`The error constructor "${e.name}" is not compatible`,{cause:o})}const n=r??t.name;if(y.has(n))throw new Error(`The error constructor "${n}" is already known.`);y.set(n,e)},"addKnownErrorConstructor");O(()=>new Map(y),"getKnownErrorConstructors");const _=O(e=>y.get(e),"getErrorConstructor"),E=O(e=>e!==null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.message=="string"&&(_(e.name)!==void 0||e.name==="Error"),"isErrorLike");var Oe=Object.defineProperty,Ee=(e,r)=>Oe(e,"name",{value:r,configurable:!0}),Pe=Object.defineProperty,c=Ee((e,r)=>Pe(e,"name",{value:r,configurable:!0}),"s");const D=c(e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},"isPlainObject"),Se={maxDepth:Number.POSITIVE_INFINITY},J=c((e,r,t=0)=>E(e)?x(e,r,t):r.maxDepth!==void 0&&t>=r.maxDepth?new p(JSON.stringify(e)):new p(JSON.stringify(e)),"deserializePlainObject"),we=c((e,r,t,n,o)=>{const a=r.map(i=>h(i,n,o+1));return new e(a,t)},"reconstructAggregateError"),x=c((e,r,t)=>{if(r.maxDepth!==void 0&&t>=r.maxDepth)return new p(JSON.stringify(e));const{cause:n,errors:o,message:a,name:i,stack:u,...d}=e,k=_(i)??Error,l=i==="AggregateError"&&Array.isArray(o)?we(k,o,a,r,t):new k(a);return!l.name&&i&&(l.name=i),a!==void 0&&(l.message=a),u&&(l.stack=u),xe(l,d,n,i,r,t),n!==void 0&&(l.cause=h(n,r,t+1)),ke(l,e),l},"reconstructError"),h=c((e,r,t)=>{if(D(e)){if(E(e))return J(e,r,t);const n={};for(const[o,a]of Object.entries(e))n[o]=h(a,r,t+1);return n}return Array.isArray(e)?e.map(n=>h(n,r,t)):e},"deserializeValue"),xe=c((e,r,t,n,o,a)=>{const i=e;for(const[u,d]of Object.entries(r))if(!(u==="cause"&&t!==void 0)){if(u==="errors"&&n==="AggregateError")continue;i[u]=h(d,o,a+1)}},"restoreErrorProperties"),ke=c((e,r)=>{const t=new Set(["message","name","stack"]);for(const n of Object.keys(r))t.add(n);for(const n of t)if(n in e){const o=Object.getOwnPropertyDescriptor(e,n);o&&!o.enumerable&&Object.defineProperty(e,n,{...o,enumerable:!0})}},"makePropertiesEnumerable"),T=c(e=>new p(JSON.stringify(e)),"handlePrimitive"),Ne=c(e=>new p(JSON.stringify(e)),"handleArray"),Ae=c((e,r)=>E(e)?x(e,r,0):J(e,r),"handlePlainObject"),tr=c((e,r={})=>{const t={...Se,...r};return e instanceof Error?e:e===null?T(null):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?T(e):Array.isArray(e)?Ne(e):E(e)?x(e,t,0):D(e)?Ae(e,t):new p(JSON.stringify(e))},"deserialize");var Te=Object.defineProperty,L=(e,r)=>Te(e,"name",{value:r,configurable:!0});const Ie=U(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ce=L(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,t]=g.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return g.getBuiltinModule(e)}return Ie(e)},"__cjs_getBuiltinModule"),{inspect:_e}=Ce("node:util");var De=Object.defineProperty,Je=L((e,r)=>De(e,"name",{value:r,configurable:!0}),"s");const nr=Je(e=>{const r=new Set,t=[];let n=e;for(;n;){if(r.has(n)){console.error(`Circular reference detected in error causes: ${_e(e)}`);break}if(t.push(n),r.add(n),typeof n!="object"||!("cause"in n))break;n=n.cause}return t},"getErrorCauses");var Le=Object.defineProperty,Fe=(e,r)=>Le(e,"name",{value:r,configurable:!0}),Re=Object.defineProperty,F=Fe((e,r)=>Re(e,"name",{value:r,configurable:!0}),"s");const Me=F(e=>{const r=e.methodName&&e.methodName!=="<unknown>"?`${e.methodName} `:"",t=e.file??"<unknown>",n=String(e.line??0),o=String(e.column??0);return r.trim()?` at ${r}(${t}:${n}:${o})`:` at ${t}:${n}:${o}`},"formatStackFrameLine"),or=F((e,r)=>{const t=[];if(r?.header&&(r.header.name||r.header.message)){const n=r.header.name??"Error",o=r.header.message??"";t.push(`${n}${o?": ":""}${o}`)}for(const n of e)t.push(Me(n));return t.join(`
76
- `)},"formatStacktrace");var Ve=Object.defineProperty,Be=(e,r)=>Ve(e,"name",{value:r,configurable:!0});const Ue=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}});var qe=Object.defineProperty,m=Be((e,r)=>qe(e,"name",{value:r,configurable:!0}),"i");const ze=m(e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},"isPlainObject"),P=new WeakSet,R=m(e=>{const r=Object.getOwnPropertyNames(e);for(const t of r){const n=Object.getOwnPropertyDescriptor(e,t);n&&(n.enumerable||Object.defineProperty(e,t,{...n,enumerable:!0}),n.value&&typeof n.value=="object"&&!Array.isArray(n.value)&&(Object.getPrototypeOf(n.value)===Object.prototype||Object.getPrototypeOf(n.value)===null)&&R(n.value))}},"makePropertiesEnumerable"),Ke=m(e=>{P.add(e);const r=e.toJSON();return P.delete(e),Object.isExtensible(r)&&R(r),r},"toJSON"),S=m((e,r,t,n,o=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 r.has(e)?"[Circular]":(t+=1,j(e,n,r,t));if(n.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(ze(e)){if(o.has(e))return"[Circular]";if(n.maxDepth!==void 0&&n.maxDepth!==Number.POSITIVE_INFINITY&&t+1>=n.maxDepth)return{};t+=1,o.add(e);const a={};for(const i in e)a[i]=S(e[i],r,t,n,o);return o.delete(e),a}try{return e}catch{return"[Not Available]"}},"serializeValue"),j=m((e,r,t,n)=>{if(t.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!P.has(e))return Ke(e);const o=Object.create(Ue);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const i=[];for(const u of e.errors){if(!(u instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(t.has(u))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;i.push(j(u,r,t,n))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:i,writable:!0})}const a=e.cause;if(a!=null)if(a instanceof Error)t.has(a)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:j(a,r,t,n),writable:!0});else{const i=S(a,t,n,r);Object.defineProperty(o,"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 u=e[i],d=S(u,t,n,r);Object.defineProperty(o,i,{configurable:!0,enumerable:!0,value:d,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const i of r.exclude)try{delete o[i]}catch{}return o},"_serialize"),ar=m((e,r={})=>j(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0),"serialize");export{ur as CODE_FRAME_POINTER,p as NonError,mr as VisulimaError,rr as addKnownErrorConstructor,Xe as aiPrompt,We as aiSolutionResponse,er as captureRawStackTrace,cr as codeFrame,tr as deserializeError,Ge as errorHintFinder,Me as formatStackFrameLine,or as formatStacktrace,nr as getErrorCauses,He as indexToLineColumn,E as isErrorLike,dr as isVisulimaError,lr as parseStacktrace,fr as renderError,Qe as ruleBasedFinder,ar as serializeError};
@@ -1 +0,0 @@
1
- import{E as r}from"./isVisulimaError-jVZgumOU-C67qeq6-.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 +0,0 @@
1
- const e=String.raw,p=e`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,i=()=>new RegExp(e`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${p}(?:\u200D${p})*`,"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 r=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,t=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,n=i(),a=/[-_./\s]+/g,E=/(\u001B\[[0-9;]*[a-z])/i,c=new RegExp("\\p{Script=Arabic}","u"),g=new RegExp("\\p{Script=Bengali}","u"),S=new RegExp("\\p{Script=Cyrillic}","u"),w=new RegExp("\\p{Script=Devanagari}","u"),R=new RegExp("\\p{Script=Ethiopic}","u"),x=new RegExp("\\p{Script=Greek}","u"),l=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),B=new RegExp("\\p{Script=Gujarati}","u"),F=new RegExp("\\p{Script=Gurmukhi}","u"),m=new RegExp("\\p{Script=Hangul}","u"),o=new RegExp("\\p{Script=Hebrew}","u"),y=new RegExp("\\p{Script=Hiragana}","u"),h=new RegExp("\\p{Script=Han}","u"),k=new RegExp("\\p{Script=Kannada}","u"),G=new RegExp("\\p{Script=Katakana}","u"),b=new RegExp("\\p{Script=Khmer}","u"),d=new RegExp("\\p{Script=Lao}","u"),H=new RegExp("\\p{Script=Latin}","u"),L=new RegExp("\\p{Script=Malayalam}","u"),M=new RegExp("\\p{Script=Myanmar}","u"),T=new RegExp("\\p{Script=Oriya}","u"),j=new RegExp("\\p{Script=Sinhala}","u"),K=new RegExp("\\p{Script=Tamil}","u"),O=new RegExp("\\p{Script=Telugu}","u"),f=new RegExp("\\p{Script=Thai}","u"),s=new RegExp("\\p{Script=Tibetan}","u"),z=/[\u02BB\u02BC\u0027]/u,A=u=>u.replace(n,"");export{y as A,h as C,k as D,c as G,S as H,d as I,H as J,B as K,w as L,R as M,L as N,F as O,M as P,T as Q,x as T,j as U,K as V,O as W,f as X,A as Y,s as Z,z as _,g as b,m as f,a as h,l as j,E as k,r as m,n,G as q,b as v,t as y,o as z};