@stacksjs/dtsx 0.9.19 → 0.9.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/bin/cli.js +5 -5
  2. package/dist/{chunk-fg4cjy7w.js → chunk-0cfb4831.js} +1 -1
  3. package/dist/{chunk-w71syh0b.js → chunk-0d5r9n78.js} +1 -1
  4. package/dist/{chunk-s30jnjb4.js → chunk-1hy2eypj.js} +1 -1
  5. package/dist/chunk-380wx22t.js +2 -0
  6. package/dist/{chunk-1z1w3s0k.js → chunk-4mtbtmee.js} +11 -11
  7. package/dist/{chunk-m68323h2.js → chunk-4zdjnqrz.js} +1 -1
  8. package/dist/chunk-7hy98p24.js +62 -0
  9. package/dist/{chunk-gg6xh82k.js → chunk-9asxz2at.js} +1 -1
  10. package/dist/{chunk-2qyt67jt.js → chunk-a0gah6hn.js} +1 -1
  11. package/dist/{chunk-nwvqfthk.js → chunk-aaba58v4.js} +1 -1
  12. package/dist/chunk-af12rv0y.js +80 -0
  13. package/dist/{chunk-kwmhsx3n.js → chunk-bymtns9a.js} +1 -1
  14. package/dist/chunk-cdv5r51q.js +156 -0
  15. package/dist/{chunk-fmhrt2ca.js → chunk-dymmh9x0.js} +1 -1
  16. package/dist/chunk-eqfegkc1.js +2 -0
  17. package/dist/{chunk-69rnp3hs.js → chunk-ft0nf9jb.js} +1 -1
  18. package/dist/{chunk-9ycwkhxh.js → chunk-fvgc14nk.js} +1 -1
  19. package/dist/chunk-m94gn6yx.js +2 -0
  20. package/dist/chunk-nmmv0nrk.js +2 -0
  21. package/dist/{chunk-x4jgc4bx.js → chunk-nqwz71ak.js} +1 -1
  22. package/dist/{chunk-fbradttj.js → chunk-rd7n0yj1.js} +1 -1
  23. package/dist/chunk-sp1xrnfe.js +2 -0
  24. package/dist/{chunk-7pwy4m0c.js → chunk-vx4a5crm.js} +1 -1
  25. package/dist/chunk-wr3swrge.js +2 -0
  26. package/dist/{chunk-dv8haj2p.js → chunk-ww6wqbda.js} +1 -1
  27. package/dist/{chunk-ezrgnecm.js → chunk-wzbwr7a3.js} +1 -1
  28. package/dist/chunk-xw9wfq8f.js +17 -0
  29. package/dist/{chunk-jjwwkrfk.js → chunk-y2pe3jq3.js} +1 -1
  30. package/dist/{chunk-mr4jjsps.js → chunk-yzhdn85p.js} +1 -1
  31. package/dist/src/index.js +1 -1
  32. package/dist/src/plugins/bun.js +1 -1
  33. package/dist/src/plugins/esbuild.js +1 -1
  34. package/dist/src/plugins/index.js +1 -1
  35. package/dist/src/plugins/tsup.js +1 -1
  36. package/dist/src/plugins/vite.js +1 -1
  37. package/dist/src/plugins/webpack.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-2n9mmg2c.js +0 -2
  40. package/dist/chunk-4jw8qvts.js +0 -16
  41. package/dist/chunk-7g7axw9t.js +0 -2
  42. package/dist/chunk-7zsd1qqw.js +0 -80
  43. package/dist/chunk-9qe2wx58.js +0 -2
  44. package/dist/chunk-a3txc27m.js +0 -33
  45. package/dist/chunk-q0k7xs9f.js +0 -2
  46. package/dist/chunk-sbmecr6t.js +0 -2
  47. package/dist/chunk-trm0gptj.js +0 -134
  48. package/dist/chunk-w1k33gyv.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{tb as y}from"./chunk-7zsd1qqw.js";import{Wc as H,Yc as F}from"./chunk-gssantc8.js";import{dd as R}from"./chunk-mcdb3q06.js";import{existsSync as V,readFileSync as G}from"fs";import{dirname as M,join as X,resolve as x}from"path";async function S(E){let A=[],z=new Set;async function q(I,O){let w=x(I);if(z.has(w))return;if(z.add(w),!V(w)){H.warn(`tsconfig not found: ${w}`);return}try{let K=G(w,"utf-8"),Q=K.indexOf("//")!==-1||K.indexOf("/*")!==-1?K.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""):K,L=JSON.parse(Q),U=M(w),Y=B(U,O),W=[];if(L.references)for(let D of L.references){let $=x(U,D.path),J=V(X($,"tsconfig.json"))?X($,"tsconfig.json"):$;await q(J,Y);let b=B(M(J),Y);W.push(b)}let Z="./src";if(L.compilerOptions?.rootDir)Z=L.compilerOptions.rootDir;else if(L.include&&L.include.length>0){if(L.include[0].startsWith("src/"))Z="./src"}let _="./dist";if(L.compilerOptions?.outDir)_=L.compilerOptions.outDir;else if(L.compilerOptions?.declarationDir)_=L.compilerOptions.declarationDir;A.push({name:Y,root:U,tsconfigPath:w,references:W,config:{root:Z,outdir:_}})}catch(K){let Q=K instanceof Error?K.message:String(K);H.warn(`Failed to parse ${w}: ${Q}`)}}return await q(E),A}function B(E,A){let z=X(E,"package.json");if(V(z))try{let I=G(z,"utf-8"),O=JSON.parse(I);if(O.name)return O.name}catch{}let q=E.split("/").pop()||"unknown";return A?`${A}/${q}`:q}function N(E){let A=new Map(E.map((w)=>[w.name,w])),z=[],q=new Set,I=new Set;function O(w){if(q.has(w))return;if(I.has(w)){H.warn(`Circular dependency detected involving: ${w}`);return}I.add(w);let K=A.get(w);if(K){for(let Q of K.references)O(Q);z.push(K)}I.delete(w),q.add(w)}for(let w of E)O(w.name);return z}async function T(E){let A=Date.now(),z=N(E.projects);H.info(`Generating declarations for ${z.length} projects...`);let q=[],I=!0;for(let Q of z){H.info(`
2
+ import{tb as y}from"./chunk-af12rv0y.js";import{Wc as H,Yc as F}from"./chunk-gssantc8.js";import{dd as R}from"./chunk-mcdb3q06.js";import{existsSync as V,readFileSync as G}from"fs";import{dirname as M,join as X,resolve as x}from"path";async function S(E){let A=[],z=new Set;async function q(I,O){let w=x(I);if(z.has(w))return;if(z.add(w),!V(w)){H.warn(`tsconfig not found: ${w}`);return}try{let K=G(w,"utf-8"),Q=K.indexOf("//")!==-1||K.indexOf("/*")!==-1?K.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""):K,L=JSON.parse(Q),U=M(w),Y=B(U,O),W=[];if(L.references)for(let D of L.references){let $=x(U,D.path),J=V(X($,"tsconfig.json"))?X($,"tsconfig.json"):$;await q(J,Y);let b=B(M(J),Y);W.push(b)}let Z="./src";if(L.compilerOptions?.rootDir)Z=L.compilerOptions.rootDir;else if(L.include&&L.include.length>0){if(L.include[0].startsWith("src/"))Z="./src"}let _="./dist";if(L.compilerOptions?.outDir)_=L.compilerOptions.outDir;else if(L.compilerOptions?.declarationDir)_=L.compilerOptions.declarationDir;A.push({name:Y,root:U,tsconfigPath:w,references:W,config:{root:Z,outdir:_}})}catch(K){let Q=K instanceof Error?K.message:String(K);H.warn(`Failed to parse ${w}: ${Q}`)}}return await q(E),A}function B(E,A){let z=X(E,"package.json");if(V(z))try{let I=G(z,"utf-8"),O=JSON.parse(I);if(O.name)return O.name}catch{}let q=E.split("/").pop()||"unknown";return A?`${A}/${q}`:q}function N(E){let A=new Map(E.map((w)=>[w.name,w])),z=[],q=new Set,I=new Set;function O(w){if(q.has(w))return;if(I.has(w)){H.warn(`Circular dependency detected involving: ${w}`);return}I.add(w);let K=A.get(w);if(K){for(let Q of K.references)O(Q);z.push(K)}I.delete(w),q.add(w)}for(let w of E)O(w.name);return z}async function T(E){let A=Date.now(),z=N(E.projects);H.info(`Generating declarations for ${z.length} projects...`);let q=[],I=!0;for(let Q of z){H.info(`
3
3
  [${Q.name}] Generating...`);try{let L={...E.sharedConfig,...Q.config,cwd:Q.root,tsconfigPath:Q.tsconfigPath},U=await y(L),Y=U.filesFailed===0;if(!Y)I=!1;q.push({name:Q.name,stats:U,success:Y}),H.info(`[${Q.name}] Generated ${U.filesGenerated} files`)}catch(L){I=!1;let U=L instanceof Error?L.message:String(L);q.push({name:Q.name,stats:{filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:U}),H.error(`[${Q.name}] Failed: ${U}`)}}let O=Date.now()-A,w=q.filter((Q)=>Q.success).length,K=q.length-w;if(H.info(`
4
4
  --- Workspace Generation Summary ---`),H.info(`Projects processed: ${q.length}`),H.info(`Successful: ${w}`),K>0)H.info(`Failed: ${K}`);return H.info(`Total duration: ${O}ms`),H.info(`------------------------------------
5
5
  `),{success:I,projects:q,durationMs:O}}async function f(E,A){if(A?.logLevel)F(A.logLevel);let z=X(E,"tsconfig.json");if(!V(z))throw Error(`Root tsconfig.json not found at: ${z}`);H.info("Discovering workspace projects...");let q=await S(z);if(q.length===0)return H.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return H.info(`Found ${q.length} projects`),T({root:E,projects:q,sharedConfig:A})}async function v(E){let A=X(E,"package.json");if(!V(A))return[];try{let z=G(A,"utf-8"),q=JSON.parse(z),I=[];if(Array.isArray(q.workspaces))I=q.workspaces;else if(q.workspaces?.packages)I=q.workspaces.packages;return I}catch{return[]}}async function C(E,A){let{Glob:z}=awaitPromise.resolve(globalThis.Bun),q=[];for(let I of A){let O=new z(I);for await(let w of O.scan({cwd:E,absolute:!0,onlyFiles:!1})){let K=X(w,"package.json");if(V(K))q.push(w)}}return q}async function l(E,A){if(A?.logLevel)F(A.logLevel);let z=await v(E);if(z.length===0)return H.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};H.info(`Found workspace patterns: ${z.join(", ")}`);let q=await C(E,z);if(q.length===0)return H.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};H.info(`Found ${q.length} workspace packages`);let I=q.map((O)=>{let w=X(O,"tsconfig.json");return{name:B(O),root:O,tsconfigPath:V(w)?w:"",references:[]}});return T({root:E,projects:I,sharedConfig:A})}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{tb as C}from"./chunk-7zsd1qqw.js";function y(F={}){let{onStart:H=!1,onEnd:I=!0,onGenerated:J,onError:z,...q}=F,B=async()=>{try{let k=await C(q);J?.(k)}catch(k){let j=k instanceof Error?k:Error(String(k));if(z?.(j),!z)console.error("[dtsx] Generation failed:",j.message)}};return{name:"dtsx",setup(k){let j=k.initialOptions;if(!q.entrypoints&&j.entryPoints)if(Array.isArray(j.entryPoints))q.entrypoints=j.entryPoints;else q.entrypoints=Object.values(j.entryPoints);if(!q.outdir){if(j.outdir)q.outdir=j.outdir;else if(j.outfile){let w=j.outfile.lastIndexOf("/");if(w!==-1)q.outdir=j.outfile.substring(0,w)}}if(H)k.onStart(async()=>{await B()});if(I)k.onEnd(async(w)=>{if(w.errors.length===0)await B()})}}}var L=y,M=y,P=y;
2
+ import{tb as C}from"./chunk-af12rv0y.js";function y(F={}){let{onStart:H=!1,onEnd:I=!0,onGenerated:J,onError:z,...q}=F,B=async()=>{try{let k=await C(q);J?.(k)}catch(k){let j=k instanceof Error?k:Error(String(k));if(z?.(j),!z)console.error("[dtsx] Generation failed:",j.message)}};return{name:"dtsx",setup(k){let j=k.initialOptions;if(!q.entrypoints&&j.entryPoints)if(Array.isArray(j.entryPoints))q.entrypoints=j.entryPoints;else q.entrypoints=Object.values(j.entryPoints);if(!q.outdir){if(j.outdir)q.outdir=j.outdir;else if(j.outfile){let w=j.outfile.lastIndexOf("/");if(w!==-1)q.outdir=j.outfile.substring(0,w)}}if(H)k.onStart(async()=>{await B()});if(I)k.onEnd(async(w)=>{if(w.errors.length===0)await B()})}}}var L=y,M=y,P=y;
3
3
  export{y as ia,L as ja,M as ka,P as la};
@@ -0,0 +1,17 @@
1
+ // @bun
2
+ var E=!1,R=null;function h(J){if(J.indexOf("/*")===-1)return J.trim();let X=[],Q=0,z=0,L=J.length;while(z<L)if(J.charCodeAt(z)===47&&z+1<L&&J.charCodeAt(z+1)===42){if(z>Q)X.push(J.substring(Q,z));z+=2;while(z<L-1){if(J.charCodeAt(z)===42&&J.charCodeAt(z+1)===47){z+=2;break}z++}Q=z}else z++;if(Q<L)X.push(J.substring(Q));return X.join("").trim()}function Qz(){E=!0,R=null}function Hz(){E=!1;let J=R;return R=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,L=!1;for(let Z=0;Z<Y;Z++)if(J.charCodeAt(Z)<=32){if(!L){if(z>=0)Q.push(J.substring(z,Z));Q.push(" "),L=!0,z=-1}}else{if(L||z<0)z=Z;L=!1}if(z>=0)Q.push(J.substring(z));return Q.join("")}function b(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 d(z);if(z.startsWith("new "))return c(z);if(z.includes("=>")||z.startsWith("function")||z.startsWith("async"))return y(z,X,Q,Y);if(z.endsWith("as const")){let L=z.slice(0,-8).trim();if(L.startsWith("[")&&L.endsWith("]")){let Z=L.slice(1,-1).trim();if(!Z)return"readonly []";let $=w(Z),H=[];for(let O=0;O<$.length;O++)H.push(b($[O].trim(),!0,!1,Q+1));return`readonly [${H.join(", ")}]`}return b(L,!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 b(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 c(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&&(k(J.charCodeAt(Y))||J.charCodeAt(Y)===46))Y++;if(Y===X)return"unknown";let z=J.slice(X,Y);{let L=J.slice(Y),Z=L;if(L.startsWith("<")){let H=0,O=-1;for(let K=0;K<L.length;K++)if(L[K]==="<")H++;else if(L[K]===">"){if(H--,H===0){O=K;break}}if(O!==-1){let K=L.slice(0,O+1);Z=L.slice(O+1);let q=Z.indexOf("(");if(q!==-1){let G=0,B=-1;for(let F=q;F<Z.length;F++)if(Z[F]==="(")G++;else if(Z[F]===")"){if(G--,G===0){B=F;break}}if(B!==-1){if(Z.slice(B+1).trimStart().startsWith("."))return"unknown"}}return`${z}${K}`}}let $=Z.indexOf("(");if($!==-1){let H=0,O=-1;for(let K=$;K<Z.length;K++)if(Z[K]==="(")H++;else if(Z[K]===")"){if(H--,H===0){O=K;break}}if(O!==-1){if(Z.slice(O+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 d(J){let Y=J.trimStart(),X=5;while(X<Y.length&&Y.charCodeAt(X)<=32)X++;let Q=X;if(X<Y.length&&k(Y.charCodeAt(X))){while(X<Y.length&&k(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 L=J.slice(16,z).trim();if(L)return`Promise<${b(L,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 L=J.slice(Q+1,z).trim(),Z=w(L),$=[];for(let H=0;H<Z.length;H++){let O=Z[H].trim();if(O.startsWith("Promise.resolve(")){let K=f(O,Y,X+1),q=K.indexOf("<"),G=K.lastIndexOf(">");$.push(q!==-1&&G>q?K.slice(q+1,G):"unknown")}else $.push(b(O,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),L=!1;for(let G=0;G<z.length;G++){let B=z[G],F=B.length;while(F>0&&B.charCodeAt(F-1)<=32)F--;if(F>=8&&B.slice(F-8,F)==="as const"){L=!0;break}}if(L){let G=[];for(let B=0;B<z.length;B++){let F=z[B].trim();if(F.endsWith("as const")){let W=F.slice(0,-8).trim();if(W.startsWith("[")&&W.endsWith("]")){let N=W.slice(1,-1).trim(),U=w(N),M=[];for(let V=0;V<U.length;V++)M.push(b(U[V].trim(),!0,!1,X+1));G.push(`readonly [${M.join(", ")}]`)}else G.push(b(W,!0,!1,X+1))}else if(F.startsWith("[")&&F.endsWith("]"))G.push(I(F,!0,X+1));else G.push(b(F,!0,!1,X+1))}return`readonly [
3
+ ${G.join(` |
4
+ `)}
5
+ ]`}let Z=E&&!Y,$=[],H=[];for(let G of z){let B=G.trim(),F=R;if(R=null,B.startsWith("[")&&B.endsWith("]"))$.push(I(B,Y,X+1));else $.push(l(B,Y,X+1));if(Z)H.push(R);R=F}if(Z)if(g(J))R=_(J);else{let G=[];for(let B=0;B<z.length;B++){let F=z[B].trim();if(F.endsWith("as const"))continue;if(x(F)||F==="null"||F==="undefined")G.push(F);else if(F.startsWith("[")&&g(F))G.push(_(F));else if(F.startsWith("{")){if(H[B])G.push(H[B])}else{let W=b(F,!1,!1,0);if(W!=="unknown")G.push(W)}}if(G.length>0)R=`[${G.join(", ")}]`}if(Y)return`readonly [${$.join(", ")}]`;let O=new Set,K=[],q=!0;for(let G of $){if(!O.has(G))O.add(G),K.push(G);if(q){if(!(S(G)||G==="true"||G==="false"||G.charCodeAt(0)===34&&G.charCodeAt(G.length-1)===34||G.charCodeAt(0)===39&&G.charCodeAt(G.length-1)===39))q=!1}}if(q&&$.length<=10)return`readonly [${$.join(", ")}]`;if(K.length===1)return`${K[0]}[]`;return`(${K.join(" | ")})[]`}function w(J){let Y=[],X=0,Q=0,z=!1,L=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(!z&&(H===34||H===39||H===96))z=!0,L=H;else if(z&&H===L&&($===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 O=J.substring(X,$).trim();if(O)Y.push(O);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 L=J.charCodeAt(z);if(Y){if(L===92){z++;continue}if(L===X)Y=!1;continue}if(L===34||L===39||L===96){Y=!0,X=L;continue}if(L===61&&z+1<Q&&J.charCodeAt(z+1)===62)return!1;if(L>=97&&L<=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=r(Q),L=[],Z=E&&!Y,$=[];for(let[H,O]of z){let K=R;R=null;let q,G=O.trim();if(zz(G))q=Jz(H,G);else if(q=b(O,Y,!1,X+1),q.includes("=>")||q.includes("function")||q.includes("async"))q=i(q);let B=R;R=K;let F=O.trim(),W=t(H);if(W){let N=e(W.kind,W.name,q);if(N){L.push(N);continue}}if(!Y&&m(q)&&x(F))L.push(`/** @defaultValue ${F} */
6
+ ${H}: ${q}`);else L.push(`${H}: ${q}`);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(B)$.push(`${N}: ${B}`)}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,O=`{ ${$.join(", ")} }`;if(O.length<=80)R=O;else{let K=" ".repeat((H+1)*2),q=" ".repeat(H*2);R=`{
7
+ ${K}${$.join(`,
8
+ ${K}`)}
9
+ ${q}}`}}return`{
10
+ ${L.join(`;
11
+ `)}
12
+ }`}function i(J){let X=J.split(`
13
+ `).map((K)=>C(K)).join(`
14
+ `),Q=X.indexOf("async");if(Q!==-1){let K=Q>0?X.charCodeAt(Q-1):32,q=Q+5<X.length?X.charCodeAt(Q+5):32;if(!k(K)&&!k(q))X=(X.slice(0,Q)+X.slice(Q+5)).trim()}let z=X.indexOf("(");if(z!==-1){let K=A(X,z,"(",")");if(K!==-1){let q=X.slice(z,K+1),G=P(q);X=X.slice(0,z)+G+X.slice(K+1)}}let L=X.length,Z="",$=[],H=!1,O=!1;for(let K=0;K<L;K++){let q=X.charCodeAt(K);if(q===123||q===40)$.push(q);else if(q===125||q===41)$.pop();if(q<=32){if(H=!0,q===10||q===13)O=!0;continue}if(H&&Z.length>0){let B=($.length>0?$[$.length-1]:0)===123;if(O&&B){let F=Z.charCodeAt(Z.length-1),W=F===59||F===44||F===123||q===125,N=Z.length>=2&&Z.charCodeAt(Z.length-1)===47&&Z.charCodeAt(Z.length-2)===42;if(!W&&!N)Z+="; ";else Z+=" "}else Z+=" "}H=!1,O=!1,Z+=X[K]}return Z.trim()}function k(J){return J>=97&&J<=122||J>=65&&J<=90||J>=48&&J<=57||J===95||J===36}function P(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 L=!1;{let F=0;for(let W=0;W<z.length;W++){let N=z.charCodeAt(W);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=W>0?z.charCodeAt(W-1):0,M=W+1<z.length?z.charCodeAt(W+1):0;if(U!==61&&U!==33&&U!==60&&U!==62&&M!==61&&M!==62){L=!0;break}}}}if(!L)return Y;let Z=[],$=[],H=0,O=0,K=!1,q=0;for(let F=0;F<=z.length;F++){if(F===z.length){Z.push(z.slice(H));break}let W=z.charCodeAt(F);if(K){if(W===92){F++;continue}if(W===q)K=!1;continue}if(W===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(W===39||W===34||W===96){K=!0,q=W;continue}if(W===40||W===60||W===91||W===123)O++;else if(W===41||W===62||W===93||W===125)O--;else if(W===44&&O===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 G=[];for(let F of Z){let W=F.trim();if(!W){G.push(F);continue}if(W.startsWith("//"))continue;let N=C(W),U=F.slice(0,F.length-F.trimStart().length);G.push(U+n(N))}let B=G[0]||"";for(let F=1;F<G.length;F++)B+=($[F-1]||", ")+G[F];return Q?`(${B})`:B}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,L=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(z){if(H===92){$++;continue}if(H===L)z=!1;continue}if(H===47&&$+1<J.length){let O=J.charCodeAt($+1);if(O===42){$+=2;while($+1<J.length&&!(J.charCodeAt($)===42&&J.charCodeAt($+1)===47))$++;$++;continue}if(O===47){while($<J.length&&J.charCodeAt($)!==10)$++;continue}}if(H===39||H===34||H===96){z=!0,L=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(),O=Z&&!$.endsWith("?")?"?":"";return`${$}${O}: ${H}`}else if(X!==-1){let $=J.slice(0,X).trim(),H=!$.endsWith("?")?"?":"",O=J.slice(X+1).trim(),K="unknown";if(O==="true"||O==="false")K="boolean";else if(/^-?\d+(\.\d+)?$/.test(O))K="number";else if(O.startsWith("'")&&O.endsWith("'")||O.startsWith('"')&&O.endsWith('"'))K="string";else if(O.startsWith("["))K="unknown[]";else if(O.startsWith("{"))K="Record<string, unknown>";return`${$}${H}: ${K}`}return J}function a(J){let Y=0,X=J.length;while(Y<X){while(Y<X&&(J.charCodeAt(Y)===32||J.charCodeAt(Y)===9||J.charCodeAt(Y)===10||J.charCodeAt(Y)===13))Y++;if(Y+1<X&&J.charCodeAt(Y)===47&&J.charCodeAt(Y+1)===42){Y+=2;while(Y+1<X&&!(J.charCodeAt(Y)===42&&J.charCodeAt(Y+1)===47))Y++;Y+=2;continue}break}return Y}function r(J){let Y=[],X="",Q="",z=0,L=!1,Z="",$=!0,H=!1,O=0,K=!1,q=!1;for(let G=0;G<J.length;G++){let B=J.charCodeAt(G),F=G>0?J.charCodeAt(G-1):0,W=G<J.length-1?J.charCodeAt(G+1):0;if(!L&&!H&&B===47&&W===47){G+=2;while(G<J.length&&J.charCodeAt(G)!==10)G++;continue}if(!L&&!H&&B===47&&W===42){H=!0,O=1,X+="/*",G++;continue}else if(H&&B===42&&W===47){if(O--,X+="*/",G++,O===0)H=!1;continue}else if(H&&B===47&&W===42){O++,X+="/*",G++;continue}let N=J[G];if(!L&&(B===34||B===39||B===96))L=!0,Z=N,X+=N;else if(L&&N===Z&&F!==92)L=!1,X+=N;else if(!L&&!H)if(B===40&&z===0&&$){Q=X.trim();let U=a(Q),M=U>0?Q.slice(0,U):"",V=Q.slice(U),j="";if(V.startsWith("async ")||V.startsWith("async\t")||V.startsWith(`async
15
+ `))V=V.slice(6).trimStart(),j="async ";if(V.startsWith("*"))V=V.slice(1).trimStart(),j+="*";Q=M+V,X=j+N,$=!1,K=!0,q=!1,z=1}else if(B===123||B===91||B===40){if(z++,X+=N,q&&B===123)q=!1}else if(B===125||B===93||B===41){if(z--,X+=N,K){if(B===41&&z===0&&!q)q=!0;else if(B===125&&z===0)K=!1,q=!1}}else if(B===58&&z===0&&$)Q=X.trim(),X="",$=!1;else if(B===44&&z===0&&!q){if(Q&&X.trim()){let U=X.trim();Y.push([Q,U])}X="",Q="",$=!0}else X+=N;else X+=N}if(Q&&X.trim()){let G=X.trim();Y.push([Q,G])}return Y}function t(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 e(J,Y,X){let Q=X.trim();if(Q.charCodeAt(0)!==40)return null;let z=A(Q,0,"(",")");if(z===-1)return null;let L=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}(${L})`}function zz(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 L=Y.slice(Q+1).trimStart();if(L.startsWith("{"))return!0;if(L.startsWith(":")){let Z=0;for(let $=0;$<L.length;$++){let H=L.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<L.length&&L.charCodeAt($+1)===62)return!1;else if(Z===0&&H===123)return!0}}return!1}}}return!1}function Jz(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 L="";if(X.charCodeAt(0)===60){let G=0,B=-1;for(let F=0;F<X.length;F++)if(X.charCodeAt(F)===60)G++;else if(X.charCodeAt(F)===62){if(G--,G===0){B=F;break}}if(B!==-1)L=X.slice(0,B+1),X=X.slice(B+1).trimStart()}let Z=X.indexOf("("),$=A(X,Z,"(",")");if(Z===-1||$===-1)return"() => unknown";let H=X.slice(Z,$+1),O="unknown",K=X.slice($+1).trimStart();if(K.charCodeAt(0)===58){let G=K.slice(1),B=0,F=-1,W=!1;for(let N=0;N<G.length;N++){let U=G.charCodeAt(N);if(U===40||U===91)B++;else if(U===41||U===93)B--;else if(U===123&&B===0){F=N;break}else if(U===61&&N+1<G.length&&G.charCodeAt(N+1)===62&&B===0){F=N,W=!0;break}}if(F!==-1)O=G.slice(0,F).trim();else O=G.trim()}if(O==="unknown"){if(Q&&z)O="AsyncGenerator<unknown, void, unknown>";else if(z)O="Generator<unknown, void, unknown>";else if(Q)O="Promise<void>"}else if(Q&&!O.startsWith("Promise<")&&!O.startsWith("AsyncGenerator<"))O=`Promise<${O}>`;let q=P(H);return`${L}${q} => ${O}`}function A(J,Y,X,Q){let z=0;for(let L=Y;L<J.length;L++)if(J[L]===X)z++;else if(J[L]===Q){if(z--,z===0)return L}return-1}function Xz(J){let Y=0,X=0,Q=!1,z="";for(let L=0;L<J.length-1;L++){let Z=J[L],$=J[L+1],H=L>0?J[L-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 L}}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(),O=Z.substring($+2).trim();if(H=P(H),H==="()"||H==="")H="()";else if(!H.startsWith("("))H=`(${H})`;let K="unknown";if(O.startsWith("{"))K="unknown";else K=b(O,Q,!1,X+1);let q=`${H} => Promise<${K}>`;return Y?`(${q})`:q}if(z.includes("=>")){let Z="",$=z;if(z.startsWith("<")){let W=A(z,0,"<",">");if(W!==-1)Z=z.substring(0,W+1),$=z.substring(W+1).trim()}let H=Xz($);if(H===-1)return Y?"(() => unknown)":"() => unknown";let O=$.substring(0,H).trim(),K=$.substring(H+2).trim(),q="",G=O.lastIndexOf("):");if(G!==-1){let W=O.substring(G+2).trim();if(W&&!W.includes("=>")&&!W.includes("="))q=W,O=O.substring(0,G+1)}if(O=P(O),O==="()"||O==="")O="()";else if(!O.startsWith("("))O=`(${O})`;let B="unknown";if(q)B=q;else if(K.startsWith("{"))B="unknown";else if(K.includes("=>")){let W=K.trimStart(),N=W.indexOf("("),U=N!==-1?A(W,N,"(",")"):-1,M=U!==-1?W.indexOf("=>",U):-1;if(N===0&&U!==-1&&M!==-1){let V=W.substring(N+1,U).trim(),j=P(V);if(Z.includes("T")&&j.includes("T"))B=`(${j}) => T`;else B=`(${j}) => any`}else B="any"}else if(Y)B="unknown";else B=b(K,Q,!1,X+1);let F=`${Z}${O} => ${B}`;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 O="";if(Z<$&&z.charCodeAt(Z)===60){let G=Z,B=1;Z++;while(Z<$&&B>0){let F=z.charCodeAt(Z);if(F===60)B++;else if(F===62)B--;Z++}O=z.substring(G,Z);while(Z<$&&z.charCodeAt(Z)<=32)Z++}let K=z.indexOf("(",Z);if(K!==-1){let G=1,B=K+1;while(B<$&&G>0){let U=z.charCodeAt(B);if(U===40)G++;else if(U===41)G--;B++}let F=z.substring(K+1,B-1).trim(),W=F?`(${F})`:"()";if(H){let U=z.substring(B).trim(),M=U.indexOf("Generator<");if(M!==-1){let j=M+10,T=U.indexOf(">",j);if(T!==-1){let u=U.substring(j,T),v=`${O}${W} => Generator<${u}>`;return Y?`(${v})`:v}}let V=`${O}${W} => Generator<any, any, any>`;return Y?`(${V})`:V}let N=`${O}${W} => unknown`;return Y?`(${N})`:N}let q="(...args: any[]) => unknown";return Y?`(${q})`:q}if(z.includes("=>")&&z.includes("(")&&z.includes(")")){if(z.length>100||D(z,"=>")>2){let Z="";if(z.charCodeAt(0)===60){let q=A(z,0,"<",">");if(q!==-1)Z=z.substring(0,q+1)}let $=z.indexOf("("),H=$!==-1?A(z,$,"(",")"):-1,O=$!==-1&&H!==-1?z.substring($,H+1):"(...args: any[])";O=P(O);let K=`${Z}${O} => any`;return Y?`(${K})`:K}return Y?`(${z})`:z}let L="() => unknown";return Y?`(${L})`:L}function Fz(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 Lz(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 Yz=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Zz=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,$z=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function Gz(J){let Y=[],X=0;for(let Q=0;Q<=J.length;Q++)if(Q===J.length||J[Q]===`
16
+ `){let z=X,L=Q;while(z<L&&(J[z]===" "||J[z]==="\t"||J[z]==="\r"))z++;while(L>z&&(J[L-1]===" "||J[L-1]==="\t"||J[L-1]==="\r"))L--;let Z=J.slice(z,L);if(X=Q+1,Z.startsWith("///")){if(Z.indexOf("<")===-1)continue;if(Yz.test(Z)||Zz.test(Z)||$z.test(Z))Y.push(Z)}else if(Z===""||Z.startsWith("//"))continue;else break}return Y}
17
+ export{Qz as Dc,Hz as Ec,b as Fc,l as Gc,I as Hc,w as Ic,s as Jc,A as Kc,y as Lc,Fz as Mc,Lz as Nc,Gz as Oc};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{oc as J}from"./chunk-1z1w3s0k.js";var S=typeof globalThis.Bun?.hash==="function";function z(B){if(S)return Bun.hash(B);let g=0;for(let T=0;T<B.length;T++){let p=B.charCodeAt(T);g=(g<<5)-g+p,g=g&g}return g}var U=100,G=0,f=new Map;function $(B,g,T=!0,p=!1){let b=z(B),j=`${g}:${T?1:0}:${p?1:0}`,w=f.get(j);if(w&&w.contentHash===b)return w.lastAccess=++G,w.declarations;let q=J(B,g,T,p);if(f.set(j,{declarations:q,contentHash:b,lastAccess:++G}),f.size>U){let Q=Math.max(1,Math.ceil(f.size*0.1)),x=[];for(let[u,F]of f)x.push([u,F.lastAccess]);x.sort((u,F)=>u[1]-F[1]);for(let u=0;u<Q&&u<x.length;u++)f.delete(x[u][0])}return q}function v(){f.clear()}
2
+ import{oc as J}from"./chunk-4mtbtmee.js";var S=typeof globalThis.Bun?.hash==="function";function z(B){if(S)return Bun.hash(B);let g=0;for(let T=0;T<B.length;T++){let p=B.charCodeAt(T);g=(g<<5)-g+p,g=g&g}return g}var U=100,G=0,f=new Map;function $(B,g,T=!0,p=!1){let b=z(B),j=`${g}:${T?1:0}:${p?1:0}`,w=f.get(j);if(w&&w.contentHash===b)return w.lastAccess=++G,w.declarations;let q=J(B,g,T,p);if(f.set(j,{declarations:q,contentHash:b,lastAccess:++G}),f.size>U){let Q=Math.max(1,Math.ceil(f.size*0.1)),x=[];for(let[u,F]of f)x.push([u,F.lastAccess]);x.sort((u,F)=>u[1]-F[1]);for(let u=0;u<Q&&u<x.length;u++)f.delete(x[u][0])}return q}function v(){f.clear()}
3
3
  export{z as lc,$ as mc,v as nc};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{tb as I}from"./chunk-7zsd1qqw.js";class H{options;generateOptions;constructor(j={}){let{onCompile:F=!1,afterEmit:w=!0,onWatchRun:q=!1,onGenerated:z,onError:B,...J}=j;this.options={onCompile:F,afterEmit:w,onWatchRun:q,onGenerated:z,onError:B},this.generateOptions=J}apply(j){if(!this.generateOptions.outdir&&j.options.output?.path)this.generateOptions.outdir=j.options.output.path;if(!this.generateOptions.cwd&&j.options.context)this.generateOptions.cwd=j.options.context;if(!this.generateOptions.entrypoints&&j.options.entry){let w=j.options.entry;if(typeof w==="string")this.generateOptions.entrypoints=[w];else if(Array.isArray(w))this.generateOptions.entrypoints=w;else if(typeof w==="object"&&w!==null){let q=[];for(let z of Object.values(w))if(typeof z==="string")q.push(z);else if(Array.isArray(z))q.push(...z.filter((B)=>typeof B==="string"));else if(typeof z==="object"&&z!==null&&"import"in z){let B=z.import;if(typeof B==="string")q.push(B);else if(Array.isArray(B))q.push(...B)}if(q.length>0)this.generateOptions.entrypoints=q}}if(this.options.onCompile)j.hooks.compile.tap("DtsxWebpackPlugin",()=>{this.runGenerate()});if(this.options.afterEmit)j.hooks.afterEmit.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()});if(this.options.onWatchRun)j.hooks.watchRun.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()})}async runGenerate(){try{let j=await I(this.generateOptions);this.options.onGenerated?.(j)}catch(j){let F=j instanceof Error?j:Error(String(j));if(this.options.onError?.(F),!this.options.onError)console.error("[dtsx] Generation failed:",F.message)}}}function K(j={}){return new H(j)}var M=K,Q=H;
2
+ import{tb as I}from"./chunk-af12rv0y.js";class H{options;generateOptions;constructor(j={}){let{onCompile:F=!1,afterEmit:w=!0,onWatchRun:q=!1,onGenerated:z,onError:B,...J}=j;this.options={onCompile:F,afterEmit:w,onWatchRun:q,onGenerated:z,onError:B},this.generateOptions=J}apply(j){if(!this.generateOptions.outdir&&j.options.output?.path)this.generateOptions.outdir=j.options.output.path;if(!this.generateOptions.cwd&&j.options.context)this.generateOptions.cwd=j.options.context;if(!this.generateOptions.entrypoints&&j.options.entry){let w=j.options.entry;if(typeof w==="string")this.generateOptions.entrypoints=[w];else if(Array.isArray(w))this.generateOptions.entrypoints=w;else if(typeof w==="object"&&w!==null){let q=[];for(let z of Object.values(w))if(typeof z==="string")q.push(z);else if(Array.isArray(z))q.push(...z.filter((B)=>typeof B==="string"));else if(typeof z==="object"&&z!==null&&"import"in z){let B=z.import;if(typeof B==="string")q.push(B);else if(Array.isArray(B))q.push(...B)}if(q.length>0)this.generateOptions.entrypoints=q}}if(this.options.onCompile)j.hooks.compile.tap("DtsxWebpackPlugin",()=>{this.runGenerate()});if(this.options.afterEmit)j.hooks.afterEmit.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()});if(this.options.onWatchRun)j.hooks.watchRun.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()})}async runGenerate(){try{let j=await I(this.generateOptions);this.options.onGenerated?.(j)}catch(j){let F=j instanceof Error?j:Error(String(j));if(this.options.onError?.(F),!this.options.onError)console.error("[dtsx] Generation failed:",F.message)}}}function K(j={}){return new H(j)}var M=K,Q=H;
3
3
  export{H as qa,K as ra,M as sa,Q as ta};
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-fg4cjy7w.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-s30jnjb4.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-dv8haj2p.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-9ycwkhxh.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-7zsd1qqw.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-69rnp3hs.js";import{hc as g0}from"../chunk-2n1bbm2c.js";import{ic as h$,jc as g$}from"../chunk-kwmhsx3n.js";import{lc as KZ}from"../chunk-jjwwkrfk.js";import"../chunk-1z1w3s0k.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-7pwy4m0c.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-4jw8qvts.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(`
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-ww6wqbda.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-af12rv0y.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(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{fa as a,ga as b,ha as c}from"../../chunk-gg6xh82k.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{a as dts,c as default,b as bunDts};
2
+ import{fa as a,ga as b,ha as c}from"../../chunk-9asxz2at.js";import"../../chunk-af12rv0y.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-ezrgnecm.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 esbuildDts,a as dtsx,c as dts,d as default};
2
+ import{ia as a,ja as b,ka as c,la as d}from"../../chunk-wzbwr7a3.js";import"../../chunk-af12rv0y.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-m68323h2.js";import{fa as t}from"../../chunk-gg6xh82k.js";import{ia as i,ka as p}from"../../chunk-ezrgnecm.js";import{ma as e,oa as u}from"../../chunk-nwvqfthk.js";import{qa as l,ra as a,sa as n}from"../../chunk-mr4jjsps.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{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};
2
+ import{ca as s}from"../../chunk-4zdjnqrz.js";import{fa as t}from"../../chunk-9asxz2at.js";import{ia as i,ka as p}from"../../chunk-wzbwr7a3.js";import{ma as e,oa as u}from"../../chunk-aaba58v4.js";import{qa as l,ra as a,sa as n}from"../../chunk-yzhdn85p.js";import"../../chunk-af12rv0y.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};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ma as a,na as b,oa as c,pa as d}from"../../chunk-nwvqfthk.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 tsupDts,a as dtsxPlugin,c as dts,d as default};
2
+ import{ma as a,na as b,oa as c,pa as d}from"../../chunk-aaba58v4.js";import"../../chunk-af12rv0y.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};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ca as a,da as b,ea as c}from"../../chunk-m68323h2.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 viteDts,a as dts,c as default};
2
+ import{ca as a,da as b,ea as c}from"../../chunk-4zdjnqrz.js";import"../../chunk-af12rv0y.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-mr4jjsps.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 dtsxWebpack,c as dts,d as default,a as DtsxWebpackPlugin};
2
+ import{qa as a,ra as b,sa as c,ta as d}from"../../chunk-yzhdn85p.js";import"../../chunk-af12rv0y.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/dtsx",
3
3
  "type": "module",
4
- "version": "0.9.19",
4
+ "version": "0.9.21",
5
5
  "description": "A modern, fast .d.ts generation tool, powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{oc as a}from"./chunk-1z1w3s0k.js";import"./chunk-mcdb3q06.js";export{a as scanDeclarations};
@@ -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};
@@ -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};
@@ -1,80 +0,0 @@
1
- // @bun
2
- import{ec as l}from"./chunk-69rnp3hs.js";import{hc as CY}from"./chunk-2n1bbm2c.js";import{lc as UJ}from"./chunk-jjwwkrfk.js";import{Cc as iJ}from"./chunk-7pwy4m0c.js";import{Uc as f}from"./chunk-a3txc27m.js";import{Wc as K,Yc as r}from"./chunk-gssantc8.js";import{bd as xY,dd as AY}from"./chunk-mcdb3q06.js";var{Glob:oJ}=globalThis.Bun;import{mkdir as o}from"fs/promises";import{availableParallelism as dY}from"os";import{dirname as u,relative as v,resolve as x}from"path";import{existsSync as ZJ,mkdirSync as JY,readFileSync as YY,writeFileSync as $Y}from"fs";import{dirname as ZY,relative as QY,resolve as UY}from"path";async function TJ(J,Y,$){let Z=new Map,Q=[],U=new Set,X=0,H=0,j=0,G=[];for(let q of J){let B=Y.get(q);if(!B)continue;G.push({file:q,decls:l(B,q,$.keepComments)})}for(let{file:q,decls:B}of G){X+=B.length;for(let k of B)if(k.kind==="import"){H++;let R=k.source||"";if(R.startsWith("."))continue;if(!Z.has(R))Z.set(R,{source:R,specifiers:new Map,isTypeOnly:k.isTypeOnly||!1,isSideEffect:k.isSideEffect||!1});let L=Z.get(R);if(k.specifiers)for(let w of k.specifiers){let S=w.alias||w.name;if(!L.specifiers.has(S))L.specifiers.set(S,{name:w.name,alias:w.alias,isType:w.isType||!1})}if(!k.isTypeOnly)L.isTypeOnly=!1}else if(k.isExported||k.kind==="export"){if(j++,k.kind==="export"&&k.source&&(k.source.startsWith(".")||k.source.startsWith("/")))continue;if(k.name&&U.has(k.name))continue;if(k.name)U.add(k.name);Q.push({declaration:k,file:q})}}let z=[];z.push("/**"),z.push(" * Bundled TypeScript declarations"),z.push(` * Generated from ${J.length} source files`),z.push(" */"),z.push("");let A=$.importOrder||["bun"],N=Array.from(Z.values()),_=Array(N.length);for(let q=0;q<N.length;q++){let B=N[q].source,k=A.length;for(let R=0;R<A.length;R++)if(B.startsWith(A[R])){k=R;break}_[q]=k}let T=N.map((q,B)=>B);T.sort((q,B)=>{let k=_[q],R=_[B];if(k!==R)return k-R;return N[q].source.localeCompare(N[B].source)});let V=T.map((q)=>N[q]);for(let q of V)if(q.isSideEffect)z.push(`import '${q.source}';`);else if(q.specifiers.size>0){let k=Array.from(q.specifiers.values()).map((L)=>{let w=L.isType?"type ":"";return L.alias?`${w}${L.name} as ${L.alias}`:`${w}${L.name}`}),R=q.isTypeOnly?"type ":"";z.push(`import ${R}{ ${k.join(", ")} } from '${q.source}';`)}if(V.length>0)z.push("");let W=new Map;for(let{declaration:q,file:B}of Q){if(!W.has(B))W.set(B,[]);W.get(B).push(q)}for(let[q,B]of W){let k=QY($.cwd,q);z.push(`// From: ${k}`);for(let R of B){if($.keepComments&&R.leadingComments)for(let L of R.leadingComments)z.push(L);z.push(RJ(R))}z.push("")}let O=z.join(`
3
- `);return{content:O,files:J,declarationCount:X,importCount:H,exportCount:j,size:Buffer.byteLength(O,"utf8"),warnings:[]}}function RJ(J){if(J.text){let $=J.text.trim();if(J.isExported&&!$.startsWith("export"))$=`export ${$}`;if(!$.endsWith(";")&&!$.endsWith("}"))$+=";";return $}let Y=[];if(J.isExported)Y.push("export");if(J.isDefault)Y.push("default");switch(J.kind){case"function":if(Y.push("declare function"),Y.push(J.name),J.generics)Y.push(J.generics);if(Y.push(`(${XY(J.parameters)})`),J.returnType)Y.push(`: ${J.returnType}`);break;case"variable":if(Y.push("declare const"),Y.push(J.name),J.typeAnnotation)Y.push(`: ${J.typeAnnotation}`);break;case"interface":if(Y.push("interface"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${$.name}${$.typeAnnotation?`: ${$.typeAnnotation}`:""};`);Y.push("}");break;case"type":if(Y.push("type"),Y.push(J.name),J.generics)Y.push(J.generics);Y.push("="),Y.push(J.typeAnnotation||"unknown");break;case"class":if(Y.push("declare class"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(J.implements&&J.implements.length>0)Y.push(`implements ${J.implements.join(", ")}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${RJ($)}`);Y.push("}");break;case"enum":if(Y.push("declare enum"),Y.push(J.name),Y.push("{"),J.members){let $=J.members.map((Z)=>Z.value!==void 0?`${Z.name} = ${Z.value}`:Z.name);Y.push(` ${$.join(`,
4
- `)}`)}Y.push("}");break;default:return J.text||""}return Y.join(" ")}function XY(J){if(!J||J.length===0)return"";return J.map((Y)=>{let $="";if(Y.rest)$+="...";if($+=Y.name,Y.optional)$+="?";if(Y.type)$+=`: ${Y.type}`;if(Y.defaultValue)$+=` = ${Y.defaultValue}`;return $}).join(", ")}async function LJ(J,Y={}){let $=[],Z=new Map,Q=[],U=[],X=new Set,H=0,j=0,G=0;for(let _ of J){if(!ZJ(_)){$.push(`File not found: ${_}`);continue}let T=YY(_,"utf-8");U.push(_);let V=T.split(`
5
- `),W=[],O=0,q=!1;for(let B of V){let k=B.trim();if(!k&&!q)continue;if(k.startsWith("import ")){j++;let L=k.match(/import\s+(type\s+)?(?:\{([^}]+)\}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/);if(L){let[,w,S,M,F,D]=L;if(Y.externals?.some((C)=>D.startsWith(C))){Q.push(k);continue}if(D.startsWith("."))continue;if(!Z.has(D))Z.set(D,{source:D,specifiers:new Map,isTypeOnly:!!w,isSideEffect:!1});let p=Z.get(D);if(S){let C=S.split(",").map((e)=>e.trim());for(let e of C){let[JJ,YJ]=e.split(/\s+as\s+/).map((eJ)=>eJ.trim()),NJ=JJ.startsWith("type "),$J=NJ?JJ.replace("type ",""):JJ;p.specifiers.set(YJ||$J,{name:$J,alias:YJ!==$J?YJ:void 0,isType:NJ})}}if(!w)p.isTypeOnly=!1}continue}if(/^(export\s+)?(declare\s+)?(interface|type|class|function|const|let|var|enum|namespace|module)\s/.test(k)){if(q=!0,W=[B],O=(B.match(/\{/g)||[]).length-(B.match(/\}/g)||[]).length,O===0&&(k.endsWith(";")||!k.includes("{"))){let L=c(k);if(!X.has(L)||!Y.mergeDuplicates){if(X.add(L),Q.push(B),H++,k.startsWith("export"))G++}q=!1,W=[]}}else if(q){if(W.push(B),O+=(B.match(/\{/g)||[]).length-(B.match(/\}/g)||[]).length,O<=0){let L=W.join(`
6
- `),w=c(W[0]);if(!X.has(w)||!Y.mergeDuplicates){if(X.add(w),Q.push(L),H++,W[0].trim().startsWith("export"))G++}q=!1,W=[]}}else if(k.startsWith("export ")&&!k.includes("declare"))Q.push(B),G++}}let z=[];if(Y.banner)z.push(Y.banner),z.push("");if(Y.includeReferences&&Y.references){for(let _ of Y.references)z.push(`/// <reference types="${_}" />`);z.push("")}let A=Array.from(Z.values()).sort((_,T)=>_.source.localeCompare(T.source));for(let _ of A)if(_.specifiers.size>0){let V=Array.from(_.specifiers.values()).map((O)=>{let q=O.isType?"type ":"";return O.alias?`${q}${O.name} as ${O.alias}`:`${q}${O.name}`}),W=_.isTypeOnly?"type ":"";z.push(`import ${W}{ ${V.join(", ")} } from '${_.source}';`)}if(A.length>0)z.push("");if(Y.ambient&&Y.moduleName){z.push(`declare module '${Y.moduleName}' {`);for(let _ of Q){let T=_.split(`
7
- `).map((V)=>` ${V.replace(/^(\s*)(export\s+)?declare\s+/,"$1$2")}`).join(`
8
- `);z.push(T)}z.push("}")}else{if(Y.sortDeclarations)Q.sort((_,T)=>{let V=c(_),W=c(T);return V.localeCompare(W)});for(let _ of Q)z.push(_)}if(Y.footer)z.push(""),z.push(Y.footer);let N=z.join(`
9
- `);return{content:N,files:U,declarationCount:H,importCount:j,exportCount:G,size:Buffer.byteLength(N,"utf-8"),warnings:$}}function c(J){let Y=J.match(/(interface|type|class|function|const|let|var|enum|namespace|module)\s+(\w+)/);return Y?`${Y[1]}:${Y[2]}`:J.trim()}async function qY(J,Y,$={}){let Z=await LJ(J,$),Q=ZY(Y);if(!ZJ(Q))JY(Q,{recursive:!0});return $Y(Y,Z.content),Z}function iY(J={}){return{bundle:(Y)=>LJ(Y,J),bundleAndWrite:(Y,$)=>qY(Y,$,{...J,output:$})}}async function oY(J,Y=process.cwd()){let $=Array.isArray(J)?J:[J],Z=[];for(let Q of $){if(Q.includes("*"))continue;let U=UY(Y,Q);if(ZJ(U))Z.push(U)}return Z}import{existsSync as s,mkdirSync as zY,readFileSync as XJ,rmSync as VY,statSync as MJ,writeFileSync as wJ}from"fs";import{join as SJ,relative as a,resolve as jY}from"path";var QJ=1,qJ=".dtsx-cache",GY="manifest.json";class zJ{cacheDir;manifestPath;manifest=null;configHash;constructor(J){this.cacheDir=jY(J.cwd,qJ),this.manifestPath=SJ(this.cacheDir,GY),this.configHash=this.hashConfig(J)}hashConfig(J){let Y={keepComments:J.keepComments,importOrder:J.importOrder,outputStructure:J.outputStructure};return String(UJ(JSON.stringify(Y)))}hashString(J){return String(UJ(J))}load(){try{if(!s(this.manifestPath))return!1;let J=XJ(this.manifestPath,"utf-8"),Y=JSON.parse(J);if(Y.version!==QJ)return!1;if(Y.configHash!==this.configHash)return!1;return this.manifest=Y,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:QJ,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!s(this.cacheDir))zY(this.cacheDir,{recursive:!0});wJ(this.manifestPath,JSON.stringify(this.manifest,null,2))}needsRegeneration(J,Y){return this.getCachedIfValid(J,Y)===null}getCached(J,Y){return this.getCachedIfValid(J,Y)}getCachedIfValid(J,Y){if(!this.manifest)return null;let $=a(Y,J),Z=this.manifest.entries[$];if(!Z)return null;try{let U=MJ(J).mtimeMs;if(U>Z.sourceMtime){let X=XJ(J,"utf-8");if(this.hashString(X)!==Z.sourceHash)return null;Z.sourceMtime=U}return Z.dtsContent}catch{return null}}update(J,Y,$,Z){if(!this.manifest)this.manifest={version:QJ,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let Q=a(Z,J),U;try{U=MJ(J).mtimeMs}catch{U=Date.now()}this.manifest.entries[Q]={sourcePath:Q,sourceHash:this.hashString(Y),sourceMtime:U,dtsContent:$,dtsHash:this.hashString($),generatedAt:Date.now(),configHash:this.configHash}}remove(J,Y){if(!this.manifest)return;let $=a(Y,J);delete this.manifest.entries[$]}clear(){this.manifest=null;try{if(s(this.manifestPath))VY(this.cacheDir,{recursive:!0,force:!0})}catch{}}getStats(){if(!this.manifest)return{entries:0,size:0};let J=Object.keys(this.manifest.entries).length,Y=0;for(let $ of Object.values(this.manifest.entries))Y+=$.dtsContent.length;return{entries:J,size:Y}}prune(J,Y){if(!this.manifest)return 0;let $=0,Z=new Set(Array.from(J).map((Q)=>a(Y,Q)));for(let Q of Object.keys(this.manifest.entries))if(!Z.has(Q))delete this.manifest.entries[Q],$++;return $}}function FJ(J){let Y=SJ(J,".gitignore");try{let $="";if(s(Y))$=XJ(Y,"utf-8");if(!$.includes(qJ)){let Z=`${$.trimEnd()}
10
-
11
- # dtsx cache
12
- ${qJ}/
13
- `;wJ(Y,Z)}}catch{}}import{spawn as HY}from"child_process";import{readFile as VJ,stat as DJ,writeFile as WY}from"fs/promises";var I=typeof globalThis.Bun<"u",Q0=!I&&typeof process<"u"&&!!process.versions?.node,U0=I?"bun":"node";class vJ{name;_size=-1;constructor(J){this.name=J}async exists(){try{return await DJ(this.name),!0}catch{return!1}}async text(){return VJ(this.name,"utf-8")}async arrayBuffer(){let J=await VJ(this.name);return J.buffer.slice(J.byteOffset,J.byteOffset+J.byteLength)}get size(){if(this._size===-1)return-1;return this._size}}class IJ{pid;stdout;stderr;stdin;exited;process;constructor(J){this.process=J,this.pid=J.pid??0,this.stdout=J.stdout,this.stderr=J.stderr,this.stdin=J.stdin,this.exited=new Promise((Y)=>{J.on("exit",($)=>{Y($??0)}),J.on("error",()=>{Y(1)})})}kill(J){this.process.kill(J)}ref(){this.process.ref()}unref(){this.process.unref()}}function EJ(J){if(I)return globalThis.Bun.file(J);return new vJ(J)}async function jJ(J,Y){if(I)return globalThis.Bun.write(J,Y);let $=typeof Y==="string"?Y:Y instanceof ArrayBuffer?Buffer.from(Y):Y;return await WY(J,$),typeof Y==="string"?Buffer.byteLength(Y):Y.byteLength}function yJ(J,Y={}){if(I)return globalThis.Bun.spawn(J,Y);let $=Array.isArray(J)?J:[J],[Z,...Q]=$,U={cwd:Y.cwd,env:Y.env,stdio:[Y.stdin??"pipe",Y.stdout??"pipe",Y.stderr??"pipe"]},X=HY(Z,Q,U);return new IJ(X)}async function y(J){if(I)return globalThis.Bun.file(J).text();return VJ(J,"utf-8")}async function X0(J){if(I)return globalThis.Bun.file(J).exists();try{return await DJ(J),!0}catch{return!1}}async function q0(J,Y){await jJ(J,Y)}function z0(){if(I)return{name:"bun",version:globalThis.Bun.version,isBun:!0,isNode:!1};return{name:"node",version:process.versions.node,isBun:!1,isNode:!0}}var m={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class E extends Error{code;context;constructor(J,Y="UNKNOWN_ERROR",$){super(J);if(this.name="DtsxError",this.code=Y,this.context=$,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let J=`${this.name} [${this.code}]: ${this.message}`;if(this.context)J+=`
14
- Context: ${JSON.stringify(this.context,null,2)}`;return J}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class bJ extends E{filePath;line;column;constructor(J,Y,$){super(J,"PARSE_ERROR",{filePath:Y,line:$?.line,column:$?.column});if(this.name="ParseError",this.filePath=Y,this.line=$?.line,this.column=$?.column,$?.cause)this.cause=$.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class KY extends E{filePath;declarationKind;constructor(J,Y,$,Z){super(J,"EXTRACTION_ERROR",{filePath:Y,declarationKind:$});if(this.name="ExtractionError",this.filePath=Y,this.declarationKind=$,Z)this.cause=Z}}class _Y extends E{declarationName;constructor(J,Y,$){super(J,"PROCESSING_ERROR",{declarationName:Y});if(this.name="ProcessingError",this.declarationName=Y,$)this.cause=$}}class xJ extends E{filePath;operation;constructor(J,Y,$,Z){super(J,$==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:Y,operation:$});if(this.name="FileError",this.filePath=Y,this.operation=$,Z)this.cause=Z}}class CJ extends E{configPath;invalidKey;constructor(J,Y){super(J,"CONFIG_ERROR",{configPath:Y?.configPath,invalidKey:Y?.invalidKey});if(this.name="ConfigError",this.configPath=Y?.configPath,this.invalidKey=Y?.invalidKey,Y?.cause)this.cause=Y.cause}}class BY extends E{cycle;constructor(J){super(`Circular dependency detected: ${J.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:J});this.name="CircularDependencyError",this.cycle=J}}function j0(J){return J instanceof E}function G0(J){return J instanceof bJ}function H0(J){return J instanceof xJ}function W0(J){return J instanceof CJ}function K0(J,Y="UNKNOWN_ERROR",$){if(J instanceof E)return J;let Z=$||(J instanceof Error?J.message:String(J)),Q=new E(Z,Y);if(J instanceof Error)Q.cause=J;return Q}function _0(J,Y){let $=1,Z=1,Q=0;for(let U of J){if(Q>=Y)break;if(U===`
15
- `)$++,Z=1;else Z++;Q++}return{line:$,column:Z,offset:Y}}function B0(J,Y,$,Z){let Q=J.split(`
16
- `),U=Y.line-1,X=[];if(Z)X.push(`${Z}:${Y.line}:${Y.column}`);else X.push(`Line ${Y.line}, Column ${Y.column}`);X.push(`Error: ${$}`),X.push("");let H=Math.max(0,U-1),j=Math.min(Q.length-1,U+1);for(let G=H;G<=j;G++){let z=(G+1).toString().padStart(4," "),A=G===U?">":" ";if(X.push(`${A} ${z} | ${Q[G]}`),G===U){let N=" ".repeat(8+Y.column-1);X.push(`${N}^`)}}return X.join(`
17
- `)}function GJ(J,Y,$){let Z={file:Y,message:"Unknown error",code:m.UNKNOWN_ERROR};if(J instanceof Error){Z.message=J.message,Z.stack=J.stack;let Q=J.message.match(/\((\d+),(\d+)\)/);if(Q)Z.location={line:Number.parseInt(Q[1],10),column:Number.parseInt(Q[2],10)};if(J.message.includes("Cannot find")||J.message.includes("not found"))Z.code=m.FILE_NOT_FOUND,Z.suggestion="Check that the file path is correct and the file exists.";else if(J.message.includes("syntax")||J.message.includes("Unexpected token"))Z.code=m.SYNTAX_ERROR,Z.suggestion="Check for syntax errors in your TypeScript code.";else if(J.message.includes("type")&&J.message.includes("cannot"))Z.code=m.TYPE_INFERENCE_ERROR,Z.suggestion="Add explicit type annotations to help with type inference.";else if(J.message.includes("parse")||J.message.includes("Parse"))Z.code=m.PARSE_ERROR,Z.suggestion="The file contains invalid TypeScript syntax."}else if(typeof J==="string")Z.message=J;return Z}function PJ(J,Y){let $=[],Z=J.file;if(J.location)Z+=`:${J.location.line}:${J.location.column}`;if(J.code)Z+=` [${J.code}]`;if($.push(Z),$.push(` Error: ${J.message}`),Y&&J.location){$.push("");let Q=Y.split(`
18
- `),U=J.location.line-1;if(U>=0&&U<Q.length){let X=Math.max(0,U-1),H=Math.min(Q.length-1,U+1);for(let j=X;j<=H;j++){let G=(j+1).toString().padStart(4," "),z=j===U?">":" ";if($.push(` ${z} ${G} | ${Q[j]}`),j===U&&J.location.column>0){let A=" ".repeat(10+J.location.column-1);$.push(` ${A}^`)}}}}if(J.suggestion)$.push(""),$.push(` Suggestion: ${J.suggestion}`);return $.join(`
19
- `)}function A0(J){if(J.length===0)return"No errors";let Y=new Map;for(let Z of J){let Q=Z.code||"UNKNOWN";Y.set(Q,(Y.get(Q)||0)+1)}let $=[`${J.length} error(s) found:`];for(let[Z,Q]of Y.entries())$.push(` - ${Z}: ${Q}`);return $.join(`
20
- `)}var n=null,b=null;async function OY(){if(n!==null)return n;try{return b=await import("prettier"),n=!0,!0}catch{return n=!1,!1}}async function kY(J,Y){if(!b)return null;try{if(Y&&b.resolveConfig){let $=await b.resolveConfig(Y);if($)return $}if(J&&b.resolveConfig){let $=await b.resolveConfig(J);if($)return $}return null}catch{return null}}async function NY(J,Y){if(!b)throw Error("Prettier is not available");let $={...Y,parser:Y.parser||"typescript"};return b.format(J,$)}function TY(J,Y={}){let{indentSize:$=2,useTabs:Z=!1,maxLineWidth:Q=100,trailingNewline:U=!0,normalizeWhitespace:X=!0,sortImports:H=!0,groupImports:j=!0}=Y,G=J,z=Z?"\t":" ".repeat($);if(G.indexOf(`\r
21
- `)!==-1)G=G.replace(/\r\n/g,`
22
- `);if(X){if(/[ \t]\n/.test(G)||/[ \t]$/.test(G))G=G.replace(/[ \t]+$/gm,"");if(G.indexOf(`
23
-
24
-
25
- `)!==-1)G=G.replace(/\n{3,}/g,`
26
-
27
- `);G=RY(G,z)}if(H||j)G=LY(G,{sort:H,group:j});if(Q>0)G=wY(G,Q,z);if(U&&!G.endsWith(`
28
- `))G+=`
29
- `;return G}function RY(J,Y){let $=J.split(`
30
- `),Z=[];for(let Q of $){let U=Q.match(/^(\s*)(.*)$/);if(!U){Z.push(Q);continue}let[,X,H]=U;if(!H){Z.push("");continue}let j=X.replace(/\t/g," ").length,G=Math.floor(j/2);Z.push(Y.repeat(G)+H)}return Z.join(`
31
- `)}function LY(J,Y){let $=J.split(`
32
- `),Z=[],Q=[],U=!1,X=0;for(let j=0;j<$.length;j++){let G=$[j],z=G.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(z){U=!0,X=j;let A=z[1];Z.push({line:G,source:z[2],isType:A.startsWith("import type ")||A.startsWith("import type\t")})}else if(U&&G.trim()==="")continue;else{if(U)U=!1;Q.push(G)}}if(Z.length===0)return J;if(Y.sort)Z.sort((j,G)=>{if(j.isType!==G.isType)return j.isType?1:-1;return MY(j.source,G.source)});let H;if(Y.group){let j=[],G=[],z=[],A=[],N=[];for(let _=0;_<Z.length;_++){let T=Z[_],V=T.source;if(V.charCodeAt(0)===46)N.push(T);else if(V.startsWith("node:"))j.push(T);else if(V.charCodeAt(0)===64)A.push(T);else if(V.includes("/"))z.push(T);else G.push(T)}H=[...j.map((_)=>_.line),...j.length>0&&G.length>0?[""]:[],...G.map((_)=>_.line),...(j.length>0||G.length>0)&&z.length>0?[""]:[],...z.map((_)=>_.line),...A.length>0&&(j.length>0||G.length>0||z.length>0)?[""]:[],...A.map((_)=>_.line),...N.length>0?[""]:[],...N.map((_)=>_.line)]}else H=Z.map((j)=>j.line);return[...H,"",...Q].join(`
33
- `)}function MY(J,Y){let $=J.startsWith("node:"),Z=Y.startsWith("node:");if($!==Z)return $?-1:1;let Q=J.startsWith("."),U=Y.startsWith(".");if(Q!==U)return Q?1:-1;return J.localeCompare(Y)}function wY(J,Y,$){let Z=J.split(`
34
- `),Q=[];for(let U of Z){if(U.length<=Y){Q.push(U);continue}if(U.trimStart().startsWith("import ")){Q.push(U);continue}let X=U.match(/^(\s*)/)?.[1]||"",H=X+$;if(U.includes("{")&&U.includes("}")){let j=SY(U,Y,X,H);Q.push(...j);continue}if(U.includes(" | ")){let j=FY(U,Y,X,H);Q.push(...j);continue}Q.push(U)}return Q.join(`
35
- `)}function SY(J,Y,$,Z){let Q=J.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!Q)return[J];let[,,U,X,H,j]=Q,G=H.split(/;\s*|,\s*/).filter((A)=>A.trim());if(G.length<=1)return[J];return[`${$}${U}${X}`,...G.map((A)=>`${Z}${A.trim()};`),`${$}${j.trim()}`]}function FY(J,Y,$,Z){let Q=J.match(/^(\s*)(.*?=\s*)(.+)$/);if(!Q)return[J];let[,,U,X]=Q,H=X.split(/\s*\|\s*/).filter((G)=>G.trim());if(H.length<=2)return[J];return[`${$}${U}`,...H.map((G,z)=>`${Z}${z>0?"| ":" "}${G.trim()}`)]}async function g(J,Y={},$){let Z=[];if(Y.usePrettier!==!1){if(await OY())try{let H={...await kY(Y.prettierConfigPath,$),...Y.prettierOptions,parser:"typescript"};return{content:await NY(J,H),usedPrettier:!0}}catch(X){Z.push(`Prettier formatting failed: ${X}. Using built-in formatter.`)}else if(Y.usePrettier===!0)Z.push("Prettier requested but not available. Using built-in formatter.")}return{content:TY(J,Y.builtIn),usedPrettier:!1,warnings:Z.length>0?Z:void 0}}async function DY(J,Y={}){let $=new Map;for(let[Z,Q]of J){let U=await g(Q,Y,Z);$.set(Z,U)}return $}function k0(J={}){return{format:(Y,$)=>g(Y,J,$),formatMany:(Y)=>DY(Y,J)}}async function N0(J){return(await g(J,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}import{existsSync as vY,statSync as IY}from"fs";import{dirname as EY,isAbsolute as WJ,resolve as yY}from"path";var hJ=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".d.ts"];function HJ(J){try{return IY(J).isFile()}catch{return!1}}function KJ(J,Y){if(!(J.startsWith("./")||J.startsWith("../")||J==="."||J==="..")&&!WJ(J))return{resolved:null,isRelative:!1};let Z=EY(Y),Q=WJ(J)?J:yY(Z,J);if(HJ(Q))return{resolved:Q,isRelative:!0};for(let U of hJ){let X=Q+U;if(HJ(X))return{resolved:X,isRelative:!0}}if(vY(Q))for(let U of hJ){let X=`${Q}/index${U}`;if(HJ(X))return{resolved:X,isRelative:!0}}return{resolved:null,isRelative:!0}}function bY(J){let Y=J.length,$="",Z=0;while(Z<Y){let Q=J.charCodeAt(Z);if(Q===34||Q===39||Q===96){let U=Q;$+=J[Z++];while(Z<Y){let X=J.charCodeAt(Z);if($+=J[Z++],X===92&&Z<Y){$+=J[Z++];continue}if(X===U)break}continue}if(Q===47&&Z+1<Y){let U=J.charCodeAt(Z+1);if(U===47){Z+=2;while(Z<Y&&J.charCodeAt(Z)!==10)Z++;continue}if(U===42){Z+=2;while(Z+1<Y&&!(J.charCodeAt(Z)===42&&J.charCodeAt(Z+1)===47))Z++;Z+=2;continue}}$+=J[Z++]}return $}var mJ=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,gJ=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";\n]+\s+from\s+)?(['"])([^'"]+)\2/g;function _J(J,Y={}){let $=[],Z=bY(J);mJ.lastIndex=0;let Q;while((Q=mJ.exec(Z))!==null){let U=!!Q[1],X=Q[3],H=Q[0],j;if(H.includes("* as "))j="export-star-as";else if(H.includes("*"))j="export-star";else j="export-named";$.push({specifier:X,kind:j,isTypeOnly:U})}if(Y.includeImports){gJ.lastIndex=0;while((Q=gJ.exec(Z))!==null)$.push({specifier:Q[3],kind:"import",isTypeOnly:!!Q[1]})}return $}async function BJ(J,Y={}){let $=new Set,Z=new Map,Q=[],U=[];for(let X of J)if(!$.has(X))$.add(X),U.push(X);while(U.length>0){let X=U.shift(),H;try{H=await y(X)}catch{continue}let j=_J(H,Y);Z.set(X,j);for(let G of j){if(!(G.specifier.startsWith(".")||WJ(G.specifier)))continue;let z=KJ(G.specifier,X);if(z.resolved){if(!$.has(z.resolved))$.add(z.resolved),U.push(z.resolved)}else Q.push({from:X,specifier:G.specifier,isTypeOnly:G.isTypeOnly})}}return{reachable:$,reExports:Z,unresolved:Q}}class i{plugins=[];config=null;register(J){if(this.plugins.some((Y)=>Y.name===J.name))throw Error(`Plugin "${J.name}" is already registered`);this.plugins.push(J)}unregister(J){let Y=this.plugins.findIndex(($)=>$.name===J);if(Y>=0)return this.plugins.splice(Y,1),!0;return!1}getPlugins(){return this.plugins}createLogger(J){return{debug:(Y)=>console.debug(`[${J}] ${Y}`),info:(Y)=>console.info(`[${J}] ${Y}`),warn:(Y)=>console.warn(`[${J}] ${Y}`),error:(Y)=>console.error(`[${J}] ${Y}`)}}async runOnStart(J){let Y=J;for(let $ of this.plugins)if($.onStart){let Z=await $.onStart(Y);if(Z)Y=Z}return this.config=Y,Y}async runOnBeforeFile(J,Y){let $=Y;for(let Z of this.plugins)if(Z.onBeforeFile){let Q={filePath:J,sourceCode:Y,content:$,config:this.config,log:this.createLogger(Z.name)},U=await Z.onBeforeFile(Q);if(typeof U==="string")$=U}return $}async runOnDeclarations(J,Y,$){let Z=$;for(let Q of this.plugins)if(Q.onDeclarations){let U={filePath:J,sourceCode:Y,declarations:Z,config:this.config,log:this.createLogger(Q.name)},X=await Q.onDeclarations(U);if(X)Z=X}return Z}async runOnAfterFile(J,Y,$){let Z=$;for(let Q of this.plugins)if(Q.onAfterFile){let U={filePath:J,sourceCode:Y,content:Z,config:this.config,log:this.createLogger(Q.name)},X=await Q.onAfterFile(U);if(typeof X==="string")Z=X}return Z}async runOnEnd(J){for(let Y of this.plugins)if(Y.onEnd)await Y.onEnd(J)}async runOnError(J,Y,$){for(let Z of this.plugins)if(Z.onError){let Q={filePath:Y,sourceCode:$,config:this.config,log:this.createLogger(Z.name)};await Z.onError(J,Q)}}}var S0=new i;function AJ(J){return J}var F0=AJ({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(J)=>{return J.declarations.filter((Y)=>{if(Y.leadingComments){if(Y.leadingComments.some((Z)=>Z.includes("@internal")))return J.log.debug(`Stripping internal declaration: ${Y.name}`),!1}return!0})}});function D0(J){return AJ({name:"banner",version:"1.0.0",description:"Adds a banner comment to generated files",onAfterFile:(Y)=>{return`/**
36
- * ${J.split(`
37
- `).join(`
38
- * `)}
39
- */
40
-
41
- `+Y.content}})}function v0(J){return AJ({name:"filter",version:"1.0.0",description:"Filters declarations by name",onDeclarations:(Y)=>{return Y.declarations.filter(($)=>{if($.kind==="import")return!0;return J($.name)})}})}var P=xY(CY(),1);import{readdir as PY}from"fs/promises";import{dirname as hY,extname as mY,isAbsolute as gY,join as uJ,resolve as fJ}from"path";import pJ from"process";import{pathToFileURL as OJ}from"url";function h0(J,Y){throw Error(Y||`Unexpected value: ${J}`)}async function h(J,Y){let $=Y.replace(/\r\n/g,`
42
- `);if(!$.endsWith(`
43
- `))$+=`
44
- `;await jJ(J,$)}async function fY(J){let Y=J??f.root,$=await PY(Y,{withFileTypes:!0});return(await Promise.all($.map((Q)=>{let U=uJ(Y,Q.name);return Q.isDirectory()?fY(U):U}))).flat(1/0).filter((Q)=>typeof Q==="string"&&mY(Q)===".ts")}async function cJ(J){try{let Y=J?.cwd||pJ.cwd(),$=J?.tsconfigPath||uJ(Y,"tsconfig.json"),Q=await import(OJ($).href);if(Q.compilerOptions?.isolatedDeclarations===!0)return!0;if(Q.extends){let U=dJ($,Q.extends),X=U.endsWith(".json")?U:`${U}.json`,j=await import(OJ(X).href);if(j.compilerOptions?.isolatedDeclarations===!0)return!0;if(j.extends){let G=dJ(X,j.extends),z=G.endsWith(".json")?G:`${G}.json`;if((await import(OJ(z).href)).compilerOptions?.isolatedDeclarations===!0)return!0}}return!1}catch{return!1}}function lJ(J,Y){let $={isValid:!0,errors:[]},Z=P.default.createSourceFile(Y,J,P.default.ScriptTarget.Latest,!0,P.default.ScriptKind.TS),Q={getSourceFile:(H)=>{if(H===Y)return Z;return},getDefaultLibFileName:()=>"lib.d.ts",writeFile:()=>{},getCurrentDirectory:()=>"",getCanonicalFileName:(H)=>H,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>`
45
- `,fileExists:(H)=>H===Y,readFile:()=>{return}},X=[...P.default.createProgram({rootNames:[Y],options:{noEmit:!0,declaration:!0,skipLibCheck:!0,noLib:!0},host:Q}).getSyntacticDiagnostics(Z)];for(let H of X){let j=P.default.flattenDiagnosticMessageText(H.messageText,`
46
- `),G=`TS${H.code}`,z;switch(H.code){case 1005:z="Add a semicolon at the end of the statement.";break;case 1109:z="Check for missing or malformed expressions.";break;case 1128:z="Ensure proper declaration syntax is used.";break;case 2304:z="Import or declare the missing type/value.";break;case 2307:z="Check that the module exists and is installed.";break;case 2322:z="Check type compatibility between the values.";break;case 2339:z="Add the missing property to the type definition.";break;case 2345:z="Check the argument types match the expected parameters.";break}if(H.file&&H.start!==void 0){let{line:A,character:N}=H.file.getLineAndCharacterOfPosition(H.start);$.errors.push({line:A+1,column:N+1,message:j,code:G,suggestion:z})}else $.errors.push({line:0,column:0,message:j,code:G,suggestion:z})}return $.isValid=$.errors.length===0,$}function aJ(J,Y,$){if(J===Y)return"";let Z=J.split(`
47
- `),Q=Y.split(`
48
- `),U=new Map,X=new Map;for(let z=0;z<Z.length;z++)U.set(Z[z],(U.get(Z[z])??0)+1);for(let z=0;z<Q.length;z++)X.set(Q[z],(X.get(Q[z])??0)+1);let H=[],j=[];for(let[z,A]of U){let N=A-(X.get(z)??0);for(let _=0;_<N;_++)H.push(z)}for(let[z,A]of X){let N=A-(U.get(z)??0);for(let _=0;_<N;_++)j.push(z)}if(H.length===0&&j.length===0)return"";let G=[`--- ${$}`,`+++ ${$}`];for(let z=0;z<H.length;z++)G.push(`- ${H[z]}`);for(let z=0;z<j.length;z++)G.push(`+ ${j[z]}`);return G.join(`
49
- `)}function dJ(J,Y){if(gY(Y))return Y;if(Y.startsWith("."))return fJ(hY(J),Y);return fJ(pJ.cwd(),"node_modules",Y)}function sJ(J,Y,$,Z){let Q=J.split(`
50
- `),U=[];function X(A){let _="",T=A<0?-A<<1|1:A<<1;do{let V=T&31;if(T>>>=5,T>0)V|=32;_+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[V]}while(T>0);return _}let H=0,j=0,G=0,z=Z.split(`
51
- `).length;for(let A=0;A<Q.length;A++){if(Q[A].trim()===""){U.push("");continue}H=0;let _=Math.min(A,z-1),T=[],V=0-H,W=0,O=_-j,q=0-G;T.push(X(V)+X(W)+X(O)+X(q)),H=0,j=_,G=0,U.push(T.join(","))}return{version:3,file:Y,sourceRoot:"",sources:[$],sourcesContent:[Z],mappings:U.join(";")}}function nJ(J,Y){return`${J}
52
- //# sourceMappingURL=${Y}
53
- `}async function uY(J){let Y=Date.now(),$={...f,...J};if($.logLevel)r($.logLevel);else if($.verbose)r("debug");let Z=new i;if($.plugins&&$.plugins.length>0){for(let V of $.plugins)Z.register(V),K.debug(`Registered plugin: ${V.name}`);$=await Z.runOnStart($)}if($.isolatedDeclarations===void 0)$.isolatedDeclarations=await cJ($);let Q=null;if($.incremental){if(Q=new zJ($),$.clearCache)K.debug("Clearing build cache..."),Q.clear();else if(Q.load()){let W=Q.getStats();K.debug(`Loaded build cache with ${W.entries} entries`)}else K.debug("No existing build cache found, starting fresh");FJ($.cwd)}let U={filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},X=0;K.debug("Starting DTS generation..."),K.debug("Config:",$);let H=await lY($),j=H.slice(),G=null;if($.autoIncludeReExports!==!1&&j.length>0){G=await BJ(j,{includeImports:!0});let V=x($.cwd,$.root),W=$.exclude||[],O=[];for(let q of G.reachable){if(j.includes(q))continue;if(q.endsWith(".d.ts"))continue;if(q.includes("node_modules"))continue;if(t(q,W,V))continue;O.push(q)}if(O.length>0)j=[...j,...O],K.debug(`Auto-included ${O.length} file(s) reached via relative re-exports`)}if(Q){let V=Q.prune(new Set(j),$.cwd);if(V>0)K.debug(`Pruned ${V} deleted files from cache`)}if(K.debug(`Found ${j.length} TypeScript files`),$.progress&&j.length>0){let V=$.parallel?"parallel":"sequential";K.info(`Processing ${j.length} files (${V})...`)}let z=async(V,W)=>{let O;try{let q=kJ(V,$);if(Q){let S=Q.getCachedIfValid(V,$.cwd);if(S)return await o(u(q),{recursive:!0}),await h(q,S),K.debug(`[cached] ${v($.cwd,q)}`),{success:!0,file:V,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:0}}O=W??await y(V);let{content:B,declarationCount:k,importCount:R,exportCount:L}=await tJ(V,O,$,Z),w=0;if($.dryRun)K.info(`[dry-run] Would generate: ${q}`),K.debug("--- Content preview ---"),K.debug(B.slice(0,500)+(B.length>500?`
54
- ...`:"")),K.debug("--- End preview ---");else{if($.diff)try{let M=await y(q),F=aJ(M,B,v($.cwd,q));if(F)K.info(`
55
- ${F}`);else K.debug(`[no changes] ${q}`)}catch{K.info(`[new file] ${v($.cwd,q)}`)}await o(u(q),{recursive:!0});let S=B;if($.declarationMap&&O){let M=q.split("/").pop()||"output.d.ts",F=v(u(q),V),D=`${M}.map`,p=sJ(B,M,F,O),C=`${q}.map`;await h(C,JSON.stringify(p)),S=nJ(B,D),K.debug(` Generated source map: ${v($.cwd,C)}`)}if($.prettier||$.indentStyle||$.indentSize){let M=await g(S,{usePrettier:$.prettier,builtIn:{indentSize:$.indentSize||2,useTabs:$.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},q);if(S=M.content,M.warnings?.length)for(let F of M.warnings)K.warn(`[format] ${F}`)}if(await h(q,S),Q&&O)Q.update(V,O,S,$.cwd);if($.validate){let M=lJ(B,q);if(!M.isValid){w=M.errors.length,K.warn(`[validation] ${v($.cwd,q)} has ${M.errors.length} error(s):`);for(let F of M.errors){let D=` Line ${F.line}:${F.column}`;if(F.code)D+=` [${F.code}]`;if(D+=` - ${F.message}`,K.warn(D),F.suggestion)K.warn(` Suggestion: ${F.suggestion}`)}}else K.debug(`[validation] ${q} - OK`)}K.debug(`Generated: ${q}`)}return{success:!0,file:V,declarationCount:k,importCount:R,exportCount:L,validationErrorCount:w}}catch(q){let B=GJ(q,V,O);if($.plugins&&$.plugins.length>0)await Z.runOnError(q instanceof Error?q:Error(String(q)),V,O||"");return{success:!1,file:V,declarationCount:0,importCount:0,exportCount:0,dtsError:B,validationErrorCount:0}}},A=$.parallel||$.parallel!==!1&&j.length>=10,N=$.concurrency||(dY?.()??8),_=new Map;if(A&&j.length>1){let V=j.map(async(W)=>{try{let O=await y(W);return{file:W,source:O}}catch{return{file:W,source:null}}});for(let W of await Promise.all(V))if(W.source!==null)_.set(W.file,W.source)}let T=(V)=>{if(U.filesProcessed++,V.success){if(V.cached)X++;else U.filesGenerated++,U.declarationsFound+=V.declarationCount,U.importsProcessed+=V.importCount,U.exportsProcessed+=V.exportCount;if($.validate){if(U.filesValidated++,V.validationErrorCount)U.validationErrors+=V.validationErrorCount}}else if(U.filesFailed++,V.dtsError){U.errors.push(V.dtsError);let W=PJ(V.dtsError);if($.continueOnError)K.warn(W);else throw K.error(W),Error(V.dtsError.message)}};if(A)for(let V=0;V<j.length;V+=N){let W=j.slice(V,V+N),O=await Promise.all(W.map((q)=>z(q,_.get(q))));for(let q of O)T(q);if($.progress){let q=Math.round(U.filesProcessed/j.length*100);K.info(`[${U.filesProcessed}/${j.length}] ${q}%`)}}else for(let V of j){let W=await z(V);if(T(W),$.progress){let O=Math.round(U.filesProcessed/j.length*100),q=W.cached?"[cached]":"";K.info(`[${U.filesProcessed}/${j.length}] ${O}% - ${v($.cwd,V)} ${q}`)}}if(Q)Q.save(),K.debug("Saved build cache");if(!$.bundle){let V=[];if(G)for(let W of G.unresolved)V.push({from:W.from,specifier:W.specifier,reason:"missing"});if($.autoIncludeReExports===!1&&j.length>0){let W=new Set(j);for(let O of j){let q;try{q=await y(O)}catch{continue}for(let B of _J(q)){if(!B.specifier.startsWith("."))continue;let k=KJ(B.specifier,O);if(!k.resolved)V.push({from:O,specifier:B.specifier,reason:"missing"});else if(!W.has(k.resolved))V.push({from:O,specifier:B.specifier,reason:"not-emitted"})}}}if(V.length>0){let W=[];W.push(`Found ${V.length} re-export(s) pointing at siblings that won't be in the output:`);for(let q of V){let B=v($.cwd,q.from);if(q.reason==="missing")W.push(` ${B} \u2192 '${q.specifier}' (path not found on disk)`);else W.push(` ${B} \u2192 '${q.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let O=W.join(`
56
- `);if($.failOnUnresolvedReExport)throw Error(O);K.warn(O),K.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if($.bundle&&(U.filesGenerated>0||X>0)&&H.length>0)try{K.debug("Bundling declarations...");let V=new Map,W=async(q)=>{let B=V.get(q);if(B!==void 0)return B;return B=await y(q),V.set(q,B),B};for(let q of j)await W(q);let O=H.length===1&&!!$.bundleOutput;for(let q of H){let B=await BJ([q],{includeImports:!0}),k=new Set;for(let M of B.reachable){if(M.endsWith(".d.ts"))continue;if(M.includes("node_modules"))continue;k.add(M)}let R=j.filter((M)=>k.has(M));if(!R.includes(q))R.push(q);let L=new Map;for(let M of R){let F=V.get(M)??await W(M);L.set(M,F)}let w=await TJ(R,L,$),S=O?x($.cwd,$.outdir,$.bundleOutput):kJ(q,$);if(await o(u(S),{recursive:!0}),await h(S,w.content),K.info(`Bundled ${w.files.length} files to: ${v($.cwd,S)}`),O)break}}catch(V){let W=V instanceof Error?V.message:String(V);K.error(`Bundle failed: ${W}`)}if(U.durationMs=Date.now()-Y,$.stats)if($.outputFormat==="json")console.log(JSON.stringify(U,null,2));else{if(K.info(`
57
- --- Generation Statistics ---`),K.info(`Files processed: ${U.filesProcessed}`),K.info(`Files generated: ${U.filesGenerated}`),X>0)K.info(`Files cached: ${X}`);if(U.filesFailed>0)K.info(`Files failed: ${U.filesFailed}`);if(K.info(`Declarations found: ${U.declarationsFound}`),K.info(`Imports processed: ${U.importsProcessed}`),K.info(`Exports processed: ${U.exportsProcessed}`),U.filesValidated>0){if(K.info(`Files validated: ${U.filesValidated}`),U.validationErrors>0)K.info(`Validation errors: ${U.validationErrors}`)}if(K.info(`Duration: ${U.durationMs}ms`),U.errors.length>0){K.info(`
58
- Errors:`);for(let V of U.errors){let W=` - ${V.file}`;if(V.location)W+=`:${V.location.line}:${V.location.column}`;if(V.code)W+=` [${V.code}]`;if(W+=`: ${V.message}`,K.info(W),V.suggestion)K.info(` Suggestion: ${V.suggestion}`)}}K.info(`-----------------------------
59
- `)}if($.plugins&&$.plugins.length>0)await Z.runOnEnd(U);return K.debug("DTS generation complete!"),U}var pY=50,d=new Map;function cY(J){let Y=d.get(J);if(!Y){if(Y=new oJ(J),d.set(J,Y),d.size>pY){let $=d.keys().next().value;if($!==void 0)d.delete($)}}return Y}function t(J,Y,$){if(!Y||Y.length===0)return!1;let Z=v($,J);for(let Q of Y){let U=cY(Q);if(U.match(Z)||U.match(J))return!0}return!1}async function lY(J){let Y=[],$=x(J.cwd,J.root),Z=J.exclude||[];for(let Q of J.entrypoints)if(Q.startsWith("/")&&Q.endsWith(".ts")){if(!Q.endsWith(".d.ts")&&!Q.includes("node_modules")){if(!t(Q,Z,$))Y.push(Q)}}else{let U=new oJ(Q);for await(let X of U.scan({cwd:$,absolute:!0,onlyFiles:!0}))if(!X.endsWith(".d.ts")&&!X.includes("node_modules")){if(!t(X,Z,$))Y.push(X)}}return[...new Set(Y)]}function kJ(J,Y){let $=x(Y.cwd,Y.root),Q=v($,J).replace(/\.(m?tsx?|cts)$/,(U)=>{if(U===".mts")return".d.mts";if(U===".cts")return".d.cts";return".d.ts"});if(Y.outputStructure==="mirror")return x(Y.cwd,Y.outdir,Q);else{let U=Q.split("/").pop();return x(Y.cwd,Y.outdir,U)}}async function Z1(J,Y){return(await rJ(J,Y)).content}async function rJ(J,Y,$){let Z=await y(J);return tJ(J,Z,Y,$)}async function tJ(J,Y,$,Z){let Q=Y;if(Z)Q=await Z.runOnBeforeFile(J,Y);let U=l(Q,J,$.keepComments,$.isolatedDeclarations??!1);if(Z)U=await Z.runOnDeclarations(J,Q,U);let X=0,H=0;for(let z=0;z<U.length;z++){let A=U[z];if(A.kind==="import")X++;if(A.kind==="export"||A.isExported)H++}let G=iJ(U,{filePath:J,sourceCode:Q,declarations:U},$.keepComments,$.importOrder);if(Z)G=await Z.runOnAfterFile(J,Q,G);return{content:G,declarationCount:U.length,importCount:X,exportCount:H}}async function Q1(J){let Y={...f,...J};if(Y.logLevel)r(Y.logLevel);let $=x(Y.cwd,Y.root),Z=150,Q=5,U=1e4,X={pendingChanges:new Set,debounceTimer:null,isProcessing:!1,errorCount:0,lastErrorTime:0};K.info(`Watching for changes in ${$}...`),K.info(`Press Ctrl+C to stop
60
- `);try{await uY(Y),K.info(`[watch] Initial generation complete
61
- `)}catch(A){let N=A instanceof Error?A.message:String(A);K.error(`[watch] Initial generation failed: ${N}`),K.info(`[watch] Continuing to watch for changes...
62
- `)}async function H(){if(X.isProcessing||X.pendingChanges.size===0)return;let A=Date.now();if(X.errorCount>=Q){if(A-X.lastErrorTime<U){K.warn(`[watch] Too many errors, pausing for ${Math.ceil((U-(A-X.lastErrorTime))/1000)}s...`);return}X.errorCount=0}X.isProcessing=!0;let N=Array.from(X.pendingChanges);X.pendingChanges.clear();let _=new Date().toLocaleTimeString();if(N.length===1)K.info(`
63
- [${_}] File changed: ${N[0]}`);else K.info(`
64
- [${_}] ${N.length} files changed`);let T=0,V=0;for(let W of N){let O=x($,W);try{let q=Y.exclude||[];if(t(O,q,$)){K.debug(` Skipping excluded file: ${W}`);continue}if(!await EJ(O).exists()){K.debug(` Skipping deleted file: ${W}`);continue}let k=kJ(O,Y),{content:R}=await rJ(O,Y);await o(u(k),{recursive:!0}),await h(k,R),K.info(` \u2713 ${v(Y.cwd,k)}`),T++}catch(q){V++,X.errorCount++,X.lastErrorTime=Date.now();let B=GJ(q,O);if(K.error(` \u2717 ${W}: ${B.message}`),B.suggestion)K.error(` Suggestion: ${B.suggestion}`)}}if(N.length>1)K.info(` Done: ${T} generated, ${V} failed`);if(V===0)X.errorCount=0;if(X.isProcessing=!1,X.pendingChanges.size>0)X.debounceTimer=setTimeout(H,Z)}function j(A){if(X.pendingChanges.add(A),X.debounceTimer)clearTimeout(X.debounceTimer);X.debounceTimer=setTimeout(H,Z)}let z=yJ([I?"bun":"node","-e",`
65
- const fs = require('fs');
66
-
67
- const rootPath = '${$}';
68
-
69
- fs.watch(rootPath, { recursive: true }, (eventType, filename) => {
70
- if (filename && filename.endsWith('.ts') && !filename.endsWith('.d.ts')) {
71
- console.log(\`CHANGED:\${filename}\`);
72
- }
73
- });
74
-
75
- // Keep process alive
76
- setInterval(() => {}, 1000);
77
- `],{stdout:"pipe",stderr:"inherit"});if(I){let A=z.stdout.getReader(),N=new TextDecoder,_="";while(!0){let{done:T,value:V}=await A.read();if(T)break;_+=N.decode(V,{stream:!0});let W=_.split(`
78
- `);_=W.pop()||"";for(let O of W)if(O.startsWith("CHANGED:")){let q=O.slice(8);j(q)}}}else{let A=z.stdout,N="";A.on("data",(_)=>{N+=_.toString();let T=N.split(`
79
- `);N=T.pop()||"";for(let V of T)if(V.startsWith("CHANGED:")){let W=V.slice(8);j(W)}}),await z.exited}}
80
- export{TJ as ua,LJ as va,qY as wa,iY as xa,oY as ya,zJ as za,FJ as Aa,I as Ba,Q0 as Ca,U0 as Da,EJ as Ea,jJ as Fa,yJ as Ga,y as Ha,X0 as Ia,q0 as Ja,z0 as Ka,m as La,E as Ma,bJ as Na,KY as Oa,_Y as Pa,xJ as Qa,CJ as Ra,BY as Sa,j0 as Ta,G0 as Ua,H0 as Va,W0 as Wa,K0 as Xa,_0 as Ya,B0 as Za,GJ as _a,PJ as $a,A0 as ab,g as bb,DY as cb,k0 as db,N0 as eb,i as fb,S0 as gb,AJ as hb,F0 as ib,D0 as jb,v0 as kb,h0 as lb,h as mb,fY as nb,cJ as ob,lJ as pb,aJ as qb,sJ as rb,nJ as sb,uY as tb,Z1 as ub,Q1 as vb};
@@ -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};