@stacksjs/dtsx 0.9.19 → 0.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +5 -5
- package/dist/{chunk-fg4cjy7w.js → chunk-0cfb4831.js} +1 -1
- package/dist/{chunk-w71syh0b.js → chunk-0d5r9n78.js} +1 -1
- package/dist/chunk-1b1j60g0.js +2 -0
- package/dist/{chunk-s30jnjb4.js → chunk-1hy2eypj.js} +1 -1
- package/dist/{chunk-1z1w3s0k.js → chunk-4mtbtmee.js} +11 -11
- package/dist/{chunk-nwvqfthk.js → chunk-5zt12z1t.js} +1 -1
- package/dist/chunk-7hy98p24.js +62 -0
- package/dist/{chunk-mr4jjsps.js → chunk-9e542zj7.js} +1 -1
- package/dist/{chunk-2qyt67jt.js → chunk-a0gah6hn.js} +1 -1
- package/dist/{chunk-kwmhsx3n.js → chunk-bymtns9a.js} +1 -1
- package/dist/chunk-c60qpa3j.js +2 -0
- package/dist/chunk-cdv5r51q.js +156 -0
- package/dist/chunk-dnbr0hke.js +2 -0
- package/dist/{chunk-fmhrt2ca.js → chunk-dymmh9x0.js} +1 -1
- package/dist/chunk-eqfegkc1.js +2 -0
- package/dist/{chunk-m68323h2.js → chunk-fqym6cgw.js} +1 -1
- package/dist/{chunk-69rnp3hs.js → chunk-ft0nf9jb.js} +1 -1
- package/dist/{chunk-9ycwkhxh.js → chunk-fvgc14nk.js} +1 -1
- package/dist/{chunk-ezrgnecm.js → chunk-h0dndwyc.js} +1 -1
- package/dist/chunk-m94gn6yx.js +2 -0
- package/dist/chunk-nmmv0nrk.js +2 -0
- package/dist/{chunk-x4jgc4bx.js → chunk-nqwz71ak.js} +1 -1
- package/dist/{chunk-gg6xh82k.js → chunk-r1yqh3qg.js} +1 -1
- package/dist/{chunk-fbradttj.js → chunk-rd7n0yj1.js} +1 -1
- package/dist/{chunk-7pwy4m0c.js → chunk-vx4a5crm.js} +1 -1
- package/dist/{chunk-dv8haj2p.js → chunk-wtqapt0n.js} +1 -1
- package/dist/chunk-xw9wfq8f.js +17 -0
- package/dist/{chunk-jjwwkrfk.js → chunk-y2pe3jq3.js} +1 -1
- package/dist/{chunk-7zsd1qqw.js → chunk-y4g1csn2.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2n9mmg2c.js +0 -2
- package/dist/chunk-4jw8qvts.js +0 -16
- package/dist/chunk-7g7axw9t.js +0 -2
- package/dist/chunk-9qe2wx58.js +0 -2
- package/dist/chunk-a3txc27m.js +0 -33
- package/dist/chunk-q0k7xs9f.js +0 -2
- package/dist/chunk-sbmecr6t.js +0 -2
- package/dist/chunk-trm0gptj.js +0 -134
- package/dist/chunk-w1k33gyv.js +0 -2
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as i$,b as n$,c as r$}from"../chunk-
|
|
2
|
+
import{a as i$,b as n$,c as r$}from"../chunk-0cfb4831.js";import{d as S9,e as T9,f as k9,g as v9,h as C9,i as b9,j as P9,k as x9}from"../chunk-1hy2eypj.js";import{l as Q2,m as X2,n as q2,o as V2,p as Y2,q as W2,r as K2}from"../chunk-wtqapt0n.js";import{s as p$,t as d$,u as c$,v as l$,w as o$,x as s$,y as a$}from"../chunk-fvgc14nk.js";import{A as p8,B as d8,C as c8,D as l8,E as o8,F as s8,G as a8,H as i8,z as m8}from"../chunk-mxam9312.js";import{I as Z$,J as $$,K as J$,L as Q$,M as X$,N as q$,O as V$,P as Y$}from"../chunk-d0p3jzwb.js";import{Q as n8,R as r8,S as t8,T as e8,U as Z9,V as $9,W as J9,X as Q9,Y as X9}from"../chunk-nf54b52t.js";import{$ as Z2,Z as t$,_ as e$,aa as $2,ba as J2}from"../chunk-zf17s33e.js";import{$a as t9,Aa as u8,Ba as q9,Ca as V9,Da as Y9,Ea as QZ,Fa as W9,Ga as K9,Ha as H9,Ia as U9,Ja as O9,Ka as G9,La as y9,Ma as h9,Na as g9,Oa as f9,Pa as u9,Qa as m9,Ra as p9,Sa as d9,Ta as c9,Ua as l9,Va as o9,Wa as s9,Xa as a9,Ya as i9,Za as n9,_a as r9,ab as e9,bb as W$,cb as K$,db as H$,eb as U$,fb as O$,gb as G$,hb as uZ,ib as _$,jb as z$,kb as A$,lb as T$,mb as k$,nb as v$,ob as C$,pb as b$,qb as P$,rb as x$,sb as y$,tb as f$,ua as P8,ub as u$,va as x8,vb as m$,wa as y8,xa as h8,ya as g8,za as f8}from"../chunk-y4g1csn2.js";import{$b as I8,Ab as s6,Bb as s0,Cb as a0,Db as Q8,Eb as X8,Fb as q8,Gb as V8,Hb as Y8,Ib as W8,Jb as K8,Kb as H8,Lb as U8,Mb as O8,Nb as G8,Ob as _8,Pb as z8,Qb as A8,Rb as B8,Sb as j8,Tb as N8,Ub as R8,Vb as F8,Wb as D8,Xb as E8,Yb as L8,Zb as w8,_b as M8,ac as S8,bc as T8,cc as k8,dc as v8,ec as FZ,fc as C8,gc as b8,wb as d6,xb as c6,yb as l6,zb as o6}from"../chunk-ft0nf9jb.js";import{hc as g0}from"../chunk-2n1bbm2c.js";import{ic as h$,jc as g$}from"../chunk-bymtns9a.js";import{lc as KZ}from"../chunk-y2pe3jq3.js";import"../chunk-4mtbtmee.js";import{Ac as I$,Bc as S$,Cc as DZ,pc as i0,qc as B$,rc as j$,sc as N$,tc as R$,uc as F$,vc as D$,wc as E$,xc as L$,yc as w$,zc as M$}from"../chunk-vx4a5crm.js";import{Fc as a6,Gc as i6,Hc as n6,Ic as r6,Jc as t6,Kc as o0,Lc as e6,Mc as Z8,Nc as $8,Oc as J8}from"../chunk-xw9wfq8f.js";import{Pc as D9,Qc as E9,Rc as L9,Sc as w9,Tc as M9,Uc as I9}from"../chunk-7hy98p24.js";import{$c as R9,Vc as _9,Wc as z9,Xc as A9,Yc as B9,Zc as j9,_c as N9,ad as F9}from"../chunk-gssantc8.js";import{bd as h0,dd as n0}from"../chunk-mcdb3q06.js";import{basename as rZ,dirname as tZ,isAbsolute as eZ,join as Z0,relative as $0,resolve as J0}from"path";function l1(Z){if(!Z||typeof Z!=="string")throw Error("Invalid file path: must be a non-empty string");return Z}function o1(Z){if(!Z||typeof Z!=="string")throw Error("Invalid directory path: must be a non-empty string");return Z}function s1(Z){if(!Z||typeof Z!=="string")throw Error("Invalid glob pattern: must be a non-empty string");return Z}function a1(Z){if(typeof Z!=="string")throw TypeError("Invalid source code: must be a string");return Z}function i1(Z){if(typeof Z!=="string")throw TypeError("Invalid DTS content: must be a string");return Z}function n1(Z){if(!Z||typeof Z!=="string")throw Error("Invalid module specifier: must be a non-empty string");return Z}function r1(Z){if(!Z||typeof Z!=="string")throw Error("Invalid type name: must be a non-empty string");if(!["string","number","boolean","symbol","bigint","undefined","null","void","never","any","unknown","object"].includes(Z)&&!/^[A-Z_$]/.test(Z));return Z}function t1(Z){if(!Z||typeof Z!=="string")throw Error("Invalid declaration name: must be a non-empty string");return Z}function e1(Z){if(!Z||typeof Z!=="string")throw Error("Invalid absolute path: must be a non-empty string");if(!Z.startsWith("/")&&!/^[A-Z]:/i.test(Z))throw Error("Invalid absolute path: must start with / or drive letter");return Z}function Z3(Z){if(!Z||typeof Z!=="string")throw Error("Invalid relative path: must be a non-empty string");if(Z.startsWith("/")||/^[A-Z]:/i.test(Z))throw Error("Invalid relative path: must not be absolute");return Z}function $3(Z){if(typeof Z!=="string")throw TypeError("Invalid JSON string: must be a string");try{JSON.parse(Z)}catch{throw Error("Invalid JSON string: must be valid JSON")}return Z}function J3(Z,$){return typeof Z==="string"||typeof Z==="number"}function Q3(Z){return Z}var X3={join(Z,...$){return Z0(Z,...$)},dirname(Z){return tZ(Z)},basename(Z){return rZ(Z)},resolve(...Z){return J0(...Z)},isAbsolute(Z){return eZ(Z)},relative(Z,$){return $0(Z,$)}};function Q0(Z,$){let J=Z.length,Q=$.length,X=Array.from({length:J+1},()=>Array(Q+1).fill(0));for(let q=1;q<=J;q++)for(let V=1;V<=Q;V++)if(Z[q-1]===$[V-1])X[q][V]=X[q-1][V-1]+1;else X[q][V]=Math.max(X[q-1][V],X[q][V-1]);return X}function X0(Z,$,J,Q,X){let q=[];while(Q>0||X>0)if(Q>0&&X>0&&$[Q-1]===J[X-1])q.unshift({op:"equal",oldIdx:Q-1,newIdx:X-1,line:$[Q-1]}),Q--,X--;else if(X>0&&(Q===0||Z[Q][X-1]>=Z[Q-1][X]))q.unshift({op:"add",newIdx:X-1,line:J[X-1]}),X--;else if(Q>0)q.unshift({op:"remove",oldIdx:Q-1,line:$[Q-1]}),Q--;return q}function JZ(Z,$){let J=Z;if($.ignoreWhitespace)J=J.replace(/\s+/g," ").trim();return J}function p(Z,$,J,Q={}){let{context:X=3,ignoreWhitespace:q=!1,ignoreBlankLines:V=!1}=Q,Y=Z.split(`
|
|
3
3
|
`),W=$.split(`
|
|
4
4
|
`);if(Y[Y.length-1]==="")Y.pop();if(W[W.length-1]==="")W.pop();let K=Y.map((F)=>JZ(F,{ignoreWhitespace:q})),H=W.map((F)=>JZ(F,{ignoreWhitespace:q})),A=K,_=H,O=Y.map((F,M)=>M),G=W.map((F,M)=>M);if(V)A=[],_=[],O=[],G=[],K.forEach((F,M)=>{if(F.trim())A.push(F),O.push(M)}),H.forEach((F,M)=>{if(F.trim())_.push(F),G.push(M)});let U=Q0(A,_),z=X0(U,A,_,A.length,_.length),B=z.every((F)=>F.op==="equal"),j=0,N=0,R=0;for(let F of z)if(F.op==="add")j++;else if(F.op==="remove")N++;else R++;let k=q0(z,Y,W,O,G,X);return{filePath:J,identical:B,hunks:k,stats:{additions:j,deletions:N,unchanged:R},oldContent:Z,newContent:$}}function q0(Z,$,J,Q,X,q){let V=[],Y=[];if(Z.forEach((H,A)=>{if(H.op!=="equal")Y.push(A)}),Y.length===0)return V;let W=[],K=[Y[0]];for(let H=1;H<Y.length;H++)if(Y[H]-Y[H-1]<=q*2+1)K.push(Y[H]);else W.push(K),K=[Y[H]];W.push(K);for(let H of W){let A=Math.max(0,H[0]-q),_=Math.min(Z.length-1,H[H.length-1]+q),O=Z.slice(A,_+1),G=[],U=1,z=1,B=0,j=0;for(let N=0;N<A;N++){let R=Z[N];if(R.op==="equal"||R.op==="remove")U++;if(R.op==="equal"||R.op==="add")z++}for(let N of O)if(N.op==="equal")G.push(` ${N.line}`),B++,j++;else if(N.op==="remove")G.push(`-${N.line}`),B++;else if(N.op==="add")G.push(`+${N.line}`),j++;V.push({operation:"equal",lines:G,oldStart:U,oldCount:B,newStart:z,newCount:j})}return V}function Y3(Z){if(Z.identical)return"";let $=[];$.push(`--- a/${Z.filePath}`),$.push(`+++ b/${Z.filePath}`);for(let J of Z.hunks)$.push(`@@ -${J.oldStart},${J.oldCount} +${J.newStart},${J.newCount} @@`),$.push(...J.lines);return $.join(`
|
|
5
5
|
`)}function V0(Z){if(Z.identical)return`\x1B[32m\u2713 ${Z.filePath} (unchanged)\x1B[0m`;let $=[],J=`+${Z.stats.additions} -${Z.stats.deletions}`;$.push(`\x1B[1m${Z.filePath}\x1B[0m \x1B[90m(${J})\x1B[0m`),$.push("");for(let Q of Z.hunks){$.push(`\x1B[36m@@ -${Q.oldStart},${Q.oldCount} +${Q.newStart},${Q.newCount} @@\x1B[0m`);for(let X of Q.lines)if(X.startsWith("+"))$.push(`\x1B[32m${X}\x1B[0m`);else if(X.startsWith("-"))$.push(`\x1B[31m${X}\x1B[0m`);else $.push(`\x1B[90m${X}\x1B[0m`);$.push("")}return $.join(`
|
package/dist/src/plugins/bun.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fa as a,ga as b,ha as c}from"../../chunk-
|
|
2
|
+
import{fa as a,ga as b,ha as c}from"../../chunk-r1yqh3qg.js";import"../../chunk-y4g1csn2.js";import"../../chunk-ft0nf9jb.js";import"../../chunk-2n1bbm2c.js";import"../../chunk-bymtns9a.js";import"../../chunk-y2pe3jq3.js";import"../../chunk-4mtbtmee.js";import"../../chunk-vx4a5crm.js";import"../../chunk-xw9wfq8f.js";import"../../chunk-7hy98p24.js";import"../../chunk-gssantc8.js";import"../../chunk-mcdb3q06.js";export{a as dts,c as default,b as bunDts};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ia as a,ja as b,ka as c,la as d}from"../../chunk-
|
|
2
|
+
import{ia as a,ja as b,ka as c,la as d}from"../../chunk-h0dndwyc.js";import"../../chunk-y4g1csn2.js";import"../../chunk-ft0nf9jb.js";import"../../chunk-2n1bbm2c.js";import"../../chunk-bymtns9a.js";import"../../chunk-y2pe3jq3.js";import"../../chunk-4mtbtmee.js";import"../../chunk-vx4a5crm.js";import"../../chunk-xw9wfq8f.js";import"../../chunk-7hy98p24.js";import"../../chunk-gssantc8.js";import"../../chunk-mcdb3q06.js";export{b as esbuildDts,a as dtsx,c as dts,d as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ca as s}from"../../chunk-
|
|
2
|
+
import{ca as s}from"../../chunk-fqym6cgw.js";import{fa as t}from"../../chunk-r1yqh3qg.js";import{ia as i,ka as p}from"../../chunk-h0dndwyc.js";import{ma as e,oa as u}from"../../chunk-5zt12z1t.js";import{qa as l,ra as a,sa as n}from"../../chunk-9e542zj7.js";import"../../chunk-y4g1csn2.js";import"../../chunk-ft0nf9jb.js";import"../../chunk-2n1bbm2c.js";import"../../chunk-bymtns9a.js";import"../../chunk-y2pe3jq3.js";import"../../chunk-4mtbtmee.js";import"../../chunk-vx4a5crm.js";import"../../chunk-xw9wfq8f.js";import"../../chunk-7hy98p24.js";import"../../chunk-gssantc8.js";import"../../chunk-mcdb3q06.js";export{n as webpackPlugin,a as webpackDts,s as viteDts,s as vite,u as tsupPlugin,e as tsupDts,e as tsup,p as esbuildPlugin,i as esbuildDts,i as esbuild,t as bunDts,t as bun,l as DtsxWebpackPlugin};
|
package/dist/src/plugins/tsup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ma as a,na as b,oa as c,pa as d}from"../../chunk-
|
|
2
|
+
import{ma as a,na as b,oa as c,pa as d}from"../../chunk-5zt12z1t.js";import"../../chunk-y4g1csn2.js";import"../../chunk-ft0nf9jb.js";import"../../chunk-2n1bbm2c.js";import"../../chunk-bymtns9a.js";import"../../chunk-y2pe3jq3.js";import"../../chunk-4mtbtmee.js";import"../../chunk-vx4a5crm.js";import"../../chunk-xw9wfq8f.js";import"../../chunk-7hy98p24.js";import"../../chunk-gssantc8.js";import"../../chunk-mcdb3q06.js";export{b as tsupDts,a as dtsxPlugin,c as dts,d as default};
|
package/dist/src/plugins/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ca as a,da as b,ea as c}from"../../chunk-
|
|
2
|
+
import{ca as a,da as b,ea as c}from"../../chunk-fqym6cgw.js";import"../../chunk-y4g1csn2.js";import"../../chunk-ft0nf9jb.js";import"../../chunk-2n1bbm2c.js";import"../../chunk-bymtns9a.js";import"../../chunk-y2pe3jq3.js";import"../../chunk-4mtbtmee.js";import"../../chunk-vx4a5crm.js";import"../../chunk-xw9wfq8f.js";import"../../chunk-7hy98p24.js";import"../../chunk-gssantc8.js";import"../../chunk-mcdb3q06.js";export{b as viteDts,a as dts,c as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qa as a,ra as b,sa as c,ta as d}from"../../chunk-
|
|
2
|
+
import{qa as a,ra as b,sa as c,ta as d}from"../../chunk-9e542zj7.js";import"../../chunk-y4g1csn2.js";import"../../chunk-ft0nf9jb.js";import"../../chunk-2n1bbm2c.js";import"../../chunk-bymtns9a.js";import"../../chunk-y2pe3jq3.js";import"../../chunk-4mtbtmee.js";import"../../chunk-vx4a5crm.js";import"../../chunk-xw9wfq8f.js";import"../../chunk-7hy98p24.js";import"../../chunk-gssantc8.js";import"../../chunk-mcdb3q06.js";export{b as dtsxWebpack,c as dts,d as default,a as DtsxWebpackPlugin};
|
package/package.json
CHANGED
package/dist/chunk-2n9mmg2c.js
DELETED
package/dist/chunk-4jw8qvts.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var E=!1,M=null;function h(J){if(J.indexOf("/*")===-1)return J.trim();let X=[],Q=0,z=0,B=J.length;while(z<B)if(J.charCodeAt(z)===47&&z+1<B&&J.charCodeAt(z+1)===42){if(z>Q)X.push(J.substring(Q,z));z+=2;while(z<B-1){if(J.charCodeAt(z)===42&&J.charCodeAt(z+1)===47){z+=2;break}z++}Q=z}else z++;if(Q<B)X.push(J.substring(Q));return X.join("").trim()}function $z(){E=!0,M=null}function Qz(){E=!1;let J=M;return M=null,J}function S(J){let Y=J.length;if(Y===0)return!1;let X=0;if(J.charCodeAt(X)===45)X++;if(X>=Y)return!1;let Q=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===Q)return!1;if(X<Y&&J.charCodeAt(X)===46){X++;let z=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===z)return!1}return X===Y}function o(J){for(let Y=0,X=J.length-1;Y<X;Y++){let Q=J.charCodeAt(Y);if(Q<48||Q>57)return!1}return!0}function D(J,Y){let X=0,Q=0;while((Q=J.indexOf(Y,Q))!==-1)X++,Q+=Y.length;return X}function _(J){let Y=J.length,X=!1;for(let Z=1;Z<Y;Z++)if(J.charCodeAt(Z)<=32&&J.charCodeAt(Z-1)<=32){X=!0;break}if(!X)for(let Z=0;Z<Y;Z++){let $=J.charCodeAt(Z);if($===10||$===13||$===9){X=!0;break}}if(!X)return J;let Q=[],z=-1,B=!1;for(let Z=0;Z<Y;Z++)if(J.charCodeAt(Z)<=32){if(!B){if(z>=0)Q.push(J.substring(z,Z));Q.push(" "),B=!0,z=-1}}else{if(B||z<0)z=Z;B=!1}if(z>=0)Q.push(J.substring(z));return Q.join("")}function V(J,Y=!1,X=!1,Q=0){if(!J||typeof J!=="string")return"unknown";if(Q>=20)return"unknown";let z=J.trim();if(z.startsWith("BigInt("))return"bigint";if(z.startsWith("Symbol.for("))return"symbol";if(z.includes(".raw`")||z.includes("String.raw`"))return"string";if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'")||z.startsWith("`")&&z.endsWith("`")){if(!z.includes("${")){if(!Y)return"string";return z}if(Y)return z;return"string"}if(S(z)){if(!Y)return"number";return z}if(z==="true"||z==="false"){if(!Y)return"boolean";return z}if(z==="null")return"null";if(z==="undefined")return"undefined";if(z.startsWith("[")&&z.endsWith("]"))return I(z,Y,Q+1);if(z.startsWith("{")&&z.endsWith("}"))return s(z,Y,Q+1);if(z.startsWith("class ")||z.startsWith("class{"))return c(z);if(z.startsWith("new "))return d(z);if(z.includes("=>")||z.startsWith("function")||z.startsWith("async"))return y(z,X,Q,Y);if(z.endsWith("as const")){let B=z.slice(0,-8).trim();if(B.startsWith("[")&&B.endsWith("]")){let Z=B.slice(1,-1).trim();if(!Z)return"readonly []";let $=w(Z),H=[];for(let L=0;L<$.length;L++)H.push(V($[L].trim(),!0,!1,Q+1));return`readonly [${H.join(", ")}]`}return V(B,!0,X,Q+1)}if(z.startsWith("`")&&z.endsWith("`"))return p(z,Y);if(z.startsWith("Promise."))return f(z,Y,Q);if(z.startsWith("await "))return"unknown";if(z.charCodeAt(z.length-1)===110&&z.length>1&&o(z)){if(Y)return z;return"bigint"}if(z.startsWith("Symbol(")||z==="Symbol.for")return"symbol";return"unknown"}function l(J,Y=!1,X=0){return V(J,Y,!0,X)}function p(J,Y){if(J.includes(".raw`")||J.includes("String.raw`"))return"string";if(!Y)return"string";if(!J.includes("${"))return J;return"string"}function d(J){let Y=4;while(Y<J.length&&J.charCodeAt(Y)<=32)Y++;let X=Y,Q=J.charCodeAt(Y);if(Q<65||Q>90)return"unknown";while(Y<J.length&&(P(J.charCodeAt(Y))||J.charCodeAt(Y)===46))Y++;if(Y===X)return"unknown";let z=J.slice(X,Y);{let B=J.slice(Y),Z=B;if(B.startsWith("<")){let H=0,L=-1;for(let O=0;O<B.length;O++)if(B[O]==="<")H++;else if(B[O]===">"){if(H--,H===0){L=O;break}}if(L!==-1){let O=B.slice(0,L+1);Z=B.slice(L+1);let G=Z.indexOf("(");if(G!==-1){let W=0,K=-1;for(let F=G;F<Z.length;F++)if(Z[F]==="(")W++;else if(Z[F]===")"){if(W--,W===0){K=F;break}}if(K!==-1){if(Z.slice(K+1).trimStart().startsWith("."))return"unknown"}}return`${z}${O}`}}let $=Z.indexOf("(");if($!==-1){let H=0,L=-1;for(let O=$;O<Z.length;O++)if(Z[O]==="(")H++;else if(Z[O]===")"){if(H--,H===0){L=O;break}}if(L!==-1){if(Z.slice(L+1).trimStart().startsWith("."))return"unknown"}}switch(z){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return z}}return"unknown"}function c(J){let Y=J.trimStart(),X=5;while(X<Y.length&&Y.charCodeAt(X)<=32)X++;let Q=X;if(X<Y.length&&P(Y.charCodeAt(X))){while(X<Y.length&&P(Y.charCodeAt(X)))X++;return`typeof ${Y.slice(Q,X)}`}return"{ new (...args: any[]): any }"}function f(J,Y,X=0){if(J.startsWith("Promise.resolve(")){let z=J.indexOf(")",16);if(z!==-1){let B=J.slice(16,z).trim();if(B)return`Promise<${V(B,Y,!1,X+1)}>`}return"Promise<unknown>"}if(J.startsWith("Promise.reject("))return"Promise<never>";if(J.startsWith("Promise.all(")){let Q=J.indexOf("[",12),z=J.lastIndexOf("]");if(Q!==-1&&z>Q){let B=J.slice(Q+1,z).trim(),Z=w(B),$=[];for(let H=0;H<Z.length;H++){let L=Z[H].trim();if(L.startsWith("Promise.resolve(")){let O=f(L,Y,X+1),G=O.indexOf("<"),W=O.lastIndexOf(">");$.push(G!==-1&&W>G?O.slice(G+1,W):"unknown")}else $.push(V(L,Y,!1,X+1))}return`Promise<[${$.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function I(J,Y,X=0){let Q=J.slice(1,-1).trim();if(!Q)return"never[]";if(X>=20)return"unknown[]";let z=w(Q),B=!1;for(let W=0;W<z.length;W++){let K=z[W],F=K.length;while(F>0&&K.charCodeAt(F-1)<=32)F--;if(F>=8&&K.slice(F-8,F)==="as const"){B=!0;break}}if(B){let W=[];for(let K=0;K<z.length;K++){let F=z[K].trim();if(F.endsWith("as const")){let q=F.slice(0,-8).trim();if(q.startsWith("[")&&q.endsWith("]")){let N=q.slice(1,-1).trim(),U=w(N),R=[];for(let b=0;b<U.length;b++)R.push(V(U[b].trim(),!0,!1,X+1));W.push(`readonly [${R.join(", ")}]`)}else W.push(V(q,!0,!1,X+1))}else if(F.startsWith("[")&&F.endsWith("]"))W.push(I(F,!0,X+1));else W.push(V(F,!0,!1,X+1))}return`readonly [
|
|
3
|
-
${W.join(` |
|
|
4
|
-
`)}
|
|
5
|
-
]`}let Z=E&&!Y,$=[],H=[];for(let W of z){let K=W.trim(),F=M;if(M=null,K.startsWith("[")&&K.endsWith("]"))$.push(I(K,Y,X+1));else $.push(l(K,Y,X+1));if(Z)H.push(M);M=F}if(Z)if(g(J))M=_(J);else{let W=[];for(let K=0;K<z.length;K++){let F=z[K].trim();if(F.endsWith("as const"))continue;if(x(F)||F==="null"||F==="undefined")W.push(F);else if(F.startsWith("[")&&g(F))W.push(_(F));else if(F.startsWith("{")){if(H[K])W.push(H[K])}else{let q=V(F,!1,!1,0);if(q!=="unknown")W.push(q)}}if(W.length>0)M=`[${W.join(", ")}]`}if(Y)return`readonly [${$.join(", ")}]`;let L=new Set,O=[],G=!0;for(let W of $){if(!L.has(W))L.add(W),O.push(W);if(G){if(!(S(W)||W==="true"||W==="false"||W.charCodeAt(0)===34&&W.charCodeAt(W.length-1)===34||W.charCodeAt(0)===39&&W.charCodeAt(W.length-1)===39))G=!1}}if(G&&$.length<=10)return`readonly [${$.join(", ")}]`;if(O.length===1)return`${O[0]}[]`;return`(${O.join(" | ")})[]`}function w(J){let Y=[],X=0,Q=0,z=!1,B=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(!z&&(H===34||H===39||H===96))z=!0,B=H;else if(z&&H===B&&($===0||J.charCodeAt($-1)!==92))z=!1;if(!z){if(H===91||H===123||H===40)Q++;else if(H===93||H===125||H===41)Q--;else if(H===44&&Q===0){let L=J.substring(X,$).trim();if(L)Y.push(L);X=$+1;continue}}}let Z=J.substring(X).trim();if(Z)Y.push(Z);return Y}function x(J){if(S(J))return!0;if(J==="true"||J==="false")return!0;if(J.startsWith('"')&&J.endsWith('"')||J.startsWith("'")&&J.endsWith("'"))return!0;return!1}function m(J){return J==="number"||J==="string"||J==="boolean"}function g(J){let Y=!1,X=0,Q=J.length;for(let z=0;z<Q;z++){let B=J.charCodeAt(z);if(Y){if(B===92){z++;continue}if(B===X)Y=!1;continue}if(B===34||B===39||B===96){Y=!0,X=B;continue}if(B===61&&z+1<Q&&J.charCodeAt(z+1)===62)return!1;if(B>=97&&B<=122){let Z=z;while(z<Q&&(J.charCodeAt(z)>=97&&J.charCodeAt(z)<=122||J.charCodeAt(z)>=65&&J.charCodeAt(z)<=90||J.charCodeAt(z)>=48&&J.charCodeAt(z)<=57||J.charCodeAt(z)===95||J.charCodeAt(z)===36))z++;let $=J.slice(Z,z);if($==="new"||$==="async"||$==="await"||$==="function"||$==="yield"||$==="console"||$==="process")return!1;let H=z;while(H<Q&&J.charCodeAt(H)<=32)H++;if(H<Q&&J.charCodeAt(H)===40)return!1;z--}}return!0}function s(J,Y,X=0){let Q=J.slice(1,-1).trim();if(!Q)return"{}";if(X>=20)return"Record<string, unknown>";let z=a(Q),B=[],Z=E&&!Y,$=[];for(let[H,L]of z){let O=M;M=null;let G,W=L.trim();if(e(W))G=zz(H,W);else if(G=V(L,Y,!1,X+1),G.includes("=>")||G.includes("function")||G.includes("async"))G=i(G);let K=M;M=O;let F=L.trim(),q=r(H);if(q){let N=t(q.kind,q.name,G);if(N){B.push(N);continue}}if(!Y&&m(G)&&x(F))B.push(`/** @defaultValue ${F} */
|
|
6
|
-
${H}: ${G}`);else B.push(`${H}: ${G}`);if(Z){let N=h(H);if(F.endsWith("as const"));else if(x(F))$.push(`${N}: ${F}`);else if(F.startsWith("[")&&g(F))$.push(`${N}: ${_(F)}`);else if(F.startsWith("{")){if(K)$.push(`${N}: ${K}`)}else if(!F.startsWith("[")&&(F.includes("=>")||F.startsWith("function")||F.startsWith("async"))){let U=y(F,!1,0,!0);$.push(`${N}: ${U}`)}}}if(Z&&$.length>0){let H=X>0?(X-1)/2:0,L=`{ ${$.join(", ")} }`;if(L.length<=80)M=L;else{let O=" ".repeat((H+1)*2),G=" ".repeat(H*2);M=`{
|
|
7
|
-
${O}${$.join(`,
|
|
8
|
-
${O}`)}
|
|
9
|
-
${G}}`}}return`{
|
|
10
|
-
${B.join(`;
|
|
11
|
-
`)}
|
|
12
|
-
}`}function i(J){let X=J.split(`
|
|
13
|
-
`).map((O)=>C(O)).join(`
|
|
14
|
-
`),Q=X.indexOf("async");if(Q!==-1){let O=Q>0?X.charCodeAt(Q-1):32,G=Q+5<X.length?X.charCodeAt(Q+5):32;if(!P(O)&&!P(G))X=(X.slice(0,Q)+X.slice(Q+5)).trim()}let z=X.indexOf("(");if(z!==-1){let O=j(X,z,"(",")");if(O!==-1){let G=X.slice(z,O+1),W=k(G);X=X.slice(0,z)+W+X.slice(O+1)}}let B=X.length,Z="",$=[],H=!1,L=!1;for(let O=0;O<B;O++){let G=X.charCodeAt(O);if(G===123||G===40)$.push(G);else if(G===125||G===41)$.pop();if(G<=32){if(H=!0,G===10||G===13)L=!0;continue}if(H&&Z.length>0){let K=($.length>0?$[$.length-1]:0)===123;if(L&&K){let F=Z.charCodeAt(Z.length-1),q=F===59||F===44||F===123||G===125,N=Z.length>=2&&Z.charCodeAt(Z.length-1)===47&&Z.charCodeAt(Z.length-2)===42;if(!q&&!N)Z+="; ";else Z+=" "}else Z+=" "}H=!1,L=!1,Z+=X[O]}return Z.trim()}function P(J){return J>=97&&J<=122||J>=65&&J<=90||J>=48&&J<=57||J===95||J===36}function k(J){let Y=J.trim(),X,Q=!1;if(Y.startsWith("(")&&Y.endsWith(")"))X=Y.slice(1,-1),Q=!0;else X=Y;let z=X.trim();if(!z)return Q?"()":"";let B=!1;{let F=0;for(let q=0;q<z.length;q++){let N=z.charCodeAt(q);if(N===40||N===60||N===91||N===123)F++;else if(N===41||N===62||N===93||N===125)F--;else if(F===0&&N===61){let U=q>0?z.charCodeAt(q-1):0,R=q+1<z.length?z.charCodeAt(q+1):0;if(U!==61&&U!==33&&U!==60&&U!==62&&R!==61&&R!==62){B=!0;break}}}}if(!B)return Y;let Z=[],$=[],H=0,L=0,O=!1,G=0;for(let F=0;F<=z.length;F++){if(F===z.length){Z.push(z.slice(H));break}let q=z.charCodeAt(F);if(O){if(q===92){F++;continue}if(q===G)O=!1;continue}if(q===47&&F+1<z.length){let N=z.charCodeAt(F+1);if(N===42){F+=2;while(F+1<z.length&&!(z.charCodeAt(F)===42&&z.charCodeAt(F+1)===47))F++;F++;continue}if(N===47){while(F<z.length&&z.charCodeAt(F)!==10)F++;continue}}if(q===39||q===34||q===96){O=!0,G=q;continue}if(q===40||q===60||q===91||q===123)L++;else if(q===41||q===62||q===93||q===125)L--;else if(q===44&&L===0){Z.push(z.slice(H,F));let N=",",U=F+1;while(U<z.length&&z.charCodeAt(U)<=32)N+=z[U],U++;$.push(N),H=U}}let W=[];for(let F of Z){let q=F.trim();if(!q){W.push(F);continue}if(q.startsWith("//"))continue;let N=C(q),U=F.slice(0,F.length-F.trimStart().length);W.push(U+n(N))}let K=W[0]||"";for(let F=1;F<W.length;F++)K+=($[F-1]||", ")+W[F];return Q?`(${K})`:K}function C(J){let Y=!1,X=0;for(let Q=0;Q<J.length-1;Q++){let z=J.charCodeAt(Q);if(Y){if(z===92){Q++;continue}if(z===X)Y=!1;continue}if(z===39||z===34||z===96){Y=!0,X=z;continue}if(z===47&&J.charCodeAt(Q+1)===47)return J.slice(0,Q).trimEnd()}return J}function n(J){if(J.startsWith("..."))return J;let Y=-1,X=-1,Q=0,z=!1,B=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(z){if(H===92){$++;continue}if(H===B)z=!1;continue}if(H===47&&$+1<J.length){let L=J.charCodeAt($+1);if(L===42){$+=2;while($+1<J.length&&!(J.charCodeAt($)===42&&J.charCodeAt($+1)===47))$++;$++;continue}if(L===47){while($<J.length&&J.charCodeAt($)!==10)$++;continue}}if(H===39||H===34||H===96){z=!0,B=H;continue}if(H===40||H===60||H===91||H===123)Q++;else if(H===41||H===62||H===93||H===125)Q--;else if(Q===0){if(H===58&&Y===-1)Y=$;else if(H===61&&X===-1&&($===0||J.charCodeAt($-1)!==61)&&($+1>=J.length||J.charCodeAt($+1)!==61&&J.charCodeAt($+1)!==62))X=$}}let Z=X!==-1;if(Y!==-1&&(X===-1||Y<X)){let $=J.slice(0,Y).trim(),H=X!==-1?J.slice(Y+1,X).trim():J.slice(Y+1).trim(),L=Z&&!$.endsWith("?")?"?":"";return`${$}${L}: ${H}`}else if(X!==-1){let $=J.slice(0,X).trim(),H=!$.endsWith("?")?"?":"",L=J.slice(X+1).trim(),O="unknown";if(L==="true"||L==="false")O="boolean";else if(/^-?\d+(\.\d+)?$/.test(L))O="number";else if(L.startsWith("'")&&L.endsWith("'")||L.startsWith('"')&&L.endsWith('"'))O="string";else if(L.startsWith("["))O="unknown[]";else if(L.startsWith("{"))O="Record<string, unknown>";return`${$}${H}: ${O}`}return J}function a(J){let Y=[],X="",Q="",z=0,B=!1,Z="",$=!0,H=!1,L=0;for(let O=0;O<J.length;O++){let G=J.charCodeAt(O),W=O>0?J.charCodeAt(O-1):0,K=O<J.length-1?J.charCodeAt(O+1):0;if(!B&&!H&&G===47&&K===47){O+=2;while(O<J.length&&J.charCodeAt(O)!==10)O++;continue}if(!B&&!H&&G===47&&K===42){H=!0,L=1,X+="/*",O++;continue}else if(H&&G===42&&K===47){if(L--,X+="*/",O++,L===0)H=!1;continue}else if(H&&G===47&&K===42){L++,X+="/*",O++;continue}let F=J[O];if(!B&&(G===34||G===39||G===96))B=!0,Z=F,X+=F;else if(B&&F===Z&&W!==92)B=!1,X+=F;else if(!B&&!H)if(G===40&&z===0&&$){Q=X.trim();let q="";if(Q.startsWith("async "))Q=Q.slice(6).trim(),q="async ";if(Q.startsWith("*"))Q=Q.slice(1).trim(),q+="*";X=q+F,$=!1,z=1}else if(G===123||G===91||G===40)z++,X+=F;else if(G===125||G===93||G===41)z--,X+=F;else if(G===58&&z===0&&$)Q=X.trim(),X="",$=!1;else if(G===44&&z===0){if(Q&&X.trim()){let q=X.trim();Y.push([Q,q])}X="",Q="",$=!0}else X+=F;else X+=F}if(Q&&X.trim()){let O=X.trim();Y.push([Q,O])}return Y}function r(J){let Y=J.trim();if(Y.startsWith("get ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"get",name:X}}if(Y.startsWith("set ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"set",name:X}}return null}function t(J,Y,X){let Q=X.trim();if(Q.charCodeAt(0)!==40)return null;let z=j(Q,0,"(",")");if(z===-1)return null;let B=Q.slice(1,z).trim(),Z=Q.slice(z+1).trimStart();if(!Z.startsWith("=>"))return null;let $=Z.slice(2).trim();if(J==="get")return`get ${Y}(): ${$||"unknown"}`;return`set ${Y}(${B})`}function e(J){let Y=J;if(Y.startsWith("async ")||Y.startsWith("async\t"))Y=Y.slice(5).trimStart();if(Y.startsWith("*"))Y=Y.slice(1).trimStart();if(!Y.startsWith("("))return!1;let X=0;for(let Q=0;Q<Y.length;Q++){let z=Y.charCodeAt(Q);if(z===40)X++;else if(z===41){if(X--,X===0){let B=Y.slice(Q+1).trimStart();if(B.startsWith("{"))return!0;if(B.startsWith(":")){let Z=0;for(let $=0;$<B.length;$++){let H=B.charCodeAt($);if(H===40||H===91)Z++;else if(H===41||H===93)Z--;else if(H===60)Z++;else if(H===62){if(Z>0)Z--}else if(Z===0&&H===61&&$+1<B.length&&B.charCodeAt($+1)===62)return!1;else if(Z===0&&H===123)return!0}}return!1}}}return!1}function zz(J,Y){let X=Y.trimStart(),Q=!1,z=!1;if(X.startsWith("async ")||X.startsWith("async\t"))Q=!0,X=X.slice(5).trimStart();if(X.startsWith("*"))z=!0,X=X.slice(1).trimStart();let B="";if(X.charCodeAt(0)===60){let W=0,K=-1;for(let F=0;F<X.length;F++)if(X.charCodeAt(F)===60)W++;else if(X.charCodeAt(F)===62){if(W--,W===0){K=F;break}}if(K!==-1)B=X.slice(0,K+1),X=X.slice(K+1).trimStart()}let Z=X.indexOf("("),$=j(X,Z,"(",")");if(Z===-1||$===-1)return"() => unknown";let H=X.slice(Z,$+1),L="unknown",O=X.slice($+1).trimStart();if(O.charCodeAt(0)===58){let W=O.slice(1),K=0,F=-1,q=!1;for(let N=0;N<W.length;N++){let U=W.charCodeAt(N);if(U===40||U===91)K++;else if(U===41||U===93)K--;else if(U===123&&K===0){F=N;break}else if(U===61&&N+1<W.length&&W.charCodeAt(N+1)===62&&K===0){F=N,q=!0;break}}if(F!==-1)L=W.slice(0,F).trim();else L=W.trim()}if(L==="unknown"){if(Q&&z)L="AsyncGenerator<unknown, void, unknown>";else if(z)L="Generator<unknown, void, unknown>";else if(Q)L="Promise<void>"}else if(Q&&!L.startsWith("Promise<")&&!L.startsWith("AsyncGenerator<"))L=`Promise<${L}>`;let G=k(H);return`${B}${G} => ${L}`}function j(J,Y,X,Q){let z=0;for(let B=Y;B<J.length;B++)if(J[B]===X)z++;else if(J[B]===Q){if(z--,z===0)return B}return-1}function Jz(J){let Y=0,X=0,Q=!1,z="";for(let B=0;B<J.length-1;B++){let Z=J[B],$=J[B+1],H=B>0?J[B-1]:"";if(!Q&&(Z==='"'||Z==="'"||Z==="`"))Q=!0,z=Z;else if(Q&&Z===z&&H!=="\\")Q=!1;if(!Q){if(Z==="(")Y++;else if(Z===")")Y--;else if(Z==="[")X++;else if(Z==="]")X--;if(Z==="="&&$===">"&&Y===0&&X===0)return B}}return-1}function y(J,Y=!1,X=0,Q=!0){let z=J.trim();if(z.length>200&&D(z,"=>")>2&&D(z,"<")>5&&!z.startsWith("function"))return Y?"((...args: any[]) => any)":"(...args: any[]) => any";if(z.startsWith("async ")&&z.includes("=>")){let Z=z.slice(5).trim(),$=Z.indexOf("=>"),H=Z.substring(0,$).trim(),L=Z.substring($+2).trim();if(H=k(H),H==="()"||H==="")H="()";else if(!H.startsWith("("))H=`(${H})`;let O="unknown";if(L.startsWith("{"))O="unknown";else O=V(L,Q,!1,X+1);let G=`${H} => Promise<${O}>`;return Y?`(${G})`:G}if(z.includes("=>")){let Z="",$=z;if(z.startsWith("<")){let q=j(z,0,"<",">");if(q!==-1)Z=z.substring(0,q+1),$=z.substring(q+1).trim()}let H=Jz($);if(H===-1)return Y?"(() => unknown)":"() => unknown";let L=$.substring(0,H).trim(),O=$.substring(H+2).trim(),G="",W=L.lastIndexOf("):");if(W!==-1){let q=L.substring(W+2).trim();if(q&&!q.includes("=>")&&!q.includes("="))G=q,L=L.substring(0,W+1)}if(L=k(L),L==="()"||L==="")L="()";else if(!L.startsWith("("))L=`(${L})`;let K="unknown";if(G)K=G;else if(O.startsWith("{"))K="unknown";else if(O.includes("=>")){let q=O.trimStart(),N=q.indexOf("("),U=N!==-1?j(q,N,"(",")"):-1,R=U!==-1?q.indexOf("=>",U):-1;if(N===0&&U!==-1&&R!==-1){let b=q.substring(N+1,U).trim(),A=k(b);if(Z.includes("T")&&A.includes("T"))K=`(${A}) => T`;else K=`(${A}) => any`}else K="any"}else if(Y)K="unknown";else K=V(O,Q,!1,X+1);let F=`${Z}${L} => ${K}`;return Y?`(${F})`:F}if(z.startsWith("function")){let Z=8,$=z.length;while(Z<$&&z.charCodeAt(Z)<=32)Z++;let H=!1;if(Z<$&&z.charCodeAt(Z)===42){H=!0,Z++;while(Z<$&&z.charCodeAt(Z)<=32)Z++}let L="";if(Z<$&&z.charCodeAt(Z)===60){let W=Z,K=1;Z++;while(Z<$&&K>0){let F=z.charCodeAt(Z);if(F===60)K++;else if(F===62)K--;Z++}L=z.substring(W,Z);while(Z<$&&z.charCodeAt(Z)<=32)Z++}let O=z.indexOf("(",Z);if(O!==-1){let W=1,K=O+1;while(K<$&&W>0){let U=z.charCodeAt(K);if(U===40)W++;else if(U===41)W--;K++}let F=z.substring(O+1,K-1).trim(),q=F?`(${F})`:"()";if(H){let U=z.substring(K).trim(),R=U.indexOf("Generator<");if(R!==-1){let A=R+10,T=U.indexOf(">",A);if(T!==-1){let u=U.substring(A,T),v=`${L}${q} => Generator<${u}>`;return Y?`(${v})`:v}}let b=`${L}${q} => Generator<any, any, any>`;return Y?`(${b})`:b}let N=`${L}${q} => unknown`;return Y?`(${N})`:N}let G="(...args: any[]) => unknown";return Y?`(${G})`:G}if(z.includes("=>")&&z.includes("(")&&z.includes(")")){if(z.length>100||D(z,"=>")>2){let Z="";if(z.charCodeAt(0)===60){let G=j(z,0,"<",">");if(G!==-1)Z=z.substring(0,G+1)}let $=z.indexOf("("),H=$!==-1?j(z,$,"(",")"):-1,L=$!==-1&&H!==-1?z.substring($,H+1):"(...args: any[])";L=k(L);let O=`${Z}${L} => any`;return Y?`(${O})`:O}return Y?`(${z})`:z}let B="() => unknown";return Y?`(${B})`:B}function Hz(J){let Y=J.trim();if(Y==="any"||Y==="object"||Y==="unknown")return!0;if(Y.startsWith("Record<")&&Y.endsWith(">"))return!0;if(Y.startsWith("Array<")&&Y.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(Y))return!0;return!1}function Fz(J){let Y=J.lastIndexOf(" satisfies ");if(Y===-1)return null;let X=J.slice(Y+11).trim();if(X.endsWith(";"))X=X.slice(0,-1).trim();return X||null}var Xz=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Yz=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Zz=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function Lz(J){let Y=[],X=0;for(let Q=0;Q<=J.length;Q++)if(Q===J.length||J[Q]===`
|
|
15
|
-
`){let z=X,B=Q;while(z<B&&(J[z]===" "||J[z]==="\t"||J[z]==="\r"))z++;while(B>z&&(J[B-1]===" "||J[B-1]==="\t"||J[B-1]==="\r"))B--;let Z=J.slice(z,B);if(X=Q+1,Z.startsWith("///")){if(Z.indexOf("<")===-1)continue;if(Xz.test(Z)||Yz.test(Z)||Zz.test(Z))Y.push(Z)}else if(Z===""||Z.startsWith("//"))continue;else break}return Y}
|
|
16
|
-
export{$z as Dc,Qz as Ec,V as Fc,l as Gc,I as Hc,w as Ic,s as Jc,j as Kc,y as Lc,Hz as Mc,Fz as Nc,Lz as Oc};
|
package/dist/chunk-7g7axw9t.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{tb as c,ub as d,vb as e}from"./chunk-7zsd1qqw.js";import"./chunk-69rnp3hs.js";import"./chunk-2n1bbm2c.js";import{ic as a,jc as b}from"./chunk-kwmhsx3n.js";import"./chunk-jjwwkrfk.js";import"./chunk-1z1w3s0k.js";import"./chunk-7pwy4m0c.js";import"./chunk-4jw8qvts.js";import"./chunk-a3txc27m.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{e as watch,a as processSource,d as processFile,c as generate,b as clearResultCache};
|
package/dist/chunk-9qe2wx58.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{l as a,m as b,n as c,o as d,p as e,q as f,r as g}from"./chunk-dv8haj2p.js";import"./chunk-7zsd1qqw.js";import"./chunk-69rnp3hs.js";import"./chunk-2n1bbm2c.js";import"./chunk-kwmhsx3n.js";import"./chunk-jjwwkrfk.js";import"./chunk-1z1w3s0k.js";import"./chunk-7pwy4m0c.js";import"./chunk-4jw8qvts.js";import"./chunk-a3txc27m.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{b as sortProjectsByDependencies,f as resolveWorkspacePatterns,c as generateWorkspace,d as generateMonorepo,g as generateFromPackageWorkspaces,a as discoverWorkspaceProjects,e as discoverWorkspaceFromPackageJson};
|
package/dist/chunk-a3txc27m.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Wc as UX}from"./chunk-gssantc8.js";import{dd as d}from"./chunk-mcdb3q06.js";import{existsSync as IY}from"fs";import{resolve as jY}from"path";import WX from"process";import{pathToFileURL as wY}from"url";import{existsSync as OQ,statSync as TQ}from"fs";import{join as jX,relative as wX,resolve as NQ}from"path";import r from"process";import{Buffer as V}from"buffer";import{createCipheriv as KX,createDecipheriv as LX,randomBytes as JQ}from"crypto";import{closeSync as HQ,createReadStream as CQ,createWriteStream as MX,existsSync as l,fsyncSync as kQ,openSync as xQ,writeFileSync as FX}from"fs";import{access as DX,constants as PQ,mkdir as VX,readdir as n,rename as bQ,stat as C,unlink as i,writeFile as UQ}from"fs/promises";import{isAbsolute as SX,join as k,resolve as EX}from"path";import B from"process";import{pipeline as OX}from"stream/promises";import{createGzip as yQ}from"zlib";import x from"process";import S from"process";import s from"process";import{existsSync as o}from"fs";import{resolve as GQ}from"path";import{existsSync as eX}from"fs";import{existsSync as LQ,mkdirSync as QY,readdirSync as XY,readFileSync as YY,writeFileSync as ZY}from"fs";import{homedir as P}from"os";import{dirname as pQ,resolve as K}from"path";import N from"process";import{existsSync as GY,readdirSync as zY}from"fs";import{extname as zQ,resolve as uQ}from"path";import _Y from"process";var AX=Object.defineProperty,qX=(Q)=>Q;function GX(Q,X){this[Q]=qX.bind(null,X)}var zX=(Q,X)=>{for(var Y in X)AX(Q,Y,{get:X[Y],enumerable:!0,configurable:!0,set:GX.bind(X,Y)})},O=(Q,X)=>()=>(Q&&(X=Q(Q=0)),X),_X=import.meta.require;class MQ{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),J=Z??this.options.ttl,H=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:J,hits:0,size:H}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!OQ(Q))return!0;return TQ(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=OQ(Y)?TQ(Y):null,J=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:J},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class FQ{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let J=await X(),H=performance.now()-Z;return this.recordMetric({operation:Q,duration:H,timestamp:$,...Y}),J}catch(J){let H=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:H,timestamp:$,...Y}),J}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,J)=>$+J,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}function BX(Q,X={}){let Z=Object.keys(X).sort().map(($)=>`${$}:${X[$]}`).join("|");return Z?`${Q}:${Z}`:Q}function RX(Q,X){try{return JSON.stringify(Q)===JSON.stringify(X)}catch{return Q===X}}function IX(Q){return Q.getStats().size*2}var b,p,cQ,g=O(()=>{b=new MQ,p=new FQ,cQ={createKey:BX,isEquivalent:RX,estimateMemoryUsage:IX}});function TX(Q,X={}){let Y=r.cwd();while(Y.includes("storage"))Y=NQ(Y,"..");let Z=NQ(Y,Q||"");if(X?.relative)return wX(r.cwd(),Z);return Z}function j(){if(S.env.NODE_ENV==="test"||S.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function NX(){if(S.env.NODE_ENV==="test"||S.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof S<"u"){let Q=S.type;if(Q==="renderer"||Q==="worker")return!1;return!!(S.versions&&(S.versions.node||S.versions.bun))}return!1}class lQ{async format(Q){let X=await NX(),Y=await this.getMetadata(X);return JSON.stringify({timestamp:Q.timestamp.toISOString(),level:Q.level,name:Q.name,message:Q.message,metadata:Y})}async getMetadata(Q){if(Q){let{hostname:X}=await import("os");return{pid:x.pid,hostname:X(),environment:x.env.NODE_ENV||"development",platform:x.platform,version:x.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:x.env.NODE_ENV||x.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class QQ{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(Q,X={}){this.name=Q,this.config={...h},this.options=this.normalizeOptions(X),this.formatter=this.options.formatter||new lQ,this.enabled=X.enabled??!0,this.fancy=X.fancy??!0,this.tagFormat=X.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=X.timestampPosition??"right",this.environment=X.environment??B.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(X);let Y={...X},Z=X.timestamp!==void 0;if(Z)delete Y.timestamp;if(this.config={...this.config,...Y,timestamp:Z||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let $=this.generateKeyId(),J=this.generateKey();this.currentKeyId=$,this.keys.set($,J),this.encryptionKeys.set($,{key:J,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(Q){if(!this.fingersCrossedConfig)return!1;let X={debug:0,info:1,success:2,warning:3,error:4},Y=this.fingersCrossedConfig.activationLevel??"error";return X[Q]>=X[Y]}initializeFingersCrossedConfig(Q){if(!Q.fingersCrossedEnabled&&Q.fingersCrossed)return{...t,...Q.fingersCrossed};if(!Q.fingersCrossedEnabled)return null;if(!Q.fingersCrossed)return{...t};return{...t,...Q.fingersCrossed}}normalizeOptions(Q){let X={format:"json",level:"info",logDirectory:h.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Y={...X,...Object.fromEntries(Object.entries(Q).filter(([,Z])=>Z!==void 0))};if(!Y.level||!["debug","info","success","warning","error"].includes(Y.level))Y.level=X.level;return Y}shouldWriteToFile(){return!j()&&this.config.writeToFile===!0}async writeToFile(Q){let Y=(async()=>{let $,J=0,H=3,W=1000;while(J<H)try{try{try{await DX(this.config.logDirectory,PQ.F_OK|PQ.W_OK)}catch(A){if(A instanceof Error&&"code"in A)if(A.code==="ENOENT")await VX(this.config.logDirectory,{recursive:!0,mode:493});else if(A.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw A;else throw A}}catch(A){throw console.error("Debug: [writeToFile] Failed to create log directory:",A),A}let U=this.validateEncryptionConfig()?(await this.encrypt(Q)).encrypted:V.from(Q);try{if(!l(this.currentLogFile))await UQ(this.currentLogFile,"",{mode:420});if($=xQ(this.currentLogFile,"a",420),FX($,U,{flag:"a"}),kQ($),$!==void 0)HQ($),$=void 0;if((await C(this.currentLogFile)).size===0){if(await UQ(this.currentLogFile,U,{flag:"w",mode:420}),(await C(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(A){let q=A;if(q.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(q.code)){if(J<H-1){let G=typeof q.message==="string"?q.message:"Unknown error";console.error(`Network error during write attempt ${J+1}/${H}:`,G);let z=W*2**J;await new Promise((_)=>setTimeout(_,z)),J++;continue}}if(q?.code&&["ENOSPC","EDQUOT"].includes(q.code))throw Error(`Disk quota exceeded or no space left on device: ${q.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",q),q}finally{if($!==void 0)try{HQ($)}catch(A){console.error("Debug: [writeToFile] Error closing file descriptor:",A)}}}catch(U){if(J===H-1){let q=U,G=typeof q.message==="string"?q.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",G),U}J++;let A=W*2**(J-1);await new Promise((q)=>setTimeout(q,A))}})();this.pendingOperations.push(Y);let Z=this.pendingOperations.length-1;try{await Y}catch($){throw console.error("Debug: [writeToFile] Error in operation:",$),$}finally{this.pendingOperations.splice(Z,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return k(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return k(this.config.logDirectory,`${this.name}.log`);let Q=new Date().toISOString().split("T")[0];return k(this.config.logDirectory,`${this.name}-${Q}.log`)}setupRotation(){if(j())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let Q=this.config.rotation,X;switch(Q.frequency){case"daily":X=86400000;break;case"weekly":X=604800000;break;case"monthly":X=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},X)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let X=this.config.rotation.keyRotation;if(!X?.enabled)return;let Y=typeof X.interval==="number"?X.interval:60,Z=Math.max(Y,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch(($)=>{console.error("Error rotating keys:",$)})},Z)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let X=this.config.rotation.keyRotation,Y=this.generateKeyId(),Z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,Z),this.encryptionKeys.set(Y,{key:Z,createdAt:new Date});let $=Array.from(this.encryptionKeys.entries()).sort(([,W],[,U])=>U.createdAt.getTime()-W.createdAt.getTime()),J=typeof X.maxKeys==="number"?X.maxKeys:1,H=Math.max(1,J);if($.length>H)for(let[W]of $.slice(H))this.encryptionKeys.delete(W),this.keys.delete(W)}generateKeyId(){return JQ(16).toString("hex")}generateKey(){return JQ(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let Q=this.keys.get(this.currentKeyId);if(!Q)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:Q,id:this.currentKeyId}}encrypt(Q){let{key:X}=this.getCurrentKey(),Y=JQ(16),Z=KX("aes-256-gcm",X,Y),$=V.isBuffer(Q)?Q:V.from(Q,"utf8"),J=Z.update($),H=Z.final(),W=J.length+H.length,U=Z.getAuthTag(),A=V.allocUnsafe(16+W+16);return Y.copy(A,0),J.copy(A,16),H.copy(A,16+J.length),U.copy(A,16+W),{encrypted:A,iv:Y}}async compressData(Q){return new Promise((X,Y)=>{let Z=yQ(),$=[];Z.on("data",(J)=>$.push(J)),Z.on("end",()=>X(V.from(V.concat($)))),Z.on("error",Y),Z.write(Q),Z.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let Q={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let X=this.config.rotation.encrypt;return{...Q,...X}}return Q}async rotateLog(){if(j())return;if(!this.shouldWriteToFile())return;let Q=await C(this.currentLogFile).catch(()=>null);if(!Q)return;let X=this.config.rotation;if(typeof X==="boolean")return;if(X.maxSize&&Q.size>=X.maxSize){let Y=this.currentLogFile,Z=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let $=await n(this.config.logDirectory),J=$.filter((U)=>U.startsWith(this.name)&&/\.log\.\d+$/.test(U)).sort((U,A)=>{let q=Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(A.match(/\.log\.(\d+)$/)?.[1]||"0")-q}),H=J.length>0?Number.parseInt(J[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,W=`${Y}.${H}`;if(await C(Y).catch(()=>null))try{if(await bQ(Y,W),X.compress)try{let U=`${W}.gz`;await this.compressLogFile(W,U),await i(W)}catch(U){console.error("Error compressing rotated file:",U)}if(J.length===0&&!$.some((U)=>U.endsWith(".log.1")))try{let U=`${Y}.1`;await UQ(U,"")}catch(U){console.error("Error creating backup file:",U)}}catch(U){console.error(`Error during rotation: ${U instanceof Error?U.message:String(U)}`)}}else{let $=new Date().toISOString().replace(/[:.]/g,"-"),J=Y.replace(/\.log$/,`-${$}.log`);if(await C(Y).catch(()=>null))await bQ(Y,J)}if(this.currentLogFile=Z,X.maxFiles){let J=(await n(this.config.logDirectory)).filter((H)=>H.startsWith(this.name)).sort((H,W)=>W.localeCompare(H));for(let H of J.slice(X.maxFiles))await i(k(this.config.logDirectory,H))}}}async compressLogFile(Q,X){let Y=CQ(Q),Z=MX(X),$=yQ();await OX(Y,$,Z)}async handleFingersCrossedBuffer(Q,X){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(Q)&&!this.isActivated){this.isActivated=!0;for(let Y of this.logBuffer){let Z=await this.formatter.format(Y);if(this.shouldWriteToFile())await this.writeToFile(Z);console.log(Z)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}}shouldLog(Q){if(!this.enabled)return!1;let X={debug:0,info:1,success:2,warning:3,error:4};return X[Q]>=X[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((Q)=>{if(Q instanceof Promise)return Q.catch((X)=>{console.error("Error in pending write operation:",X)});return Promise.resolve()})),l(this.currentLogFile))try{let Q=xQ(this.currentLogFile,"r+");kQ(Q),HQ(Q)}catch(Q){console.error(`Error flushing file: ${Q}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let Q of this.pendingOperations)if(typeof Q.cancel==="function")Q.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(Q){console.error("Error waiting for pending operations:",Q)}if(!j()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let X=(await n(this.config.logDirectory)).filter((Y)=>(Y.includes("temp")||Y.includes(".tmp"))&&Y.includes(this.name));for(let Y of X)try{await i(k(this.config.logDirectory,Y))}catch(Z){console.error(`Failed to delete temp file ${Y}:`,Z)}}catch(Q){console.error("Error cleaning up temporary files:",Q)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(Q){if(!Q)return"";return`${this.tagFormat.prefix}${Q}${this.tagFormat.suffix}`}formatFileTimestamp(Q){return`[${Q.toISOString()}]`}formatConsoleTimestamp(Q){return this.shouldStyleConsole()?R.gray(Q.toLocaleTimeString()):Q.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||j())return!1;let Q=typeof B.env.NO_COLOR<"u",X=B.env.FORCE_COLOR==="0";if(Q||X)return!1;return!!(typeof B.stderr<"u"&&B.stderr.isTTY||typeof B.stdout<"u"&&B.stdout.isTTY)}formatConsoleMessage(Q){let{timestamp:X,icon:Y="",tag:Z="",message:$,level:J,showTimestamp:H=!0}=Q,W=(_)=>_.replace(this.ANSI_PATTERN,"");if(!this.fancy){let _=[];if(H)_.push(X);if(J==="warning")_.push("WARN");else if(J==="error")_.push("ERROR");else if(Y)_.push(Y.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(Z)_.push(Z.replace(/[[\]]/g,""));return _.push($),_.join(" ")}let U=B.stdout.columns||120,A="";if(J==="warning"||J==="error")A=`${Y} ${$}`;else if(J==="info"||J==="success")A=`${Y} ${Z} ${$}`;else A=`${Y} ${Z} ${R.cyan($)}`;if(!H)return A.trim();let q=W(A).trim().length,G=W(X).length,z=Math.max(1,U-2-q-G);return`${A.trim()}${" ".repeat(z)}${X}`}formatMessage(Q,X){if(X.length===1&&Array.isArray(X[0]))return Q.replace(/\{(\d+)\}/g,(J,H)=>{let W=Number.parseInt(H,10);return W<X[0].length?String(X[0][W]):J});let Y=/%([sdijfo%])/g,Z=0,$=Q.replace(Y,(J,H)=>{if(H==="%")return"%";if(Z>=X.length)return J;let W=X[Z++];switch(H){case"s":return String(W);case"d":case"i":return Number(W).toString();case"j":case"o":return JSON.stringify(W,null,2);default:return J}});if(Z<X.length)$+=` ${X.slice(Z).map((J)=>typeof J==="object"?JSON.stringify(J,null,2):String(J)).join(" ")}`;return $}formatMarkdown(Q){if(!Q)return Q;let X=Q;return X=X.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Y,Z,$)=>{let J=R.underline(R.blue(Z)),H=this.toAbsoluteFilePath($);if(H&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let W=`file://${encodeURI(H)}`,U="\x1B]8;;",A="\x1B\\";return`\x1B]8;;${W}\x1B\\${J}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${$}\x1B\\${J}\x1B]8;;\x1B\\`;return J}),X=X.replace(/`([^`]+)`/g,(Y,Z)=>R.bgGray(Z)),X=X.replace(/\*\*([^*]+)\*\*/g,(Y,Z)=>R.bold(Z)),X=X.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Y,Z)=>R.italic(Z)),X=X.replace(/(?<!_)_([^_]+)_(?!_)/g,(Y,Z)=>R.italic(Z)),X=X.replace(/~([^~]+)~/g,(Y,Z)=>R.strikethrough(Z)),X}supportsHyperlinks(){if(j())return!1;let Q=B.env;if(!Q)return!1;if(Q.TERM_PROGRAM==="iTerm.app"||Q.TERM_PROGRAM==="vscode"||Q.TERM_PROGRAM==="WezTerm")return!0;if(Q.WT_SESSION)return!0;if(Q.TERM==="xterm-kitty")return!0;let X=Q.VTE_VERSION?Number.parseInt(Q.VTE_VERSION,10):0;if(!Number.isNaN(X)&&X>=5000)return!0;return!1}toAbsoluteFilePath(Q){try{let X=Q;if(X.startsWith("file://"))X=X.replace(/^file:\/\//,"");if(X.startsWith("~")){let Y=B.env.HOME||"";if(Y)X=X.replace(/^~(?=$|\/)/,Y)}if(SX(X)||X.startsWith("./")||X.startsWith("../"))X=EX(X);else return null;return l(X)?X:null}catch{return null}}buildOutputTexts(Q){let X=this.shouldStyleConsole()?this.formatMarkdown(Q):Q,Y=Q.replace(this.ANSI_PATTERN,"");return{consoleText:X,fileText:Y}}async log(Q,X,...Y){if(!this.shouldLog(Q))return;let Z=new Date,$=this.formatConsoleTimestamp(Z),J=this.formatFileTimestamp(Z),H,W;if(X instanceof Error)H=X.message,W=X.stack;else H=this.formatMessage(X,Y);let{consoleText:U,fileText:A}=this.buildOutputTexts(H);if(this.shouldStyleConsole()){let G=this.options.showIcons===!1?"":nQ[Q],z=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"",_;switch(Q){case"debug":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:R.gray(U),level:Q}),console.error(_);break;case"info":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:U,level:Q}),console.warn(_);break;case"success":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:R.green(U),level:Q}),console.error(_);break;case"warning":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:U,level:Q}),console.warn(_);break;case"error":if(_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:U,level:Q}),console.error(_),W){let D=W.split(`
|
|
3
|
-
`);for(let I of D)if(I.trim()&&!I.includes(H))console.error(this.formatConsoleMessage({timestamp:$,message:R.gray(` ${I}`),level:Q,showTimestamp:!1}))}break}}else if(!j()){if(console.error(`${J} ${this.environment}.${Q.toUpperCase()}: ${H}`),W)console.error(W)}let q=`${J} ${this.environment}.${Q.toUpperCase()}: ${A}
|
|
4
|
-
`;if(W)q+=`${W}
|
|
5
|
-
`;if(q=q.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(q)}progress(Q,X=""){let Y={update:(W,U)=>{},finish:(W)=>{},interrupt:(W,U)=>{}};if(!this.enabled)return Y;let Z=30;if(this.activeProgressBar={total:Math.max(1,Q||1),current:0,message:X||"",barLength:Z,lastRenderedLine:""},this.shouldStyleConsole()&&!j()&&B.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(W,U)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,W),this.activeProgressBar.total),U!==void 0)this.activeProgressBar.message=U;if(this.shouldStyleConsole()&&!j()&&B.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(W)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,W)},interrupt:(W,U="info")=>{if(!j()&&B.stdout.isTTY)B.stdout.write(`
|
|
6
|
-
`);if(this[U==="warning"?"warn":U](W),this.activeProgressBar&&this.shouldStyleConsole()&&!j()&&B.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(Q){let X=performance.now();if(this.shouldStyleConsole()){let Y=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"",Z=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:Z,icon:this.options.showIcons===!1?"":R.blue("\u25D0"),tag:Y,message:`${R.cyan(Q)}...`}))}return async(Y)=>{if(!this.enabled)return;let Z=performance.now(),$=Math.round(Z-X),J=`${Q} completed in ${$}ms`,H=new Date,W=this.formatConsoleTimestamp(H),A=`${this.formatFileTimestamp(H)} ${this.environment}.INFO: ${J}`;if(Y)A+=` ${JSON.stringify(Y)}`;if(A+=`
|
|
7
|
-
`,A=A.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let q=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:W,icon:this.options.showIcons===!1?"":R.green("\u2713"),tag:q,message:`${J}${Y?` ${JSON.stringify(Y)}`:""}`}))}else if(!j())console.error(A.trim());if(this.shouldWriteToFile())await this.writeToFile(A)}}async debug(Q,...X){await this.log("debug",Q,...X)}async info(Q,...X){await this.log("info",Q,...X)}async success(Q,...X){await this.log("success",Q,...X)}async warn(Q,...X){await this.log("warning",Q,...X)}async error(Q,...X){await this.log("error",Q,...X)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let Q=this.config.rotation,{encrypt:X}=Q;return!!X}async only(Q){if(!this.enabled)return;return await Q()}isEnabled(){return this.enabled}setEnabled(Q){this.enabled=Q}extend(Q){let X=`${this.name}:${Q}`,Y=new QQ(X,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(Y),Y}createReadStream(){if(j())throw Error("createReadStream is not supported in browser environments");if(!l(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return CQ(this.currentLogFile,{encoding:"utf8"})}async decrypt(Q){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let X=this.config.rotation;if(!X.encrypt||typeof X.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Y=this.keys.get(this.currentKeyId);try{let Z=V.isBuffer(Q)?Q:V.from(Q,"base64"),$=Z.subarray(0,16),J=Z.subarray(Z.length-16),H=Z.subarray(16,Z.length-16),W=LX("aes-256-gcm",Y,$);W.setAuthTag(J);let U=W.update(H),A=W.final(),q=U.length+A.length,G=V.allocUnsafe(q);return U.copy(G,0),A.copy(G,U.length),G.toString("utf8")}catch(Z){throw Error(`Decryption failed: ${Z instanceof Error?Z.message:String(Z)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return j()}isServerMode(){return!j()}setTestEncryptionKey(Q,X){this.currentKeyId=Q,this.keys.set(Q,X)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(Q){if(!this.enabled)return;let X=new Date,Y=this.formatConsoleTimestamp(X),Z=this.formatFileTimestamp(X),{consoleText:$,fileText:J}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let W=$.split(`
|
|
8
|
-
`),U=Math.max(...W.map((z)=>z.length))+2,A=`\u250C${"\u2500".repeat(U)}\u2510`,q=`\u2514${"\u2500".repeat(U)}\u2518`,G=W.map((z)=>{return this.formatConsoleMessage({timestamp:Y,message:R.cyan(z),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:Y,message:R.cyan(A),showTimestamp:!1})),G.forEach((z)=>console.error(z)),console.error(this.formatConsoleMessage({timestamp:Y,message:R.cyan(q),showTimestamp:!1}))}else if(!j())console.error(`${Z} ${this.environment}.INFO: [BOX] ${J}`);let H=`${Z} ${this.environment}.INFO: [BOX] ${J}
|
|
9
|
-
`.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(H)}async prompt(Q){if(j())return Promise.resolve(!0);return new Promise((X)=>{console.error(`${R.cyan("?")} ${Q} (y/n) `);let Y=(Z)=>{let $=Z.toString().trim().toLowerCase();B.stdin.removeListener("data",Y);try{if(typeof B.stdin.setRawMode==="function")B.stdin.setRawMode(!1)}catch{}B.stdin.pause(),console.error(""),X($==="y"||$==="yes")};try{if(typeof B.stdin.setRawMode==="function")B.stdin.setRawMode(!0)}catch{}B.stdin.resume(),B.stdin.once("data",Y)})}setFancy(Q){this.fancy=Q}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(Q,...X){if(!this.enabled)return;let Y=Q;if(X&&X.length>0){let U=/%([sdijfo%])/g,A=0;if(Y=Q.replace(U,(q,G)=>{if(G==="%")return"%";if(A>=X.length)return q;let z=X[A++];switch(G){case"s":return String(z);case"d":case"i":return Number(z).toString();case"j":case"o":return JSON.stringify(z,null,2);default:return q}}),A<X.length)Y+=` ${X.slice(A).map((q)=>typeof q==="object"?JSON.stringify(q,null,2):String(q)).join(" ")}`}let{consoleText:Z,fileText:$}=this.buildOutputTexts(Y);if(this.shouldStyleConsole()){let U=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"",A=this.options.showIcons===!1?"":`${R.blue("\u25D0")} `;console.error(`${A}${U} ${R.cyan(Z)}`)}let W=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${$}
|
|
10
|
-
`.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(W)}renderProgressBar(Q,X=!1){if(!this.enabled||!this.shouldStyleConsole()||!B.stdout.isTTY)return;let Y=Math.min(100,Math.max(0,Math.round(Q.current/Q.total*100))),Z=Math.round(Q.barLength*Y/100),$=Q.barLength-Z,J=R.green("\u2501".repeat(Z)),H=R.gray("\u2501".repeat($)),W=`[${J}${H}]`,U=`${Y}%`.padStart(4),A=Q.message?` ${Q.message}`:"",q=this.options.showIcons===!1?"":X||Y===100?R.green("\u2713"):R.blue("\u25B6"),G=this.options.showTags!==!1&&this.name?` ${R.gray(this.formatTag(this.name))}`:"",z=`\r${q}${G} ${W} ${U}${A}`,_=B.stdout.columns||80,D=" ".repeat(Math.max(0,_-z.replace(this.ANSI_PATTERN,"").length));if(Q.lastRenderedLine=`${z}${D}`,B.stdout.write(Q.lastRenderedLine),X)B.stdout.write(`
|
|
11
|
-
`)}finishProgressBar(Q,X){if(!this.enabled||!this.fancy||j()||!B.stdout.isTTY){this.activeProgressBar=null;return}if(Q.current<Q.total)Q.current=Q.total;if(X)Q.message=X;this.renderProgressBar(Q,!0),this.activeProgressBar=null}async clear(Q={}){if(j()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let X=await n(this.config.logDirectory),Y=[];for(let Z of X){if(!(Q.name?new RegExp(Q.name.replace("*",".*")).test(Z):Z.startsWith(this.name))||!Z.endsWith(".log"))continue;let J=k(this.config.logDirectory,Z);if(Q.before)try{if((await C(J)).mtime>=Q.before)continue}catch(H){console.error(`Failed to get stats for file ${J}:`,H);continue}Y.push(J)}if(Y.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Y.length} log file(s)...`);for(let Z of Y)try{await i(Z),console.warn(`Deleted log file: ${Z}`)}catch($){console.error(`Failed to delete log file ${Z}:`,$)}console.warn("Log clearing process finished.")}catch(X){console.error("Error during log clearing process:",X)}}}var vQ,WQ,h,CX,w,R,kX,dQ,xX,hQ,PX,bX,AQ,yX,fQ,mQ,vX,qQ,dX,hX,fX,mX,pX,t,nQ,gX,uX=O(()=>{vQ=r.env.CLARITY_LOG_DIR||jX(TX(),"logs"),WQ={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:vQ,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},h={...WQ},CX=(async()=>{try{let{loadConfig:Q}=await Promise.resolve().then(()=>(HX(),JX)),X=await Q({name:"clarity",alias:"logging",defaultConfig:WQ,cwd:r.cwd()});if(X)Object.assign(h,X)}catch{}return h})(),w={red:(Q)=>`\x1B[31m${Q}\x1B[0m`,green:(Q)=>`\x1B[32m${Q}\x1B[0m`,yellow:(Q)=>`\x1B[33m${Q}\x1B[0m`,blue:(Q)=>`\x1B[34m${Q}\x1B[0m`,magenta:(Q)=>`\x1B[35m${Q}\x1B[0m`,cyan:(Q)=>`\x1B[36m${Q}\x1B[0m`,white:(Q)=>`\x1B[37m${Q}\x1B[0m`,gray:(Q)=>`\x1B[90m${Q}\x1B[0m`,bgRed:(Q)=>`\x1B[41m${Q}\x1B[0m`,bgYellow:(Q)=>`\x1B[43m${Q}\x1B[0m`,bgGray:(Q)=>`\x1B[100m${Q}\x1B[0m`,bold:(Q)=>`\x1B[1m${Q}\x1B[0m`,dim:(Q)=>`\x1B[2m${Q}\x1B[0m`,italic:(Q)=>`\x1B[3m${Q}\x1B[0m`,underline:(Q)=>`\x1B[4m${Q}\x1B[0m`,strikethrough:(Q)=>`\x1B[9m${Q}\x1B[0m`,reset:"\x1B[0m"},R=w,kX=w.red,dQ=w.green,xX=w.yellow,hQ=w.blue,PX=w.magenta,bX=w.cyan,AQ=w.white,yX=w.gray,fQ=w.bgRed,mQ=w.bgYellow,vX=w.bgGray,qQ=w.bold,dX=w.dim,hX=w.italic,fX=w.underline,mX=w.strikethrough,pX=w.reset,t={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},nQ={debug:"\uD83D\uDD0D",info:hQ("\u2139"),success:dQ("\u2713"),warning:mQ(AQ(qQ(" WARN "))),error:fQ(AQ(qQ(" ERROR ")))},gX=new QQ("stacks")}),cX="0.15.9",lX=()=>{};async function iQ(Q,X={}){let{maxRetries:Y=3,retryDelay:Z=1000,isRetryable:$=()=>!0,fallback:J}=X,H=Error("Unknown error occurred");for(let W=0;W<=Y;W++)try{return await Q()}catch(U){if(H=U instanceof Error?U:Error(String(U)),W===Y||!$(H))break;if(Z>0)await new Promise((A)=>setTimeout(A,Z))}if(J!==void 0)return J;throw H instanceof Error?H:Error(`Unknown error: ${String(H)}`)}function sQ(Q){return Q instanceof L}function nX(Q){return Q instanceof a}function iX(Q){if(sQ(Q))return Q.code==="FILE_SYSTEM_ERROR"||Q.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((Y)=>Q.message.toLowerCase().includes(Y.toLowerCase()))}var L,a,f,_Q,BQ,e,RQ,IQ,m,jQ,wQ,T,y=O(()=>{L=class extends Error{timestamp;context;constructor(X,Y={}){super(X);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=Y,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let X=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([Y,Z])=>`${Y}: ${Z}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${X}`}},a=class extends L{code="CONFIG_NOT_FOUND";constructor(X,Y,Z){let $=Z===void 0?[]:Array.isArray(Z)?Z.filter(Boolean):[Z],J="";if($.length===1)J=` or alias "${$[0]}"`;else if($.length>1)J=` or aliases ${$.map((H)=>`"${H}"`).join(", ")}`;super(`Configuration "${X}"${J} not found`,{configName:X,alias:Z,searchPaths:Y,searchPathCount:Y.length})}},f=class extends L{code="CONFIG_LOAD_ERROR";constructor(X,Y,Z){super(`Failed to load configuration from "${X}": ${Y.message}`,{configPath:X,configName:Z,originalError:Y.name,originalMessage:Y.message});this.cause=Y}},_Q=class extends L{code="CONFIG_VALIDATION_ERROR";constructor(X,Y,Z){super(`Configuration validation failed for "${X}"`,{configPath:X,configName:Z,validationErrors:Y,errorCount:Y.length})}},BQ=class extends L{code="CONFIG_MERGE_ERROR";constructor(X,Y,Z,$){super(`Failed to merge configuration from "${X}" with "${Y}": ${Z.message}`,{sourcePath:X,targetPath:Y,configName:$,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},e=class extends L{code="ENV_VAR_ERROR";constructor(X,Y,Z,$){super(`Failed to parse environment variable "${X}" with value "${Y}" as ${Z}`,{envKey:X,envValue:Y,expectedType:Z,configName:$})}},RQ=class extends L{code="FILE_SYSTEM_ERROR";constructor(X,Y,Z){super(`File system ${X} failed for "${Y}": ${Z.message}`,{operation:X,path:Y,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},IQ=class extends L{code="TYPE_GENERATION_ERROR";constructor(X,Y,Z){super(`Failed to generate types from "${X}" to "${Y}": ${Z.message}`,{configDir:X,outputPath:Y,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},m=class extends L{code="SCHEMA_VALIDATION_ERROR";constructor(X,Y,Z){super(`Schema validation failed${Z?` for config "${Z}"`:""}`,{schemaPath:X,configName:Z,validationErrors:Y,errorCount:Y.length})}},jQ=class extends L{code="BROWSER_CONFIG_ERROR";constructor(X,Y,Z,$){super(`Failed to fetch configuration from "${X}": ${Y} ${Z}`,{endpoint:X,status:Y,statusText:Z,configName:$})}},wQ=class extends L{code="PLUGIN_ERROR";constructor(X,Y,Z){super(`Plugin "${X}" failed during ${Y}: ${Z.message}`,{pluginName:X,operation:Y,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},T={configNotFound(Q,X,Y){return new a(Q,X,Y)},configLoad(Q,X,Y){return new f(Q,X,Y)},configValidation(Q,X,Y){return new _Q(Q,X,Y)},configMerge(Q,X,Y,Z){return new BQ(Q,X,Y,Z)},envVar(Q,X,Y,Z){return new e(Q,X,Y,Z)},fileSystem(Q,X,Y){return new RQ(Q,X,Y)},typeGeneration(Q,X,Y){return new IQ(Q,X,Y)},schemaValidation(Q,X,Y){return new m(Q,X,Y)},browserConfig(Q,X,Y,Z){return new jQ(Q,X,Y,Z)},plugin(Q,X,Y){return new wQ(Q,X,Y)}}});class XQ{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(Q,X)=>X==="boolean"||["true","false","1","0","yes","no"].includes(Q.toLowerCase()),parse:(Q)=>{let X=Q.toLowerCase();return["true","1","yes"].includes(X)}},{name:"number",canParse:(Q,X)=>X==="number"||!Number.isNaN(Number(Q))&&!Number.isNaN(Number.parseFloat(Q)),parse:(Q)=>{let X=Number(Q);if(Number.isNaN(X))throw TypeError(`Cannot parse "${Q}" as number`);return X}},{name:"array",canParse:(Q,X)=>X==="array"||Q.startsWith("[")||Q.includes(","),parse:(Q)=>{try{let X=JSON.parse(Q);if(Array.isArray(X))return X}catch{}return Q.split(",").map((X)=>X.trim())}},{name:"json",canParse:(Q,X)=>X==="object"||(Q.startsWith("{")&&Q.endsWith("}")||Q.startsWith("[")&&Q.endsWith("]")),parse:(Q)=>{try{return JSON.parse(Q)}catch(X){throw Error(`Cannot parse "${Q}" as JSON: ${X}`)}}}]}async applyEnvironmentVariables(Q,X,Y={}){let{prefix:Z,useCamelCase:$=!0,useBackwardCompatibility:J=!0,customParsers:H={},verbose:W=!1,trackPerformance:U=!0}=Y,A=async()=>{if(!Q)return{config:X,source:{type:"environment",priority:50,timestamp:new Date}};let q=Z||this.generateEnvPrefix(Q),G={...X};return this.processObject(G,[],q,{useCamelCase:$,useBackwardCompatibility:J,customParsers:H,verbose:W,configName:Q}),{config:G,source:{type:"environment",priority:50,timestamp:new Date}}};if(U)return p.track("applyEnvironmentVariables",A,{configName:Q});return A()}generateEnvPrefix(Q){return Q.toUpperCase().replace(/-/g,"_")}formatEnvKey(Q,X){if(!X)return Q.toUpperCase();return Q.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(Q,X,Y,Z){for(let[$,J]of Object.entries(Q)){let H=[...X,$],W=H.map((q)=>this.formatEnvKey(q,Z.useCamelCase)),U=`${Y}_${W.join("_")}`,A=Z.useBackwardCompatibility?`${Y}_${H.map((q)=>q.toUpperCase()).join("_")}`:null;if(Z.verbose);if(typeof J==="object"&&J!==null&&!Array.isArray(J))this.processObject(J,H,Y,Z);else{let q=s.env[U]||(A?s.env[A]:void 0);if(q!==void 0){if(Z.verbose){let G=s.env[U]?U:A}try{Q[$]=this.parseEnvironmentValue(q,typeof J,U,Z.customParsers,Z.configName)}catch(G){if(G instanceof e)throw G;throw T.envVar(U,q,typeof J,Z.configName)}}}}}parseEnvironmentValue(Q,X,Y,Z,$){for(let[J,H]of Object.entries(Z))try{return H(Q)}catch{continue}for(let J of this.defaultParsers)if(J.canParse(Q,X))try{return J.parse(Q)}catch{throw T.envVar(Y,Q,`${X} (via ${J.name} parser)`,$)}return Q}getEnvironmentVariables(Q){let X={},Y=Q.toUpperCase();for(let[Z,$]of Object.entries(s.env))if(Z.startsWith(Y)&&$!==void 0)X[Z]=$;return X}validateEnvironmentVariable(Q,X,Y){let Z=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(Q))Z.push(`Environment variable key "${Q}" should only contain uppercase letters, numbers, and underscores`);if(Y)try{this.parseEnvironmentValue(Q,X,Y,{})}catch($){Z.push(`Cannot parse value "${X}" as ${Y}: ${$}`)}return{isValid:Z.length===0,errors:Z}}generateEnvVarDocs(Q,X,Y={}){let{prefix:Z,format:$="text"}=Y,J=Z||this.generateEnvPrefix(Q),H=[];switch(this.extractEnvVarInfo(X,[],J,H),$){case"markdown":return this.formatAsMarkdown(H,Q);case"json":return JSON.stringify(H,null,2);default:return this.formatAsText(H,Q)}}extractEnvVarInfo(Q,X,Y,Z){for(let[$,J]of Object.entries(Q)){let H=[...X,$],W=`${Y}_${H.map((U)=>this.formatEnvKey(U,!0)).join("_")}`;if(typeof J==="object"&&J!==null&&!Array.isArray(J))this.extractEnvVarInfo(J,H,Y,Z);else Z.push({key:W,type:Array.isArray(J)?"array":typeof J,description:`Configuration for ${H.join(".")}`,example:this.generateExample(J)})}}generateExample(Q){if(Array.isArray(Q))return JSON.stringify(Q);if(typeof Q==="object"&&Q!==null)return JSON.stringify(Q);return String(Q)}formatAsText(Q,X){let Y=`Environment Variables for ${X}:
|
|
12
|
-
|
|
13
|
-
`;for(let Z of Q)Y+=`${Z.key}
|
|
14
|
-
`,Y+=` Type: ${Z.type}
|
|
15
|
-
`,Y+=` Description: ${Z.description}
|
|
16
|
-
`,Y+=` Example: ${Z.example}
|
|
17
|
-
|
|
18
|
-
`;return Y}formatAsMarkdown(Q,X){let Y=`# Environment Variables for ${X}
|
|
19
|
-
|
|
20
|
-
`;Y+=`| Variable | Type | Description | Example |
|
|
21
|
-
`,Y+=`|----------|------|-------------|----------|
|
|
22
|
-
`;for(let Z of Q)Y+=`| \`${Z.key}\` | ${Z.type} | ${Z.description} | \`${Z.example}\` |
|
|
23
|
-
`;return Y}}var oQ=O(()=>{g(),y()});function sX(Q,X){let Y=_X("process");if(typeof Y>"u"||!Y.env)return X;let Z=Y.env[Q];return Z!==void 0?Z:X}function tQ(Q,X,Y={}){return rQ(Q,X,Y,new WeakMap)}function rQ(Q,X,Y,Z){let{arrayMergeMode:$="replace",skipNullish:J=!1,customMerger:H}=Y;if(X===null||X===void 0)return J?Q:X;if(H){let W=H(Q,X);if(W!==void 0)return W}if(Array.isArray(X)||Array.isArray(Q))return aQ(Q,X,$,Z);if(!F(X)||!F(Q))return X;return aX(Q,X,Y,Z)}function aQ(Q,X,Y,Z){if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(Q)&&!Array.isArray(X))return X;if(Array.isArray(X)&&Array.isArray(Q))switch(Y){case"replace":return X;case"concat":return oX(Q,X);case"smart":return tX(Q,X,Z);default:return X}return X}function oX(Q,X){let Y=[...X];for(let Z of Q)if(!Y.some(($)=>KQ($,Z)))Y.push(Z);return Y}function tX(Q,X,Y){if(X.length===0)return Q;if(Q.length===0)return X;if(F(X[0])&&F(Q[0]))return rX(Q,X,Y);if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}function rX(Q,X,Y){let Z=[...X];for(let $ of Q){if(!F($)){Z.push($);continue}let J=["id","name","key","path","type"],H=!1;for(let W of J)if(W in $){if(Z.find((A)=>F(A)&&(W in A)&&A[W]===$[W])){H=!0;break}}if(!H)Z.push($)}return Z}function aX(Q,X,Y,Z){let $=X;if(F($)&&Z.has($))return Z.get($);let J={...Q};if(F($))Z.set($,J);for(let H in $){if(!Object.prototype.hasOwnProperty.call($,H))continue;let W=$[H],U=J[H];if(Y.skipNullish&&(W===null||W===void 0))continue;if(W===null||W===void 0){J[H]=W;continue}if(F(W)&&F(U))J[H]=rQ(U,W,Y,Z);else if(Array.isArray(W)||Array.isArray(U))J[H]=aQ(U,W,Y.arrayMergeMode||"smart",Z);else J[H]=W}return J}function DQ(Q,X,Y="replace"){return tQ(Q,X,{arrayMergeMode:Y==="replace"?"replace":"smart",skipNullish:!0})}function KQ(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!KQ(Q[Y],X[Y]))return!1;return!0}if(F(Q)&&F(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!KQ(Q[$],X[$]))return!1}return!0}return!1}function F(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}var eQ,VQ=O(()=>{eQ={replace:"replace",concat:"concat",smart:"smart"}});class YQ{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(Q,X,Y={}){let{arrayStrategy:Z="replace",useCache:$=!0,cacheTtl:J,trackPerformance:H=!0,verbose:W=!1}=Y;if($){let A=b.getWithFileCheck("file",Q);if(A){if(W)console.log(`Configuration loaded from cache: ${Q}`);return A}}let U=async()=>{if(!o(Q))return null;try{let A=`?t=${Date.now()}`,q=await import(Q+A),G=q.default||q,z="default"in q,_=Object.keys(q).length>0;if(!z&&!_)throw new f(Q,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof G!=="object"||G===null||Array.isArray(G))throw new f(Q,Error("Configuration must export a valid object"),"unknown");let $Q={config:DQ(X,G,Z),source:{type:"file",path:Q,priority:100,timestamp:new Date}};if($)b.setWithFileCheck("file",$Q,Q,J);return $Q}catch(A){throw A instanceof Error?T.configLoad(Q,A):T.configLoad(Q,Error(String(A)))}};if(H)return p.track("loadFromPath",U,{path:Q});return U()}async tryLoadFromPaths(Q,X,Y={}){for(let Z of Q)try{let $=await this.loadFromPath(Z,X,Y);if($)return $}catch($){if($ instanceof Error&&$.name==="ConfigLoadError")throw $;if(Y.verbose)console.warn(`Failed to load config from ${Z}:`,$)}return null}generateConfigPaths(Q,X,Y){let Z=this.generateNamePatterns(Q,Y),$=[];for(let J of Z)for(let H of this.extensions)$.push(GQ(X,`${J}${H}`));return $}generateNamePatterns(Q,X){let Y=[];if(Y.push("config",".config"),Q)Y.push(Q,`.${Q}.config`,`${Q}.config`,`.${Q}`);let Z=X===void 0?[]:Array.isArray(X)?X:[X];for(let J of Z){if(!J)continue;if(Y.push(J,`.${J}.config`,`${J}.config`,`.${J}`),Q)Y.push(`${Q}.${J}.config`,`.${Q}.${J}.config`)}let $=new Set;return Y.filter((J)=>{if(!J||$.has(J))return!1;return $.add(J),!0})}checkFileAccess(Q){return iQ(async()=>{return o(Q)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(Q,X,Y){let Z=[];if(!o(Q))return Z;if(X||Y){let $=this.generateNamePatterns(X||"",Y);for(let J of $)for(let H of this.extensions){let W=GQ(Q,`${J}${H}`);if(await this.checkFileAccess(W))Z.push(W)}}else try{let{readdirSync:$}=await import("fs"),J=$(Q);for(let H of J)if(this.looksLikeConfigFile(H)){let W=GQ(Q,H);if(await this.checkFileAccess(W))Z.push(W)}}catch{return[]}return Z}looksLikeConfigFile(Q){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((Y)=>Y.test(Q))}async validateConfigFile(Q){let X=[];try{if(!o(Q))return X.push("Configuration file does not exist"),X;let Y=await import(Q),Z=Y.default||Y;if(Z===void 0)X.push("Configuration file must export a default value or named exports");else if(typeof Z!=="object"||Z===null)X.push("Configuration must be an object");else if(Array.isArray(Z))X.push("Configuration cannot be an array at the root level");if(Q.endsWith(".json"))try{let{readFileSync:$}=await import("fs"),J=$(Q,"utf8");JSON.parse(J)}catch($){X.push(`Invalid JSON syntax: ${$}`)}}catch(Y){X.push(`Failed to load configuration file: ${Y}`)}return X}async getFileModificationTime(Q){try{let{statSync:X}=await import("fs");return X(Q).mtime}catch{return null}}async preloadConfigurations(Q,X={}){let Y=new Map;return await Promise.allSettled(Q.map(async(Z)=>{try{let $=await this.loadFromPath(Z,{},X);if($)Y.set(Z,$.config)}catch($){if(X.verbose)console.warn(`Failed to preload ${Z}:`,$)}})),Y}}var QX=O(()=>{g(),y(),VQ()});class SQ{async validateConfiguration(Q,X,Y={}){let{stopOnFirstError:Z=!1,validateRequired:$=!0,validateTypes:J=!0,customRules:H=[],trackPerformance:W=!0,verbose:U=!1}=Y,A=async()=>{let q=[],G=[],z={stopOnFirstError:Z,validateRequired:$,validateTypes:J,customRules:H,trackPerformance:W,verbose:U};try{if(typeof X==="string")return await this.validateWithSchemaFile(Q,X,z);else if(Array.isArray(X))return this.validateWithRules(Q,[...X,...H],z);else return this.validateWithJSONSchema(Q,X,z)}catch(_){return q.push({path:"",message:`Validation failed: ${_}`,rule:"system"}),{isValid:!1,errors:q,warnings:G}}};if(W)return await p.track("validateConfiguration",A);return A()}async validateWithSchemaFile(Q,X,Y){try{if(!eX(X))throw new m(X,[{path:"",message:"Schema file does not exist"}]);let Z=await import(X),$=Z.default||Z;if(Array.isArray($))return this.validateWithRules(Q,$,Y);else return this.validateWithJSONSchema(Q,$,Y)}catch(Z){throw new m(X,[{path:"",message:`Failed to load schema: ${Z}`}])}}validateWithJSONSchema(Q,X,Y){let Z=[],$=[];return this.validateObjectAgainstSchema(Q,X,"",Z,$,Y),{isValid:Z.length===0,errors:Z,warnings:$}}validateObjectAgainstSchema(Q,X,Y,Z,$,J){if(J.validateTypes&&X.type){let H=Array.isArray(Q)?"array":typeof Q,W=Array.isArray(X.type)?X.type:[X.type];if(!W.includes(H)){if(Z.push({path:Y,message:`Expected type ${W.join(" or ")}, got ${H}`,expected:W.join(" or "),actual:H,rule:"type"}),J.stopOnFirstError)return}}if(X.enum&&!X.enum.includes(Q)){if(Z.push({path:Y,message:`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"}),J.stopOnFirstError)return}if(typeof Q==="string"){if(X.minLength!==void 0&&Q.length<X.minLength)Z.push({path:Y,message:`String length must be at least ${X.minLength}`,expected:`>= ${X.minLength}`,actual:Q.length,rule:"minLength"});if(X.maxLength!==void 0&&Q.length>X.maxLength)Z.push({path:Y,message:`String length must not exceed ${X.maxLength}`,expected:`<= ${X.maxLength}`,actual:Q.length,rule:"maxLength"});if(X.pattern){if(!new RegExp(X.pattern).test(Q))Z.push({path:Y,message:`String does not match pattern ${X.pattern}`,expected:X.pattern,actual:Q,rule:"pattern"})}}if(typeof Q==="number"){if(X.minimum!==void 0&&Q<X.minimum)Z.push({path:Y,message:`Value must be at least ${X.minimum}`,expected:`>= ${X.minimum}`,actual:Q,rule:"minimum"});if(X.maximum!==void 0&&Q>X.maximum)Z.push({path:Y,message:`Value must not exceed ${X.maximum}`,expected:`<= ${X.maximum}`,actual:Q,rule:"maximum"})}if(Array.isArray(Q)&&X.items)for(let H=0;H<Q.length;H++){let W=Y?`${Y}[${H}]`:`[${H}]`;if(this.validateObjectAgainstSchema(Q[H],X.items,W,Z,$,J),J.stopOnFirstError&&Z.length>0)return}if(Q&&typeof Q==="object"&&!Array.isArray(Q)){let H=Q;if(J.validateRequired&&X.required){for(let W of X.required)if(!(W in H)){if(Z.push({path:Y?`${Y}.${W}`:W,message:`Missing required property '${W}'`,expected:"required",rule:"required"}),J.stopOnFirstError)return}}if(X.properties){for(let[W,U]of Object.entries(X.properties))if(W in H){let A=Y?`${Y}.${W}`:W;if(this.validateObjectAgainstSchema(H[W],U,A,Z,$,J),J.stopOnFirstError&&Z.length>0)return}}if(X.additionalProperties===!1){let W=new Set(Object.keys(X.properties||{}));for(let U of Object.keys(H))if(!W.has(U))$.push({path:Y?`${Y}.${U}`:U,message:`Additional property '${U}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(Q,X,Y){let Z=[],$=[];for(let J of X)try{let H=this.getValueByPath(Q,J.path),W=this.validateWithRule(H,J,J.path);if(Z.push(...W),Y.stopOnFirstError&&Z.length>0)break}catch(H){Z.push({path:J.path,message:`Rule validation failed: ${H}`,rule:"system"})}return{isValid:Z.length===0,errors:Z,warnings:$}}validateWithRule(Q,X,Y){let Z=[];if(X.required&&(Q===void 0||Q===null))return Z.push({path:Y,message:X.message||`Property '${Y}' is required`,expected:"required",rule:"required"}),Z;if(Q===void 0||Q===null)return Z;if(X.type){let $=Array.isArray(Q)?"array":typeof Q;if($!==X.type)Z.push({path:Y,message:X.message||`Expected type ${X.type}, got ${$}`,expected:X.type,actual:$,rule:"type"})}if(X.min!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($<X.min)Z.push({path:Y,message:X.message||`Value must be at least ${X.min}`,expected:`>= ${X.min}`,actual:$,rule:"min"})}if(X.max!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($>X.max)Z.push({path:Y,message:X.message||`Value must not exceed ${X.max}`,expected:`<= ${X.max}`,actual:$,rule:"max"})}if(X.pattern&&typeof Q==="string"){if(!X.pattern.test(Q))Z.push({path:Y,message:X.message||`Value does not match pattern ${X.pattern}`,expected:X.pattern.toString(),actual:Q,rule:"pattern"})}if(X.enum&&!X.enum.includes(Q))Z.push({path:Y,message:X.message||`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"});if(X.validator){let $=X.validator(Q);if($)Z.push({path:Y,message:X.message||$,rule:"custom"})}return Z}getValueByPath(Q,X){if(!X)return Q;let Y=X.split("."),Z=Q;for(let $ of Y)if(Z&&typeof Z==="object"&&$ in Z)Z=Z[$];else return;return Z}generateRulesFromInterface(Q){let X=[],Y=Q.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let Z of Y){let[,$,J,H]=Z;X.push({path:$,required:!J,type:this.mapTypeScriptType(H)})}return X}mapTypeScriptType(Q){switch(Q.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:XX},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}var XX,YX=O(()=>{g(),y(),XX=/^https?:\/\//});function $Y(Q){if(!Q)return"";let X=Array.isArray(Q)?Q.filter(Boolean):[Q];if(X.length===0)return"";if(X.length===1)return` or alias "${X[0]}"`;return` or aliases ${X.map((Y)=>`"${Y}"`).join(", ")}`}class EQ{fileLoader=new YQ;envProcessor=new XQ;validator=new SQ;async loadConfig(Q){let X=Date.now(),{cache:Y,performance:Z,schema:$,validate:J,...H}=Q;try{if(Y?.enabled){let U=this.checkCache(H.name||"",H);if(U)return U}let W;try{W=await this.loadConfigurationStrategies(H,!0,Y)}catch(U){let A=H.__strictErrorHandling;if(U instanceof Error&&U.name==="ConfigNotFoundError"){if(A)throw U;W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:[`No configuration file found for "${H.name||"config"}", using defaults with environment variables`]}}else if(U instanceof Error&&U.name==="ConfigLoadError"){let q=U.message.includes("EACCES")||U.message.includes("EPERM")||U.message.includes("permission denied"),G=!q&&(U.message.includes("syntax")||U.message.includes("Expected")||U.message.includes("Unexpected")||U.message.includes("BuildMessage")||U.message.includes("errors building")),z=U.message.includes("Configuration must export a valid object")||U.message.includes("Configuration file is empty and exports nothing");if(A&&(z||q))throw U;if(G&&(!A||!z))W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!A)W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:[`Configuration loading error, using defaults: ${U.message}`]};else throw U}else W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${U instanceof Error?U.message:String(U)}`]}}if($||J)await this.validateConfiguration(W.config,$,J,H.name);if(Y?.enabled&&W)this.cacheResult(H.name||"",W,Y,H);if(Z?.enabled){let U={operation:"loadConfig",duration:Date.now()-X,configName:H.name,timestamp:new Date};if(Z.onMetrics)Z.onMetrics(U);if(Z.slowThreshold&&U.duration>Z.slowThreshold)M.warn(`Slow configuration loading detected: ${U.duration}ms for ${H.name}`);W.metrics=U}return W}catch(W){let U=Date.now()-X;throw M.error(`Configuration loading failed after ${U}ms:`,[W instanceof Error?W:Error(String(W))]),W}}async loadConfigurationStrategies(Q,X=!1,Y){let{name:Z="",alias:$,cwd:J,configDir:H,defaultConfig:W,checkEnv:U=!0,arrayStrategy:A="replace",verbose:q=!1}=Q,G=J||N.cwd(),z=[],_=await this.loadLocalConfiguration(Z,$,G,H,W,A,q,U,Y);if(_)return z.push(...this.getLocalSearchPaths(Z,$,G,H)),this.finalizeResult(_,z,U,Z,q);let D=await this.loadHomeConfiguration(Z,$,W,A,q,U);if(D)return z.push(...this.getHomeSearchPaths(Z,$)),this.finalizeResult(D,z,U,Z,q);let I=await this.loadPackageJsonConfiguration(Z,$,G,W,A,q,U);if(I)return z.push(K(G,"package.json")),this.finalizeResult(I,z,U,Z,q);if(z.push(...this.getAllSearchPaths(Z,$,G,H)),X)throw T.configNotFound(Z,z,$);return{...await this.applyEnvironmentVariables(Z,W,U,q),warnings:[`No configuration file found for "${Z}"${$Y($)}, using defaults with environment variables`]}}async loadLocalConfiguration(Q,X,Y,Z,$,J,H,W,U){let A=W?v(Q,$,H):$,q=this.getLocalDirectories(Y,Z);for(let G of q){if(H)M.info(`Searching for configuration in: ${G}`);let z=this.fileLoader.generateConfigPaths(Q,G,X),_=await this.fileLoader.tryLoadFromPaths(z,A,{arrayStrategy:J,verbose:H,cacheTtl:U?.ttl,useCache:!U?.ttl||U.ttl>100});if(_){if(H)M.success(`Configuration loaded from: ${_.source.path}`);return _}}return null}async loadHomeConfiguration(Q,X,Y,Z,$,J){if(!Q)return null;let H=J?v(Q,Y,$):Y,W=[K(P(),".config",Q),K(P(),".config"),P()];for(let U of W){if($)M.info(`Checking home directory: ${U}`);let A=this.fileLoader.generateConfigPaths(Q,U,X),q=await this.fileLoader.tryLoadFromPaths(A,H,{arrayStrategy:Z,verbose:$});if(q){if($)M.success(`Configuration loaded from home directory: ${q.source.path}`);return q}}return null}async loadPackageJsonConfiguration(Q,X,Y,Z,$,J,H){let W=H?v(Q,Z,J):Z;try{let U=K(Y,"package.json");if(!LQ(U))return null;let A={};try{A=JSON.parse(YY(U,"utf8"))}catch(z){if(J)M.warn("Failed to parse package.json:",[z instanceof Error?z:Error(String(z))]);return null}let q=A[Q],G=Q;if(!q&&X){let z=Array.isArray(X)?X:[X];for(let _ of z){if(!_)continue;if(A[_]){q=A[_],G=_;break}}}if(q&&typeof q==="object"&&!Array.isArray(q)){if(J)M.success(`Configuration loaded from package.json: ${G}`);return{config:DQ(W,q,$),source:{type:"package.json",path:U,priority:30,timestamp:new Date}}}}catch(U){if(J)M.warn("Failed to load package.json:",[U instanceof Error?U:Error(String(U))])}return null}async applyEnvironmentVariables(Q,X,Y,Z){if(!Y||!Q||typeof X!=="object"||X===null||Array.isArray(X))return{config:X,source:{type:"default",priority:10,timestamp:new Date}};return{config:v(Q,X,Z),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(Q,X,Y,Z,$){return{config:Q.config,source:Q.source,path:Q.source.path}}async validateConfiguration(Q,X,Y,Z){let $=[];if(Y){let J=Y(Q);if(J)$.push(...J)}if(X){let J=await this.validator.validateConfiguration(Q,X);if(!J.isValid)$.push(...J.errors.map((H)=>H.path?`${H.path}: ${H.message}`:H.message))}if($.length>0)throw T.configValidation(Z||"unknown",$,Z)}checkCache(Q,X){let Y=this.generateCacheKey(Q,X);return b.get(Y)||null}cacheResult(Q,X,Y,Z){let $=this.generateCacheKey(Q,Z);b.set($,X,void 0,Y.ttl)}generateCacheKey(Q,X){let Y=[Q];if(X.alias){let Z=Array.isArray(X.alias)?X.alias.join(","):X.alias;Y.push(`alias:${Z}`)}if(X.cwd)Y.push(`cwd:${X.cwd}`);if(X.configDir)Y.push(`configDir:${X.configDir}`);if("checkEnv"in X)Y.push(`checkEnv:${X.checkEnv}`);return Y.join("|")}getLocalDirectories(Q,X){return Array.from(new Set([Q,K(Q,"config"),K(Q,".config"),X?K(Q,X):void 0].filter(Boolean)))}getAllSearchPaths(Q,X,Y,Z){let $=[];return $.push(...this.getLocalSearchPaths(Q,X,Y,Z)),$.push(...this.getHomeSearchPaths(Q,X)),$.push(K(Y,"package.json")),$}getLocalSearchPaths(Q,X,Y,Z){let $=this.getLocalDirectories(Y,Z),J=[];for(let H of $)J.push(...this.fileLoader.generateConfigPaths(Q,H,X));return J}getHomeSearchPaths(Q,X){if(!Q)return[];let Y=[K(P(),".config",Q),K(P(),".config"),P()],Z=[];for(let $ of Y)Z.push(...this.fileLoader.generateConfigPaths(Q,$,X));return Z}async loadConfigWithResult(Q){return this.loadConfig(Q)}}function gQ(Q){let Y=!(Q.message.includes("EACCES")||Q.message.includes("EPERM")||Q.message.includes("permission denied"))&&(Q.message.includes("syntax")||Q.message.includes("Expected")||Q.message.includes("Unexpected")||Q.message.includes("BuildMessage")),Z=Q.message.includes("Configuration must export a valid object")||Q.message.includes("Configuration file is empty and exports nothing");return Y||Z}async function JY(Q){return E.loadConfig({...Q,__strictErrorHandling:!0})}async function ZQ(Q){let X="defaultConfig"in Q&&Q.defaultConfig!==void 0?Q.defaultConfig:{},Y="cache"in Q||"performance"in Q||"schema"in Q||"validate"in Q;try{let Z;if(Y)Z=await E.loadConfig(Q);else Z=await E.loadConfig({...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}});return Z?.config??X}catch(Z){let $=Z instanceof Error?Z.name:"UnknownError",J=Z instanceof Error?Z.message:String(Z);if(!($==="ConfigNotFoundError"||$==="ConfigLoadError"||$==="ConfigValidationError"||J.includes("config"))&&Q.verbose)M.warn("Unexpected error loading config, using defaults:",[Z instanceof Error?Z:Error(String(Z))]);let W=Y?{...Q,defaultConfig:X}:{...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in Q?Q.checkEnv!==!1:!0)return(await E.applyEnvironmentVariables(W.name||"",X,!0,W.verbose||!1))?.config??X;return X}}async function HY(Q={defaultConfig:{}}){if(typeof Q==="string"){let{cwd:X}=await import("process");try{return(await E.loadConfig({name:Q,cwd:X(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(Y){if(Y instanceof Error&&(Y.name==="ConfigNotFoundError"||Y.name==="ConfigLoadError"&&gQ(Y)))return(await E.applyEnvironmentVariables(Q,{},!0,!1)).config;throw Y}}try{return(await E.loadConfig({...Q,cwd:Q.cwd||N.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(X){if(X instanceof Error&&(X.name==="ConfigNotFoundError"||X.name==="ConfigLoadError"&&gQ(X)))return(await E.applyEnvironmentVariables(Q.name||"",Q.defaultConfig||{},Q.checkEnv!==!1,Q.verbose||!1)).config;throw X}}async function UY(Q,X,Y="replace"){let Z=new YQ;try{let $=await Z.loadFromPath(Q,X,{arrayStrategy:Y,useCache:!1,trackPerformance:!1});return $?$.config:null}catch{return null}}function v(Q,X,Y=!1){let Z=new XQ,$=Q.toUpperCase().replace(/[^A-Z0-9]/g,"_");function J(H,W=[]){let U={...H};for(let[A,q]of Object.entries(H)){let G=[...W,A],z=[`${$}_${G.join("_").toUpperCase()}`,`${$}_${G.map((I)=>I.toUpperCase()).join("")}`,`${$}_${G.map((I)=>I.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],_,D;for(let I of z)if(_=N.env[I],_!==void 0){D=I;break}if(_!==void 0&&D)if(typeof q==="boolean")U[A]=["true","1","yes"].includes(_.toLowerCase());else if(typeof q==="number"){let I=Number(_);if(!Number.isNaN(I))U[A]=I}else if(Array.isArray(q))try{U[A]=JSON.parse(_)}catch{U[A]=_.split(",").map((I)=>I.trim())}else U[A]=_;else if(q&&typeof q==="object"&&!Array.isArray(q))U[A]=J(q,G)}return U}return J(X)}function WY(Q){let X=K(N.cwd(),Q.configDir),Y=K(N.cwd(),Q.generatedDir),Z=K(Y,"config-types.ts");if(!LQ(pQ(Z)))QY(pQ(Z),{recursive:!0,mode:511});let $=LQ(X)?XY(X).map((H)=>H.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],J=`// Generated by bunfig v${cX}
|
|
24
|
-
export type ConfigNames = ${$.length?`'${$.join("' | '")}'`:"string"}
|
|
25
|
-
`;ZY(Z,J,{mode:438})}function AY(Q){let X=null,Y=null,Z=()=>{if(!Y)Y=ZQ(Q).then((J)=>{return X=J,J},(J)=>{let H="defaultConfig"in Q?Q.defaultConfig:{};if(X=H,"verbose"in Q&&Q.verbose)M.warn("Config loading failed, using defaults:",[J instanceof Error?J:Error(String(J))]);return H});return Y},$="defaultConfig"in Q?Q.defaultConfig:{};return X=$,Z(),new Proxy({},{get(J,H){if(X)return X[H];let W=$[H];return Z(),W},has(J,H){return H in(X||$)},ownKeys(){return Object.keys(X||$)},getOwnPropertyDescriptor(J,H){return Object.getOwnPropertyDescriptor(X||$,H)},set(J,H,W){if(!X)X={...$};return X[H]=W,!0}})}var M,E,ZX,$X,qY=O(()=>{uX(),lX(),g(),y(),oQ(),QX(),YX(),VQ(),M=new QQ("bunfig",{showTags:!0}),E=new EQ,ZX=K(N.cwd(),"config"),$X=K(N.cwd(),"src/generated")});function BY(Q){let X=uQ(_Y.cwd(),Q?.configDir||"./config");function Y(){if(!GY(X))return[];let $=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),J=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],H=zY(X).filter((U)=>$.has(zQ(U))).map((U)=>({base:U.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:U})),W=new Map;for(let{base:U,file:A}of H){let q=zQ(A).toLowerCase(),G=W.get(U);if(!G){W.set(U,A);continue}let z=zQ(G).toLowerCase();if(J.indexOf(q)<J.indexOf(z))W.set(U,A)}return Array.from(W.entries()).map(([U,A])=>({base:U,file:A})).sort((U,A)=>U.base.localeCompare(A.base))}function Z(){let $=Y(),J=$.map((A)=>A.base),H=J.length?J.map((A)=>`'${A}'`).join(" | "):"string",W=$.length?`{
|
|
26
|
-
${$.map((A)=>{let q=uQ(X,A.file).replace(/\\/g,"/");return` '${A.base}': typeof import('${q}').default`}).join(`,
|
|
27
|
-
`)}
|
|
28
|
-
}`:"Record<string, any>";return`export type ConfigNames = ${H}
|
|
29
|
-
export type ConfigByName = ${W}
|
|
30
|
-
export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
|
|
31
|
-
export type ConfigOf = Config
|
|
32
|
-
`}return{name:"bunfig-plugin",setup($){$.onResolve({filter:/^virtual:bunfig-types$/},(J)=>{return{path:J.path,namespace:"bunfig-virtual"}}),$.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:Z(),loader:"ts"}})}}}var RY=()=>{},JX={};zX(JX,{withErrorRecovery:()=>iQ,tryLoadConfig:()=>UY,loadConfigWithResult:()=>JY,loadConfig:()=>ZQ,isRetryableError:()=>iX,isConfigNotFoundError:()=>nX,isBunfigError:()=>sQ,globalPerformanceMonitor:()=>p,globalCache:()=>b,getEnvOrDefault:()=>sX,generateConfigTypes:()=>WY,defaultGeneratedDir:()=>$X,defaultConfigDir:()=>ZX,deepMergeWithArrayStrategy:()=>DQ,deepMerge:()=>tQ,createLibraryConfig:()=>AY,config:()=>HY,bunfigPlugin:()=>BY,applyEnvVarsToConfig:()=>v,TypeGenerationError:()=>IQ,SchemaValidationError:()=>m,PluginError:()=>wQ,PerformanceMonitor:()=>FQ,FileSystemError:()=>RQ,ErrorFactory:()=>T,EnvVarError:()=>e,EnvProcessor:()=>XQ,ConfigValidator:()=>SQ,ConfigValidationError:()=>_Q,ConfigNotFoundError:()=>a,ConfigMergeError:()=>BQ,ConfigLoader:()=>EQ,ConfigLoadError:()=>f,ConfigFileLoader:()=>YQ,ConfigCache:()=>MQ,CacheUtils:()=>cQ,BunfigError:()=>L,BrowserConfigError:()=>jQ,ArrayMergeStrategies:()=>eQ});var HX=O(()=>{qY(),y(),g(),y(),RY(),oQ(),QX(),YX(),VQ()});HX();var c={cwd:WX.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",verbose:!1,importOrder:["bun"],declarationMap:!1},KY=["dtsx.config.ts","dtsx.config.js","dtsx.config.mjs","dtsx.config.mts","dts.config.ts","dts.config.js"];async function LY(Q=WX.cwd()){for(let X of KY){let Y=jY(Q,X);if(IY(Y))try{let $=await import(wY(Y).href),J=$.default||$.config||$,H=typeof J==="function"?await J():J;return{...c,...H,cwd:Q}}catch(Z){let $=Z instanceof Error?Z.message:String(Z);UX.warn(`Failed to load config from ${X}: ${$}`)}}return null}var u=null;async function aY(Q){if(!u){let X=await LY(Q);if(X)u=X;else u=await ZQ({name:"dts",defaultConfig:c})}return u}function eY(){u=null}function QZ(Q){return{...c,...Q}}function XZ(Q){return async()=>{let X=await Q();return{...c,...X}}}var YZ=c;
|
|
33
|
-
export{c as Pc,aY as Qc,eY as Rc,QZ as Sc,XZ as Tc,YZ as Uc};
|
package/dist/chunk-q0k7xs9f.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{a,b,c}from"./chunk-fg4cjy7w.js";import"./chunk-69rnp3hs.js";import"./chunk-2n1bbm2c.js";import"./chunk-jjwwkrfk.js";import"./chunk-1z1w3s0k.js";import"./chunk-4jw8qvts.js";import"./chunk-mcdb3q06.js";export{b as optimizeFile,a as optimizeDeclarations,c as minifyDts};
|
package/dist/chunk-sbmecr6t.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import"./chunk-mcdb3q06.js";var e="@stacksjs/dtsx",i="module",n="0.9.19",r=!0,o="A modern, fast .d.ts generation tool, powered by Bun.",u="Chris Breuer <chris@stacksjs.org>",c="MIT",p="https://github.com/stacksjs/dtsx#readme",d={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},a={url:"https://github.com/stacksjs/dtsx/issues"},b=["dts","generation","isolated declarations","development","bun","stacks","typescript","javascript"],m={".":{import:"./dist/index.js"},"./*":{import:"./dist/*"}},l="./dist/index.js",g="./dist/index.d.ts",x={dtsx:"./dist/cli.js"},k=["dist"],h={benchmark:"bun benchmark/index.ts",build:"bun --filter './packages/dtsx' build",test:"bun test",lint:"bunx --bun pickier .","lint:fix":"bunx --bun pickier . --fix",format:"bunx --bun pickier . --format","format:fix":"bunx --bun pickier . --format --write",changelog:"bunx logsmith --verbose","changelog:generate":"bunx logsmith --output CHANGELOG.md",release:"bun --bun run changelog:generate && bunx --bun bumpx prompt --recursive",typecheck:"bunx tsc --noEmit","dev:docs":"bun --bun vitepress dev docs","build:docs":"bun --bun vitepress build docs","preview:docs":"bun --bun vitepress preview docs"},v={"@stacksjs/bumpx":"^0.2.4","@stacksjs/bunpress":"^0.1.4","@stacksjs/clapp":"^0.2.0",pickier:"^0.1.20","@stacksjs/gitlint":"^0.1.5","@stacksjs/logsmith":"^0.2.1","@types/bun":"^1.3.11","@typescript/native-preview":"^7.0.0-dev.20260311.1","buddy-bot":"^0.9.18","bun-git-hooks":"^0.3.1","bun-plugin-dtsx":"workspace:*",mitata:"^1.0.34","oxc-transform":"^0.121.0",typescript:"^5.9.3"},j=["packages/*"],y={name:e,type:i,version:n,private:r,description:o,author:u,license:c,homepage:p,repository:d,bugs:a,keywords:b,exports:m,module:l,types:g,bin:x,files:k,scripts:h,devDependencies:v,workspaces:j,"git-hooks":{"pre-commit":{"staged-lint":{"*.{js,ts,json,yaml,yml,md}":"bunx --bun pickier lint --fix"}},"commit-msg":"bunx gitlint --edit .git/COMMIT_EDITMSG"}};export{j as workspaces,n as version,g as types,i as type,h as scripts,d as repository,r as private,e as name,l as module,c as license,b as keywords,p as homepage,k as files,m as exports,v as devDependencies,o as description,y as default,a as bugs,x as bin,u as author};
|