@stacksjs/dtsx 0.9.13 → 0.9.15
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/README.md +4 -8
- package/dist/bin/cli.js +6 -6
- package/dist/branded-types.d.ts +10 -18
- package/dist/chunk-14gh6ezz.js +80 -0
- package/dist/chunk-285mqzvx.js +16 -0
- package/dist/chunk-2n1bbm2c.js +448 -0
- package/dist/chunk-2r21f44d.js +25 -0
- package/dist/chunk-3xqchdwd.js +2 -0
- package/dist/{chunk-e0gx49tv.js → chunk-3zjt21t1.js} +1 -1
- package/dist/chunk-4s9jv983.js +3 -0
- package/dist/chunk-5hzvjjt0.js +2 -0
- package/dist/chunk-83e9a4fq.js +4 -0
- package/dist/chunk-8cv1t8qg.js +2 -0
- package/dist/{chunk-pdt5pc9f.js → chunk-8g7jyxbr.js} +1 -1
- package/dist/chunk-8z31rkfp.js +3 -0
- package/dist/chunk-a3txc27m.js +33 -0
- package/dist/chunk-bh9ey0vw.js +2 -0
- package/dist/chunk-bsxtpwx6.js +2 -0
- package/dist/{chunk-0f9tt1yd.js → chunk-c09v68yx.js} +1 -1
- package/dist/{chunk-emwe4zbk.js → chunk-f4c389mj.js} +1 -1
- package/dist/{chunk-hbd2nj9p.js → chunk-fef6249b.js} +1 -1
- package/dist/{chunk-57agx6g8.js → chunk-gssantc8.js} +1 -1
- package/dist/chunk-j2yw0d45.js +6 -0
- package/dist/{chunk-ns3hznyf.js → chunk-mcdb3q06.js} +1 -1
- package/dist/{chunk-tzrvp0n2.js → chunk-mn46jafe.js} +1 -1
- package/dist/{chunk-mrk48ejm.js → chunk-mxam9312.js} +8 -8
- package/dist/chunk-nf54b52t.js +6 -0
- package/dist/{chunk-f0mvmcmj.js → chunk-npj0c002.js} +1 -1
- package/dist/chunk-pep9jyxn.js +2 -0
- package/dist/chunk-qrht3d5g.js +2 -0
- package/dist/chunk-rh2bqn7v.js +2 -0
- package/dist/{chunk-ck86m3vf.js → chunk-sw3m29sw.js} +1 -1
- package/dist/{chunk-a592hfkt.js → chunk-tne5n3h1.js} +1 -1
- package/dist/{chunk-1t76q5wk.js → chunk-trm0gptj.js} +1 -1
- package/dist/chunk-vpjw38x7.js +34 -0
- package/dist/chunk-w71syh0b.js +2 -0
- package/dist/chunk-w8d9jjsa.js +2 -0
- package/dist/{chunk-188ep5ns.js → chunk-xhs0tsnn.js} +1 -1
- package/dist/{chunk-e38jw5aa.js → chunk-xmje6xfw.js} +1 -1
- package/dist/{chunk-vf7ywnxz.js → chunk-xtee8g1a.js} +1 -1
- package/dist/chunk-y581wnfe.js +19 -0
- package/dist/{chunk-6qv7p9sg.js → chunk-zf17s33e.js} +18 -11
- package/dist/compat.d.ts +5 -2
- package/dist/extractor/cache.d.ts +6 -2
- package/dist/extractor/directives.d.ts +0 -4
- package/dist/generator.d.ts +1 -1
- package/dist/logger.d.ts +4 -0
- package/dist/optimizer.d.ts +4 -0
- package/dist/process-source.d.ts +1 -0
- package/dist/processor/cache.d.ts +4 -2
- package/dist/processor/imports.d.ts +1 -0
- package/dist/src/index.js +52 -51
- 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/dist/transformers.d.ts +4 -1
- package/dist/type-mappings.d.ts +16 -16
- package/dist/types.d.ts +2 -0
- package/package.json +3 -3
- package/dist/chunk-2vw7w2j4.js +0 -23
- package/dist/chunk-365avtde.js +0 -32
- package/dist/chunk-446n992h.js +0 -2
- package/dist/chunk-49b3ran6.js +0 -4
- package/dist/chunk-50hbgzrj.js +0 -3
- package/dist/chunk-6jpqpjkc.js +0 -3
- package/dist/chunk-94h87sgb.js +0 -449
- package/dist/chunk-at36dtgx.js +0 -2
- package/dist/chunk-b0bkjk0p.js +0 -19
- package/dist/chunk-chbk4344.js +0 -2
- package/dist/chunk-ez568rby.js +0 -2
- package/dist/chunk-hwm87z68.js +0 -2
- package/dist/chunk-jfk0hw36.js +0 -75
- package/dist/chunk-myvmq7hz.js +0 -2
- package/dist/chunk-nd0xbpbz.js +0 -2
- package/dist/chunk-nfeqwqca.js +0 -6
- package/dist/chunk-nr1gxnen.js +0 -2
- package/dist/chunk-pdvve1gm.js +0 -33
- package/dist/chunk-sv136qag.js +0 -17
- package/dist/chunk-te9r0j9z.js +0 -6
- package/dist/chunk-trftkghj.js +0 -2
- package/dist/chunk-xqymptjk.js +0 -2
- package/dist/extractor/extract.d.ts +0 -10
- package/dist/extractor/scanner.d.ts +0 -6
package/dist/src/index.js
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as
|
|
3
|
-
`),W
|
|
4
|
-
`);if(
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`),
|
|
8
|
-
`)}function
|
|
9
|
-
`)}function
|
|
10
|
-
`),
|
|
11
|
-
${
|
|
12
|
-
}`;return{...
|
|
13
|
-
`),extends:
|
|
14
|
-
`),
|
|
15
|
-
${
|
|
16
|
-
}`;return{...
|
|
17
|
-
`),
|
|
18
|
-
${
|
|
19
|
-
}`;return{...
|
|
20
|
-
`),
|
|
21
|
-
`)}return
|
|
2
|
+
import{a as i$,b as n$,c as r$}from"../chunk-83e9a4fq.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-f4c389mj.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-j2yw0d45.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-xhs0tsnn.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-14gh6ezz.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-y581wnfe.js";import{hc as g0}from"../chunk-2n1bbm2c.js";import{ic as h$,jc as g$}from"../chunk-4s9jv983.js";import{lc as KZ}from"../chunk-8z31rkfp.js";import"../chunk-2r21f44d.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-vpjw38x7.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-285mqzvx.js";import{Pc as D9,Qc as E9,Rc as L9,Sc as w9,Tc as M9,Uc as I9}from"../chunk-a3txc27m.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
|
+
`),W=$.split(`
|
|
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
|
+
`)}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(`
|
|
6
|
+
`)}function W3(Z){if(Z.identical)return`${Z.filePath}: unchanged`;return`${Z.filePath}: +${Z.stats.additions} -${Z.stats.deletions} lines`}async function Y0(Z,$,J={}){let Q="";try{let X=QZ(Z);if(await X.exists())Q=await X.text();else if(!J.treatMissingAsEmpty)return p("",$,Z,J)}catch{if(!J.treatMissingAsEmpty)return p("",$,Z,J)}return p(Q,$,Z,J)}async function K3(Z,$={}){let J=new Map;for(let[Q,X]of Z){let q=await Y0(Q,X,$);J.set(Q,q)}return J}function W0(Z){let $=0,J=0,Q=0,X=0,q=0;for(let V of Z.values())if(V.identical)J++;else if($++,Q+=V.stats.additions,X+=V.stats.deletions,!V.oldContent)q++;return{totalFiles:Z.size,changedFiles:$,unchangedFiles:J,totalAdditions:Q,totalDeletions:X,newFiles:q}}function K0(Z){console.log(V0(Z))}function H3(Z,$=!1){for(let Q of Z.values()){if(Q.identical&&!$)continue;K0(Q)}let J=W0(Z);if(console.log(""),console.log(`\x1B[1mSummary:\x1B[0m ${J.totalFiles} files, ${J.changedFiles} changed, ${J.unchangedFiles} unchanged`),J.changedFiles>0)console.log(` \x1B[32m+${J.totalAdditions}\x1B[0m \x1B[31m-${J.totalDeletions}\x1B[0m lines`);if(J.newFiles>0)console.log(` ${J.newFiles} new files`)}var XZ=["builtin","external","internal","parent","sibling","index","type","unknown"];function qZ(Z){let $=Z.match(/^(import\s+)(type\s+)?(.+?)\s+from\s+['"]([^'"]+)['"]/);if(!$){let A=Z.match(/^import\s+['"]([^'"]+)['"]/);if(A)return{statement:Z,source:A[1],isTypeOnly:!1,group:d(A[1]),specifiers:[]};return null}let[,,J,Q,X]=$,q=!!J,V,Y,W=[],K=Q.trim(),H=K.match(/^\*\s+as\s+(\w+)$/);if(H)Y=H[1];else if(K.includes("{")){let A=K.match(/^(\w+)\s*,/);if(A)V=A[1];let _=K.match(/\{([^}]+)\}/);if(_){let O=_[1].split(",").map((G)=>G.trim()).filter(Boolean);W.push(...O)}}else if(/^\w+$/.test(K))V=K;else{let A=K.match(/\{([^}]+)\}/);if(A){let _=A[1].split(",").map((O)=>O.trim()).filter(Boolean);W.push(..._)}}return{statement:Z,source:X,isTypeOnly:q,group:d(X,q),specifiers:W,defaultImport:V,namespaceImport:Y}}function d(Z,$=!1){if($)return"type";if(Z.startsWith("node:")||U0(Z))return"builtin";if(Z.startsWith("./"))return"sibling";if(Z.startsWith("../"))return"parent";if(Z==="."||Z==="./index")return"index";if(Z.startsWith("@/")||Z.startsWith("~/")||Z.startsWith("#"))return"internal";if(Z.startsWith("@")||/^[a-z]/.test(Z))return"external";return"unknown"}var H0=new Set(["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"]);function U0(Z){return H0.has(Z)}function VZ(Z,$={}){let{order:J=[],groupByType:Q=!0,groups:X=XZ,alphabetize:q=!0,caseInsensitive:V=!0,typeImportsLast:Y=!1,separateTypeImports:W=!1}=$,K=[];for(let U of Z){let z=qZ(U);if(z)K.push(z);else K.push({statement:U,source:"",isTypeOnly:!1,group:"unknown",specifiers:[]})}let H=J.length>0?J.map((U)=>{if(U.startsWith("^"))try{return{regex:new RegExp(U),prefix:U.slice(1)}}catch{return{prefix:U.slice(1)}}return{prefix:U}}):[],A=(U)=>{for(let z=0;z<H.length;z++){let B=H[z];if(B.regex){if(B.regex.test(U))return z}else if(U.startsWith(B.prefix)||U.includes(`/${B.prefix}`))return z}return H.length},_=new Map,O=(U)=>{let z=_.get(U);if(z!==void 0)return z;let B=X.indexOf(U),j=B>=0?B:X.length;return _.set(U,j),j},G=(U,z)=>{if(H.length>0){let B=A(U.source),j=A(z.source);if(B!==j)return B-j}if(Q){let B=O(U.group),j=O(z.group);if(B!==j)return B-j}if(Y&&U.isTypeOnly!==z.isTypeOnly)return U.isTypeOnly?1:-1;if(q){let B=V?U.source.toLowerCase():U.source,j=V?z.source.toLowerCase():z.source;return B.localeCompare(j)}return 0};if(K.sort(G),Q){let U=[],z=null;for(let B of K){if(z!==null&&B.group!==z){let j=X.indexOf(z),N=X.indexOf(B.group);if(j>=0&&N>=0&&j!==N)U.push("")}U.push(B.statement),z=B.group}return U}return K.map((U)=>U.statement)}function O0(Z,$={}){let J=Z.split(`
|
|
7
|
+
`),Q=[],X=[],q=-1;for(let K=0;K<J.length;K++){let H=J[K].trim();if(H.startsWith("import "))Q.push(J[K]),X.push(K),q=K;else if(Q.length>0&&H==="")continue;else if(Q.length>0&&!H.startsWith("import "))break}if(Q.length===0)return Z;let V=VZ(Q,$),Y=J.slice(0,X[0]),W=J.slice(q+1);while(W.length>0&&W[0].trim()==="")W.shift();return[...Y,...V,"",...W].join(`
|
|
8
|
+
`)}function O3(Z={}){return{sort:($)=>VZ($,Z),sortContent:($)=>O0($,Z),parse:qZ,detectGroup:d}}var G3={default:{groupByType:!0,groups:XZ,alphabetize:!0,caseInsensitive:!0},node:{order:["node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},bun:{order:["bun","node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},typeSeparated:{groupByType:!0,groups:["builtin","external","internal","parent","sibling","index","type"],separateTypeImports:!0,alphabetize:!0},alphabetical:{groupByType:!1,alphabetize:!0,caseInsensitive:!0},none:{groupByType:!1,alphabetize:!1}};import{createHash as G0}from"crypto";import{mkdir as _0,readFile as YZ,stat as c,writeFile as z0}from"fs/promises";import{dirname as A0,join as C}from"path";var h="1.0.0",B0=".dtsx-cache",WZ="manifest.json";class j0{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(Z={}){this.config={enabled:Z.enabled??!0,cacheDir:Z.cacheDir??B0,format:Z.format??"json",maxAge:Z.maxAge??86400000,force:Z.force??!1,validateCache:Z.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await _0(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:h,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let Z=C(this.config.cacheDir,WZ);try{let $=await YZ(Z,"utf-8");if(this.manifest=JSON.parse($),this.manifest.version!==h){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:h,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let Z=C(this.config.cacheDir,WZ);this.manifest.updatedAt=Date.now(),await z0(Z,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(Z,$){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let J=this.manifest.entries[Z];if(!J)return this.stats.misses++,null;if(J.configHash!==$)return this.stats.misses++,null;if(Date.now()-J.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[Z],this.dirty=!0,null;if(this.config.validateCache)try{let X=(await c(Z)).mtimeMs;if(X!==J.mtime){let q=await YZ(Z,"utf-8");if(this.hashContent(q)!==J.hash)return this.stats.misses++,null;J.mtime=X,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[Z],this.dirty=!0,null}if(J.dependencies.length>0){if((await Promise.all(J.dependencies.map(async(X)=>{let q=this.manifest.entries[X];if(!q)return!0;try{return(await c(X)).mtimeMs===q.mtime}catch{return!1}}))).some((X)=>!X))return this.stats.misses++,null}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),J}async set(Z,$,J,Q,X,q){if(!this.config.enabled||!this.manifest)return;let V=Date.now();try{V=(await c(Z)).mtimeMs}catch{}let Y={filePath:Z,hash:this.hashContent($),mtime:V,declarations:J,dtsContent:Q,dependencies:X,cachedAt:Date.now(),configHash:q};if(!(Z in this.manifest.entries))this.stats.totalEntries++;this.manifest.entries[Z]=Y,this.dirty=!0}invalidate(Z){if(!this.manifest)return;delete this.manifest.entries[Z],this.dirty=!0;for(let[$,J]of Object.entries(this.manifest.entries))if(J.dependencies.includes(Z))delete this.manifest.entries[$]}async clear(){this.manifest={version:h,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(Z){return String(KZ(Z))}updateHitRatio(){let Z=this.stats.hits+this.stats.misses;this.stats.hitRatio=Z>0?this.stats.hits/Z:0}static hashConfig(Z){let $={outdir:Z.outdir,clean:Z.clean,tsconfigPath:Z.tsconfigPath};return G0("sha256").update(JSON.stringify($)).digest("hex").slice(0,16)}}function N3(Z,$){let J=[],Q=[],X=[];return{async needsRebuild(q){return await Z.get(q,$)===null},async getCachedDeclarations(q){let V=await Z.get(q,$);if(V)return Q.push(q),V.declarations;return null},async getCachedDts(q){let V=await Z.get(q,$);if(V)return V.dtsContent;return null},async cacheResult(q,V,Y,W,K=[]){await Z.set(q,V,Y,W,K,$),J.push(q)},skip(q){X.push(q)},getResult(){return{rebuilt:J,cached:Q,skipped:X,stats:Z.getStats()}},async save(){await Z.save()}}}async function R3(Z,$=604800000){let J=Z.getStats();if(J.totalEntries>1000)return await Z.clear(),J.totalEntries;return 0}function F3(Z){let $=[];return $.push("Incremental Build Results:"),$.push(` Rebuilt: ${Z.rebuilt.length} files`),$.push(` From cache: ${Z.cached.length} files`),$.push(` Skipped: ${Z.skipped.length} files`),$.push(""),$.push("Cache Statistics:"),$.push(` Total entries: ${Z.stats.totalEntries}`),$.push(` Hit ratio: ${(Z.stats.hitRatio*100).toFixed(1)}%`),$.push(` Time saved: ~${Z.stats.timeSavedMs}ms`),$.join(`
|
|
9
|
+
`)}function D3(Z,$){let J=[],Q=/import\s+(?:type\s+)?(?:.+(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])from\s+)?['"]([^'"]+)['"]/g,X;while((X=Q.exec(Z))!==null){let q=X[1];if(q.startsWith(".")){let V=C(A0($),q);J.push(V),J.push(`${V}.ts`),J.push(`${V}.tsx`),J.push(C(V,"index.ts")),J.push(C(V,"index.tsx"))}}return J}import{createReadStream as N0,createWriteStream as R0,statSync as F0}from"fs";import{createInterface as D0}from"readline";class HZ{config;profiles=[];cleanupTimer=null;constructor(Z={}){this.config={maxMemoryMB:Z.maxMemoryMB??512,chunkSize:Z.chunkSize??65536,aggressiveGC:Z.aggressiveGC??!0,maxDeclarationsInMemory:Z.maxDeclarationsInMemory??1e4,profile:Z.profile??!1,cleanupInterval:Z.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let Z=process.memoryUsage();return{heapUsed:Z.heapUsed,heapTotal:Z.heapTotal,external:Z.external,arrayBuffers:Z.arrayBuffers,rss:Z.rss,heapUsedMB:Math.ceil(Z.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(Z.heapUsed/Z.heapTotal*100))}}async profile(Z,$){if(!this.config.profile)return $();let J=this.getMemoryStats(),Q=Date.now();try{return await $()}finally{let X=this.getMemoryStats(),q=Date.now()-Q;this.profiles.push({timestamp:Date.now(),operation:Z,memoryBefore:J,memoryAfter:X,duration:q})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(Z){let $=N0(Z,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),J=D0({input:$,crlfDelay:1/0});for await(let Q of J)yield Q}async processFileInChunks(Z,$,J=1000){let Q=[],X=[];for await(let q of this.streamFile(Z))if(X.push(q),X.length>=J){let V=await $(X);Q.push(...V),X=[],this.checkMemoryAndCleanup()}if(X.length>0){let q=await $(X);Q.push(...q)}return Q}async streamWrite(Z,$){let J=R0(Z,{encoding:"utf-8"});return new Promise((Q,X)=>{let q=async()=>{try{for await(let V of $)if(!J.write(V))await new Promise((W)=>J.once("drain",()=>W()));J.end(),J.once("finish",Q)}catch(V){X(V)}};J.once("error",X),q()})}}class E0{declarations=new Map;registry=new FinalizationRegistry((Z)=>{this.declarations.delete(Z)});maxSize;constructor(Z=1e4){this.maxSize=Z}add(Z,$){if(this.declarations.size>=this.maxSize)this.evictOldest();let J=new WeakRef($);this.declarations.set(Z,J),this.registry.register($,Z)}get(Z){return this.declarations.get(Z)?.deref()}has(Z){return this.declarations.get(Z)?.deref()!==void 0}delete(Z){this.declarations.delete(Z)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let Z=Math.ceil(this.maxSize*0.2),$=Array.from(this.declarations.keys());for(let J=0;J<Z&&J<$.length;J++)this.declarations.delete($[J])}}class L0{value=null;loaded=!1;loader;constructor(Z){this.loader=Z}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class w0{strings=new Map;maxSize;constructor(Z=50000){this.maxSize=Z}intern(Z){if(Z.length>100)return Z;let $=this.strings.get(Z);if($!==void 0)return $;if(this.strings.size>=this.maxSize){let J=Array.from(this.strings.keys());for(let Q=0;Q<J.length/2;Q++)this.strings.delete(J[Q])}return this.strings.set(Z,Z),Z}get size(){return this.strings.size}clear(){this.strings.clear()}}class M0{pool=[];factory;reset;maxSize;constructor(Z,$,J=1000){this.factory=Z,this.reset=$,this.maxSize=J}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(Z){if(this.pool.length<this.maxSize)this.reset(Z),this.pool.push(Z)}get size(){return this.pool.length}clear(){this.pool=[]}}function M3(Z,$={}){return{...Z,memory:{maxMemoryMB:$.maxMemoryMB??512,chunkSize:$.chunkSize??65536,aggressiveGC:$.aggressiveGC??!0,maxDeclarationsInMemory:$.maxDeclarationsInMemory??1e4,profile:$.profile??!1,cleanupInterval:$.cleanupInterval??5000}}}function I3(Z){let J=F0(Z).size/1024/1024,Q=J*4,X=65536;if(J>10)X=32768;if(J>50)X=16384;return{fileSizeMB:Math.round(J*100)/100,estimatedMemoryMB:Math.round(Q*100)/100,recommendedChunkSize:X}}function S3(Z){return[`Heap: ${Z.heapUsedMB}MB / ${Math.round(Z.heapTotal/1024/1024)}MB (${Z.percentUsed}%)`,`RSS: ${Math.round(Z.rss/1024/1024)}MB`,`External: ${Math.round(Z.external/1024/1024)}MB`].join(" | ")}function T3(Z={}){return new HZ(Z)}function v3(Z,$={}){let{mergeInterfaces:J=!0,mergeNamespaces:Q=!0,mergeTypes:X=!1,mergeEnums:q=!0,deduplicateIdentical:V=!0,conflictStrategy:Y="last",preserveAllComments:W=!0}=$,K=[],H=0,A=new Map,_=[];for(let G of Z){let U=`${G.kind}:${G.name}`,z=A.get(U);if(!z)z=[],A.set(U,z),_.push(U);z.push(G)}let O=[];for(let G of _){let U=A.get(G),z=U[0];if(U.length===1){O.push(z);continue}if(!(z.kind==="interface"&&J||z.kind==="module"&&Q||z.kind==="type"&&X||z.kind==="enum"&&q)){O.push(...U);continue}let j=U;if(V)j=I0(U);if(j.length===1){O.push(j[0]);continue}let N;switch(z.kind){case"interface":N=T0(j,Y,W);break;case"module":N=k0(j,Y,W);break;case"enum":N=v0(j,Y,W);break;case"type":N=C0(j,Y,W);break;default:N=j[0]}O.push(N),H+=j.length-1,K.push({name:z.name,kind:z.kind,sourceCount:j.length,memberCount:N.members?.length||0})}return{declarations:O,mergedCount:H,merges:K}}function I0(Z){let $=new Map;for(let J of Z){let Q=S0(J.text);if(!$.has(Q))$.set(Q,J);else{let X=$.get(Q);if((J.leadingComments?.length||0)>(X.leadingComments?.length||0))$.set(Q,J)}}return Array.from($.values())}function S0(Z){return Z.replace(/\s+/g," ").replace(/;\s*/g,";").trim()}function T0(Z,$,J){let Q=Z[0],X=new Map,q=[],V=J?new Set:null;for(let U of Z){if(J&&U.leadingComments&&V){for(let z of U.leadingComments)if(!V.has(z))V.add(z),q.push(z)}if(U.members)for(let z of U.members)if(!X.get(z.name))X.set(z.name,z);else switch($){case"first":break;case"last":X.set(z.name,z);break;case"error":throw Error(`Conflicting member '${z.name}' in interface '${Q.name}'`)}}let Y=Array.from(X.values()),W=Y.map((U)=>` ${U.text}`).join(`
|
|
10
|
+
`),K=Q.generics||"",H=Q.extends||"",A=new Set;for(let U of Z)if(U.extends){let z=U.extends.split(",");for(let B of z){let j=B.trim();if(j)A.add(j)}}if(A.size>0)H=`extends ${Array.from(A).join(", ")}`;let _=Q.isExported?"export ":"",O=Q.modifiers?.includes("declare")?"declare ":"",G=`${_}${O}interface ${Q.name}${K} ${H} {
|
|
11
|
+
${W}
|
|
12
|
+
}`;return{...Q,members:Y,leadingComments:q.length>0?q:Q.leadingComments,text:G.replace(/\s+\{/," {").replace(/\{\s*\n\s*\n/,`{
|
|
13
|
+
`),extends:H||void 0}}function k0(Z,$,J){let Q=Z[0],X=new Map,q=[],V=J?new Set:null;for(let _ of Z){if(J&&_.leadingComments&&V){for(let O of _.leadingComments)if(!V.has(O))V.add(O),q.push(O)}if(_.members)for(let O of _.members){let G=`${O.kind}:${O.name}`;if(!X.get(G))X.set(G,O);else switch($){case"first":break;case"last":X.set(G,O);break;case"error":throw Error(`Conflicting member '${O.name}' in namespace '${Q.name}'`)}}}let Y=Array.from(X.values()),W=Y.map((_)=>` ${_.text}`).join(`
|
|
14
|
+
`),K=Q.isExported?"export ":"",H=Q.modifiers?.includes("declare")?"declare ":"",A=`${K}${H}namespace ${Q.name} {
|
|
15
|
+
${W}
|
|
16
|
+
}`;return{...Q,members:Y,leadingComments:q.length>0?q:Q.leadingComments,text:A}}function v0(Z,$,J){let Q=Z[0],X=new Map,q=[],V=J?new Set:null;for(let O of Z){if(J&&O.leadingComments&&V){for(let G of O.leadingComments)if(!V.has(G))V.add(G),q.push(G)}if(O.members)for(let G of O.members)if(!X.get(G.name))X.set(G.name,G);else switch($){case"first":break;case"last":X.set(G.name,G);break;case"error":throw Error(`Conflicting member '${G.name}' in enum '${Q.name}'`)}}let Y=Array.from(X.values()),W=Y.map((O)=>` ${O.name}${O.value!==void 0?` = ${O.value}`:""}`).join(`,
|
|
17
|
+
`),K=Q.isExported?"export ":"",H=Q.modifiers?.includes("declare")?"declare ":"",A=Q.modifiers?.includes("const")?"const ":"",_=`${K}${H}${A}enum ${Q.name} {
|
|
18
|
+
${W}
|
|
19
|
+
}`;return{...Q,members:Y,leadingComments:q.length>0?q:Q.leadingComments,text:_}}function C0(Z,$,J){let Q=Z[0],X=[],q=J?new Set:null,V=[],Y=new Set;for(let _ of Z){if(J&&_.leadingComments&&q){for(let O of _.leadingComments)if(!q.has(O))q.add(O),X.push(O)}if(_.typeAnnotation&&!Y.has(_.typeAnnotation))Y.add(_.typeAnnotation),V.push(_.typeAnnotation)}if(V.length<=1)return{...Q,leadingComments:X.length>0?X:Q.leadingComments};let W=V.join(" | "),K=Q.isExported?"export ":"",H=Q.generics||"",A=`${K}type ${Q.name}${H} = ${W}`;return{...Q,typeAnnotation:W,leadingComments:X.length>0?X:Q.leadingComments,text:A}}function C3(Z,$={}){let J=Z.split(`
|
|
20
|
+
`),Q=new Map,X=null,q=0;for(let K=0;K<J.length;K++){let H=J[K],A=H.match(/^(export\s+)?(declare\s+)?interface\s+(\w+)/);if(A&&!X){X={name:A[3],start:K,lines:[H]},q=(H.match(/\{/g)||[]).length-(H.match(/\}/g)||[]).length;continue}if(X){if(X.lines.push(H),q+=(H.match(/\{/g)||[]).length-(H.match(/\}/g)||[]).length,q<=0){let _=Q.get(X.name)||[];_.push({start:X.start,end:K,content:X.lines}),Q.set(X.name,_),X=null,q=0}}}let V=Array.from(Q.entries()).filter(([,K])=>K.length>1);if(V.length===0)return Z;let Y=[...J],W=new Set;for(let[K,H]of V){if(H.length<=1)continue;let[A,..._]=H,O=[],G=new Set;for(let B of H)for(let j of B.content){let N=j.trim();if(N.startsWith("interface")||N.startsWith("export")||N==="{"||N==="}")continue;if(N&&!G.has(N))G.add(N),O.push(j)}for(let B of _)for(let j=B.start;j<=B.end;j++)W.add(j);let U=A.content[0],z=[U.endsWith("{")?U:`${U} {`,...O,"}"];for(let B=A.start;B<=A.end;B++)W.add(B);Y[A.start]=z.join(`
|
|
21
|
+
`)}return Y.filter((K,H)=>!W.has(H)||Y[H].includes("interface")).join(`
|
|
22
22
|
`).replace(/\n{3,}/g,`
|
|
23
23
|
|
|
24
|
-
`)}var
|
|
25
|
-
`).replace(/\r/g,`
|
|
26
|
-
`);if(
|
|
27
|
-
`)
|
|
28
|
-
`)
|
|
29
|
-
`)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`
|
|
33
|
-
`)
|
|
34
|
-
`)
|
|
35
|
-
`)
|
|
36
|
-
`)
|
|
37
|
-
`)
|
|
38
|
-
`)
|
|
39
|
-
`)
|
|
40
|
-
`);if(Q
|
|
41
|
-
`)
|
|
42
|
-
`)
|
|
43
|
-
//# sourceMappingURL=${Z}`}function J3(X,Z,$=!1){return`${X}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
`)
|
|
47
|
-
`)})
|
|
48
|
-
`),J
|
|
49
|
-
`)
|
|
50
|
-
`)}),
|
|
24
|
+
`)}var GZ=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],b0=["builtin","external","scoped","internal","parent","sibling","index","type"];function P0(Z,$={}){let{lineEnding:J="lf",trailingNewline:Q=!0,maxBlankLines:X=1,trimTrailingWhitespace:q=!0,normalizeIndentation:V=!0,indent:Y={style:"spaces",size:2},declarationOrder:W,importGrouping:K,preserveComments:H=!0,insertFinalNewline:A=!0}=$,_=Z;if(_=_Z(_,J),K?.enabled!==!1)_=jZ(_,K||{});if(W)_=NZ(_,W);if(q)_=zZ(_);if(_=AZ(_,X),V)_=x0(_,Y);if(Q||A)_=BZ(_);return _}function _Z(Z,$){let J=Z;if(Z.indexOf("\r")!==-1){if(Z.indexOf(`\r
|
|
25
|
+
`)!==-1)J=J.replace(/\r\n/g,`
|
|
26
|
+
`);if(J.indexOf("\r")!==-1)J=J.replace(/\r/g,`
|
|
27
|
+
`)}if($==="crlf")J=J.replace(/\n/g,`\r
|
|
28
|
+
`);return J}function P3(Z){let $=(Z.match(/\r\n/g)||[]).length,J=(Z.match(/(?<!\r)\n/g)||[]).length;if($>J)return"crlf";return"lf"}function zZ(Z){return Z.split(`
|
|
29
|
+
`).map(($)=>$.replace(/[\t ]+$/,"")).join(`
|
|
30
|
+
`)}function AZ(Z,$){let J=new RegExp(`\\n{${$+2},}`,"g");return Z.replace(J,`
|
|
31
|
+
`.repeat($+1))}function BZ(Z){return`${Z.replace(/\s+$/,"")}
|
|
32
|
+
`}function x0(Z,$){let{style:J="spaces",size:Q=2}=$,X=J==="tabs"?"\t":" ".repeat(Q),q=Z.split(`
|
|
33
|
+
`),V=[];for(let Y of q){let W=Y.match(/^([\t ]*)(.*)$/);if(!W){V.push(Y);continue}let[,K,H]=W;if(!H){V.push("");continue}let A=K.replace(/\t/g," "),_=Math.floor(A.length/2);V.push(X.repeat(_)+H)}return V.join(`
|
|
34
|
+
`)}function jZ(Z,$){let{groups:J=b0,separateGroups:Q=!0,alphabetize:X=!0}=$,q=Z.split(`
|
|
35
|
+
`),V=[],Y=[],W=-1;for(let G=0;G<q.length;G++){let U=q[G],z=UZ(U);if(z)V.push({line:U,source:z.source,group:z.group,isType:z.isType}),W=G;else if(V.length>0&&U.trim()==="")continue;else if(V.length>0||U.trim()!==""){if(V.length===0||G>W+1)Y.push(U)}}if(V.length===0)return Z;let K=new Map;for(let G of J)K.set(G,[]);for(let G of V)(K.get(G.group)||K.get("external")||[]).push(G);if(X)for(let[,G]of K)G.sort((U,z)=>{if(U.isType!==z.isType)return U.isType?1:-1;return U.source.localeCompare(z.source)});let H=[],A=null;for(let G of J){let U=K.get(G)||[];if(U.length===0)continue;if(Q&&A!==null)H.push("");for(let z of U)H.push(z.line);A=G}let _=q.slice(0,q.findIndex((G)=>UZ(G)!==null)),O=Y;while(O.length>0&&O[0].trim()==="")O.shift();return[..._,...H,"",...O].join(`
|
|
36
|
+
`)}function UZ(Z){let $=Z.trim(),J=$.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!J){let q=$.match(/^import\s+['"]([^'"]+)['"]/);if(q)return{source:q[1],group:OZ(q[1]),isType:!1};return null}let Q=!!J[1],X=J[2];return{source:X,group:Q?"type":OZ(X),isType:Q}}function OZ(Z){if(Z.startsWith("node:"))return"builtin";let $=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if($.includes(Z)||$.includes(Z.split("/")[0]))return"builtin";if(Z==="."||Z==="./index"||Z==="./index.js"||Z==="./index.ts")return"index";if(Z.startsWith("./"))return"sibling";if(Z.startsWith("../"))return"parent";if(Z.startsWith("@/")||Z.startsWith("~/")||Z.startsWith("#"))return"internal";if(Z.startsWith("@"))return"scoped";return"external"}function NZ(Z,$){let{kinds:J=GZ,alphabetize:Q=!1,groupExports:X=!0}=$,q=Z.split(`
|
|
37
|
+
`),V=[],Y=[],W=[],K=null,H=0,A=!0;for(let G=0;G<q.length;G++){let U=q[G],z=U.trim();H+=(U.match(/\{/g)||[]).length,H-=(U.match(/\}/g)||[]).length;let B=y0(z);if(A&&B&&B.kind!=="import"&&!z.startsWith("//")&&!z.startsWith("/*"))A=!1;if(A){Y.push(U);continue}if(B&&H<=1){if(K)V.push(K);K={lines:[U],kind:B.kind,name:B.name,isExport:B.isExport}}else if(K)K.lines.push(U);else{if(z==="")continue;W.push(U)}}if(K)V.push(K);V.sort((G,U)=>{if(X&&G.isExport!==U.isExport)return G.isExport?-1:1;let z=J.indexOf(G.kind),B=J.indexOf(U.kind),j=z>=0?z:J.length,N=B>=0?B:J.length;if(j!==N)return j-N;if(Q)return G.name.localeCompare(U.name);return 0});let _=[...Y],O=null;for(let G of V){if(O!==null&&G.kind!==O)_.push("");_.push(...G.lines),O=G.kind}if(W.length>0)_.push(""),_.push(...W);return _.join(`
|
|
38
|
+
`)}function y0(Z){let $=Z.startsWith("export "),J=$?Z.slice(7):Z;if(Z.startsWith("import "))return{kind:"import",name:Z.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(J.startsWith("type ")||J.startsWith("declare type "))return{kind:"type",name:J.match(/type\s+(\w+)/)?.[1]||"",isExport:$};if(J.startsWith("interface ")||J.startsWith("declare interface "))return{kind:"interface",name:J.match(/interface\s+(\w+)/)?.[1]||"",isExport:$};if(J.startsWith("class ")||J.startsWith("abstract class ")||J.startsWith("declare class ")||J.startsWith("declare abstract class "))return{kind:"class",name:J.match(/class\s+(\w+)/)?.[1]||"",isExport:$};if(J.startsWith("enum ")||J.startsWith("const enum ")||J.startsWith("declare enum ")||J.startsWith("declare const enum "))return{kind:"enum",name:J.match(/enum\s+(\w+)/)?.[1]||"",isExport:$};if(J.startsWith("function ")||J.startsWith("async function ")||J.startsWith("declare function ")||J.startsWith("declare async function "))return{kind:"function",name:J.match(/function\s+(\w+)/)?.[1]||"",isExport:$};if(J.startsWith("const ")||J.startsWith("let ")||J.startsWith("var ")||J.startsWith("declare const ")||J.startsWith("declare let ")||J.startsWith("declare var "))return{kind:"variable",name:J.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:$};if(J.startsWith("namespace ")||J.startsWith("declare namespace "))return{kind:"namespace",name:J.match(/namespace\s+(\w+)/)?.[1]||"",isExport:$};if(J.startsWith("module ")||J.startsWith("declare module "))return{kind:"module",name:J.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:$};if(Z.startsWith("export {")||Z.startsWith("export *")||Z.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}function x3(Z){let $=Z.split(`
|
|
39
|
+
`),J=[];for(let Q=0;Q<$.length;Q++){let X=$[Q],q=X.trim();if(q.startsWith("/**")||q.startsWith("*")||q.startsWith("*/")){J.push(X);continue}if(q.startsWith("//")){J.push(X);continue}if(q.startsWith("/*")||q.endsWith("*/")){J.push(X);continue}J.push(X)}return J.join(`
|
|
40
|
+
`)}function y3(Z={}){return{normalize:($)=>P0($,Z),normalizeLineEndings:($)=>_Z($,Z.lineEnding||"lf"),removeTrailingWhitespace:zZ,normalizeBlankLines:($)=>AZ($,Z.maxBlankLines||1),ensureTrailingNewline:BZ,processImports:($)=>jZ($,Z.importGrouping||{}),orderDeclarations:($)=>NZ($,Z.declarationOrder||{})}}var h3={default:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},minimal:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:2,trimTrailingWhitespace:!0,normalizeIndentation:!1,importGrouping:{enabled:!1}},strict:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0},declarationOrder:{kinds:GZ,alphabetize:!0,groupExports:!0}},windows:{lineEnding:"crlf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},tabs:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"tabs",size:1},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}}};var S=h0(g0(),1);import{readFile as EZ}from"fs/promises";import{dirname as f0,resolve as LZ}from"path";async function u0(Z,$=process.cwd()){let J=new Map;for(let Q of Z){let X=LZ($,Q),q=await m0(X,$);J.set(X,{path:X,dependencies:q,dependents:new Set,state:"pending"})}for(let[Q,X]of J)for(let q of X.dependencies){let V=J.get(q);if(V)V.dependents.add(Q)}return J}async function m0(Z,$){let J=new Set;try{let V=function(Y){if(S.default.isImportDeclaration(Y)){let W=Y.moduleSpecifier;if(S.default.isStringLiteral(W)){let K=W.text;if(K.startsWith(".")||K.startsWith("/")){let H=RZ(K,q,$);if(H)J.add(H)}}}else if(S.default.isExportDeclaration(Y)&&Y.moduleSpecifier){if(S.default.isStringLiteral(Y.moduleSpecifier)){let W=Y.moduleSpecifier.text;if(W.startsWith(".")||W.startsWith("/")){let K=RZ(W,q,$);if(K)J.add(K)}}}S.default.forEachChild(Y,V)},Q=await EZ(Z,"utf-8"),X=S.default.createSourceFile(Z,Q,S.default.ScriptTarget.Latest,!0,S.default.ScriptKind.TS),q=f0(Z);V(X)}catch{}return J}function RZ(Z,$,J){let Q=LZ($,Z);if(Z.endsWith(".ts")||Z.endsWith(".tsx")||Z.endsWith(".d.ts"))return Q.includes("node_modules")?null:Q;let X=`${Q}.ts`;return X.includes("node_modules")?null:X}function p0(Z){let $=[];for(let[J,Q]of Z){if(Q.state!=="pending")continue;let X=!0;for(let q of Q.dependencies){let V=Z.get(q);if(V&&V.state!=="completed"){X=!1;break}}if(X)$.push(J)}return $}async function d0(Z,$={}){let J=await EZ(Z,"utf-8"),Q=FZ(J,Z,$.keepComments??!0);return DZ(Q,{filePath:Z,sourceCode:J,declarations:Q})}async function d3(Z,$={}){let J=performance.now(),{maxConcurrency:Q=4,rootDir:X=process.cwd(),config:q={},onProgress:V,onError:Y}=$,W=await u0(Z,X),K=new Map,H=new Map,A=[],_=0,O=0,G=0,U=W.size;while(G<U){let z=p0(W);if(z.length===0){let N=[...W.values()].filter((R)=>R.state==="pending");if(N.length>0)for(let R of N)R.state="failed",R.error=Error("Circular dependency detected or dependency failed"),H.set(R.path,R.error),G++;break}let B=z.slice(0,Q-O);for(let N of B){let R=W.get(N);R.state="processing",O++}_=Math.max(_,O);let j=B.map(async(N)=>{let R=W.get(N),k=performance.now();try{let F=await d0(N,q);R.state="completed",R.result=F,R.duration=performance.now()-k,K.set(N,F),A.push(N)}catch(F){if(R.state="failed",R.error=F instanceof Error?F:Error(String(F)),R.duration=performance.now()-k,H.set(N,R.error),Y&&!Y(N,R.error))throw Error("Processing aborted by error handler")}finally{O--,G++,V?.(G,U,N)}});await Promise.all(j)}return{success:K,failed:H,totalTimeMs:performance.now()-J,maxConcurrent:_,processingOrder:A}}function c3(Z){let $=[],J=new Set,Q=new Set;function X(q){if(J.has(q))return;if(Q.has(q))return;Q.add(q);let V=Z.get(q);if(V){for(let Y of V.dependencies)if(Z.has(Y))X(Y)}Q.delete(q),J.add(q),$.push(q)}for(let q of Z.keys())X(q);return $}function c0(Z){let $=[];for(let[J,Q]of Z){let X=!1;for(let q of Q.dependencies)if(Z.has(q)){X=!0;break}if(!X)$.push(J)}return $}function l0(Z){let $=[],J=new Set;while(J.size<Z.size){let Q=[];for(let[X,q]of Z){if(J.has(X))continue;let V=!0;for(let Y of q.dependencies)if(Z.has(Y)&&!J.has(Y)){V=!1;break}if(V)Q.push(X)}if(Q.length===0){for(let X of Z.keys())if(!J.has(X))Q.push(X)}for(let X of Q)J.add(X);$.push(Q)}return $}function l3(Z){let $=l0(Z),J=c0(Z),Q=Math.max(...$.map((q)=>q.length)),X=Z.size/$.length;return{totalFiles:Z.size,independentFiles:J.length,maxParallelism:Q,levels:$.length,estimatedSpeedup:X}}function MZ(Z){let $=Z,J=!0;while(J){J=!1;let Q=$.trimStart();if(Q.startsWith("/*")){let X=Q.indexOf("*/",2);if(X!==-1){$=Q.slice(X+2),J=!0;continue}}if(Q.startsWith("//")){let X=Q.indexOf(`
|
|
41
|
+
`);if(X!==-1)$=Q.slice(X+1),J=!0;else $="",J=!0}}return $.trim()}function s3(Z,$){let Q=Z.substring(0,$).split(`
|
|
42
|
+
`),X=[],q=Q.length-1,V=!1,Y=[];while(q>=0){let W=Q[q].trim();if(W.endsWith("*/")&&!V)V=!0,Y.unshift(W);else if(W.startsWith("/*")&&V)Y.unshift(W),X.unshift(...Y),Y=[],V=!1;else if(V)Y.unshift(W);else if(W.startsWith("//"))X.unshift(W);else if(W.startsWith("*")&&(q>0&&Q[q-1].trim().startsWith("/*")))X.unshift(W);else if(W===""&&X.length>0);else if(W!=="")break;q--}return X}function a3(Z){let $=!1,J="",Q=!1;for(let X=0;X<Z.length;X++){let q=Z[X];if(!Q&&!$&&(q==='"'||q==="'"||q==="`"))$=!0,J=q;else if(!Q&&$&&q===J)$=!1;else if(q==="\\"&&!Q){Q=!0;continue}else if(!$&&q==="/"&&X<Z.length-1){if(Z[X+1]==="/")return Z.substring(X)}Q=!1}return null}function wZ(Z,$,J){let Q=0,X=!1,q="",V=!1;if(!Z.startsWith($))return null;for(let Y=0;Y<Z.length;Y++){let W=Z[Y];if(!V&&(W==='"'||W==="'"||W==="`")){if(!X)X=!0,q=W;else if(W===q)X=!1}if(W==="\\"&&!V){V=!0;continue}if(V=!1,!X){if(Z.substring(Y,Y+$.length)===$)Q++;else if(Z.substring(Y,Y+J.length)===J){if(Q--,Q===0)return{content:Z.substring(0,Y+J.length),rest:Z.substring(Y+J.length)}}}}return null}function i3(Z){let $=MZ(Z).trim(),J=$.match(/^(export\s+)?(async\s+)?function\s*(\*?)([a-zA-Z_$][\w$]*)/);if(!J)return null;let Q=[];if(J[1])Q.push("export");if(J[2])Q.push("async");if(J[3])Q.push("generator");let X=J[4],q=$.substring(J[0].length).trim(),V="";if(q.startsWith("<")){let K=wZ(q,"<",">");if(K)V=K.content,q=K.rest.trim()}let Y="";if(q.startsWith("(")){let K=wZ(q,"(",")");if(K)Y=K.content.slice(1,-1).trim(),q=K.rest.trim()}let W="void";if(q.startsWith(":")){let K=q.match(/^:\s*([^{;]+)/);if(K)W=K[1].trim()}return{name:X,generics:V,parameters:Y,returnType:W,modifiers:Q}}function n3(Z){return/^\s*export\s+/.test(Z)}function r3(Z){return/^\s*export\s+type\s+/.test(Z)}function t3(Z){let $=MZ(Z).trim(),J=$.match(/^(export\s+)?(const|let|var)\s+([a-zA-Z_$][\w$]*)/);if(!J)return null;let Q=J[2],X=J[3],q=$.substring(J[0].length).trim(),V;if(q.startsWith(":")){let W=q.indexOf("=");if(W!==-1)V=q.substring(1,W).trim(),q=q.substring(W).trim();else V=q.substring(1).replace(/;?\s*$/,"").trim(),q=""}let Y;if(q.startsWith("="))Y=q.substring(1).replace(/;?\s*$/,"").trim();return{kind:Q,name:X,typeAnnotation:V,value:Y}}class SZ{config;memorySamples=[];cpuSamples=[];ioOperations=[];startTime=0;memoryInterval=null;cpuInterval=null;lastCpuUsage=null;isRunning=!1;constructor(Z={}){this.config={memory:Z.memory??!1,memoryLimit:Z.memoryLimit??1024,cpu:Z.cpu??!1,samplingInterval:Z.samplingInterval??100,io:Z.io??!1,trackOperations:Z.trackOperations??["read","write"],outputFile:Z.outputFile??""}}start(){if(this.isRunning)return;if(this.isRunning=!0,this.startTime=Date.now(),this.memorySamples=[],this.cpuSamples=[],this.ioOperations=[],this.lastCpuUsage=null,this.config.memory)this.sampleMemory(),this.memoryInterval=setInterval(()=>this.sampleMemory(),this.config.samplingInterval);if(this.config.cpu)this.sampleCpu(),this.cpuInterval=setInterval(()=>this.sampleCpu(),this.config.samplingInterval)}stop(){if(!this.isRunning)return;if(this.isRunning=!1,this.memoryInterval)clearInterval(this.memoryInterval),this.memoryInterval=null;if(this.cpuInterval)clearInterval(this.cpuInterval),this.cpuInterval=null}sampleMemory(){let Z=IZ();this.memorySamples.push(Z)}sampleCpu(){let Z=r0();if(this.lastCpuUsage){let $={timestamp:Date.now(),user:Z.user-this.lastCpuUsage.user,system:Z.system-this.lastCpuUsage.system,total:Z.user-this.lastCpuUsage.user+(Z.system-this.lastCpuUsage.system)};this.cpuSamples.push($)}this.lastCpuUsage=Z}recordIo(Z,$,J,Q){if(!this.config.io)return;if(!this.config.trackOperations.includes(Z))return;this.ioOperations.push({timestamp:Date.now(),operation:Z,path:$,size:J,durationMs:Q})}getResults(){let Z=Date.now(),$=[],J=this.memorySamples[0]||IZ(),Q=0;for(let O of this.memorySamples){if(Q+=O.heapUsed,O.heapUsed>J.heapUsed)J=O;let G=O.heapUsed/1048576;if(G>this.config.memoryLimit)$.push(`Memory limit exceeded at ${new Date(O.timestamp).toISOString()}: ${G.toFixed(2)}MB > ${this.config.memoryLimit}MB`)}let X=this.memorySamples.length>0?Q/this.memorySamples.length:0,q=0,V=0;for(let O of this.cpuSamples)q+=O.user,V+=O.system;let Y=0,W=0,K=0,H=0,A=0,_=0;for(let O of this.ioOperations)if(O.operation==="read")Y++,K+=O.size,A+=O.durationMs;else W++,H+=O.size,_+=O.durationMs;return{startTime:this.startTime,endTime:Z,durationMs:Z-this.startTime,memory:{samples:this.memorySamples,peak:J,average:{timestamp:0,heapUsed:X,heapTotal:0,external:0,arrayBuffers:0,rss:0},warnings:$},cpu:{samples:this.cpuSamples,totalUser:q,totalSystem:V},io:{operations:this.ioOperations,totalReads:Y,totalWrites:W,totalReadBytes:K,totalWriteBytes:H,totalReadMs:A,totalWriteMs:_}}}formatResults(){let Z=this.getResults(),$=["=== Profiling Results ===",""];if($.push(`Duration: ${Z.durationMs}ms`),$.push(""),this.config.memory){if($.push("Memory:"),$.push(` Samples: ${Z.memory.samples.length}`),$.push(` Peak heap: ${g(Z.memory.peak.heapUsed)}`),$.push(` Average heap: ${g(Z.memory.average.heapUsed)}`),Z.memory.warnings.length>0){$.push(" Warnings:");for(let J of Z.memory.warnings)$.push(` - ${J}`)}$.push("")}if(this.config.cpu)$.push("CPU:"),$.push(` Samples: ${Z.cpu.samples.length}`),$.push(` Total user time: ${(Z.cpu.totalUser/1000).toFixed(2)}ms`),$.push(` Total system time: ${(Z.cpu.totalSystem/1000).toFixed(2)}ms`),$.push("");if(this.config.io)$.push("I/O:"),$.push(` Total reads: ${Z.io.totalReads}`),$.push(` Total writes: ${Z.io.totalWrites}`),$.push(` Total read: ${g(Z.io.totalReadBytes)} in ${Z.io.totalReadMs.toFixed(2)}ms`),$.push(` Total write: ${g(Z.io.totalWriteBytes)} in ${Z.io.totalWriteMs.toFixed(2)}ms`),$.push("");return $.join(`
|
|
43
|
+
`)}async writeResults(){if(!this.config.outputFile)return;let Z=this.getResults(),$=JSON.stringify(Z,null,2);try{await(await import("fs/promises")).writeFile(this.config.outputFile,$,"utf-8")}catch{await Bun.write(this.config.outputFile,$)}}}function IZ(){if(typeof process<"u"&&process.memoryUsage){let Z=process.memoryUsage();return{timestamp:Date.now(),heapUsed:Z.heapUsed,heapTotal:Z.heapTotal,external:Z.external,arrayBuffers:Z.arrayBuffers||0,rss:Z.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function r0(){if(typeof process<"u"&&process.cpuUsage){let Z=process.cpuUsage();return{user:Z.user,system:Z.system}}return{user:0,system:0}}function g(Z){if(Z===0)return"0 B";let $=["B","KB","MB","GB"],J=1024,Q=Math.floor(Math.log(Z)/Math.log(J));return`${Number.parseFloat((Z/J**Q).toFixed(2))} ${$[Q]}`}function t0(Z){return new SZ(Z)}async function Q4(Z,$){let J=t0({memory:!0,cpu:!0,...$});J.start();try{return{result:await Z(),profile:J.getResults()}}finally{J.stop()}}function X4(Z){return{async read($,J){let Q=Date.now();try{let X=await J(),q=typeof X==="string"?X.length:0;return Z.recordIo("read",$,q,Date.now()-Q),X}catch(X){throw Z.recordIo("read",$,0,Date.now()-Q),X}},async write($,J,Q){let X=Date.now();try{await J(),Z.recordIo("write",$,Q,Date.now()-X)}catch(q){throw Z.recordIo("write",$,0,Date.now()-X),q}}}}class TZ{marks=new Map;durations=new Map;mark(Z){this.marks.set(Z,performance.now())}measure(Z,$){let J=this.marks.get($);if(J===void 0)throw Error(`Mark "${$}" not found`);let Q=performance.now()-J,X=this.durations.get(Z)||[];return X.push(Q),this.durations.set(Z,X),Q}getDurations(Z){return this.durations.get(Z)||[]}getAverage(Z){let $=this.getDurations(Z);if($.length===0)return 0;return $.reduce((J,Q)=>J+Q,0)/$.length}getSummary(){let Z=new Map;for(let[$,J]of this.durations)Z.set($,{count:J.length,total:J.reduce((Q,X)=>Q+X,0),average:J.reduce((Q,X)=>Q+X,0)/J.length,min:Math.min(...J),max:Math.max(...J)});return Z}clear(){this.marks.clear(),this.durations.clear()}}function q4(){return new TZ}import{lstat as e0,realpath as Z1,stat as $1}from"fs/promises";import{isAbsolute as l,normalize as CZ,relative as J1,resolve as kZ}from"path";var T={rootDir:process.cwd(),maxFileSize:10485760,maxTotalSize:104857600,timeout:30000,followSymlinks:!1,maxFiles:1e4,blockedPatterns:["**/.git/**","**/node_modules/**","**/.env*","**/secrets/**","**/*.key","**/*.pem"]};class I extends Error{code;path;constructor(Z,$,J){super(Z);this.code=$;this.path=J;this.name="SecurityError"}}function u(Z,$={}){let{rootDir:J=process.cwd()}=$,Q=CZ(Z),X=l(Q)?Q:kZ(J,Q),q=kZ(X),V=J1(J,q);if(V.startsWith("..")||l(V))throw new I(`Path traversal detected: "${Z}" resolves outside root directory`,"PATH_TRAVERSAL",Z);return q}function Q1(Z,$={}){return Z.map((J)=>u(J,$))}function bZ(Z,$={}){let J=$.blockedPatterns||T.blockedPatterns;for(let Q of J)if(q1(Z,Q))return!0;return!1}var vZ=new Map;function X1(Z){let $=vZ.get(Z);if($)return $;let J=Z.replace(/\*\*/g,"<<GLOBSTAR>>").replace(/\*/g,"<<STAR>>").replace(/\?/g,"<<QUESTION>>");J=J.replace(/[.+^${}()|[\]\\]/g,"\\$&"),J=J.replace(/^<<GLOBSTAR>>\//,"(.*\\/)?"),J=J.replace(/\/<<GLOBSTAR>>$/,"(\\/.*)?"),J=J.replace(/\/<<GLOBSTAR>>\//g,"(\\/.*)?\\/"),J=J.replace(/<<GLOBSTAR>>/g,".*"),J=J.replace(/<<STAR>>/g,"[^/]*"),J=J.replace(/<<QUESTION>>/g,"[^/]");let Q=new RegExp(`^${J}$`);return vZ.set(Z,Q),Q}function q1(Z,$){let J=Z.indexOf("\\")===-1?Z:Z.replace(/\\/g,"/");return X1($).test(J)}async function V1(Z,$={}){let J=$.maxFileSize??T.maxFileSize;try{let Q=await $1(Z);if(Q.size>J)throw new I(`File too large: "${Z}" is ${f(Q.size)}, max is ${f(J)}`,"FILE_TOO_LARGE",Z);return Q.size}catch(Q){if(Q instanceof I)throw Q;throw new I(`Failed to check file size: ${Z}`,"INVALID_PATH",Z)}}async function Y1(Z){try{return(await e0(Z)).isSymbolicLink()}catch{return!1}}async function W1(Z,$={}){let J=$.followSymlinks??T.followSymlinks;if(await Y1(Z)){if(!J)throw new I(`Symbolic links not allowed: "${Z}"`,"SYMLINK_NOT_ALLOWED",Z);let Q=await Z1(Z);return u(Q,$)}return Z}async function o(Z,$={}){let J=u(Z,$);if(bZ(J,$))throw new I(`Path matches blocked pattern: "${Z}"`,"BLOCKED_PATTERN",Z);let Q=await W1(J,$),X=await V1(Q,$);return{path:Q,size:X}}async function PZ(Z,$={}){let J=$.maxFiles??T.maxFiles,Q=$.maxTotalSize??T.maxTotalSize;if(Z.length>J)throw new I(`Too many files: ${Z.length} exceeds maximum of ${J}`,"MAX_FILES_EXCEEDED");let X=[],q=0;for(let V of Z){let Y=await o(V,$);if(X.push(Y.path),q+=Y.size,q>Q)throw new I(`Total size exceeded: ${f(q)} exceeds maximum of ${f(Q)}`,"TOTAL_SIZE_EXCEEDED")}return{paths:X,totalSize:q}}function s(Z,$,J="Operation"){return new Promise((Q,X)=>{let q=setTimeout(()=>{X(new I(`${J} timed out after ${$}ms`,"TIMEOUT"))},$);Z.then((V)=>{clearTimeout(q),Q(V)}).catch((V)=>{clearTimeout(q),X(V)})})}function K1(Z,$={}){let J=$.timeout??T.timeout;return async(Q)=>{let{path:X}=await o(Q,$);return s(Z(X),J,`Processing ${Q}`)}}function K4(Z,$={}){let J=$.timeout??T.timeout;return async(Q)=>{let{paths:X}=await PZ(Q,$);return s(Z(X),J,`Processing ${Q.length} files`)}}function H4(Z){let $=Z.replace(/\\/g,"/").replace(/\0/g,"").replace(/^\/+/,"").replace(/^[A-Z]:/i,""),J="";while(J!==$)J=$,$=$.replace(/\.\.\/|\.\.$/g,"").replace(/\/+/g,"/");return $.replace(/^\/+|\/+$/g,"")}function U4(Z){if(Z.includes("\x00"))return!1;if(CZ(Z).includes(".."))return!1;if(l(Z)&&!Z.startsWith(process.cwd()))return!1;return!0}function f(Z){if(Z===0)return"0 B";let $=["B","KB","MB","GB"],J=1024,Q=Math.floor(Math.log(Z)/Math.log(J));return`${Number.parseFloat((Z/J**Q).toFixed(2))} ${$[Q]}`}function O4(Z={}){let $={...T,...Z};return{validatePath:(J)=>u(J,$),validatePaths:(J)=>Q1(J,$),validateFile:(J)=>o(J,$),validateBatch:(J)=>PZ(J,$),withTimeout:(J,Q)=>s(J,$.timeout,Q),secureProcessor:(J)=>K1(J,$),isBlocked:(J)=>bZ(J,$),getConfig:()=>$}}import{readFile as H1,writeFile as U1}from"fs/promises";import{basename as O1,dirname as xZ,relative as G1,resolve as _1}from"path";class yZ{file;sourceRoot;sources=[];sourcesContent=[];names=[];mappings=[];sourceIndexMap=new Map;nameIndexMap=new Map;constructor(Z){this.file=Z.file,this.sourceRoot=Z.sourceRoot}addSource(Z,$){let J=this.sourceIndexMap.get(Z);if(J===void 0)J=this.sources.length,this.sources.push(Z),this.sourcesContent.push($??null),this.sourceIndexMap.set(Z,J);else if($&&!this.sourcesContent[J])this.sourcesContent[J]=$;return J}addName(Z){let $=this.nameIndexMap.get(Z);if($===void 0)$=this.names.length,this.names.push(Z),this.nameIndexMap.set(Z,$);return $}addMapping(Z){let $=this.addSource(Z.source),J;if(Z.name)J=this.addName(Z.name);this.mappings.push({generated:Z.generated,original:Z.original,sourceIndex:$,nameIndex:J})}generate(Z=!1){this.mappings.sort((J,Q)=>{if(J.generated.line!==Q.generated.line)return J.generated.line-Q.generated.line;return J.generated.column-Q.generated.column});let $={version:3,file:this.file,sources:this.sources,names:this.names,mappings:this.encodeMappings()};if(this.sourceRoot)$.sourceRoot=this.sourceRoot;if(Z)$.sourcesContent=this.sourcesContent;return $}encodeMappings(){let Z=[],$=0,J=0,Q=0,X=0,q=0,V=0,Y=[];for(let W of this.mappings){while($<W.generated.line)Z.push(Y.join(",")),Y=[],$++,J=0;let K=[];if(K.push(W.generated.column-J),J=W.generated.column,K.push(W.sourceIndex-Q),Q=W.sourceIndex,K.push(W.original.line-X),X=W.original.line,K.push(W.original.column-q),q=W.original.column,W.nameIndex!==void 0)K.push(W.nameIndex-V),V=W.nameIndex;Y.push(z1(K))}return Z.push(Y.join(",")),Z.join(";")}toString(Z=!1){return JSON.stringify(this.generate(Z))}toDataUrl(Z=!1){let $=this.toString(Z);return`data:application/json;charset=utf-8;base64,${Buffer.from($).toString("base64")}`}toComment(Z=!1){return`//# sourceMappingURL=${this.toDataUrl(Z)}`}}class a{map;decodedMappings=null;constructor(Z){this.map=typeof Z==="string"?JSON.parse(Z):Z}originalPositionFor(Z){let $=this.getMappings(),J=0,Q=$.length-1,X=null;while(J<=Q){let q=Math.floor((J+Q)/2),V=$[q];if(V.generated.line===Z.line)if(V.generated.column===Z.column){X=V;break}else if(V.generated.column<Z.column)X=V,J=q+1;else Q=q-1;else if(V.generated.line<Z.line)J=q+1;else Q=q-1}if(!X)return{source:null,line:null,column:null,name:null};return{source:this.map.sources[X.sourceIndex]||null,line:X.original.line,column:X.original.column,name:X.nameIndex!==void 0?this.map.names[X.nameIndex]:null}}generatedPositionFor(Z){let $=this.map.sources.indexOf(Z.source);if($===-1)return null;let J=this.getMappings();for(let Q of J)if(Q.sourceIndex===$&&Q.original.line===Z.line&&Q.original.column<=Z.column)return Q.generated;return null}getMappings(){if(!this.decodedMappings)this.decodedMappings=B1(this.map.mappings);return this.decodedMappings}sourceContentFor(Z){let $=this.map.sources.indexOf(Z);if($===-1||!this.map.sourcesContent)return null;return this.map.sourcesContent[$]}}function z1(Z){return Z.map(A1).join("")}function A1(Z){let q="",V=Z<0?-Z<<1|1:Z<<1;do{let Y=V&31;if(V>>>=5,V>0)Y|=32;q+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[Y]}while(V>0);return q}function B1(Z){let $=[],J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Q=0,X=0,q=0,V=0,Y=0,W=0,K=Z.split(";");for(let H of K){if(X=0,H){let A=H.split(",");for(let _ of A){if(!_)continue;let O=j1(_,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");if(O.length>=1)X+=O[0];if(O.length>=4){q+=O[1],V+=O[2],Y+=O[3];let G={generated:{line:Q,column:X},original:{line:V,column:Y},sourceIndex:q};if(O.length>=5)W+=O[4],G.nameIndex=W;$.push(G)}}}Q++}return $}function j1(Z,$){let Q=[],X=0,q=0;for(let V of Z){let Y=$.indexOf(V);if(Y===-1)continue;let W=Y&32;if(q+=(Y&31)<<X,W)X+=5;else{let K=q&1;q>>=1,Q.push(K?-q:q),q=0,X=0}}return Q}function A4(Z){let $=new yZ({file:O1(Z.generatedFile),sourceRoot:Z.sourceRoot}),J=G1(xZ(Z.generatedFile),Z.sourceFile);$.addSource(J,Z.sourceContent);for(let Q of Z.mappings)$.addMapping({generated:{line:Q.generatedLine,column:Q.generatedColumn},original:{line:Q.originalLine,column:Q.originalColumn},source:J,name:Q.name});return $}function B4(Z,$){return`${Z}
|
|
44
|
+
//# sourceMappingURL=${$}`}function j4(Z,$,J=!1){return`${Z}
|
|
45
|
+
${$.toComment(J)}`}async function N4(Z,$,J=!1){await U1(Z,$.toString(J))}async function N1(Z){let $=await H1(Z,"utf-8");return new a($)}async function R4(Z,$){let J=Z.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if(J){let X=J[1],q=Buffer.from(X,"base64").toString("utf-8");return new a(q)}let Q=Z.match(/\/\/# sourceMappingURL=(.+)$/);if(Q){let X=_1(xZ($),Q[1].trim());try{return await N1(X)}catch{return null}}return null}function F4(Z,$){let J=Z,Q=$,X=J.split(`
|
|
46
|
+
`),q=[],V=0,Y=0;for(let W of Q){while(V+X[Y].length+1<=W.generatedStart&&Y<X.length-1)V+=X[Y].length+1,Y++;let K=W.generatedStart-V;q.push({generatedLine:Y,generatedColumn:Math.max(0,K),originalLine:W.originalLine,originalColumn:W.originalColumn,name:W.name})}return q}class hZ{config;types=new Map;imports=new Map;relationships=[];usageMap=new Map;constructor(Z={}){this.config={types:!1,relationships:!1,usage:!1,imports:!1,importUsage:!1,importRelationships:!1,...Z}}trackType(Z,$){if(!this.config.types)return;if(["interface","type","class","enum"].includes(Z.kind)){if(this.types.get(Z.name))return;let Q={name:Z.name,kind:Z.kind,file:$,usedBy:new Set,references:new Set,extendsFrom:Z.extends?[Z.extends]:void 0,implementsFrom:Z.implements};if(this.types.set(Z.name,Q),this.config.relationships){if(Z.extends)this.relationships.push({from:Z.name,to:Z.extends,kind:"extends",file:$});if(Z.implements)for(let X of Z.implements)this.relationships.push({from:Z.name,to:X,kind:"implements",file:$})}}}trackTypeUsage(Z,$,J){if(!this.config.usage)return;let Q=this.types.get(Z);if(Q)Q.usedBy.add($);let X=this.usageMap.get(Z)||new Set;if(X.add(`${J}:${$}`),this.usageMap.set(Z,X),this.config.relationships)this.relationships.push({from:$,to:Z,kind:"uses",file:J})}trackImport(Z,$,J,Q){if(!this.config.imports)return;let X={source:Z,specifiers:$,isTypeOnly:J,file:Q,usedSpecifiers:new Set,unusedSpecifiers:new Set($)},q=this.imports.get(Q)||[];q.push(X),this.imports.set(Q,q)}trackImportUsage(Z,$){if(!this.config.importUsage)return;let J=this.imports.get($);if(!J)return;for(let Q of J)if(Q.specifiers.includes(Z))Q.usedSpecifiers.add(Z),Q.unusedSpecifiers.delete(Z)}trackTypeReference(Z,$){if(!this.config.types)return;let J=this.types.get(Z);if(J)J.references.add($)}getResults(){let Z=[],$=[];for(let[X,q]of this.types)if(q.usedBy.size===0&&q.references.size===0)Z.push(X);for(let X of this.imports.values())for(let q of X)if(q.unusedSpecifiers.size===q.specifiers.length)$.push(q);let J=this.detectCircularReferences(),Q={totalTypes:this.types.size,usedTypes:this.types.size-Z.length,unusedTypes:Z.length,totalImports:Array.from(this.imports.values()).flat().length,usedImports:Array.from(this.imports.values()).flat().filter((X)=>X.usedSpecifiers.size>0).length,unusedImports:$.length,totalRelationships:this.relationships.length,circularDependencies:J.length};return{types:this.types,imports:this.imports,relationships:this.relationships,unusedTypes:Z,unusedImports:$,circularReferences:J,statistics:Q}}detectCircularReferences(){let Z=[],$=new Set,J=[],Q=(X)=>{if(J.includes(X)){let V=J.indexOf(X);Z.push(J.slice(V));return}if($.has(X))return;$.add(X),J.push(X);let q=this.relationships.filter((V)=>V.from===X&&(V.kind==="extends"||V.kind==="implements"||V.kind==="references")).map((V)=>V.to);for(let V of q)Q(V);J.pop()};for(let X of this.types.keys())Q(X);return Z}clear(){this.types.clear(),this.imports.clear(),this.relationships=[],this.usageMap.clear()}formatResults(){let Z=this.getResults(),$=["=== Tracking Results ===",""];if($.push("Statistics:"),$.push(` Total types: ${Z.statistics.totalTypes}`),$.push(` Used types: ${Z.statistics.usedTypes}`),$.push(` Unused types: ${Z.statistics.unusedTypes}`),$.push(` Total imports: ${Z.statistics.totalImports}`),$.push(` Used imports: ${Z.statistics.usedImports}`),$.push(` Unused imports: ${Z.statistics.unusedImports}`),$.push(` Type relationships: ${Z.statistics.totalRelationships}`),$.push(` Circular dependencies: ${Z.statistics.circularDependencies}`),$.push(""),Z.unusedTypes.length>0){$.push("Unused types:");for(let J of Z.unusedTypes){let Q=Z.types.get(J);$.push(` - ${J} (${Q?.kind}) in ${Q?.file}`)}$.push("")}if(Z.unusedImports.length>0){$.push("Unused imports:");for(let J of Z.unusedImports)$.push(` - ${J.source} in ${J.file}`),$.push(` Specifiers: ${Array.from(J.unusedSpecifiers).join(", ")}`);$.push("")}if(Z.circularReferences.length>0){$.push("Circular references:");for(let J of Z.circularReferences)$.push(` - ${J.join(" -> ")} -> ${J[0]}`);$.push("")}return $.join(`
|
|
47
|
+
`)}}function gZ(Z){return new hZ(Z)}function fZ(Z,$,J){for(let Q of Z){if(J.trackType(Q,$),Q.typeAnnotation){let X=R1(Q.typeAnnotation);for(let q of X)J.trackTypeUsage(q,Q.name,$)}if(Q.extends)J.trackTypeUsage(Q.extends,Q.name,$);if(Q.implements)for(let X of Q.implements)J.trackTypeUsage(X,Q.name,$);if(Q.kind==="import"&&Q.source&&Q.specifiers)J.trackImport(Q.source,Q.specifiers.map((X)=>X.name),Q.isTypeOnly||!1,$)}}function R1(Z){let $=[],J=new Set(["string","number","boolean","any","unknown","void","never","null","undefined","object","symbol","bigint","true","false","readonly","keyof","typeof","infer","extends","in","out"]),Q=/\b([A-Z]\w*)\b/g,X;while((X=Q.exec(Z))!==null){let q=X[1];if(!J.has(q.toLowerCase())&&!$.includes(q))$.push(q)}return $}function E4(Z,$){let J=gZ({imports:!0,importUsage:!0,importRelationships:!0,...$});for(let[Q,X]of Z)fZ(X,Q,J);return J.getResults()}function L4(Z,$){let J=gZ({types:!0,relationships:!0,usage:!0,...$});for(let[Q,X]of Z)fZ(X,Q,J);return J.getResults()}function F1(Z,$,J,Q={}){return{kind:Z,name:$,text:J,isExported:Q.isExported??!1,...Q}}function D1(Z){if(typeof structuredClone==="function")return structuredClone(Z);return JSON.parse(JSON.stringify(Z))}function mZ(Z,$,J=null){for(let Q of Z){$.enter?.(Q,J);let X=$[Q.kind];if(X)X(Q,J);if(Q.members&&Q.members.length>0)mZ(Q.members,$,Q);$.leave?.(Q,J)}}function I4(Z,$){let J=[];return mZ(Z,{enter:(Q)=>{if($(Q))J.push(Q)}}),J}async function E1(Z,$,J){let Q=[],X=Z.length;for(let q=0;q<Z.length;q++){let V=Z[q],Y={...J,index:q,total:X,allDeclarations:Z},W=await $(V,Y);if(W===null)continue;else if(W===void 0)Q.push(V);else if(Array.isArray(W))Q.push(...W);else Q.push(W)}return Q}function S4(...Z){return async($,J)=>{let Q=$;for(let X of Z){if(Q===null)return null;if(Array.isArray(Q)){let q=[];for(let V of Q){let Y=await X(V,J);if(Y===null)continue;if(Y===void 0)q.push(V);else if(Array.isArray(Y))q.push(...Y);else q.push(Y)}Q=q.length>0?q:null}else{let q=await X(Q,J);if(q===null)Q=null;else if(q===void 0);else Q=q}}return Q}}function b(Z,$){let J=new Set(Array.isArray(Z)?Z:[Z]);return async(Q,X)=>{if(J.has(Q.kind))return $(Q,X);return}}function T4(Z,$){return async(J,Q)=>{if(Z(J))return $(J,Q);return}}function m(Z){let $={createDeclaration:F1,cloneDeclaration:D1,modifyText:(J,Q)=>({...J,text:Q}),addModifier:(J,Q)=>({...J,modifiers:[...J.modifiers||[],Q]}),removeModifier:(J,Q)=>({...J,modifiers:(J.modifiers||[]).filter((X)=>X!==Q)})};return uZ({name:Z.name,version:Z.version,description:Z.description,onBeforeFile:Z.beforeParse?async(J)=>{return Z.beforeParse(J.content,{filePath:J.filePath,phase:"before"})}:void 0,onDeclarations:Z.transform?async(J)=>{return E1(J.declarations,Z.transform,{filePath:J.filePath,sourceCode:J.sourceCode,...$})}:void 0,onAfterFile:Z.afterGenerate?async(J)=>{return Z.afterGenerate(J.content,{filePath:J.filePath,phase:"after"})}:void 0})}function k4(Z,$){let J=typeof Z==="string"?new RegExp(Z):Z;return(Q)=>{if(J.test(Q.name)){let X=typeof $==="function"?$(Q.name,Q):Q.name.replace(J,$),q=Q.text.replace(new RegExp(`\\b${P(Q.name)}\\b`),X);return{...Q,name:X,text:q}}return}}function L1(Z,$){return(J)=>{if(J.kind==="import")return;if($&&!$(J))return;let Q=`${Z}${J.name}`,X=J.text.replace(new RegExp(`\\b${P(J.name)}\\b`),Q);return{...J,name:Q,text:X}}}function v4(Z,$){return(J)=>{if(J.kind==="import")return;if($&&!$(J))return;let Q=`${J.name}${Z}`,X=J.text.replace(new RegExp(`\\b${P(J.name)}\\b`),Q);return{...J,name:Q,text:X}}}function w1(Z){let $=typeof Z==="function"?Z:(J)=>{return(typeof Z==="string"?new RegExp(Z):Z).test(J.name)};return(J)=>{if($(J))return null;return}}function C4(Z){return($)=>{let J=Z($);if(!J)return;let X=(Array.isArray(J)?J:[J]).map((q)=>{if(q.startsWith("/**"))return q;if(q.startsWith("/*"))return q;return`/** ${q} */`});return{...$,leadingComments:[...$.leadingComments||[],...X]}}}function b4(Z){return($)=>{if(!$.typeAnnotation)return;let J=Z($.typeAnnotation,$);if(J===null)return null;if(J===void 0)return;let Q=$.text.replace(new RegExp(`:[ ]*${P($.typeAnnotation)}`),`: ${J}`);return{...$,typeAnnotation:J,text:Q}}}function P4(Z){return b("function",($)=>{if(!$.returnType)return;let J=Z($.returnType,$);if(J===null)return null;if(J===void 0)return;let Q=$.text.replace(new RegExp(`\\):[ ]*${P($.returnType)}`),`): ${J}`);return{...$,returnType:J,text:Q}})}function x4(Z){return b(["function","class"],($)=>{if(!$.parameters)return;let J=Z($.parameters,$);if(J===null)return null;if(J===void 0)return;let Q=J.map((q)=>{let V="";if(q.rest)V+="...";if(V+=q.name,q.optional)V+="?";if(q.type)V+=`: ${q.type}`;if(q.defaultValue)V+=` = ${q.defaultValue}`;return V}).join(", "),X=$.text.replace(/\([^)]*\)/,`(${Q})`);return{...$,parameters:J,text:X}})}function M1(Z,$){return(J)=>{if($&&!$(J))return;if(J.modifiers?.includes(Z))return;let Q=[...J.modifiers||[],Z],X=J.text;if(!X.includes(Z)){let q=["function","class","interface","type","enum","const","let","var"];for(let V of q){let Y=X.indexOf(V);if(Y>=0){X=`${X.slice(0,Y)}${Z} ${X.slice(Y)}`;break}}}return{...J,modifiers:Q,text:X}}}var I1=b(["interface","type"],(Z)=>{let $=Z.text.replace(/(\n\s*)(\w+)(\??:\s)/g,"$1readonly $2$3");if($===Z.text)return;return{...Z,text:$}}),y4=b(["interface","type"],(Z)=>{let $=Z.text.replace(/(\w+)\?:/g,"$1:");if($===Z.text)return;return{...Z,text:$}}),h4=b(["interface","type"],(Z)=>{let $=Z.text.replace(/(\w+)(?<!\?):/g,"$1?:");if($===Z.text)return;return{...Z,text:$}});function g4(Z){let $=new RegExp(`@(${Z.join("|")})\\b[^@]*`,"g");return(J)=>{if(!J.leadingComments?.length)return;let Q=J.leadingComments.map((q)=>{return q.replace($,"").replace(/\n\s*\*\s*\n/g,`
|
|
48
|
+
`)});if(!Q.some((q,V)=>q!==J.leadingComments[V]))return;return{...J,leadingComments:Q}}}function f4(Z,$){return(J)=>{if($&&!$(J))return;if(!J.typeAnnotation)return;let Q=`${Z}<${J.typeAnnotation}>`,X=J.text.replace(J.typeAnnotation,Q);return{...J,typeAnnotation:Q,text:X}}}var u4=m({name:"readonly",version:"1.0.0",description:"Makes all interface properties readonly",transform:I1}),m4=m({name:"strip-private",version:"1.0.0",description:"Strips @internal, @private, and @hidden declarations",transform:w1((Z)=>{if(!Z.leadingComments)return!1;return Z.leadingComments.some(($)=>/@(internal|private|hidden)\b/.test($))})}),p4=m({name:"declare",version:"1.0.0",description:"Adds declare keyword to all declarations",transform:M1("declare",(Z)=>Z.kind!=="import")});function d4(Z){return m({name:`namespace-prefix-${Z}`,version:"1.0.0",description:`Prefixes exported declarations with ${Z}`,transform:L1(`${Z}_`,($)=>$.isExported&&$.kind!=="import")})}function P(Z){return Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function n(Z,$={}){let{entryPoints:J,keepExported:Q=!0,keep:X=[],remove:q=[],shakableKinds:V=["type","interface"],debug:Y=!1}=$,W=Y?console.log.bind(console,"[tree-shake]"):()=>{},K=new Map;for(let B of Z)K.set(B.name,B);let H=r(Z);W("Dependency graph:",Object.fromEntries(Array.from(H.entries()).map(([B,j])=>[B,Array.from(j)])));let A=new Set;if(J&&J.length>0){for(let B of J)if(K.has(B))A.add(B)}else{let B=new Set(V);for(let j of Z){if(Q&&j.isExported){A.add(j.name);continue}if(i(j.name,X)){A.add(j.name);continue}if(!B.has(j.kind))A.add(j.name)}}if(J&&J.length>0&&X.length>0){for(let B of Z)if(i(B.name,X))A.add(B.name)}W("Entry points:",Array.from(A));let _=dZ(A,H);W("Reachable:",Array.from(_));let O=new Set,G=[];for(let B of Z){let j=B.name;if(_.has(j)){O.add(j);continue}if(i(j,q)){G.push(j);continue}if(!V.includes(B.kind)){O.add(j);continue}G.push(j)}W("Keeping:",Array.from(O)),W("Removing:",G);let U=Z.filter((B)=>O.has(B.name)),z={totalBefore:Z.length,totalAfter:U.length,removedCount:G.length,reductionPercent:Z.length>0?Math.round(G.length/Z.length*100):0};return{declarations:U,removed:G,dependencyGraph:H,stats:z}}function r(Z){let $=new Map,J=new Set;for(let Q=0;Q<Z.length;Q++)J.add(Z[Q].name);for(let Q of Z){let X=new Set,q=t(Q);for(let V of q)if(J.has(V)&&V!==Q.name)X.add(V);$.set(Q.name,X)}return $}function t(Z){let $=new Set;if(Z.typeAnnotation)x(Z.typeAnnotation,$);if(Z.extends)x(Z.extends,$);if(Z.text)T1(Z.text,$);if(Z.members)for(let J of Z.members){let Q=t(J);for(let X of Q)$.add(X)}if(Z.parameters){for(let J of Z.parameters)if(J.type)x(J.type,$)}if(Z.returnType)x(Z.returnType,$);return $}var S1=new Set(["string","number","boolean","object","any","unknown","never","void","null","undefined","symbol","bigint","true","false","Array","Object","String","Number","Boolean","Function","Symbol","Promise","Map","Set","WeakMap","WeakSet","Record","Partial","Required","Readonly","Pick","Omit","Exclude","Extract","NonNullable","Parameters","ReturnType","InstanceType","ConstructorParameters","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","keyof","typeof","infer","extends","readonly","const","new"]),pZ=/\b([A-Z]\w*)\b/g;function x(Z,$){pZ.lastIndex=0;let J;while((J=pZ.exec(Z))!==null){let Q=J[1];if(!S1.has(Q))$.add(Q)}}function T1(Z,$){x(Z,$)}function dZ(Z,$){let J=new Set,Q=Array.from(Z);while(Q.length>0){let X=Q.pop();if(J.has(X))continue;J.add(X);let q=$.get(X);if(q){for(let V of q)if(!J.has(V))Q.push(V)}}return J}function i(Z,$){for(let J of $)if(typeof J==="string"){if(J.includes("*")){if(new RegExp(`^${J.replace(/\*/g,".*").replace(/\?/g,".")}$`).test(Z))return!0}else if(Z===J)return!0}else if(J.test(Z))return!0;return!1}function k1(Z,$={}){let J=Z.split(`
|
|
49
|
+
`),Q=[],X=null;for(let H=0;H<J.length;H++){let A=J[H],_=A.trim();if(!X&&(_===""||_.startsWith("//")))continue;if(!X){let O=_.match(/^(export\s+)?(declare\s+)?(interface|type|enum|class|function|const|let|var)\s+(\w+)/);if(O){let[,G,,U,z]=O;if(X={name:z,kind:U,isExported:!!G,start:H,lines:[A],braceCount:0},X.braceCount+=(A.match(/\{/g)||[]).length,X.braceCount-=(A.match(/\}/g)||[]).length,X.braceCount===0&&(_.endsWith(";")||!_.includes("{")))Q.push({name:X.name,kind:X.kind,isExported:X.isExported,start:X.start,end:H,text:X.lines.join(`
|
|
50
|
+
`)}),X=null;continue}}if(X){if(X.lines.push(A),X.braceCount+=(A.match(/\{/g)||[]).length,X.braceCount-=(A.match(/\}/g)||[]).length,X.braceCount<=0&&(_.endsWith("}")||_.endsWith(";")))Q.push({name:X.name,kind:X.kind,isExported:X.isExported,start:X.start,end:H,text:X.lines.join(`
|
|
51
|
+
`)}),X=null}}if(Q.length===0)return{content:Z,removed:[]};let q=Q.map((H)=>({name:H.name,kind:H.kind,isExported:H.isExported,text:H.text})),V=n(q,$),Y=new Set(V.declarations.map((H)=>H.name)),W=new Set;for(let H of Q)if(!Y.has(H.name))for(let A=H.start;A<=H.end;A++)W.add(A);return{content:J.filter((H,A)=>!W.has(A)).join(`
|
|
51
52
|
`).replace(/\n{3,}/g,`
|
|
52
53
|
|
|
53
|
-
`),removed:
|
|
54
|
-
${
|
|
55
|
-
`)}`}function
|
|
56
|
-
Rebuilding...`)},onBuildComplete:(
|
|
54
|
+
`),removed:V.removed}}function v1(Z,$={}){return n(Z,{...$,debug:!1}).removed}function C1(Z,$){let J=r($),Q=J.get(Z)||new Set,X=dZ(new Set([Z]),J);X.delete(Z);let q=[];for(let[V,Y]of J)if(V!==Z&&Y.has(Z))q.push(V);return{directDependencies:Array.from(Q),transitiveDependencies:Array.from(X),dependents:q}}function l4(Z={}){return{shake:($)=>n($,Z),shakeContent:($)=>k1($,Z),findUnused:($)=>v1($,Z),analyzeDependencies:($,J)=>C1($,J),buildGraph:r,extractRefs:t}}var b1=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],P1=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],x1=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],y1=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function h1(Z){switch(Z){case"strict":return P1;case"readonly":return x1;case"simplified":return y1;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:($)=>$.declarationKind==="variable"&&($.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var g1=/[.*+?^${}()|[\]\\]/g,cZ=2048;class lZ{rules;compiled=[];cache=new Map;constructor(Z={rules:[]}){if(this.rules=[],Z.includeDefaults!==!1)this.rules.push(...b1);if(Z.presets)for(let $ of Z.presets)this.rules.push(...h1($));this.rules.push(...Z.rules),this.rules.sort(($,J)=>(J.priority||0)-($.priority||0)),this.recompile()}recompile(){let Z=Array(this.rules.length);for(let $=0;$<this.rules.length;$++){let J=this.rules[$],Q=typeof J.pattern==="string"?new RegExp(J.pattern.replace(g1,"\\$&"),J.global?"g":""):J.pattern;Z[$]={rule:J,regex:Q}}this.compiled=Z}map(Z,$={}){let Q=!$.declarationName&&!$.declarationKind&&!$.filePath&&!$.isReturnType&&!$.isParameterType&&!$.isPropertyType?Z:`${Z}\x00${$.declarationName??""}\x00${$.declarationKind??""}\x00${$.filePath??""}\x00${$.isReturnType?"r":""}${$.isParameterType?"p":""}${$.isPropertyType?"P":""}`,X=this.cache.get(Q);if(X!==void 0)return X;let q=Z,V=null;for(let Y=0;Y<this.compiled.length;Y++){let{rule:W,regex:K}=this.compiled[Y];if(W.condition){if(!V)V={type:Z,...$};if(!W.condition(V))continue}if(K.test(q)){if(q=q.replace(K,W.replacement),!W.global)break}}if(this.cache.size>=cZ){let Y=Math.ceil(cZ*0.1),W=0;for(let K of this.cache.keys()){if(W++>=Y)break;this.cache.delete(K)}}return this.cache.set(Q,q),q}mapAll(Z,$={}){return Z.map((J)=>this.map(J,{...$,type:J}))}addRule(Z){this.rules.push(Z),this.rules.sort(($,J)=>(J.priority||0)-($.priority||0)),this.recompile(),this.cache.clear()}removeRules(Z){let $=this.rules.length;return this.rules=this.rules.filter((J)=>{let Q=typeof J.pattern==="string"?J.pattern:J.pattern.source;return typeof Z==="string"?Q!==Z:!Z.test(Q)}),this.recompile(),this.cache.clear(),$-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function oZ(Z={rules:[]}){return new lZ(Z)}var s4=oZ({rules:[]}),a4=oZ({rules:[],presets:["strict"]});function i4(Z,$,J={}){return Z.replace(/:\s*([^;,)\]}]+)/g,(Q,X)=>{return`: ${$.map(X.trim(),J)}`})}var n4={makeReadonly:(Z)=>{if(Z.endsWith("[]"))return`readonly ${Z}`;if(Z.startsWith("Array<"))return Z.replace("Array<","ReadonlyArray<");return Z},makeNullable:(Z)=>{if(Z.includes("| null")||Z.includes("| undefined"))return Z;return`${Z} | null`},makeOptional:(Z)=>{if(Z.includes("| undefined"))return Z;return`${Z} | undefined`},makeRequired:(Z)=>{return Z.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim()},promisify:(Z)=>{if(Z.startsWith("Promise<"))return Z;return`Promise<${Z}>`},unpromisify:(Z)=>{let $=Z.match(/^Promise<(.+)>$/);return $?$[1]:Z},arrayify:(Z)=>{if(Z.endsWith("[]")||Z.startsWith("Array<"))return Z;return`${Z}[]`},unarrayify:(Z)=>{if(Z.endsWith("[]"))return Z.slice(0,-2);let $=Z.match(/^(?:Readonly)?Array<(.+)>$/);return $?$[1]:Z}};import{watch as f1}from"fs";import{readdir as u1,stat as m1}from"fs/promises";import{join as sZ,relative as e}from"path";function p1(Z,$){let{root:J,include:Q=["**/*.ts","**/*.tsx"],exclude:X=["**/node_modules/**","**/*.d.ts","**/dist/**"],debounce:q=100,initialBuild:V=!0,clearScreen:Y=!1,onChange:W,onBuildStart:K,onBuildComplete:H,onError:A}=Z,_=[],O=new Set,G=!1,U=new Map,z=null,B=!1;function j(L){let E=e(J,L);for(let w of X)if(N(E,w))return!1;for(let w of Q)if(N(E,w))return!0;return!1}function N(L,E){let w=E.replace(/\./g,"\\.").replace(/\*\*/g,"{{DOUBLESTAR}}").replace(/\*/g,"[^/]*").replace(/\{\{DOUBLESTAR\}\}/g,".*").replace(/\?/g,".");return new RegExp(`^${w}$`).test(L.replace(/\\/g,"/"))}async function R(){if(B||U.size===0)return;B=!0;let L=Array.from(U.values());U.clear();try{for(let D of L)await W?.(D);if(Y)console.clear();await K?.();let E=L.filter((D)=>D.type!=="unlink").map((D)=>D.path),w=await $(E.length>0?E:void 0);await H?.(w)}catch(E){await A?.(E)}finally{if(B=!1,U.size>0)k()}}function k(){if(z)clearTimeout(z);z=setTimeout(()=>{z=null,R()},q)}function F(L,E,w){if(!E||!G)return;let D=sZ(w,E);if(!j(D))return;let v={type:L==="rename"?"add":"change",path:D,relativePath:e(J,D)};m1(D).then(()=>{O.add(D)}).catch(()=>{v.type="unlink",O.delete(D)}).finally(()=>{U.set(D,v),k()})}async function M(L){let E=[L];try{let w=await u1(L,{withFileTypes:!0});for(let D of w)if(D.isDirectory()){let v=sZ(L,D.name),ZZ=e(J,v),$Z=!1;for(let y of X)if(N(ZZ,y)||N(`${ZZ}/`,y)){$Z=!0;break}if(!$Z){let y=await M(v);E.push(...y)}}}catch{}return E}async function aZ(){if(G)return;G=!0;let L=await M(J);for(let E of L)try{let w=f1(E,{persistent:!0},(D,v)=>{F(D,v,E)});w.on("error",(D)=>{A?.(D)}),_.push(w)}catch(w){await A?.(w)}if(V){await K?.();let E=await $();await H?.(E)}}function iZ(){if(G=!1,z)clearTimeout(z),z=null;for(let L of _)L.close();_.length=0,O.clear(),U.clear()}async function nZ(){await K?.();let L=await $();return await H?.(L),L}return{start:aZ,stop:iZ,rebuild:nZ,isWatching:()=>G,getWatchedFiles:()=>Array.from(O)}}async function $6(Z,$){let J=async(X)=>{let q=Date.now();try{let V=await $(Z);return{success:V.errors.length===0,duration:Date.now()-q,filesProcessed:V.filesProcessed,errors:V.errors}}catch(V){return{success:!1,duration:Date.now()-q,filesProcessed:0,errors:[V.message]}}},Q=p1({root:Z.root||Z.cwd||process.cwd(),include:Z.include,exclude:Z.exclude,debounce:Z.debounce,initialBuild:Z.initialBuild,clearScreen:Z.clearScreen,onChange:Z.onChange,onBuildStart:Z.onBuildStart,onBuildComplete:Z.onBuildComplete,onError:Z.onError},J);return await Q.start(),Q}function d1(Z){let $=Z.success?"\u2713":"\u2717",J=`${Z.duration}ms`;if(Z.success)return`${$} Built ${Z.filesProcessed} file(s) in ${J}`;else return`${$} Build failed in ${J}
|
|
55
|
+
${Z.errors.map((Q)=>` - ${Q}`).join(`
|
|
56
|
+
`)}`}function J6(){return{onChange:(Z)=>{let $=Z.type==="add"?"+":Z.type==="unlink"?"-":"~";console.log(`[${$}] ${Z.relativePath}`)},onBuildStart:()=>{console.log(`
|
|
57
|
+
Rebuilding...`)},onBuildComplete:(Z)=>{console.log(d1(Z))},onError:(Z)=>{console.error(`Error: ${Z.message}`)}}}export{k$ as writeToFile,O9 as writeTextFile,N4 as writeSourceMap,W9 as write,a9 as wrapError,s as withTimeout,$6 as watchAndGenerate,m$ as watch,mZ as walkDeclarations,W1 as validateSymlink,Q1 as validatePaths,u as validatePath,i8 as validateGeneratedDeclarations,V1 as validateFileSize,o as validateFilePath,PZ as validateFileBatch,b$ as validateDtsContent,d8 as validateDeclarations,Q3 as unwrap,a8 as typeCheckWithConfig,p8 as typeCheck,k1 as treeShakeContent,n as treeShake,fZ as trackDeclarations,$$ as toZod,X$ as toYup,J$ as toValibot,Z$ as toJsonSchema,Q$ as toIoTs,q$ as toArkType,e9 as summarizeErrors,W0 as summarizeDiffs,m4 as stripPrivatePlugin,_$ as stripInternalPlugin,P1 as strictTypeMappings,a4 as strictTypeMapper,s$ as startLSPServer,K9 as spawnProcess,X2 as sortProjectsByDependencies,O0 as sortImportsInContent,VZ as sortImports,y1 as simplifiedTypeMappings,o6 as shouldUseAsyncParsing,Y8 as shouldIncludeNonExportedInterface,V8 as shouldIncludeNonExportedFunction,R9 as setTimestamps,N9 as setLogPrefix,B9 as setLogLevel,A9 as scopedLogger,H4 as sanitizeFilename,Y9 as runtime,W2 as resolveWorkspacePatterns,g8 as resolveEntryFiles,L9 as resetConfig,y4 as requiredTransformer,zZ as removeTrailingWhitespace,MZ as removeLeadingComments,x1 as readonlyTypeMappings,I1 as readonlyTransformer,u4 as readonlyPlugin,H9 as readTextFile,N1 as readSourceMap,U$ as quickFormat,R3 as pruneCache,Q4 as profileExecution,j$ as processVariableDeclaration,R$ as processTypeDeclaration,h$ as processSource,w$ as processModuleDeclaration,N$ as processInterfaceDeclaration,d3 as processInParallel,jZ as processImports,E$ as processImportDeclaration,B$ as processFunctionDeclaration,u$ as processFile,L$ as processExportDeclaration,D$ as processEnumDeclaration,DZ as processDeclarations,F$ as processClassDeclaration,H3 as printDiffs,K0 as printDiff,G3 as presets,x3 as preserveCommentFormatting,G$ as pluginManager,t3 as parseVariableDeclaration,S9 as parseJSDoc,I$ as parseImportStatement,qZ as parseImport,i3 as parseFunctionDeclaration,r6 as parseArrayElements,Z2 as parallelProcess,NZ as orderDeclarations,h4 as optionalTransformer,n$ as optimizeFile,i$ as optimizeDeclarations,F9 as nullLogger,h3 as normalizerPresets,P0 as normalizeOutput,_Z as normalizeLineEndings,x0 as normalizeIndent,AZ as normalizeBlankLines,r$ as minifyDts,C3 as mergeDeclarationsInContent,v3 as mergeDeclarations,E1 as mapDeclarations,z9 as logger,m8 as loadCompilerOptions,r3 as isTypeOnlyExport,Y1 as isSymlink,U4 as isSafePath,l9 as isParseError,V9 as isNode,Z8 as isGenericType,o9 as isFileError,n3 as isExportStatement,c9 as isDtsxError,s9 as isConfigError,q9 as isBun,W8 as isBuiltInType,J3 as isBranded,bZ as isBlockedPath,t6 as inferObjectType,i6 as inferNarrowTypeInUnion,a6 as inferNarrowType,e6 as inferFunctionType,n6 as inferArrayType,X8 as hasExportModifier,q8 as hasAsyncModifier,l8 as getTypeAtPosition,c3 as getTopologicalOrder,d6 as getSourceFileCacheSize,c6 as getSourceFileAsync,G9 as getRuntimeInfo,o8 as getQuickInfo,l0 as getProcessingLevels,h1 as getPresetMappings,s6 as getPendingParseCount,Q8 as getParameterName,s0 as getNodeText,j9 as getLogLevel,i9 as getLocationFromOffset,G8 as getInterfaceBody,Z9 as getGraphSummary,Y$ as getFormatExtension,E9 as getConfig,v$ as getAllTypeScriptFiles,q2 as generateWorkspace,b9 as generateTypeDocJSON,V2 as generateMonorepo,k9 as generateMarkdown,C9 as generateJSON,v9 as generateHTML,K2 as generateFromPackageWorkspaces,P9 as generateDocs,x$ as generateDeclarationMap,f$ as generate,d1 as formatWatchResult,Y3 as formatUnifiedDiff,s8 as formatTypeCheckResults,S3 as formatMemoryStats,F3 as formatIncrementalResult,K$ as formatFiles,n9 as formatErrorWithContext,t9 as formatDtsError,W$ as formatDts,W3 as formatDiffSummary,i0 as formatComments,V0 as formatColoredDiff,e8 as formatCircularAnalysis,v1 as findUnusedDeclarations,T8 as findReferencedTypes,o0 as findMatchingBracket,c0 as findIndependentFiles,I4 as findDeclarations,$9 as findAllDependents,J9 as findAllDependencies,T4 as filterByPredicate,b as filterByKind,U9 as fileExists,QZ as file,E8 as extractVariableStatement,K8 as extractTypesFromModuleText,t as extractTypeReferences,w8 as extractTypeAliasDeclaration,J8 as extractTripleSlashDirectives,a3 as extractTrailingComment,R4 as extractSourceMap,$8 as extractSatisfiesType,k8 as extractReferencedTypeDeclarations,S8 as extractModuleDeclaration,a0 as extractLeadingCommentsFromNode,s3 as extractLeadingComments,a0 as extractJSDocComments,L8 as extractInterfaceDeclaration,N8 as extractImportDeclaration,D8 as extractFunctionDeclaration,R8 as extractExportDeclaration,F8 as extractExportAssignment,I8 as extractEnumDeclaration,T9 as extractDocumentation,D3 as extractDependencies,C8 as extractDeclarationsAsync,FZ as extractDeclarations,M8 as extractClassDeclaration,wZ as extractBalancedSymbols,S$ as extractAllImportedItems,X9 as exportGraphAsJson,Q9 as exportGraphAsDot,I3 as estimateMemoryUsage,BZ as ensureTrailingNewline,u8 as ensureGitignore,Q2 as discoverWorkspaceProjects,Y2 as discoverWorkspaceFromPackageJson,K3 as diffFiles,Y0 as diffFile,P3 as detectLineEnding,d as detectGroup,r8 as detectCircularDependencies,uZ as definePlugin,M9 as defineConfigAsync,w9 as defineConfig,b1 as defaultTypeMappings,s4 as defaultTypeMapper,D9 as defaultConfig,p4 as declarePlugin,f4 as createWrapTypeTransformer,e$ as createWorkerPool,p1 as createWatcher,J6 as createWatchLogger,b4 as createTypeTransformer,oZ as createTypeMapper,l4 as createTreeShaker,m as createTransformerPlugin,gZ as createTracker,q4 as createTimer,v4 as createSuffixTransformer,g4 as createStripTagsTransformer,T3 as createStreamingProcessor,A4 as createSourceMap,O4 as createSecurityMiddleware,K1 as createSecureProcessor,K4 as createSecureBatchProcessor,P4 as createReturnTypeTransformer,k4 as createRenameTransformer,w1 as createRemoveTransformer,t0 as createProfiler,X4 as createProfiledIo,L1 as createPrefixTransformer,x4 as createParameterTransformer,y3 as createOutputNormalizer,d4 as createNamespacePrefixPlugin,M1 as createModifierTransformer,M3 as createMemoryOptimizedConfig,_9 as createLogger,C4 as createJSDocTransformer,N3 as createIncrementalBuilder,O3 as createImportSorter,H$ as createFormatter,A$ as createFilterPlugin,a$ as createFileWatcher,r9 as createDtsError,x9 as createDocsGenerator,P$ as createDiff,F1 as createDeclaration,h8 as createBundler,z$ as createBannerPlugin,V$ as convertToFormat,I9 as config,p as computeDiff,S4 as composeTransformers,D1 as cloneDeclaration,v8 as clearSourceFileCache,g$ as clearResultCache,M$ as clearProcessorCaches,C$ as checkIsolatedDeclarationsConfig,c8 as checkIsolatedDeclarations,J2 as calculateOptimalBatchSize,x8 as bundleDtsFiles,P8 as bundleDeclarations,y8 as bundleAndWrite,U8 as buildVariableDeclaration,_8 as buildTypeDeclaration,u0 as buildProcessingGraph,B8 as buildModuleDeclaration,j8 as buildModuleBody,O8 as buildInterfaceDeclaration,H8 as buildFunctionSignature,n8 as buildDependencyGraph,F4 as buildDeclarationMappings,r as buildDeclarationDependencyGraph,z8 as buildClassDeclaration,A8 as buildClassBody,l6 as batchParseSourceFiles,$2 as batchFiles,b8 as batchExtractDeclarations,T$ as assertNever,r1 as asTypeName,a1 as asSourceCode,Z3 as asRelativePath,n1 as asModuleSpecifier,$3 as asJsonString,s1 as asGlobPattern,l1 as asFilePath,i1 as asDtsContent,o1 as asDirectoryPath,t1 as asDeclarationName,e1 as asAbsolutePath,i4 as applyTypeMappings,B4 as appendSourceMapComment,j4 as appendInlineSourceMap,L4 as analyzeTypes,l3 as analyzeParallelizationPotential,E4 as analyzeImports,C1 as analyzeDependencies,t8 as analyzeCircularDependencies,y$ as addSourceMapComment,t$ as WorkerPool,n4 as TypeTransformers,lZ as TypeMapper,hZ as Tracker,TZ as Timer,d$ as SymbolKind,w0 as StringInterner,HZ as StreamingProcessor,yZ as SourceMapGenerator,a as SourceMapConsumer,I as SecurityError,SZ as Profiler,u9 as ProcessingError,O$ as PluginManager,g9 as ParseError,M0 as ObjectPool,p$ as LspDiagnosticSeverity,L0 as LazyLoader,j0 as IncrementalCache,m9 as FileError,f9 as ExtractionError,y9 as ErrorCodes,o$ as DtsxLanguageServer,h9 as DtsxError,l$ as DocumentHighlightKind,E0 as DeclarationPool,T as DEFAULT_SECURITY_CONFIG,b0 as DEFAULT_IMPORT_GROUP_ORDER,XZ as DEFAULT_GROUP_ORDER,GZ as DEFAULT_DECLARATION_ORDER,p9 as ConfigError,c$ as CompletionItemKind,d9 as CircularDependencyError,f8 as BuildCache,X3 as BrandedPath};
|