@dtsx/dtsx 0.11.39 → 0.11.41

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 (136) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/dist/{chunk-31kbs9mj.js → chunk-00m9cbar.js} +3 -3
  3. package/dist/{chunk-2dstvjpv.js → chunk-01jwgm2m.js} +1 -1
  4. package/dist/{chunk-jswvvjkr.js → chunk-01zsk2q8.js} +3 -3
  5. package/dist/{chunk-zn2gvwve.js → chunk-059gzhxc.js} +3 -3
  6. package/dist/{chunk-tm2j0feh.js → chunk-06jp6gah.js} +2 -2
  7. package/dist/{chunk-3jjrn16z.js → chunk-13tjnp25.js} +3 -3
  8. package/dist/{chunk-ka8mbyjb.js → chunk-1vc3eend.js} +2 -2
  9. package/dist/{chunk-aak9xzy7.js → chunk-2ck79rny.js} +2 -2
  10. package/dist/{chunk-t6ds7drh.js → chunk-3f3byyqp.js} +2 -2
  11. package/dist/{chunk-8dvxjzhy.js → chunk-3r9dptyy.js} +2 -2
  12. package/dist/{chunk-vbzchjvq.js → chunk-5mbfgcvp.js} +1 -1
  13. package/dist/{chunk-p4hf9bwj.js → chunk-6vz1grv8.js} +3 -3
  14. package/dist/{chunk-bc7ahgxz.js → chunk-6yn2edca.js} +2 -2
  15. package/dist/{chunk-8zvjkzsv.js → chunk-7387m006.js} +2 -2
  16. package/dist/{chunk-kccc6p2t.js → chunk-73qsp464.js} +1 -1
  17. package/dist/{chunk-0c03j9eq.js → chunk-7g0hjhqy.js} +1 -1
  18. package/dist/chunk-7khy25x0.js +3 -0
  19. package/dist/{chunk-ayyb1jpe.js → chunk-85d82vn3.js} +2 -2
  20. package/dist/chunk-8g4wk8mm.js +38 -0
  21. package/dist/{chunk-zk55g2cb.js → chunk-8qvphjgv.js} +1 -1
  22. package/dist/{chunk-hvy1zvk6.js → chunk-8wk7nw3c.js} +1 -1
  23. package/dist/{chunk-vgmnxnjf.js → chunk-9pharkp0.js} +11 -11
  24. package/dist/{chunk-jfygtm4r.js → chunk-a2dn9j88.js} +1 -1
  25. package/dist/{chunk-phwfth21.js → chunk-asqkc0bw.js} +2 -2
  26. package/dist/{chunk-nd0sbh5r.js → chunk-btwfkzt5.js} +3 -3
  27. package/dist/{chunk-996gqrz6.js → chunk-df8p90w4.js} +2 -2
  28. package/dist/{chunk-js4m0y2m.js → chunk-dpanh3p5.js} +1 -1
  29. package/dist/{chunk-3mcz22q8.js → chunk-epjq1edf.js} +4 -4
  30. package/dist/{chunk-0m1wt3db.js → chunk-fv3x086v.js} +2 -2
  31. package/dist/chunk-g0dxj89b.js +7 -0
  32. package/dist/{chunk-6epjc5rj.js → chunk-geqv8t08.js} +1 -1
  33. package/dist/{chunk-a3vfqhnp.js → chunk-gn3zapr9.js} +1 -1
  34. package/dist/{chunk-w26wgqh8.js → chunk-grqy03qp.js} +1 -1
  35. package/dist/{chunk-qrwst9bb.js → chunk-j0p7bwj6.js} +2 -2
  36. package/dist/{chunk-nqgfrehj.js → chunk-jfsj0sd2.js} +1 -1
  37. package/dist/{chunk-45fpbdw3.js → chunk-jvaqq9fq.js} +1 -1
  38. package/dist/{chunk-cyw59tgm.js → chunk-k0mqnrc1.js} +1 -1
  39. package/dist/{chunk-3dweac93.js → chunk-k4pkkkmh.js} +1 -1
  40. package/dist/{chunk-zbe06f63.js → chunk-pq1n1xqh.js} +1 -1
  41. package/dist/{chunk-g3zt5h6d.js → chunk-q11f576t.js} +2 -2
  42. package/dist/{chunk-y4wykrya.js → chunk-q4ph9qa2.js} +3 -3
  43. package/dist/{chunk-7ynrmx5b.js → chunk-qnwcsmsg.js} +4 -4
  44. package/dist/{chunk-hgscwj1y.js → chunk-qqjbaqm6.js} +2 -2
  45. package/dist/{chunk-sgcne5bb.js → chunk-qzb5pswc.js} +2 -2
  46. package/dist/{chunk-y3x7p6jf.js → chunk-rajfxka5.js} +1 -1
  47. package/dist/{chunk-jyq39qjt.js → chunk-sp0k32m0.js} +2 -2
  48. package/dist/{chunk-fay5vymp.js → chunk-twrcd0q6.js} +2 -2
  49. package/dist/{chunk-ee109s3r.js → chunk-v55m1ae1.js} +6 -6
  50. package/dist/{chunk-axj2w6hp.js → chunk-ves9h7g2.js} +1 -1
  51. package/dist/{chunk-kv0bpgyw.js → chunk-vgdsxnc2.js} +1 -1
  52. package/dist/chunk-w3zqfm8a.js +3 -0
  53. package/dist/{chunk-jhpfmjnx.js → chunk-w8ws29dq.js} +1 -1
  54. package/dist/{chunk-yde8rmfm.js → chunk-wma315wm.js} +8 -8
  55. package/dist/{chunk-z6mpxpxt.js → chunk-xmj05115.js} +1 -1
  56. package/dist/{chunk-ybzz1jg7.js → chunk-xzw0p4nq.js} +2 -2
  57. package/dist/{chunk-dpcvehxp.js → chunk-yf6v2p6x.js} +1 -1
  58. package/dist/{chunk-ex03kbwr.js → chunk-ywv56grs.js} +1 -1
  59. package/dist/{chunk-yzdh207n.js → chunk-yyqay3jp.js} +4 -4
  60. package/dist/{chunk-7j4cgkb4.js → chunk-zf96k060.js} +2 -2
  61. package/dist/src/augmentation-graph.js +1 -1
  62. package/dist/src/binding-patterns.js +1 -1
  63. package/dist/src/branded-types.js +1 -1
  64. package/dist/src/bundle-linker.js +1 -1
  65. package/dist/src/bundler.js +1 -1
  66. package/dist/src/cache.js +1 -1
  67. package/dist/src/call-signatures.js +1 -1
  68. package/dist/src/circular.js +1 -1
  69. package/dist/src/compat.js +1 -1
  70. package/dist/src/computed-keys.js +1 -1
  71. package/dist/src/declaration-project.js +1 -1
  72. package/dist/src/declaration-publication.js +1 -1
  73. package/dist/src/declaration-references.js +1 -1
  74. package/dist/src/diff.js +1 -1
  75. package/dist/src/docs.js +1 -1
  76. package/dist/src/enum-declarations.js +1 -1
  77. package/dist/src/errors.js +1 -1
  78. package/dist/src/extractor/extract.js +1 -1
  79. package/dist/src/extractor/scanner.js +1 -1
  80. package/dist/src/extractor.js +1 -1
  81. package/dist/src/formatter.js +1 -1
  82. package/dist/src/function-properties.js +1 -1
  83. package/dist/src/generator.js +1 -1
  84. package/dist/src/incremental.js +1 -1
  85. package/dist/src/index.js +1 -1
  86. package/dist/src/inferred-imports.js +1 -1
  87. package/dist/src/lsp.js +1 -1
  88. package/dist/src/memory.js +1 -1
  89. package/dist/src/module-graph.js +1 -1
  90. package/dist/src/module-references.js +1 -1
  91. package/dist/src/native-checker.js +1 -1
  92. package/dist/src/native-extractor.js +1 -1
  93. package/dist/src/native-generation.js +1 -1
  94. package/dist/src/native-project.js +1 -1
  95. package/dist/src/optimizer.js +1 -1
  96. package/dist/src/parallel-processor.js +1 -1
  97. package/dist/src/parameters.js +1 -1
  98. package/dist/src/parser.js +1 -1
  99. package/dist/src/plugins/bun.js +1 -1
  100. package/dist/src/plugins/esbuild.js +1 -1
  101. package/dist/src/plugins/index.js +1 -1
  102. package/dist/src/plugins/tsdown.js +1 -1
  103. package/dist/src/plugins/tsup.js +1 -1
  104. package/dist/src/plugins/vite.js +1 -1
  105. package/dist/src/plugins/webpack.js +1 -1
  106. package/dist/src/plugins.js +1 -1
  107. package/dist/src/process-source.js +1 -1
  108. package/dist/src/processor/declarations.js +1 -1
  109. package/dist/src/processor/import-usage.js +1 -1
  110. package/dist/src/processor/imports.js +1 -1
  111. package/dist/src/processor/index.js +1 -1
  112. package/dist/src/processor/type-inference.js +1 -1
  113. package/dist/src/processor.js +1 -1
  114. package/dist/src/profiling.js +1 -1
  115. package/dist/src/return-type-scope.js +1 -1
  116. package/dist/src/source-cache.js +1 -1
  117. package/dist/src/sourcemap.js +1 -1
  118. package/dist/src/transformers.js +1 -1
  119. package/dist/src/tsconfig.js +1 -1
  120. package/dist/src/type-mappings.js +1 -1
  121. package/dist/src/utils.js +1 -1
  122. package/dist/src/value-inference.js +1 -1
  123. package/dist/src/watcher.js +1 -1
  124. package/dist/src/worker-thread.js +1 -1
  125. package/dist/src/workspace.js +1 -1
  126. package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
  127. package/native/darwin-x64/libzig-dtsx.dylib +0 -0
  128. package/native/freebsd-x64/libzig-dtsx.so +0 -0
  129. package/native/linux-arm64/libzig-dtsx.so +0 -0
  130. package/native/linux-x64/libzig-dtsx.so +0 -0
  131. package/native/windows-x64/zig-dtsx.dll +0 -0
  132. package/package.json +1 -1
  133. package/dist/chunk-7z8pykqp.js +0 -3
  134. package/dist/chunk-c7a07a26.js +0 -7
  135. package/dist/chunk-qq5x44y9.js +0 -38
  136. package/dist/chunk-vf8jmdsp.js +0 -3
