@stacksjs/dtsx 0.9.12 → 0.9.14

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 (87) hide show
  1. package/README.md +5 -3
  2. package/dist/bin/cli.js +6 -6
  3. package/dist/branded-types.d.ts +10 -18
  4. package/dist/chunk-1bge31tv.js +2 -0
  5. package/dist/chunk-27nzyfdd.js +2 -0
  6. package/dist/chunk-285mqzvx.js +16 -0
  7. package/dist/chunk-2n1bbm2c.js +448 -0
  8. package/dist/chunk-3w5aqasc.js +33 -0
  9. package/dist/chunk-3xqchdwd.js +2 -0
  10. package/dist/chunk-7tyhhk7c.js +2 -0
  11. package/dist/chunk-8kz02py2.js +2 -0
  12. package/dist/{chunk-xe1z54pq.js → chunk-abhx1v3w.js} +1 -1
  13. package/dist/chunk-ayvw3402.js +2 -0
  14. package/dist/chunk-cbz06k9p.js +2 -0
  15. package/dist/chunk-d1xj2pjv.js +24 -0
  16. package/dist/chunk-dk914hsr.js +2 -0
  17. package/dist/chunk-dzgms5s6.js +80 -0
  18. package/dist/{chunk-91gpfz27.js → chunk-enqtx6te.js} +1 -1
  19. package/dist/{chunk-57agx6g8.js → chunk-gssantc8.js} +1 -1
  20. package/dist/chunk-j1zrbs2z.js +2 -0
  21. package/dist/{chunk-20kdv9bh.js → chunk-j8zksbkn.js} +1 -1
  22. package/dist/chunk-mcdb3q06.js +3 -0
  23. package/dist/{chunk-7vj8vtzh.js → chunk-mwfja9e3.js} +1 -1
  24. package/dist/{chunk-jm5ywn4e.js → chunk-mxam9312.js} +8 -8
  25. package/dist/chunk-nf54b52t.js +6 -0
  26. package/dist/{chunk-kge8a5vc.js → chunk-p50ms07x.js} +1 -1
  27. package/dist/{chunk-p09jmjq8.js → chunk-pj8142by.js} +1 -1
  28. package/dist/chunk-pt2txw6z.js +2 -0
  29. package/dist/chunk-r6v1qdqb.js +6 -0
  30. package/dist/chunk-rsv17jh8.js +3 -0
  31. package/dist/{chunk-7cpp6v8f.js → chunk-sw3m29sw.js} +1 -1
  32. package/dist/chunk-thhd43x5.js +19 -0
  33. package/dist/{chunk-3j7r0fxz.js → chunk-tne5n3h1.js} +1 -1
  34. package/dist/{chunk-v96rjx7x.js → chunk-trm0gptj.js} +1 -1
  35. package/dist/{chunk-jddkdjap.js → chunk-vgm83r4p.js} +1 -1
  36. package/dist/chunk-vpjw38x7.js +34 -0
  37. package/dist/chunk-wzq881r8.js +4 -0
  38. package/dist/chunk-x4v9kajr.js +3 -0
  39. package/dist/{chunk-8j312sjx.js → chunk-xmje6xfw.js} +1 -1
  40. package/dist/{chunk-3g2v2ns2.js → chunk-xtee8g1a.js} +1 -1
  41. package/dist/{chunk-fjjs2r77.js → chunk-y6m8mmyg.js} +1 -1
  42. package/dist/{chunk-6qv7p9sg.js → chunk-zf17s33e.js} +18 -11
  43. package/dist/compat.d.ts +5 -2
  44. package/dist/extractor/cache.d.ts +6 -2
  45. package/dist/extractor/directives.d.ts +0 -4
  46. package/dist/generator.d.ts +1 -1
  47. package/dist/logger.d.ts +4 -0
  48. package/dist/optimizer.d.ts +4 -0
  49. package/dist/process-source.d.ts +1 -0
  50. package/dist/processor/cache.d.ts +4 -2
  51. package/dist/processor/imports.d.ts +1 -0
  52. package/dist/src/index.js +52 -51
  53. package/dist/src/plugins/bun.js +1 -1
  54. package/dist/src/plugins/esbuild.js +1 -1
  55. package/dist/src/plugins/index.js +1 -1
  56. package/dist/src/plugins/tsup.js +1 -1
  57. package/dist/src/plugins/vite.js +1 -1
  58. package/dist/src/plugins/webpack.js +1 -1
  59. package/dist/transformers.d.ts +16 -1
  60. package/dist/type-mappings.d.ts +32 -16
  61. package/dist/types.d.ts +2 -0
  62. package/package.json +3 -3
  63. package/dist/chunk-0fhq2wva.js +0 -17
  64. package/dist/chunk-1e5c83wa.js +0 -2
  65. package/dist/chunk-1vc477cq.js +0 -2
  66. package/dist/chunk-2w3g3g00.js +0 -19
  67. package/dist/chunk-5fveksya.js +0 -6
  68. package/dist/chunk-6s7n1gt0.js +0 -2
  69. package/dist/chunk-7p1sfeeg.js +0 -2
  70. package/dist/chunk-8dx98fd5.js +0 -75
  71. package/dist/chunk-97pgeywh.js +0 -33
  72. package/dist/chunk-bzsvvb81.js +0 -2
  73. package/dist/chunk-d9my0n30.js +0 -2
  74. package/dist/chunk-efkpkyz9.js +0 -4
  75. package/dist/chunk-f18nyrrb.js +0 -32
  76. package/dist/chunk-gpxdn99a.js +0 -3
  77. package/dist/chunk-j40mkvfg.js +0 -2
  78. package/dist/chunk-kpp6ajgg.js +0 -2
  79. package/dist/chunk-me2ae6f0.js +0 -23
  80. package/dist/chunk-p1d09y82.js +0 -449
  81. package/dist/chunk-qn0xktfx.js +0 -3
  82. package/dist/chunk-r1m3q3dj.js +0 -2
  83. package/dist/chunk-r1ywapeb.js +0 -6
  84. package/dist/chunk-rw6j20e2.js +0 -3
  85. package/dist/chunk-zsznaama.js +0 -2
  86. package/dist/extractor/extract.d.ts +0 -10
  87. package/dist/extractor/scanner.d.ts +0 -6
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![GitHub Actions][github-actions-src]][github-actions-href]
5
- [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
5
+ [![Commitizen friendly][commitizen-src]][commitizen-href]
6
6
  <!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
7
7
  <!-- [![Codecov][codecov-src]][codecov-href] -->
8
8
 
@@ -28,7 +28,7 @@
28
28
  bun install -d @stacksjs/dtsx
29
29
  ```
30
30
 
31
- _@npmjs.com, please allow us to use the `dtsx` package name 🙏_
31
+ > _@npmjs.com, please allow us to use the `dtsx` package name 🙏_
32
32
 
33
33
  <!-- _Alternatively, you can install:_
34
34
 
@@ -116,7 +116,7 @@ _You may also run:_
116
116
  ```bash
117
117
  ./dtsx generate
118
118
 
119
- # if the package is installed, you can also run:
119
+ # if the package is installed, you can also run
120
120
  # bunx dtsx generate
121
121
  ```
122
122
 
@@ -415,6 +415,8 @@ Made with 💙
415
415
  [npm-version-href]: https://npmjs.com/package/@stacksjs/dtsx
416
416
  [github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/dtsx/ci.yml?style=flat-square&branch=main
417
417
  [github-actions-href]: https://github.com/stacksjs/dtsx/actions?query=workflow%3Aci
418
+ [commitizen-src]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
419
+ [commitizen-href]: http://commitizen.github.io/cz-cli/
418
420
 
419
421
  <!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/dtsx/main?style=flat-square
420
422
  [codecov-href]: https://codecov.io/gh/stacksjs/dtsx -->
package/dist/bin/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // @bun
2
- import{cd as Y}from"../chunk-rw6j20e2.js";import V from"process";var f=V.argv[2];if(f==="stdin"||f==="emit"||f==="--project"){if(f==="stdin"){let{processSource:q}=await import("../chunk-7p1sfeeg.js"),Q=[];for await(let N of V.stdin)Q.push(N);let K=Buffer.concat(Q).toString("utf-8");if(K.trim())V.stdout.write(q(K,"stdin.ts")),V.stdout.write(`
3
- `)}else if(f==="--project"){let{readdirSync:q,readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv.slice(3),z="",B="",G=!1;for(let X=0;X<$.length;X++)if($[X]==="--outdir"&&$[X+1])B=$[X+1],X++;else if($[X]==="--isolated-declarations")G=!0;else if(!z)z=$[X];N(B,{recursive:!0});let j=q(z).filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")),Z=j.length,E=Array(Z),M=Array(Z);for(let X=0;X<Z;X++)E[X]=`${z}/${j[X]}`,M[X]=`${B}/${j[X].slice(0,-3)}.d.ts`;let T=["bun"],R=A&&Z>=64,I=!1,_=null;if(R){let X=null;try{let{createWorkerPool:F,calculateOptimalBatchSize:D}=await import("../chunk-r1m3q3dj.js"),{cpus:C}=await import("os"),w=Math.max(1,C().length-1),U=Math.min(64,Math.max(8,D(Z,w)*2)),L=Z>=256,a=!0,l=Z>=256;if(!L&&Z>=256){_=Array(Z);for(let x=0;x<Z;x++)_[x]=J.file(E[x]).text()}let O=Math.ceil(Z/U),u=Math.min(O,Math.max(2,w*2));X=F({maxWorkers:w,initialWorkers:w,recycleAfter:Math.max(100,O+1)}),await X.init();let d=X,i=0,r=Date.now(),t=async()=>{for(;;){let x=i++;if(x>=O)return;let S=x*U;if(S>=Z)return;let g=Math.min(Z,S+U)-S,m;if(l){let P=Array(g),y=Array(g),b;if(L)for(let W=0;W<g;W++){let v=S+W;P[W]=E[v],y[W]=M[v]}else{let W=Array(g);for(let v=0;v<g;v++){let c=S+v;P[v]=E[c],y[v]=M[c],W[v]=_?_[c]:J.file(E[c]).text()}b=await Promise.all(W)}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:P[0]||"",filePaths:P,sources:b,outPaths:y,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}else{let P=Array(g);if(L)for(let y=0;y<g;y++){let b=S+y;P[y]={filePath:E[b],outPath:M[b]}}else{let y=Array(g);for(let W=0;W<g;W++){let v=S+W;y[W]=_?_[v]:J.file(E[v]).text()}let b=await Promise.all(y);for(let W=0;W<g;W++){let v=S+W;P[W]={filePath:E[v],sourceCode:b[W],outPath:M[v]}}}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:E[S]||"",files:P,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}if(!m.success)throw Error(m.error||`Worker batch failed for ${E[S]}`);if(m.batchResults?.length){let P=m.batchResults[0];throw Error(P?.error||m.error||`Worker failed for ${E[S]}`)}}},n=[];for(let x=0;x<u;x++)n.push(t());await Promise.all(n),I=!0}catch{I=!1}finally{if(X)await X.shutdown()}}if(!I){let{scanDeclarations:X}=await import("../chunk-bzsvvb81.js"),{processDeclarations:F}=await import("../chunk-8j312sjx.js"),D=Array(Z);if(A){let U=_?await Promise.all(_):await Promise.all(E.map((L)=>J.file(L).text()));for(let L=0;L<Z;L++)D[L]=U[L]}else for(let U=0;U<Z;U++)D[U]=Q(E[U],"utf-8");let C=Array(Z),w={filePath:"",sourceCode:"",declarations:[]};for(let U=0;U<Z;U++){let L=X(D[U],j[U],!0,G);w.filePath=j[U],w.sourceCode=D[U],w.declarations=L,C[U]=F(L,w,!0,T)}if(A){let U=Array(Z);for(let L=0;L<Z;L++)U[L]=J.write(M[L],C[L]);await Promise.all(U)}else for(let U=0;U<Z;U++)K(M[U],C[U])}}else{let{processSource:q}=await import("../chunk-7p1sfeeg.js"),{readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv[3],z=A?await J.file($).text():Q($,"utf-8"),B=V.argv[4];if(B){let{dirname:G}=await import("path");N(G(B),{recursive:!0});let j=`${q(z,$)}
2
+ import{dd as Y}from"../chunk-mcdb3q06.js";import V from"process";var f=V.argv[2];if(f==="stdin"||f==="emit"||f==="--project"){if(f==="stdin"){let{processSource:q}=await import("../chunk-pt2txw6z.js"),Q=[];for await(let N of V.stdin)Q.push(N);let K=Buffer.concat(Q).toString("utf-8");if(K.trim())V.stdout.write(q(K,"stdin.ts")),V.stdout.write(`
3
+ `)}else if(f==="--project"){let{readdirSync:q,readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv.slice(3),z="",B="",G=!1;for(let X=0;X<$.length;X++)if($[X]==="--outdir"&&$[X+1])B=$[X+1],X++;else if($[X]==="--isolated-declarations")G=!0;else if(!z)z=$[X];N(B,{recursive:!0});let j=q(z).filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")),Z=j.length,E=Array(Z),M=Array(Z);for(let X=0;X<Z;X++)E[X]=`${z}/${j[X]}`,M[X]=`${B}/${j[X].slice(0,-3)}.d.ts`;let T=["bun"],R=A&&Z>=64,I=!1,_=null;if(R){let X=null;try{let{createWorkerPool:F,calculateOptimalBatchSize:D}=await import("../chunk-3xqchdwd.js"),{cpus:C}=await import("os"),w=Math.max(1,C().length-1),U=Math.min(64,Math.max(8,D(Z,w)*2)),L=Z>=256,a=!0,l=Z>=256;if(!L&&Z>=256){_=Array(Z);for(let x=0;x<Z;x++)_[x]=J.file(E[x]).text()}let O=Math.ceil(Z/U),u=Math.min(O,Math.max(2,w*2));X=F({maxWorkers:w,initialWorkers:w,recycleAfter:Math.max(100,O+1)}),await X.init();let d=X,i=0,r=Date.now(),t=async()=>{for(;;){let x=i++;if(x>=O)return;let S=x*U;if(S>=Z)return;let g=Math.min(Z,S+U)-S,m;if(l){let P=Array(g),y=Array(g),b;if(L)for(let W=0;W<g;W++){let v=S+W;P[W]=E[v],y[W]=M[v]}else{let W=Array(g);for(let v=0;v<g;v++){let c=S+v;P[v]=E[c],y[v]=M[c],W[v]=_?_[c]:J.file(E[c]).text()}b=await Promise.all(W)}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:P[0]||"",filePaths:P,sources:b,outPaths:y,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}else{let P=Array(g);if(L)for(let y=0;y<g;y++){let b=S+y;P[y]={filePath:E[b],outPath:M[b]}}else{let y=Array(g);for(let W=0;W<g;W++){let v=S+W;y[W]=_?_[v]:J.file(E[v]).text()}let b=await Promise.all(y);for(let W=0;W<g;W++){let v=S+W;P[W]={filePath:E[v],sourceCode:b[W],outPath:M[v]}}}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:E[S]||"",files:P,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}if(!m.success)throw Error(m.error||`Worker batch failed for ${E[S]}`);if(m.batchResults?.length){let P=m.batchResults[0];throw Error(P?.error||m.error||`Worker failed for ${E[S]}`)}}},n=[];for(let x=0;x<u;x++)n.push(t());await Promise.all(n),I=!0}catch{I=!1}finally{if(X)await X.shutdown()}}if(!I){let{scanDeclarations:X}=await import("../chunk-1bge31tv.js"),{processDeclarations:F}=await import("../chunk-xmje6xfw.js"),D=Array(Z);if(A){let U=_?await Promise.all(_):await Promise.all(E.map((L)=>J.file(L).text()));for(let L=0;L<Z;L++)D[L]=U[L]}else for(let U=0;U<Z;U++)D[U]=Q(E[U],"utf-8");let C=Array(Z),w={filePath:"",sourceCode:"",declarations:[]};for(let U=0;U<Z;U++){let L=X(D[U],j[U],!0,G);w.filePath=j[U],w.sourceCode=D[U],w.declarations=L,C[U]=F(L,w,!0,T)}if(A){let U=Array(Z);for(let L=0;L<Z;L++)U[L]=J.write(M[L],C[L]);await Promise.all(U)}else for(let U=0;U<Z;U++)K(M[U],C[U])}}else{let{processSource:q}=await import("../chunk-pt2txw6z.js"),{readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv[3],z=A?await J.file($).text():Q($,"utf-8"),B=V.argv[4];if(B){let{dirname:G}=await import("path");N(G(B),{recursive:!0});let j=`${q(z,$)}
4
4
  `;if(A)await J.write(B,j);else K(B,j)}else V.stdout.write(q(z,$)),V.stdout.write(`
5
- `)}V.exit(0)}var{resolve:h}=await import("path"),{CLI:s}=await import("../chunk-v96rjx7x.js"),{version:e}=await import("../chunk-d9my0n30.js"),{getConfig:o}=await import("../chunk-6s7n1gt0.js"),{generate:qq,processSource:Hq,watch:Kq}=await import("../chunk-kpp6ajgg.js"),k=new s("dtsx"),H={cwd:V.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};k.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--clean","Clean output directory before generation",{default:H.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:H.tsconfigPath}).option("--verbose","Enable verbose logging",{default:H.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:H.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:H.dryRun}).option("--stats","Show statistics after generation",{default:H.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:H.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:H.outputFormat}).option("--progress","Show progress during generation",{default:H.progress}).option("--diff","Show diff of changes compared to existing files",{default:H.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:H.validate}).option("--parallel","Process files in parallel",{default:H.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:H.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 --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(q)=>{try{let Q=h(q.cwd||H.cwd),K=await o(Q),N={entrypoints:q.entrypoints?q.entrypoints:K.entrypoints||H.entrypoints,cwd:Q,root:h(q.root||K.root||H.root),outdir:h(q.outdir||K.outdir||H.outdir),tsconfigPath:h(q.tsconfigPath||K.tsconfigPath||H.tsconfigPath),keepComments:q.keepComments??K.keepComments??H.keepComments,clean:q.clean??K.clean??H.clean,verbose:q.verbose??K.verbose??H.verbose,importOrder:q.importOrder||K.importOrder||H.importOrder,dryRun:q.dryRun??K.dryRun??H.dryRun,stats:q.stats??K.stats??H.stats,continueOnError:q.continueOnError??K.continueOnError??H.continueOnError,logLevel:q.logLevel??K.logLevel??H.logLevel,exclude:q.exclude?q.exclude.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean)):K.exclude||H.exclude,outputFormat:q.outputFormat??K.outputFormat??H.outputFormat,progress:q.progress??K.progress??H.progress,diff:q.diff??K.diff??H.diff,validate:q.validate??K.validate??H.validate,parallel:q.parallel??K.parallel??H.parallel,concurrency:Number(q.concurrency)||K.concurrency||H.concurrency,declarationMap:q.declarationMap??K.declarationMap??!1,bundle:q.bundle??K.bundle??!1,bundleOutput:q.bundleOutput??K.bundleOutput??"index.d.ts",incremental:q.incremental??K.incremental??!1,clearCache:q.clearCache??!1,indentStyle:q.indentStyle??K.indentStyle??"spaces",indentSize:Number(q.indentSize)||K.indentSize||2,prettier:q.prettier??K.prettier??!1,plugins:K.plugins},A=await qq(N);if(A.filesFailed>0&&A.filesGenerated===0)V.exit(1);else if(A.filesFailed>0)V.exit(2)}catch(Q){console.error("Error generating .d.ts files:",Q),V.exit(1)}});k.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(q)=>{try{let Q={entrypoints:q.entrypoints?q.entrypoints:H.entrypoints,cwd:h(q.cwd||H.cwd),root:h(q.root||H.root),outdir:h(q.outdir||H.outdir),keepComments:q.keepComments??H.keepComments,exclude:q.exclude?q.exclude.flatMap((K)=>K.split(",").map((N)=>N.trim()).filter(Boolean)):H.exclude,logLevel:q.logLevel??H.logLevel};await Kq(Q)}catch(Q){console.error("Error in watch mode:",Q),V.exit(1)}});k.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(q)=>{try{let Q=[];for await(let J of V.stdin)Q.push(J);let K=Buffer.concat(Q).toString("utf-8");if(!K.trim())console.error("Error: No input received from stdin"),V.exit(1);let N=["bun"];if(q.importOrder){if(Array.isArray(q.importOrder))N=q.importOrder.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean));else if(typeof q.importOrder==="string")N=q.importOrder.split(",").map((J)=>J.trim()).filter(Boolean)}let A=Hq(K,"stdin.ts",q.keepComments??!0,N);console.log(A)}catch(Q){console.error("Error processing stdin:",Q),V.exit(1)}});k.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(q)=>{try{let{optimizeFile:Q}=await import("../chunk-1e5c83wa.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N,join:A,relative:J,dirname:$,basename:z}=await import("path"),{mkdirSync:B,copyFileSync:G,existsSync:j}=await import("fs"),Z=V.cwd(),E=q.files||["**/*.d.ts"],M=[];for(let _ of E){let X=new K(_);for await(let F of X.scan({cwd:Z,absolute:!0,onlyFiles:!0}))if(F.endsWith(".d.ts")&&!F.includes("node_modules"))M.push(F)}if(M.length===0)console.error("No .d.ts files found"),V.exit(1);console.log(`Optimizing ${M.length} declaration files...`);let T=0,R=0;for(let _ of M){let X=_;if(q.outdir){let C=J(Z,_);X=A(N(q.outdir),C);let w=$(X);if(!j(w))B(w,{recursive:!0});G(_,X)}let F=await Q(X,{removeUnusedImports:q.removeUnusedImports??!0,deduplicateDeclarations:q.deduplicate??!0,mergeInterfaces:q.mergeInterfaces??!0,inlineSimpleTypes:q.inlineTypes??!1,removeEmptyInterfaces:q.removeEmpty??!0,sortDeclarations:q.sort??!1,sortImports:q.sortImports??!0,minify:q.minify??!1,removeComments:q.removeComments??!1});R+=F.originalSize,T+=F.savings;let D=J(Z,X);console.log(` ${D}: ${F.originalSize}B -> ${F.optimizedSize}B (-${F.savingsPercent}%)`)}let I=R>0?Math.round(T/R*100):0;console.log(`
6
- Total: ${R}B -> ${R-T}B (-${I}%)`)}catch(Q){console.error("Error optimizing files:",Q),V.exit(1)}});k.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(q)=>{try{let{generateDocs:Q}=await import("../chunk-j40mkvfg.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N}=await import("path"),A=N(q.root||"./src"),J=new K("**/*.ts"),$=[];for await(let z of J.scan({cwd:A,absolute:!0,onlyFiles:!0}))if(!z.endsWith(".d.ts")&&!z.includes("node_modules"))$.push(z);if($.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Found ${$.length} source files`),await Q($,{format:q.format||"markdown",outdir:N(q.outdir||"./docs"),title:q.title||"API Documentation",includePrivate:q.includePrivate??!1,includeInternal:q.includeInternal??!1,groupByCategory:q.groupByCategory??!1,includeSourceLinks:!!q.sourceUrl,sourceBaseUrl:q.sourceUrl})}catch(Q){console.error("Error generating documentation:",Q),V.exit(1)}});k.command("workspace","Generate declarations for all projects in a monorepo/workspace").option("--cwd <path>","Workspace root directory",{default:V.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(q)=>{try{let{generateMonorepo:Q,generateFromPackageWorkspaces:K}=await import("../chunk-zsznaama.js"),{existsSync:N}=await import("fs"),{join:A,resolve:J}=await import("path"),$=J(q.cwd||V.cwd()),z=A($,"tsconfig.json"),B;if(N(z))B=await Q($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});else B=await K($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});if(!B.success)V.exit(1)}catch(Q){console.error("Error generating workspace declarations:",Q),V.exit(1)}});k.command("lsp","Start the Language Server Protocol server for IDE integration").example("dtsx lsp").action(async()=>{let{startLSPServer:q}=await import("../chunk-1vc477cq.js");q()});k.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(q)=>{try{let{typeCheck:Q,checkIsolatedDeclarations:K,formatTypeCheckResults:N}=await import("../chunk-7cpp6v8f.js"),{Glob:A}=awaitPromise.resolve(globalThis.Bun),{resolve:J,relative:$}=await import("path"),z=V.cwd(),B=q.files||["**/*.ts"],G=[];for(let Z of B){let E=new A(Z);for await(let M of E.scan({cwd:z,absolute:!0,onlyFiles:!0}))if(!M.includes("node_modules"))if(q.declarationsOnly){if(M.endsWith(".d.ts"))G.push(M)}else G.push(M)}if(G.length===0)console.error("No files found to check"),V.exit(1);if(q.isolatedDeclarations){console.log(`Checking ${G.length} files for isolated declarations best practices...`);let Z=await K(G,q.tsconfig?J(q.tsconfig):void 0),E=0,M=[];for(let[T,R]of Z){let I=$(z,T);if(!R.compatible)if(E+=R.issues.length,q.format==="json")M.push({file:I,compatible:!1,issues:R.issues});else{console.log(`
5
+ `)}V.exit(0)}var{resolve:h}=await import("path"),{CLI:s}=await import("../chunk-trm0gptj.js"),{version:e}=await import("../chunk-dk914hsr.js"),{getConfig:o}=await import("../chunk-ayvw3402.js"),{generate:qq,processSource:Hq,watch:Kq}=await import("../chunk-cbz06k9p.js"),k=new s("dtsx"),H={cwd:V.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};k.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--clean","Clean output directory before generation",{default:H.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:H.tsconfigPath}).option("--verbose","Enable verbose logging",{default:H.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:H.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:H.dryRun}).option("--stats","Show statistics after generation",{default:H.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:H.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:H.outputFormat}).option("--progress","Show progress during generation",{default:H.progress}).option("--diff","Show diff of changes compared to existing files",{default:H.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:H.validate}).option("--parallel","Process files in parallel",{default:H.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:H.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 --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(q)=>{try{let Q=h(q.cwd||H.cwd),K=await o(Q),N={entrypoints:q.entrypoints?q.entrypoints:K.entrypoints||H.entrypoints,cwd:Q,root:h(q.root||K.root||H.root),outdir:h(q.outdir||K.outdir||H.outdir),tsconfigPath:h(q.tsconfigPath||K.tsconfigPath||H.tsconfigPath),keepComments:q.keepComments??K.keepComments??H.keepComments,clean:q.clean??K.clean??H.clean,verbose:q.verbose??K.verbose??H.verbose,importOrder:q.importOrder||K.importOrder||H.importOrder,dryRun:q.dryRun??K.dryRun??H.dryRun,stats:q.stats??K.stats??H.stats,continueOnError:q.continueOnError??K.continueOnError??H.continueOnError,logLevel:q.logLevel??K.logLevel??H.logLevel,exclude:q.exclude?q.exclude.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean)):K.exclude||H.exclude,outputFormat:q.outputFormat??K.outputFormat??H.outputFormat,progress:q.progress??K.progress??H.progress,diff:q.diff??K.diff??H.diff,validate:q.validate??K.validate??H.validate,parallel:q.parallel??K.parallel??H.parallel,concurrency:Number(q.concurrency)||K.concurrency||H.concurrency,declarationMap:q.declarationMap??K.declarationMap??!1,bundle:q.bundle??K.bundle??!1,bundleOutput:q.bundleOutput??K.bundleOutput??"index.d.ts",incremental:q.incremental??K.incremental??!1,clearCache:q.clearCache??!1,indentStyle:q.indentStyle??K.indentStyle??"spaces",indentSize:Number(q.indentSize)||K.indentSize||2,prettier:q.prettier??K.prettier??!1,plugins:K.plugins},A=await qq(N);if(A.filesFailed>0&&A.filesGenerated===0)V.exit(1);else if(A.filesFailed>0)V.exit(2)}catch(Q){console.error("Error generating .d.ts files:",Q),V.exit(1)}});k.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(q)=>{try{let Q={entrypoints:q.entrypoints?q.entrypoints:H.entrypoints,cwd:h(q.cwd||H.cwd),root:h(q.root||H.root),outdir:h(q.outdir||H.outdir),keepComments:q.keepComments??H.keepComments,exclude:q.exclude?q.exclude.flatMap((K)=>K.split(",").map((N)=>N.trim()).filter(Boolean)):H.exclude,logLevel:q.logLevel??H.logLevel};await Kq(Q)}catch(Q){console.error("Error in watch mode:",Q),V.exit(1)}});k.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(q)=>{try{let Q=[];for await(let J of V.stdin)Q.push(J);let K=Buffer.concat(Q).toString("utf-8");if(!K.trim())console.error("Error: No input received from stdin"),V.exit(1);let N=["bun"];if(q.importOrder){if(Array.isArray(q.importOrder))N=q.importOrder.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean));else if(typeof q.importOrder==="string")N=q.importOrder.split(",").map((J)=>J.trim()).filter(Boolean)}let A=Hq(K,"stdin.ts",q.keepComments??!0,N);console.log(A)}catch(Q){console.error("Error processing stdin:",Q),V.exit(1)}});k.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(q)=>{try{let{optimizeFile:Q}=await import("../chunk-27nzyfdd.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N,join:A,relative:J,dirname:$,basename:z}=await import("path"),{mkdirSync:B,copyFileSync:G,existsSync:j}=await import("fs"),Z=V.cwd(),E=q.files||["**/*.d.ts"],M=[];for(let _ of E){let X=new K(_);for await(let F of X.scan({cwd:Z,absolute:!0,onlyFiles:!0}))if(F.endsWith(".d.ts")&&!F.includes("node_modules"))M.push(F)}if(M.length===0)console.error("No .d.ts files found"),V.exit(1);console.log(`Optimizing ${M.length} declaration files...`);let T=0,R=0;for(let _ of M){let X=_;if(q.outdir){let C=J(Z,_);X=A(N(q.outdir),C);let w=$(X);if(!j(w))B(w,{recursive:!0});G(_,X)}let F=await Q(X,{removeUnusedImports:q.removeUnusedImports??!0,deduplicateDeclarations:q.deduplicate??!0,mergeInterfaces:q.mergeInterfaces??!0,inlineSimpleTypes:q.inlineTypes??!1,removeEmptyInterfaces:q.removeEmpty??!0,sortDeclarations:q.sort??!1,sortImports:q.sortImports??!0,minify:q.minify??!1,removeComments:q.removeComments??!1});R+=F.originalSize,T+=F.savings;let D=J(Z,X);console.log(` ${D}: ${F.originalSize}B -> ${F.optimizedSize}B (-${F.savingsPercent}%)`)}let I=R>0?Math.round(T/R*100):0;console.log(`
6
+ Total: ${R}B -> ${R-T}B (-${I}%)`)}catch(Q){console.error("Error optimizing files:",Q),V.exit(1)}});k.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(q)=>{try{let{generateDocs:Q}=await import("../chunk-8kz02py2.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N}=await import("path"),A=N(q.root||"./src"),J=new K("**/*.ts"),$=[];for await(let z of J.scan({cwd:A,absolute:!0,onlyFiles:!0}))if(!z.endsWith(".d.ts")&&!z.includes("node_modules"))$.push(z);if($.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Found ${$.length} source files`),await Q($,{format:q.format||"markdown",outdir:N(q.outdir||"./docs"),title:q.title||"API Documentation",includePrivate:q.includePrivate??!1,includeInternal:q.includeInternal??!1,groupByCategory:q.groupByCategory??!1,includeSourceLinks:!!q.sourceUrl,sourceBaseUrl:q.sourceUrl})}catch(Q){console.error("Error generating documentation:",Q),V.exit(1)}});k.command("workspace","Generate declarations for all projects in a monorepo/workspace").option("--cwd <path>","Workspace root directory",{default:V.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(q)=>{try{let{generateMonorepo:Q,generateFromPackageWorkspaces:K}=await import("../chunk-j1zrbs2z.js"),{existsSync:N}=await import("fs"),{join:A,resolve:J}=await import("path"),$=J(q.cwd||V.cwd()),z=A($,"tsconfig.json"),B;if(N(z))B=await Q($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});else B=await K($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});if(!B.success)V.exit(1)}catch(Q){console.error("Error generating workspace declarations:",Q),V.exit(1)}});k.command("lsp","Start the Language Server Protocol server for IDE integration").example("dtsx lsp").action(async()=>{let{startLSPServer:q}=await import("../chunk-7tyhhk7c.js");q()});k.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(q)=>{try{let{typeCheck:Q,checkIsolatedDeclarations:K,formatTypeCheckResults:N}=await import("../chunk-sw3m29sw.js"),{Glob:A}=awaitPromise.resolve(globalThis.Bun),{resolve:J,relative:$}=await import("path"),z=V.cwd(),B=q.files||["**/*.ts"],G=[];for(let Z of B){let E=new A(Z);for await(let M of E.scan({cwd:z,absolute:!0,onlyFiles:!0}))if(!M.includes("node_modules"))if(q.declarationsOnly){if(M.endsWith(".d.ts"))G.push(M)}else G.push(M)}if(G.length===0)console.error("No files found to check"),V.exit(1);if(q.isolatedDeclarations){console.log(`Checking ${G.length} files for isolated declarations best practices...`);let Z=await K(G,q.tsconfig?J(q.tsconfig):void 0),E=0,M=[];for(let[T,R]of Z){let I=$(z,T);if(!R.compatible)if(E+=R.issues.length,q.format==="json")M.push({file:I,compatible:!1,issues:R.issues});else{console.log(`
7
7
  \u2717 ${I}`);for(let _ of R.issues)if(console.log(` ${_.line}:${_.column} - ${_.message}`),_.missingAnnotation)console.log(` Missing: ${_.missingAnnotation} type annotation`)}else if(q.format==="json")M.push({file:I,compatible:!0,issues:[]})}if(q.format==="json")console.log(JSON.stringify(M,null,2));else if(E>0)console.log(`
8
8
  ${G.length} files checked, ${E} recommendations found`),console.log("Tip: Adding explicit type annotations improves .d.ts accuracy");else console.log(`
9
- ${G.length} files checked, all follow isolated declarations best practices`);V.exit(E>0?1:0)}console.log(`Type checking ${G.length} files...`);let j=await Q(G,{tsconfigPath:q.tsconfig?J(q.tsconfig):void 0,strict:q.strict??!1,declarationsOnly:q.declarationsOnly??!1,skipLibCheck:q.skipLibCheck??!0,warningsAsErrors:q.warningsAsErrors??!1,maxErrors:q.maxErrors||void 0});if(q.format==="json")console.log(JSON.stringify(j,null,2));else console.log(N(j));V.exit(j.success?0:1)}catch(Q){console.error("Error during type checking:",Q),V.exit(1)}});k.command("convert","Convert TypeScript types to different schema formats").option("--files <patterns>","Glob patterns for TypeScript files",{default:"**/*.ts",type:[String]}).option("--format <format>","Output format: json-schema, zod, valibot, io-ts, yup, arktype",{default:"json-schema"}).option("--outdir <path>","Output directory for converted files",{default:"./schemas"}).option("--include-descriptions","Include JSDoc descriptions in output",{default:!0}).option("--all-optional","Make all properties optional",{default:!1}).option("--use-infer","Include inferred types (for Zod, Valibot, etc.)",{default:!0}).option("--json-schema-draft <version>","JSON Schema draft version: 2020-12, 2019-09, draft-07",{default:"2020-12"}).example("dtsx convert --format zod").example('dtsx convert --format json-schema --files "src/types/**/*.ts"').example("dtsx convert --format valibot --outdir ./validation").action(async(q)=>{try{let Q=await import("../chunk-3g2v2ns2.js"),{extractDeclarations:K}=await import("../chunk-kge8a5vc.js"),{Glob:N}=awaitPromise.resolve(globalThis.Bun),{resolve:A,relative:J,join:$,dirname:z,basename:B}=await import("path"),{mkdirSync:G,existsSync:j,readFileSync:Z,writeFileSync:E}=await import("fs"),M=V.cwd(),T=q.files||["**/*.ts"],R=q.format||"json-schema",I=A(q.outdir||"./schemas"),_=[];for(let D of T){let C=new N(D);for await(let w of C.scan({cwd:M,absolute:!0,onlyFiles:!0}))if(!w.endsWith(".d.ts")&&!w.includes("node_modules"))_.push(w)}if(_.length===0)console.error("No TypeScript files found"),V.exit(1);if(console.log(`Converting ${_.length} files to ${R} format...`),!j(I))G(I,{recursive:!0});let X=0,F=0;for(let D of _){let C=Z(D,"utf-8"),U=K(C,D).filter((d)=>d.kind==="interface"||d.kind==="type");if(U.length===0)continue;let L=Q.convertToFormat(U,{format:R,includeDescriptions:q.includeDescriptions??!0,allOptional:q.allOptional??!1,useInfer:q.useInfer??!0,jsonSchemaDraft:q.jsonSchemaDraft||"2020-12"}),a=J(M,D),l=B(D,".ts"),p=Q.getFormatExtension(R),O=$(I,z(a),`${l}${p}`),u=z(O);if(!j(u))G(u,{recursive:!0});E(O,L),X+=U.length,F++,console.log(` ${J(M,O)} (${U.length} types)`)}console.log(`
10
- Converted ${X} declarations from ${F} files`)}catch(Q){console.error("Error converting files:",Q),V.exit(1)}});k.command("circular","Detect circular dependencies in TypeScript files").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--root <path>","Root directory for resolution",{default:"."}).option("--ignore <patterns>","Glob patterns to ignore (comma-separated)",{default:"",type:[String]}).option("--types-only","Only report type-level cycles",{default:!1}).option("--max-depth <number>","Maximum depth for cycle detection",{default:100}).option("--include-node-modules","Include node_modules in analysis",{default:!1}).option("--format <format>","Output format: text, json, dot",{default:"text"}).option("--summary","Show graph summary statistics",{default:!1}).example("dtsx circular").example('dtsx circular --files "src/**/*.ts"').example('dtsx circular --ignore "**/*.test.ts,**/__tests__/**"').example("dtsx circular --format dot > deps.dot").example("dtsx circular --summary").action(async(q)=>{try{let{analyzeCircularDependencies:Q,formatCircularAnalysis:K,getGraphSummary:N,exportGraphAsDot:A,exportGraphAsJson:J}=await import("../chunk-3j7r0fxz.js"),{Glob:$}=awaitPromise.resolve(globalThis.Bun),{resolve:z,relative:B}=await import("path"),G=V.cwd(),j=z(q.root||"."),Z=q.files||["**/*.ts"],E=[];for(let T of Z){let R=new $(T);for await(let I of R.scan({cwd:j,absolute:!0,onlyFiles:!0}))if(!I.endsWith(".d.ts")){if(!q.includeNodeModules&&I.includes("node_modules"))continue;E.push(I)}}if(E.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Analyzing ${E.length} files for circular dependencies...`);let M=await Q(E,{rootDir:j,ignore:q.ignore?.filter(Boolean),typesOnly:q.typesOnly??!1,maxDepth:q.maxDepth??100,includeNodeModules:q.includeNodeModules??!1});if(q.format==="json")console.log(J(M.graph,j));else if(q.format==="dot")console.log(A(M.graph,j));else if(console.log(K(M,j)),q.summary){let T=N(M.graph);if(console.log(`
9
+ ${G.length} files checked, all follow isolated declarations best practices`);V.exit(E>0?1:0)}console.log(`Type checking ${G.length} files...`);let j=await Q(G,{tsconfigPath:q.tsconfig?J(q.tsconfig):void 0,strict:q.strict??!1,declarationsOnly:q.declarationsOnly??!1,skipLibCheck:q.skipLibCheck??!0,warningsAsErrors:q.warningsAsErrors??!1,maxErrors:q.maxErrors||void 0});if(q.format==="json")console.log(JSON.stringify(j,null,2));else console.log(N(j));V.exit(j.success?0:1)}catch(Q){console.error("Error during type checking:",Q),V.exit(1)}});k.command("convert","Convert TypeScript types to different schema formats").option("--files <patterns>","Glob patterns for TypeScript files",{default:"**/*.ts",type:[String]}).option("--format <format>","Output format: json-schema, zod, valibot, io-ts, yup, arktype",{default:"json-schema"}).option("--outdir <path>","Output directory for converted files",{default:"./schemas"}).option("--include-descriptions","Include JSDoc descriptions in output",{default:!0}).option("--all-optional","Make all properties optional",{default:!1}).option("--use-infer","Include inferred types (for Zod, Valibot, etc.)",{default:!0}).option("--json-schema-draft <version>","JSON Schema draft version: 2020-12, 2019-09, draft-07",{default:"2020-12"}).example("dtsx convert --format zod").example('dtsx convert --format json-schema --files "src/types/**/*.ts"').example("dtsx convert --format valibot --outdir ./validation").action(async(q)=>{try{let Q=await import("../chunk-xtee8g1a.js"),{extractDeclarations:K}=await import("../chunk-p50ms07x.js"),{Glob:N}=awaitPromise.resolve(globalThis.Bun),{resolve:A,relative:J,join:$,dirname:z,basename:B}=await import("path"),{mkdirSync:G,existsSync:j,readFileSync:Z,writeFileSync:E}=await import("fs"),M=V.cwd(),T=q.files||["**/*.ts"],R=q.format||"json-schema",I=A(q.outdir||"./schemas"),_=[];for(let D of T){let C=new N(D);for await(let w of C.scan({cwd:M,absolute:!0,onlyFiles:!0}))if(!w.endsWith(".d.ts")&&!w.includes("node_modules"))_.push(w)}if(_.length===0)console.error("No TypeScript files found"),V.exit(1);if(console.log(`Converting ${_.length} files to ${R} format...`),!j(I))G(I,{recursive:!0});let X=0,F=0;for(let D of _){let C=Z(D,"utf-8"),U=K(C,D).filter((d)=>d.kind==="interface"||d.kind==="type");if(U.length===0)continue;let L=Q.convertToFormat(U,{format:R,includeDescriptions:q.includeDescriptions??!0,allOptional:q.allOptional??!1,useInfer:q.useInfer??!0,jsonSchemaDraft:q.jsonSchemaDraft||"2020-12"}),a=J(M,D),l=B(D,".ts"),p=Q.getFormatExtension(R),O=$(I,z(a),`${l}${p}`),u=z(O);if(!j(u))G(u,{recursive:!0});E(O,L),X+=U.length,F++,console.log(` ${J(M,O)} (${U.length} types)`)}console.log(`
10
+ Converted ${X} declarations from ${F} files`)}catch(Q){console.error("Error converting files:",Q),V.exit(1)}});k.command("circular","Detect circular dependencies in TypeScript files").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--root <path>","Root directory for resolution",{default:"."}).option("--ignore <patterns>","Glob patterns to ignore (comma-separated)",{default:"",type:[String]}).option("--types-only","Only report type-level cycles",{default:!1}).option("--max-depth <number>","Maximum depth for cycle detection",{default:100}).option("--include-node-modules","Include node_modules in analysis",{default:!1}).option("--format <format>","Output format: text, json, dot",{default:"text"}).option("--summary","Show graph summary statistics",{default:!1}).example("dtsx circular").example('dtsx circular --files "src/**/*.ts"').example('dtsx circular --ignore "**/*.test.ts,**/__tests__/**"').example("dtsx circular --format dot > deps.dot").example("dtsx circular --summary").action(async(q)=>{try{let{analyzeCircularDependencies:Q,formatCircularAnalysis:K,getGraphSummary:N,exportGraphAsDot:A,exportGraphAsJson:J}=await import("../chunk-tne5n3h1.js"),{Glob:$}=awaitPromise.resolve(globalThis.Bun),{resolve:z,relative:B}=await import("path"),G=V.cwd(),j=z(q.root||"."),Z=q.files||["**/*.ts"],E=[];for(let T of Z){let R=new $(T);for await(let I of R.scan({cwd:j,absolute:!0,onlyFiles:!0}))if(!I.endsWith(".d.ts")){if(!q.includeNodeModules&&I.includes("node_modules"))continue;E.push(I)}}if(E.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Analyzing ${E.length} files for circular dependencies...`);let M=await Q(E,{rootDir:j,ignore:q.ignore?.filter(Boolean),typesOnly:q.typesOnly??!1,maxDepth:q.maxDepth??100,includeNodeModules:q.includeNodeModules??!1});if(q.format==="json")console.log(J(M.graph,j));else if(q.format==="dot")console.log(A(M.graph,j));else if(console.log(K(M,j)),q.summary){let T=N(M.graph);if(console.log(`
11
11
  --- Dependency Graph Summary ---`),console.log(`Total files: ${T.totalFiles}`),console.log(`Total dependencies: ${T.totalDependencies}`),console.log(`Average dependencies per file: ${T.avgDependencies.toFixed(2)}`),T.maxDependencies.count>0)console.log(`Most dependencies: ${B(j,T.maxDependencies.file)} (${T.maxDependencies.count})`);if(T.mostDepended.count>0)console.log(`Most depended on: ${B(j,T.mostDepended.file)} (${T.mostDepended.count} dependents)`);if(T.isolatedFiles.length>0)console.log(`Isolated files (no dependencies): ${T.isolatedFiles.length}`)}V.exit(M.hasCircular?1:0)}catch(Q){console.error("Error analyzing dependencies:",Q),V.exit(1)}});k.command("version","Show the version of dtsx").action(()=>{console.log(e)});k.version(e);k.help();k.parse();
@@ -52,44 +52,36 @@ export declare function isBranded<T, B extends string>(value: unknown, _brand: B
52
52
  */
53
53
  export declare function unwrap<T>(branded: Brand<T, string>): T;
54
54
  /**
55
- * Safe path operations that preserve branding
56
- * @defaultValue
57
- * ```ts
58
- * {
59
- * join: (base: DirectoryPath, ...segments: string[]) => unknown,
60
- * dirname: (path: FilePath) => unknown,
61
- * basename: (path: FilePath) => unknown,
62
- * resolve: (...segments: string[]) => unknown,
63
- * isAbsolute: (path: string) => unknown,
64
- * relative: (from: DirectoryPath, to: FilePath) => unknown
65
- * }
66
- * ```
55
+ * Safe path operations that preserve branding.
56
+ * Uses ESM imports hoisted to module scope so each call avoids the per-call
57
+ * `require('node:path')` overhead that the previous CommonJS-style implementation
58
+ * incurred.
67
59
  */
68
60
  export declare const BrandedPath: {
69
61
  /**
70
62
  * Join path segments, returning appropriate branded type
71
63
  */
72
- join: (base: DirectoryPath, ...segments: string[]) => unknown;
64
+ join: (base: DirectoryPath, ...segments: string[]) => FilePath;
73
65
  /**
74
66
  * Get directory name from a file path
75
67
  */
76
- dirname: (path: FilePath) => unknown;
68
+ dirname: (path: FilePath) => DirectoryPath;
77
69
  /**
78
70
  * Get base name from a file path
79
71
  */
80
- basename: (path: FilePath) => unknown;
72
+ basename: (path: FilePath) => string;
81
73
  /**
82
74
  * Resolve path to absolute
83
75
  */
84
- resolve: (...segments: string[]) => unknown;
76
+ resolve: (...segments: string[]) => AbsolutePath;
85
77
  /**
86
78
  * Check if path is absolute
87
79
  */
88
- isAbsolute: (path: string) => unknown;
80
+ isAbsolute: (path: string) => path is AbsolutePath;
89
81
  /**
90
82
  * Get relative path from one path to another
91
83
  */
92
- relative: (from: DirectoryPath, to: FilePath) => unknown
84
+ relative: (from: DirectoryPath, to: FilePath) => RelativePath
93
85
  };
94
86
  /**
95
87
  * Generic branded type creator
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{oc as a}from"./chunk-d1xj2pjv.js";import"./chunk-mcdb3q06.js";export{a as scanDeclarations};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{a,b,c}from"./chunk-wzq881r8.js";import"./chunk-thhd43x5.js";import"./chunk-2n1bbm2c.js";import"./chunk-rsv17jh8.js";import"./chunk-d1xj2pjv.js";import"./chunk-285mqzvx.js";import"./chunk-mcdb3q06.js";export{b as optimizeFile,a as optimizeDeclarations,c as minifyDts};
@@ -0,0 +1,16 @@
1
+ // @bun
2
+ var E=!1,M=null;function h(J){if(J.indexOf("/*")===-1)return J.trim();let X=[],$=0,z=0,B=J.length;while(z<B)if(J.charCodeAt(z)===47&&z+1<B&&J.charCodeAt(z+1)===42){if(z>$)X.push(J.substring($,z));z+=2;while(z<B-1){if(J.charCodeAt(z)===42&&J.charCodeAt(z+1)===47){z+=2;break}z++}$=z}else z++;if($<B)X.push(J.substring($));return X.join("").trim()}function $z(){E=!0,M=null}function Qz(){E=!1;let J=M;return M=null,J}function S(J){let Y=J.length;if(Y===0)return!1;let X=0;if(J.charCodeAt(X)===45)X++;if(X>=Y)return!1;let $=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===$)return!1;if(X<Y&&J.charCodeAt(X)===46){X++;let z=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===z)return!1}return X===Y}function o(J){for(let Y=0,X=J.length-1;Y<X;Y++){let $=J.charCodeAt(Y);if($<48||$>57)return!1}return!0}function D(J,Y){let X=0,$=0;while(($=J.indexOf(Y,$))!==-1)X++,$+=Y.length;return X}function _(J){let Y=J.length,X=!1;for(let Z=1;Z<Y;Z++)if(J.charCodeAt(Z)<=32&&J.charCodeAt(Z-1)<=32){X=!0;break}if(!X)for(let Z=0;Z<Y;Z++){let H=J.charCodeAt(Z);if(H===10||H===13||H===9){X=!0;break}}if(!X)return J;let $=[],z=-1,B=!1;for(let Z=0;Z<Y;Z++)if(J.charCodeAt(Z)<=32){if(!B){if(z>=0)$.push(J.substring(z,Z));$.push(" "),B=!0,z=-1}}else{if(B||z<0)z=Z;B=!1}if(z>=0)$.push(J.substring(z));return $.join("")}function V(J,Y=!1,X=!1,$=0){if(!J||typeof J!=="string")return"unknown";if($>=20)return"unknown";let z=J.trim();if(z.startsWith("BigInt("))return"bigint";if(z.startsWith("Symbol.for("))return"symbol";if(z.includes(".raw`")||z.includes("String.raw`"))return"string";if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'")||z.startsWith("`")&&z.endsWith("`")){if(!z.includes("${")){if(!Y)return"string";return z}if(Y)return z;return"string"}if(S(z)){if(!Y)return"number";return z}if(z==="true"||z==="false"){if(!Y)return"boolean";return z}if(z==="null")return"null";if(z==="undefined")return"undefined";if(z.startsWith("[")&&z.endsWith("]"))return I(z,Y,$+1);if(z.startsWith("{")&&z.endsWith("}"))return s(z,Y,$+1);if(z.startsWith("class ")||z.startsWith("class{"))return c(z);if(z.startsWith("new "))return d(z);if(z.includes("=>")||z.startsWith("function")||z.startsWith("async"))return y(z,X,$,Y);if(z.endsWith("as const")){let B=z.slice(0,-8).trim();if(B.startsWith("[")&&B.endsWith("]")){let Z=B.slice(1,-1).trim();if(!Z)return"readonly []";let H=w(Z),Q=[];for(let L=0;L<H.length;L++)Q.push(V(H[L].trim(),!0,!1,$+1));return`readonly [${Q.join(", ")}]`}return V(B,!0,X,$+1)}if(z.startsWith("`")&&z.endsWith("`"))return p(z,Y);if(z.startsWith("Promise."))return f(z,Y,$);if(z.startsWith("await "))return"unknown";if(z.charCodeAt(z.length-1)===110&&z.length>1&&o(z)){if(Y)return z;return"bigint"}if(z.startsWith("Symbol(")||z==="Symbol.for")return"symbol";return"unknown"}function l(J,Y=!1,X=0){return V(J,Y,!0,X)}function p(J,Y){if(J.includes(".raw`")||J.includes("String.raw`"))return"string";if(!Y)return"string";if(!J.includes("${"))return J;return"string"}function d(J){let Y=4;while(Y<J.length&&J.charCodeAt(Y)<=32)Y++;let X=Y,$=J.charCodeAt(Y);if($<65||$>90)return"unknown";while(Y<J.length&&(P(J.charCodeAt(Y))||J.charCodeAt(Y)===46))Y++;if(Y===X)return"unknown";let z=J.slice(X,Y);{let B=J.slice(Y),Z=B;if(B.startsWith("<")){let Q=0,L=-1;for(let O=0;O<B.length;O++)if(B[O]==="<")Q++;else if(B[O]===">"){if(Q--,Q===0){L=O;break}}if(L!==-1){let O=B.slice(0,L+1);Z=B.slice(L+1);let G=Z.indexOf("(");if(G!==-1){let W=0,K=-1;for(let F=G;F<Z.length;F++)if(Z[F]==="(")W++;else if(Z[F]===")"){if(W--,W===0){K=F;break}}if(K!==-1){if(Z.slice(K+1).trimStart().startsWith("."))return"unknown"}}return`${z}${O}`}}let H=Z.indexOf("(");if(H!==-1){let Q=0,L=-1;for(let O=H;O<Z.length;O++)if(Z[O]==="(")Q++;else if(Z[O]===")"){if(Q--,Q===0){L=O;break}}if(L!==-1){if(Z.slice(L+1).trimStart().startsWith("."))return"unknown"}}switch(z){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return z}}return"unknown"}function c(J){let Y=J.trimStart(),X=5;while(X<Y.length&&Y.charCodeAt(X)<=32)X++;let $=X;if(X<Y.length&&P(Y.charCodeAt(X))){while(X<Y.length&&P(Y.charCodeAt(X)))X++;return`typeof ${Y.slice($,X)}`}return"{ new (...args: any[]): any }"}function f(J,Y,X=0){if(J.startsWith("Promise.resolve(")){let z=J.indexOf(")",16);if(z!==-1){let B=J.slice(16,z).trim();if(B)return`Promise<${V(B,Y,!1,X+1)}>`}return"Promise<unknown>"}if(J.startsWith("Promise.reject("))return"Promise<never>";if(J.startsWith("Promise.all(")){let $=J.indexOf("[",12),z=J.lastIndexOf("]");if($!==-1&&z>$){let B=J.slice($+1,z).trim(),Z=w(B),H=[];for(let Q=0;Q<Z.length;Q++){let L=Z[Q].trim();if(L.startsWith("Promise.resolve(")){let O=f(L,Y,X+1),G=O.indexOf("<"),W=O.lastIndexOf(">");H.push(G!==-1&&W>G?O.slice(G+1,W):"unknown")}else H.push(V(L,Y,!1,X+1))}return`Promise<[${H.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function I(J,Y,X=0){let $=J.slice(1,-1).trim();if(!$)return"never[]";if(X>=20)return"unknown[]";let z=w($),B=!1;for(let W=0;W<z.length;W++){let K=z[W],F=K.length;while(F>0&&K.charCodeAt(F-1)<=32)F--;if(F>=8&&K.slice(F-8,F)==="as const"){B=!0;break}}if(B){let W=[];for(let K=0;K<z.length;K++){let F=z[K].trim();if(F.endsWith("as const")){let q=F.slice(0,-8).trim();if(q.startsWith("[")&&q.endsWith("]")){let N=q.slice(1,-1).trim(),U=w(N),R=[];for(let b=0;b<U.length;b++)R.push(V(U[b].trim(),!0,!1,X+1));W.push(`readonly [${R.join(", ")}]`)}else W.push(V(q,!0,!1,X+1))}else if(F.startsWith("[")&&F.endsWith("]"))W.push(I(F,!0,X+1));else W.push(V(F,!0,!1,X+1))}return`readonly [
3
+ ${W.join(` |
4
+ `)}
5
+ ]`}let Z=E&&!Y,H=[],Q=[];for(let W of z){let K=W.trim(),F=M;if(M=null,K.startsWith("[")&&K.endsWith("]"))H.push(I(K,Y,X+1));else H.push(l(K,Y,X+1));if(Z)Q.push(M);M=F}if(Z)if(g(J))M=_(J);else{let W=[];for(let K=0;K<z.length;K++){let F=z[K].trim();if(F.endsWith("as const"))continue;if(x(F)||F==="null"||F==="undefined")W.push(F);else if(F.startsWith("[")&&g(F))W.push(_(F));else if(F.startsWith("{")){if(Q[K])W.push(Q[K])}else{let q=V(F,!1,!1,0);if(q!=="unknown")W.push(q)}}if(W.length>0)M=`[${W.join(", ")}]`}if(Y)return`readonly [${H.join(", ")}]`;let L=new Set,O=[],G=!0;for(let W of H){if(!L.has(W))L.add(W),O.push(W);if(G){if(!(S(W)||W==="true"||W==="false"||W.charCodeAt(0)===34&&W.charCodeAt(W.length-1)===34||W.charCodeAt(0)===39&&W.charCodeAt(W.length-1)===39))G=!1}}if(G&&H.length<=10)return`readonly [${H.join(", ")}]`;if(O.length===1)return`${O[0]}[]`;return`(${O.join(" | ")})[]`}function w(J){let Y=[],X=0,$=0,z=!1,B=0;for(let H=0;H<J.length;H++){let Q=J.charCodeAt(H);if(!z&&(Q===34||Q===39||Q===96))z=!0,B=Q;else if(z&&Q===B&&(H===0||J.charCodeAt(H-1)!==92))z=!1;if(!z){if(Q===91||Q===123||Q===40)$++;else if(Q===93||Q===125||Q===41)$--;else if(Q===44&&$===0){let L=J.substring(X,H).trim();if(L)Y.push(L);X=H+1;continue}}}let Z=J.substring(X).trim();if(Z)Y.push(Z);return Y}function x(J){if(S(J))return!0;if(J==="true"||J==="false")return!0;if(J.startsWith('"')&&J.endsWith('"')||J.startsWith("'")&&J.endsWith("'"))return!0;return!1}function m(J){return J==="number"||J==="string"||J==="boolean"}function g(J){let Y=!1,X=0,$=J.length;for(let z=0;z<$;z++){let B=J.charCodeAt(z);if(Y){if(B===92){z++;continue}if(B===X)Y=!1;continue}if(B===34||B===39||B===96){Y=!0,X=B;continue}if(B===61&&z+1<$&&J.charCodeAt(z+1)===62)return!1;if(B>=97&&B<=122){let Z=z;while(z<$&&(J.charCodeAt(z)>=97&&J.charCodeAt(z)<=122||J.charCodeAt(z)>=65&&J.charCodeAt(z)<=90||J.charCodeAt(z)>=48&&J.charCodeAt(z)<=57||J.charCodeAt(z)===95||J.charCodeAt(z)===36))z++;let H=J.slice(Z,z);if(H==="new"||H==="async"||H==="await"||H==="function"||H==="yield"||H==="console"||H==="process")return!1;let Q=z;while(Q<$&&J.charCodeAt(Q)<=32)Q++;if(Q<$&&J.charCodeAt(Q)===40)return!1;z--}}return!0}function s(J,Y,X=0){let $=J.slice(1,-1).trim();if(!$)return"{}";if(X>=20)return"Record<string, unknown>";let z=a($),B=[],Z=E&&!Y,H=[];for(let[Q,L]of z){let O=M;M=null;let G,W=L.trim();if(e(W))G=zz(Q,W);else if(G=V(L,Y,!1,X+1),G.includes("=>")||G.includes("function")||G.includes("async"))G=i(G);let K=M;M=O;let F=L.trim(),q=r(Q);if(q){let N=t(q.kind,q.name,G);if(N){B.push(N);continue}}if(!Y&&m(G)&&x(F))B.push(`/** @defaultValue ${F} */
6
+ ${Q}: ${G}`);else B.push(`${Q}: ${G}`);if(Z){let N=h(Q);if(F.endsWith("as const"));else if(x(F))H.push(`${N}: ${F}`);else if(F.startsWith("[")&&g(F))H.push(`${N}: ${_(F)}`);else if(F.startsWith("{")){if(K)H.push(`${N}: ${K}`)}else if(!F.startsWith("[")&&(F.includes("=>")||F.startsWith("function")||F.startsWith("async"))){let U=y(F,!1,0,!0);H.push(`${N}: ${U}`)}}}if(Z&&H.length>0){let Q=X>0?(X-1)/2:0,L=`{ ${H.join(", ")} }`;if(L.length<=80)M=L;else{let O=" ".repeat((Q+1)*2),G=" ".repeat(Q*2);M=`{
7
+ ${O}${H.join(`,
8
+ ${O}`)}
9
+ ${G}}`}}return`{
10
+ ${B.join(`;
11
+ `)}
12
+ }`}function i(J){let X=J.split(`
13
+ `).map((O)=>C(O)).join(`
14
+ `),$=X.indexOf("async");if($!==-1){let O=$>0?X.charCodeAt($-1):32,G=$+5<X.length?X.charCodeAt($+5):32;if(!P(O)&&!P(G))X=(X.slice(0,$)+X.slice($+5)).trim()}let z=X.indexOf("(");if(z!==-1){let O=j(X,z,"(",")");if(O!==-1){let G=X.slice(z,O+1),W=k(G);X=X.slice(0,z)+W+X.slice(O+1)}}let B=X.length,Z="",H=[],Q=!1,L=!1;for(let O=0;O<B;O++){let G=X.charCodeAt(O);if(G===123||G===40)H.push(G);else if(G===125||G===41)H.pop();if(G<=32){if(Q=!0,G===10||G===13)L=!0;continue}if(Q&&Z.length>0){let K=(H.length>0?H[H.length-1]:0)===123;if(L&&K){let F=Z.charCodeAt(Z.length-1),q=F===59||F===44||F===123||G===125,N=Z.length>=2&&Z.charCodeAt(Z.length-1)===47&&Z.charCodeAt(Z.length-2)===42;if(!q&&!N)Z+="; ";else Z+=" "}else Z+=" "}Q=!1,L=!1,Z+=X[O]}return Z.trim()}function P(J){return J>=97&&J<=122||J>=65&&J<=90||J>=48&&J<=57||J===95||J===36}function k(J){let Y=J.trim(),X,$=!1;if(Y.startsWith("(")&&Y.endsWith(")"))X=Y.slice(1,-1),$=!0;else X=Y;let z=X.trim();if(!z)return $?"()":"";let B=!1;{let F=0;for(let q=0;q<z.length;q++){let N=z.charCodeAt(q);if(N===40||N===60||N===91||N===123)F++;else if(N===41||N===62||N===93||N===125)F--;else if(F===0&&N===61){let U=q>0?z.charCodeAt(q-1):0,R=q+1<z.length?z.charCodeAt(q+1):0;if(U!==61&&U!==33&&U!==60&&U!==62&&R!==61&&R!==62){B=!0;break}}}}if(!B)return Y;let Z=[],H=[],Q=0,L=0,O=!1,G=0;for(let F=0;F<=z.length;F++){if(F===z.length){Z.push(z.slice(Q));break}let q=z.charCodeAt(F);if(O){if(q===92){F++;continue}if(q===G)O=!1;continue}if(q===39||q===34||q===96){O=!0,G=q;continue}if(q===40||q===60||q===91||q===123)L++;else if(q===41||q===62||q===93||q===125)L--;else if(q===44&&L===0){Z.push(z.slice(Q,F));let N=",",U=F+1;while(U<z.length&&z.charCodeAt(U)<=32)N+=z[U],U++;H.push(N),Q=U}}let W=[];for(let F of Z){let q=F.trim();if(!q){W.push(F);continue}if(q.startsWith("//"))continue;let N=C(q),U=F.slice(0,F.length-F.trimStart().length);W.push(U+n(N))}let K=W[0]||"";for(let F=1;F<W.length;F++)K+=(H[F-1]||", ")+W[F];return $?`(${K})`:K}function C(J){let Y=!1,X=0;for(let $=0;$<J.length-1;$++){let z=J.charCodeAt($);if(Y){if(z===92){$++;continue}if(z===X)Y=!1;continue}if(z===39||z===34||z===96){Y=!0,X=z;continue}if(z===47&&J.charCodeAt($+1)===47)return J.slice(0,$).trimEnd()}return J}function n(J){if(J.startsWith("..."))return J;let Y=-1,X=-1,$=0,z=!1,B=0;for(let H=0;H<J.length;H++){let Q=J.charCodeAt(H);if(z){if(Q===92){H++;continue}if(Q===B)z=!1;continue}if(Q===39||Q===34||Q===96){z=!0,B=Q;continue}if(Q===40||Q===60||Q===91||Q===123)$++;else if(Q===41||Q===62||Q===93||Q===125)$--;else if($===0){if(Q===58&&Y===-1)Y=H;else if(Q===61&&X===-1&&(H===0||J.charCodeAt(H-1)!==61)&&(H+1>=J.length||J.charCodeAt(H+1)!==61&&J.charCodeAt(H+1)!==62))X=H}}let Z=X!==-1;if(Y!==-1&&(X===-1||Y<X)){let H=J.slice(0,Y).trim(),Q=X!==-1?J.slice(Y+1,X).trim():J.slice(Y+1).trim(),L=Z&&!H.endsWith("?")?"?":"";return`${H}${L}: ${Q}`}else if(X!==-1){let H=J.slice(0,X).trim(),Q=!H.endsWith("?")?"?":"",L=J.slice(X+1).trim(),O="unknown";if(L==="true"||L==="false")O="boolean";else if(/^-?\d+(\.\d+)?$/.test(L))O="number";else if(L.startsWith("'")&&L.endsWith("'")||L.startsWith('"')&&L.endsWith('"'))O="string";else if(L.startsWith("["))O="unknown[]";else if(L.startsWith("{"))O="Record<string, unknown>";return`${H}${Q}: ${O}`}return J}function a(J){let Y=[],X="",$="",z=0,B=!1,Z="",H=!0,Q=!1,L=0;for(let O=0;O<J.length;O++){let G=J.charCodeAt(O),W=O>0?J.charCodeAt(O-1):0,K=O<J.length-1?J.charCodeAt(O+1):0;if(!B&&!Q&&G===47&&K===47){O+=2;while(O<J.length&&J.charCodeAt(O)!==10)O++;continue}if(!B&&!Q&&G===47&&K===42){Q=!0,L=1,X+="/*",O++;continue}else if(Q&&G===42&&K===47){if(L--,X+="*/",O++,L===0)Q=!1;continue}else if(Q&&G===47&&K===42){L++,X+="/*",O++;continue}let F=J[O];if(!B&&(G===34||G===39||G===96))B=!0,Z=F,X+=F;else if(B&&F===Z&&W!==92)B=!1,X+=F;else if(!B&&!Q)if(G===40&&z===0&&H){$=X.trim();let q="";if($.startsWith("async "))$=$.slice(6).trim(),q="async ";if($.startsWith("*"))$=$.slice(1).trim(),q+="*";X=q+F,H=!1,z=1}else if(G===123||G===91||G===40)z++,X+=F;else if(G===125||G===93||G===41)z--,X+=F;else if(G===58&&z===0&&H)$=X.trim(),X="",H=!1;else if(G===44&&z===0){if($&&X.trim()){let q=X.trim();Y.push([$,q])}X="",$="",H=!0}else X+=F;else X+=F}if($&&X.trim()){let O=X.trim();Y.push([$,O])}return Y}function r(J){let Y=J.trim();if(Y.startsWith("get ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"get",name:X}}if(Y.startsWith("set ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"set",name:X}}return null}function t(J,Y,X){let $=X.trim();if($.charCodeAt(0)!==40)return null;let z=j($,0,"(",")");if(z===-1)return null;let B=$.slice(1,z).trim(),Z=$.slice(z+1).trimStart();if(!Z.startsWith("=>"))return null;let H=Z.slice(2).trim();if(J==="get")return`get ${Y}(): ${H||"unknown"}`;return`set ${Y}(${B})`}function e(J){let Y=J;if(Y.startsWith("async ")||Y.startsWith("async\t"))Y=Y.slice(5).trimStart();if(Y.startsWith("*"))Y=Y.slice(1).trimStart();if(!Y.startsWith("("))return!1;let X=0;for(let $=0;$<Y.length;$++){let z=Y.charCodeAt($);if(z===40)X++;else if(z===41){if(X--,X===0){let B=Y.slice($+1).trimStart();if(B.startsWith("{"))return!0;if(B.startsWith(":")){let Z=0;for(let H=0;H<B.length;H++){let Q=B.charCodeAt(H);if(Q===40||Q===91)Z++;else if(Q===41||Q===93)Z--;else if(Q===60)Z++;else if(Q===62){if(Z>0)Z--}else if(Z===0&&Q===61&&H+1<B.length&&B.charCodeAt(H+1)===62)return!1;else if(Z===0&&Q===123)return!0}}return!1}}}return!1}function zz(J,Y){let X=Y.trimStart(),$=!1,z=!1;if(X.startsWith("async ")||X.startsWith("async\t"))$=!0,X=X.slice(5).trimStart();if(X.startsWith("*"))z=!0,X=X.slice(1).trimStart();let B="";if(X.charCodeAt(0)===60){let W=0,K=-1;for(let F=0;F<X.length;F++)if(X.charCodeAt(F)===60)W++;else if(X.charCodeAt(F)===62){if(W--,W===0){K=F;break}}if(K!==-1)B=X.slice(0,K+1),X=X.slice(K+1).trimStart()}let Z=X.indexOf("("),H=j(X,Z,"(",")");if(Z===-1||H===-1)return"() => unknown";let Q=X.slice(Z,H+1),L="unknown",O=X.slice(H+1).trimStart();if(O.charCodeAt(0)===58){let W=O.slice(1),K=0,F=-1,q=!1;for(let N=0;N<W.length;N++){let U=W.charCodeAt(N);if(U===40||U===91)K++;else if(U===41||U===93)K--;else if(U===123&&K===0){F=N;break}else if(U===61&&N+1<W.length&&W.charCodeAt(N+1)===62&&K===0){F=N,q=!0;break}}if(F!==-1)L=W.slice(0,F).trim();else L=W.trim()}if(L==="unknown"){if($&&z)L="AsyncGenerator<unknown, void, unknown>";else if(z)L="Generator<unknown, void, unknown>";else if($)L="Promise<void>"}else if($&&!L.startsWith("Promise<")&&!L.startsWith("AsyncGenerator<"))L=`Promise<${L}>`;let G=k(Q);return`${B}${G} => ${L}`}function j(J,Y,X,$){let z=0;for(let B=Y;B<J.length;B++)if(J[B]===X)z++;else if(J[B]===$){if(z--,z===0)return B}return-1}function Jz(J){let Y=0,X=0,$=!1,z="";for(let B=0;B<J.length-1;B++){let Z=J[B],H=J[B+1],Q=B>0?J[B-1]:"";if(!$&&(Z==='"'||Z==="'"||Z==="`"))$=!0,z=Z;else if($&&Z===z&&Q!=="\\")$=!1;if(!$){if(Z==="(")Y++;else if(Z===")")Y--;else if(Z==="[")X++;else if(Z==="]")X--;if(Z==="="&&H===">"&&Y===0&&X===0)return B}}return-1}function y(J,Y=!1,X=0,$=!0){let z=J.trim();if(z.length>200&&D(z,"=>")>2&&D(z,"<")>5&&!z.startsWith("function"))return Y?"((...args: any[]) => any)":"(...args: any[]) => any";if(z.startsWith("async ")&&z.includes("=>")){let Z=z.slice(5).trim(),H=Z.indexOf("=>"),Q=Z.substring(0,H).trim(),L=Z.substring(H+2).trim();if(Q=k(Q),Q==="()"||Q==="")Q="()";else if(!Q.startsWith("("))Q=`(${Q})`;let O="unknown";if(L.startsWith("{"))O="unknown";else O=V(L,$,!1,X+1);let G=`${Q} => Promise<${O}>`;return Y?`(${G})`:G}if(z.includes("=>")){let Z="",H=z;if(z.startsWith("<")){let q=j(z,0,"<",">");if(q!==-1)Z=z.substring(0,q+1),H=z.substring(q+1).trim()}let Q=Jz(H);if(Q===-1)return Y?"(() => unknown)":"() => unknown";let L=H.substring(0,Q).trim(),O=H.substring(Q+2).trim(),G="",W=L.lastIndexOf("):");if(W!==-1){let q=L.substring(W+2).trim();if(q&&!q.includes("=>")&&!q.includes("="))G=q,L=L.substring(0,W+1)}if(L=k(L),L==="()"||L==="")L="()";else if(!L.startsWith("("))L=`(${L})`;let K="unknown";if(G)K=G;else if(O.startsWith("{"))K="unknown";else if(O.includes("=>")){let q=O.trimStart(),N=q.indexOf("("),U=N!==-1?j(q,N,"(",")"):-1,R=U!==-1?q.indexOf("=>",U):-1;if(N===0&&U!==-1&&R!==-1){let b=q.substring(N+1,U).trim(),A=k(b);if(Z.includes("T")&&A.includes("T"))K=`(${A}) => T`;else K=`(${A}) => any`}else K="any"}else if(Y)K="unknown";else K=V(O,$,!1,X+1);let F=`${Z}${L} => ${K}`;return Y?`(${F})`:F}if(z.startsWith("function")){let Z=8,H=z.length;while(Z<H&&z.charCodeAt(Z)<=32)Z++;let Q=!1;if(Z<H&&z.charCodeAt(Z)===42){Q=!0,Z++;while(Z<H&&z.charCodeAt(Z)<=32)Z++}let L="";if(Z<H&&z.charCodeAt(Z)===60){let W=Z,K=1;Z++;while(Z<H&&K>0){let F=z.charCodeAt(Z);if(F===60)K++;else if(F===62)K--;Z++}L=z.substring(W,Z);while(Z<H&&z.charCodeAt(Z)<=32)Z++}let O=z.indexOf("(",Z);if(O!==-1){let W=1,K=O+1;while(K<H&&W>0){let U=z.charCodeAt(K);if(U===40)W++;else if(U===41)W--;K++}let F=z.substring(O+1,K-1).trim(),q=F?`(${F})`:"()";if(Q){let U=z.substring(K).trim(),R=U.indexOf("Generator<");if(R!==-1){let A=R+10,T=U.indexOf(">",A);if(T!==-1){let u=U.substring(A,T),v=`${L}${q} => Generator<${u}>`;return Y?`(${v})`:v}}let b=`${L}${q} => Generator<any, any, any>`;return Y?`(${b})`:b}let N=`${L}${q} => unknown`;return Y?`(${N})`:N}let G="(...args: any[]) => unknown";return Y?`(${G})`:G}if(z.includes("=>")&&z.includes("(")&&z.includes(")")){if(z.length>100||D(z,"=>")>2){let Z="";if(z.charCodeAt(0)===60){let G=j(z,0,"<",">");if(G!==-1)Z=z.substring(0,G+1)}let H=z.indexOf("("),Q=H!==-1?j(z,H,"(",")"):-1,L=H!==-1&&Q!==-1?z.substring(H,Q+1):"(...args: any[])";L=k(L);let O=`${Z}${L} => any`;return Y?`(${O})`:O}return Y?`(${z})`:z}let B="() => unknown";return Y?`(${B})`:B}function Hz(J){let Y=J.trim();if(Y==="any"||Y==="object"||Y==="unknown")return!0;if(Y.startsWith("Record<")&&Y.endsWith(">"))return!0;if(Y.startsWith("Array<")&&Y.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(Y))return!0;return!1}function Fz(J){let Y=J.lastIndexOf(" satisfies ");if(Y===-1)return null;let X=J.slice(Y+11).trim();if(X.endsWith(";"))X=X.slice(0,-1).trim();return X||null}var Xz=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Yz=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Zz=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function Lz(J){let Y=[],X=0;for(let $=0;$<=J.length;$++)if($===J.length||J[$]===`
15
+ `){let z=X,B=$;while(z<B&&(J[z]===" "||J[z]==="\t"||J[z]==="\r"))z++;while(B>z&&(J[B-1]===" "||J[B-1]==="\t"||J[B-1]==="\r"))B--;let Z=J.slice(z,B);if(X=$+1,Z.startsWith("///")){if(Z.indexOf("<")===-1)continue;if(Xz.test(Z)||Yz.test(Z)||Zz.test(Z))Y.push(Z)}else if(Z===""||Z.startsWith("//"))continue;else break}return Y}
16
+ export{$z as Dc,Qz as Ec,V as Fc,l as Gc,I as Hc,w as Ic,s as Jc,j as Kc,y as Lc,Hz as Mc,Fz as Nc,Lz as Oc};