@dtsx/dtsx 0.11.37 → 0.11.38

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 (179) hide show
  1. package/dist/bin/cli.js +3 -3
  2. package/dist/{chunk-wrnz0e76.js → chunk-082w7zvy.js} +3 -3
  3. package/dist/{chunk-psrgw9f8.js → chunk-0k0fhq13.js} +7 -7
  4. package/dist/{chunk-69dbf6de.js → chunk-0rmbc5zp.js} +2 -2
  5. package/dist/{chunk-nn9tpxx3.js → chunk-0yg5mcrf.js} +2 -2
  6. package/dist/chunk-0zfzhn19.js +31 -0
  7. package/dist/chunk-189nn4fc.js +3 -0
  8. package/dist/{chunk-cen2t56g.js → chunk-1qtghb2x.js} +2 -2
  9. package/dist/{chunk-r4zkf9ag.js → chunk-2436cnmb.js} +2 -2
  10. package/dist/{chunk-py7pj8aj.js → chunk-2qd3axyx.js} +4 -4
  11. package/dist/{chunk-n2nyd0ck.js → chunk-32qexm3w.js} +2 -2
  12. package/dist/{chunk-1pz7zxhc.js → chunk-3fbt79hx.js} +2 -2
  13. package/dist/{chunk-gpq2kggq.js → chunk-3t57mzvf.js} +2 -2
  14. package/dist/{chunk-2kwjbk55.js → chunk-42j9cfte.js} +2 -2
  15. package/dist/{chunk-vtskg4r2.js → chunk-4fygcxtb.js} +2 -2
  16. package/dist/{chunk-437g8zz6.js → chunk-50h54rax.js} +3 -3
  17. package/dist/{chunk-aw48mk3t.js → chunk-6yvk3q1e.js} +2 -2
  18. package/dist/chunk-73dzve1s.js +3 -0
  19. package/dist/chunk-7tremqhs.js +14 -0
  20. package/dist/{chunk-mt9219xc.js → chunk-83qnrx0m.js} +5 -5
  21. package/dist/{chunk-ckq8g1ck.js → chunk-88gwzbew.js} +3 -3
  22. package/dist/{chunk-90aptjh6.js → chunk-8d3sdkv4.js} +19 -19
  23. package/dist/{chunk-srg5qhch.js → chunk-8tzd98q8.js} +4 -4
  24. package/dist/{chunk-fy97syc2.js → chunk-96atbsd3.js} +2 -2
  25. package/dist/{chunk-h7k9wamx.js → chunk-9gts9ymh.js} +2 -2
  26. package/dist/{chunk-sq34kkhy.js → chunk-9menejdz.js} +2 -2
  27. package/dist/{chunk-1h6ycqza.js → chunk-a7nvyxpg.js} +4 -4
  28. package/dist/{chunk-j6pfxvy8.js → chunk-ag1b6d30.js} +2 -2
  29. package/dist/{chunk-0ke9xh7t.js → chunk-bnry23ve.js} +3 -3
  30. package/dist/{chunk-wzcwctba.js → chunk-bxc2herz.js} +3 -3
  31. package/dist/{chunk-pzedkn7z.js → chunk-cpmqa8kd.js} +2 -2
  32. package/dist/{chunk-rdzfdjkb.js → chunk-cv29b4zb.js} +3 -3
  33. package/dist/{chunk-xr1h3tv2.js → chunk-cyr45de1.js} +2 -2
  34. package/dist/{chunk-m1khpcqb.js → chunk-d0bazr3p.js} +1 -1
  35. package/dist/{chunk-vae5wxar.js → chunk-danfamyx.js} +2 -2
  36. package/dist/{chunk-853ftm92.js → chunk-davy89dj.js} +5 -5
  37. package/dist/{chunk-n6nw7sn2.js → chunk-e29rp5xj.js} +5 -5
  38. package/dist/{chunk-p7w9ydhe.js → chunk-eba562w8.js} +2 -2
  39. package/dist/{chunk-v44crx69.js → chunk-ebjafajx.js} +11 -11
  40. package/dist/{chunk-g9d5r6a8.js → chunk-ft2zk7jx.js} +2 -2
  41. package/dist/chunk-g2120ysy.js +3 -0
  42. package/dist/chunk-ghfd34r7.js +3 -0
  43. package/dist/{chunk-sjneg7p7.js → chunk-gspsxc9d.js} +8 -8
  44. package/dist/{chunk-n3p7wedp.js → chunk-h3n6256r.js} +2 -2
  45. package/dist/{chunk-4f2mwn7p.js → chunk-hnqm1zb3.js} +4 -4
  46. package/dist/{chunk-gs7wfk8b.js → chunk-htgy94y3.js} +1 -1
  47. package/dist/{chunk-knrtwppp.js → chunk-hv8bx8xx.js} +6 -6
  48. package/dist/chunk-hzn9kmq7.js +3 -0
  49. package/dist/{chunk-nchp0pqa.js → chunk-ja7bp731.js} +2 -2
  50. package/dist/chunk-jcckwgb9.js +3 -0
  51. package/dist/{chunk-s0mvstt0.js → chunk-kfk554fj.js} +2 -2
  52. package/dist/{chunk-1e10w914.js → chunk-kkshxyex.js} +3 -3
  53. package/dist/{chunk-bdxq6500.js → chunk-kpbz61yy.js} +3 -3
  54. package/dist/{chunk-w9av39jy.js → chunk-mkakbjvs.js} +2 -2
  55. package/dist/{chunk-xsf941gw.js → chunk-mwyjxjqa.js} +2 -2
  56. package/dist/{chunk-n37yj3xv.js → chunk-p023fhce.js} +3 -3
  57. package/dist/chunk-p9vfxn8g.js +3 -0
  58. package/dist/{chunk-q0hn0ymb.js → chunk-pjqzkgzk.js} +4 -4
  59. package/dist/chunk-qzjzw9p2.js +3 -0
  60. package/dist/{chunk-acyj1dev.js → chunk-rbx6q1r0.js} +2 -2
  61. package/dist/{chunk-fgbdm1y6.js → chunk-rkstz4w1.js} +4 -4
  62. package/dist/{chunk-gsv5yc32.js → chunk-rz060wxt.js} +4 -4
  63. package/dist/{chunk-z4mvkazp.js → chunk-sd8bywh9.js} +11 -11
  64. package/dist/{chunk-dv5hhg1a.js → chunk-sv8h007a.js} +2 -2
  65. package/dist/{chunk-1bpv3tck.js → chunk-t4va49p3.js} +4 -4
  66. package/dist/{chunk-bqabznps.js → chunk-tka2m4af.js} +2 -2
  67. package/dist/{chunk-7610h2tf.js → chunk-v93389xm.js} +1 -1
  68. package/dist/{chunk-wnk9yjw2.js → chunk-vf3ybe5r.js} +2 -2
  69. package/dist/{chunk-ezbp8tss.js → chunk-vkahj2ab.js} +8 -8
  70. package/dist/chunk-wnqg6hem.js +27 -0
  71. package/dist/chunk-xa6rsd4b.js +29 -0
  72. package/dist/{chunk-gsb3ty07.js → chunk-xfjfhe9d.js} +2 -2
  73. package/dist/{chunk-5n0tfrpc.js → chunk-xwpn40p0.js} +3 -3
  74. package/dist/chunk-y1g6v96c.js +10 -0
  75. package/dist/{chunk-r4s18nn5.js → chunk-y5k0szq6.js} +2 -2
  76. package/dist/{chunk-km8t8gqg.js → chunk-yay68832.js} +2 -2
  77. package/dist/{chunk-strqhcqs.js → chunk-yrv6z221.js} +2 -2
  78. package/dist/chunk-yx1jy7fx.js +37 -0
  79. package/dist/{chunk-ggbahdr2.js → chunk-zgcdx773.js} +3 -3
  80. package/dist/{chunk-60ssvwc8.js → chunk-zk3w5sqv.js} +2 -2
  81. package/dist/src/augmentation-graph.js +1 -1
  82. package/dist/src/binding-patterns.js +1 -1
  83. package/dist/src/branded-types.js +1 -1
  84. package/dist/src/bundle-linker.js +1 -1
  85. package/dist/src/bundler.js +1 -1
  86. package/dist/src/cache.js +1 -1
  87. package/dist/src/call-signatures.js +1 -1
  88. package/dist/src/circular.js +1 -1
  89. package/dist/src/compat.js +1 -1
  90. package/dist/src/computed-keys.js +1 -1
  91. package/dist/src/config.js +1 -1
  92. package/dist/src/dangling-refs.js +1 -1
  93. package/dist/src/declaration-project.js +1 -1
  94. package/dist/src/declaration-publication.js +1 -1
  95. package/dist/src/declaration-references.js +1 -1
  96. package/dist/src/diff.js +1 -1
  97. package/dist/src/docs.js +1 -1
  98. package/dist/src/enum-declarations.js +1 -1
  99. package/dist/src/errors.js +1 -1
  100. package/dist/src/extractor/directives.js +1 -1
  101. package/dist/src/extractor/extract.js +1 -1
  102. package/dist/src/extractor/scanner.js +1 -1
  103. package/dist/src/extractor.js +1 -1
  104. package/dist/src/formats.js +1 -1
  105. package/dist/src/formatter.js +1 -1
  106. package/dist/src/function-properties.js +1 -1
  107. package/dist/src/generator.js +1 -1
  108. package/dist/src/global-types.js +1 -1
  109. package/dist/src/import-sorter.js +1 -1
  110. package/dist/src/incremental.js +1 -1
  111. package/dist/src/index.js +1 -1
  112. package/dist/src/inferred-imports.js +1 -1
  113. package/dist/src/json-config.js +1 -1
  114. package/dist/src/logger.js +1 -1
  115. package/dist/src/lsp.js +1 -1
  116. package/dist/src/memory.js +1 -1
  117. package/dist/src/merger.js +1 -1
  118. package/dist/src/module-graph.js +1 -1
  119. package/dist/src/native-checker.js +1 -1
  120. package/dist/src/native-engine.js +1 -1
  121. package/dist/src/native-extractor.js +1 -1
  122. package/dist/src/native-generation.js +1 -1
  123. package/dist/src/native-project.js +1 -1
  124. package/dist/src/optimizer.js +1 -1
  125. package/dist/src/output-normalizer.js +1 -1
  126. package/dist/src/parallel-processor.js +1 -1
  127. package/dist/src/parameters.js +1 -1
  128. package/dist/src/parser.js +1 -1
  129. package/dist/src/plugins/bun.js +1 -1
  130. package/dist/src/plugins/esbuild.js +1 -1
  131. package/dist/src/plugins/index.js +1 -1
  132. package/dist/src/plugins/tsdown.js +1 -1
  133. package/dist/src/plugins/tsup.js +1 -1
  134. package/dist/src/plugins/vite.js +1 -1
  135. package/dist/src/plugins/webpack.js +1 -1
  136. package/dist/src/plugins.js +1 -1
  137. package/dist/src/process-source.js +1 -1
  138. package/dist/src/processor/cache.js +1 -1
  139. package/dist/src/processor/comments.js +1 -1
  140. package/dist/src/processor/declarations.js +1 -1
  141. package/dist/src/processor/import-usage.js +1 -1
  142. package/dist/src/processor/imports.js +1 -1
  143. package/dist/src/processor/index.js +1 -1
  144. package/dist/src/processor/type-inference.js +1 -1
  145. package/dist/src/processor.js +1 -1
  146. package/dist/src/profiling.js +1 -1
  147. package/dist/src/return-type-scope.js +1 -1
  148. package/dist/src/security.js +1 -1
  149. package/dist/src/source-cache.js +1 -1
  150. package/dist/src/sourcemap.js +1 -1
  151. package/dist/src/stx.js +1 -1
  152. package/dist/src/syntax-validator.js +1 -1
  153. package/dist/src/tracking.js +1 -1
  154. package/dist/src/transformers.js +1 -1
  155. package/dist/src/tree-shaker.js +1 -1
  156. package/dist/src/tsconfig.js +1 -1
  157. package/dist/src/type-mappings.js +1 -1
  158. package/dist/src/utils.js +1 -1
  159. package/dist/src/value-inference.js +1 -1
  160. package/dist/src/vue.js +1 -1
  161. package/dist/src/watcher.js +1 -1
  162. package/dist/src/worker-thread.js +1 -1
  163. package/dist/src/worker.js +1 -1
  164. package/dist/src/workspace.js +1 -1
  165. package/package.json +1 -1
  166. package/dist/chunk-0azm93j9.js +0 -31
  167. package/dist/chunk-25vyhfzh.js +0 -3
  168. package/dist/chunk-79nv7twc.js +0 -14
  169. package/dist/chunk-cs4gwz1k.js +0 -27
  170. package/dist/chunk-d43bpfk6.js +0 -3
  171. package/dist/chunk-dfye109x.js +0 -3
  172. package/dist/chunk-n94729d9.js +0 -3
  173. package/dist/chunk-p2qz2nk2.js +0 -3
  174. package/dist/chunk-qnf4byak.js +0 -3
  175. package/dist/chunk-rmdwvzgn.js +0 -3
  176. package/dist/chunk-s6c98nad.js +0 -29
  177. package/dist/chunk-t1jtn2r0.js +0 -10
  178. package/dist/chunk-ttc5pr8y.js +0 -37
  179. package/dist/chunk-xb92nrsm.js +0 -3