package/dist/bin/cli.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import n from"process";var U=n.argv[2];if(U==="stdin"||U==="emit"||U==="--project"){if(U==="stdin"){let{processSource:e}=await import("../src/process-source.js"),t=[];for await(let f of n.stdin)t.push(f);let o=Buffer.concat(t).toString("utf-8");if(o.trim())n.stdout.write(e(o,"stdin.ts")),n.stdout.write(`
4
4
  `)}else if(U==="--project"){let{readdirSync:e,readFileSync:t,writeFileSync:o,mkdirSync:f}=await import("fs"),p=typeof globalThis.Bun<"u",a=p?globalThis.Bun:null,l=n.argv.slice(3),y="",w="",h=!1;for(let s=0;s<l.length;s++)if(l[s]==="--outdir"&&l[s+1])w=l[s+1],s++;else if(l[s]==="--isolated-declarations")h=!0;else if(!y)y=l[s];f(w,{recursive:!0});let m=e(y).filter((s)=>s.endsWith(".ts")&&!s.endsWith(".d.ts")),i=m.length,u=Array(i),c=Array(i);for(let s=0;s<i;s++)u[s]=`${y}/${m[s]}`,c[s]=`${w}/${m[s].slice(0,-3)}.d.ts`;let g=["bun"],k=16777216,{nativeEngineAvailable:P}=await import("../src/native-engine.js"),x=!1;if(p&&i>=256&&!P()){let s=0;for(let E=0;E<i&&!x;E++)s+=a.file(u[E]).size,x=s>=k}let C=!1,b=null;if(x){let s=null;try{let{createWorkerPool:E,calculateOptimalBatchSize:L}=await import("../src/worker.js"),{cpus:I}=await import("os"),F=Math.max(1,I().length-1),T=Math.min(64,Math.max(8,L(i,F)*2)),d=i>=256,S=!0,W=i>=256;if(!d&&i>=256){b=Array(i);for(let j=0;j<i;j++)b[j]=a.file(u[j]).text()}let _=Math.ceil(i/T),X=Math.min(_,Math.max(2,F*2));s=E({maxWorkers:F,initialWorkers:F,recycleAfter:Math.max(100,_+1)}),await s.init();let Z=s,Y=0,q=Date.now(),ee=async()=>{for(;;){let j=Y++;if(j>=_)return;let M=j*T;if(M>=i)return;let G=Math.min(i,M+T)-M,z;if(W){let B=Array(G),A=Array(G),R;if(d)for(let v=0;v<G;v++){let O=M+v;B[v]=u[O],A[v]=c[O]}else{let v=Array(G);for(let O=0;O<G;O++){let J=M+O;B[O]=u[J],A[O]=c[J],v[O]=b?b[J]:a.file(u[J]).text()}R=await Promise.all(v)}z=await Z.submit({id:`batch-${q}-${j}`,type:"process-batch",filePath:B[0]||"",filePaths:B,sources:R,outPaths:A,writeOutput:!0,config:{keepComments:!0,importOrder:g,isolatedDeclarations:h}})}else{let B=Array(G);if(d)for(let A=0;A<G;A++){let R=M+A;B[A]={filePath:u[R],outPath:c[R]}}else{let A=Array(G);for(let v=0;v<G;v++){let O=M+v;A[v]=b?b[O]:a.file(u[O]).text()}let R=await Promise.all(A);for(let v=0;v<G;v++){let O=M+v;B[v]={filePath:u[O],sourceCode:R[v],outPath:c[O]}}}z=await Z.submit({id:`batch-${q}-${j}`,type:"process-batch",filePath:u[M]||"",files:B,writeOutput:!0,config:{keepComments:!0,importOrder:g,isolatedDeclarations:h}})}if(!z.success)throw Error(z.error||`Worker batch failed for ${u[M]}`);if(z.batchResults?.length){let B=z.batchResults[0];throw Error(B?.error||z.error||`Worker failed for ${u[M]}`)}}},H=[];for(let j=0;j<X;j++)H.push(ee());await Promise.all(H),C=!0}catch{C=!1}finally{if(s)await s.shutdown()}}if(!C){let{scanDeclarations:s}=await import("../src/extractor/scanner.js"),{processDeclarations:E}=await import("../src/processor.js"),{emitNatively:L}=await import("../src/process-source.js"),I=Array(i);if(p){let d=b?await Promise.all(b):await Promise.all(u.map((S)=>a.file(S).text()));for(let S=0;S<i;S++)I[S]=d[S]}else for(let d=0;d<i;d++)I[d]=t(u[d],"utf-8");let F=Array(i),T={filePath:"",sourceCode:"",declarations:[]};for(let d=0;d<i;d++){let S=L(I[d],m[d],!0,g,h);if(S!==null){F[d]=S;continue}let W=s(I[d],m[d],!0,h);T.filePath=m[d],T.sourceCode=I[d],T.declarations=W,F[d]=E(W,T,!0,g)}if(p){let d=Array(i);for(let S=0;S<i;S++)d[S]=a.write(c[S],F[S]);await Promise.all(d)}else for(let d=0;d<i;d++)o(c[d],F[d])}}else{let{processSource:e}=await import("../src/process-source.js"),{readFileSync:t,writeFileSync:o,mkdirSync:f}=await import("fs"),p=typeof globalThis.Bun<"u",a=p?globalThis.Bun:null,l=n.argv[3],y=p?await a.file(l).text():t(l,"utf-8"),w=n.argv[4];if(w){let{dirname:h}=await import("path");f(h(w),{recursive:!0});let m=`${e(y,l)}
5
5
  `;if(p)await a.write(w,m);else o(w,m)}else n.stdout.write(e(y,l)),n.stdout.write(`
6
- `)}n.exit(0)}var{resolve:N}=await import("path"),{CLI:te}=await import("../chunk-asws39qs.js"),{version:Q}=await import("../chunk-cyw59tgm.js"),{getConfig:oe}=await import("../src/config.js"),{generate:re,processSource:ne,watch:se}=await import("../src/generator.js"),D=new te("dtsx"),r={cwd:n.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!1,tsconfigPath:"tsconfig.json",verbose:!1,importOrder:["bun"],dryRun:!1,stats:!1,continueOnError:!1,logLevel:"info",exclude:[],outputFormat:"text",progress:!1,diff:!1,validate:!1,parallel:!1,concurrency:4};function V(e){if(e===void 0)return;let t=(Array.isArray(e)?e:[e]).flatMap((o)=>String(o).split(",")).map((o)=>o.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}D.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--clean","Clean output directory before generation",{default:r.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:r.tsconfigPath}).option("--module-specifier-mode <mode>","Declaration module specifiers: preserve or node").option("--verbose","Enable verbose logging",{default:r.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:r.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:r.dryRun}).option("--stats","Show statistics after generation",{default:r.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:r.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:r.outputFormat}).option("--progress","Show progress during generation",{default:r.progress}).option("--diff","Show diff of changes compared to existing files",{default:r.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:r.validate}).option("--parallel","Process files in parallel",{default:r.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:r.concurrency}).option("--declaration-map","Generate declaration map files (.d.ts.map)",{default:!1}).option("--bundle","Bundle all declarations into a single output file",{default:!1}).option("--bundle-output <file>","Output filename when bundling (relative to outdir)",{default:"index.d.ts"}).option("--config <path>","Path to config file (dtsx.config.ts)",{default:""}).option("--incremental","Enable incremental builds (only regenerate changed files)",{default:!1}).option("--clear-cache","Clear the incremental build cache before generating",{default:!1}).option("--indent-style <style>","Indentation style: spaces or tabs",{default:"spaces"}).option("--indent-size <size>","Number of spaces for indentation",{default:2}).option("--prettier","Use Prettier for output formatting if available",{default:!1}).example("dtsx generate").example("dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types").example("dtsx generate --entrypoints index.ts --entrypoints mime/index.ts --root src").example('dtsx generate --import-order "node:,bun,@myorg/"').example("dtsx generate --dry-run --stats").example('dtsx generate --exclude "**/*.test.ts,**/__tests__/**"').example("dtsx generate --stats --output-format json").example("dtsx generate --bundle --bundle-output types.d.ts").action(async(e)=>{try{let t=N(e.cwd||r.cwd),o=await oe(t),f={entrypoints:V(e.entrypoints)??o.entrypoints??r.entrypoints,cwd:t,root:N(e.root||o.root||r.root),outdir:N(e.outdir||o.outdir||r.outdir),tsconfigPath:N(e.tsconfigPath||o.tsconfigPath||r.tsconfigPath),moduleSpecifierMode:e.moduleSpecifierMode??o.moduleSpecifierMode??r.moduleSpecifierMode,keepComments:e.keepComments??o.keepComments??r.keepComments,clean:e.clean??o.clean??r.clean,verbose:e.verbose??o.verbose??r.verbose,importOrder:V(e.importOrder)??o.importOrder??r.importOrder,dryRun:e.dryRun??o.dryRun??r.dryRun,stats:e.stats??o.stats??r.stats,continueOnError:e.continueOnError??o.continueOnError??r.continueOnError,logLevel:e.logLevel??o.logLevel??r.logLevel,exclude:e.exclude?e.exclude.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean)):o.exclude||r.exclude,outputFormat:e.outputFormat??o.outputFormat??r.outputFormat,progress:e.progress??o.progress??r.progress,diff:e.diff??o.diff??r.diff,validate:e.validate??o.validate??r.validate,parallel:e.parallel??o.parallel??r.parallel,concurrency:Number(e.concurrency)||o.concurrency||r.concurrency,declarationMap:e.declarationMap??o.declarationMap??!1,bundle:e.bundle??o.bundle??!1,bundleOutput:e.bundleOutput??o.bundleOutput??"index.d.ts",incremental:e.incremental??o.incremental??!1,cacheDir:o.cacheDir,clearCache:e.clearCache??!1,indentStyle:e.indentStyle??o.indentStyle??"spaces",indentSize:Number(e.indentSize)||o.indentSize||2,prettier:e.prettier??o.prettier??!1,plugins:o.plugins},p=await re(f);if(p.filesFailed>0&&p.filesGenerated===0)n.exit(1);else if(p.filesFailed>0)n.exit(2)}catch(t){if(console.error(`Error generating .d.ts files: ${t instanceof Error?t.message:String(t)}`),e.verbose&&t instanceof Error&&t.stack)console.error(t.stack);n.exit(1)}});D.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(e)=>{try{let t={entrypoints:V(e.entrypoints)??r.entrypoints,cwd:N(e.cwd||r.cwd),root:N(e.root||r.root),outdir:N(e.outdir||r.outdir),keepComments:e.keepComments??r.keepComments,exclude:e.exclude?e.exclude.flatMap((o)=>o.split(",").map((f)=>f.trim()).filter(Boolean)):r.exclude,logLevel:e.logLevel??r.logLevel};await se(t)}catch(t){console.error("Error in watch mode:",t),n.exit(1)}});D.command("stdin","Process TypeScript from stdin and output .d.ts to stdout").option("--keep-comments","Keep comments in generated .d.ts files",{default:!0}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:"bun",type:[String]}).example(`echo "export const foo: string = 'bar'" | dtsx stdin`).example("cat src/index.ts | dtsx stdin").action(async(e)=>{try{let t=[];for await(let a of n.stdin)t.push(a);let o=Buffer.concat(t).toString("utf-8");if(!o.trim())console.error("Error: No input received from stdin"),n.exit(1);let f=["bun"];if(e.importOrder){if(Array.isArray(e.importOrder))f=e.importOrder.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean));else if(typeof e.importOrder==="string")f=e.importOrder.split(",").map((a)=>a.trim()).filter(Boolean)}let p=ne(o,"stdin.ts",e.keepComments??!0,f);console.log(p)}catch(t){console.error("Error processing stdin:",t),n.exit(1)}});D.command("optimize","Optimize declaration files").option("--files <patterns>","Glob patterns for .d.ts files to optimize",{default:"**/*.d.ts",type:[String]}).option("--outdir <path>","Output directory (defaults to in-place)",{default:""}).option("--remove-unused-imports","Remove unused type imports",{default:!0}).option("--deduplicate","Remove duplicate declarations",{default:!0}).option("--merge-interfaces","Merge interface declarations with same name",{default:!0}).option("--inline-types","Inline simple type aliases",{default:!1}).option("--remove-empty","Remove empty interfaces",{default:!0}).option("--sort","Sort declarations alphabetically",{default:!1}).option("--sort-imports","Sort imports",{default:!0}).option("--minify","Minify output (remove whitespace)",{default:!1}).option("--remove-comments","Remove comments",{default:!1}).example('dtsx optimize --files "dist/**/*.d.ts"').example("dtsx optimize --minify --remove-comments").action(async(e)=>{try{let{optimizeFile:t}=await import("../src/optimizer.js"),{Glob:o}=await Promise.resolve(globalThis.Bun),{resolve:f,join:p,relative:a,dirname:l,basename:y}=await import("path"),{mkdirSync:w,copyFileSync:h,existsSync:m}=await import("fs"),i=n.cwd(),u=e.files||["**/*.d.ts"],c=[];for(let x of u){let C=new o(x);for await(let b of C.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(b.endsWith(".d.ts")&&!b.includes("node_modules"))c.push(b)}if(c.length===0)console.error("No .d.ts files found"),n.exit(1);console.log(`Optimizing ${c.length} declaration files...`);let g=0,k=0;for(let x of c){let C=x;if(e.outdir){let E=a(i,x);C=p(f(e.outdir),E);let L=l(C);if(!m(L))w(L,{recursive:!0});h(x,C)}let b=await t(C,{removeUnusedImports:e.removeUnusedImports??!0,deduplicateDeclarations:e.deduplicate??!0,mergeInterfaces:e.mergeInterfaces??!0,inlineSimpleTypes:e.inlineTypes??!1,removeEmptyInterfaces:e.removeEmpty??!0,sortDeclarations:e.sort??!1,sortImports:e.sortImports??!0,minify:e.minify??!1,removeComments:e.removeComments??!1});k+=b.originalSize,g+=b.savings;let s=a(i,C);console.log(` ${s}: ${b.originalSize}B -> ${b.optimizedSize}B (-${b.savingsPercent}%)`)}let P=k>0?Math.round(g/k*100):0;console.log(`
6
+ `)}n.exit(0)}var{resolve:N}=await import("path"),{CLI:te}=await import("../chunk-asws39qs.js"),{version:Q}=await import("../chunk-k0mqnrc1.js"),{getConfig:oe}=await import("../src/config.js"),{generate:re,processSource:ne,watch:se}=await import("../src/generator.js"),D=new te("dtsx"),r={cwd:n.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!1,tsconfigPath:"tsconfig.json",verbose:!1,importOrder:["bun"],dryRun:!1,stats:!1,continueOnError:!1,logLevel:"info",exclude:[],outputFormat:"text",progress:!1,diff:!1,validate:!1,parallel:!1,concurrency:4};function V(e){if(e===void 0)return;let t=(Array.isArray(e)?e:[e]).flatMap((o)=>String(o).split(",")).map((o)=>o.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}D.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--clean","Clean output directory before generation",{default:r.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:r.tsconfigPath}).option("--module-specifier-mode <mode>","Declaration module specifiers: preserve or node").option("--verbose","Enable verbose logging",{default:r.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:r.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:r.dryRun}).option("--stats","Show statistics after generation",{default:r.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:r.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:r.outputFormat}).option("--progress","Show progress during generation",{default:r.progress}).option("--diff","Show diff of changes compared to existing files",{default:r.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:r.validate}).option("--parallel","Process files in parallel",{default:r.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:r.concurrency}).option("--declaration-map","Generate declaration map files (.d.ts.map)",{default:!1}).option("--bundle","Bundle all declarations into a single output file",{default:!1}).option("--bundle-output <file>","Output filename when bundling (relative to outdir)",{default:"index.d.ts"}).option("--config <path>","Path to config file (dtsx.config.ts)",{default:""}).option("--incremental","Enable incremental builds (only regenerate changed files)",{default:!1}).option("--clear-cache","Clear the incremental build cache before generating",{default:!1}).option("--indent-style <style>","Indentation style: spaces or tabs",{default:"spaces"}).option("--indent-size <size>","Number of spaces for indentation",{default:2}).option("--prettier","Use Prettier for output formatting if available",{default:!1}).example("dtsx generate").example("dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types").example("dtsx generate --entrypoints index.ts --entrypoints mime/index.ts --root src").example('dtsx generate --import-order "node:,bun,@myorg/"').example("dtsx generate --dry-run --stats").example('dtsx generate --exclude "**/*.test.ts,**/__tests__/**"').example("dtsx generate --stats --output-format json").example("dtsx generate --bundle --bundle-output types.d.ts").action(async(e)=>{try{let t=N(e.cwd||r.cwd),o=await oe(t),f={entrypoints:V(e.entrypoints)??o.entrypoints??r.entrypoints,cwd:t,root:N(e.root||o.root||r.root),outdir:N(e.outdir||o.outdir||r.outdir),tsconfigPath:N(e.tsconfigPath||o.tsconfigPath||r.tsconfigPath),moduleSpecifierMode:e.moduleSpecifierMode??o.moduleSpecifierMode??r.moduleSpecifierMode,keepComments:e.keepComments??o.keepComments??r.keepComments,clean:e.clean??o.clean??r.clean,verbose:e.verbose??o.verbose??r.verbose,importOrder:V(e.importOrder)??o.importOrder??r.importOrder,dryRun:e.dryRun??o.dryRun??r.dryRun,stats:e.stats??o.stats??r.stats,continueOnError:e.continueOnError??o.continueOnError??r.continueOnError,logLevel:e.logLevel??o.logLevel??r.logLevel,exclude:e.exclude?e.exclude.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean)):o.exclude||r.exclude,outputFormat:e.outputFormat??o.outputFormat??r.outputFormat,progress:e.progress??o.progress??r.progress,diff:e.diff??o.diff??r.diff,validate:e.validate??o.validate??r.validate,parallel:e.parallel??o.parallel??r.parallel,concurrency:Number(e.concurrency)||o.concurrency||r.concurrency,declarationMap:e.declarationMap??o.declarationMap??!1,bundle:e.bundle??o.bundle??!1,bundleOutput:e.bundleOutput??o.bundleOutput??"index.d.ts",incremental:e.incremental??o.incremental??!1,cacheDir:o.cacheDir,clearCache:e.clearCache??!1,indentStyle:e.indentStyle??o.indentStyle??"spaces",indentSize:Number(e.indentSize)||o.indentSize||2,prettier:e.prettier??o.prettier??!1,plugins:o.plugins},p=await re(f);if(p.filesFailed>0&&p.filesGenerated===0)n.exit(1);else if(p.filesFailed>0)n.exit(2)}catch(t){if(console.error(`Error generating .d.ts files: ${t instanceof Error?t.message:String(t)}`),e.verbose&&t instanceof Error&&t.stack)console.error(t.stack);n.exit(1)}});D.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(e)=>{try{let t={entrypoints:V(e.entrypoints)??r.entrypoints,cwd:N(e.cwd||r.cwd),root:N(e.root||r.root),outdir:N(e.outdir||r.outdir),keepComments:e.keepComments??r.keepComments,exclude:e.exclude?e.exclude.flatMap((o)=>o.split(",").map((f)=>f.trim()).filter(Boolean)):r.exclude,logLevel:e.logLevel??r.logLevel};await se(t)}catch(t){console.error("Error in watch mode:",t),n.exit(1)}});D.command("stdin","Process TypeScript from stdin and output .d.ts to stdout").option("--keep-comments","Keep comments in generated .d.ts files",{default:!0}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:"bun",type:[String]}).example(`echo "export const foo: string = 'bar'" | dtsx stdin`).example("cat src/index.ts | dtsx stdin").action(async(e)=>{try{let t=[];for await(let a of n.stdin)t.push(a);let o=Buffer.concat(t).toString("utf-8");if(!o.trim())console.error("Error: No input received from stdin"),n.exit(1);let f=["bun"];if(e.importOrder){if(Array.isArray(e.importOrder))f=e.importOrder.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean));else if(typeof e.importOrder==="string")f=e.importOrder.split(",").map((a)=>a.trim()).filter(Boolean)}let p=ne(o,"stdin.ts",e.keepComments??!0,f);console.log(p)}catch(t){console.error("Error processing stdin:",t),n.exit(1)}});D.command("optimize","Optimize declaration files").option("--files <patterns>","Glob patterns for .d.ts files to optimize",{default:"**/*.d.ts",type:[String]}).option("--outdir <path>","Output directory (defaults to in-place)",{default:""}).option("--remove-unused-imports","Remove unused type imports",{default:!0}).option("--deduplicate","Remove duplicate declarations",{default:!0}).option("--merge-interfaces","Merge interface declarations with same name",{default:!0}).option("--inline-types","Inline simple type aliases",{default:!1}).option("--remove-empty","Remove empty interfaces",{default:!0}).option("--sort","Sort declarations alphabetically",{default:!1}).option("--sort-imports","Sort imports",{default:!0}).option("--minify","Minify output (remove whitespace)",{default:!1}).option("--remove-comments","Remove comments",{default:!1}).example('dtsx optimize --files "dist/**/*.d.ts"').example("dtsx optimize --minify --remove-comments").action(async(e)=>{try{let{optimizeFile:t}=await import("../src/optimizer.js"),{Glob:o}=await Promise.resolve(globalThis.Bun),{resolve:f,join:p,relative:a,dirname:l,basename:y}=await import("path"),{mkdirSync:w,copyFileSync:h,existsSync:m}=await import("fs"),i=n.cwd(),u=e.files||["**/*.d.ts"],c=[];for(let x of u){let C=new o(x);for await(let b of C.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(b.endsWith(".d.ts")&&!b.includes("node_modules"))c.push(b)}if(c.length===0)console.error("No .d.ts files found"),n.exit(1);console.log(`Optimizing ${c.length} declaration files...`);let g=0,k=0;for(let x of c){let C=x;if(e.outdir){let E=a(i,x);C=p(f(e.outdir),E);let L=l(C);if(!m(L))w(L,{recursive:!0});h(x,C)}let b=await t(C,{removeUnusedImports:e.removeUnusedImports??!0,deduplicateDeclarations:e.deduplicate??!0,mergeInterfaces:e.mergeInterfaces??!0,inlineSimpleTypes:e.inlineTypes??!1,removeEmptyInterfaces:e.removeEmpty??!0,sortDeclarations:e.sort??!1,sortImports:e.sortImports??!0,minify:e.minify??!1,removeComments:e.removeComments??!1});k+=b.originalSize,g+=b.savings;let s=a(i,C);console.log(` ${s}: ${b.originalSize}B -> ${b.optimizedSize}B (-${b.savingsPercent}%)`)}let P=k>0?Math.round(g/k*100):0;console.log(`
7
7
  Total: ${k}B -> ${k-g}B (-${P}%)`)}catch(t){console.error("Error optimizing files:",t),n.exit(1)}});D.command("docs","Generate API documentation from source files").option("--root <path>","Root directory to scan for source files",{default:"./src"}).option("--outdir <path>","Output directory for documentation",{default:"./docs"}).option("--format <format>","Output format: markdown or html",{default:"markdown"}).option("--title <title>","Documentation title",{default:"API Documentation"}).option("--include-private","Include private members (prefixed with _)",{default:!1}).option("--include-internal","Include internal members (@internal)",{default:!1}).option("--group-by-category","Group entries by @category tag",{default:!1}).option("--source-url <url>","Base URL for source links").example("dtsx docs").example("dtsx docs --format html --outdir ./api-docs").example('dtsx docs --group-by-category --title "My API"').action(async(e)=>{try{let{generateDocs:t}=await import("../src/docs.js"),{Glob:o}=await Promise.resolve(globalThis.Bun),{resolve:f}=await import("path"),p=f(e.root||"./src"),a=new o("**/*.ts"),l=[];for await(let y of a.scan({cwd:p,absolute:!0,onlyFiles:!0}))if(!y.endsWith(".d.ts")&&!y.includes("node_modules"))l.push(y);if(l.length===0)console.error("No TypeScript files found"),n.exit(1);console.log(`Found ${l.length} source files`),await t(l,{format:e.format||"markdown",outdir:f(e.outdir||"./docs"),title:e.title||"API Documentation",includePrivate:e.includePrivate??!1,includeInternal:e.includeInternal??!1,groupByCategory:e.groupByCategory??!1,includeSourceLinks:!!e.sourceUrl,sourceBaseUrl:e.sourceUrl})}catch(t){console.error("Error generating documentation:",t),n.exit(1)}});D.command("workspace","Generate declarations for all projects in a monorepo/workspace").option("--cwd <path>","Workspace root directory",{default:n.cwd()}).option("--parallel","Process projects in parallel",{default:!1}).option("--continue-on-error","Continue if a project fails",{default:!0}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:"info"}).example("dtsx workspace").example("dtsx workspace --cwd /path/to/monorepo").action(async(e)=>{try{let{generateMonorepo:t,generateFromPackageWorkspaces:o}=await import("../src/workspace.js"),{existsSync:f}=await import("fs"),{join:p,resolve:a}=await import("path"),l=a(e.cwd||n.cwd()),y=p(l,"tsconfig.json"),w;if(f(y))w=await t(l,{logLevel:e.logLevel||"info",continueOnError:e.continueOnError??!0});else w=await o(l,{logLevel:e.logLevel||"info",continueOnError:e.continueOnError??!0});if(!w.success)n.exit(1)}catch(t){console.error("Error generating workspace declarations:",t),n.exit(1)}});D.command("lsp","Start the Language Server Protocol server for IDE integration").example("dtsx lsp").action(async()=>{let{startLSPServer:e}=await import("../src/lsp.js");e()});D.command("check","Type check TypeScript files or validate generated declarations").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--declarations-only","Only check .d.ts files",{default:!1}).option("--tsconfig <path>","Path to tsconfig.json",{default:"tsconfig.json"}).option("--strict","Enable strict type checking",{default:!1}).option("--skip-lib-check","Skip checking library definitions",{default:!0}).option("--warnings-as-errors","Treat warnings as errors",{default:!1}).option("--max-errors <number>","Maximum errors before stopping",{default:0}).option("--isolated-declarations","Check if code follows isolated declarations best practices (recommended)",{default:!1}).option("--format <format>","Output format: text or json",{default:"text"}).example("dtsx check").example('dtsx check --files "src/**/*.ts" --strict').example('dtsx check --declarations-only --files "dist/**/*.d.ts"').example("dtsx check --isolated-declarations").action(async(e)=>{try{let{typeCheck:t,checkIsolatedDeclarations:o,formatTypeCheckResults:f}=await import("../chunk-5hyv43ps.js"),{Glob:p}=await Promise.resolve(globalThis.Bun),{resolve:a,relative:l}=await import("path"),y=n.cwd(),w=e.files||["**/*.ts"],h=[];for(let i of w){let u=new p(i);for await(let c of u.scan({cwd:y,absolute:!0,onlyFiles:!0}))if(!c.includes("node_modules"))if(e.declarationsOnly){if(c.endsWith(".d.ts"))h.push(c)}else h.push(c)}if(h.length===0)console.error("No files found to check"),n.exit(1);if(e.isolatedDeclarations){console.log(`Checking ${h.length} files for isolated declarations best practices...`);let i=await o(h,e.tsconfig?a(e.tsconfig):void 0),u=0,c=[];for(let[g,k]of i){let P=l(y,g);if(!k.compatible)if(u+=k.issues.length,e.format==="json")c.push({file:P,compatible:!1,issues:k.issues});else{console.log(`
8
8
  \u2717 ${P}`);for(let x of k.issues)if(console.log(` ${x.line}:${x.column} - ${x.message}`),x.missingAnnotation)console.log(` Missing: ${x.missingAnnotation} type annotation`)}else if(e.format==="json")c.push({file:P,compatible:!0,issues:[]})}if(e.format==="json")console.log(JSON.stringify(c,null,2));else if(u>0)console.log(`
9
9
  ${h.length} files checked, ${u} recommendations found`),console.log("Tip: Adding explicit type annotations improves .d.ts accuracy");else console.log(`
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- class _t{config;memorySamples=[];cpuSamples=[];ioOperations=[];startTime=0;memoryInterval=null;cpuInterval=null;lastCpuUsage=null;isRunning=!1;constructor(e={}){this.config={memory:e.memory??!1,memoryLimit:e.memoryLimit??1024,cpu:e.cpu??!1,samplingInterval:e.samplingInterval??100,io:e.io??!1,trackOperations:e.trackOperations??["read","write"],outputFile:e.outputFile??""}}start(){if(this.isRunning)return;if(this.isRunning=!0,this.startTime=Date.now(),this.memorySamples=[],this.cpuSamples=[],this.ioOperations=[],this.lastCpuUsage=null,this.config.memory)this.sampleMemory(),this.memoryInterval=setInterval(()=>this.sampleMemory(),this.config.samplingInterval);if(this.config.cpu)this.sampleCpu(),this.cpuInterval=setInterval(()=>this.sampleCpu(),this.config.samplingInterval)}stop(){if(!this.isRunning)return;if(this.isRunning=!1,this.memoryInterval)clearInterval(this.memoryInterval),this.memoryInterval=null;if(this.cpuInterval)clearInterval(this.cpuInterval),this.cpuInterval=null}sampleMemory(){let e=y();this.memorySamples.push(e)}sampleCpu(){let e=d();if(this.lastCpuUsage){let t={timestamp:Date.now(),user:e.user-this.lastCpuUsage.user,system:e.system-this.lastCpuUsage.system,total:e.user-this.lastCpuUsage.user+(e.system-this.lastCpuUsage.system)};this.cpuSamples.push(t)}this.lastCpuUsage=e}recordIo(e,t,s,r){if(!this.config.io)return;if(!this.config.trackOperations.includes(e))return;this.ioOperations.push({timestamp:Date.now(),operation:e,path:t,size:s,durationMs:r})}getResults(){let e=Date.now(),t=[],s=this.memorySamples[0]||y(),r=0;for(let a of this.memorySamples){if(r+=a.heapUsed,a.heapUsed>s.heapUsed)s=a;let g=a.heapUsed/1048576;if(g>this.config.memoryLimit)t.push(`Memory limit exceeded at ${new Date(a.timestamp).toISOString()}: ${g.toFixed(2)}MB > ${this.config.memoryLimit}MB`)}let i=this.memorySamples.length>0?r/this.memorySamples.length:0,o=0,m=0;for(let a of this.cpuSamples)o+=a.user,m+=a.system;let u=0,l=0,p=0,h=0,c=0,f=0;for(let a of this.ioOperations)if(a.operation==="read")u++,p+=a.size,c+=a.durationMs;else l++,h+=a.size,f+=a.durationMs;return{startTime:this.startTime,endTime:e,durationMs:e-this.startTime,memory:{samples:this.memorySamples,peak:s,average:{timestamp:0,heapUsed:i,heapTotal:0,external:0,arrayBuffers:0,rss:0},warnings:t},cpu:{samples:this.cpuSamples,totalUser:o,totalSystem:m},io:{operations:this.ioOperations,totalReads:u,totalWrites:l,totalReadBytes:p,totalWriteBytes:h,totalReadMs:c,totalWriteMs:f}}}formatResults(){let e=this.getResults(),t=["=== Profiling Results ===",""];if(t.push(`Duration: ${e.durationMs}ms`),t.push(""),this.config.memory){if(t.push("Memory:"),t.push(` Samples: ${e.memory.samples.length}`),t.push(` Peak heap: ${n(e.memory.peak.heapUsed)}`),t.push(` Average heap: ${n(e.memory.average.heapUsed)}`),e.memory.warnings.length>0){t.push(" Warnings:");for(let s of e.memory.warnings)t.push(` - ${s}`)}t.push("")}if(this.config.cpu)t.push("CPU:"),t.push(` Samples: ${e.cpu.samples.length}`),t.push(` Total user time: ${(e.cpu.totalUser/1000).toFixed(2)}ms`),t.push(` Total system time: ${(e.cpu.totalSystem/1000).toFixed(2)}ms`),t.push("");if(this.config.io)t.push("I/O:"),t.push(` Total reads: ${e.io.totalReads}`),t.push(` Total writes: ${e.io.totalWrites}`),t.push(` Total read: ${n(e.io.totalReadBytes)} in ${e.io.totalReadMs.toFixed(2)}ms`),t.push(` Total write: ${n(e.io.totalWriteBytes)} in ${e.io.totalWriteMs.toFixed(2)}ms`),t.push("");return t.join(`
3
- `)}async writeResults(){if(!this.config.outputFile)return;let e=this.getResults(),t=JSON.stringify(e,null,2);try{let s=await import("fs/promises");await s.writeFile(this.config.outputFile,t,"utf-8")}catch{await Bun.write(this.config.outputFile,t)}}}function y(){if(typeof process<"u"&&process.memoryUsage){let e=process.memoryUsage();return{timestamp:Date.now(),heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers||0,rss:e.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function d(){if(typeof process<"u"&&process.cpuUsage){let e=process.cpuUsage();return{user:e.user,system:e.system}}return{user:0,system:0}}function n(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],s=1024,r=Math.floor(Math.log(e)/Math.log(s));return`${Number.parseFloat((e/s**r).toFixed(2))} ${t[r]}`}function gr(e){return new _t(e)}async function Zi(e,t){let s=gr({memory:!0,cpu:!0,...t});s.start();try{return{result:await e(),profile:s.getResults()}}finally{s.stop()}}function Qi(e){return{async read(t,s){let r=Date.now();try{let i=await s(),o=typeof i==="string"?i.length:0;return e.recordIo("read",t,o,Date.now()-r),i}catch(i){throw e.recordIo("read",t,0,Date.now()-r),i}},async write(t,s,r){let i=Date.now();try{await s(),e.recordIo("write",t,r,Date.now()-i)}catch(o){throw e.recordIo("write",t,0,Date.now()-i),o}}}}class Gt{marks=new Map;durations=new Map;mark(e){this.marks.set(e,performance.now())}measure(e,t){let s=this.marks.get(t);if(s===void 0)throw Error(`Mark "${t}" not found`);let r=performance.now()-s,i=this.durations.get(e)||[];return i.push(r),this.durations.set(e,i),r}getDurations(e){return this.durations.get(e)||[]}getAverage(e){let t=this.getDurations(e);if(t.length===0)return 0;return t.reduce((s,r)=>s+r,0)/t.length}getSummary(){let e=new Map;for(let[t,s]of this.durations)e.set(t,{count:s.length,total:s.reduce((r,i)=>r+i,0),average:s.reduce((r,i)=>r+i,0)/s.length,min:Math.min(...s),max:Math.max(...s)});return e}clear(){this.marks.clear(),this.durations.clear()}}function es(){return new Gt}
4
- export{_t,gr,Zi,Qi,Gt,es};
2
+ class jt{config;memorySamples=[];cpuSamples=[];ioOperations=[];startTime=0;memoryInterval=null;cpuInterval=null;lastCpuUsage=null;isRunning=!1;constructor(e={}){this.config={memory:e.memory??!1,memoryLimit:e.memoryLimit??1024,cpu:e.cpu??!1,samplingInterval:e.samplingInterval??100,io:e.io??!1,trackOperations:e.trackOperations??["read","write"],outputFile:e.outputFile??""}}start(){if(this.isRunning)return;if(this.isRunning=!0,this.startTime=Date.now(),this.memorySamples=[],this.cpuSamples=[],this.ioOperations=[],this.lastCpuUsage=null,this.config.memory)this.sampleMemory(),this.memoryInterval=setInterval(()=>this.sampleMemory(),this.config.samplingInterval);if(this.config.cpu)this.sampleCpu(),this.cpuInterval=setInterval(()=>this.sampleCpu(),this.config.samplingInterval)}stop(){if(!this.isRunning)return;if(this.isRunning=!1,this.memoryInterval)clearInterval(this.memoryInterval),this.memoryInterval=null;if(this.cpuInterval)clearInterval(this.cpuInterval),this.cpuInterval=null}sampleMemory(){let e=y();this.memorySamples.push(e)}sampleCpu(){let e=d();if(this.lastCpuUsage){let t={timestamp:Date.now(),user:e.user-this.lastCpuUsage.user,system:e.system-this.lastCpuUsage.system,total:e.user-this.lastCpuUsage.user+(e.system-this.lastCpuUsage.system)};this.cpuSamples.push(t)}this.lastCpuUsage=e}recordIo(e,t,s,r){if(!this.config.io)return;if(!this.config.trackOperations.includes(e))return;this.ioOperations.push({timestamp:Date.now(),operation:e,path:t,size:s,durationMs:r})}getResults(){let e=Date.now(),t=[],s=this.memorySamples[0]||y(),r=0;for(let a of this.memorySamples){if(r+=a.heapUsed,a.heapUsed>s.heapUsed)s=a;let g=a.heapUsed/1048576;if(g>this.config.memoryLimit)t.push(`Memory limit exceeded at ${new Date(a.timestamp).toISOString()}: ${g.toFixed(2)}MB > ${this.config.memoryLimit}MB`)}let i=this.memorySamples.length>0?r/this.memorySamples.length:0,o=0,m=0;for(let a of this.cpuSamples)o+=a.user,m+=a.system;let u=0,l=0,p=0,h=0,c=0,f=0;for(let a of this.ioOperations)if(a.operation==="read")u++,p+=a.size,c+=a.durationMs;else l++,h+=a.size,f+=a.durationMs;return{startTime:this.startTime,endTime:e,durationMs:e-this.startTime,memory:{samples:this.memorySamples,peak:s,average:{timestamp:0,heapUsed:i,heapTotal:0,external:0,arrayBuffers:0,rss:0},warnings:t},cpu:{samples:this.cpuSamples,totalUser:o,totalSystem:m},io:{operations:this.ioOperations,totalReads:u,totalWrites:l,totalReadBytes:p,totalWriteBytes:h,totalReadMs:c,totalWriteMs:f}}}formatResults(){let e=this.getResults(),t=["=== Profiling Results ===",""];if(t.push(`Duration: ${e.durationMs}ms`),t.push(""),this.config.memory){if(t.push("Memory:"),t.push(` Samples: ${e.memory.samples.length}`),t.push(` Peak heap: ${n(e.memory.peak.heapUsed)}`),t.push(` Average heap: ${n(e.memory.average.heapUsed)}`),e.memory.warnings.length>0){t.push(" Warnings:");for(let s of e.memory.warnings)t.push(` - ${s}`)}t.push("")}if(this.config.cpu)t.push("CPU:"),t.push(` Samples: ${e.cpu.samples.length}`),t.push(` Total user time: ${(e.cpu.totalUser/1000).toFixed(2)}ms`),t.push(` Total system time: ${(e.cpu.totalSystem/1000).toFixed(2)}ms`),t.push("");if(this.config.io)t.push("I/O:"),t.push(` Total reads: ${e.io.totalReads}`),t.push(` Total writes: ${e.io.totalWrites}`),t.push(` Total read: ${n(e.io.totalReadBytes)} in ${e.io.totalReadMs.toFixed(2)}ms`),t.push(` Total write: ${n(e.io.totalWriteBytes)} in ${e.io.totalWriteMs.toFixed(2)}ms`),t.push("");return t.join(`
3
+ `)}async writeResults(){if(!this.config.outputFile)return;let e=this.getResults(),t=JSON.stringify(e,null,2);try{let s=await import("fs/promises");await s.writeFile(this.config.outputFile,t,"utf-8")}catch{await Bun.write(this.config.outputFile,t)}}}function y(){if(typeof process<"u"&&process.memoryUsage){let e=process.memoryUsage();return{timestamp:Date.now(),heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers||0,rss:e.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function d(){if(typeof process<"u"&&process.cpuUsage){let e=process.cpuUsage();return{user:e.user,system:e.system}}return{user:0,system:0}}function n(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],s=1024,r=Math.floor(Math.log(e)/Math.log(s));return`${Number.parseFloat((e/s**r).toFixed(2))} ${t[r]}`}function gr(e){return new jt(e)}async function Zi(e,t){let s=gr({memory:!0,cpu:!0,...t});s.start();try{return{result:await e(),profile:s.getResults()}}finally{s.stop()}}function Qi(e){return{async read(t,s){let r=Date.now();try{let i=await s(),o=typeof i==="string"?i.length:0;return e.recordIo("read",t,o,Date.now()-r),i}catch(i){throw e.recordIo("read",t,0,Date.now()-r),i}},async write(t,s,r){let i=Date.now();try{await s(),e.recordIo("write",t,r,Date.now()-i)}catch(o){throw e.recordIo("write",t,0,Date.now()-i),o}}}}class Gt{marks=new Map;durations=new Map;mark(e){this.marks.set(e,performance.now())}measure(e,t){let s=this.marks.get(t);if(s===void 0)throw Error(`Mark "${t}" not found`);let r=performance.now()-s,i=this.durations.get(e)||[];return i.push(r),this.durations.set(e,i),r}getDurations(e){return this.durations.get(e)||[]}getAverage(e){let t=this.getDurations(e);if(t.length===0)return 0;return t.reduce((s,r)=>s+r,0)/t.length}getSummary(){let e=new Map;for(let[t,s]of this.durations)e.set(t,{count:s.length,total:s.reduce((r,i)=>r+i,0),average:s.reduce((r,i)=>r+i,0)/s.length,min:Math.min(...s),max:Math.max(...s)});return e}clear(){this.marks.clear(),this.durations.clear()}}function es(){return new Gt}
4
+ export{jt,gr,Zi,Qi,Gt,es};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{u}from"./chunk-ayyb1jpe.js";import{m}from"./chunk-c7a07a26.js";import{y}from"./chunk-jfygtm4r.js";import{r}from"./chunk-z6mpxpxt.js";import{$e}from"./chunk-zk55g2cb.js";function Xo(c){if(!c.includes("declare")||!c.includes("module"))return[];return m(c).filter((d)=>d.category==="augmentation").map((d)=>d.specifier)}function E(c,d){let p=new Set([c]);for(let v of p)for(let h of d(v))p.add(h);return p}async function Se(c,d,p=!1,v){let h=new Map,x=new Map;for(let e of c){let g=v?.get(e)??await u(e);h.set(e,g);let s=Xo(g);if(s.length)x.set(e,s)}let M=new Map;if(x.size===0)return M;let l=new Map,b=(e,g)=>{let s=d(e,g);if(s.resolved)return s.resolved;if(!s.isRelative&&!s.isAlias)return`external:${e}`;return};for(let[e,g]of h){let s=r(g,e,!1,p),a=$e(s),f={edges:[],declarations:new Set,augmentations:new Set},w=(n,i,t)=>{let o=b(n.specifier,e);if(!o)return;if(h.has(o))f.edges.push({specifier:n.specifier,target:o,import:i});if(t)f.declarations.add(o)};for(let n of s){if(n.kind!=="import")continue;let i=n.isSideEffect||y(n.text).some((t)=>a.usedItems.has(t));for(let t of m(n.text))w(t,!0,!!i)}for(let n of m(a.referenceText))w(n,!1,!0);for(let n of x.get(e)??[]){let i=b(n,e);if(i)f.augmentations.add(i),f.declarations.add(i)}l.set(e,f)}let R=!0;while(R){R=!1;for(let[e,g]of l){let s=E(e,(a)=>l.get(a)?.declarations??[]);for(let[a,f]of l){if(s.has(a)||!f.augmentations.size||![...f.augmentations].some((t)=>s.has(t)))continue;let w=[e],n=new Map,i=new Set([e]);for(let t of w){if(t===a)break;for(let o of l.get(t).edges){if(i.has(o.target))continue;i.add(o.target),n.set(o.target,{from:t,edge:o}),w.push(o.target)}}if(!n.has(a))continue;for(let t=a;t!==e;){let{from:o,edge:I}=n.get(t),A=l.get(o);if(I.import){let S=M.get(o);if(!S)S=new Set,M.set(o,S);S.add(I.specifier)}if(!A.declarations.has(t))A.declarations.add(t),R=!0;t=o}}}}return M}
2
+ import{u}from"./chunk-85d82vn3.js";import{m}from"./chunk-g0dxj89b.js";import{y}from"./chunk-a2dn9j88.js";import{r}from"./chunk-xmj05115.js";import{$e}from"./chunk-8qvphjgv.js";function Xo(c){if(!c.includes("declare")||!c.includes("module"))return[];return m(c).filter((d)=>d.category==="augmentation").map((d)=>d.specifier)}function E(c,d){let p=new Set([c]);for(let v of p)for(let h of d(v))p.add(h);return p}async function Se(c,d,p=!1,v){let h=new Map,x=new Map;for(let e of c){let g=v?.get(e)??await u(e);h.set(e,g);let s=Xo(g);if(s.length)x.set(e,s)}let M=new Map;if(x.size===0)return M;let l=new Map,b=(e,g)=>{let s=d(e,g);if(s.resolved)return s.resolved;if(!s.isRelative&&!s.isAlias)return`external:${e}`;return};for(let[e,g]of h){let s=r(g,e,!1,p),a=$e(s),f={edges:[],declarations:new Set,augmentations:new Set},w=(n,i,t)=>{let o=b(n.specifier,e);if(!o)return;if(h.has(o))f.edges.push({specifier:n.specifier,target:o,import:i});if(t)f.declarations.add(o)};for(let n of s){if(n.kind!=="import")continue;let i=n.isSideEffect||y(n.text).some((t)=>a.usedItems.has(t));for(let t of m(n.text))w(t,!0,!!i)}for(let n of m(a.referenceText))w(n,!1,!0);for(let n of x.get(e)??[]){let i=b(n,e);if(i)f.augmentations.add(i),f.declarations.add(i)}l.set(e,f)}let R=!0;while(R){R=!1;for(let[e,g]of l){let s=E(e,(a)=>l.get(a)?.declarations??[]);for(let[a,f]of l){if(s.has(a)||!f.augmentations.size||![...f.augmentations].some((t)=>s.has(t)))continue;let w=[e],n=new Map,i=new Set([e]);for(let t of w){if(t===a)break;for(let o of l.get(t).edges){if(i.has(o.target))continue;i.add(o.target),n.set(o.target,{from:t,edge:o}),w.push(o.target)}}if(!n.has(a))continue;for(let t=a;t!==e;){let{from:o,edge:I}=n.get(t),A=l.get(o);if(I.import){let S=M.get(o);if(!S)S=new Set,M.set(o,S);S.add(I.specifier)}if(!A.declarations.has(t))A.declarations.add(t),R=!0;t=o}}}}return M}
3
3
  export{Xo,Se};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- class xe{plugins=[];config=null;register(t){if(this.plugins.some((n)=>n.name===t.name))throw Error(`Plugin "${t.name}" is already registered`);this.plugins.push(t)}hasDeclarationHooks(){return this.plugins.some((t)=>t.onDeclarations!==void 0)}unregister(t){let n=this.plugins.findIndex((r)=>r.name===t);if(n>=0)return this.plugins.splice(n,1),!0;return!1}getPlugins(){return this.plugins}createLogger(t){return{debug:(n)=>console.debug(`[${t}] ${n}`),info:(n)=>console.info(`[${t}] ${n}`),warn:(n)=>console.warn(`[${t}] ${n}`),error:(n)=>console.error(`[${t}] ${n}`)}}async runOnStart(t){let n=t;for(let r of this.plugins)if(r.onStart){let e=await r.onStart(n);if(e)n=e}return this.config=n,n}async runOnBeforeFile(t,n){let r=n;for(let e of this.plugins)if(e.onBeforeFile){let i={filePath:t,sourceCode:n,content:r,config:this.config,log:this.createLogger(e.name)},o=await e.onBeforeFile(i);if(typeof o==="string")r=o}return r}async runOnDeclarations(t,n,r){let e=r;for(let i of this.plugins)if(i.onDeclarations){let o={filePath:t,sourceCode:n,declarations:e,config:this.config,log:this.createLogger(i.name)},s=await i.onDeclarations(o);if(s)e=s}return e}async runOnAfterFile(t,n,r){let e=r;for(let i of this.plugins)if(i.onAfterFile){let o={filePath:t,sourceCode:n,content:e,config:this.config,log:this.createLogger(i.name)},s=await i.onAfterFile(o);if(typeof s==="string")e=s}return e}async runOnEnd(t){for(let n of this.plugins)if(n.onEnd)await n.onEnd(t)}async runOnError(t,n,r){for(let e of this.plugins)if(e.onError){let i={filePath:n,sourceCode:r,config:this.config,log:this.createLogger(e.name)};await e.onError(t,i)}}}var Ho=new xe;function Y(t){return t}var Ko=Y({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(t)=>t.declarations.filter((n)=>{if(n.leadingComments){if(n.leadingComments.some((e)=>e.includes("@internal")))return t.log.debug(`Stripping internal declaration: ${n.name}`),!1}return!0})});function qo(t){return Y({name:"banner",version:"1.0.0",description:"Adds a banner comment to generated files",onAfterFile:(n)=>`/**
2
+ class we{plugins=[];config=null;register(t){if(this.plugins.some((n)=>n.name===t.name))throw Error(`Plugin "${t.name}" is already registered`);this.plugins.push(t)}hasDeclarationHooks(){return this.plugins.some((t)=>t.onDeclarations!==void 0)}unregister(t){let n=this.plugins.findIndex((r)=>r.name===t);if(n>=0)return this.plugins.splice(n,1),!0;return!1}getPlugins(){return this.plugins}createLogger(t){return{debug:(n)=>console.debug(`[${t}] ${n}`),info:(n)=>console.info(`[${t}] ${n}`),warn:(n)=>console.warn(`[${t}] ${n}`),error:(n)=>console.error(`[${t}] ${n}`)}}async runOnStart(t){let n=t;for(let r of this.plugins)if(r.onStart){let e=await r.onStart(n);if(e)n=e}return this.config=n,n}async runOnBeforeFile(t,n){let r=n;for(let e of this.plugins)if(e.onBeforeFile){let i={filePath:t,sourceCode:n,content:r,config:this.config,log:this.createLogger(e.name)},o=await e.onBeforeFile(i);if(typeof o==="string")r=o}return r}async runOnDeclarations(t,n,r){let e=r;for(let i of this.plugins)if(i.onDeclarations){let o={filePath:t,sourceCode:n,declarations:e,config:this.config,log:this.createLogger(i.name)},s=await i.onDeclarations(o);if(s)e=s}return e}async runOnAfterFile(t,n,r){let e=r;for(let i of this.plugins)if(i.onAfterFile){let o={filePath:t,sourceCode:n,content:e,config:this.config,log:this.createLogger(i.name)},s=await i.onAfterFile(o);if(typeof s==="string")e=s}return e}async runOnEnd(t){for(let n of this.plugins)if(n.onEnd)await n.onEnd(t)}async runOnError(t,n,r){for(let e of this.plugins)if(e.onError){let i={filePath:n,sourceCode:r,config:this.config,log:this.createLogger(e.name)};await e.onError(t,i)}}}var Ho=new we;function X(t){return t}var Ko=X({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(t)=>t.declarations.filter((n)=>{if(n.leadingComments){if(n.leadingComments.some((e)=>e.includes("@internal")))return t.log.debug(`Stripping internal declaration: ${n.name}`),!1}return!0})});function qo(t){return X({name:"banner",version:"1.0.0",description:"Adds a banner comment to generated files",onAfterFile:(n)=>`/**
3
3
  * ${t.split(`
4
4
  `).join(`
5
5
  * `)}
6
6
  */
7
7
 
8
- `+n.content})}function Jo(t){return Y({name:"filter",version:"1.0.0",description:"Filters declarations by name",onDeclarations:(n)=>n.declarations.filter((r)=>{if(r.kind==="import")return!0;return t(r.name)})})}
9
- export{xe,Ho,Y,Ko,qo,Jo};
8
+ `+n.content})}function Jo(t){return X({name:"filter",version:"1.0.0",description:"Filters declarations by name",onDeclarations:(n)=>n.declarations.filter((r)=>{if(r.kind==="import")return!0;return t(r.name)})})}
9
+ export{we,Ho,X,Ko,qo,Jo};
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{r}from"./chunk-z6mpxpxt.js";import{existsSync as j,mkdirSync as N,readFileSync as z,writeFileSync as G}from"fs";import{dirname as K,relative as L,resolve as _}from"path";async function ls(t,e,n){let u=new Map,f=[],x=new Set,D=0,w=0,S=0,C=[];for(let i of t){let o=e.get(i);if(!o)continue;C.push({file:i,decls:r(o,i,n.keepComments)})}for(let{file:i,decls:o}of C){D+=o.length;for(let s of o)if(s.kind==="import"){w++;let c=s.source||"";if(c.startsWith("."))continue;if(!u.has(c))u.set(c,{source:c,specifiers:new Map,isTypeOnly:s.isTypeOnly||!1,isSideEffect:s.isSideEffect||!1});let l=u.get(c);if(s.specifiers)for(let h of s.specifiers){let W=h.alias||h.name;if(!l.specifiers.has(W))l.specifiers.set(W,{name:h.name,alias:h.alias,isType:h.isType||!1})}if(!s.isTypeOnly)l.isTypeOnly=!1}else if(s.isExported||s.kind==="export"){if(S++,s.kind==="export"&&s.source&&(s.source.startsWith(".")||s.source.startsWith("/")))continue;if(s.name&&x.has(s.name))continue;if(s.name)x.add(s.name);f.push({declaration:s,file:i})}}let a=[];a.push("/**"),a.push(" * Bundled TypeScript declarations"),a.push(` * Generated from ${t.length} source files`),a.push(" */"),a.push("");let T=n.importOrder||["bun"],y=Array.from(u.values()),p=Array(y.length);for(let i=0;i<y.length;i++){let o=y[i].source,s=T.length;for(let c=0;c<T.length;c++)if(o.startsWith(T[c])){s=c;break}p[i]=s}let g=y.map((i,o)=>o);g.sort((i,o)=>{let s=p[i],c=p[o];if(s!==c)return s-c;return y[i].source.localeCompare(y[o].source)});let b=g.map((i)=>y[i]);for(let i of b)if(i.isSideEffect)a.push(`import '${i.source}';`);else if(i.specifiers.size>0){let s=Array.from(i.specifiers.values()).map((l)=>{let h=l.isType?"type ":"";return l.alias?`${h}${l.name} as ${l.alias}`:`${h}${l.name}`}),c=i.isTypeOnly?"type ":"";a.push(`import ${c}{ ${s.join(", ")} } from '${i.source}';`)}if(b.length>0)a.push("");let m=new Map;for(let{declaration:i,file:o}of f){if(!m.has(o))m.set(o,[]);m.get(o).push(i)}for(let[i,o]of m){let s=L(n.cwd,i);a.push(`// From: ${s}`);for(let c of o){if(n.keepComments&&c.leadingComments)for(let l of c.leadingComments)a.push(l);a.push(F(c))}a.push("")}let d=a.join(`
2
+ import{r}from"./chunk-xmj05115.js";import{existsSync as j,mkdirSync as N,readFileSync as z,writeFileSync as G}from"fs";import{dirname as K,relative as L,resolve as _}from"path";async function ls(t,e,n){let u=new Map,f=[],x=new Set,D=0,w=0,S=0,C=[];for(let i of t){let o=e.get(i);if(!o)continue;C.push({file:i,decls:r(o,i,n.keepComments)})}for(let{file:i,decls:o}of C){D+=o.length;for(let s of o)if(s.kind==="import"){w++;let c=s.source||"";if(c.startsWith("."))continue;if(!u.has(c))u.set(c,{source:c,specifiers:new Map,isTypeOnly:s.isTypeOnly||!1,isSideEffect:s.isSideEffect||!1});let l=u.get(c);if(s.specifiers)for(let h of s.specifiers){let W=h.alias||h.name;if(!l.specifiers.has(W))l.specifiers.set(W,{name:h.name,alias:h.alias,isType:h.isType||!1})}if(!s.isTypeOnly)l.isTypeOnly=!1}else if(s.isExported||s.kind==="export"){if(S++,s.kind==="export"&&s.source&&(s.source.startsWith(".")||s.source.startsWith("/")))continue;if(s.name&&x.has(s.name))continue;if(s.name)x.add(s.name);f.push({declaration:s,file:i})}}let a=[];a.push("/**"),a.push(" * Bundled TypeScript declarations"),a.push(` * Generated from ${t.length} source files`),a.push(" */"),a.push("");let T=n.importOrder||["bun"],y=Array.from(u.values()),p=Array(y.length);for(let i=0;i<y.length;i++){let o=y[i].source,s=T.length;for(let c=0;c<T.length;c++)if(o.startsWith(T[c])){s=c;break}p[i]=s}let g=y.map((i,o)=>o);g.sort((i,o)=>{let s=p[i],c=p[o];if(s!==c)return s-c;return y[i].source.localeCompare(y[o].source)});let b=g.map((i)=>y[i]);for(let i of b)if(i.isSideEffect)a.push(`import '${i.source}';`);else if(i.specifiers.size>0){let s=Array.from(i.specifiers.values()).map((l)=>{let h=l.isType?"type ":"";return l.alias?`${h}${l.name} as ${l.alias}`:`${h}${l.name}`}),c=i.isTypeOnly?"type ":"";a.push(`import ${c}{ ${s.join(", ")} } from '${i.source}';`)}if(b.length>0)a.push("");let m=new Map;for(let{declaration:i,file:o}of f){if(!m.has(o))m.set(o,[]);m.get(o).push(i)}for(let[i,o]of m){let s=L(n.cwd,i);a.push(`// From: ${s}`);for(let c of o){if(n.keepComments&&c.leadingComments)for(let l of c.leadingComments)a.push(l);a.push(F(c))}a.push("")}let d=a.join(`
3
3
  `);return{content:d,files:t,declarationCount:D,importCount:w,exportCount:S,size:Buffer.byteLength(d,"utf8"),warnings:[]}}function F(t){if(t.text){let n=t.text.trim();if(t.isExported&&!n.startsWith("export"))n=`export ${n}`;if(!n.endsWith(";")&&!n.endsWith("}"))n+=";";return n}let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${V(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let n of t.members)e.push(` ${n.name}${n.typeAnnotation?`: ${n.typeAnnotation}`:""};`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)e.push(`implements ${t.implements.join(", ")}`);if(e.push("{"),t.members)for(let n of t.members)e.push(` ${F(n)}`);e.push("}");break;case"enum":if(e.push("declare enum"),e.push(t.name),e.push("{"),t.members){let n=t.members.map((u)=>u.value!==void 0?`${u.name} = ${u.value}`:u.name);e.push(` ${n.join(`,
4
4
  `)}`)}e.push("}");break;default:return t.text||""}return e.join(" ")}function V(t){if(!t||t.length===0)return"";return t.map((e)=>{let n="";if(e.rest)n+="...";if(n+=e.name,e.optional)n+="?";if(e.type)n+=`: ${e.type}`;if(e.defaultValue)n+=` = ${e.defaultValue}`;return n}).join(", ")}async function Kt(t,e={}){let n=[],u=new Map,f=[],x=[],D=new Set,w=0,S=0,C=0;for(let p of t){if(!j(p)){n.push(`File not found: ${p}`);continue}let g=z(p,"utf-8");x.push(p);let b=g.split(`
5
5
  `),m=[],d=0,i=!1;for(let o of b){let s=o.trim();if(!s&&!i)continue;if(s.startsWith("import ")){S++;let l=s.match(/import\s+(type\s+)?(?:\{([^}]+)\}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/);if(l){let[,h,W,q,H,A]=l;if(e.externals?.some((P)=>A.startsWith(P))){f.push(s);continue}if(A.startsWith("."))continue;if(!u.has(A))u.set(A,{source:A,specifiers:new Map,isTypeOnly:!!h,isSideEffect:!1});let E=u.get(A);if(W){let P=W.split(",").map((k)=>k.trim());for(let k of P){let[I,v]=k.split(/\s+as\s+/).map((M)=>M.trim()),R=I.startsWith("type "),O=R?I.replace("type ",""):I;E.specifiers.set(v||O,{name:O,alias:v!==O?v:void 0,isType:R})}}if(!h)E.isTypeOnly=!1}continue}if(/^(export\s+)?(declare\s+)?(interface|type|class|function|const|let|var|enum|namespace|module)\s/.test(s)){if(i=!0,m=[o],d=(o.match(/\{/g)||[]).length-(o.match(/\}/g)||[]).length,d===0&&(s.endsWith(";")||!s.includes("{"))){let l=B(s);if(!D.has(l)||!e.mergeDuplicates){if(D.add(l),f.push(o),w++,s.startsWith("export"))C++}i=!1,m=[]}}else if(i){if(m.push(o),d+=(o.match(/\{/g)||[]).length-(o.match(/\}/g)||[]).length,d<=0){let l=m.join(`
6
6
  `),h=B(m[0]);if(!D.has(h)||!e.mergeDuplicates){if(D.add(h),f.push(l),w++,m[0].trim().startsWith("export"))C++}i=!1,m=[]}}else if(s.startsWith("export ")&&!s.includes("declare"))f.push(o),C++}}let a=[];if(e.banner)a.push(e.banner),a.push("");if(e.includeReferences&&e.references){for(let p of e.references)a.push(`/// <reference types="${p}" />`);a.push("")}let T=Array.from(u.values()).sort((p,g)=>p.source.localeCompare(g.source));for(let p of T)if(p.specifiers.size>0){let b=Array.from(p.specifiers.values()).map((d)=>{let i=d.isType?"type ":"";return d.alias?`${i}${d.name} as ${d.alias}`:`${i}${d.name}`}),m=p.isTypeOnly?"type ":"";a.push(`import ${m}{ ${b.join(", ")} } from '${p.source}';`)}if(T.length>0)a.push("");if(e.ambient&&e.moduleName){a.push(`declare module '${e.moduleName}' {`);for(let p of f){let g=p.split(`
7
7
  `).map((b)=>` ${b.replace(/^(\s*)(export\s+)?declare\s+/,"$1$2")}`).join(`
8
8
  `);a.push(g)}a.push("}")}else{if(e.sortDeclarations)f.sort((p,g)=>{let b=B(p),m=B(g);return b.localeCompare(m)});for(let p of f)a.push(p)}if(e.footer)a.push(""),a.push(e.footer);let y=a.join(`
9
- `);return{content:y,files:x,declarationCount:w,importCount:S,exportCount:C,size:Buffer.byteLength(y,"utf-8"),warnings:n}}function B(t){let e=t.match(/(interface|type|class|function|const|let|var|enum|namespace|module)\s+(\w+)/);return e?`${e[1]}:${e[2]}`:t.trim()}async function xr(t,e,n={}){let u=await Kt(t,n),f=K(e);if(!j(f))N(f,{recursive:!0});return G(e,u.content),u}function us(t={}){return{bundle:(e)=>Kt(e,t),bundleAndWrite:(e,n)=>xr(e,n,{...t,output:n})}}async function fs(t,e=process.cwd()){let n=Array.isArray(t)?t:[t],u=[];for(let f of n){if(f.includes("*"))continue;let x=_(e,f);if(j(x))u.push(x)}return u}
10
- export{ls,Kt,xr,us,fs};
9
+ `);return{content:y,files:x,declarationCount:w,importCount:S,exportCount:C,size:Buffer.byteLength(y,"utf-8"),warnings:n}}function B(t){let e=t.match(/(interface|type|class|function|const|let|var|enum|namespace|module)\s+(\w+)/);return e?`${e[1]}:${e[2]}`:t.trim()}async function wr(t,e,n={}){let u=await Kt(t,n),f=K(e);if(!j(f))N(f,{recursive:!0});return G(e,u.content),u}function us(t={}){return{bundle:(e)=>Kt(e,t),bundleAndWrite:(e,n)=>wr(e,n,{...t,output:n})}}async function fs(t,e=process.cwd()){let n=Array.isArray(t)?t:[t],u=[];for(let f of n){if(f.includes("*"))continue;let x=_(e,f);if(j(x))u.push(x)}return u}
10
+ export{ls,Kt,wr,us,fs};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class ai{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(t={}){this.config={enabled:t.enabled??!0,cacheDir:t.cacheDir??b,format:t.format??"json",maxAge:t.maxAge??86400000,force:t.force??!1,validateCache:t.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await y(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let t=o(this.config.cacheDir,d);try{let e=await l(t,"utf-8");if(this.manifest=JSON.parse(e),this.manifest.version!==c){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let t=o(this.config.cacheDir,d);this.manifest.updatedAt=Date.now(),await v(t,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(t,e){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let s=this.manifest.entries[t];if(!s)return this.stats.misses++,null;if(s.configHash!==e)return this.stats.misses++,null;if(Date.now()-s.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null;if(this.config.validateCache)try{let a=(await m(t)).mtimeMs;if(a!==s.mtime){let i=await l(t,"utf-8");if(this.hashContent(i)!==s.hash)return this.stats.misses++,null;s.mtime=a,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null}if(s.dependencies.length>0){if((await Promise.all(s.dependencies.map(async(a)=>{let i=this.manifest.entries[a];if(!i)return!0;try{return(await m(a)).mtimeMs===i.mtime}catch{return!1}}))).some((a)=>!a))return this.stats.misses++,null}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),s}async set(t,e,s,r,a,i){if(!this.config.enabled||!this.manifest)return;let n=Date.now();try{n=(await m(t)).mtimeMs}catch{}let h={filePath:t,hash:this.hashContent(e),mtime:n,declarations:s,dtsContent:r,dependencies:a,cachedAt:Date.now(),configHash:i};if(!(t in this.manifest.entries))this.stats.totalEntries++;this.manifest.entries[t]=h,this.dirty=!0}invalidate(t){if(!this.manifest)return;delete this.manifest.entries[t],this.dirty=!0;for(let[e,s]of Object.entries(this.manifest.entries))if(s.dependencies.includes(t))delete this.manifest.entries[e]}async clear(){this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(t){return String(p(t))}updateHitRatio(){let t=this.stats.hits+this.stats.misses;this.stats.hitRatio=t>0?this.stats.hits/t:0}static hashConfig(t){let e={outdir:t.outdir,clean:t.clean,tsconfigPath:t.tsconfigPath};return g("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}}function xo(t,e){let s=[],r=[],a=[];return{async needsRebuild(i){return await t.get(i,e)===null},async getCachedDeclarations(i){let n=await t.get(i,e);if(n)return r.push(i),n.declarations;return null},async getCachedDts(i){let n=await t.get(i,e);if(n)return n.dtsContent;return null},async cacheResult(i,n,h,u,f=[]){await t.set(i,n,h,u,f,e),s.push(i)},skip(i){a.push(i)},getResult(){return{rebuilt:s,cached:r,skipped:a,stats:t.getStats()}},async save(){await t.save()}}}async function Co(t,e=604800000){let s=t.getStats();if(s.totalEntries>1000)return await t.clear(),s.totalEntries;return 0}function vo(t){let e=[];return e.push("Incremental Build Results:"),e.push(` Rebuilt: ${t.rebuilt.length} files`),e.push(` From cache: ${t.cached.length} files`),e.push(` Skipped: ${t.skipped.length} files`),e.push(""),e.push("Cache Statistics:"),e.push(` Total entries: ${t.stats.totalEntries}`),e.push(` Hit ratio: ${(t.stats.hitRatio*100).toFixed(1)}%`),e.push(` Time saved: ~${t.stats.timeSavedMs}ms`),e.join(`
2
+ import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class ai{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(t={}){this.config={enabled:t.enabled??!0,cacheDir:t.cacheDir??b,format:t.format??"json",maxAge:t.maxAge??86400000,force:t.force??!1,validateCache:t.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await y(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let t=o(this.config.cacheDir,d);try{let e=await l(t,"utf-8");if(this.manifest=JSON.parse(e),this.manifest.version!==c){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let t=o(this.config.cacheDir,d);this.manifest.updatedAt=Date.now(),await v(t,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(t,e){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let s=this.manifest.entries[t];if(!s)return this.stats.misses++,null;if(s.configHash!==e)return this.stats.misses++,null;if(Date.now()-s.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null;if(this.config.validateCache)try{let a=(await m(t)).mtimeMs;if(a!==s.mtime){let i=await l(t,"utf-8");if(this.hashContent(i)!==s.hash)return this.stats.misses++,null;s.mtime=a,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null}if(s.dependencies.length>0){if((await Promise.all(s.dependencies.map(async(a)=>{let i=this.manifest.entries[a];if(!i)return!0;try{return(await m(a)).mtimeMs===i.mtime}catch{return!1}}))).some((a)=>!a))return this.stats.misses++,null}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),s}async set(t,e,s,r,a,i){if(!this.config.enabled||!this.manifest)return;let n=Date.now();try{n=(await m(t)).mtimeMs}catch{}let h={filePath:t,hash:this.hashContent(e),mtime:n,declarations:s,dtsContent:r,dependencies:a,cachedAt:Date.now(),configHash:i};if(!(t in this.manifest.entries))this.stats.totalEntries++;this.manifest.entries[t]=h,this.dirty=!0}invalidate(t){if(!this.manifest)return;delete this.manifest.entries[t],this.dirty=!0;for(let[e,s]of Object.entries(this.manifest.entries))if(s.dependencies.includes(t))delete this.manifest.entries[e]}async clear(){this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(t){return String(p(t))}updateHitRatio(){let t=this.stats.hits+this.stats.misses;this.stats.hitRatio=t>0?this.stats.hits/t:0}static hashConfig(t){let e={outdir:t.outdir,clean:t.clean,tsconfigPath:t.tsconfigPath};return g("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}}function wo(t,e){let s=[],r=[],a=[];return{async needsRebuild(i){return await t.get(i,e)===null},async getCachedDeclarations(i){let n=await t.get(i,e);if(n)return r.push(i),n.declarations;return null},async getCachedDts(i){let n=await t.get(i,e);if(n)return n.dtsContent;return null},async cacheResult(i,n,h,u,f=[]){await t.set(i,n,h,u,f,e),s.push(i)},skip(i){a.push(i)},getResult(){return{rebuilt:s,cached:r,skipped:a,stats:t.getStats()}},async save(){await t.save()}}}async function Co(t,e=604800000){let s=t.getStats();if(s.totalEntries>1000)return await t.clear(),s.totalEntries;return 0}function vo(t){let e=[];return e.push("Incremental Build Results:"),e.push(` Rebuilt: ${t.rebuilt.length} files`),e.push(` From cache: ${t.cached.length} files`),e.push(` Skipped: ${t.skipped.length} files`),e.push(""),e.push("Cache Statistics:"),e.push(` Total entries: ${t.stats.totalEntries}`),e.push(` Hit ratio: ${(t.stats.hitRatio*100).toFixed(1)}%`),e.push(` Time saved: ~${t.stats.timeSavedMs}ms`),e.join(`
3
3
  `)}function So(t,e){let s=[],r=/import\s+(?:type\s+)?(?:.+(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])from\s+)?['"]([^'"]+)['"]/g,a;while((a=r.exec(t))!==null){let i=a[1];if(i.startsWith(".")){let n=o(C(e),i);s.push(n),s.push(`${n}.ts`),s.push(`${n}.tsx`),s.push(o(n,"index.ts")),s.push(o(n,"index.tsx"))}}return s}
4
- export{ai,xo,Co,vo,So};
4
+ export{ai,wo,Co,vo,So};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{Xe}from"./chunk-ayyb1jpe.js";import{E}from"./chunk-60wrxcjt.js";import{$n}from"./chunk-7bt7x8sy.js";import{be}from"./chunk-vae5wxar.js";import{Q}from"./chunk-vf8jmdsp.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function Ke(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function $o(n,r){throw Error(r||`Unexpected value: ${n}`)}async function G(n,r,o="lf"){let t=r.replace(/\r\n/g,`
2
+ import{Xe}from"./chunk-85d82vn3.js";import{E}from"./chunk-60wrxcjt.js";import{$n}from"./chunk-7bt7x8sy.js";import{be}from"./chunk-vae5wxar.js";import{ee}from"./chunk-w3zqfm8a.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function Ke(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function $o(n,r){throw Error(r||`Unexpected value: ${n}`)}async function G(n,r,o="lf"){let t=r.replace(/\r\n/g,`
3
3
  `);if(!t.endsWith(`
4
4
  `))t+=`
5
5
  `;if(o==="crlf")t=t.replace(/\n/g,`\r
6
- `);if(await Xe(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function li(n){let r=n??E.root,o=await v(r,{withFileTypes:!0});return(await Promise.all(o.map((i)=>{let c=C(r,i.name);return i.isDirectory()?li(c):c}))).flat(1/0).filter((i)=>{if(typeof i!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(i)&&!/\.d\.(?:ts|mts|cts)$/.test(i)})}async function q(n){try{let r=n?.cwd||y.cwd();return(await Q(D(r,n?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function xt(n,r){let o={isValid:!0,errors:[]};for(let t of be(n))o.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of $n(n))o.errors.push({line:t.line,column:1,message:`'${t.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${t.context}`,code:"dangling-type-reference"});return o.isValid=o.errors.length===0,o}function Ct(n,r,o){if(n===r)return"";let t=n.split(`
6
+ `);if(await Xe(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function li(n){let r=n??E.root,o=await v(r,{withFileTypes:!0});return(await Promise.all(o.map((i)=>{let c=C(r,i.name);return i.isDirectory()?li(c):c}))).flat(1/0).filter((i)=>{if(typeof i!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(i)&&!/\.d\.(?:ts|mts|cts)$/.test(i)})}async function J(n){try{let r=n?.cwd||y.cwd();return(await ee(D(r,n?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function wt(n,r){let o={isValid:!0,errors:[]};for(let t of be(n))o.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of $n(n))o.errors.push({line:t.line,column:1,message:`'${t.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${t.context}`,code:"dangling-type-reference"});return o.isValid=o.errors.length===0,o}function Ct(n,r,o){if(n===r)return"";let t=n.split(`
7
7
  `),i=r.split(`
8
8
  `),c=new Map,a=new Map;for(let e=0;e<t.length;e++)c.set(t[e],(c.get(t[e])??0)+1);for(let e=0;e<i.length;e++)a.set(i[e],(a.get(i[e])??0)+1);let g=[],u=[];for(let[e,s]of c){let m=s-(a.get(e)??0);for(let l=0;l<m;l++)g.push(e)}for(let[e,s]of a){let m=s-(c.get(e)??0);for(let l=0;l<m;l++)u.push(e)}if(g.length===0&&u.length===0)return"";let p=[`--- ${o}`,`+++ ${o}`];for(let e=0;e<g.length;e++)p.push(`- ${g[e]}`);for(let e=0;e<u.length;e++)p.push(`+ ${u[e]}`);return p.join(`
9
9
  `)}function vt(n,r,o,t){let i=n.split(`
@@ -11,4 +11,4 @@ import{Xe}from"./chunk-ayyb1jpe.js";import{E}from"./chunk-60wrxcjt.js";import{$n
11
11
  `).length;for(let s=0;s<i.length;s++){if(i[s].trim()===""){c.push("");continue}g=0;let l=Math.min(s,e-1),f=[],d=0-g,h=0,w=l-u,x=0-p;f.push(a(d)+a(h)+a(w)+a(x)),g=0,u=l,p=0,c.push(f.join(","))}return{version:3,file:r,sourceRoot:"",sources:[o],sourcesContent:[t],mappings:c.join(";")}}function St(n,r){return`${n}
12
12
  ${Ke()}${r}
13
13
  `}
14
- export{Ke,$o,G,li,q,xt,Ct,vt,St};
14
+ export{Ke,$o,G,li,J,wt,Ct,vt,St};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{p}from"./chunk-v6fwy63g.js";import{existsSync as u,mkdirSync as H,readFileSync as l,renameSync as b,rmdirSync as D,rmSync as C,statSync as g,writeFileSync as S}from"fs";import{join as d,relative as h,resolve as y}from"path";var f=24,m=".dtsx-cache",v="manifest.json";function oi(t){try{C(d(t,v),{force:!0});try{D(t)}catch{}}catch{}}class He{cacheDir;manifestPath;manifest=null;configHash;constructor(t,n){this.cacheDir=y(t.cwd,t.cacheDir??m),this.manifestPath=d(this.cacheDir,v),this.configHash=this.hashConfig(t,n)}hashConfig(t,n){let s={resolutionContext:n,keepComments:t.keepComments,importOrder:t.importOrder,outputStructure:t.outputStructure,moduleSpecifierMode:t.moduleSpecifierMode??"preserve",root:y(t.cwd,t.root),exclude:t.exclude??[],isolatedDeclarations:t.isolatedDeclarations,declarationMap:t.declarationMap,indentStyle:t.indentStyle,indentSize:t.indentSize,prettier:t.prettier,typeMappings:t.typeMappings?{includeDefaults:t.typeMappings.includeDefaults,presets:t.typeMappings.presets,cacheKey:t.typeMappings.cacheKey,rules:t.typeMappings.rules.map((e)=>({pattern:typeof e.pattern==="string"?{kind:"string",value:e.pattern}:{kind:"regex",source:e.pattern.source,flags:e.pattern.flags},replacement:e.replacement,global:e.global,priority:e.priority,hasCondition:Boolean(e.condition)}))}:void 0,lineEnding:t.lineEnding,normalizeOutput:t.normalizeOutput,declarationOrder:t.declarationOrder,plugins:t.plugins?.map((e)=>({name:e.name,version:e.version,cacheKey:e.cacheKey}))};return String(p(JSON.stringify(s)))}hashString(t){return String(p(t))}load(){try{if(!u(this.manifestPath))return!1;let t=l(this.manifestPath,"utf-8"),n=JSON.parse(t);if(n.version!==f)return!1;if(n.configHash!==this.configHash)return!1;if(!n.entries||typeof n.entries!=="object"||Array.isArray(n.entries))return!1;return this.manifest=n,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!u(this.cacheDir))H(this.cacheDir,{recursive:!0});let t=`${this.manifestPath}.${process.pid}.tmp`;try{S(t,JSON.stringify(this.manifest,null,2)),b(t,this.manifestPath)}finally{if(u(t))C(t,{force:!0})}}needsRegeneration(t,n){return this.getCachedIfValid(t,n)===null}getCached(t,n){return this.getCachedIfValid(t,n)}getCachedIfValid(t,n){if(!this.manifest)return null;let s=h(n,t),e=this.manifest.entries[s];if(!e)return null;if(typeof e.dtsContent!=="string"||typeof e.dtsHash!=="string"||e.configHash!==this.configHash||this.hashString(e.dtsContent)!==e.dtsHash)return null;try{let i=g(t),{mtimeMs:r,ctimeMs:a}=i;if(i.size!==e.sourceSize)return null;if(r!==e.sourceMtime||a!==e.sourceCtime){let o=l(t,"utf-8");if(this.hashString(o)!==e.sourceHash)return null;e.sourceMtime=r,e.sourceCtime=a}return e.dtsContent}catch{return null}}update(t,n,s,e){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=h(e,t),r,a,o;try{let c=g(t);r=c.mtimeMs,a=c.ctimeMs,o=c.size}catch{r=Date.now(),a=r,o=Buffer.byteLength(n)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(n),sourceMtime:r,sourceCtime:a,sourceSize:o,dtsContent:s,dtsHash:this.hashString(s),generatedAt:Date.now(),configHash:this.configHash}}remove(t,n){if(!this.manifest)return;let s=h(n,t);delete this.manifest.entries[s]}clear(){this.manifest=null,oi(this.cacheDir)}getStats(){if(!this.manifest)return{entries:0,size:0};let t=Object.keys(this.manifest.entries).length,n=0;for(let s of Object.values(this.manifest.entries))n+=s.dtsContent.length;return{entries:t,size:n}}prune(t,n){if(!this.manifest)return 0;let s=0,e=new Set(Array.from(t).map((i)=>h(n,i)));for(let i of Object.keys(this.manifest.entries))if(!e.has(i))delete this.manifest.entries[i],s++;return s}}function wt(t){let n=d(t,".gitignore");try{let s="";if(u(n))s=l(n,"utf-8");if(!s.split(/\r?\n/).some((i)=>i.trim()===m||i.trim()===`${m}/`)){let i=s.trimEnd(),r=`${i}${i?`
2
+ import{p}from"./chunk-v6fwy63g.js";import{existsSync as u,mkdirSync as H,readFileSync as l,renameSync as b,rmdirSync as D,rmSync as C,statSync as g,writeFileSync as S}from"fs";import{join as d,relative as h,resolve as y}from"path";var f=24,m=".dtsx-cache",v="manifest.json";function oi(t){try{C(d(t,v),{force:!0});try{D(t)}catch{}}catch{}}class He{cacheDir;manifestPath;manifest=null;configHash;constructor(t,n){this.cacheDir=y(t.cwd,t.cacheDir??m),this.manifestPath=d(this.cacheDir,v),this.configHash=this.hashConfig(t,n)}hashConfig(t,n){let s={resolutionContext:n,keepComments:t.keepComments,importOrder:t.importOrder,outputStructure:t.outputStructure,moduleSpecifierMode:t.moduleSpecifierMode??"preserve",root:y(t.cwd,t.root),exclude:t.exclude??[],isolatedDeclarations:t.isolatedDeclarations,declarationMap:t.declarationMap,indentStyle:t.indentStyle,indentSize:t.indentSize,prettier:t.prettier,typeMappings:t.typeMappings?{includeDefaults:t.typeMappings.includeDefaults,presets:t.typeMappings.presets,cacheKey:t.typeMappings.cacheKey,rules:t.typeMappings.rules.map((e)=>({pattern:typeof e.pattern==="string"?{kind:"string",value:e.pattern}:{kind:"regex",source:e.pattern.source,flags:e.pattern.flags},replacement:e.replacement,global:e.global,priority:e.priority,hasCondition:Boolean(e.condition)}))}:void 0,lineEnding:t.lineEnding,normalizeOutput:t.normalizeOutput,declarationOrder:t.declarationOrder,plugins:t.plugins?.map((e)=>({name:e.name,version:e.version,cacheKey:e.cacheKey}))};return String(p(JSON.stringify(s)))}hashString(t){return String(p(t))}load(){try{if(!u(this.manifestPath))return!1;let t=l(this.manifestPath,"utf-8"),n=JSON.parse(t);if(n.version!==f)return!1;if(n.configHash!==this.configHash)return!1;if(!n.entries||typeof n.entries!=="object"||Array.isArray(n.entries))return!1;return this.manifest=n,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!u(this.cacheDir))H(this.cacheDir,{recursive:!0});let t=`${this.manifestPath}.${process.pid}.tmp`;try{S(t,JSON.stringify(this.manifest,null,2)),b(t,this.manifestPath)}finally{if(u(t))C(t,{force:!0})}}needsRegeneration(t,n){return this.getCachedIfValid(t,n)===null}getCached(t,n){return this.getCachedIfValid(t,n)}getCachedIfValid(t,n){if(!this.manifest)return null;let s=h(n,t),e=this.manifest.entries[s];if(!e)return null;if(typeof e.dtsContent!=="string"||typeof e.dtsHash!=="string"||e.configHash!==this.configHash||this.hashString(e.dtsContent)!==e.dtsHash)return null;try{let i=g(t),{mtimeMs:r,ctimeMs:a}=i;if(i.size!==e.sourceSize)return null;if(r!==e.sourceMtime||a!==e.sourceCtime){let o=l(t,"utf-8");if(this.hashString(o)!==e.sourceHash)return null;e.sourceMtime=r,e.sourceCtime=a}return e.dtsContent}catch{return null}}update(t,n,s,e){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=h(e,t),r,a,o;try{let c=g(t);r=c.mtimeMs,a=c.ctimeMs,o=c.size}catch{r=Date.now(),a=r,o=Buffer.byteLength(n)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(n),sourceMtime:r,sourceCtime:a,sourceSize:o,dtsContent:s,dtsHash:this.hashString(s),generatedAt:Date.now(),configHash:this.configHash}}remove(t,n){if(!this.manifest)return;let s=h(n,t);delete this.manifest.entries[s]}clear(){this.manifest=null,oi(this.cacheDir)}getStats(){if(!this.manifest)return{entries:0,size:0};let t=Object.keys(this.manifest.entries).length,n=0;for(let s of Object.values(this.manifest.entries))n+=s.dtsContent.length;return{entries:t,size:n}}prune(t,n){if(!this.manifest)return 0;let s=0,e=new Set(Array.from(t).map((i)=>h(n,i)));for(let i of Object.keys(this.manifest.entries))if(!e.has(i))delete this.manifest.entries[i],s++;return s}}function xt(t){let n=d(t,".gitignore");try{let s="";if(u(n))s=l(n,"utf-8");if(!s.split(/\r?\n/).some((i)=>i.trim()===m||i.trim()===`${m}/`)){let i=s.trimEnd(),r=`${i}${i?`
3
3
 
4
4
  `:""}# dtsx cache
5
5
  ${m}/
6
6
  `;S(n,r)}}catch{}}
7
- export{oi,He,wt};
7
+ export{oi,He,xt};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{S}from"./chunk-y4wykrya.js";import{G}from"./chunk-3jjrn16z.js";import{chmod as j,lstat as P,mkdir as y,readdir as q,realpath as L,rename as D,rm as R,rmdir as W,stat as A,writeFile as _}from"fs/promises";import{basename as B,dirname as m,isAbsolute as M,parse as J,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await L(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),B(e))}}async function K(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!S(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===J(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(S(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function x(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await x(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await q(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function he(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await K(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!S(t,n)||S(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],T=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!S(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(S(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await x(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await _(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await G(v,i.content,i.lineEnding),!a.clean&&u.existing)await j(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),T.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await x(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of T.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await W(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
3
- export{K,he};
2
+ import{S}from"./chunk-q4ph9qa2.js";import{G}from"./chunk-13tjnp25.js";import{chmod as j,lstat as P,mkdir as y,readdir as L,realpath as W,rename as D,rm as R,rmdir as _,stat as A,writeFile as B}from"fs/promises";import{basename as J,dirname as m,isAbsolute as M,parse as U,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await W(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),J(e))}}async function q(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!S(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===U(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(S(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function x(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await x(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await L(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function he(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await q(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!S(t,n)||S(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],T=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!S(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(S(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await x(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await B(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await G(v,i.content,i.lineEnding),!a.clean&&u.existing)await j(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),T.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await x(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of T.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await _(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
3
+ export{q,he};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{r}from"./chunk-z6mpxpxt.js";import{l}from"./chunk-yzdh207n.js";import{existsSync as v}from"fs";import{readFile as D}from"fs/promises";import{dirname as N,join as k,resolve as S}from"path";async function yr(e,o=process.cwd()){let i=new Map;for(let t of e){let n=S(o,t),s=await F(n,o);i.set(n,{path:n,dependencies:s,dependents:new Set,state:"pending"})}for(let[t,n]of i)for(let s of n.dependencies){let c=i.get(s);if(c)c.dependents.add(t)}return i}async function F(e,o){let i=new Set;try{let t=await D(e,"utf-8"),n=N(e);for(let s of r(t,e,!1)){let c=s.source;if(!c||!c.startsWith(".")&&!c.startsWith("/"))continue;let a=z(c,n,o);if(a)i.add(a)}}catch{}return i}function z(e,o,i){let t=S(o,e);if(/\.(?:ts|tsx|mts|cts)$/.test(e))return t.includes("node_modules")?null:t;let n=[".ts",".tsx",".mts",".cts"];for(let c of n){let a=`${t}${c}`;if(v(a))return a}for(let c of n){let a=k(t,`index${c}`);if(v(a))return a}let s=`${t}.ts`;return s.includes("node_modules")?null:s}function G(e){let o=[];for(let[i,t]of e){if(t.state!=="pending")continue;let n=!0;for(let s of t.dependencies){let c=e.get(s);if(c&&c.state!=="completed"){n=!1;break}}if(n)o.push(i)}return o}async function I(e,o={}){let i=await D(e,"utf-8"),t=o.keepComments??!0,n=r(i,e,t,o.isolatedDeclarations??!1);return l(n,{filePath:e,sourceCode:i,declarations:n},t,o.importOrder)}async function is(e,o={}){let i=performance.now(),{maxConcurrency:t=4,rootDir:n=process.cwd(),config:s={},onProgress:c,onError:a}=o,g=await yr(e,n),w=new Map,P=new Map,h=[],x=0,u=0,m=0,b=g.size;while(m<b){let y=G(g);if(y.length===0){let f=[...g.values()].filter((d)=>d.state==="pending");if(f.length>0)for(let d of f)d.state="failed",d.error=Error("Circular dependency detected or dependency failed"),P.set(d.path,d.error),m++;break}let C=y.slice(0,t-u);for(let f of C){let d=g.get(f);d.state="processing",u++}x=Math.max(x,u);let E=C.map(async(f)=>{let d=g.get(f),M=performance.now();try{let p=await I(f,s);d.state="completed",d.result=p,d.duration=performance.now()-M,w.set(f,p),h.push(f)}catch(p){if(d.state="failed",d.error=p instanceof Error?p:Error(String(p)),d.duration=performance.now()-M,P.set(f,d.error),a&&!a(f,d.error))throw Error("Processing aborted by error handler")}finally{u--,m++,c?.(m,b,f)}});await Promise.all(E)}return{success:w,failed:P,totalTimeMs:performance.now()-i,maxConcurrent:x,processingOrder:h}}function ss(e){let o=[],i=new Set,t=new Set;function n(s){if(i.has(s))return;if(t.has(s))return;t.add(s);let c=e.get(s);if(c){for(let a of c.dependencies)if(e.has(a))n(a)}t.delete(s),i.add(s),o.push(s)}for(let s of e.keys())n(s);return o}function br(e){let o=[];for(let[i,t]of e){let n=!1;for(let s of t.dependencies)if(e.has(s)){n=!0;break}if(!n)o.push(i)}return o}function wr(e){let o=[],i=new Set;while(i.size<e.size){let t=[];for(let[n,s]of e){if(i.has(n))continue;let c=!0;for(let a of s.dependencies)if(e.has(a)&&!i.has(a)){c=!1;break}if(c)t.push(n)}if(t.length===0){for(let n of e.keys())if(!i.has(n))t.push(n)}for(let n of t)i.add(n);o.push(t)}return o}function os(e){let o=wr(e),i=br(e),t=Math.max(...o.map((s)=>s.length)),n=e.size/o.length;return{totalFiles:e.size,independentFiles:i.length,maxParallelism:t,levels:o.length,estimatedSpeedup:n}}
3
- export{yr,is,ss,br,wr,os};
2
+ import{r}from"./chunk-xmj05115.js";import{l}from"./chunk-yyqay3jp.js";import{existsSync as v}from"fs";import{readFile as D}from"fs/promises";import{dirname as N,join as k,resolve as S}from"path";async function yr(e,o=process.cwd()){let i=new Map;for(let t of e){let n=S(o,t),s=await F(n,o);i.set(n,{path:n,dependencies:s,dependents:new Set,state:"pending"})}for(let[t,n]of i)for(let s of n.dependencies){let c=i.get(s);if(c)c.dependents.add(t)}return i}async function F(e,o){let i=new Set;try{let t=await D(e,"utf-8"),n=N(e);for(let s of r(t,e,!1)){let c=s.source;if(!c||!c.startsWith(".")&&!c.startsWith("/"))continue;let a=z(c,n,o);if(a)i.add(a)}}catch{}return i}function z(e,o,i){let t=S(o,e);if(/\.(?:ts|tsx|mts|cts)$/.test(e))return t.includes("node_modules")?null:t;let n=[".ts",".tsx",".mts",".cts"];for(let c of n){let a=`${t}${c}`;if(v(a))return a}for(let c of n){let a=k(t,`index${c}`);if(v(a))return a}let s=`${t}.ts`;return s.includes("node_modules")?null:s}function G(e){let o=[];for(let[i,t]of e){if(t.state!=="pending")continue;let n=!0;for(let s of t.dependencies){let c=e.get(s);if(c&&c.state!=="completed"){n=!1;break}}if(n)o.push(i)}return o}async function I(e,o={}){let i=await D(e,"utf-8"),t=o.keepComments??!0,n=r(i,e,t,o.isolatedDeclarations??!1);return l(n,{filePath:e,sourceCode:i,declarations:n},t,o.importOrder)}async function is(e,o={}){let i=performance.now(),{maxConcurrency:t=4,rootDir:n=process.cwd(),config:s={},onProgress:c,onError:a}=o,g=await yr(e,n),w=new Map,P=new Map,h=[],x=0,u=0,m=0,b=g.size;while(m<b){let y=G(g);if(y.length===0){let f=[...g.values()].filter((d)=>d.state==="pending");if(f.length>0)for(let d of f)d.state="failed",d.error=Error("Circular dependency detected or dependency failed"),P.set(d.path,d.error),m++;break}let C=y.slice(0,t-u);for(let f of C){let d=g.get(f);d.state="processing",u++}x=Math.max(x,u);let E=C.map(async(f)=>{let d=g.get(f),M=performance.now();try{let p=await I(f,s);d.state="completed",d.result=p,d.duration=performance.now()-M,w.set(f,p),h.push(f)}catch(p){if(d.state="failed",d.error=p instanceof Error?p:Error(String(p)),d.duration=performance.now()-M,P.set(f,d.error),a&&!a(f,d.error))throw Error("Processing aborted by error handler")}finally{u--,m++,c?.(m,b,f)}});await Promise.all(E)}return{success:w,failed:P,totalTimeMs:performance.now()-i,maxConcurrent:x,processingOrder:h}}function ss(e){let o=[],i=new Set,t=new Set;function n(s){if(i.has(s))return;if(t.has(s))return;t.add(s);let c=e.get(s);if(c){for(let a of c.dependencies)if(e.has(a))n(a)}t.delete(s),i.add(s),o.push(s)}for(let s of e.keys())n(s);return o}function br(e){let o=[];for(let[i,t]of e){let n=!1;for(let s of t.dependencies)if(e.has(s)){n=!0;break}if(!n)o.push(i)}return o}function xr(e){let o=[],i=new Set;while(i.size<e.size){let t=[];for(let[n,s]of e){if(i.has(n))continue;let c=!0;for(let a of s.dependencies)if(e.has(a)&&!i.has(a)){c=!1;break}if(c)t.push(n)}if(t.length===0){for(let n of e.keys())if(!i.has(n))t.push(n)}for(let n of t)i.add(n);o.push(t)}return o}function os(e){let o=xr(e),i=br(e),t=Math.max(...o.map((s)=>s.length)),n=e.size/o.length;return{totalFiles:e.size,independentFiles:i.length,maxParallelism:t,levels:o.length,estimatedSpeedup:n}}
3
+ export{yr,is,ss,br,xr,os};
@@ -14,5 +14,5 @@ var d=null,m=null;async function P(){if(d!==null)return d;try{return m=await imp
14
14
  `),s=[],a=[],i=!1,u=0;for(let o=0;o<n.length;o++){let t=n[o],p=t.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(p){i=!0,u=o;let c=p[1];s.push({line:t,source:p[2],isType:c.startsWith("import type ")||c.startsWith("import type\t")})}else if(i&&t.trim()==="")continue;else{if(i)i=!1;a.push(t)}}if(s.length===0)return r;if(e.sort)s.sort((o,t)=>{if(o.isType!==t.isType)return o.isType?1:-1;return M(o.source,t.source)});let l;if(e.group){let o=[],t=[],p=[],c=[],b=[];for(let f=0;f<s.length;f++){let g=s[f],h=g.source;if(h.charCodeAt(0)===46)b.push(g);else if(h.startsWith("node:"))o.push(g);else if(h.charCodeAt(0)===64)c.push(g);else if(h.includes("/"))p.push(g);else t.push(g)}l=[...o.map((f)=>f.line),...o.length>0&&t.length>0?[""]:[],...t.map((f)=>f.line),...(o.length>0||t.length>0)&&p.length>0?[""]:[],...p.map((f)=>f.line),...c.length>0&&(o.length>0||t.length>0||p.length>0)?[""]:[],...c.map((f)=>f.line),...b.length>0?[""]:[],...b.map((f)=>f.line)]}else l=s.map((o)=>o.line);return[...l,"",...a].join(`
15
15
  `)}function M(r,e){let n=r.startsWith("node:"),s=e.startsWith("node:");if(n!==s)return n?-1:1;let a=r.startsWith("."),i=e.startsWith(".");if(a!==i)return a?1:-1;return r.localeCompare(e)}function W(r,e,n){let s=r.split(`
16
16
  `),a=[];for(let i of s){if(i.length<=e){a.push(i);continue}if(i.trimStart().startsWith("import ")){a.push(i);continue}let u=i.match(/^(\s*)/)?.[1]||"",l=u+n,o=O(i,u,l);if(o){a.push(...o);continue}if(i.includes("{")&&i.includes("}")){let t=v(i,e,u,l);a.push(...t);continue}if(i.includes(" | ")){let t=R(i,e,u,l);a.push(...t);continue}a.push(i)}return a.join(`
17
- `)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(r,e,n){let s=r.match(F);if(!s)return null;let[,a,i,u,l]=s,o=u.split(",").map((c)=>c.trim()).filter(Boolean);if(o.length<=1)return[r];let t=`${e}${a}${i??""} {`,p=l?`${e}} ${l};`:`${e}};`;return[t,...o.map((c)=>`${n}${c},`),p]}function v(r,e,n,s){let a=r.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!a)return[r];let[,,i,u,l,o]=a,t=l.split(/;\s*|,\s*/).filter((c)=>c.trim());if(t.length<=1)return[r];return[`${n}${i}${u}`,...t.map((c)=>`${s}${c.trim()};`),`${n}${o.trim()}`]}function R(r,e,n,s){let a=r.match(/^(\s*)(.*?=\s*)(.+)$/);if(!a)return[r];let[,,i,u]=a,l=u.split(/\s*\|\s*/).filter((t)=>t.trim());if(l.length<=2)return[r];return[`${n}${i}`,...l.map((t,p)=>`${s}${p>0?"| ":" "}${t.trim()}`)]}async function H(r,e={},n){let s=[];if(e.usePrettier!==!1){if(await P())try{let l={...await y(e.prettierConfigPath,n),...e.prettierOptions,parser:"typescript"};return{content:await w(r,l),usedPrettier:!0}}catch(u){s.push(`Prettier formatting failed: ${u}. Using built-in formatter.`)}else if(e.usePrettier===!0)s.push("Prettier requested but not available. Using built-in formatter.")}return{content:C(r,e.builtIn),usedPrettier:!1,warnings:s.length>0?s:void 0}}async function Xr(r,e={}){let n=new Map;for(let[s,a]of r){let i=await H(a,e,s);n.set(s,i)}return n}function so(r={}){return{format:(e,n)=>H(e,r,n),formatMany:(e)=>Xr(e,r)}}async function oo(r){return(await H(r,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}
18
- export{H,Xr,so,oo};
17
+ `)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(r,e,n){let s=r.match(F);if(!s)return null;let[,a,i,u,l]=s,o=u.split(",").map((c)=>c.trim()).filter(Boolean);if(o.length<=1)return[r];let t=`${e}${a}${i??""} {`,p=l?`${e}} ${l};`:`${e}};`;return[t,...o.map((c)=>`${n}${c},`),p]}function v(r,e,n,s){let a=r.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!a)return[r];let[,,i,u,l,o]=a,t=l.split(/;\s*|,\s*/).filter((c)=>c.trim());if(t.length<=1)return[r];return[`${n}${i}${u}`,...t.map((c)=>`${s}${c.trim()};`),`${n}${o.trim()}`]}function R(r,e,n,s){let a=r.match(/^(\s*)(.*?=\s*)(.+)$/);if(!a)return[r];let[,,i,u]=a,l=u.split(/\s*\|\s*/).filter((t)=>t.trim());if(l.length<=2)return[r];return[`${n}${i}`,...l.map((t,p)=>`${s}${p>0?"| ":" "}${t.trim()}`)]}async function K(r,e={},n){let s=[];if(e.usePrettier!==!1){if(await P())try{let l={...await y(e.prettierConfigPath,n),...e.prettierOptions,parser:"typescript"};return{content:await w(r,l),usedPrettier:!0}}catch(u){s.push(`Prettier formatting failed: ${u}. Using built-in formatter.`)}else if(e.usePrettier===!0)s.push("Prettier requested but not available. Using built-in formatter.")}return{content:C(r,e.builtIn),usedPrettier:!1,warnings:s.length>0?s:void 0}}async function Xr(r,e={}){let n=new Map;for(let[s,a]of r){let i=await K(a,e,s);n.set(s,i)}return n}function so(r={}){return{format:(e,n)=>K(e,r,n),formatMany:(e)=>Xr(e,r)}}async function oo(r){return(await K(r,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}
18
+ export{K,Xr,so,oo};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{R,M}from"./chunk-2ngfncfx.js";import{P,D}from"./chunk-hqph3vnd.js";import{nr}from"./chunk-c7a07a26.js";import{p}from"./chunk-v6fwy63g.js";import{T,O}from"./chunk-3mcz22q8.js";var y=100,h=0,s=new Map;function Te(n,a,c=!0,i=!1,l){if(R(a))n=M(n);else if(P(a))n=D(n);let f=p(n),m=`${a}:${c?1:0}:${i?1:0}:${JSON.stringify([...l??[]].sort())}`,r=s.get(m);if(r&&r.contentHash===f)return r.lastAccess=++h,r.declarations;let g=i?T(n,a,c):O(n,a,c,l);if(s.set(m,{declarations:g,contentHash:f,lastAccess:++h}),s.size>y){let S=Math.max(1,Math.ceil(s.size*0.1)),e=[];for(let[t,o]of s)e.push([t,o.lastAccess]);e.sort((t,o)=>t[1]-o[1]);for(let t=0;t<S&&t<e.length;t++)s.delete(e[t][0])}return g}function Rn(){s.clear(),nr()}
2
+ import{R,M}from"./chunk-2ngfncfx.js";import{P,D}from"./chunk-hqph3vnd.js";import{nr}from"./chunk-g0dxj89b.js";import{p}from"./chunk-v6fwy63g.js";import{T,O}from"./chunk-epjq1edf.js";var y=100,h=0,s=new Map;function Te(n,a,c=!0,i=!1,l){if(R(a))n=M(n);else if(P(a))n=D(n);let f=p(n),m=`${a}:${c?1:0}:${i?1:0}:${JSON.stringify([...l??[]].sort())}`,r=s.get(m);if(r&&r.contentHash===f)return r.lastAccess=++h,r.declarations;let g=i?T(n,a,c):O(n,a,c,l);if(s.set(m,{declarations:g,contentHash:f,lastAccess:++h}),s.size>y){let S=Math.max(1,Math.ceil(s.size*0.1)),e=[];for(let[t,o]of s)e.push([t,o.lastAccess]);e.sort((t,o)=>t[1]-o[1]);for(let t=0;t<S&&t<e.length;t++)s.delete(e[t][0])}return g}function Rn(){s.clear(),nr()}
3
3
  export{Te,Rn};
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  var ge={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 v extends Error{code;context;constructor(n,e="UNKNOWN_ERROR",t){super(n);if(this.name="DtsxError",this.code=e,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let n=`${this.name} [${this.code}]: ${this.message}`;if(this.context)n+=`
3
- Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class wn extends v{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.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 ri extends v{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class ii extends v{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class xn extends v{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Cn extends v{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class si extends v{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function fo(n){return n instanceof v}function po(n){return n instanceof wn}function mo(n){return n instanceof xn}function go(n){return n instanceof Cn}function ho(n,e="UNKNOWN_ERROR",t){if(n instanceof v)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new v(s,e);if(n instanceof Error)r.cause=n;return r}function yo(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
3
+ Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class xn extends v{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.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 ri extends v{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class ii extends v{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class wn extends v{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Cn extends v{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class si extends v{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function fo(n){return n instanceof v}function po(n){return n instanceof xn}function mo(n){return n instanceof wn}function go(n){return n instanceof Cn}function ho(n,e="UNKNOWN_ERROR",t){if(n instanceof v)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new v(s,e);if(n instanceof Error)r.cause=n;return r}function yo(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
4
4
  `)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function bo(n,e,t,s){let r=n.split(`
5
5
  `),i=e.line-1,o=[];if(s)o.push(`${s}:${e.line}:${e.column}`);else o.push(`Line ${e.line}, Column ${e.column}`);o.push(`Error: ${t}`),o.push("");let E=Math.max(0,i-1),c=Math.min(r.length-1,i+1);for(let a=E;a<=c;a++){let R=(a+1).toString().padStart(4," "),u=a===i?">":" ";if(o.push(`${u} ${R} | ${r[a]}`),a===i){let l=" ".repeat(8+e.column-1);o.push(`${l}^`)}}return o.join(`
6
6
  `)}function ze(n,e,t){let s={file:e,message:"Unknown error",code:ge.UNKNOWN_ERROR};if(n instanceof Error){s.message=n.message,s.stack=n.stack;let r=n.message.match(/\((\d+),(\d+)\)/);if(r)s.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(n.message.includes("Cannot find")||n.message.includes("not found"))s.code=ge.FILE_NOT_FOUND,s.suggestion="Check that the file path is correct and the file exists.";else if(n.message.includes("syntax")||n.message.includes("Unexpected token"))s.code=ge.SYNTAX_ERROR,s.suggestion="Check for syntax errors in your TypeScript code.";else if(n.message.includes("type")&&n.message.includes("cannot"))s.code=ge.TYPE_INFERENCE_ERROR,s.suggestion="Add explicit type annotations to help with type inference.";else if(n.message.includes("parse")||n.message.includes("Parse"))s.code=ge.PARSE_ERROR,s.suggestion="The file contains invalid TypeScript syntax."}else if(typeof n==="string")s.message=n;return s}function bt(n,e){let t=[],s=n.file;if(n.location)s+=`:${n.location.line}:${n.location.column}`;if(n.code)s+=` [${n.code}]`;if(t.push(s),t.push(` Error: ${n.message}`),e&&n.location){t.push("");let r=e.split(`
7
7
  `),i=n.location.line-1;if(i>=0&&i<r.length){let o=Math.max(0,i-1),E=Math.min(r.length-1,i+1);for(let c=o;c<=E;c++){let a=(c+1).toString().padStart(4," "),R=c===i?">":" ";if(t.push(` ${R} ${a} | ${r[c]}`),c===i&&n.location.column>0){let u=" ".repeat(10+n.location.column-1);t.push(` ${u}^`)}}}}if(n.suggestion)t.push(""),t.push(` Suggestion: ${n.suggestion}`);return t.join(`
8
- `)}function wo(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
8
+ `)}function xo(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
9
9
  `)}
10
- export{ge,v,wn,ri,ii,xn,Cn,si,fo,po,mo,go,ho,yo,bo,ze,bt,wo};
10
+ export{ge,v,xn,ri,ii,wn,Cn,si,fo,po,mo,go,ho,yo,bo,ze,bt,xo};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{r}from"./chunk-z6mpxpxt.js";import{l}from"./chunk-yzdh207n.js";import{existsSync as P,readFileSync as b,unwatchFile as w}from"fs";var Nr;((o)=>{o[o.Error=1]="Error";o[o.Warning=2]="Warning";o[o.Information=3]="Information";o[o.Hint=4]="Hint"})(Nr||={});var Br;((s)=>{s[s.File=1]="File";s[s.Module=2]="Module";s[s.Namespace=3]="Namespace";s[s.Package=4]="Package";s[s.Class=5]="Class";s[s.Method=6]="Method";s[s.Property=7]="Property";s[s.Field=8]="Field";s[s.Constructor=9]="Constructor";s[s.Enum=10]="Enum";s[s.Interface=11]="Interface";s[s.Function=12]="Function";s[s.Variable=13]="Variable";s[s.Constant=14]="Constant";s[s.String=15]="String";s[s.Number=16]="Number";s[s.Boolean=17]="Boolean";s[s.Array=18]="Array";s[s.Object=19]="Object";s[s.Key=20]="Key";s[s.Null=21]="Null";s[s.EnumMember=22]="EnumMember";s[s.Struct=23]="Struct";s[s.Event=24]="Event";s[s.Operator=25]="Operator";s[s.TypeParameter=26]="TypeParameter"})(Br||={});var Wr;((c)=>{c[c.Text=1]="Text";c[c.Method=2]="Method";c[c.Function=3]="Function";c[c.Constructor=4]="Constructor";c[c.Field=5]="Field";c[c.Variable=6]="Variable";c[c.Class=7]="Class";c[c.Interface=8]="Interface";c[c.Module=9]="Module";c[c.Property=10]="Property";c[c.Unit=11]="Unit";c[c.Value=12]="Value";c[c.Enum=13]="Enum";c[c.Keyword=14]="Keyword";c[c.Snippet=15]="Snippet";c[c.Color=16]="Color";c[c.File=17]="File";c[c.Reference=18]="Reference";c[c.Folder=19]="Folder";c[c.EnumMember=20]="EnumMember";c[c.Constant=21]="Constant";c[c.Struct=22]="Struct";c[c.Event=23]="Event";c[c.Operator=24]="Operator";c[c.TypeParameter=25]="TypeParameter"})(Wr||={});var jr;((n)=>{n[n.Text=1]="Text";n[n.Read=2]="Read";n[n.Write=3]="Write"})(jr||={});class nn{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(t){return this.rootUri=t.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(t){let{uri:e,text:i,version:n}=t.textDocument;this.updateDocument(e,i,n)}didChange(t){let{uri:e,version:i}=t.textDocument,n=t.contentChanges[0]?.text||"";this.updateDocument(e,n,i)}didClose(t){let e=t.textDocument.uri;if(this.documents.delete(e),this.watchers.get(e))w(this.uriToPath(e)),this.watchers.delete(e)}updateDocument(t,e,i){let n=this.uriToPath(t),o=r(e,n,!0);this.documents.set(t,{content:e,version:i,declarations:o})}getDiagnostics(t){let e=this.documents.get(t);if(!e)return[];let i=[];for(let n of e.declarations){if(n.isExported&&n.kind==="variable"&&!n.typeAnnotation)i.push({range:this.getDeclarationRange(n,e.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${n.name}' should have an explicit type annotation for better declaration generation`});if(n.typeAnnotation==="any"||n.returnType==="any")i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(n.kind==="function"&&n.isExported&&!n.returnType)i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${n.name}' should have an explicit return type for better declaration generation`})}return i}hover(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:i,character:n}=t.position,a=e.content.split(`
2
+ import{r}from"./chunk-xmj05115.js";import{l}from"./chunk-yyqay3jp.js";import{existsSync as P,readFileSync as b,unwatchFile as w}from"fs";var Nr;((o)=>{o[o.Error=1]="Error";o[o.Warning=2]="Warning";o[o.Information=3]="Information";o[o.Hint=4]="Hint"})(Nr||={});var Br;((s)=>{s[s.File=1]="File";s[s.Module=2]="Module";s[s.Namespace=3]="Namespace";s[s.Package=4]="Package";s[s.Class=5]="Class";s[s.Method=6]="Method";s[s.Property=7]="Property";s[s.Field=8]="Field";s[s.Constructor=9]="Constructor";s[s.Enum=10]="Enum";s[s.Interface=11]="Interface";s[s.Function=12]="Function";s[s.Variable=13]="Variable";s[s.Constant=14]="Constant";s[s.String=15]="String";s[s.Number=16]="Number";s[s.Boolean=17]="Boolean";s[s.Array=18]="Array";s[s.Object=19]="Object";s[s.Key=20]="Key";s[s.Null=21]="Null";s[s.EnumMember=22]="EnumMember";s[s.Struct=23]="Struct";s[s.Event=24]="Event";s[s.Operator=25]="Operator";s[s.TypeParameter=26]="TypeParameter"})(Br||={});var Wr;((c)=>{c[c.Text=1]="Text";c[c.Method=2]="Method";c[c.Function=3]="Function";c[c.Constructor=4]="Constructor";c[c.Field=5]="Field";c[c.Variable=6]="Variable";c[c.Class=7]="Class";c[c.Interface=8]="Interface";c[c.Module=9]="Module";c[c.Property=10]="Property";c[c.Unit=11]="Unit";c[c.Value=12]="Value";c[c.Enum=13]="Enum";c[c.Keyword=14]="Keyword";c[c.Snippet=15]="Snippet";c[c.Color=16]="Color";c[c.File=17]="File";c[c.Reference=18]="Reference";c[c.Folder=19]="Folder";c[c.EnumMember=20]="EnumMember";c[c.Constant=21]="Constant";c[c.Struct=22]="Struct";c[c.Event=23]="Event";c[c.Operator=24]="Operator";c[c.TypeParameter=25]="TypeParameter"})(Wr||={});var _r;((n)=>{n[n.Text=1]="Text";n[n.Read=2]="Read";n[n.Write=3]="Write"})(_r||={});class nn{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(t){return this.rootUri=t.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(t){let{uri:e,text:i,version:n}=t.textDocument;this.updateDocument(e,i,n)}didChange(t){let{uri:e,version:i}=t.textDocument,n=t.contentChanges[0]?.text||"";this.updateDocument(e,n,i)}didClose(t){let e=t.textDocument.uri;if(this.documents.delete(e),this.watchers.get(e))w(this.uriToPath(e)),this.watchers.delete(e)}updateDocument(t,e,i){let n=this.uriToPath(t),o=r(e,n,!0);this.documents.set(t,{content:e,version:i,declarations:o})}getDiagnostics(t){let e=this.documents.get(t);if(!e)return[];let i=[];for(let n of e.declarations){if(n.isExported&&n.kind==="variable"&&!n.typeAnnotation)i.push({range:this.getDeclarationRange(n,e.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${n.name}' should have an explicit type annotation for better declaration generation`});if(n.typeAnnotation==="any"||n.returnType==="any")i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(n.kind==="function"&&n.isExported&&!n.returnType)i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${n.name}' should have an explicit return type for better declaration generation`})}return i}hover(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:i,character:n}=t.position,a=e.content.split(`
3
3
  `)[i]||"",u=a.slice(0,n).match(/[\w$]+$/),d=a.slice(n).match(/^[\w$]+/);if(!u&&!d)return null;let g=(u?.[0]||"")+(d?.[0]||""),f=e.declarations.find((x)=>x.name===g);if(!f)return null;let m=`\`\`\`typescript
4
4
  ${this.buildSignature(f)}
5
5
  \`\`\``;if(f.leadingComments&&f.leadingComments.length>0){let v=f.leadingComments.join(`
@@ -19,4 +19,4 @@ ${v[1].trim()}`}return{contents:{kind:"markdown",value:m}}}completion(t){let e=t
19
19
  `);if(n===-1)break;let a=e.slice(0,n).match(/Content-Length:\s*(\d+)/i);if(!a){e=e.slice(n+4);continue}let u=Number.parseInt(a[1],10),d=n+4,g=d+u;if(e.length<g)break;let f=e.slice(d,g);e=e.slice(g);try{let p=JSON.parse(f),m=t.handleMessage(p);if(m){let x=JSON.stringify(m),v=Buffer.byteLength(x,"utf8");process.stdout.write(`Content-Length: ${v}\r
20
20
  \r
21
21
  ${x}`)}}catch(p){console.error("Error parsing LSP message:",p)}}})}function Fs(t,e){return(i)=>{if(!P(i))return;let n=b(i,"utf-8"),o=`file://${i}`;t.didOpen({textDocument:{uri:o,languageId:"typescript",version:1,text:n}});let a=t.getDiagnostics(o);e(o,a)}}
22
- export{Nr,Br,Wr,jr,nn,Ls,Fs};
22
+ export{Nr,Br,Wr,_r,nn,Ls,Fs};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{W}from"./chunk-k5wz43yh.js";import{p}from"./chunk-v6fwy63g.js";var f=100,c=new Map,a=new Map,u=new Map,g=0;function d(e,n,t){let r={fileName:e,text:n};c.delete(e),c.set(e,{file:r,hash:t});while(c.size>f){let s=c.keys().next().value;if(s===void 0)break;c.delete(s)}return r}function b(e,n,t){return u.set(e,(u.get(e)??0)+1),d(e,n,t)}function Ot(e,n,t=p(n)){let r=c.get(e);if(r?.hash===t)return c.delete(e),c.set(e,r),r.file;return b(e,n,t)}async function te(e,n,t={}){let r=p(n);if(c.get(e)?.hash===r)return Ot(e,n,r);let o=`${e}\x00${String(r)}`,i=a.get(o);if(i)return i;let h=(u.get(e)??0)+1;u.set(e,h);let m=g,l;return l=Promise.resolve().then(async()=>{try{if(n.length>=(t.asyncThreshold??1e5))await new Promise((y)=>setTimeout(y,Math.max(0,t.yieldInterval??0)));if(m===g&&u.get(e)===h)return d(e,n,r);return{fileName:e,text:n}}finally{if(a.get(o)===l)a.delete(o)}}),a.set(o,l),l}async function Mn(e,n={}){let t=new Map,r=W(n.concurrency,4);for(let s=0;s<e.length;s+=r){let o=await Promise.all(e.slice(s,s+r).map(async(i)=>({path:i.filePath,file:await te(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function On(){g++,c.clear(),a.clear(),u.clear()}function In(){return c.size}function Ln(){return a.size}function Fn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
3
- export{Ot,te,Mn,On,In,Ln,Fn};
2
+ import{W}from"./chunk-k5wz43yh.js";import{p}from"./chunk-v6fwy63g.js";var f=100,c=new Map,a=new Map,u=new Map,g=0;function d(e,n,t){let r={fileName:e,text:n};c.delete(e),c.set(e,{file:r,hash:t});while(c.size>f){let s=c.keys().next().value;if(s===void 0)break;c.delete(s)}return r}function b(e,n,t){return u.set(e,(u.get(e)??0)+1),d(e,n,t)}function Ot(e,n,t=p(n)){let r=c.get(e);if(r?.hash===t)return c.delete(e),c.set(e,r),r.file;return b(e,n,t)}async function ne(e,n,t={}){let r=p(n);if(c.get(e)?.hash===r)return Ot(e,n,r);let o=`${e}\x00${String(r)}`,i=a.get(o);if(i)return i;let h=(u.get(e)??0)+1;u.set(e,h);let m=g,l;return l=Promise.resolve().then(async()=>{try{if(n.length>=(t.asyncThreshold??1e5))await new Promise((y)=>setTimeout(y,Math.max(0,t.yieldInterval??0)));if(m===g&&u.get(e)===h)return d(e,n,r);return{fileName:e,text:n}}finally{if(a.get(o)===l)a.delete(o)}}),a.set(o,l),l}async function Mn(e,n={}){let t=new Map,r=W(n.concurrency,4);for(let s=0;s<e.length;s+=r){let o=await Promise.all(e.slice(s,s+r).map(async(i)=>({path:i.filePath,file:await ne(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function On(){g++,c.clear(),a.clear(),u.clear()}function In(){return c.size}function Ln(){return a.size}function Fn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
3
+ export{Ot,ne,Mn,On,In,Ln,Fn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{t}from"./chunk-c7a07a26.js";function j(n){let s=t(n),r=(e)=>s[e]?n.slice(s[e].start,s[e].end):"",d=new Map,k=[];for(let e=0;e<s.length;e++)if(["(","[","{"].includes(r(e)))k.push(e);else if([")","]","}"].includes(r(e))){let i=k.pop();if(i===void 0||!["()","[]","{}"].includes(r(i)+r(e)))throw Error("Unbalanced binding pattern");d.set(i,e)}if(k.length)throw Error("Unbalanced binding pattern");for(let e=0;e<s.length;e++){if(r(e)!=="<")continue;let i=["=",",","(",":","?","[","{"].includes(r(e-1)),f=1;for(let a=e+1;a<s.length;a++){if(r(a)==="="&&r(a+1)!==">"&&f===1&&!i)break;if(r(a)==="<")f++;else if(r(a)===">"&&r(a-1)!=="="&&--f===0){if(a+1===s.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(r(a+1)))d.set(e,a);break}let u=d.get(a);if(u!==void 0)a=u}}let g=(e,i)=>({text:e<i?n.slice(s[e].start,s[i-1].end):"",offset:s[e]?.start??n.length}),w=(e,i,f)=>{for(let a=e;a<i;a++){if(r(a)===f)return a;let u=d.get(a);if(u!==void 0)a=u}return},b=(e,i)=>{let f=w(e,i,"="),a=f===void 0?void 0:g(f+1,i);if(f!==void 0)i=f;if(e+1===i&&s[e]?.kind==="word")return{kind:"name",name:r(e),defaultValue:a};let u=r(e)==="{"?"object":r(e)==="["?"array":void 0;if(!u||d.get(e)!==i-1)throw Error(`Invalid binding target: ${g(e,i).text}`);let m=[],o=e+1;while(o<i-1){let h=w(o,i-1,","),p=h??i-1;if(o===p)m.push(void 0);else if(r(o)==="."&&r(o+1)==="."&&r(o+2)===".")m.push({rest:!0,target:b(o+3,p)});else if(u==="array")m.push({rest:!1,target:b(o,p)});else if(r(o)==="["){let c=d.get(o);if(c===void 0||r(c+1)!==":")throw Error("Computed binding needs a target");m.push({computed:g(o+1,c),rest:!1,target:b(c+2,p)})}else{let c=o+1;if(s[o].kind!=="word"&&s[o].kind!=="quoted")while(c<p&&r(c)!==":")c++;let l=r(c)===":";if(!l&&s[o].kind!=="word")throw Error("Invalid object binding key");m.push({key:g(o,l?c:o+1).text,rest:!1,target:b(l?c+1:o,p)})}if(h===void 0)break;o=h+1}return{kind:u,elements:m,defaultValue:a}};return b(0,s.length)}function y(n,s){if(n.kind==="name")s.push(n.name);else for(let r of n.elements)if(r)y(r.target,s)}function er(n){let s=[];return y(j(n),s),s}function tr(n){let s=j(n.pattern),r=[];if(y(s,r),!r.length)return[];let d=[n.root],k=!1,g={start:n.root.start,end:n.root.end},w=(e,i)=>{let f=n.allocateName();return d.push({kind:"variable",name:f,text:`declare ${i} ${f}: unknown;`,value:e.text,initializerStart:n.patternOffset+e.offset,modifiers:[i],isExported:!1,...g}),f},b=(e,i)=>{if(e.defaultValue){let l=w(e.defaultValue,n.kind),x=n.allocateName();i=`(${i}) extends infer ${x} ? ${x} extends undefined ? typeof ${l} : ${x} : never`}if(e.kind==="name"){let l=k?void 0:n.comments;k=!0,d.push({kind:"variable",name:e.name,text:`${n.exported?"export ":""}declare ${n.kind} ${e.name}: ${i};`,typeAnnotation:i,modifiers:[n.kind],isExported:n.exported,leadingComments:l,...g});return}let f=e.elements,a=[],u=[],m=[];for(let l of f){if(!l){a.push("");continue}let x=n.allocateName(),E=l.key;if(l.computed)E=`[${w(l.computed,"const")}]`;a.push(l.rest?`...${x}`:e.kind==="object"?`${E}: ${x}`:x),u.push({target:l.target,index:m.length}),m.push(`typeof ${x}`)}let o=n.allocateName(),h=n.allocateName(),p=n.allocateName(),c=e.kind==="object"?`{ ${a.join(", ")} }`:`[${a.join(", ")}]`;d.push({kind:"function",name:o,text:`declare function ${o}(${c}: ${i}): [${m.join(", ")}];`,isExported:!1,...g}),d.push({kind:"type",name:h,text:`type ${h} = (typeof ${o}) extends (...args: never[]) => infer ${p} ? ${p} : never;`,isExported:!1,...g});for(let l of u)b(l.target,`${h}[${l.index}]`)};return b(s,`typeof ${n.root.name}`),d}
2
+ import{t}from"./chunk-g0dxj89b.js";function j(n){let s=t(n),r=(e)=>s[e]?n.slice(s[e].start,s[e].end):"",d=new Map,k=[];for(let e=0;e<s.length;e++)if(["(","[","{"].includes(r(e)))k.push(e);else if([")","]","}"].includes(r(e))){let i=k.pop();if(i===void 0||!["()","[]","{}"].includes(r(i)+r(e)))throw Error("Unbalanced binding pattern");d.set(i,e)}if(k.length)throw Error("Unbalanced binding pattern");for(let e=0;e<s.length;e++){if(r(e)!=="<")continue;let i=["=",",","(",":","?","[","{"].includes(r(e-1)),f=1;for(let a=e+1;a<s.length;a++){if(r(a)==="="&&r(a+1)!==">"&&f===1&&!i)break;if(r(a)==="<")f++;else if(r(a)===">"&&r(a-1)!=="="&&--f===0){if(a+1===s.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(r(a+1)))d.set(e,a);break}let u=d.get(a);if(u!==void 0)a=u}}let g=(e,i)=>({text:e<i?n.slice(s[e].start,s[i-1].end):"",offset:s[e]?.start??n.length}),w=(e,i,f)=>{for(let a=e;a<i;a++){if(r(a)===f)return a;let u=d.get(a);if(u!==void 0)a=u}return},b=(e,i)=>{let f=w(e,i,"="),a=f===void 0?void 0:g(f+1,i);if(f!==void 0)i=f;if(e+1===i&&s[e]?.kind==="word")return{kind:"name",name:r(e),defaultValue:a};let u=r(e)==="{"?"object":r(e)==="["?"array":void 0;if(!u||d.get(e)!==i-1)throw Error(`Invalid binding target: ${g(e,i).text}`);let m=[],o=e+1;while(o<i-1){let h=w(o,i-1,","),p=h??i-1;if(o===p)m.push(void 0);else if(r(o)==="."&&r(o+1)==="."&&r(o+2)===".")m.push({rest:!0,target:b(o+3,p)});else if(u==="array")m.push({rest:!1,target:b(o,p)});else if(r(o)==="["){let c=d.get(o);if(c===void 0||r(c+1)!==":")throw Error("Computed binding needs a target");m.push({computed:g(o+1,c),rest:!1,target:b(c+2,p)})}else{let c=o+1;if(s[o].kind!=="word"&&s[o].kind!=="quoted")while(c<p&&r(c)!==":")c++;let l=r(c)===":";if(!l&&s[o].kind!=="word")throw Error("Invalid object binding key");m.push({key:g(o,l?c:o+1).text,rest:!1,target:b(l?c+1:o,p)})}if(h===void 0)break;o=h+1}return{kind:u,elements:m,defaultValue:a}};return b(0,s.length)}function y(n,s){if(n.kind==="name")s.push(n.name);else for(let r of n.elements)if(r)y(r.target,s)}function er(n){let s=[];return y(j(n),s),s}function tr(n){let s=j(n.pattern),r=[];if(y(s,r),!r.length)return[];let d=[n.root],k=!1,g={start:n.root.start,end:n.root.end},w=(e,i)=>{let f=n.allocateName();return d.push({kind:"variable",name:f,text:`declare ${i} ${f}: unknown;`,value:e.text,initializerStart:n.patternOffset+e.offset,modifiers:[i],isExported:!1,...g}),f},b=(e,i)=>{if(e.defaultValue){let l=w(e.defaultValue,n.kind),x=n.allocateName();i=`(${i}) extends infer ${x} ? ${x} extends undefined ? typeof ${l} : ${x} : never`}if(e.kind==="name"){let l=k?void 0:n.comments;k=!0,d.push({kind:"variable",name:e.name,text:`${n.exported?"export ":""}declare ${n.kind} ${e.name}: ${i};`,typeAnnotation:i,modifiers:[n.kind],isExported:n.exported,leadingComments:l,...g});return}let f=e.elements,a=[],u=[],m=[];for(let l of f){if(!l){a.push("");continue}let x=n.allocateName(),E=l.key;if(l.computed)E=`[${w(l.computed,"const")}]`;a.push(l.rest?`...${x}`:e.kind==="object"?`${E}: ${x}`:x),u.push({target:l.target,index:m.length}),m.push(`typeof ${x}`)}let o=n.allocateName(),h=n.allocateName(),p=n.allocateName(),c=e.kind==="object"?`{ ${a.join(", ")} }`:`[${a.join(", ")}]`;d.push({kind:"function",name:o,text:`declare function ${o}(${c}: ${i}): [${m.join(", ")}];`,isExported:!1,...g}),d.push({kind:"type",name:h,text:`type ${h} = (typeof ${o}) extends (...args: never[]) => infer ${p} ? ${p} : never;`,isExported:!1,...g});for(let l of u)b(l.target,`${h}[${l.index}]`)};return b(s,`typeof ${n.root.name}`),d}
3
3
  export{er,tr};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{t,d,x}from"./chunk-c7a07a26.js";import{w}from"./chunk-0m1wt3db.js";function q(n){return typeof n==="string"?x(n,"'"):String(n)}function ma(n,k,m=new Map){let o=t(n),e=new Map(m),i=new Map,f=[],c=1,p=0,A=0;for(let r=1;r<o.length;r++){let v=o[r],h=n.slice(v.start,v.end);if(v.kind==="punctuation"&&p===0&&(h===","||h==="}")){let l=o.slice(c,r),a=l[0];if(a){let u=a.kind==="quoted"?d(n.slice(a.start,a.end)):n.slice(a.start,a.end),M=l.findIndex((g)=>g.kind==="punctuation"&&n[g.start]==="="),s=A;if(M>=0){let g=l.slice(M+1),b="",S=l[M].end;for(let y=0;y+2<g.length;y++){let[B,E,C]=g.slice(y,y+3);if(B.kind!=="word"||C.kind!=="word"||n.slice(E.start,E.end)!==".")continue;let D=e.get(`${n.slice(B.start,B.end)}.${n.slice(C.start,C.end)}`);if(D===void 0||typeof D==="object")continue;b+=n.slice(S,B.start)+q(D),S=C.end,y+=2}b+=n.slice(S,l.at(-1).end),s=w(b,e),f.push({start:l[M].start,end:l.at(-1).end,text:s===void 0?"":`= ${q(s)}`})}else if(s!==void 0)f.push({start:a.end,end:a.end,text:` = ${q(s)}`});if(A=typeof s==="number"?s+1:void 0,u!==void 0){if(e.delete(u),e.delete(`${k}.${u}`),s!==void 0)i.set(u,s),e.set(u,s),e.set(`${k}.${u}`,s)}}c=r+1}else if(v.kind==="punctuation"){if("([{".includes(h))p++;else if(")]}".includes(h))p--}}let K=n;for(let r of f.reverse())K=K.slice(0,r.start)+r.text+K.slice(r.end);return{body:K,members:i}}function Bn(n,k){let m=[...new Set([...n,...k.values()])];if(!m.some((e)=>e.kind==="enum"))return;m.sort((e,i)=>(e.start??0)-(i.start??0));let o=new Map;for(let e of m)if(e.kind==="enum"){let i=e.text.indexOf("{");if(i<0)continue;if(t(e.text.slice(0,i)).some((c)=>e.text.slice(c.start,c.end)==="declare"))continue;let f=ma(e.text.slice(i),e.name,o);e.text=e.text.slice(0,i)+f.body;for(let[c,p]of f.members)o.set(`${e.name}.${c}`,p)}else if(e.kind==="variable"&&e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion")&&typeof e.value==="string"){let i=w(e.value,o);if(i!==void 0)o.set(e.name,i)}}
2
+ import{t,d,w}from"./chunk-g0dxj89b.js";import{x}from"./chunk-fv3x086v.js";function q(n){return typeof n==="string"?w(n,"'"):String(n)}function ma(n,k,m=new Map){let o=t(n),e=new Map(m),i=new Map,f=[],c=1,p=0,A=0;for(let r=1;r<o.length;r++){let v=o[r],h=n.slice(v.start,v.end);if(v.kind==="punctuation"&&p===0&&(h===","||h==="}")){let l=o.slice(c,r),a=l[0];if(a){let u=a.kind==="quoted"?d(n.slice(a.start,a.end)):n.slice(a.start,a.end),M=l.findIndex((g)=>g.kind==="punctuation"&&n[g.start]==="="),s=A;if(M>=0){let g=l.slice(M+1),b="",S=l[M].end;for(let y=0;y+2<g.length;y++){let[B,E,C]=g.slice(y,y+3);if(B.kind!=="word"||C.kind!=="word"||n.slice(E.start,E.end)!==".")continue;let D=e.get(`${n.slice(B.start,B.end)}.${n.slice(C.start,C.end)}`);if(D===void 0||typeof D==="object")continue;b+=n.slice(S,B.start)+q(D),S=C.end,y+=2}b+=n.slice(S,l.at(-1).end),s=x(b,e),f.push({start:l[M].start,end:l.at(-1).end,text:s===void 0?"":`= ${q(s)}`})}else if(s!==void 0)f.push({start:a.end,end:a.end,text:` = ${q(s)}`});if(A=typeof s==="number"?s+1:void 0,u!==void 0){if(e.delete(u),e.delete(`${k}.${u}`),s!==void 0)i.set(u,s),e.set(u,s),e.set(`${k}.${u}`,s)}}c=r+1}else if(v.kind==="punctuation"){if("([{".includes(h))p++;else if(")]}".includes(h))p--}}let K=n;for(let r of f.reverse())K=K.slice(0,r.start)+r.text+K.slice(r.end);return{body:K,members:i}}function Bn(n,k){let m=[...new Set([...n,...k.values()])];if(!m.some((e)=>e.kind==="enum"))return;m.sort((e,i)=>(e.start??0)-(i.start??0));let o=new Map;for(let e of m)if(e.kind==="enum"){let i=e.text.indexOf("{");if(i<0)continue;if(t(e.text.slice(0,i)).some((c)=>e.text.slice(c.start,c.end)==="declare"))continue;let f=ma(e.text.slice(i),e.name,o);e.text=e.text.slice(0,i)+f.body;for(let[c,p]of f.members)o.set(`${e.name}.${c}`,p)}else if(e.kind==="variable"&&e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion")&&typeof e.value==="string"){let i=x(e.value,o);if(i!==void 0)o.set(e.name,i)}}
3
3
  export{ma,Bn};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{u}from"./chunk-85d82vn3.js";import{e}from"./chunk-btc6zbyj.js";import{w,m}from"./chunk-g0dxj89b.js";import{ee}from"./chunk-w3zqfm8a.js";import{existsSync as T,readFileSync as N,realpathSync as E,statSync as X}from"fs";import{builtinModules as F}from"module";import{dirname as I,extname as V,isAbsolute as A,join as J,relative as C,resolve as S}from"path";var B=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],z={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};function j(t){try{return X(t).isFile()}catch{return!1}}function Q(t,i){let s=t.replace(/[?#].*$/,"");if(!(s.startsWith("./")||s.startsWith("../")||s==="."||s==="..")&&!A(s))return{resolved:null,isRelative:!1};let a=I(i),c=S(a,s);if(j(c))return{resolved:c,isRelative:!0};let p=V(c),d=z[p];if(d){let f=c.slice(0,-p.length);for(let r of d){let o=f+r;if(j(o))return{resolved:o,isRelative:!0}}}for(let f of B){let r=c+f;if(j(r))return{resolved:r,isRelative:!0}}if(T(c))for(let f of B){let r=J(c,`index${f}`);if(j(r))return{resolved:r,isRelative:!0}}return{resolved:null,isRelative:!0}}function K(t,i){let s=t.indexOf("*");return s===-1?i===t:i.startsWith(t.slice(0,s))&&i.endsWith(t.slice(s+1))&&i.length>=t.length-1}function L(t,i){if(Object.hasOwn(t,i))return t[i]!==null;let s=Object.keys(t).filter((l)=>l.includes("*")&&K(l,i)).sort((l,a)=>a.indexOf("*")-l.indexOf("*")||a.length-l.length)[0];return s!==void 0&&t[s]!==null}function D(t,i){if(!t.name||i!==t.name&&!i.startsWith(`${t.name}/`))return!1;if(t.exports===void 0)return!0;let s=i===t.name?".":`.${i.slice(t.name.length)}`;if(typeof t.exports==="string"||Array.isArray(t.exports))return s===".";if(!t.exports||typeof t.exports!=="object")return!1;let l=t.exports;if(!Object.keys(l).some((c)=>c.startsWith(".")))return s===".";return L(l,s)}function W(t,i){let s=C(t,i);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!A(s)}async function Ee(t){let i=await ee(S(t.cwd,t.tsconfigPath||"tsconfig.json")),s=Object.entries(i?.paths??{});if(s.length===0){let r=(o,n)=>Q(o,n);return r.cacheKey=(o)=>JSON.stringify(o.map((n)=>({file:n,references:k(N(n,"utf8"),{includeImports:!0}).map((g)=>({specifier:g.specifier,resolution:r(g.specifier,n)}))}))),r}let l=i?.baseUrl??i?.pathsBasePath??t.cwd,a=S(t.cwd,t.root),c=new Map,p=new Set([...F,"bun"]),d=(r)=>{let o=I(r),n=[];while(!0){if(c.has(o)){let R=c.get(o);for(let y of n)c.set(y,R);return R}n.push(o);let g=J(o,"package.json");if(T(g)){let y={...JSON.parse(N(g,"utf8")),directory:E(o)};for(let O of n)c.set(O,y);return y}let v=I(o);if(v===o)return;o=v}},f=(r,o)=>{if(r.startsWith(".")||A(r))return Q(r,o);if(r.startsWith("node:")||r.startsWith("bun:")||p.has(r))return{resolved:null,isRelative:!1};let n=d(o),g=r.startsWith("@")?/^@[^/]+\/[^/]+/.exec(r)?.[0]:r.split("/")[0];if(n&&(D(n,r)||L(n.imports??{},r)||g&&[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies].some((h)=>Object.hasOwn(h??{},g))))return{resolved:null,isRelative:!1};let v=s.filter(([h])=>K(h,r)).sort(([h],[b])=>{if(!h.includes("*"))return-1;if(!b.includes("*"))return 1;return b.indexOf("*")-h.indexOf("*")})[0];if(!v)return{resolved:null,isRelative:!1};let[R,y]=v,O=R.indexOf("*"),_=O===-1?"":r.slice(O,r.length-(R.length-O-1));for(let h of y){let b=S(l,h.replace("*",_)),M=d(b);if(M&&D(M,r)&&!M.private&&M.directory!==n?.directory)return{resolved:null,isRelative:!1};let P=Q(b,o);if(!P.resolved)continue;let x=E(P.resolved),q=t.outputStructure==="flat"||T(a)&&W(E(a),x);if(!n||!W(n.directory,x)||!q||d(x)?.directory!==n.directory||/\.d\.(?:ts|mts|cts)$/.test(x))throw Error(`Local alias ${JSON.stringify(r)} from ${o} resolves outside its emitted package source: ${x}`);return e.debug(`Resolved local declaration alias ${r} from ${o} to ${x}`),{resolved:t.outputStructure==="flat"?P.resolved:S(a,C(E(a),x)),isRelative:!0,isAlias:!0,suffix:b.match(/[?#].*$/)?.[0]??""}}throw Error(`Cannot resolve local alias ${JSON.stringify(r)} from ${o} using ${t.tsconfigPath||"tsconfig.json"} (${JSON.stringify(R)})`)};return f.isPackageLocal=(r,o)=>{let n=d(r);return!!n&&d(o)?.directory===n.directory&&W(n.directory,E(o))},f.cacheKey=(r)=>{let o=r.map((g)=>({file:g,references:k(N(g,"utf8"),{includeImports:!0}).map((v)=>({specifier:v.specifier,resolution:f(v.specifier,g)}))})),n=[...new Set(c.values())].filter((g)=>g!==void 0).sort((g,v)=>g.directory.localeCompare(v.directory));return JSON.stringify({root:a,compilerOptions:i,packages:n,edges:o})},f}function k(t,i={}){let s=m(t);return(i.includeImports?["export","static-import","import-type","augmentation"]:["export"]).flatMap((a)=>s.filter((c)=>c.category===a).map(({specifier:c,kind:p,isTypeOnly:d})=>({specifier:c,kind:p,isTypeOnly:d})))}function Pn(t,i){let s=[];for(let a of m(t)){let c=i(a.specifier);if(c!==a.specifier)s.push({start:a.start,end:a.end,value:w(c,t[a.start])})}let l=t;for(let a of s.reverse())l=l.slice(0,a.start)+a.value+l.slice(a.end);return l}async function U(t,i={}){let s=new Set,l=new Map,a=[],c=new Map,p=[];for(let d of t){let f=S(d);if(!s.has(f))s.add(f),p.push(f)}while(p.length>0){let d=p.shift(),f;try{f=await u(d)}catch{continue}c.set(d,f);let r=k(f,i);l.set(d,r);for(let o of r){let n=(i.resolveSpecifier??Q)(o.specifier,d);if(!n.isRelative)continue;if(n.resolved){if(!s.has(n.resolved))s.add(n.resolved),p.push(n.resolved)}else a.push({from:d,specifier:o.specifier,isTypeOnly:o.isTypeOnly})}}return{reachable:s,reExports:l,unresolved:a,sources:c}}
3
+ export{Q,Ee,k,Pn,U};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{spawn as m}from"child_process";import{readFile as i,stat as n,writeFile as p}from"fs/promises";var g=typeof globalThis.Bun<"u",na=!g&&typeof process<"u"&&!!process.versions?.node,ra=g?"bun":"node";class s{name;_size=-1;constructor(e){this.name=e}async exists(){try{return await n(this.name),!0}catch{return!1}}async text(){return i(this.name,"utf-8")}async arrayBuffer(){let e=await i(this.name);return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}get size(){if(this._size===-1)return-1;return this._size}}class a{pid;stdout;stderr;stdin;exited;process;constructor(e){this.process=e,this.pid=e.pid??0,this.stdout=e.stdout,this.stderr=e.stderr,this.stdin=e.stdin,this.exited=new Promise((r)=>{e.on("exit",(t)=>{r(t??0)}),e.on("error",()=>{r(1)})})}kill(e){this.process.kill(e)}ref(){this.process.ref()}unref(){this.process.unref()}}function ee(e){if(g)return globalThis.Bun.file(e);return new s(e)}async function Xe(e,r){if(g)return globalThis.Bun.write(e,r);let t=typeof r==="string"?r:r instanceof ArrayBuffer?Buffer.from(r):r;return await p(e,t),typeof r==="string"?Buffer.byteLength(r):r.byteLength}function Et(e,r={}){if(g)return globalThis.Bun.spawn(e,r);let t=Array.isArray(e)?e:[e],[o,...d]=t,l={cwd:r.cwd,env:r.env,stdio:[r.stdin??"pipe",r.stdout??"pipe",r.stderr??"pipe"]},f=m(o,d,l);return new a(f)}async function u(e){if(g)return globalThis.Bun.file(e).text();return i(e,"utf-8")}async function ia(e){if(g)return globalThis.Bun.file(e).exists();try{return await n(e),!0}catch{return!1}}async function sa(e,r){await Xe(e,r)}function oa(){if(g)return{name:"bun",version:globalThis.Bun.version,isBun:!0,isNode:!1};return{name:"node",version:process.versions.node,isBun:!1,isNode:!0}}
3
- export{g,na,ra,ee,Xe,Et,u,ia,sa,oa};
2
+ import{spawn as m}from"child_process";import{readFile as i,stat as n,writeFile as p}from"fs/promises";var g=typeof globalThis.Bun<"u",na=!g&&typeof process<"u"&&!!process.versions?.node,ra=g?"bun":"node";class s{name;_size=-1;constructor(e){this.name=e}async exists(){try{return await n(this.name),!0}catch{return!1}}async text(){return i(this.name,"utf-8")}async arrayBuffer(){let e=await i(this.name);return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}get size(){if(this._size===-1)return-1;return this._size}}class a{pid;stdout;stderr;stdin;exited;process;constructor(e){this.process=e,this.pid=e.pid??0,this.stdout=e.stdout,this.stderr=e.stderr,this.stdin=e.stdin,this.exited=new Promise((r)=>{e.on("exit",(t)=>{r(t??0)}),e.on("error",()=>{r(1)})})}kill(e){this.process.kill(e)}ref(){this.process.ref()}unref(){this.process.unref()}}function te(e){if(g)return globalThis.Bun.file(e);return new s(e)}async function Xe(e,r){if(g)return globalThis.Bun.write(e,r);let t=typeof r==="string"?r:r instanceof ArrayBuffer?Buffer.from(r):r;return await p(e,t),typeof r==="string"?Buffer.byteLength(r):r.byteLength}function Et(e,r={}){if(g)return globalThis.Bun.spawn(e,r);let t=Array.isArray(e)?e:[e],[o,...d]=t,l={cwd:r.cwd,env:r.env,stdio:[r.stdin??"pipe",r.stdout??"pipe",r.stderr??"pipe"]},f=m(o,d,l);return new a(f)}async function u(e){if(g)return globalThis.Bun.file(e).text();return i(e,"utf-8")}async function ia(e){if(g)return globalThis.Bun.file(e).exists();try{return await n(e),!0}catch{return!1}}async function sa(e,r){await Xe(e,r)}function oa(){if(g)return{name:"bun",version:globalThis.Bun.version,isBun:!0,isNode:!1};return{name:"node",version:process.versions.node,isBun:!1,isNode:!0}}
3
+ export{g,na,ra,te,Xe,Et,u,ia,sa,oa};