package/dist/bin/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
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
- `)}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 V=s,Y=0,Z=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 V.submit({id:`batch-${Z}-${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 V.submit({id:`batch-${Z}-${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]}`)}}},q=[];for(let j=0;j<X;j++)q.push(ee());await Promise.all(q),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)}
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:H}=await import("../chunk-gs7wfk8b.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 Q(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:Q(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: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:Q(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-htgy94y3.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(`
10
10
  ${h.length} files checked, all follow isolated declarations best practices`);n.exit(u>0?1:0)}console.log(`Type checking ${h.length} files...`);let m=await t(h,{tsconfigPath:e.tsconfig?a(e.tsconfig):void 0,strict:e.strict??!1,declarationsOnly:e.declarationsOnly??!1,skipLibCheck:e.skipLibCheck??!0,warningsAsErrors:e.warningsAsErrors??!1,maxErrors:e.maxErrors||void 0});if(e.format==="json")console.log(JSON.stringify(m,null,2));else console.log(f(m));n.exit(m.success?0:1)}catch(t){console.error(t instanceof Error?`Error during type checking: ${t.message}`:`Error during type checking: ${String(t)}`),n.exit(1)}});D.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(e)=>{try{let t=await import("../src/formats.js"),{extractDeclarations:o}=await import("../src/extractor.js"),{Glob:f}=await Promise.resolve(globalThis.Bun),{resolve:p,relative:a,join:l,dirname:y,basename:w}=await import("path"),{mkdirSync:h,existsSync:m,readFileSync:i,writeFileSync:u}=await import("fs"),c=n.cwd(),g=e.files||["**/*.ts"],k=e.format||"json-schema",P=p(e.outdir||"./schemas"),x=[];for(let s of g){let E=new f(s);for await(let L of E.scan({cwd:c,absolute:!0,onlyFiles:!0}))if(!L.endsWith(".d.ts")&&!L.includes("node_modules"))x.push(L)}if(x.length===0)console.error("No TypeScript files found"),n.exit(1);if(console.log(`Converting ${x.length} files to ${k} format...`),!m(P))h(P,{recursive:!0});let C=0,b=0;for(let s of x){let E=i(s,"utf-8"),I=o(E,s).filter((_)=>_.kind==="interface"||_.kind==="type");if(I.length===0)continue;let F=t.convertToFormat(I,{format:k,includeDescriptions:e.includeDescriptions??!0,allOptional:e.allOptional??!1,useInfer:e.useInfer??!0,jsonSchemaDraft:e.jsonSchemaDraft||"2020-12"}),T=a(c,s),d=w(s,".ts"),S=t.getFormatExtension(k),W=l(P,y(T),`${d}${S}`),K=y(W);if(!m(K))h(K,{recursive:!0});u(W,F),C+=I.length,b++,console.log(` ${a(c,W)} (${I.length} types)`)}console.log(`
11
11
  Converted ${C} declarations from ${b} files`)}catch(t){console.error("Error converting files:",t),n.exit(1)}});D.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(e)=>{try{let{analyzeCircularDependencies:t,formatCircularAnalysis:o,getGraphSummary:f,exportGraphAsDot:p,exportGraphAsJson:a}=await import("../src/circular.js"),{Glob:l}=await Promise.resolve(globalThis.Bun),{resolve:y,relative:w}=await import("path"),h=n.cwd(),m=y(e.root||"."),i=e.files||["**/*.ts"],u=[];for(let g of i){let k=new l(g);for await(let P of k.scan({cwd:m,absolute:!0,onlyFiles:!0}))if(!P.endsWith(".d.ts")){if(!e.includeNodeModules&&P.includes("node_modules"))continue;u.push(P)}}if(u.length===0)console.error("No TypeScript files found"),n.exit(1);console.log(`Analyzing ${u.length} files for circular dependencies...`);let c=await t(u,{rootDir:m,ignore:e.ignore?.filter(Boolean),typesOnly:e.typesOnly??!1,maxDepth:e.maxDepth??100,includeNodeModules:e.includeNodeModules??!1});if(e.format==="json")console.log(a(c.graph,m));else if(e.format==="dot")console.log(p(c.graph,m));else if(console.log(o(c,m)),e.summary){let g=f(c.graph);if(console.log(`
12
- --- Dependency Graph Summary ---`),console.log(`Total files: ${g.totalFiles}`),console.log(`Total dependencies: ${g.totalDependencies}`),console.log(`Average dependencies per file: ${g.avgDependencies.toFixed(2)}`),g.maxDependencies.count>0)console.log(`Most dependencies: ${w(m,g.maxDependencies.file)} (${g.maxDependencies.count})`);if(g.mostDepended.count>0)console.log(`Most depended on: ${w(m,g.mostDepended.file)} (${g.mostDepended.count} dependents)`);if(g.isolatedFiles.length>0)console.log(`Isolated files (no dependencies): ${g.isolatedFiles.length}`)}n.exit(c.hasCircular?1:0)}catch(t){console.error("Error analyzing dependencies:",t),n.exit(1)}});D.command("version","Show the version of dtsx").action(()=>{console.log(H)});D.version(H);D.help();D.parse();
12
+ --- Dependency Graph Summary ---`),console.log(`Total files: ${g.totalFiles}`),console.log(`Total dependencies: ${g.totalDependencies}`),console.log(`Average dependencies per file: ${g.avgDependencies.toFixed(2)}`),g.maxDependencies.count>0)console.log(`Most dependencies: ${w(m,g.maxDependencies.file)} (${g.maxDependencies.count})`);if(g.mostDepended.count>0)console.log(`Most depended on: ${w(m,g.mostDepended.file)} (${g.mostDepended.count} dependents)`);if(g.isolatedFiles.length>0)console.log(`Isolated files (no dependencies): ${g.isolatedFiles.length}`)}n.exit(c.hasCircular?1:0)}catch(t){console.error("Error analyzing dependencies:",t),n.exit(1)}});D.command("version","Show the version of dtsx").action(()=>{console.log(Q)});D.version(Q);D.help();D.parse();
@@ -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 yi{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 Uo(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 zo(t,e=604800000){let s=t.getStats();if(s.totalEntries>1000)return await t.clear(),s.totalEntries;return 0}function Ho(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
- `)}function Ko(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{yi,Uo,zo,Ho,Ko};
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 ei{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 po(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 mo(t,e=604800000){let s=t.getStats();if(s.totalEntries>1000)return await t.clear(),s.totalEntries;return 0}function go(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
+ `)}function ho(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{ei,po,mo,go,ho};
@@ -1,19 +1,19 @@
1
1
  // @bun
2
- var rn=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],Yr=["builtin","external","scoped","internal","parent","sibling","index","type"];function je(e,n={}){let{lineEnding:t="lf",trailingNewline:i=!0,maxBlankLines:u=1,trimTrailingWhitespace:a=!0,normalizeIndentation:l=!0,indent:x={style:"spaces",size:2},declarationOrder:f,importGrouping:p,preserveComments:d=!0,insertFinalNewline:b=!0}=n,r=e;if(r=sn(r,t),p?.enabled!==!1)r=ln(r,p||{});if(f)r=un(r,f);if(a)r=on(r);if(r=an(r,u),l)r=Xr(r,x);if(i||b)r=cn(r);return r}function sn(e,n){let t=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
2
+ var rn=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],zr=["builtin","external","scoped","internal","parent","sibling","index","type"];function We(e,n={}){let{lineEnding:t="lf",trailingNewline:i=!0,maxBlankLines:u=1,trimTrailingWhitespace:a=!0,normalizeIndentation:l=!0,indent:x={style:"spaces",size:2},declarationOrder:f,importGrouping:p,preserveComments:d=!0,insertFinalNewline:b=!0}=n,r=e;if(r=sn(r,t),p?.enabled!==!1)r=ln(r,p||{});if(f)r=un(r,f);if(a)r=on(r);if(r=an(r,u),l)r=Hr(r,x);if(i||b)r=cn(r);return r}function sn(e,n){let t=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
3
3
  `)!==-1)t=t.replace(/\r\n/g,`
4
4
  `);if(t.indexOf("\r")!==-1)t=t.replace(/\r/g,`
5
5
  `)}if(n==="crlf")t=t.replace(/\n/g,`\r
6
- `);return t}function uo(e){let n=(e.match(/\r\n/g)||[]).length,t=(e.match(/(?<!\r)\n/g)||[]).length;if(n>t)return"crlf";return"lf"}function on(e){return e.split(`
6
+ `);return t}function eo(e){let n=(e.match(/\r\n/g)||[]).length,t=(e.match(/(?<!\r)\n/g)||[]).length;if(n>t)return"crlf";return"lf"}function on(e){return e.split(`
7
7
  `).map((n)=>n.replace(/[\t ]+$/,"")).join(`
8
8
  `)}function an(e,n){let t=new RegExp(`\\n{${n+2},}`,"g");return e.replace(t,`
9
9
  `.repeat(n+1))}function cn(e){return`${e.replace(/\s+$/,"")}
10
- `}function Xr(e,n){let{style:t="spaces",size:i=2}=n,u=t==="tabs"?"\t":" ".repeat(i),a=e.split(`
10
+ `}function Hr(e,n){let{style:t="spaces",size:i=2}=n,u=t==="tabs"?"\t":" ".repeat(i),a=e.split(`
11
11
  `),l=[];for(let x of a){let f=x.match(/^([\t ]*)(.*)$/);if(!f){l.push(x);continue}let[,p,d]=f;if(!d){l.push("");continue}let b=p.replace(/\t/g," "),r=Math.floor(b.length/2);l.push(u.repeat(r)+d)}return l.join(`
12
- `)}function ln(e,n){let{groups:t=Yr,separateGroups:i=!0,alphabetize:u=!0}=n,a=e.split(`
12
+ `)}function ln(e,n){let{groups:t=zr,separateGroups:i=!0,alphabetize:u=!0}=n,a=e.split(`
13
13
  `),l=[],x=[],f=-1;for(let s=0;s<a.length;s++){let c=a[s],o=E(c);if(o)l.push({line:c,source:o.source,group:o.group,isType:o.isType}),f=s;else if(l.length>0&&c.trim()==="")continue;else if(l.length>0||c.trim()!==""){if(l.length===0||s>f+1)x.push(c)}}if(l.length===0)return e;let p=new Map;for(let s of t)p.set(s,[]);for(let s of l)(p.get(s.group)||p.get("external")||[]).push(s);if(u)for(let[,s]of p)s.sort((c,o)=>{if(c.isType!==o.isType)return c.isType?1:-1;return c.source.localeCompare(o.source)});let d=[],b=null;for(let s of t){let c=p.get(s)||[];if(c.length===0)continue;if(i&&b!==null)d.push("");for(let o of c)d.push(o.line);b=s}let r=a.slice(0,a.findIndex((s)=>E(s)!==null)),m=x;while(m.length>0&&m[0].trim()==="")m.shift();return[...r,...d,"",...m].join(`
14
14
  `)}function E(e){let n=e.trim(),t=n.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!t){let a=n.match(/^import\s+['"]([^'"]+)['"]/);if(a)return{source:a[1],group:k(a[1]),isType:!1};return null}let i=!!t[1],u=t[2];return{source:u,group:i?"type":k(u),isType:i}}function k(e){if(e.startsWith("node:"))return"builtin";let n=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if(n.includes(e)||n.includes(e.split("/")[0]))return"builtin";if(e==="."||e==="./index"||e==="./index.js"||e==="./index.ts")return"index";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@"))return"scoped";return"external"}function un(e,n){let{kinds:t=rn,alphabetize:i=!1,groupExports:u=!0}=n,a=e.split(`
15
15
  `),l=[],x=[],f=[],p=null,d=0,b=!0,r=!1,m=[];for(let o=0;o<a.length;o++){let g=a[o],h=g.trim(),y=d,z=h.startsWith("///"),I=y===0&&!z&&(h.startsWith("//")||h.startsWith("/*"));if(r||I){if(m.push(g),!r&&h.startsWith("/*")&&!h.includes("*/"))r=!0;else if(r&&h.includes("*/"))r=!1;continue}if(y===0&&m.length>0&&h===""){m.push(g);continue}d+=(g.match(/\{/g)||[]).length,d-=(g.match(/\}/g)||[]).length;let W=T(h);if(b&&W&&W.kind!=="import"&&!h.startsWith("//")&&!h.startsWith("/*"))b=!1;if(b){if(m.length>0){if(W?.kind==="import"||!W)x.push(...m),m.length=0}x.push(g);continue}if(W&&d<=1){if(p)l.push(p);p={lines:m.length>0?[...m,g]:[g],kind:W.kind,name:W.name,isExport:W.isExport},m.length=0}else if(p)p.lines.push(g);else{if(h==="")continue;f.push(g)}}if(p)l.push(p);if(m.length>0)f.push(...m);l.sort((o,g)=>{if(u&&o.isExport!==g.isExport)return o.isExport?-1:1;let h=t.indexOf(o.kind),y=t.indexOf(g.kind),z=h>=0?h:t.length,I=y>=0?y:t.length;if(z!==I)return z-I;if(i)return o.name.localeCompare(g.name);return 0});let s=[...x],c=null;for(let o of l){if(c!==null&&o.kind!==c)s.push("");s.push(...o.lines),c=o.kind}if(f.length>0)s.push(""),s.push(...f);return s.join(`
16
- `)}function T(e){let n=e.startsWith("export "),t=n?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(t.startsWith("type ")||t.startsWith("declare type "))return{kind:"type",name:t.match(/type\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("interface ")||t.startsWith("declare interface "))return{kind:"interface",name:t.match(/interface\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("class ")||t.startsWith("abstract class ")||t.startsWith("declare class ")||t.startsWith("declare abstract class "))return{kind:"class",name:t.match(/class\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("enum ")||t.startsWith("const enum ")||t.startsWith("declare enum ")||t.startsWith("declare const enum "))return{kind:"enum",name:t.match(/enum\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("function ")||t.startsWith("async function ")||t.startsWith("declare function ")||t.startsWith("declare async function "))return{kind:"function",name:t.match(/function\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("const ")||t.startsWith("let ")||t.startsWith("var ")||t.startsWith("declare const ")||t.startsWith("declare let ")||t.startsWith("declare var "))return{kind:"variable",name:t.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("namespace ")||t.startsWith("declare namespace "))return{kind:"namespace",name:t.match(/namespace\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("module ")||t.startsWith("declare module "))return{kind:"module",name:t.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:n};if(e.startsWith("export {")||e.startsWith("export *")||e.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}function fo(e){let n=e.split(`
16
+ `)}function T(e){let n=e.startsWith("export "),t=n?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(t.startsWith("type ")||t.startsWith("declare type "))return{kind:"type",name:t.match(/type\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("interface ")||t.startsWith("declare interface "))return{kind:"interface",name:t.match(/interface\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("class ")||t.startsWith("abstract class ")||t.startsWith("declare class ")||t.startsWith("declare abstract class "))return{kind:"class",name:t.match(/class\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("enum ")||t.startsWith("const enum ")||t.startsWith("declare enum ")||t.startsWith("declare const enum "))return{kind:"enum",name:t.match(/enum\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("function ")||t.startsWith("async function ")||t.startsWith("declare function ")||t.startsWith("declare async function "))return{kind:"function",name:t.match(/function\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("const ")||t.startsWith("let ")||t.startsWith("var ")||t.startsWith("declare const ")||t.startsWith("declare let ")||t.startsWith("declare var "))return{kind:"variable",name:t.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("namespace ")||t.startsWith("declare namespace "))return{kind:"namespace",name:t.match(/namespace\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("module ")||t.startsWith("declare module "))return{kind:"module",name:t.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:n};if(e.startsWith("export {")||e.startsWith("export *")||e.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}function to(e){let n=e.split(`
17
17
  `),t=[];for(let i=0;i<n.length;i++){let u=n[i],a=u.trim();if(a.startsWith("/**")||a.startsWith("*")||a.startsWith("*/")){t.push(u);continue}if(a.startsWith("//")){t.push(u);continue}if(a.startsWith("/*")||a.endsWith("*/")){t.push(u);continue}t.push(u)}return t.join(`
18
- `)}function po(e={}){return{normalize:(n)=>je(n,e),normalizeLineEndings:(n)=>sn(n,e.lineEnding||"lf"),removeTrailingWhitespace:on,normalizeBlankLines:(n)=>an(n,e.maxBlankLines||1),ensureTrailingNewline:cn,processImports:(n)=>ln(n,e.importGrouping||{}),orderDeclarations:(n)=>un(n,e.declarationOrder||{})}}var mo={default:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},minimal:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:2,trimTrailingWhitespace:!0,normalizeIndentation:!1,importGrouping:{enabled:!1}},strict:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0},declarationOrder:{kinds:rn,alphabetize:!0,groupExports:!0}},windows:{lineEnding:"crlf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},tabs:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"tabs",size:1},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}}};
19
- export{rn,Yr,je,sn,uo,on,an,cn,Xr,ln,un,fo,po,mo};
18
+ `)}function no(e={}){return{normalize:(n)=>We(n,e),normalizeLineEndings:(n)=>sn(n,e.lineEnding||"lf"),removeTrailingWhitespace:on,normalizeBlankLines:(n)=>an(n,e.maxBlankLines||1),ensureTrailingNewline:cn,processImports:(n)=>ln(n,e.importGrouping||{}),orderDeclarations:(n)=>un(n,e.declarationOrder||{})}}var ro={default:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},minimal:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:2,trimTrailingWhitespace:!0,normalizeIndentation:!1,importGrouping:{enabled:!1}},strict:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0},declarationOrder:{kinds:rn,alphabetize:!0,groupExports:!0}},windows:{lineEnding:"crlf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},tabs:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"tabs",size:1},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}}};
19
+ export{rn,zr,We,sn,eo,on,an,cn,Hr,ln,un,to,no,ro};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{t}from"./chunk-1j6092xz.js";function q(r,i){if(i.kind!=="punctuation")return 0;let u=r.slice(i.start,i.end);if("([{<".includes(u))return 1;if(")]}".includes(u)||u===">"&&r[i.start-1]!=="=")return-1;return 0}function Ae(r){if(!r.includes("?"))return r;let i=r.trim(),u=i.startsWith("(")&&i.endsWith(")"),c=r.indexOf(i)+(u?1:0),o=u?i.slice(1,-1):i,a=[[]],x=0;for(let n of t(o)){if(n.kind==="punctuation"&&o[n.start]===","&&x===0)a.push([]);else a[a.length-1].push(n);x+=q(o,n)}let g=a.map((n)=>{let e=0,s=-1;for(let[T,p]of n.entries()){if(e===0&&p.kind==="punctuation"&&o[p.start]===":"){s=T;break}e+=q(o,p)}let d=s>0&&o[n[s-1].start]==="?"?n[s-1]:void 0,b=n[0]?o.slice(n[0].start,n[0].end):"",m=n[0]&&o.startsWith("...",n[0].start);return{tokens:n,colon:s,question:d,required:n.length>0&&!d&&!m&&b!=="this"}}),y=-1;for(let[n,e]of g.entries())if(e.required)y=n;let f=[];for(let[n,e]of g.entries()){if(n>=y||!e.question||e.colon<0)continue;let s=e.tokens[e.colon+1],d=e.tokens.at(-1);if(!s||!d)continue;f.push({start:c+e.question.start,end:c+e.question.end,text:""},{start:c+s.start,end:c+s.start,text:"("},{start:c+d.end,end:c+d.end,text:") | undefined"})}if(!f.length)return r;let l=[],h=0;for(let n of f)l.push(r.slice(h,n.start),n.text),h=n.end;return l.push(r.slice(h)),l.join("")}
3
- export{Ae};
2
+ import{t}from"./chunk-1j6092xz.js";function q(r,i){if(i.kind!=="punctuation")return 0;let u=r.slice(i.start,i.end);if("([{<".includes(u))return 1;if(")]}".includes(u)||u===">"&&r[i.start-1]!=="=")return-1;return 0}function De(r){if(!r.includes("?"))return r;let i=r.trim(),u=i.startsWith("(")&&i.endsWith(")"),c=r.indexOf(i)+(u?1:0),o=u?i.slice(1,-1):i,a=[[]],x=0;for(let n of t(o)){if(n.kind==="punctuation"&&o[n.start]===","&&x===0)a.push([]);else a[a.length-1].push(n);x+=q(o,n)}let g=a.map((n)=>{let e=0,s=-1;for(let[T,p]of n.entries()){if(e===0&&p.kind==="punctuation"&&o[p.start]===":"){s=T;break}e+=q(o,p)}let d=s>0&&o[n[s-1].start]==="?"?n[s-1]:void 0,b=n[0]?o.slice(n[0].start,n[0].end):"",m=n[0]&&o.startsWith("...",n[0].start);return{tokens:n,colon:s,question:d,required:n.length>0&&!d&&!m&&b!=="this"}}),y=-1;for(let[n,e]of g.entries())if(e.required)y=n;let f=[];for(let[n,e]of g.entries()){if(n>=y||!e.question||e.colon<0)continue;let s=e.tokens[e.colon+1],d=e.tokens.at(-1);if(!s||!d)continue;f.push({start:c+e.question.start,end:c+e.question.end,text:""},{start:c+s.start,end:c+s.start,text:"("},{start:c+d.end,end:c+d.end,text:") | undefined"})}if(!f.length)return r;let l=[],h=0;for(let n of f)l.push(r.slice(h,n.start),n.text),h=n.end;return l.push(r.slice(h)),l.join("")}
3
+ export{De};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var Zr=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],Qr=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],ei=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],ti=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function ni(e){switch(e){case"strict":return Qr;case"readonly":return ei;case"simplified":return ti;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class fn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...Zr);if(e.presets)for(let r of e.presets)this.rules.push(...ni(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function U(e={rules:[]}){return new fn(e)}var go=U({rules:[]}),ho=U({rules:[],presets:["strict"]});function dt(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var yo={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
3
- export{Zr,Qr,ei,ti,ni,fn,U,go,ho,dt,yo};
2
+ var ri=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],ii=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],si=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],oi=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function ai(e){switch(e){case"strict":return ii;case"readonly":return si;case"simplified":return oi;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class yn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...ri);if(e.presets)for(let r of e.presets)this.rules.push(...ai(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function K(e={rules:[]}){return new yn(e)}var wo=K({rules:[]}),xo=K({rules:[],presets:["strict"]});function wt(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var Co={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
3
+ export{ri,ii,si,oi,ai,yn,K,wo,xo,wt,Co};
@@ -0,0 +1,31 @@
1
+ // @bun
2
+ import{g,Z,xt,u}from"./chunk-73dzve1s.js";import{B}from"./chunk-pga5m4wm.js";import{R,M}from"./chunk-sd8bywh9.js";import{P,D}from"./chunk-83qnrx0m.js";import{r}from"./chunk-jcckwgb9.js";import{we}from"./chunk-g2120ysy.js";import{e,A}from"./chunk-yay68832.js";import{Ce,k,Sn,V}from"./chunk-p9vfxn8g.js";import{hn}from"./chunk-wnqg6hem.js";import{Ge,mt}from"./chunk-tka2m4af.js";import{E}from"./chunk-ebjafajx.js";import{ye,J,G,be}from"./chunk-davy89dj.js";import{Ve,_,H,gt,ht,yt,bt}from"./chunk-7tremqhs.js";import{z,de}from"./chunk-kfk554fj.js";import{_e,pt}from"./chunk-vkahj2ab.js";import{U}from"./chunk-rbx6q1r0.js";import{xn,ze}from"./chunk-ghfd34r7.js";import{pe}from"./chunk-mkakbjvs.js";import{We}from"./chunk-0k0fhq13.js";import{he}from"./chunk-bxc2herz.js";import{l}from"./chunk-y1g6v96c.js";import{K,wt}from"./chunk-0yg5mcrf.js";import{mkdir as xe}from"fs/promises";import{availableParallelism as Pe}from"os";import{basename as fe,dirname as me,relative as j,resolve as ie}from"path";var oe=new WeakMap,ce=new WeakMap;function se(d){let a=oe.get(d);if(!a)a=Ce(d),oe.set(d,a),a.catch(()=>oe.delete(d));return a}async function le(d,a,t,f,w,h=_){let o=fe(d)||"output.d.ts",C=j(me(d),a),W=`${o}.map`,Y=t.lastIndexOf(`
3
+ ${Ve()}`),p=Y===-1?t:t.slice(0,Y),y=yt(p,o,C,f),b=`${d}.map`;return await h(b,JSON.stringify(y)),e.debug(` Generated source map: ${j(w,b)}`),W}async function s(d){let a=Date.now(),t={...E,...d};if(t.logLevel)A(t.logLevel);else if(t.verbose)A("debug");let f=new he;if(t.plugins&&t.plugins.length>0){for(let n of t.plugins)f.register(n),e.debug(`Registered plugin: ${n.name}`);t=await f.runOnStart(t)}if(t.moduleSpecifierMode!==void 0&&t.moduleSpecifierMode!=="preserve"&&t.moduleSpecifierMode!=="node")throw Error("moduleSpecifierMode must be preserve or node");if(await z(t),t.isolatedDeclarations===void 0)t.isolatedDeclarations=await H(t);let w=t.typeMappings?K(t.typeMappings):void 0,h=null,o={generationMode:t.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},C=0;e.debug("Starting DTS generation..."),e.debug(`Using ${o.generationMode} declaration generation path`),e.debug("Config:",t);let W=await ye(t,()=>se(t)),Y=W.entryFiles,p=[...W.files],{resolver:y,reachability:b}=W;if(ce.set(t,new Set(p)),t.incremental){let n=W.getResolutionFingerprint();if(!t.isolatedDeclarations){let i=new Set(p),m=new Map;for(let S of p){let T=await u(S);m.set(S,ze(T));for(let te of k(T,{includeImports:!0})){let O=y(te.specifier,S).resolved;if(O&&!O.split(/[/\\]/).includes("node_modules")&&!i.has(O))i.add(O),m.set(O,ze(await u(O)))}}let c=[...m].sort(([S],[T])=>S.localeCompare(T));n=JSON.stringify([n,c])}if(h=new Ge(t,n),t.clearCache){if(e.debug("Clearing build cache..."),!t.dryRun)h.clear()}else if(h.load()){let m=h.getStats();e.debug(`Loaded build cache with ${m.entries} entries`)}else e.debug("No existing build cache found, starting fresh");if(!t.dryRun)mt(t.cwd)}if(h&&!t.dryRun){let n=h.prune(new Set(p),t.cwd);if(n>0)e.debug(`Pruned ${n} deleted files from cache`)}if(e.debug(`Found ${p.length} TypeScript files`),t.progress&&p.length>0){let n=t.parallel?"parallel":"sequential";e.info(`Processing ${p.length} files (${n})...`)}let L=new Map,N=new Map,v=async(n,i,m="lf")=>{N.set(n,{content:i,lineEnding:m})},x=async(n,i)=>{let m;try{let c=G(n,t),S=async(F)=>{if(!t.diff)return;try{let Q=await u(c),X=ht(Q,F,j(t.cwd,c));if(X)e.info(`
4
+ ${X}`);else e.debug(`[no changes] ${c}`)}catch{e.info(`[new file] ${j(t.cwd,c)}`)}},T=(F)=>{if(!t.validate)return 0;let Q=gt(F,c);if(Q.isValid)return e.debug(`[validation] ${c} - OK`),0;e.warn(`[validation] ${j(t.cwd,c)} has ${Q.errors.length} error(s):`);for(let X of Q.errors){let ae=` Line ${X.line}:${X.column}`;if(X.code)ae+=` [${X.code}]`;if(ae+=` - ${X.message}`,e.warn(ae),X.suggestion)e.warn(` Suggestion: ${X.suggestion}`)}return Q.errors.length},te=(F)=>{e.info(`[dry-run] Would generate: ${c}`),e.debug("--- Content preview ---"),e.debug(F.slice(0,500)+(F.length>500?`
5
+ ...`:"")),e.debug("--- End preview ---")};if(h){let F=h.getCachedIfValid(n,t.cwd);if(F){if(t.bundle)L.set(n,F);await S(F);let Q=T(F);if(t.dryRun)te(F);else{if(t.declarationMap)m=i??await u(n),await le(c,n,F,m,t.cwd,v);await v(c,F,t.lineEnding)}return e.debug(`[cached] ${j(t.cwd,c)}`),{success:!0,file:n,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:Q}}}m=i??await u(n);let{content:O,declarationCount:$e,importCount:ve,exportCount:Ee}=await Se(n,m,t,f,w,W.augmentationImports.get(n));if(t.bundle)L.set(n,O);let q=O;if(t.prettier||t.indentStyle||t.indentSize){let F=await U(q,{usePrettier:t.prettier,builtIn:{indentSize:t.indentSize||2,useTabs:t.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},c);q=F.content;for(let Q of F.warnings??[])e.warn(`[format] ${Q}`)}if(t.declarationMap){let F=`${fe(c)||"output.d.ts"}.map`;q=bt(q,F)}await S(q);let De=T(q);if(t.dryRun)te(q);else{if(t.declarationMap&&m)await le(c,n,q,m,t.cwd,v);if(await v(c,q,t.lineEnding),h&&m)h.update(n,m,q,t.cwd);e.debug(`Generated: ${c}`)}return{success:!0,file:n,declarationCount:$e,importCount:ve,exportCount:Ee,validationErrorCount:De}}catch(c){let S=_e(c,n,m);if(t.plugins&&t.plugins.length>0)await f.runOnError(c instanceof Error?c:Error(String(c)),n,m||"");return{success:!1,file:n,declarationCount:0,importCount:0,exportCount:0,dtsError:S,validationErrorCount:0}}},I=t.parallel||t.parallel!==!1&&p.length>=10,ee=B(t.concurrency,Pe?.()??8),ne=new Map;if(I&&p.length>1){let n=p.map(async(i)=>{try{let m=await u(i);return{file:i,source:m}}catch{return{file:i,source:null}}});for(let i of await Promise.all(n))if(i.source!==null)ne.set(i.file,i.source)}let re=(n)=>{if(o.filesProcessed++,n.success){if(n.cached)C++;else o.filesGenerated++,o.declarationsFound+=n.declarationCount,o.importsProcessed+=n.importCount,o.exportsProcessed+=n.exportCount;if(t.validate){if(o.filesValidated++,n.validationErrorCount)o.validationErrors+=n.validationErrorCount}}else if(o.filesFailed++,n.dtsError){o.errors.push(n.dtsError);let i=pt(n.dtsError);if(t.continueOnError)e.warn(i);else throw e.error(i),Error(n.dtsError.message)}};if(I)for(let n=0;n<p.length;n+=ee){let i=p.slice(n,n+ee),m=await Promise.all(i.map((c)=>x(c,ne.get(c))));for(let c of m)re(c);if(t.progress){let c=Math.round(o.filesProcessed/p.length*100);e.info(`[${o.filesProcessed}/${p.length}] ${c}%`)}}else for(let n of p){let i=await x(n);if(re(i),t.progress){let m=Math.round(o.filesProcessed/p.length*100),c=i.cached?"[cached]":"";e.info(`[${o.filesProcessed}/${p.length}] ${m}% - ${j(t.cwd,n)} ${c}`)}}if(!t.bundle){let n=[];if(b)for(let i of b.unresolved)n.push({from:i.from,specifier:i.specifier,reason:"missing"});if(t.autoIncludeReExports===!1&&p.length>0){let i=new Set(p);for(let m of p){let c;try{c=await u(m)}catch{continue}for(let S of k(c)){let T=y(S.specifier,m);if(!T.isRelative)continue;if(!T.resolved)n.push({from:m,specifier:S.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(T.resolved)&&!i.has(T.resolved))n.push({from:m,specifier:S.specifier,reason:"not-emitted"})}}}if(n.length>0){let i=[];i.push(`Found ${n.length} re-export(s) pointing at siblings that won't be in the output:`);for(let c of n){let S=j(t.cwd,c.from);if(c.reason==="missing")i.push(` ${S} \u2192 '${c.specifier}' (path not found on disk)`);else i.push(` ${S} \u2192 '${c.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let m=i.join(`
6
+ `);if(t.failOnUnresolvedReExport)throw Error(m);e.warn(m),e.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(t.bundle&&(o.filesGenerated>0||C>0)&&Y.length>0)try{e.debug("Bundling declarations...");let n=Y.length===1&&!!t.bundleOutput;for(let i of Y){let m=await V([i],{includeImports:!0,resolveSpecifier:y}),c=new Set;for(let O of m.reachable){if(O.endsWith(".d.ts"))continue;if(O.includes("node_modules"))continue;c.add(O)}let S=p.filter((O)=>c.has(O));if(!S.includes(i))S.push(i);let T=hn(i,S,L,{cwd:t.cwd,keepComments:t.keepComments});for(let O of new Set(T.warnings))e.warn(`[bundle] ${O}`);let te=n?ie(t.cwd,t.outdir,t.bundleOutput):G(i,t);if(t.dryRun)e.info(`[dry-run] Would bundle ${T.files.length} files to: ${j(t.cwd,te)}`);else await v(te,T.content,t.lineEnding),e.debug(`Prepared ${T.files.length} bundled files for: ${j(t.cwd,te)}`);if(n)break}}catch(n){let i=n instanceof Error?n.message:String(n);throw e.error(`Bundle failed: ${i}`),n}if(!t.dryRun)await de(t,N);if(h&&!t.dryRun)h.save(),e.debug("Saved build cache");if(o.durationMs=Date.now()-a,t.stats)if(t.outputFormat==="json")console.log(JSON.stringify(o,null,2));else{if(e.info(`
7
+ --- Generation Statistics ---`),e.info(`Files processed: ${o.filesProcessed}`),e.info(`Files generated: ${o.filesGenerated}`),C>0)e.info(`Files cached: ${C}`);if(o.filesFailed>0)e.info(`Files failed: ${o.filesFailed}`);if(e.info(`Declarations found: ${o.declarationsFound}`),e.info(`Imports processed: ${o.importsProcessed}`),e.info(`Exports processed: ${o.exportsProcessed}`),o.filesValidated>0){if(e.info(`Files validated: ${o.filesValidated}`),o.validationErrors>0)e.info(`Validation errors: ${o.validationErrors}`)}if(e.info(`Duration: ${o.durationMs}ms`),o.errors.length>0){e.info(`
8
+ Errors:`);for(let n of o.errors){let i=` - ${n.file}`;if(n.location)i+=`:${n.location.line}:${n.location.column}`;if(n.code)i+=` [${n.code}]`;if(i+=`: ${n.message}`,e.info(i),n.suggestion)e.info(` Suggestion: ${n.suggestion}`)}}e.info(`-----------------------------
9
+ `)}if(t.plugins&&t.plugins.length>0)await f.runOnEnd(o);return e.debug("DTS generation complete!"),o}async function Me(d,a,t){let f=await se(t),w=be(a,t,f,ce.get(t));return Sn(d,(h)=>w(h).emittedSpecifier)}async function Ys(d,a){oe.delete(a),ce.delete(a);let t=await se(a),f=await V([d],{includeImports:!0,resolveSpecifier:t}),w=await we([...f.sources.keys()],t,a.isolatedDeclarations??!1,f.sources);return(await ge(d,a,void 0,w.get(ie(d)))).content}async function ge(d,a,t,f){let w=await u(d),h=a.typeMappings?K(a.typeMappings):void 0;return Se(d,w,a,t,h,f)}async function Se(d,a,t,f,w,h){let o=a;if(f)o=await f.runOnBeforeFile(d,a);let C=new Map;if(!t.isolatedDeclarations){let v=await se(t);for(let x of k(o,{includeImports:!0})){let I=v(x.specifier,d).resolved;if(I&&!I.split(/[/\\]/).includes("node_modules"))C.set(x.specifier,await u(I))}}let W=f?.hasDeclarationHooks()?null:Re(o,d,t,C,h);if(W!==null)return ue(W,d,o,t,f,w,Fe(W));let Y=C.size?xn(o,C):void 0,p=r(o,d,t.keepComments,t.isolatedDeclarations??!1,Y);if(f)p=await f.runOnDeclarations(d,o,p);let y=0,b=0;for(let v=0;v<p.length;v++){let x=p[v];if(x.kind==="import")y++;if(x.kind==="export"||x.isExported)b++}let N=l(p,{filePath:d,sourceCode:o,declarations:p,augmentationImports:h},t.keepComments,t.importOrder);return ue(N,d,o,t,f,w,{declarationCount:p.length,importCount:y,exportCount:b})}function Fe(d){let a=0,t=0,f=0;for(let w of d.split(`
10
+ `)){if(!w||w.startsWith(" ")||w.startsWith("\t")||w.startsWith("}")||w.startsWith("*")||w.startsWith("/"))continue;if(a++,w.startsWith("import "))t++;else if(w.startsWith("export "))f++}return{declarationCount:a,importCount:t,exportCount:f}}function Re(d,a,t,f,w){let h=t.importOrder??["bun"];if(h.length!==1||h[0]!=="bun")return null;let o=R(a)?M(d):P(a)?D(d):d;return pe(o,{keepComments:t.keepComments??!0,isolatedDeclarations:t.isolatedDeclarations??!1,sourceFile:a,inferenceSources:f,augmentationImports:w})}async function ue(d,a,t,f,w,h,o){let C=await Me(d,a,f);if(h)C=wt(C,h,{filePath:a});if(f.normalizeOutput===!0||f.declarationOrder)C=We(C,{lineEnding:"lf",declarationOrder:f.declarationOrder,indent:{style:f.indentStyle??"spaces",size:f.indentSize??2}});if(w)C=await w.runOnAfterFile(a,t,C);return{content:C,...o}}async function Xs(d){let a={...E,...d};if(a.logLevel)A(a.logLevel);let t=ie(a.cwd,a.root),f=150,w=5,h=1e4,o={pendingChanges:new Set,debounceTimer:null,isProcessing:!1,errorCount:0,lastErrorTime:0};e.info(`Watching for changes in ${t}...`),e.info(`Press Ctrl+C to stop
11
+ `);try{await s(a),e.info(`[watch] Initial generation complete
12
+ `)}catch(y){let b=y instanceof Error?y.message:String(y);e.error(`[watch] Initial generation failed: ${b}`),e.info(`[watch] Continuing to watch for changes...
13
+ `)}async function C(){if(o.isProcessing||o.pendingChanges.size===0)return;let y=Date.now();if(o.errorCount>=w){if(y-o.lastErrorTime<h){e.warn(`[watch] Too many errors, pausing for ${Math.ceil((h-(y-o.lastErrorTime))/1000)}s...`);return}o.errorCount=0}o.isProcessing=!0;let b=Array.from(o.pendingChanges);o.pendingChanges.clear();let L=new Date().toLocaleTimeString();if(b.length===1)e.info(`
14
+ [${L}] File changed: ${b[0]}`);else e.info(`
15
+ [${L}] ${b.length} files changed`);let N=0,v=0;for(let x of b){let I=ie(t,x);try{let ee=a.exclude||[];if(J(I,ee,t)){e.debug(` Skipping excluded file: ${x}`);continue}if(!await Z(I).exists()){e.debug(` Skipping deleted file: ${x}`);continue}let re=G(I,a),{content:n}=await ge(I,a);await xe(me(re),{recursive:!0}),await _(re,n,a.lineEnding),e.info(` \u2713 ${j(a.cwd,re)}`),N++}catch(ee){v++,o.errorCount++,o.lastErrorTime=Date.now();let ne=_e(ee,I);if(e.error(` \u2717 ${x}: ${ne.message}`),ne.suggestion)e.error(` Suggestion: ${ne.suggestion}`)}}if(b.length>1)e.info(` Done: ${N} generated, ${v} failed`);if(v===0)o.errorCount=0;if(o.isProcessing=!1,o.pendingChanges.size>0)o.debounceTimer=setTimeout(C,f)}function W(y){if(o.pendingChanges.add(y),o.debounceTimer)clearTimeout(o.debounceTimer);o.debounceTimer=setTimeout(C,f)}let p=xt([g?"bun":"node","-e",`
16
+ const fs = require('fs');
17
+
18
+ const rootPath = '${t}';
19
+
20
+ fs.watch(rootPath, { recursive: true }, (eventType, filename) => {
21
+ if (filename && /.(?:[cm]?[jt]sx?|vue|stx)$/.test(filename) && !/.d.(?:ts|mts|cts)$/.test(filename)) {
22
+ console.log(\`CHANGED:\${filename}\`);
23
+ }
24
+ });
25
+
26
+ // Keep process alive
27
+ setInterval(() => {}, 1000);
28
+ `],{stdout:"pipe",stderr:"inherit"});if(g){let y=p.stdout.getReader(),b=new TextDecoder,L="";while(!0){let{done:N,value:v}=await y.read();if(N)break;L+=b.decode(v,{stream:!0});let x=L.split(`
29
+ `);L=x.pop()||"";for(let I of x)if(I.startsWith("CHANGED:")){let ee=I.slice(8);W(ee)}}}else{let y=p.stdout,b="";y.on("data",(L)=>{b+=L.toString();let N=b.split(`
30
+ `);b=N.pop()||"";for(let v of N)if(v.startsWith("CHANGED:")){let x=v.slice(8);W(x)}}),await p.exited}}
31
+ export{s,Ys,Xs};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{R,M}from"./chunk-sd8bywh9.js";import{P,D}from"./chunk-83qnrx0m.js";import{Jn}from"./chunk-1j6092xz.js";import{p}from"./chunk-v6fwy63g.js";import{T,O}from"./chunk-yx1jy7fx.js";var y=100,h=0,s=new Map;function Se(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 En(){s.clear(),Jn()}
3
+ export{Se,En};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{t}from"./chunk-1j6092xz.js";function Pe(e,d){let i=t(e),o=0,r=0;for(let n=0;n<i.length;n++){let l=i[n],s=e.slice(l.start,l.end),c=i[n+1];if(o===0&&s==="function"&&c?.kind==="word"&&e.slice(c.start,c.end)===d)r++;if(["{","(","["].includes(s))o++;else if(["}",")","]"].includes(s))o--}return r}
3
- export{Pe};
2
+ import{t}from"./chunk-1j6092xz.js";function Re(e,d){let i=t(e),o=0,r=0;for(let n=0;n<i.length;n++){let l=i[n],s=e.slice(l.start,l.end),c=i[n+1];if(o===0&&s==="function"&&c?.kind==="word"&&e.slice(c.start,c.end)===d)r++;if(["{","(","["].includes(s))o++;else if(["}",")","]"].includes(s))o--}return r}
3
+ export{Re};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class Nt{config;profiles=[];cleanupTimer=null;constructor(e={}){this.config={maxMemoryMB:e.maxMemoryMB??512,chunkSize:e.chunkSize??65536,aggressiveGC:e.aggressiveGC??!0,maxDeclarationsInMemory:e.maxDeclarationsInMemory??1e4,profile:e.profile??!1,cleanupInterval:e.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let e=process.memoryUsage();return{heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers,rss:e.rss,heapUsedMB:Math.ceil(e.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(e.heapUsed/e.heapTotal*100))}}async profile(e,t){if(!this.config.profile)return t();let r=this.getMemoryStats(),i=Date.now();try{return await t()}finally{let n=this.getMemoryStats(),s=Date.now()-i;this.profiles.push({timestamp:Date.now(),operation:e,memoryBefore:r,memoryAfter:n,duration:s})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(e){let t=l(e,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),r=u({input:t,crlfDelay:1/0});for await(let i of r)yield i}async processFileInChunks(e,t,r=1000){let i=[],n=[];for await(let s of this.streamFile(e))if(n.push(s),n.length>=r){let a=await t(n);i.push(...a),n=[],this.checkMemoryAndCleanup()}if(n.length>0){let s=await t(n);i.push(...s)}return i}async streamWrite(e,t){let r=c(e,{encoding:"utf-8"});return new Promise((i,n)=>{let s=async()=>{try{for await(let a of t)if(!r.write(a))await new Promise((o)=>r.once("drain",()=>o()));r.end(),r.once("finish",i)}catch(a){n(a)}};r.once("error",n),s()})}}class ir{declarations=new Map;registry=new FinalizationRegistry((e)=>{this.declarations.delete(e)});maxSize;constructor(e=1e4){this.maxSize=e}add(e,t){if(this.declarations.size>=this.maxSize)this.evictOldest();let r=new WeakRef(t);this.declarations.set(e,r),this.registry.register(t,e)}get(e){return this.declarations.get(e)?.deref()}has(e){return this.declarations.get(e)?.deref()!==void 0}delete(e){this.declarations.delete(e)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let e=Math.ceil(this.maxSize*0.2),t=Array.from(this.declarations.keys());for(let r=0;r<e&&r<t.length;r++)this.declarations.delete(t[r])}}class sr{value=null;loaded=!1;loader;constructor(e){this.loader=e}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class or{strings=new Map;maxSize;constructor(e=50000){this.maxSize=e}intern(e){if(e.length>100)return e;let t=this.strings.get(e);if(t!==void 0)return t;if(this.strings.size>=this.maxSize){let r=Array.from(this.strings.keys());for(let i=0;i<r.length/2;i++)this.strings.delete(r[i])}return this.strings.set(e,e),e}get size(){return this.strings.size}clear(){this.strings.clear()}}class ar{pool=[];factory;reset;maxSize;constructor(e,t,r=1000){this.factory=e,this.reset=t,this.maxSize=r}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(e){if(this.pool.length<this.maxSize)this.reset(e),this.pool.push(e)}get size(){return this.pool.length}clear(){this.pool=[]}}function Pi(e,t={}){return{...e,memory:{maxMemoryMB:t.maxMemoryMB??512,chunkSize:t.chunkSize??65536,aggressiveGC:t.aggressiveGC??!0,maxDeclarationsInMemory:t.maxDeclarationsInMemory??1e4,profile:t.profile??!1,cleanupInterval:t.cleanupInterval??5000}}}function Di(e){let r=m(e).size/1024/1024,i=r*4,n=65536;if(r>10)n=32768;if(r>50)n=16384;return{fileSizeMB:Math.round(r*100)/100,estimatedMemoryMB:Math.round(i*100)/100,recommendedChunkSize:n}}function Ri(e){return[`Heap: ${e.heapUsedMB}MB / ${Math.round(e.heapTotal/1024/1024)}MB (${e.percentUsed}%)`,`RSS: ${Math.round(e.rss/1024/1024)}MB`,`External: ${Math.round(e.external/1024/1024)}MB`].join(" | ")}function Mi(e={}){return new Nt(e)}
3
- export{Nt,ir,sr,or,ar,Pi,Di,Ri,Mi};
2
+ import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class Gt{config;profiles=[];cleanupTimer=null;constructor(e={}){this.config={maxMemoryMB:e.maxMemoryMB??512,chunkSize:e.chunkSize??65536,aggressiveGC:e.aggressiveGC??!0,maxDeclarationsInMemory:e.maxDeclarationsInMemory??1e4,profile:e.profile??!1,cleanupInterval:e.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let e=process.memoryUsage();return{heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers,rss:e.rss,heapUsedMB:Math.ceil(e.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(e.heapUsed/e.heapTotal*100))}}async profile(e,t){if(!this.config.profile)return t();let r=this.getMemoryStats(),i=Date.now();try{return await t()}finally{let n=this.getMemoryStats(),s=Date.now()-i;this.profiles.push({timestamp:Date.now(),operation:e,memoryBefore:r,memoryAfter:n,duration:s})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(e){let t=l(e,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),r=u({input:t,crlfDelay:1/0});for await(let i of r)yield i}async processFileInChunks(e,t,r=1000){let i=[],n=[];for await(let s of this.streamFile(e))if(n.push(s),n.length>=r){let a=await t(n);i.push(...a),n=[],this.checkMemoryAndCleanup()}if(n.length>0){let s=await t(n);i.push(...s)}return i}async streamWrite(e,t){let r=c(e,{encoding:"utf-8"});return new Promise((i,n)=>{let s=async()=>{try{for await(let a of t)if(!r.write(a))await new Promise((o)=>r.once("drain",()=>o()));r.end(),r.once("finish",i)}catch(a){n(a)}};r.once("error",n),s()})}}class hr{declarations=new Map;registry=new FinalizationRegistry((e)=>{this.declarations.delete(e)});maxSize;constructor(e=1e4){this.maxSize=e}add(e,t){if(this.declarations.size>=this.maxSize)this.evictOldest();let r=new WeakRef(t);this.declarations.set(e,r),this.registry.register(t,e)}get(e){return this.declarations.get(e)?.deref()}has(e){return this.declarations.get(e)?.deref()!==void 0}delete(e){this.declarations.delete(e)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let e=Math.ceil(this.maxSize*0.2),t=Array.from(this.declarations.keys());for(let r=0;r<e&&r<t.length;r++)this.declarations.delete(t[r])}}class yr{value=null;loaded=!1;loader;constructor(e){this.loader=e}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class br{strings=new Map;maxSize;constructor(e=50000){this.maxSize=e}intern(e){if(e.length>100)return e;let t=this.strings.get(e);if(t!==void 0)return t;if(this.strings.size>=this.maxSize){let r=Array.from(this.strings.keys());for(let i=0;i<r.length/2;i++)this.strings.delete(r[i])}return this.strings.set(e,e),e}get size(){return this.strings.size}clear(){this.strings.clear()}}class wr{pool=[];factory;reset;maxSize;constructor(e,t,r=1000){this.factory=e,this.reset=t,this.maxSize=r}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(e){if(this.pool.length<this.maxSize)this.reset(e),this.pool.push(e)}get size(){return this.pool.length}clear(){this.pool=[]}}function ds(e,t={}){return{...e,memory:{maxMemoryMB:t.maxMemoryMB??512,chunkSize:t.chunkSize??65536,aggressiveGC:t.aggressiveGC??!0,maxDeclarationsInMemory:t.maxDeclarationsInMemory??1e4,profile:t.profile??!1,cleanupInterval:t.cleanupInterval??5000}}}function ps(e){let r=m(e).size/1024/1024,i=r*4,n=65536;if(r>10)n=32768;if(r>50)n=16384;return{fileSizeMB:Math.round(r*100)/100,estimatedMemoryMB:Math.round(i*100)/100,recommendedChunkSize:n}}function ms(e){return[`Heap: ${e.heapUsedMB}MB / ${Math.round(e.heapTotal/1024/1024)}MB (${e.percentUsed}%)`,`RSS: ${Math.round(e.rss/1024/1024)}MB`,`External: ${Math.round(e.external/1024/1024)}MB`].join(" | ")}function gs(e={}){return new Gt(e)}
3
+ export{Gt,hr,yr,br,wr,ds,ps,ms,gs};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var Ht=["builtin","external","internal","parent","sibling","index","type","unknown"];function Kt(e){let i=e.match(/^(import\s+)(type\s+)?(.+?)\s+from\s+['"]([^'"]+)['"]/);if(!i){let p=e.match(/^import\s+['"]([^'"]+)['"]/);if(p)return{statement:e,source:p[1],isTypeOnly:!1,group:ct(p[1]),specifiers:[]};return null}let[,,u,l,c]=i,g=!!u,m,h,f=[],n=l.trim(),a=n.match(/^\*\s+as\s+(\w+)$/);if(a)h=a[1];else if(n.includes("{")){let p=n.match(/^(\w+)\s*,/);if(p)m=p[1];let d=n.match(/\{([^}]+)\}/);if(d){let I=d[1].split(",").map((y)=>y.trim()).filter(Boolean);f.push(...I)}}else if(/^\w+$/.test(n))m=n;else{let p=n.match(/\{([^}]+)\}/);if(p){let d=p[1].split(",").map((I)=>I.trim()).filter(Boolean);f.push(...d)}}return{statement:e,source:c,isTypeOnly:g,group:ct(c,g),specifiers:f,defaultImport:m,namespaceImport:h}}function ct(e,i=!1){if(i)return"type";if(e.startsWith("node:")||O(e))return"builtin";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e==="."||e==="./index")return"index";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@")||/^[a-z]/.test(e))return"external";return"unknown"}var b=new Set(["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"]);function O(e){return b.has(e)}function qt(e,i={}){let{order:u=[],groupByType:l=!0,groups:c=Ht,alphabetize:g=!0,caseInsensitive:m=!0,typeImportsLast:h=!1,separateTypeImports:f=!1}=i,n=[];for(let t of e){let r=Kt(t);if(r)n.push(r);else n.push({statement:t,source:"",isTypeOnly:!1,group:"unknown",specifiers:[]})}let a=u.length>0?u.map((t)=>{if(t.startsWith("^"))try{return{regex:new RegExp(t),prefix:t.slice(1)}}catch{return{prefix:t.slice(1)}}return{prefix:t}}):[],p=(t)=>{for(let r=0;r<a.length;r++){let s=a[r];if(s.regex){if(s.regex.test(t))return r}else if(t.startsWith(s.prefix)||t.includes(`/${s.prefix}`))return r}return a.length},d=new Map,I=(t)=>{let r=d.get(t);if(r!==void 0)return r;let s=c.indexOf(t),o=s>=0?s:c.length;return d.set(t,o),o},y=(t,r)=>{if(a.length>0){let s=p(t.source),o=p(r.source);if(s!==o)return s-o}if(l){let s=I(t.group),o=I(r.group);if(s!==o)return s-o}if(h&&t.isTypeOnly!==r.isTypeOnly)return t.isTypeOnly?1:-1;if(g){let s=m?t.source.toLowerCase():t.source,o=m?r.source.toLowerCase():r.source;return s.localeCompare(o)}return 0};if(n.sort(y),l){let t=[],r=null;for(let s of n){if(r!==null&&s.group!==r){let o=c.indexOf(r),x=c.indexOf(s.group);if(o>=0&&x>=0&&o!==x)t.push("")}t.push(s.statement),r=s.group}return t}return n.map((t)=>t.statement)}function Er(e,i={}){let u=e.split(`
3
- `),l=[],c=[],g=-1;for(let n=0;n<u.length;n++){let a=u[n].trim();if(a.startsWith("import "))l.push(u[n]),c.push(n),g=n;else if(l.length>0&&a==="")continue;else if(l.length>0&&!a.startsWith("import "))break}if(l.length===0)return e;let m=qt(l,i),h=u.slice(0,c[0]),f=u.slice(g+1);while(f.length>0&&f[0].trim()==="")f.shift();return[...h,...m,"",...f].join(`
4
- `)}function ss(e={}){return{sort:(i)=>qt(i,e),sortContent:(i)=>Er(i,e),parse:Kt,detectGroup:ct}}var os={default:{groupByType:!0,groups:Ht,alphabetize:!0,caseInsensitive:!0},node:{order:["node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},bun:{order:["bun","node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},typeSeparated:{groupByType:!0,groups:["builtin","external","internal","parent","sibling","index","type"],separateTypeImports:!0,alphabetize:!0},alphabetical:{groupByType:!1,alphabetize:!0,caseInsensitive:!0},none:{groupByType:!1,alphabetize:!1}};
5
- export{Ht,Kt,ct,qt,Er,ss,os};
2
+ var Vt=["builtin","external","internal","parent","sibling","index","type","unknown"];function Ut(e){let i=e.match(/^(import\s+)(type\s+)?(.+?)\s+from\s+['"]([^'"]+)['"]/);if(!i){let p=e.match(/^import\s+['"]([^'"]+)['"]/);if(p)return{statement:e,source:p[1],isTypeOnly:!1,group:ct(p[1]),specifiers:[]};return null}let[,,u,l,c]=i,g=!!u,m,h,f=[],n=l.trim(),a=n.match(/^\*\s+as\s+(\w+)$/);if(a)h=a[1];else if(n.includes("{")){let p=n.match(/^(\w+)\s*,/);if(p)m=p[1];let d=n.match(/\{([^}]+)\}/);if(d){let I=d[1].split(",").map((y)=>y.trim()).filter(Boolean);f.push(...I)}}else if(/^\w+$/.test(n))m=n;else{let p=n.match(/\{([^}]+)\}/);if(p){let d=p[1].split(",").map((I)=>I.trim()).filter(Boolean);f.push(...d)}}return{statement:e,source:c,isTypeOnly:g,group:ct(c,g),specifiers:f,defaultImport:m,namespaceImport:h}}function ct(e,i=!1){if(i)return"type";if(e.startsWith("node:")||O(e))return"builtin";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e==="."||e==="./index")return"index";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@")||/^[a-z]/.test(e))return"external";return"unknown"}var b=new Set(["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"]);function O(e){return b.has(e)}function zt(e,i={}){let{order:u=[],groupByType:l=!0,groups:c=Vt,alphabetize:g=!0,caseInsensitive:m=!0,typeImportsLast:h=!1,separateTypeImports:f=!1}=i,n=[];for(let t of e){let r=Ut(t);if(r)n.push(r);else n.push({statement:t,source:"",isTypeOnly:!1,group:"unknown",specifiers:[]})}let a=u.length>0?u.map((t)=>{if(t.startsWith("^"))try{return{regex:new RegExp(t),prefix:t.slice(1)}}catch{return{prefix:t.slice(1)}}return{prefix:t}}):[],p=(t)=>{for(let r=0;r<a.length;r++){let s=a[r];if(s.regex){if(s.regex.test(t))return r}else if(t.startsWith(s.prefix)||t.includes(`/${s.prefix}`))return r}return a.length},d=new Map,I=(t)=>{let r=d.get(t);if(r!==void 0)return r;let s=c.indexOf(t),o=s>=0?s:c.length;return d.set(t,o),o},y=(t,r)=>{if(a.length>0){let s=p(t.source),o=p(r.source);if(s!==o)return s-o}if(l){let s=I(t.group),o=I(r.group);if(s!==o)return s-o}if(h&&t.isTypeOnly!==r.isTypeOnly)return t.isTypeOnly?1:-1;if(g){let s=m?t.source.toLowerCase():t.source,o=m?r.source.toLowerCase():r.source;return s.localeCompare(o)}return 0};if(n.sort(y),l){let t=[],r=null;for(let s of n){if(r!==null&&s.group!==r){let o=c.indexOf(r),x=c.indexOf(s.group);if(o>=0&&x>=0&&o!==x)t.push("")}t.push(s.statement),r=s.group}return t}return n.map((t)=>t.statement)}function vr(e,i={}){let u=e.split(`
3
+ `),l=[],c=[],g=-1;for(let n=0;n<u.length;n++){let a=u[n].trim();if(a.startsWith("import "))l.push(u[n]),c.push(n),g=n;else if(l.length>0&&a==="")continue;else if(l.length>0&&!a.startsWith("import "))break}if(l.length===0)return e;let m=zt(l,i),h=u.slice(0,c[0]),f=u.slice(g+1);while(f.length>0&&f[0].trim()==="")f.shift();return[...h,...m,"",...f].join(`
4
+ `)}function vs(e={}){return{sort:(i)=>zt(i,e),sortContent:(i)=>vr(i,e),parse:Ut,detectGroup:ct}}var Ss={default:{groupByType:!0,groups:Vt,alphabetize:!0,caseInsensitive:!0},node:{order:["node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},bun:{order:["bun","node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},typeSeparated:{groupByType:!0,groups:["builtin","external","internal","parent","sibling","index","type"],separateTypeImports:!0,alphabetize:!0},alphabetical:{groupByType:!1,alphabetize:!0,caseInsensitive:!0},none:{groupByType:!1,alphabetize:!1}};
5
+ export{Vt,Ut,ct,zt,vr,vs,Ss};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{t,d,x}from"./chunk-1j6092xz.js";var C={kind:"symbol"},K=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:[\d_]+(?:\.[\d_]*)?|\.[\d_]+)(?:[eE][+-]?[\d_]+)?)/,v={"|":1,"^":2,"&":3,"<<":4,">>":4,">>>":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},M=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"];function w(l,c,o=0){if(o>=64)return;let n=l.trim(),r=t(n);if(!r.length)return;if(r[0].start!==0||r[r.length-1].end!==n.length)return w(n.slice(r[0].start,r[r.length-1].end),c,o+1);if(r.length===1&&r[0].kind==="quoted")return d(n);if(r.length===1&&r[0].kind==="word"){let e=c.get(n);return typeof e==="object"?void 0:e}if(K.exec(n)?.[0].length===n.length){let e=Number(n.replaceAll("_",""));return Number.isFinite(e)?e:void 0}let i=0,a;for(let e=0;e<r.length;e++){let s=r[e],u=n.slice(s.start,s.end);if(s.kind!=="punctuation")continue;if(["(","[","{"].includes(u)){i++;continue}if([")","]","}"].includes(u)){i--;continue}let m=K.exec(n.slice(s.start));if(m){while(r[e+1]?.start<s.start+m[0].length)e++;continue}if(i)continue;let f=M.find((S)=>n.startsWith(S,s.start));if(!f)continue;let p=r[e-1],h=p?n.slice(p.start,p.end):"";if(!(!p||p.kind==="punctuation"&&![")","]"].includes(h)&&!/\d/.test(h))&&(!a||v[f]<a.priority||v[f]===a.priority&&f!=="**"))a={start:s.start,operator:f,priority:v[f]};while(r[e+1]?.start<s.start+f.length)e++}if(a){let e=w(n.slice(0,a.start),c,o+1),s=w(n.slice(a.start+a.operator.length),c,o+1);if(e===void 0||s===void 0)return;if(a.operator==="+"&&(typeof e==="string"||typeof s==="string"))return String(e)+String(s);if(typeof e!=="number"||typeof s!=="number")return;let u;switch(a.operator){case"+":u=e+s;break;case"-":u=e-s;break;case"*":u=e*s;break;case"/":u=e/s;break;case"%":u=e%s;break;case"**":u=e**s;break;case"<<":u=e<<s;break;case">>":u=e>>s;break;case">>>":u=e>>>s;break;case"|":u=e|s;break;case"^":u=e^s;break;case"&":u=e&s;break;default:return}return Number.isFinite(u)?u:void 0}if(n.startsWith("(")&&n.endsWith(")")){let e=0;if(r.every((u,m)=>{let f=n.slice(u.start,u.end);if(f==="(")e++;if(f===")")e--;return e!==0||m===r.length-1}))return w(n.slice(1,-1),c,o+1)}if(["+","-","~"].includes(n[0])){let e=w(n.slice(1),c,o+1);if(typeof e!=="number")return;return n[0]==="-"?-e:n[0]==="~"?~e:e}if(!n.startsWith("`")||!n.endsWith("`"))return;let y="",b=1;for(let e=1;e<n.length-1;e++){if(n[e]==="\\"){e++;continue}if(n[e]!=="$"||n[e+1]!=="{")continue;let s=d(`\`${n.slice(b,e)}\``);if(s===void 0)return;y+=s;let u=0,m=r.find((p)=>{if(p.start<e+2||p.kind!=="punctuation")return!1;let h=n.slice(p.start,p.end);if(h==="{")u++;if(h!=="}")return!1;if(u===0)return!0;return u--,!1});if(!m)return;let f=w(n.slice(e+2,m.start),c,o+1);if(f===void 0)return;y+=String(f),e=m.start,b=e+1}let g=d(`\`${n.slice(b,-1)}\``);return g===void 0?void 0:y+g}function Wn(l,c){let o=[...new Set([...l,...c.values()])];if(!o.some((i)=>i.kind==="variable"&&typeof i.value==="string"&&/[\[{]/.test(i.value)))return;o.sort((i,a)=>(i.start??0)-(a.start??0));let n=new Map,r=new Map,k=o.some((i)=>i.name==="Symbol");for(let i of o){if(i.kind!=="variable"||typeof i.value!=="string")continue;if(i.value.includes("{")||i.value.includes("[")){let g=new Map(n);g.mutableBindingTypes=new Map(r),i.computedKeyConstants=g}let a=t(i.value),y=a.length===1&&a[0].kind==="word"?n.get(i.value.slice(a[0].start,a[0].end)):void 0;if(i.typeAnnotation==="unique symbol"||i.typeAnnotation==="symbol"||typeof y==="object"||!k&&a[0]?.kind==="word"&&i.value.slice(a[0].start,a[0].end)==="Symbol"&&["(","."].includes(i.value.slice(a[1]?.start,a[1]?.end))){n.set(i.name,C);continue}if(i.modifiers?.[0]!=="const"||i.typeAnnotation||i.modifiers.includes("const assertion"))continue;let b=w(i.value,n);if(b!==void 0){if(n.set(i.name,b),!(a.length===1&&a[0].kind==="word")||r.has(i.value.trim()))r.set(i.name,typeof b)}else if(i.value.trim()==="true"||i.value.trim()==="false")r.set(i.name,"boolean");else if(a.length===1&&a[0].kind==="word"){let g=r.get(i.value.trim());if(g)r.set(i.name,g)}}}function jn(l,c){if(!l.trimStart().startsWith("[")||!l.includes("`"))return;let o=t(l);if(l[o[0]?.start]!=="["||l[o[1]?.start]!=="`"||l[o.at(-1)?.start??-1]!=="]")return;let n=l.slice(o[0].end,o.at(-1).start).trim(),r=w(n,c??new Map);return typeof r==="string"?{name:x(r,"'")}:{index:!0}}function _n(l,c){if(!c||!l.trimStart().startsWith("["))return!1;let o=t(l);return o.length===3&&l[o[0].start]==="["&&o[1].kind==="word"&&l[o[2].start]==="]"&&typeof c.get(l.slice(o[1].start,o[1].end))==="object"}function Gn(l){if(!l.trimStart().startsWith("[")||!l.includes("`"))return!1;let c=t(l);return l[c[1]?.start]==="`"&&c.some((o)=>o.kind==="punctuation"&&l[o.start]==="{")}
3
- export{w,Wn,jn,_n,Gn};
2
+ import{t,d,x}from"./chunk-1j6092xz.js";var C={kind:"symbol"},K=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:[\d_]+(?:\.[\d_]*)?|\.[\d_]+)(?:[eE][+-]?[\d_]+)?)/,v={"|":1,"^":2,"&":3,"<<":4,">>":4,">>>":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},M=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"];function w(l,c,o=0){if(o>=64)return;let n=l.trim(),r=t(n);if(!r.length)return;if(r[0].start!==0||r[r.length-1].end!==n.length)return w(n.slice(r[0].start,r[r.length-1].end),c,o+1);if(r.length===1&&r[0].kind==="quoted")return d(n);if(r.length===1&&r[0].kind==="word"){let e=c.get(n);return typeof e==="object"?void 0:e}if(K.exec(n)?.[0].length===n.length){let e=Number(n.replaceAll("_",""));return Number.isFinite(e)?e:void 0}let i=0,a;for(let e=0;e<r.length;e++){let s=r[e],u=n.slice(s.start,s.end);if(s.kind!=="punctuation")continue;if(["(","[","{"].includes(u)){i++;continue}if([")","]","}"].includes(u)){i--;continue}let m=K.exec(n.slice(s.start));if(m){while(r[e+1]?.start<s.start+m[0].length)e++;continue}if(i)continue;let f=M.find((S)=>n.startsWith(S,s.start));if(!f)continue;let p=r[e-1],h=p?n.slice(p.start,p.end):"";if(!(!p||p.kind==="punctuation"&&![")","]"].includes(h)&&!/\d/.test(h))&&(!a||v[f]<a.priority||v[f]===a.priority&&f!=="**"))a={start:s.start,operator:f,priority:v[f]};while(r[e+1]?.start<s.start+f.length)e++}if(a){let e=w(n.slice(0,a.start),c,o+1),s=w(n.slice(a.start+a.operator.length),c,o+1);if(e===void 0||s===void 0)return;if(a.operator==="+"&&(typeof e==="string"||typeof s==="string"))return String(e)+String(s);if(typeof e!=="number"||typeof s!=="number")return;let u;switch(a.operator){case"+":u=e+s;break;case"-":u=e-s;break;case"*":u=e*s;break;case"/":u=e/s;break;case"%":u=e%s;break;case"**":u=e**s;break;case"<<":u=e<<s;break;case">>":u=e>>s;break;case">>>":u=e>>>s;break;case"|":u=e|s;break;case"^":u=e^s;break;case"&":u=e&s;break;default:return}return Number.isFinite(u)?u:void 0}if(n.startsWith("(")&&n.endsWith(")")){let e=0;if(r.every((u,m)=>{let f=n.slice(u.start,u.end);if(f==="(")e++;if(f===")")e--;return e!==0||m===r.length-1}))return w(n.slice(1,-1),c,o+1)}if(["+","-","~"].includes(n[0])){let e=w(n.slice(1),c,o+1);if(typeof e!=="number")return;return n[0]==="-"?-e:n[0]==="~"?~e:e}if(!n.startsWith("`")||!n.endsWith("`"))return;let y="",b=1;for(let e=1;e<n.length-1;e++){if(n[e]==="\\"){e++;continue}if(n[e]!=="$"||n[e+1]!=="{")continue;let s=d(`\`${n.slice(b,e)}\``);if(s===void 0)return;y+=s;let u=0,m=r.find((p)=>{if(p.start<e+2||p.kind!=="punctuation")return!1;let h=n.slice(p.start,p.end);if(h==="{")u++;if(h!=="}")return!1;if(u===0)return!0;return u--,!1});if(!m)return;let f=w(n.slice(e+2,m.start),c,o+1);if(f===void 0)return;y+=String(f),e=m.start,b=e+1}let g=d(`\`${n.slice(b,-1)}\``);return g===void 0?void 0:y+g}function Vn(l,c){let o=[...new Set([...l,...c.values()])];if(!o.some((i)=>i.kind==="variable"&&typeof i.value==="string"&&/[\[{]/.test(i.value)))return;o.sort((i,a)=>(i.start??0)-(a.start??0));let n=new Map,r=new Map,k=o.some((i)=>i.name==="Symbol");for(let i of o){if(i.kind!=="variable"||typeof i.value!=="string")continue;if(i.value.includes("{")||i.value.includes("[")){let g=new Map(n);g.mutableBindingTypes=new Map(r),i.computedKeyConstants=g}let a=t(i.value),y=a.length===1&&a[0].kind==="word"?n.get(i.value.slice(a[0].start,a[0].end)):void 0;if(i.typeAnnotation==="unique symbol"||i.typeAnnotation==="symbol"||typeof y==="object"||!k&&a[0]?.kind==="word"&&i.value.slice(a[0].start,a[0].end)==="Symbol"&&["(","."].includes(i.value.slice(a[1]?.start,a[1]?.end))){n.set(i.name,C);continue}if(i.modifiers?.[0]!=="const"||i.typeAnnotation||i.modifiers.includes("const assertion"))continue;let b=w(i.value,n);if(b!==void 0){if(n.set(i.name,b),!(a.length===1&&a[0].kind==="word")||r.has(i.value.trim()))r.set(i.name,typeof b)}else if(i.value.trim()==="true"||i.value.trim()==="false")r.set(i.name,"boolean");else if(a.length===1&&a[0].kind==="word"){let g=r.get(i.value.trim());if(g)r.set(i.name,g)}}}function Un(l,c){if(!l.trimStart().startsWith("[")||!l.includes("`"))return;let o=t(l);if(l[o[0]?.start]!=="["||l[o[1]?.start]!=="`"||l[o.at(-1)?.start??-1]!=="]")return;let n=l.slice(o[0].end,o.at(-1).start).trim(),r=w(n,c??new Map);return typeof r==="string"?{name:x(r,"'")}:{index:!0}}function zn(l,c){if(!c||!l.trimStart().startsWith("["))return!1;let o=t(l);return o.length===3&&l[o[0].start]==="["&&o[1].kind==="word"&&l[o[2].start]==="]"&&typeof c.get(l.slice(o[1].start,o[1].end))==="object"}function Hn(l){if(!l.trimStart().startsWith("[")||!l.includes("`"))return!1;let c=t(l);return l[c[1]?.start]==="`"&&c.some((o)=>o.kind==="punctuation"&&l[o.start]==="{")}
3
+ export{w,Vn,Un,zn,Hn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{B}from"./chunk-pga5m4wm.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 wt(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 Y(e,n,t={}){let r=p(n);if(c.get(e)?.hash===r)return wt(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 bn(e,n={}){let t=new Map,r=B(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 Y(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function wn(){g++,c.clear(),a.clear(),u.clear()}function xn(){return c.size}function Cn(){return a.size}function vn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
3
- export{wt,Y,bn,wn,xn,Cn,vn};
2
+ import{B}from"./chunk-pga5m4wm.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 At(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 Q(e,n,t={}){let r=p(n);if(c.get(e)?.hash===r)return At(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 kn(e,n={}){let t=new Map,r=B(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 Q(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function Tn(){g++,c.clear(),a.clear(),u.clear()}function An(){return c.size}function Pn(){return a.size}function Dn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
3
+ export{At,Q,kn,Tn,An,Pn,Dn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var s=new Map,n=new Map;function ka(e){let t=s.get(e);if(t)return s.delete(e),s.set(e,t),t;let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`\\b${o}\\b`);if(s.set(e,c),s.size>500){let r=0;for(let i of s.keys()){if(r++>=50)break;s.delete(i)}}return c}function Ln(e){let t=n.get(e);if(t)return n.delete(e),n.set(e,t),t;return null}function Nn(e,t){if(n.set(e,t),n.size>200){let o=0;for(let c of n.keys()){if(o++>=20)break;n.delete(c)}}}function Bn(){s.clear(),n.clear()}
3
- export{ka,Ln,Nn,Bn};
2
+ var s=new Map,n=new Map;function ka(e){let t=s.get(e);if(t)return s.delete(e),s.set(e,t),t;let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`\\b${o}\\b`);if(s.set(e,c),s.size>500){let r=0;for(let i of s.keys()){if(r++>=50)break;s.delete(i)}}return c}function Nn(e){let t=n.get(e);if(t)return n.delete(e),n.set(e,t),t;return null}function Bn(e,t){if(n.set(e,t),n.size>200){let o=0;for(let c of n.keys()){if(o++>=20)break;n.delete(c)}}}function Wn(){s.clear(),n.clear()}
3
+ export{ka,Nn,Bn,Wn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{t}from"./chunk-1j6092xz.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 Hn(n){let s=[];return y(j(n),s),s}function Kn(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
- export{Hn,Kn};
2
+ import{t}from"./chunk-1j6092xz.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 Kn(n){let s=[];return y(j(n),s),s}function qn(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
+ export{Kn,qn};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{c,i}from"./chunk-zq93f8ca.js";import{g}from"./chunk-s6c98nad.js";import{h}from"./chunk-wnk9yjw2.js";function we(f){let r=new Set,n=[];for(let t of f)if(t.kind==="import")for(let o of h(t.text))r.add(o);else if(t.kind!=="unknown"){if(n.push(t.text),t.kind==="variable"){if(t.typeAnnotation)n.push(t.typeAnnotation);else if(t.value)n.push(g(t,!1))}}let e=n.join(`
2
+ import{c,i}from"./chunk-zq93f8ca.js";import{h}from"./chunk-xa6rsd4b.js";import{y}from"./chunk-vf3ybe5r.js";function xe(f){let r=new Set,n=[];for(let t of f)if(t.kind==="import")for(let o of y(t.text))r.add(o);else if(t.kind!=="unknown"){if(n.push(t.text),t.kind==="variable"){if(t.typeAnnotation)n.push(t.typeAnnotation);else if(t.value)n.push(h(t,!1))}}let e=n.join(`
3
3
  `),s=new Set;for(let t=0;t<e.length;){if(!c(e.charCodeAt(t))){t++;continue}let o=t++;while(t<e.length&&i(e.charCodeAt(t)))t++;let a=e.slice(o,t);if(r.has(a))s.add(a)}return{usedItems:s,referenceText:e}}
4
- export{we};
4
+ export{xe};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{e}from"./chunk-km8t8gqg.js";import{existsSync as h}from"fs";import{cpus as u}from"os";import{resolve as l}from"path";import{fileURLToPath as k}from"url";import{Worker as c}from"worker_threads";var __dirname="/Users/chris/Code/Tools/dtsx/packages/dtsx/src",a;function f(){if(a!==void 0)return a;a=null;for(let t of["./worker-thread.js","./worker-thread.ts","./src/worker-thread.js","./src/worker-thread.ts"]){let r=new URL(t,import.meta.url);try{if(h(k(r))){a=r;break}}catch{}}return a}class Lt{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(t={}){let r=t.maxWorkers??Math.max(1,u().length-1);this.config={maxWorkers:r,taskTimeout:t.taskTimeout??30000,recycleAfter:t.recycleAfter??100,idleTimeout:t.idleTimeout??1e4,initialWorkers:t.initialWorkers??Math.min(2,r)}}async init(){let t=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let r=0;r<t;r++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let t=`
2
+ import{e}from"./chunk-yay68832.js";import{existsSync as h}from"fs";import{cpus as u}from"os";import{resolve as l}from"path";import{fileURLToPath as k}from"url";import{Worker as c}from"worker_threads";var __dirname="/home/runner/work/dtsx/dtsx/packages/dtsx/src",a;function f(){if(a!==void 0)return a;a=null;for(let t of["./worker-thread.js","./worker-thread.ts","./src/worker-thread.js","./src/worker-thread.ts"]){let r=new URL(t,import.meta.url);try{if(h(k(r))){a=r;break}}catch{}}return a}class Nt{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(t={}){let r=t.maxWorkers??Math.max(1,u().length-1);this.config={maxWorkers:r,taskTimeout:t.taskTimeout??30000,recycleAfter:t.recycleAfter??100,idleTimeout:t.idleTimeout??1e4,initialWorkers:t.initialWorkers??Math.min(2,r)}}async init(){let t=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let r=0;r<t;r++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let t=`
3
3
  const { parentPort } = require('worker_threads');
4
4
  const bun = typeof Bun !== 'undefined' ? Bun : null;
5
5
  const fs = bun ? null : require('node:fs');
@@ -173,5 +173,5 @@ catch (error) {
173
173
  const result = await processTask(task);
174
174
  parentPort.postMessage(result);
175
175
  });
176
- `,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function er(t={}){return new Lt(t)}async function Ei(t,r={},o={}){let s=er(o);await s.init();try{return await s.processFiles(t,r)}finally{await s.shutdown()}}function ki(t,r){let o=[];for(let s=0;s<t.length;s+=r)o.push(t.slice(s,s+r));return o}function Ti(t,r=u().length){if(t<=r)return 1;let s=r*3;return Math.max(1,Math.ceil(t/s))}
177
- export{Lt,er,Ei,ki,Ti};
176
+ `,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function lr(t={}){return new Nt(t)}async function qi(t,r={},o={}){let s=lr(o);await s.init();try{return await s.processFiles(t,r)}finally{await s.shutdown()}}function Ji(t,r){let o=[];for(let s=0;s<t.length;s+=r)o.push(t.slice(s,s+r));return o}function Yi(t,r=u().length){if(t<=r)return 1;let s=r*3;return Math.max(1,Math.ceil(t/s))}
177
+ export{Nt,lr,qi,Ji,Yi};