@dtsx/dtsx 0.11.56 → 0.12.0

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 (242) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/dist/{chunk-62428w6e.js → chunk-07c41ffx.js} +7 -7
  3. package/dist/{chunk-j7rpp55s.js → chunk-0mj07j66.js} +3 -3
  4. package/dist/chunk-0zwa1tag.js +31 -0
  5. package/dist/chunk-16rpzfwq.js +10 -0
  6. package/dist/chunk-253e6nb4.js +3 -0
  7. package/dist/chunk-27hrxxsh.js +9 -0
  8. package/dist/{chunk-tgaear7n.js → chunk-27rxm6hh.js} +6 -6
  9. package/dist/chunk-30ffarqm.js +4 -0
  10. package/dist/{chunk-kkshxyex.js → chunk-37jcvx0v.js} +3 -3
  11. package/dist/chunk-44a6zpxs.js +3 -0
  12. package/dist/{chunk-g9emajpc.js → chunk-4ce9a877.js} +2 -2
  13. package/dist/{chunk-587w6ktw.js → chunk-4th0w19y.js} +3 -3
  14. package/dist/{chunk-mew3f4wh.js → chunk-50r5qs7t.js} +2 -2
  15. package/dist/chunk-5fgakmq9.js +3 -0
  16. package/dist/chunk-5tcpge5e.js +56 -0
  17. package/dist/{chunk-h6ddkhyq.js → chunk-5vk2x8ee.js} +2 -2
  18. package/dist/{chunk-k8tnz2qd.js → chunk-7116bytq.js} +8 -8
  19. package/dist/{chunk-6j6dvj8a.js → chunk-78ft65vf.js} +2 -2
  20. package/dist/{chunk-v22xpr7j.js → chunk-795w1bb2.js} +2 -2
  21. package/dist/chunk-7vjbc4z7.js +6 -0
  22. package/dist/chunk-85r70e8z.js +3 -0
  23. package/dist/chunk-8t9qp0mq.js +5 -0
  24. package/dist/chunk-9axwjcna.js +21 -0
  25. package/dist/{chunk-qt9gjs57.js → chunk-9wgk5qp1.js} +2 -2
  26. package/dist/{chunk-hbmnkmzb.js → chunk-am4b9zt0.js} +3 -3
  27. package/dist/chunk-b5wcbnb8.js +9 -0
  28. package/dist/{chunk-8vvryt8p.js → chunk-bd048mjd.js} +2 -2
  29. package/dist/chunk-be7f8t6b.js +3 -0
  30. package/dist/chunk-bwb12r8r.js +3 -0
  31. package/dist/chunk-cb5dj4qy.js +3 -0
  32. package/dist/chunk-chj3hn6f.js +3 -0
  33. package/dist/chunk-cnb2rfmv.js +21 -0
  34. package/dist/{chunk-vk5r6pgx.js → chunk-cs6538bw.js} +2 -2
  35. package/dist/chunk-d99qykzn.js +6 -0
  36. package/dist/{chunk-2qbj76ap.js → chunk-e12f4mpd.js} +8 -8
  37. package/dist/chunk-e21ap86b.js +3 -0
  38. package/dist/{chunk-f5jc2v3k.js → chunk-ezhvnzja.js} +2 -2
  39. package/dist/chunk-fnd5bvfd.js +3 -0
  40. package/dist/chunk-fwqdc8fd.js +3 -0
  41. package/dist/{chunk-6r01zgys.js → chunk-gkfchhnr.js} +2 -2
  42. package/dist/chunk-h9gwg4kt.js +9 -0
  43. package/dist/chunk-hd2bq1j5.js +6 -0
  44. package/dist/{chunk-g25sbqbw.js → chunk-hpdmtzhk.js} +3 -3
  45. package/dist/{chunk-v6fwy63g.js → chunk-j2bapmng.js} +2 -2
  46. package/dist/{chunk-pnfjhm01.js → chunk-j41nnny5.js} +2 -2
  47. package/dist/{chunk-btcj8fgc.js → chunk-j60x598n.js} +3 -3
  48. package/dist/{chunk-gwa4hmfa.js → chunk-javyer70.js} +2 -2
  49. package/dist/chunk-ke1h5m7f.js +5 -0
  50. package/dist/chunk-kp395d2p.js +44 -0
  51. package/dist/{chunk-4rsk49xj.js → chunk-mzw42cv7.js} +2 -2
  52. package/dist/chunk-n2fm08w5.js +2 -0
  53. package/dist/chunk-n73yp5s4.js +6 -0
  54. package/dist/{chunk-6ekemc3h.js → chunk-ne7q6jf2.js} +2 -2
  55. package/dist/{chunk-5bdwrsqt.js → chunk-ngb87w7x.js} +7 -7
  56. package/dist/chunk-p15wwraa.js +3 -0
  57. package/dist/{chunk-1mzxq1rg.js → chunk-pb7p64tn.js} +2 -2
  58. package/dist/chunk-peg2exva.js +3 -0
  59. package/dist/chunk-pjrnfmwm.js +3 -0
  60. package/dist/{chunk-mph001z4.js → chunk-pkmjprad.js} +4 -4
  61. package/dist/{chunk-fpa2ea8k.js → chunk-pq6j9bkd.js} +5 -5
  62. package/dist/chunk-r1t34d75.js +3 -0
  63. package/dist/chunk-r48h4anw.js +3 -0
  64. package/dist/chunk-r6bagvr6.js +18 -0
  65. package/dist/chunk-rnm8937h.js +3 -0
  66. package/dist/chunk-rv597vq5.js +3 -0
  67. package/dist/chunk-s7d3d1wx.js +3 -0
  68. package/dist/{chunk-b6994asf.js → chunk-sqhmhd08.js} +2 -2
  69. package/dist/{chunk-8r7rmcz7.js → chunk-t5x9cy8y.js} +5 -5
  70. package/dist/chunk-t9w6e58q.js +22 -0
  71. package/dist/chunk-v0gpmwh9.js +8 -0
  72. package/dist/{chunk-heqx5083.js → chunk-ves5kf6r.js} +4 -4
  73. package/dist/{chunk-6c8nk9rm.js → chunk-veys7ggd.js} +4 -4
  74. package/dist/chunk-vjmwxye4.js +3 -0
  75. package/dist/chunk-war78wdt.js +22 -0
  76. package/dist/chunk-wfkkp4tx.js +29 -0
  77. package/dist/{chunk-mqv5m22t.js → chunk-x4pxkg7c.js} +4 -4
  78. package/dist/chunk-xrtfb38p.js +14 -0
  79. package/dist/chunk-xz57d151.js +3 -0
  80. package/dist/chunk-y7bcjjqd.js +3 -0
  81. package/dist/{chunk-hgg4aqvf.js → chunk-yfgm2ccr.js} +2 -2
  82. package/dist/{chunk-nmht3krt.js → chunk-yje9ebc0.js} +4 -4
  83. package/dist/chunk-yjkhep5n.js +3 -0
  84. package/dist/{chunk-7dmn623d.js → chunk-ykxeeekb.js} +3 -3
  85. package/dist/{chunk-9bj73ygx.js → chunk-ypbjr2b6.js} +3 -3
  86. package/dist/src/augmentation-graph.js +1 -1
  87. package/dist/src/binding-patterns.js +1 -1
  88. package/dist/src/branded-types.js +1 -1
  89. package/dist/src/bundle-linker.d.ts +4 -2
  90. package/dist/src/bundle-linker.js +1 -1
  91. package/dist/src/bundler.js +1 -1
  92. package/dist/src/cache.js +1 -1
  93. package/dist/src/call-signatures.d.ts +2 -0
  94. package/dist/src/call-signatures.js +1 -1
  95. package/dist/src/circular.js +1 -1
  96. package/dist/src/compat.js +1 -1
  97. package/dist/src/computed-keys.js +1 -1
  98. package/dist/src/concurrency.js +1 -1
  99. package/dist/src/config.js +1 -1
  100. package/dist/src/dangling-refs.js +1 -1
  101. package/dist/src/declaration-project.d.ts +4 -2
  102. package/dist/src/declaration-project.js +1 -1
  103. package/dist/src/declaration-publication.d.ts +1 -1
  104. package/dist/src/declaration-publication.js +1 -1
  105. package/dist/src/declaration-references.js +1 -1
  106. package/dist/src/diff.js +1 -1
  107. package/dist/src/docs.js +1 -1
  108. package/dist/src/enum-declarations.js +1 -1
  109. package/dist/src/errors.js +1 -1
  110. package/dist/src/extractor/directives.js +1 -1
  111. package/dist/src/extractor/extract.js +1 -1
  112. package/dist/src/extractor/hash.js +1 -1
  113. package/dist/src/extractor/scanner.d.ts +2 -0
  114. package/dist/src/extractor/scanner.js +1 -1
  115. package/dist/src/extractor.js +1 -1
  116. package/dist/src/formats.js +1 -1
  117. package/dist/src/formatter.js +1 -1
  118. package/dist/src/function-properties.js +1 -1
  119. package/dist/src/generator.js +1 -1
  120. package/dist/src/import-sorter.d.ts +6 -6
  121. package/dist/src/import-sorter.js +1 -1
  122. package/dist/src/incremental.js +1 -1
  123. package/dist/src/index.js +1 -1
  124. package/dist/src/inferred-imports.d.ts +5 -1
  125. package/dist/src/inferred-imports.js +1 -1
  126. package/dist/src/initializer-type-spans.js +1 -1
  127. package/dist/src/json-config.js +1 -1
  128. package/dist/src/lexical.d.ts +3 -0
  129. package/dist/src/lexical.js +1 -1
  130. package/dist/src/logger.js +1 -1
  131. package/dist/src/lsp.js +1 -1
  132. package/dist/src/memory.js +1 -1
  133. package/dist/src/merger.js +1 -1
  134. package/dist/src/module-graph.d.ts +9 -3
  135. package/dist/src/module-graph.js +1 -1
  136. package/dist/src/module-references.d.ts +2 -0
  137. package/dist/src/module-references.js +1 -1
  138. package/dist/src/native-checker.js +1 -1
  139. package/dist/src/native-engine.d.ts +24 -0
  140. package/dist/src/native-engine.js +1 -1
  141. package/dist/src/native-extractor.js +1 -1
  142. package/dist/src/native-generation.js +1 -1
  143. package/dist/src/native-project.js +1 -1
  144. package/dist/src/numeric-literals.js +1 -1
  145. package/dist/src/optimizer.js +1 -1
  146. package/dist/src/output-normalizer.d.ts +5 -5
  147. package/dist/src/output-normalizer.js +1 -1
  148. package/dist/src/parallel-processor.js +1 -1
  149. package/dist/src/parameters.js +1 -1
  150. package/dist/src/parser.js +1 -1
  151. package/dist/src/plugins/bun.js +1 -1
  152. package/dist/src/plugins/esbuild.js +1 -1
  153. package/dist/src/plugins/index.js +1 -1
  154. package/dist/src/plugins/tsdown.js +1 -1
  155. package/dist/src/plugins/tsup.js +1 -1
  156. package/dist/src/plugins/vite.js +1 -1
  157. package/dist/src/plugins/webpack.js +1 -1
  158. package/dist/src/plugins.d.ts +2 -0
  159. package/dist/src/plugins.js +1 -1
  160. package/dist/src/process-source.js +1 -1
  161. package/dist/src/processor/cache.js +1 -1
  162. package/dist/src/processor/comments.js +1 -1
  163. package/dist/src/processor/declarations.js +1 -1
  164. package/dist/src/processor/import-usage.js +1 -1
  165. package/dist/src/processor/imports.d.ts +3 -1
  166. package/dist/src/processor/imports.js +1 -1
  167. package/dist/src/processor/index.js +1 -1
  168. package/dist/src/processor/type-inference.d.ts +27 -7
  169. package/dist/src/processor/type-inference.js +1 -1
  170. package/dist/src/processor.js +1 -1
  171. package/dist/src/profiling.js +1 -1
  172. package/dist/src/return-type-scope.js +1 -1
  173. package/dist/src/security.js +1 -1
  174. package/dist/src/source-cache.js +1 -1
  175. package/dist/src/sourcemap.js +1 -1
  176. package/dist/src/stx.js +1 -1
  177. package/dist/src/syntax-validator.js +1 -1
  178. package/dist/src/tracking.js +1 -1
  179. package/dist/src/transformers.js +1 -1
  180. package/dist/src/tree-shaker.js +1 -1
  181. package/dist/src/tsconfig.js +1 -1
  182. package/dist/src/type-mappings.js +1 -1
  183. package/dist/src/utils.js +1 -1
  184. package/dist/src/value-inference.js +1 -1
  185. package/dist/src/vue.js +1 -1
  186. package/dist/src/watcher.js +1 -1
  187. package/dist/src/worker-thread.js +1 -1
  188. package/dist/src/worker.js +1 -1
  189. package/dist/src/workspace.js +1 -1
  190. package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
  191. package/native/darwin-x64/libzig-dtsx.dylib +0 -0
  192. package/native/freebsd-x64/libzig-dtsx.so +0 -0
  193. package/native/linux-arm64/libzig-dtsx.so +0 -0
  194. package/native/linux-x64/libzig-dtsx.so +0 -0
  195. package/native/windows-x64/zig-dtsx.dll +0 -0
  196. package/package.json +1 -1
  197. package/dist/chunk-0a1xppye.js +0 -3
  198. package/dist/chunk-0d5nemtn.js +0 -3
  199. package/dist/chunk-1t77gtcx.js +0 -3
  200. package/dist/chunk-20jq5v1p.js +0 -14
  201. package/dist/chunk-38r6thfe.js +0 -3
  202. package/dist/chunk-4cr1q0yf.js +0 -4
  203. package/dist/chunk-555w3kcr.js +0 -8
  204. package/dist/chunk-5tn8854w.js +0 -31
  205. package/dist/chunk-5yx2x4v4.js +0 -3
  206. package/dist/chunk-6b6rt0yh.js +0 -3
  207. package/dist/chunk-7pw9ayve.js +0 -9
  208. package/dist/chunk-7rdazac9.js +0 -40
  209. package/dist/chunk-81jrzxr6.js +0 -10
  210. package/dist/chunk-9h17ws4c.js +0 -2
  211. package/dist/chunk-9mdgtq38.js +0 -3
  212. package/dist/chunk-9wwsqemm.js +0 -3
  213. package/dist/chunk-bt2n0b75.js +0 -4
  214. package/dist/chunk-c726s7aj.js +0 -6
  215. package/dist/chunk-cfjd81h8.js +0 -3
  216. package/dist/chunk-cgqg1br8.js +0 -5
  217. package/dist/chunk-daasy0pw.js +0 -3
  218. package/dist/chunk-dak0dhnx.js +0 -3
  219. package/dist/chunk-djbck65n.js +0 -3
  220. package/dist/chunk-ekf33t9z.js +0 -6
  221. package/dist/chunk-eskywkxz.js +0 -22
  222. package/dist/chunk-ewgs91y1.js +0 -3
  223. package/dist/chunk-h28vzayq.js +0 -3
  224. package/dist/chunk-h7ebvy8j.js +0 -3
  225. package/dist/chunk-hj7gs32r.js +0 -3
  226. package/dist/chunk-hkcqbex1.js +0 -3
  227. package/dist/chunk-msa98cgm.js +0 -19
  228. package/dist/chunk-mzxxgnp8.js +0 -3
  229. package/dist/chunk-njknd1pt.js +0 -6
  230. package/dist/chunk-qbk49jz5.js +0 -21
  231. package/dist/chunk-qhkxctek.js +0 -3
  232. package/dist/chunk-r46rw8gr.js +0 -29
  233. package/dist/chunk-rzcnab8j.js +0 -3
  234. package/dist/chunk-sjbm1trn.js +0 -3
  235. package/dist/chunk-spdw3tc0.js +0 -18
  236. package/dist/chunk-srm0ddsk.js +0 -27
  237. package/dist/chunk-t5nmnzy6.js +0 -7
  238. package/dist/chunk-tw99ftp1.js +0 -3
  239. package/dist/chunk-vt5hr8vs.js +0 -3
  240. package/dist/chunk-wq5r1ms9.js +0 -38
  241. package/dist/chunk-x6ddycvm.js +0 -3
  242. package/dist/chunk-yxcyqezk.js +0 -8
package/dist/bin/cli.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import n from"process";var _;for(let e=2;e<n.argv.length;e++){let t=n.argv[e];if(t!=="--engine"&&!t.startsWith("--engine="))continue;let o=t.startsWith("--engine="),f=o?t.slice(9):n.argv[e+1],{parseDeclarationEngine:p,setDeclarationEngine:s}=await import("../src/native-engine.js");try{if(_=p(f??null,"--engine"),!_)throw Error("--engine needs a value: native or typescript");s(_)}catch(a){console.error(`Error: ${a.message}`),n.exit(1)}n.argv.splice(e,o?1:2),e--}var J=n.argv[2];if(J==="stdin"||J==="emit"||J==="--project"){if(J==="stdin"){let{processSource:e}=await import("../src/process-source.js"),t=[];for await(let f of n.stdin)t.push(f);let o=Buffer.concat(t).toString("utf-8");if(o.trim())n.stdout.write(e(o,"stdin.ts")),n.stdout.write(`
4
4
  `)}else if(J==="--project"){let{readdirSync:e,readFileSync:t,writeFileSync:o,mkdirSync:f}=await import("fs"),p=typeof globalThis.Bun<"u",s=p?globalThis.Bun:null,a=n.argv.slice(3),y="",w="",h=!1;for(let i=0;i<a.length;i++)if(a[i]==="--outdir"&&a[i+1])w=a[i+1],i++;else if(a[i]==="--isolated-declarations")h=!0;else if(!y)y=a[i];f(w,{recursive:!0});let m=e(y).filter((i)=>i.endsWith(".ts")&&!i.endsWith(".d.ts")),l=m.length,u=Array(l),c=Array(l);for(let i=0;i<l;i++)u[i]=`${y}/${m[i]}`,c[i]=`${w}/${m[i].slice(0,-3)}.d.ts`;let g=["bun"],k=16777216,{nativeEngineAvailable:P}=await import("../src/native-engine.js"),b=!1;if(p&&l>=256&&!P()){let i=0;for(let E=0;E<l&&!b;E++)i+=s.file(u[E]).size,b=i>=k}let D=!1,x=null;if(b){let i=null;try{let{createWorkerPool:E,calculateOptimalBatchSize:L}=await import("../src/worker.js"),{cpus:I}=await import("os"),F=Math.max(1,I().length-1),B=Math.min(64,Math.max(8,L(l,F)*2)),d=l>=256,S=!0,G=l>=256;if(!d&&l>=256){x=Array(l);for(let j=0;j<l;j++)x[j]=s.file(u[j]).text()}let U=Math.ceil(l/B),Y=Math.min(U,Math.max(2,F*2));i=E({maxWorkers:F,initialWorkers:F,recycleAfter:Math.max(100,U+1)}),await i.init();let q=i,ee=0,H=Date.now(),te=async()=>{for(;;){let j=ee++;if(j>=U)return;let M=j*B;if(M>=l)return;let T=Math.min(l,M+B)-M,z;if(G){let W=Array(T),A=Array(T),R;if(d)for(let v=0;v<T;v++){let O=M+v;W[v]=u[O],A[v]=c[O]}else{let v=Array(T);for(let O=0;O<T;O++){let K=M+O;W[O]=u[K],A[O]=c[K],v[O]=x?x[K]:s.file(u[K]).text()}R=await Promise.all(v)}z=await q.submit({id:`batch-${H}-${j}`,type:"process-batch",filePath:W[0]||"",filePaths:W,sources:R,outPaths:A,writeOutput:!0,config:{keepComments:!0,importOrder:g,isolatedDeclarations:h,engine:_}})}else{let W=Array(T);if(d)for(let A=0;A<T;A++){let R=M+A;W[A]={filePath:u[R],outPath:c[R]}}else{let A=Array(T);for(let v=0;v<T;v++){let O=M+v;A[v]=x?x[O]:s.file(u[O]).text()}let R=await Promise.all(A);for(let v=0;v<T;v++){let O=M+v;W[v]={filePath:u[O],sourceCode:R[v],outPath:c[O]}}}z=await q.submit({id:`batch-${H}-${j}`,type:"process-batch",filePath:u[M]||"",files:W,writeOutput:!0,config:{keepComments:!0,importOrder:g,isolatedDeclarations:h,engine:_}})}if(!z.success)throw Error(z.error||`Worker batch failed for ${u[M]}`);if(z.batchResults?.length){let W=z.batchResults[0];throw Error(W?.error||z.error||`Worker failed for ${u[M]}`)}}},Q=[];for(let j=0;j<Y;j++)Q.push(te());await Promise.all(Q),D=!0}catch{D=!1}finally{if(i)await i.shutdown()}}if(!D){let{scanDeclarations:i}=await import("../src/extractor/scanner.js"),{processDeclarations:E}=await import("../src/processor.js"),{emitNatively:L}=await import("../src/process-source.js"),I=Array(l);if(p){let d=x?await Promise.all(x):await Promise.all(u.map((S)=>s.file(S).text()));for(let S=0;S<l;S++)I[S]=d[S]}else for(let d=0;d<l;d++)I[d]=t(u[d],"utf-8");let F=Array(l),B={filePath:"",sourceCode:"",declarations:[]};for(let d=0;d<l;d++){let S=L(I[d],m[d],!0,g,h);if(S!==null){F[d]=S;continue}let G=i(I[d],m[d],!0,h);B.filePath=m[d],B.sourceCode=I[d],B.declarations=G,F[d]=E(G,B,!0,g)}if(p){let d=Array(l);for(let S=0;S<l;S++)d[S]=s.write(c[S],F[S]);await Promise.all(d)}else for(let d=0;d<l;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",s=p?globalThis.Bun:null,a=n.argv[3],y=p?await s.file(a).text():t(a,"utf-8"),w=n.argv[4];if(w){let{dirname:h}=await import("path");f(h(w),{recursive:!0});let m=`${e(y,a)}
5
5
  `;if(p)await s.write(w,m);else o(w,m)}else n.stdout.write(e(y,a)),n.stdout.write(`
6
- `)}n.exit(0)}var{resolve:N}=await import("path"),{CLI:oe}=await import("../chunk-xn7p8w2c.js"),{version:X}=await import("../chunk-9h17ws4c.js"),{getConfig:re}=await import("../src/config.js"),{generate:ne,processSource:ie,watch:se}=await import("../src/generator.js"),C=new oe("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 Z(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}C.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}).option("--engine <engine>","Declaration engine: native (default) or typescript, the reference implementation").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 re(t),f={entrypoints:Z(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:Z(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((s)=>s.split(",").map((a)=>a.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,engine:_??o.engine,plugins:o.plugins},p=await ne(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)}});C.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}).option("--engine <engine>","Declaration engine: native (default) or typescript, the reference implementation").example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(e)=>{try{let t={entrypoints:Z(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,engine:_};await se(t)}catch(t){console.error("Error in watch mode:",t),n.exit(1)}});C.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]}).option("--engine <engine>","Declaration engine: native (default) or typescript, the reference implementation").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 s of n.stdin)t.push(s);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((s)=>s.split(",").map((a)=>a.trim()).filter(Boolean));else if(typeof e.importOrder==="string")f=e.importOrder.split(",").map((s)=>s.trim()).filter(Boolean)}let p=ie(o,"stdin.ts",e.keepComments??!0,f);console.log(p)}catch(t){console.error("Error processing stdin:",t),n.exit(1)}});C.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:s,dirname:a,basename:y}=await import("path"),{mkdirSync:w,copyFileSync:h,existsSync:m}=await import("fs"),l=n.cwd(),u=e.files||["**/*.d.ts"],c=[];for(let b of u){let D=new o(b);for await(let x of D.scan({cwd:l,absolute:!0,onlyFiles:!0}))if(x.endsWith(".d.ts")&&!x.includes("node_modules"))c.push(x)}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 b of c){let D=b;if(e.outdir){let E=s(l,b);D=p(f(e.outdir),E);let L=a(D);if(!m(L))w(L,{recursive:!0});h(b,D)}let x=await t(D,{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+=x.originalSize,g+=x.savings;let i=s(l,D);console.log(` ${i}: ${x.originalSize}B -> ${x.optimizedSize}B (-${x.savingsPercent}%)`)}let P=k>0?Math.round(g/k*100):0;console.log(`
6
+ `)}n.exit(0)}var{resolve:N}=await import("path"),{CLI:oe}=await import("../chunk-xn7p8w2c.js"),{version:X}=await import("../chunk-n2fm08w5.js"),{getConfig:re}=await import("../src/config.js"),{generate:ne,processSource:ie,watch:se}=await import("../src/generator.js"),C=new oe("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 Z(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}C.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}).option("--engine <engine>","Declaration engine: native (default) or typescript, the reference implementation").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 re(t),f={entrypoints:Z(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:Z(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((s)=>s.split(",").map((a)=>a.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,engine:_??o.engine,plugins:o.plugins},p=await ne(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)}});C.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}).option("--engine <engine>","Declaration engine: native (default) or typescript, the reference implementation").example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(e)=>{try{let t={entrypoints:Z(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,engine:_};await se(t)}catch(t){console.error("Error in watch mode:",t),n.exit(1)}});C.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]}).option("--engine <engine>","Declaration engine: native (default) or typescript, the reference implementation").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 s of n.stdin)t.push(s);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((s)=>s.split(",").map((a)=>a.trim()).filter(Boolean));else if(typeof e.importOrder==="string")f=e.importOrder.split(",").map((s)=>s.trim()).filter(Boolean)}let p=ie(o,"stdin.ts",e.keepComments??!0,f);console.log(p)}catch(t){console.error("Error processing stdin:",t),n.exit(1)}});C.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:s,dirname:a,basename:y}=await import("path"),{mkdirSync:w,copyFileSync:h,existsSync:m}=await import("fs"),l=n.cwd(),u=e.files||["**/*.d.ts"],c=[];for(let b of u){let D=new o(b);for await(let x of D.scan({cwd:l,absolute:!0,onlyFiles:!0}))if(x.endsWith(".d.ts")&&!x.includes("node_modules"))c.push(x)}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 b of c){let D=b;if(e.outdir){let E=s(l,b);D=p(f(e.outdir),E);let L=a(D);if(!m(L))w(L,{recursive:!0});h(b,D)}let x=await t(D,{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+=x.originalSize,g+=x.savings;let i=s(l,D);console.log(` ${i}: ${x.originalSize}B -> ${x.optimizedSize}B (-${x.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)}});C.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"),s=new o("**/*.ts"),a=[];for await(let y of s.scan({cwd:p,absolute:!0,onlyFiles:!0}))if(!y.endsWith(".d.ts")&&!y.includes("node_modules"))a.push(y);if(a.length===0)console.error("No TypeScript files found"),n.exit(1);console.log(`Found ${a.length} source files`),await t(a,{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)}});C.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:s}=await import("path"),a=s(e.cwd||n.cwd()),y=p(a,"tsconfig.json"),w;if(f(y))w=await t(a,{logLevel:e.logLevel||"info",continueOnError:e.continueOnError??!0});else w=await o(a,{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)}});C.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()});C.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:s,relative:a}=await import("path"),y=n.cwd(),w=e.files||["**/*.ts"],h=[];for(let l of w){let u=new p(l);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 l=await o(h,e.tsconfig?s(e.tsconfig):void 0),u=0,c=[];for(let[g,k]of l){let P=a(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 b of k.issues)if(console.log(` ${b.line}:${b.column} - ${b.message}`),b.missingAnnotation)console.log(` Missing: ${b.missingAnnotation} type annotation`)}else if(e.format==="json")c.push({file:P,compatible:!0,issues:[]})}if(e.format==="json")console.log(JSON.stringify(c,null,2));else if(u>0)console.log(`
9
9
  ${h.length} files checked, ${u} recommendations found`),console.log("Tip: Adding explicit type annotations improves .d.ts accuracy");else console.log(`
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{r}from"./chunk-0a1xppye.js";import{e}from"./chunk-8vvryt8p.js";import{existsSync as j,mkdirSync as S,readFileSync as E,writeFileSync as f}from"fs";import{basename as h,join as g}from"path";function cn(t){let n={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!t||t.length===0)return n;for(let s of t){let o=s.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
2
+ import{s}from"./chunk-vjmwxye4.js";import{e}from"./chunk-bd048mjd.js";import{existsSync as j,mkdirSync as S,readFileSync as E,writeFileSync as f}from"fs";import{basename as h,join as g}from"path";function un(t){let n={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!t||t.length===0)return n;for(let r of t){let o=r.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
3
3
  `).map((p)=>p.replace(/^\s*\*\s?/,"")).join(`
4
- `).trim(),i=o.search(/@\w+/);if(i===-1){n.description=o;continue}else if(i>0)n.description=o.slice(0,i).trim(),o=o.slice(i);let a=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,c;while((c=a.exec(o))!==null){let[,p,u,d]=c,m=d.trim();switch(p){case"param":{let l=m.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(l)n.params.push({name:l[2],type:u,description:l[3].trim(),optional:!!l[1]});break}case"returns":case"return":n.returns={type:u,description:m};break;case"example":n.examples.push(m);break;case"deprecated":n.deprecated=m||"Deprecated";break;case"since":n.since=m;break;case"see":n.see.push(m);break;case"throws":case"throw":n.throws.push({type:u,description:m});break;case"category":n.category=m;break;default:if(!n.tags[p])n.tags[p]=[];n.tags[p].push(m)}}}return n}function w(t,n){let s=cn(t.leadingComments),o="";switch(t.kind){case"function":o=M(t);break;case"variable":o=C(t);break;case"interface":o=P(t);break;case"type":o=v(t);break;case"class":o=T(t);break;case"enum":o=F(t);break;default:o=t.text||t.name}let i={name:t.name,kind:t.kind,signature:o,jsdoc:s,isExported:t.isExported,isDefault:t.isDefault,sourceFile:n};if(t.members&&t.members.length>0)i.members=t.members.map((a)=>w(a,n));return i}function M(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("function"),n.push(t.name),t.generics)n.push(t.generics);if(t.parameters){let s=t.parameters.map((o)=>{let i="";if(o.rest)i+="...";if(i+=o.name,o.optional)i+="?";if(o.type)i+=`: ${o.type}`;return i}).join(", ");n.push(`(${s})`)}else n.push("()");if(t.returnType)n.push(`: ${t.returnType}`);return n.join(" ").replace(/\s+/g," ")}function C(t){let n=[];if(t.isExported)n.push("export");if(n.push("const"),n.push(t.name),t.typeAnnotation)n.push(`: ${t.typeAnnotation}`);return n.join(" ")}function P(t){let n=[];if(t.isExported)n.push("export");if(n.push("interface"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);return n.join(" ")}function v(t){let n=[];if(t.isExported)n.push("export");if(n.push("type"),n.push(t.name),t.generics)n.push(t.generics);if(n.push("="),t.typeAnnotation)n.push(t.typeAnnotation);return n.join(" ")}function T(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("class"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)n.push(`implements ${t.implements.join(", ")}`);return n.join(" ")}function F(t){let n=[];if(t.isExported)n.push("export");return n.push("enum"),n.push(t.name),n.join(" ")}async function ln(t,n={}){let s=[],o=new Map;for(let i of t){if(!j(i)){e.warn(`File not found: ${i}`);continue}let a=E(i,"utf-8"),c=r(a,i,!0);for(let p of c){if(p.kind==="import")continue;if(!n.includePrivate&&p.name.startsWith("_"))continue;if(!n.includeInternal&&p.leadingComments?.some((d)=>d.includes("@internal")))continue;let u=w(p,i);if(s.push(u),n.groupByCategory&&u.jsdoc.category){let d=u.jsdoc.category;if(!o.has(d))o.set(d,[]);o.get(d).push(u)}}}return{title:n.title||"API Documentation",description:n.description,entries:s,categories:o,generatedAt:new Date}}function Je(t,n={}){let s=[];if(s.push(`# ${t.title}`),s.push(""),t.description)s.push(t.description),s.push("");if(s.push(`> Generated on ${t.generatedAt.toISOString()}`),s.push(""),s.push("## Table of Contents"),s.push(""),n.groupByCategory&&t.categories.size>0)for(let o of t.categories.keys())s.push(`- [${o}](#${D(o)})`);else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0)s.push(`- [${b(i)}](#${D(b(i))})`)}if(s.push(""),n.groupByCategory&&t.categories.size>0)for(let[o,i]of t.categories){s.push(`## ${o}`),s.push("");for(let a of i)s.push(...k(a,n))}else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0){s.push(`## ${b(i)}`),s.push("");for(let c of a)s.push(...k(c,n))}}return s.join(`
5
- `)}function k(t,n){let s=[];if(s.push(`### ${t.name}`),s.push(""),t.jsdoc.deprecated)s.push(`> **Deprecated:** ${t.jsdoc.deprecated}`),s.push("");if(s.push("```typescript"),s.push(t.signature),s.push("```"),s.push(""),t.jsdoc.description)s.push(t.jsdoc.description),s.push("");if(t.jsdoc.params.length>0){s.push("**Parameters:**"),s.push(""),s.push("| Name | Type | Description |"),s.push("|------|------|-------------|");for(let o of t.jsdoc.params){let i=o.optional?" (optional)":"",a=o.type||"any";s.push(`| \`${o.name}\`${i} | \`${a}\` | ${o.description} |`)}s.push("")}if(t.jsdoc.returns){s.push("**Returns:**"),s.push("");let o=t.jsdoc.returns.type?`\`${t.jsdoc.returns.type}\``:"";s.push(`${o} ${t.jsdoc.returns.description}`),s.push("")}if(t.jsdoc.throws.length>0){s.push("**Throws:**"),s.push("");for(let o of t.jsdoc.throws){let i=o.type?`\`${o.type}\``:"";s.push(`- ${i} ${o.description}`)}s.push("")}if(t.jsdoc.examples.length>0){s.push("**Examples:**"),s.push("");for(let o of t.jsdoc.examples)s.push("```typescript"),s.push(o),s.push("```"),s.push("")}if(t.jsdoc.see.length>0){s.push("**See also:**"),s.push("");for(let o of t.jsdoc.see)s.push(`- ${o}`);s.push("")}if(t.jsdoc.since)s.push(`*Since: ${t.jsdoc.since}*`),s.push("");if(n.includeSourceLinks&&t.sourceFile){let o=t.sourceFile;if(n.sourceBaseUrl)s.push(`[Source](${n.sourceBaseUrl}/${o})`);else s.push(`*Source: ${o}*`);s.push("")}if(t.members&&t.members.length>0){s.push("**Members:**"),s.push("");for(let o of t.members)if(s.push(`#### ${o.name}`),s.push(""),s.push("```typescript"),s.push(o.signature),s.push("```"),s.push(""),o.jsdoc.description)s.push(o.jsdoc.description),s.push("")}return s.push("---"),s.push(""),s}function un(t,n={}){let s=Je(t,n);return`<!DOCTYPE html>
4
+ `).trim(),i=o.search(/@\w+/);if(i===-1){n.description=o;continue}else if(i>0)n.description=o.slice(0,i).trim(),o=o.slice(i);let a=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,c;while((c=a.exec(o))!==null){let[,p,u,d]=c,m=d.trim();switch(p){case"param":{let l=m.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(l)n.params.push({name:l[2],type:u,description:l[3].trim(),optional:!!l[1]});break}case"returns":case"return":n.returns={type:u,description:m};break;case"example":n.examples.push(m);break;case"deprecated":n.deprecated=m||"Deprecated";break;case"since":n.since=m;break;case"see":n.see.push(m);break;case"throws":case"throw":n.throws.push({type:u,description:m});break;case"category":n.category=m;break;default:if(!n.tags[p])n.tags[p]=[];n.tags[p].push(m)}}}return n}function w(t,n){let r=un(t.leadingComments),o="";switch(t.kind){case"function":o=M(t);break;case"variable":o=C(t);break;case"interface":o=P(t);break;case"type":o=v(t);break;case"class":o=T(t);break;case"enum":o=F(t);break;default:o=t.text||t.name}let i={name:t.name,kind:t.kind,signature:o,jsdoc:r,isExported:t.isExported,isDefault:t.isDefault,sourceFile:n};if(t.members&&t.members.length>0)i.members=t.members.map((a)=>w(a,n));return i}function M(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("function"),n.push(t.name),t.generics)n.push(t.generics);if(t.parameters){let r=t.parameters.map((o)=>{let i="";if(o.rest)i+="...";if(i+=o.name,o.optional)i+="?";if(o.type)i+=`: ${o.type}`;return i}).join(", ");n.push(`(${r})`)}else n.push("()");if(t.returnType)n.push(`: ${t.returnType}`);return n.join(" ").replace(/\s+/g," ")}function C(t){let n=[];if(t.isExported)n.push("export");if(n.push("const"),n.push(t.name),t.typeAnnotation)n.push(`: ${t.typeAnnotation}`);return n.join(" ")}function P(t){let n=[];if(t.isExported)n.push("export");if(n.push("interface"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);return n.join(" ")}function v(t){let n=[];if(t.isExported)n.push("export");if(n.push("type"),n.push(t.name),t.generics)n.push(t.generics);if(n.push("="),t.typeAnnotation)n.push(t.typeAnnotation);return n.join(" ")}function T(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("class"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)n.push(`implements ${t.implements.join(", ")}`);return n.join(" ")}function F(t){let n=[];if(t.isExported)n.push("export");return n.push("enum"),n.push(t.name),n.join(" ")}async function fn(t,n={}){let r=[],o=new Map;for(let i of t){if(!j(i)){e.warn(`File not found: ${i}`);continue}let a=E(i,"utf-8"),c=s(a,i,!0);for(let p of c){if(p.kind==="import")continue;if(!n.includePrivate&&p.name.startsWith("_"))continue;if(!n.includeInternal&&p.leadingComments?.some((d)=>d.includes("@internal")))continue;let u=w(p,i);if(r.push(u),n.groupByCategory&&u.jsdoc.category){let d=u.jsdoc.category;if(!o.has(d))o.set(d,[]);o.get(d).push(u)}}}return{title:n.title||"API Documentation",description:n.description,entries:r,categories:o,generatedAt:new Date}}function Ze(t,n={}){let r=[];if(r.push(`# ${t.title}`),r.push(""),t.description)r.push(t.description),r.push("");if(r.push(`> Generated on ${t.generatedAt.toISOString()}`),r.push(""),r.push("## Table of Contents"),r.push(""),n.groupByCategory&&t.categories.size>0)for(let o of t.categories.keys())r.push(`- [${o}](#${D(o)})`);else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0)r.push(`- [${b(i)}](#${D(b(i))})`)}if(r.push(""),n.groupByCategory&&t.categories.size>0)for(let[o,i]of t.categories){r.push(`## ${o}`),r.push("");for(let a of i)r.push(...k(a,n))}else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0){r.push(`## ${b(i)}`),r.push("");for(let c of a)r.push(...k(c,n))}}return r.join(`
5
+ `)}function k(t,n){let r=[];if(r.push(`### ${t.name}`),r.push(""),t.jsdoc.deprecated)r.push(`> **Deprecated:** ${t.jsdoc.deprecated}`),r.push("");if(r.push("```typescript"),r.push(t.signature),r.push("```"),r.push(""),t.jsdoc.description)r.push(t.jsdoc.description),r.push("");if(t.jsdoc.params.length>0){r.push("**Parameters:**"),r.push(""),r.push("| Name | Type | Description |"),r.push("|------|------|-------------|");for(let o of t.jsdoc.params){let i=o.optional?" (optional)":"",a=o.type||"any";r.push(`| \`${o.name}\`${i} | \`${a}\` | ${o.description} |`)}r.push("")}if(t.jsdoc.returns){r.push("**Returns:**"),r.push("");let o=t.jsdoc.returns.type?`\`${t.jsdoc.returns.type}\``:"";r.push(`${o} ${t.jsdoc.returns.description}`),r.push("")}if(t.jsdoc.throws.length>0){r.push("**Throws:**"),r.push("");for(let o of t.jsdoc.throws){let i=o.type?`\`${o.type}\``:"";r.push(`- ${i} ${o.description}`)}r.push("")}if(t.jsdoc.examples.length>0){r.push("**Examples:**"),r.push("");for(let o of t.jsdoc.examples)r.push("```typescript"),r.push(o),r.push("```"),r.push("")}if(t.jsdoc.see.length>0){r.push("**See also:**"),r.push("");for(let o of t.jsdoc.see)r.push(`- ${o}`);r.push("")}if(t.jsdoc.since)r.push(`*Since: ${t.jsdoc.since}*`),r.push("");if(n.includeSourceLinks&&t.sourceFile){let o=t.sourceFile;if(n.sourceBaseUrl)r.push(`[Source](${n.sourceBaseUrl}/${o})`);else r.push(`*Source: ${o}*`);r.push("")}if(t.members&&t.members.length>0){r.push("**Members:**"),r.push("");for(let o of t.members)if(r.push(`#### ${o.name}`),r.push(""),r.push("```typescript"),r.push(o.signature),r.push("```"),r.push(""),o.jsdoc.description)r.push(o.jsdoc.description),r.push("")}return r.push("---"),r.push(""),r}function dn(t,n={}){let r=Ze(t,n);return`<!DOCTYPE html>
6
6
  <html lang="en">
7
7
  <head>
8
8
  <meta charset="UTF-8">
@@ -93,10 +93,10 @@ import{r}from"./chunk-0a1xppye.js";import{e}from"./chunk-8vvryt8p.js";import{exi
93
93
  <article id="content"></article>
94
94
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
95
95
  <script>
96
- const markdown = ${JSON.stringify(s)};
96
+ const markdown = ${JSON.stringify(r)};
97
97
  document.getElementById('content').innerHTML = marked.parse(markdown);
98
98
  </script>
99
99
  </body>
100
- </html>`}function fn(t,n={}){let s={title:t.title,description:t.description,generatedAt:t.generatedAt.toISOString(),version:"1.0.0",entries:t.entries.map((o)=>({name:o.name,kind:o.kind,signature:o.signature,description:o.jsdoc.description,isExported:o.isExported,isDefault:o.isDefault,deprecated:o.jsdoc.deprecated,since:o.jsdoc.since,category:o.jsdoc.category,params:o.jsdoc.params,returns:o.jsdoc.returns,examples:o.jsdoc.examples,throws:o.jsdoc.throws,see:o.jsdoc.see,tags:o.jsdoc.tags,sourceFile:o.sourceFile,sourceLine:o.sourceLine,members:o.members?.map((i)=>({name:i.name,kind:i.kind,signature:i.signature,description:i.jsdoc.description,deprecated:i.jsdoc.deprecated,params:i.jsdoc.params,returns:i.jsdoc.returns}))})),categories:n.groupByCategory?Object.fromEntries(Array.from(t.categories.entries()).map(([o,i])=>[o,i.map((a)=>a.name)])):void 0};return JSON.stringify(s,null,2)}function Br(t){let n={id:0,name:t.title,kind:1,kindString:"Project",flags:{},children:t.entries.map((s,o)=>({id:o+1,name:s.name,kind:y(s.kind),kindString:s.kind,flags:{isExported:s.isExported,isDefault:s.isDefault},comment:s.jsdoc.description?{summary:[{kind:"text",text:s.jsdoc.description}],blockTags:s.jsdoc.deprecated?[{tag:"@deprecated",content:[{kind:"text",text:s.jsdoc.deprecated}]}]:void 0}:void 0,sources:s.sourceFile?[{fileName:s.sourceFile,line:s.sourceLine||1,character:0}]:void 0,signatures:s.kind==="function"?[{id:o+1000,name:s.name,kind:4096,kindString:"Call signature",parameters:s.jsdoc.params.map((i,a)=>({id:o+2000+a,name:i.name,kind:32768,kindString:"Parameter",flags:{isOptional:i.optional},type:i.type?{type:"intrinsic",name:i.type}:void 0,comment:i.description?{summary:[{kind:"text",text:i.description}]}:void 0})),type:s.jsdoc.returns?.type?{type:"intrinsic",name:s.jsdoc.returns.type}:void 0}]:void 0,children:s.members?.map((i,a)=>({id:o+3000+a,name:i.name,kind:y(i.kind),kindString:i.kind,comment:i.jsdoc.description?{summary:[{kind:"text",text:i.jsdoc.description}]}:void 0}))}))};return JSON.stringify(n,null,2)}async function _s(t,n){e.info("Extracting documentation...");let s=await ln(t,n);if(e.info(`Found ${s.entries.length} documented entries`),!j(n.outdir))S(n.outdir,{recursive:!0});if(n.format==="markdown")if(n.splitByModule){let o=I(s.entries);for(let[a,c]of o){let p={title:h(a,".ts"),description:`Documentation for ${a}`,entries:c,categories:new Map,generatedAt:s.generatedAt},u=Je(p,n),d=g(n.outdir,`${h(a,".ts")}.md`);f(d,u),e.info(`Generated: ${d}`)}let i=[`# ${s.title}`,"",s.description||"","","## Modules",""];for(let[a]of o){let c=h(a,".ts");i.push(`- [${c}](./${c}.md)`)}f(g(n.outdir,"README.md"),i.join(`
101
- `)),e.info(`Generated: ${g(n.outdir,"README.md")}`)}else{let o=Je(s,n),i=g(n.outdir,"API.md");f(i,o),e.info(`Generated: ${i}`)}else if(n.format==="json"){let o=fn(s,n),i=g(n.outdir,"api.json");f(i,o),e.info(`Generated: ${i}`);let a=Br(s),c=g(n.outdir,"typedoc.json");f(c,a),e.info(`Generated: ${c}`)}else{let o=un(s,n),i=g(n.outdir,"index.html");f(i,o),e.info(`Generated: ${i}`)}}function D(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function b(t){return{function:"Functions",variable:"Variables",interface:"Interfaces",type:"Type Aliases",class:"Classes",enum:"Enums",export:"Exports",module:"Modules"}[t]||t}function x(t){let n=new Map,s=["function","class","interface","type","enum","variable"];for(let o of s)n.set(o,[]);for(let o of t){let i=o.kind;if(!n.has(i))n.set(i,[]);n.get(i).push(o)}return n}function A(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function I(t){let n=new Map;for(let s of t){let o=s.sourceFile||"unknown";if(!n.has(o))n.set(o,[]);n.get(o).push(s)}return n}function y(t){return{function:64,variable:32,interface:256,type:4194304,class:128,enum:8,property:1024,method:2048,module:2,namespace:4}[t]||0}function js(t={}){return{extract:(n)=>ln(n,t),generateMarkdown:(n)=>Je(n,t),generateHTML:(n)=>un(n,t),generateJSON:(n)=>fn(n,t),parseJSDoc:cn}}
102
- export{cn,ln,Je,un,fn,Br,_s,js};
100
+ </html>`}function pn(t,n={}){let r={title:t.title,description:t.description,generatedAt:t.generatedAt.toISOString(),version:"1.0.0",entries:t.entries.map((o)=>({name:o.name,kind:o.kind,signature:o.signature,description:o.jsdoc.description,isExported:o.isExported,isDefault:o.isDefault,deprecated:o.jsdoc.deprecated,since:o.jsdoc.since,category:o.jsdoc.category,params:o.jsdoc.params,returns:o.jsdoc.returns,examples:o.jsdoc.examples,throws:o.jsdoc.throws,see:o.jsdoc.see,tags:o.jsdoc.tags,sourceFile:o.sourceFile,sourceLine:o.sourceLine,members:o.members?.map((i)=>({name:i.name,kind:i.kind,signature:i.signature,description:i.jsdoc.description,deprecated:i.jsdoc.deprecated,params:i.jsdoc.params,returns:i.jsdoc.returns}))})),categories:n.groupByCategory?Object.fromEntries(Array.from(t.categories.entries()).map(([o,i])=>[o,i.map((a)=>a.name)])):void 0};return JSON.stringify(r,null,2)}function Mr(t){let n={id:0,name:t.title,kind:1,kindString:"Project",flags:{},children:t.entries.map((r,o)=>({id:o+1,name:r.name,kind:y(r.kind),kindString:r.kind,flags:{isExported:r.isExported,isDefault:r.isDefault},comment:r.jsdoc.description?{summary:[{kind:"text",text:r.jsdoc.description}],blockTags:r.jsdoc.deprecated?[{tag:"@deprecated",content:[{kind:"text",text:r.jsdoc.deprecated}]}]:void 0}:void 0,sources:r.sourceFile?[{fileName:r.sourceFile,line:r.sourceLine||1,character:0}]:void 0,signatures:r.kind==="function"?[{id:o+1000,name:r.name,kind:4096,kindString:"Call signature",parameters:r.jsdoc.params.map((i,a)=>({id:o+2000+a,name:i.name,kind:32768,kindString:"Parameter",flags:{isOptional:i.optional},type:i.type?{type:"intrinsic",name:i.type}:void 0,comment:i.description?{summary:[{kind:"text",text:i.description}]}:void 0})),type:r.jsdoc.returns?.type?{type:"intrinsic",name:r.jsdoc.returns.type}:void 0}]:void 0,children:r.members?.map((i,a)=>({id:o+3000+a,name:i.name,kind:y(i.kind),kindString:i.kind,comment:i.jsdoc.description?{summary:[{kind:"text",text:i.jsdoc.description}]}:void 0}))}))};return JSON.stringify(n,null,2)}async function rs(t,n){e.info("Extracting documentation...");let r=await fn(t,n);if(e.info(`Found ${r.entries.length} documented entries`),!j(n.outdir))S(n.outdir,{recursive:!0});if(n.format==="markdown")if(n.splitByModule){let o=I(r.entries);for(let[a,c]of o){let p={title:h(a,".ts"),description:`Documentation for ${a}`,entries:c,categories:new Map,generatedAt:r.generatedAt},u=Ze(p,n),d=g(n.outdir,`${h(a,".ts")}.md`);f(d,u),e.info(`Generated: ${d}`)}let i=[`# ${r.title}`,"",r.description||"","","## Modules",""];for(let[a]of o){let c=h(a,".ts");i.push(`- [${c}](./${c}.md)`)}f(g(n.outdir,"README.md"),i.join(`
101
+ `)),e.info(`Generated: ${g(n.outdir,"README.md")}`)}else{let o=Ze(r,n),i=g(n.outdir,"API.md");f(i,o),e.info(`Generated: ${i}`)}else if(n.format==="json"){let o=pn(r,n),i=g(n.outdir,"api.json");f(i,o),e.info(`Generated: ${i}`);let a=Mr(r),c=g(n.outdir,"typedoc.json");f(c,a),e.info(`Generated: ${c}`)}else{let o=dn(r,n),i=g(n.outdir,"index.html");f(i,o),e.info(`Generated: ${i}`)}}function D(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function b(t){return{function:"Functions",variable:"Variables",interface:"Interfaces",type:"Type Aliases",class:"Classes",enum:"Enums",export:"Exports",module:"Modules"}[t]||t}function x(t){let n=new Map,r=["function","class","interface","type","enum","variable"];for(let o of r)n.set(o,[]);for(let o of t){let i=o.kind;if(!n.has(i))n.set(i,[]);n.get(i).push(o)}return n}function A(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function I(t){let n=new Map;for(let r of t){let o=r.sourceFile||"unknown";if(!n.has(o))n.set(o,[]);n.get(o).push(r)}return n}function y(t){return{function:64,variable:32,interface:256,type:4194304,class:128,enum:8,property:1024,method:2048,module:2,namespace:4}[t]||0}function is(t={}){return{extract:(n)=>fn(n,t),generateMarkdown:(n)=>Ze(n,t),generateHTML:(n)=>dn(n,t),generateJSON:(n)=>pn(n,t),parseJSDoc:un}}
102
+ export{un,fn,Ze,dn,pn,Mr,rs,is};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{se}from"./chunk-7pw9ayve.js";function $i(n,r,e,t={}){return{kind:n,name:r,text:e,isExported:t.isExported??!1,...t}}function Ei(n){if(typeof structuredClone==="function")return structuredClone(n);return JSON.parse(JSON.stringify(n))}function Nn(n,r,e=null){for(let t of n){r.enter?.(t,e);let o=r[t.kind];if(o)o(t,e);if(t.members&&t.members.length>0)Nn(t.members,r,t);r.leave?.(t,e)}}function Bo(n,r){let e=[];return Nn(n,{enter:(t)=>{if(r(t))e.push(t)}}),e}async function ki(n,r,e){let t=[],o=n.length;for(let a=0;a<n.length;a++){let i=n[a],s={...e,index:a,total:o,allDeclarations:n},l=await r(i,s);if(l===null)continue;else if(l===void 0)t.push(i);else if(Array.isArray(l))t.push(...l);else t.push(l)}return t}function Wo(...n){return async(r,e)=>{let t=r;for(let o of n){if(t===null)return null;if(Array.isArray(t)){let a=[];for(let i of t){let s=await o(i,e);if(s===null)continue;if(s===void 0)a.push(i);else if(Array.isArray(s))a.push(...s);else a.push(s)}t=a.length>0?a:null}else{let a=await o(t,e);if(a===null)t=null;else if(a===void 0);else t=a}}return t}}function Te(n,r){let e=new Set(Array.isArray(n)?n:[n]);return async(t,o)=>{if(e.has(t.kind))return r(t,o);return}}function _o(n,r){return async(e,t)=>{if(n(e))return r(e,t);return}}function it(n){let r={createDeclaration:$i,cloneDeclaration:Ei,modifyText:(e,t)=>({...e,text:t}),addModifier:(e,t)=>({...e,modifiers:[...e.modifiers||[],t]}),removeModifier:(e,t)=>({...e,modifiers:(e.modifiers||[]).filter((o)=>o!==t)})};return se({name:n.name,version:n.version,description:n.description,onBeforeFile:n.beforeParse?async(e)=>n.beforeParse(e.content,{filePath:e.filePath,phase:"before"}):void 0,onDeclarations:n.transform?async(e)=>ki(e.declarations,n.transform,{filePath:e.filePath,sourceCode:e.sourceCode,...r}):void 0,onAfterFile:n.afterGenerate?async(e)=>n.afterGenerate(e.content,{filePath:e.filePath,phase:"after"}):void 0})}function jo(n,r){let e=typeof n==="string"?new RegExp(n):n;return(t)=>{if(e.test(t.name)){let o=typeof r==="function"?r(t.name,t):t.name.replace(e,r),a=t.text.replace(new RegExp(`\\b${f(t.name)}\\b`),o);return{...t,name:o,text:a}}return}}function Ti(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${n}${e.name}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function Go(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${e.name}${n}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function Ai(n){let r=typeof n==="function"?n:(e)=>(typeof n==="string"?new RegExp(n):n).test(e.name);return(e)=>{if(r(e))return null;return}}function Vo(n){return(r)=>{let e=n(r);if(!e)return;let o=(Array.isArray(e)?e:[e]).map((a)=>{if(a.startsWith("/**"))return a;if(a.startsWith("/*"))return a;return`/** ${a} */`});return{...r,leadingComments:[...r.leadingComments||[],...o]}}}function zo(n){return(r)=>{if(!r.typeAnnotation)return;let e=n(r.typeAnnotation,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`:[ ]*${f(r.typeAnnotation)}`),`: ${e}`);return{...r,typeAnnotation:e,text:t}}}function Uo(n){return Te("function",(r)=>{if(!r.returnType)return;let e=n(r.returnType,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`\\):[ ]*${f(r.returnType)}`),`): ${e}`);return{...r,returnType:e,text:t}})}function Ho(n){return Te(["function","class"],(r)=>{if(!r.parameters)return;let e=n(r.parameters,r);if(e===null)return null;if(e===void 0)return;let t=e.map((a)=>{let i="";if(a.rest)i+="...";if(i+=a.name,a.optional)i+="?";if(a.type)i+=`: ${a.type}`;if(a.defaultValue)i+=` = ${a.defaultValue}`;return i}).join(", "),o=r.text.replace(/\([^)]*\)/,`(${t})`);return{...r,parameters:e,text:o}})}function Di(n,r){return(e)=>{if(r&&!r(e))return;if(e.modifiers?.includes(n))return;let t=[...e.modifiers||[],n],o=e.text;if(!o.includes(n)){let a=["function","class","interface","type","enum","const","let","var"];for(let i of a){let s=o.indexOf(i);if(s>=0){o=`${o.slice(0,s)}${n} ${o.slice(s)}`;break}}}return{...e,modifiers:t,text:o}}}var Pi=Te(["interface","type"],(n)=>{let r=n.text.replace(/(\n\s*)(\w+)(\??:\s)/g,"$1readonly $2$3");if(r===n.text)return;return{...n,text:r}}),Ko=Te(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)\?:/g,"$1:");if(r===n.text)return;return{...n,text:r}}),qo=Te(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)(?<!\?):/g,"$1?:");if(r===n.text)return;return{...n,text:r}});function Jo(n){let r=new RegExp(`@(${n.join("|")})\\b[^@]*`,"g");return(e)=>{if(!e.leadingComments?.length)return;let t=e.leadingComments.map((a)=>a.replace(r,"").replace(/\n\s*\*\s*\n/g,`
3
- `));if(!t.some((a,i)=>a!==e.leadingComments[i]))return;return{...e,leadingComments:t}}}function Yo(n,r){return(e)=>{if(r&&!r(e))return;if(!e.typeAnnotation)return;let t=`${n}<${e.typeAnnotation}>`,o=e.text.replace(e.typeAnnotation,t);return{...e,typeAnnotation:t,text:o}}}var Xo=it({name:"readonly",version:"1.0.0",description:"Makes all interface properties readonly",transform:Pi}),Zo=it({name:"strip-private",version:"1.0.0",description:"Strips @internal, @private, and @hidden declarations",transform:Ai((n)=>{if(!n.leadingComments)return!1;return n.leadingComments.some((r)=>/@(internal|private|hidden)\b/.test(r))})}),Qo=it({name:"declare",version:"1.0.0",description:"Adds declare keyword to all declarations",transform:Di("declare",(n)=>n.kind!=="import")});function ea(n){return it({name:`namespace-prefix-${n}`,version:"1.0.0",description:`Prefixes exported declarations with ${n}`,transform:Ti(`${n}_`,(r)=>r.isExported&&r.kind!=="import")})}function f(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}
4
- export{$i,Ei,Nn,Bo,ki,Wo,Te,_o,it,jo,Ti,Go,Ai,Vo,zo,Uo,Ho,Di,Pi,Ko,qo,Jo,Yo,Xo,Zo,Qo,ea};
2
+ import{de}from"./chunk-h9gwg4kt.js";function Ir(n,r,e,t={}){return{kind:n,name:r,text:e,isExported:t.isExported??!1,...t}}function Nr(n){if(typeof structuredClone==="function")return structuredClone(n);return JSON.parse(JSON.stringify(n))}function mn(n,r,e=null){for(let t of n){r.enter?.(t,e);let o=r[t.kind];if(o)o(t,e);if(t.members&&t.members.length>0)mn(t.members,r,t);r.leave?.(t,e)}}function ss(n,r){let e=[];return mn(n,{enter:(t)=>{if(r(t))e.push(t)}}),e}async function Wr(n,r,e){let t=[],o=n.length;for(let a=0;a<n.length;a++){let i=n[a],s={...e,index:a,total:o,allDeclarations:n},l=await r(i,s);if(l===null)continue;else if(l===void 0)t.push(i);else if(Array.isArray(l))t.push(...l);else t.push(l)}return t}function os(...n){return async(r,e)=>{let t=r;for(let o of n){if(t===null)return null;if(Array.isArray(t)){let a=[];for(let i of t){let s=await o(i,e);if(s===null)continue;if(s===void 0)a.push(i);else if(Array.isArray(s))a.push(...s);else a.push(s)}t=a.length>0?a:null}else{let a=await o(t,e);if(a===null)t=null;else if(a===void 0);else t=a}}return t}}function Re(n,r){let e=new Set(Array.isArray(n)?n:[n]);return async(t,o)=>{if(e.has(t.kind))return r(t,o);return}}function as(n,r){return async(e,t)=>{if(n(e))return r(e,t);return}}function et(n){let r={createDeclaration:Ir,cloneDeclaration:Nr,modifyText:(e,t)=>({...e,text:t}),addModifier:(e,t)=>({...e,modifiers:[...e.modifiers||[],t]}),removeModifier:(e,t)=>({...e,modifiers:(e.modifiers||[]).filter((o)=>o!==t)})};return de({name:n.name,version:n.version,description:n.description,onBeforeFile:n.beforeParse?async(e)=>n.beforeParse(e.content,{filePath:e.filePath,phase:"before"}):void 0,onDeclarations:n.transform?async(e)=>Wr(e.declarations,n.transform,{filePath:e.filePath,sourceCode:e.sourceCode,...r}):void 0,onAfterFile:n.afterGenerate?async(e)=>n.afterGenerate(e.content,{filePath:e.filePath,phase:"after"}):void 0})}function cs(n,r){let e=typeof n==="string"?new RegExp(n):n;return(t)=>{if(e.test(t.name)){let o=typeof r==="function"?r(t.name,t):t.name.replace(e,r),a=t.text.replace(new RegExp(`\\b${f(t.name)}\\b`),o);return{...t,name:o,text:a}}return}}function Lr(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${n}${e.name}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function ls(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${e.name}${n}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function Fr(n){let r=typeof n==="function"?n:(e)=>(typeof n==="string"?new RegExp(n):n).test(e.name);return(e)=>{if(r(e))return null;return}}function us(n){return(r)=>{let e=n(r);if(!e)return;let o=(Array.isArray(e)?e:[e]).map((a)=>{if(a.startsWith("/**"))return a;if(a.startsWith("/*"))return a;return`/** ${a} */`});return{...r,leadingComments:[...r.leadingComments||[],...o]}}}function fs(n){return(r)=>{if(!r.typeAnnotation)return;let e=n(r.typeAnnotation,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`:[ ]*${f(r.typeAnnotation)}`),`: ${e}`);return{...r,typeAnnotation:e,text:t}}}function ds(n){return Re("function",(r)=>{if(!r.returnType)return;let e=n(r.returnType,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`\\):[ ]*${f(r.returnType)}`),`): ${e}`);return{...r,returnType:e,text:t}})}function ps(n){return Re(["function","class"],(r)=>{if(!r.parameters)return;let e=n(r.parameters,r);if(e===null)return null;if(e===void 0)return;let t=e.map((a)=>{let i="";if(a.rest)i+="...";if(i+=a.name,a.optional)i+="?";if(a.type)i+=`: ${a.type}`;if(a.defaultValue)i+=` = ${a.defaultValue}`;return i}).join(", "),o=r.text.replace(/\([^)]*\)/,`(${t})`);return{...r,parameters:e,text:o}})}function Br(n,r){return(e)=>{if(r&&!r(e))return;if(e.modifiers?.includes(n))return;let t=[...e.modifiers||[],n],o=e.text;if(!o.includes(n)){let a=["function","class","interface","type","enum","const","let","var"];for(let i of a){let s=o.indexOf(i);if(s>=0){o=`${o.slice(0,s)}${n} ${o.slice(s)}`;break}}}return{...e,modifiers:t,text:o}}}var _r=Re(["interface","type"],(n)=>{let r=n.text.replace(/(\n\s*)(\w+)(\??:\s)/g,"$1readonly $2$3");if(r===n.text)return;return{...n,text:r}}),ms=Re(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)\?:/g,"$1:");if(r===n.text)return;return{...n,text:r}}),hs=Re(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)(?<!\?):/g,"$1?:");if(r===n.text)return;return{...n,text:r}});function gs(n){let r=new RegExp(`@(${n.join("|")})\\b[^@]*`,"g");return(e)=>{if(!e.leadingComments?.length)return;let t=e.leadingComments.map((a)=>a.replace(r,"").replace(/\n\s*\*\s*\n/g,`
3
+ `));if(!t.some((a,i)=>a!==e.leadingComments[i]))return;return{...e,leadingComments:t}}}function ys(n,r){return(e)=>{if(r&&!r(e))return;if(!e.typeAnnotation)return;let t=`${n}<${e.typeAnnotation}>`,o=e.text.replace(e.typeAnnotation,t);return{...e,typeAnnotation:t,text:o}}}var bs=et({name:"readonly",version:"1.0.0",description:"Makes all interface properties readonly",transform:_r}),ws=et({name:"strip-private",version:"1.0.0",description:"Strips @internal, @private, and @hidden declarations",transform:Fr((n)=>{if(!n.leadingComments)return!1;return n.leadingComments.some((r)=>/@(internal|private|hidden)\b/.test(r))})}),xs=et({name:"declare",version:"1.0.0",description:"Adds declare keyword to all declarations",transform:Br("declare",(n)=>n.kind!=="import")});function Cs(n){return et({name:`namespace-prefix-${n}`,version:"1.0.0",description:`Prefixes exported declarations with ${n}`,transform:Lr(`${n}_`,(r)=>r.isExported&&r.kind!=="import")})}function f(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}
4
+ export{Ir,Nr,mn,ss,Wr,os,Re,as,et,cs,Lr,ls,Fr,us,fs,ds,ps,Br,_r,ms,hs,gs,ys,bs,ws,xs,Cs};
@@ -0,0 +1,31 @@
1
+ // @bun
2
+ import{E,ge,Ht,p}from"./chunk-44a6zpxs.js";import{Y}from"./chunk-50r5qs7t.js";import{N,j}from"./chunk-9axwjcna.js";import{I,_}from"./chunk-pq6j9bkd.js";import{s}from"./chunk-vjmwxye4.js";import{Le}from"./chunk-r48h4anw.js";import{e,H}from"./chunk-bd048mjd.js";import{G}from"./chunk-rv597vq5.js";import{he,F,or,re}from"./chunk-chj3hn6f.js";import{sr}from"./chunk-t9w6e58q.js";import{nt,$t}from"./chunk-5vk2x8ee.js";import{M}from"./chunk-e12f4mpd.js";import{Ne,ne,q,We}from"./chunk-v0gpmwh9.js";import{it,K,fe,Tt,Pt,Dt,Rt}from"./chunk-xrtfb38p.js";import{ue,Oe}from"./chunk-253e6nb4.js";import{ut,Gt}from"./chunk-27rxm6hh.js";import{le}from"./chunk-r6bagvr6.js";import{kn,tt}from"./chunk-fnd5bvfd.js";import{te,k,At,Pn}from"./chunk-s7d3d1wx.js";import{dt}from"./chunk-cnb2rfmv.js";import{Me}from"./chunk-h9gwg4kt.js";import{h}from"./chunk-16rpzfwq.js";import{ce,kt}from"./chunk-hd2bq1j5.js";import{mkdir as ze}from"fs/promises";import{availableParallelism as Be}from"os";import{basename as xe,dirname as Re,relative as J,resolve as oe}from"path";var ae=new WeakMap,ye=new WeakMap,ie=new WeakMap;function de(a){let c=ae.get(a);if(!c){let t=ye.has(a)?ye.get(a):void 0;c=t!==void 0?he({...a,effectiveTsconfig:t}):he(a),ae.set(a,c),c.catch(()=>ae.delete(a))}return c}async function De(a,c,t,u,v,g=K){let r=xe(a)||"output.d.ts",R=J(Re(a),c),m=`${r}.map`,C=t.lastIndexOf(`
3
+ ${it()}`),f=C===-1?t:t.slice(0,C),S=Dt(f,r,R,u),w=`${a}.map`;return await g(w,JSON.stringify(S)),e.debug(` Generated source map: ${J(v,w)}`),m}async function l(a){let c=Date.now(),t={...M,...a};if(t.logLevel)H(t.logLevel);else if(t.verbose)H("debug");let u=new Me;if(t.plugins&&t.plugins.length>0){for(let n of t.plugins)u.register(n),e.debug(`Registered plugin: ${n.name}`);t=await u.runOnStart(t)}if(t.moduleSpecifierMode!==void 0&&t.moduleSpecifierMode!=="preserve"&&t.moduleSpecifierMode!=="node")throw Error("moduleSpecifierMode must be preserve or node");if(te(t.engine,"engine"),await ue(t),t.isolatedDeclarations===void 0)try{let n=await G(oe(t.cwd,t.tsconfigPath||"tsconfig.json"));ye.set(t,n??null),t.isolatedDeclarations=n?.isolatedDeclarations??!1}catch{t.isolatedDeclarations=await fe(t)}let v=t.typeMappings?ce(t.typeMappings):void 0,g=null,r={generationMode:t.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},R=0;e.debug("Starting DTS generation..."),e.debug(`Using ${r.generationMode} declaration generation path`),e.debug("Config:",t);let m=await Ne(t,()=>de(t)),C=m.entryFiles,f=[...m.files],{resolver:S,reachability:w}=m;ie.set(t,new Set(f));let b=new Map,D=(n,d)=>{let i=b.get(n);if(i===void 0)i=tt(d),b.set(n,i);return i};if(t.incremental){let n=m.getResolutionFingerprint();if(!t.isolatedDeclarations){let d=new Set(f),i=new Map;for(let y of f){let P=m.sources.get(y)??await p(y);i.set(y,D(y,P));let A=m.reExports.get(y)??F(P,{includeImports:!0});for(let z of A){let V=S(z.specifier,y).resolved;if(V&&!V.split(/[/\\]/).includes("node_modules")&&!d.has(V)){d.add(V);let we=m.sources.get(V)??await p(V);i.set(V,D(V,we))}}}let o=[...i].sort(([y],[P])=>y.localeCompare(P));n=JSON.stringify([n,o])}if(g=new nt(t,n),t.clearCache){if(e.debug("Clearing build cache..."),!t.dryRun)g.clear()}else if(g.load()){let i=g.getStats();e.debug(`Loaded build cache with ${i.entries} entries`)}else e.debug("No existing build cache found, starting fresh");if(!t.dryRun)$t(t.cwd)}if(g&&!t.dryRun){let n=g.prune(new Set(f),t.cwd);if(n>0)e.debug(`Pruned ${n} deleted files from cache`)}if(e.debug(`Found ${f.length} TypeScript files`),t.progress&&f.length>0){let n=t.parallel?"parallel":"sequential";e.info(`Processing ${f.length} files (${n})...`)}let x=new Map,T=new Map,W=async(n,d,i="lf")=>{T.set(n,{content:d,lineEnding:i})},L=new Set(C),B=new Map,U=new Map,se=async(n,d)=>{let i;try{let o=m.outputBySource.get(n)??q(n,t),y=async(O)=>{if(!t.diff)return;try{let X=await p(o),Z=Pt(X,O,J(t.cwd,o));if(Z)e.info(`
4
+ ${Z}`);else e.debug(`[no changes] ${o}`)}catch{e.info(`[new file] ${J(t.cwd,o)}`)}},P=(O)=>{if(!t.validate)return 0;let X=Tt(O,o);if(X.isValid)return e.debug(`[validation] ${o} - OK`),0;e.warn(`[validation] ${J(t.cwd,o)} has ${X.errors.length} error(s):`);for(let Z of X.errors){let Ce=` Line ${Z.line}:${Z.column}`;if(Z.code)Ce+=` [${Z.code}]`;if(Ce+=` - ${Z.message}`,e.warn(Ce),Z.suggestion)e.warn(` Suggestion: ${Z.suggestion}`)}return X.errors.length},A=(O)=>{e.info(`[dry-run] Would generate: ${o}`),e.debug("--- Content preview ---"),e.debug(O.slice(0,500)+(O.length>500?`
5
+ ...`:"")),e.debug("--- End preview ---")};if(g){let O=g.getCachedIfValid(n,t.cwd);if(O){if(t.bundle)x.set(n,O);await y(O);let X=P(O);if(t.dryRun)A(O);else if(!t.bundle||C.length===0||L.has(n)){if(t.declarationMap)i=d??await p(n),await De(o,n,O,i,t.cwd,W);await W(o,O,t.lineEnding)}return e.debug(`[cached] ${J(t.cwd,o)}`),{success:!0,file:n,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:X}}}i=d??await p(n);let z=B.get(n),{content:V,declarationCount:we,importCount:ke,exportCount:Ge}=z!==void 0?await ve(z,n,i,t,u,v,be(z),m.resolver,m.outputBySource):await Te(n,i,t,u,v,m.augmentationImports.get(n),ee,b,m.reExports.get(n),U.get(n));if(t.bundle)x.set(n,V);let Q=V;if(t.prettier||t.indentStyle||t.indentSize){let O=await le(Q,{usePrettier:t.prettier,builtIn:{indentSize:t.indentSize||2,useTabs:t.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},o);Q=O.content;for(let X of O.warnings??[])e.warn(`[format] ${X}`)}if(t.declarationMap){let O=`${xe(o)||"output.d.ts"}.map`;Q=Rt(Q,O)}await y(Q);let Ie=P(Q);if(t.dryRun)A(Q);else{if(!t.bundle||C.length===0||L.has(n)){if(t.declarationMap&&i)await De(o,n,Q,i,t.cwd,W);await W(o,Q,t.lineEnding)}if(g&&i)g.update(n,i,Q,t.cwd);e.debug(`Generated: ${o}`)}return{success:!0,file:n,declarationCount:we,importCount:ke,exportCount:Ge,validationErrorCount:Ie}}catch(o){let y=ut(o,n,i);if(t.plugins&&t.plugins.length>0)await u.runOnError(o instanceof Error?o:Error(String(o)),n,i||"");return{success:!1,file:n,declarationCount:0,importCount:0,exportCount:0,dtsError:y,validationErrorCount:0}}},pe=t.parallel||t.parallel!==!1&&f.length>=10,me=Y(t.concurrency,Be?.()??8),ee=new Map;for(let[n,d]of m.sources)ee.set(n,d);if(pe&&f.length>1){let n=f.filter((d)=>!ee.has(d));if(n.length>0){let d=n.map(async(i)=>{try{let o=await p(i);return{file:i,source:o}}catch{return{file:i,source:null}}});for(let i of await Promise.all(d))if(i.source!==null)ee.set(i.file,i.source)}}let Ee=t.importOrder??["bun"];if(pe&&f.length>=4&&!g&&Ee.length===1&&Ee[0]==="bun"&&!u.hasDeclarationHooks()&&!u.hasBeforeFileHooks()&&k(t.engine)==="native"){let n=[],d=[];for(let i of f){if(N(i)||I(i))continue;if((m.augmentationImports.get(i)?.size??0)>0)continue;let o=ee.get(i);if(o===void 0)continue;if(!t.isolatedDeclarations&&o.includes("import")&&o.includes("(")){let y=await Fe(i,o,o,t,ee,b,m.reExports.get(i));if(y.size>0){U.set(i,y);continue}}n.push(i),d.push({source:o,sourceFile:i})}if(d.length>=4){let i=Pn(d,{keepComments:t.keepComments??!0,isolatedDeclarations:t.isolatedDeclarations??!1,engine:t.engine,threadCount:me});if(i)for(let o=0;o<n.length;o++){let y=i[o];if(y!==null)B.set(n[o],y)}}}let $e=(n)=>{if(r.filesProcessed++,n.success){if(n.cached)R++;else r.filesGenerated++,r.declarationsFound+=n.declarationCount,r.importsProcessed+=n.importCount,r.exportsProcessed+=n.exportCount;if(t.validate){if(r.filesValidated++,n.validationErrorCount)r.validationErrors+=n.validationErrorCount}}else if(r.filesFailed++,n.dtsError){r.errors.push(n.dtsError);let d=Gt(n.dtsError);if(t.continueOnError)e.warn(d);else throw e.error(d),Error(n.dtsError.message)}};if(B.size===f.length&&!g&&!t.diff&&!t.validate&&!t.dryRun&&!t.declarationMap&&!t.progress&&!v&&t.normalizeOutput!==!0&&!t.declarationOrder&&!u.hasAfterFileHooks()){let n=ie.get(t),d=t.lineEnding??"lf";for(let i=0;i<f.length;i++){let o=f[i],y=B.get(o),P=Se(y,o,t,m.resolver,n,m.outputBySource);if(t.bundle)x.set(o,P);if(!t.bundle||C.length===0||L.has(o)){let z=m.outputBySource.get(o)??q(o,t);T.set(z,{content:P,lineEnding:d})}let A=be(y);r.filesProcessed++,r.filesGenerated++,r.declarationsFound+=A.declarationCount,r.importsProcessed+=A.importCount,r.exportsProcessed+=A.exportCount}}else if(pe)for(let n=0;n<f.length;n+=me){let d=f.slice(n,n+me),i=await Promise.all(d.map((o)=>se(o,ee.get(o))));for(let o of i)$e(o);if(t.progress){let o=Math.round(r.filesProcessed/f.length*100);e.info(`[${r.filesProcessed}/${f.length}] ${o}%`)}}else for(let n of f){let d=await se(n,ee.get(n));if($e(d),t.progress){let i=Math.round(r.filesProcessed/f.length*100),o=d.cached?"[cached]":"";e.info(`[${r.filesProcessed}/${f.length}] ${i}% - ${J(t.cwd,n)} ${o}`)}}if(!t.bundle){let n=[];if(w)for(let d of w.unresolved)n.push({from:d.from,specifier:d.specifier,reason:"missing"});if(t.autoIncludeReExports===!1&&f.length>0){let d=new Set(f);for(let i of f){let o;try{o=await p(i)}catch{continue}for(let y of F(o)){let P=S(y.specifier,i);if(!P.isRelative)continue;if(!P.resolved)n.push({from:i,specifier:y.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(P.resolved)&&!d.has(P.resolved))n.push({from:i,specifier:y.specifier,reason:"not-emitted"})}}}if(n.length>0){let d=[];d.push(`Found ${n.length} re-export(s) pointing at siblings that won't be in the output:`);for(let o of n){let y=J(t.cwd,o.from);if(o.reason==="missing")d.push(` ${y} \u2192 '${o.specifier}' (path not found on disk)`);else d.push(` ${y} \u2192 '${o.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let i=d.join(`
6
+ `);if(t.failOnUnresolvedReExport)throw Error(i);e.warn(i),e.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(t.bundle&&(r.filesGenerated>0||R>0)&&C.length>0)try{e.debug("Bundling declarations...");let n=C.length===1&&!!t.bundleOutput;for(let d of C){let i=C.length===1&&w?w:await re([d],{includeImports:!0,resolveSpecifier:S,knownSources:ee}),o=new Set;for(let z of i.reachable){if(z.endsWith(".d.ts"))continue;if(z.includes("node_modules"))continue;o.add(z)}let y=f.filter((z)=>o.has(z));if(!y.includes(d))y.push(d);let P=sr(d,y,x,{cwd:t.cwd,keepComments:t.keepComments,resolver:m.resolver});for(let z of new Set(P.warnings))e.warn(`[bundle] ${z}`);let A=n?oe(t.cwd,t.outdir,t.bundleOutput):q(d,t);if(t.dryRun)e.info(`[dry-run] Would bundle ${P.files.length} files to: ${J(t.cwd,A)}`);else await W(A,P.content,t.lineEnding),e.debug(`Prepared ${P.files.length} bundled files for: ${J(t.cwd,A)}`);if(n)break}}catch(n){let d=n instanceof Error?n.message:String(n);throw e.error(`Bundle failed: ${d}`),n}if(!t.dryRun)await Oe(t,T,{skipSafetyCheck:!0});if(g&&!t.dryRun)g.save(),e.debug("Saved build cache");if(r.durationMs=Date.now()-c,t.stats)if(t.outputFormat==="json")console.log(JSON.stringify(r,null,2));else{if(e.info(`
7
+ --- Generation Statistics ---`),e.info(`Files processed: ${r.filesProcessed}`),e.info(`Files generated: ${r.filesGenerated}`),R>0)e.info(`Files cached: ${R}`);if(r.filesFailed>0)e.info(`Files failed: ${r.filesFailed}`);if(e.info(`Declarations found: ${r.declarationsFound}`),e.info(`Imports processed: ${r.importsProcessed}`),e.info(`Exports processed: ${r.exportsProcessed}`),r.filesValidated>0){if(e.info(`Files validated: ${r.filesValidated}`),r.validationErrors>0)e.info(`Validation errors: ${r.validationErrors}`)}if(e.info(`Duration: ${r.durationMs}ms`),r.errors.length>0){e.info(`
8
+ Errors:`);for(let n of r.errors){let d=` - ${n.file}`;if(n.location)d+=`:${n.location.line}:${n.location.column}`;if(n.code)d+=` [${n.code}]`;if(d+=`: ${n.message}`,e.info(d),n.suggestion)e.info(` Suggestion: ${n.suggestion}`)}}e.info(`-----------------------------
9
+ `)}if(t.plugins&&t.plugins.length>0)await u.runOnEnd(r);return e.debug("DTS generation complete!"),r}function Se(a,c,t,u,v,g){if(!a.includes("from")&&!a.includes("import")&&!a.includes("module"))return a;let r=We(c,t,u,v,g);return or(a,(R)=>r(R).emittedSpecifier)}async function Ae(a,c,t,u,v){if(!a.includes("from")&&!a.includes("import")&&!a.includes("module"))return a;let g=u??await de(t);return Se(a,c,t,g,ie.get(t),v)}async function Zs(a,c){ae.delete(c),ie.delete(c);let t=await de(c),u=await re([a],{includeImports:!0,resolveSpecifier:t}),v=await Le([...u.sources.keys()],t,c.isolatedDeclarations??!1,u.sources);return(await Pe(a,c,void 0,v.get(oe(a)))).content}async function Pe(a,c,t,u){let v=await p(a),g=c.typeMappings?ce(c.typeMappings):void 0;return Te(a,v,c,t,g,u)}async function Fe(a,c,t,u,v,g,r){let R=new Map;if(u.isolatedDeclarations||!c.includes("import")||!c.includes("("))return R;let m=await de(u),C=[],f=(w,b,D)=>{let x=g?.get(b);if(x===void 0)x=tt(D),g?.set(b,x);if(x.length===0)return;if(!x.some((T)=>T.isDefault||c.includes(T.name)))return;R.set(w,D)},S=r&&c===t?r:F(c,{includeImports:!0});for(let w of S){if(w.kind!=="import"||w.isTypeOnly)continue;let b=m(w.specifier,a).resolved;if(!b||b.split(/[/\\]/).includes("node_modules"))continue;let D=v?.get(b);if(D!==void 0)f(w.specifier,b,D);else C.push({specifier:w.specifier,resolved:b})}if(C.length===1)f(C[0].specifier,C[0].resolved,await p(C[0].resolved));else if(C.length>1){let w=await Promise.all(C.map((b)=>p(b.resolved)));for(let b=0;b<C.length;b++)f(C[b].specifier,C[b].resolved,w[b])}return R}async function Te(a,c,t,u,v,g,r,R,m,C){let f=c;if(u)f=await u.runOnBeforeFile(a,c);let S=C&&f===c?C:await Fe(a,f,c,t,r,R,m),w=u?.hasDeclarationHooks()?null:He(f,a,t,S,g);if(w!==null)return ve(w,a,f,t,u,v,be(w));let b=S.size?kn(f,S):void 0,D=s(f,a,t.keepComments,t.isolatedDeclarations??!1,b);if(u)D=await u.runOnDeclarations(a,f,D);let x=0,T=0;for(let B=0;B<D.length;B++){let U=D[B];if(U.kind==="import")x++;if(U.kind==="export"||U.isExported)T++}let L=h(D,{filePath:a,sourceCode:f,declarations:D,augmentationImports:g},t.keepComments,t.importOrder);return ve(L,a,f,t,u,v,{declarationCount:D.length,importCount:x,exportCount:T})}function be(a){let c=0,t=0,u=0,v=a.length,g=0;while(g<v){let r=a.indexOf(`
10
+ `,g);if((r===-1?v:r)>g){let m=a.charCodeAt(g);if(m!==32&&m!==9&&m!==125&&m!==42&&m!==47&&m!==13){if(c++,m===105&&a.startsWith("import ",g))t++;else if(m===101&&a.startsWith("export ",g))u++}}if(r===-1)break;g=r+1}return{declarationCount:c,importCount:t,exportCount:u}}function He(a,c,t,u,v){let g=t.importOrder??["bun"];if(g.length!==1||g[0]!=="bun")return null;let r=N(c)?j(a):I(c)?_(a):a;return At(r,{keepComments:t.keepComments??!0,isolatedDeclarations:t.isolatedDeclarations??!1,engine:t.engine,sourceFile:c,inferenceSources:u,augmentationImports:v})}async function ve(a,c,t,u,v,g,r,R,m){let C=R?Se(a,c,u,R,ie.get(u),m):await Ae(a,c,u);if(g)C=kt(C,g,{filePath:c});if(u.normalizeOutput===!0||u.declarationOrder)C=dt(C,{lineEnding:"lf",declarationOrder:u.declarationOrder,indent:{style:u.indentStyle??"spaces",size:u.indentSize??2}});if(v)C=await v.runOnAfterFile(c,t,C);return{content:C,...r}}async function eo(a){let c={...M,...a};if(c.logLevel)H(c.logLevel);let t=oe(c.cwd,c.root),u=150,v=5,g=1e4,r={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 l(c),e.info(`[watch] Initial generation complete
12
+ `)}catch(S){let w=S instanceof Error?S.message:String(S);e.error(`[watch] Initial generation failed: ${w}`),e.info(`[watch] Continuing to watch for changes...
13
+ `)}async function R(){if(r.isProcessing||r.pendingChanges.size===0)return;let S=Date.now();if(r.errorCount>=v){if(S-r.lastErrorTime<g){e.warn(`[watch] Too many errors, pausing for ${Math.ceil((g-(S-r.lastErrorTime))/1000)}s...`);return}r.errorCount=0}r.isProcessing=!0;let w=Array.from(r.pendingChanges);r.pendingChanges.clear();let b=new Date().toLocaleTimeString();if(w.length===1)e.info(`
14
+ [${b}] File changed: ${w[0]}`);else e.info(`
15
+ [${b}] ${w.length} files changed`);let D=0,x=0;for(let T of w){let W=oe(t,T);try{let L=c.exclude||[];if(ne(W,L,t)){e.debug(` Skipping excluded file: ${T}`);continue}if(!await ge(W).exists()){e.debug(` Skipping deleted file: ${T}`);continue}let U=q(W,c),{content:se}=await Pe(W,c);await ze(Re(U),{recursive:!0}),await K(U,se,c.lineEnding),e.info(` \u2713 ${J(c.cwd,U)}`),D++}catch(L){x++,r.errorCount++,r.lastErrorTime=Date.now();let B=ut(L,W);if(e.error(` \u2717 ${T}: ${B.message}`),B.suggestion)e.error(` Suggestion: ${B.suggestion}`)}}if(w.length>1)e.info(` Done: ${D} generated, ${x} failed`);if(x===0)r.errorCount=0;if(r.isProcessing=!1,r.pendingChanges.size>0)r.debounceTimer=setTimeout(R,u)}function m(S){if(r.pendingChanges.add(S),r.debounceTimer)clearTimeout(r.debounceTimer);r.debounceTimer=setTimeout(R,u)}let f=Ht([E?"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(E){let S=f.stdout.getReader(),w=new TextDecoder,b="";while(!0){let{done:D,value:x}=await S.read();if(D)break;b+=w.decode(x,{stream:!0});let T=b.split(`
29
+ `);b=T.pop()||"";for(let W of T)if(W.startsWith("CHANGED:")){let L=W.slice(8);m(L)}}}else{let S=f.stdout,w="";S.on("data",(b)=>{w+=b.toString();let D=w.split(`
30
+ `);w=D.pop()||"";for(let x of D)if(x.startsWith("CHANGED:")){let T=x.slice(8);m(T)}}),await f.exited}}
31
+ export{l,Zs,eo};
@@ -0,0 +1,10 @@
1
+ // @bun
2
+ import{Q,Yt,br}from"./chunk-30ffarqm.js";import{Dn}from"./chunk-j41nnny5.js";import{y}from"./chunk-4th0w19y.js";import{Ve,T}from"./chunk-cb5dj4qy.js";import{ye,A,be,we,xe,Ce,ve}from"./chunk-wfkkp4tx.js";import{cr}from"./chunk-5tcpge5e.js";import{Fe}from"./chunk-8t9qp0mq.js";function G(g,x){throw Error(x||`Unexpected value: ${g}`)}var V=null,j=[],q=[];function h(g,x,u=!0,D=["bun"]){let a="",p=x.sourceCode;if(p){let e=0;while(e<p.length&&(p.charCodeAt(e)===32||p.charCodeAt(e)===9||p.charCodeAt(e)===10||p.charCodeAt(e)===13))e++;if(e<p.length-2&&p.charCodeAt(e)===47&&p.charCodeAt(e+1)===47&&p.charCodeAt(e+2)===47){let i=Dn(p);if(i.length>0)for(let o=0;o<i.length;o++){if(a)a+=`
3
+ `;a+=i[o]}}}let I=[],N=[],M=[],P=[],U=[],W=[],_=[],E=[],w=[];for(let e of g){let i=e.kind;switch(i){case"import":I.push(e);break;case"function":N.push(e);break;case"variable":M.push(e);break;case"interface":P.push(e);break;case"type":U.push(e);break;case"class":W.push(e);break;case"enum":_.push(e);break;case"module":E.push(e);break;case"export":w.push(e);break;case"namespace":E.push(e);break;case"unknown":break;default:G(i,`Unhandled declaration kind: ${i}`)}}let S=[],C=[],v=[],L=new Set;for(let e of w){let i=y(e.leadingComments,u);if(e.text.startsWith("export default")){let o=e.text.endsWith(";")?e.text:`${e.text};`;v.push(i+o)}else{let o=e.text.trim();if(!o.endsWith(";"))o+=";";let t=i+o;if(!L.has(t))if(L.add(t),t.includes("export type"))S.push(t);else C.push(t)}}let f=[];if(I.length>0){let{usedItems:e}=Fe(g);for(let o of I){if(o.isSideEffect){let r=o.text.trim(),c=r.endsWith(";")?r:`${r};`;f.push(c);continue}let t=T(o.text);if(!t)continue;let{defaultName:s,namedItems:n,isTypeOnly:m,namespaceName:l}=t,d=s?e.has(s):!1,K=l?e.has(l):!1;if(t.isImportEquals){if(d){let r=o.text.trim();f.push(r.endsWith(";")?r:`${r};`)}else if(x.augmentationImports?.has(t.source)){let r=Ve(o.text);if(!r)throw Error("Cannot locate an augmentation import module literal");f.push(`import ${r};`)}continue}let b="",k=0;for(let r=0;r<n.length;r++){let c=n[r];if(e.has(c.name)){if(k>0)b+=", ";if(!m&&c.isTypeOnly)b+="type ";b+=c.originalName===c.name?c.name:`${c.originalName} as ${c.name}`,k++}}if(d||K||k>0){let r=m?"import type ":"import ";if(K&&l){if(d&&s)r+=`${s}, `;r+=`* as ${l}`}else if(d&&s)r+=k>0?`${s}, { ${b} }`:s;else if(k>0)r+=`{ ${b} }`;let c=t.sourceLiteral??Ve(o.text);if(!c)throw Error("Cannot locate a grammatical module literal in the import declaration");let z=t.attributes?` ${t.attributes}`:"";r+=` from ${c}${z};`,f.push(r)}else if(x.augmentationImports?.has(t.source)){let r=t.sourceLiteral??Ve(o.text);if(!r)throw Error("Cannot locate an augmentation import module literal");let c=t.attributes?` ${t.attributes}`:"";f.push(`import ${r}${c};`)}}let i=D.length;if(f.length>1){if(V!==D)V=D,j=D.map((n)=>`from '${n}`),q=D.map((n)=>`from "${n}`);let o=j,t=q,s=new Map;for(let n of f){let m=i;for(let l=0;l<D.length;l++)if(n.includes(o[l])||n.includes(t[l])){m=l;break}s.set(n,m)}f.sort((n,m)=>{let l=s.get(n),d=s.get(m);return l!==d?l-d:n.localeCompare(m)})}}for(let e=0;e<f.length;e++){if(a)a+=`
4
+ `;a+=f[e]}for(let e=0;e<S.length;e++){if(a)a+=`
5
+ `;a+=S[e]}let F=[N,M,P,U,W,_,E];for(let e=0;e<F.length;e++){let i=F[e];for(let o=0;o<i.length;o++){let t=i[o],s="",n=t.kind;switch(n){case"function":s=ye(t,u);break;case"variable":s=A(t,u);break;case"interface":s=be(t,u);break;case"type":s=we(t,u);break;case"class":s=xe(t,u);break;case"enum":s=Ce(t,u);break;case"module":case"namespace":s=ve(t,u);break;case"import":case"export":case"unknown":break;default:G(n,`Unhandled declaration kind in processor: ${n}`)}if(s){if(a)a+=`
6
+ `;a+=s}}}for(let e=0;e<C.length;e++){if(a)a+=`
7
+ `;a+=C[e]}for(let e=0;e<v.length;e++){if(a)a+=`
8
+ `;a+=v[e]}if(w.length===0&&(cr(g)??Q(x.sourceCode))&&(g.some(br)||!Yt(a)))a+=`${a?`
9
+ `:""}export {};`;return a}
10
+ export{h};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{R}from"./chunk-v0gpmwh9.js";import{K}from"./chunk-xrtfb38p.js";import{chmod as et,lstat as F,mkdir as A,readdir as ut,realpath as lt,rename as G,rm as at,rmdir as dt,stat as rt,writeFile as ft}from"fs/promises";import{basename as pt,dirname as v,isAbsolute as it,parse as wt,relative as nt,resolve as p}from"path";function y(e,r){return e instanceof Error&&"code"in e&&e.code===r}async function E(e){try{return await F(e)}catch(r){if(y(r,"ENOENT"))return;throw r}}async function x(e){let r=p(e);try{return await lt(r)}catch(w){if(!y(w,"ENOENT")||v(r)===r)throw w;return p(await x(v(r)),pt(r))}}async function ue(e){let r=p(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(it(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!R(p(r,e.bundleOutput),r))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(r===wt(r).root)throw Error("Refusing to clean declarations from the filesystem root");let[w,i]=await Promise.all([x(r),x(p(e.cwd,e.root))]);if(R(i,w))throw Error("Refusing to clean an outdir that contains the source root")}function ot(e){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((r)=>e.endsWith(r))}function L(e,r){return e.dev===r.dev&&e.ino===r.ino}async function _(e,r){try{return await A(e),r.push(e),!0}catch(i){if(y(i,"EEXIST")){if(!(await rt(e)).isDirectory())throw Error(`Declaration output parent is not a directory: ${e}`);return!1}if(!y(i,"ENOENT"))throw i}let w=v(e);if(w===e)throw Error(`Cannot create declaration output directory: ${e}`);await _(w,r);try{return await A(e),r.push(e),!0}catch(i){if(!y(i,"EEXIST")||!(await rt(e)).isDirectory())throw i;return!1}}async function st(e,r,w){let i=(await ut(e,{withFileTypes:!0})).sort((g,d)=>g.name.localeCompare(d.name)),n=[],h=[];for(let g of i){let d=p(e,g.name);if(d===r)continue;if(g.isDirectory())n.push(d);else if(ot(g.name))h.push(d)}if(h.length>0){let g=await Promise.all(h.map((d)=>E(d)));for(let d=0;d<h.length;d++){let I=g[d];if(!I)throw Error(`Declaration output changed during inventory: ${h[d]}`);w.set(h[d],I)}}for(let g of n)await st(g,r,w)}function W(e,r,w,i,n){return Object.assign(AggregateError(r,e),{code:"DTSX_PUBLICATION_FAILED",phase:w,recoveryDirectory:i,outputsCommitted:n})}async function Oe(e,r,w){if(e.dryRun||r.size===0&&!e.clean)return;if(!w?.skipSafetyCheck)await ue(e);let i=p(e.cwd,e.outdir);if(r.size===0&&!await E(i))return;let n=p(i,".dtsx-publication"),h=new Map;for(let[c,u]of r){let s=p(c);if(!it(c)||s===i||!R(s,i)||R(s,n)||!ot(s))throw Error(`Invalid declaration publication target: ${c}`);if(h.has(s))throw Error(`Duplicate declaration publication target: ${c}`);h.set(s,u)}let g=[],d=[],I=[],z=!1,M,b,q=!1;async function P(c,u){let s=v(c);if(s===i)return;let o=await x(s);if(!R(o,u))throw Error(`Declaration publication parent escapes outdir: ${c}`);if(R(o,p(u,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${c}`)}async function B(){if(!z)return;if(!M)throw Error(`Cannot verify declaration publication ownership: ${n}`);let[c,u]=await Promise.all([E(n),b?x(n):Promise.resolve(void 0)]);if(!c||!L(c,M))throw Error(`Declaration publication ownership changed: ${n}`);if(b&&u!==p(b,".dtsx-publication"))throw Error(`Declaration publication location changed: ${n}`);await at(n,{recursive:!0})}try{let c=await _(i,g);try{await A(n)}catch(t){if(y(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${n}`,{cause:t});throw t}z=!0;let u=new Map,s=[...h.keys()],[o,l,V,H,X]=await Promise.allSettled([F(n),x(i),A(p(n,"staged")),e.clean&&!c?st(i,n,u):Promise.resolve(),c?Promise.resolve(Array(s.length)):Promise.all(s.map((t)=>E(t)))]);if(o.status==="fulfilled")M=o.value;if(l.status==="fulfilled")b=l.value;if(o.status==="rejected")throw o.reason;if(l.status==="rejected")throw l.reason;if(V.status==="rejected")throw V.reason;if(H.status==="rejected")throw H.reason;if(X.status==="rejected")throw X.reason;let C=l.value,ct=X.value,N=new Set;for(let t of h.keys()){let a=v(t);if(!N.has(a))await P(t,C),N.add(a)}for(let t=0;t<s.length;t++){let a=ct[t];if(a&&!a.isFile())throw Error(`Declaration publication target is not a regular file: ${s[t]}`);if(a)u.set(s[t],a)}for(let t of u.keys()){let a=v(t);if(!N.has(a))await P(t,C),N.add(a)}if(u.size>0)await A(p(n,"backups"));let S=new Map;for(let t of new Set([...u.keys(),...h.keys()])){let a=S.size.toString();S.set(t,{path:t,existing:u.get(t),backup:p(n,"backups",a),staged:h.has(t)?p(n,"staged",a):void 0})}let J=ft(p(n,"manifest.json"),JSON.stringify({version:1,outdir:i,targets:[...S.values()].map((t)=>({path:nt(i,t.path),backup:nt(n,t.backup),hadPrevious:!!t.existing}))})),j=[...h.entries()],k=64;if(j.length<=k){let t=await Promise.allSettled([J,...j.map(async([a,f])=>{let m=S.get(a),D=m.staged;if(await K(D,f.content,f.lineEnding),!e.clean&&m.existing)await et(D,m.existing.mode&511);m.stagedIdentity=await F(D)})]);for(let a of t)if(a.status==="rejected")throw a.reason}else{await J;for(let t=0;t<j.length;t+=k)await Promise.all(j.slice(t,t+k).map(async([a,f])=>{let m=S.get(a),D=m.staged;if(await K(D,f.content,f.lineEnding),!e.clean&&m.existing)await et(D,m.existing.mode&511);m.stagedIdentity=await F(D)}))}let O=[],U=new Set;for(let t of S.values()){if(!t.existing)continue;let a=v(t.path);if(!U.has(a))await P(t.path,C),U.add(a);O.push(t)}let Y=[];for(let t=0;t<O.length;t+=k){let a=await Promise.all(O.slice(t,t+k).map((f)=>E(f.path)));for(let f of a)Y.push(f)}for(let t=0;t<O.length;t++){let a=O[t],f=Y[t];if(!f||!L(f,a.existing))throw Error(`Declaration output changed before commit: ${a.path}`)}for(let t of O)await G(t.path,t.backup),d.push(t);let T=[],Q=new Set,Z=new Set([i]);for(let t of S.values()){if(!t.staged||!t.stagedIdentity)continue;let a=v(t.path);if(!Q.has(a)){if(await P(t.path,C),!Z.has(a))await _(a,g),Z.add(a),await P(t.path,C);Q.add(a)}T.push(t)}let tt=[];for(let t=0;t<T.length;t+=k){let a=await Promise.all(T.slice(t,t+k).map((f)=>E(f.path)));for(let f of a)tt.push(f)}for(let t=0;t<T.length;t++)if(tt[t])throw Error(`Declaration output appeared during commit: ${T[t].path}`);for(let t of T)await G(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity});q=!0;try{await B()}catch(t){throw W(`Declaration outputs committed, but transaction cleanup failed at ${n}`,[t],"finalize",n,!0)}}catch(c){if(q)throw c;let u=[];for(let o of I.toReversed())try{if(b)await P(o.path,b);let l=await E(o.path);if(!l)continue;if(!L(l,o.identity))throw Error(`Installed declaration changed before rollback: ${o.path}`);await at(o.path)}catch(l){u.push(l)}for(let o of d.toReversed())try{if(b)await P(o.path,b);if(await E(o.path))throw Error(`Cannot restore declaration over an existing path: ${o.path}`);await G(o.backup,o.path)}catch(l){u.push(l)}if(u.length>0)throw W(`Declaration rollback failed; recovery data retained at ${n}`,[c,...u],"rollback",n,!1);let s=[];try{await B()}catch(o){s.push(o)}for(let o of g.toReversed())try{await dt(o)}catch(l){if(!y(l,"ENOENT")&&!y(l,"ENOTEMPTY")&&!y(l,"EEXIST"))s.push(l)}if(s.length>0)throw W(`Prior declarations retained, but publication cleanup failed at ${n}`,[c,...s],"cleanup",z?n:void 0,!1);throw c}}
3
+ export{ue,Oe};
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import{n,f}from"./chunk-b5wcbnb8.js";import{r}from"./chunk-kp395d2p.js";var M=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","await","eval","arguments"]),E=new Set(["export","const","let","var","function","class","interface","type","enum","namespace","declare","import","abstract","async"]);function dr(a,w,_,b){let u=new Map,s=new Map;for(let e of[...w,..._.values(),...[...b.values()].flat()])if(u.set(e.name,e),e.kind==="function")s.set(e.name,e);for(let[e,t]of b)if(t.length)s.set(e,t[t.length-1]);if(!s.size)return;if(!a.includes(".")||!a.includes("="))return;let k=!1;for(let e of s.keys()){let t=a.indexOf(e);while(t!==-1){let i=t+e.length;while(i<a.length){let y=a.charCodeAt(i);if(y===32||y===9||y===10||y===13){i++;continue}break}if(i<a.length&&a.charCodeAt(i)===46){k=!0;break}t=a.indexOf(e,t+1)}if(k)break}if(!k)return;let c=new Set;for(let[e,t]of b)if(t.length>1)c.add(e);let S=new Map;for(let e of w)if(e.kind==="function"){let t=(S.get(e.name)??0)+1;if(S.set(e.name,t),t>1)c.add(e.name)}let l=f(a),g=(e)=>l[e]?a.slice(l[e].start,l[e].end):"",v=new Map,x=0;for(let e=0;e<l.length;e++){let t=l[e];if(t.kind==="punctuation"){let h=a.charCodeAt(t.start);if(h===40||h===91||h===123)x++;else if(h===41||h===93||h===125)x--;continue}if(x||e>0&&g(e-1)==="."||l[e+2]?.kind!=="word"||g(e+1)!=="."||g(e+3)!=="="||g(e+4)==="=")continue;let i=g(e);if(!s.has(i))continue;let y=g(e+2),A=e+4,m=A,d=0;for(;m<l.length;m++){let h=g(m);if(!d&&h===";")break;if(!d&&m>A&&/[\r\n]/.test(a.slice(l[m-1].end,l[m].start))&&(E.has(h)||s.has(h)&&g(m+1)==="."))break;if(["(","[","{"].includes(h))d++;else if([")","]","}"].includes(h))d--}if(m===A)continue;let o=R(a.slice(l[A].start,l[m-1].end),u,c),D=v.get(i);if(!D)v.set(i,D=new Map);let p=D.get(y);if(!p)D.set(y,p=[]);if(!p.includes(o))p.push(o);e=m-1}for(let[e,t]of v){let i=s.get(e),y=[...t.keys()].some((d)=>M.has(d)),A=[...t].map(([d,o])=>{let D=o.map((p)=>p.includes("=>")&&o.length>1?`(${p})`:p).join(" | ");if(M.has(d)){let p=`__dtsx_prop_${d}`;while(t.has(p))p+="_";return` let ${p}: ${D};
3
+ export { ${p} as ${d} };`}return` ${y?"export ":""}let ${d}: ${D};`}).join(`
4
+ `),m=i.isExported&&!i.isDefault?"export ":"";if(i.isDefault){for(let o of w)if(o!==i&&o.kind==="function"&&o.name===e&&o.isDefault)o.text=o.text.replace("export default function ","declare function ");let d=b.get(e);if(d){for(let o of d)if(o!==i&&o.kind==="function"&&o.name===e&&o.isDefault)o.text=o.text.replace("export default function ","declare function ")}i.text=i.text.replace("export default function ","declare function ")}if(i.text+=`
5
+ ${m}declare namespace ${e} {
6
+ ${A}
7
+ }`,i.isDefault)i.text+=`
8
+ export default ${e};`}}function R(a,w,_,b=0){let u=a.trim(),s=w.get(u);if(s?.kind==="variable"&&b<64){if(s.typeAnnotation)return s.typeAnnotation==="unique symbol"?`typeof ${u}`:s.typeAnnotation;if(typeof s.value==="string")return R(s.value,w,_,b+1)}let k=r(u,!1);if(k!=="unknown")return k;let c=n(u);if(c[0]?.kind==="word"&&c[1]&&u.slice(c[1].start,c[1].end)==="("&&u.endsWith(")")){let S=0,l=-1;for(let x=1;x<c.length;x++){let e=u.slice(c[x].start,c[x].end);if(e==="(")S++;else if(e===")"&&--S===0){l=x;break}}if(l!==c.length-1)return k;let g=u.slice(c[0].start,c[0].end),v=w.get(g);if(v?.kind==="function"&&!v.generics&&!_.has(g))return`ReturnType<typeof ${g}>`}if(/^[$A-Z_a-z][$\w]*(?:\.[$A-Z_a-z][$\w]*)*$/.test(u))return`typeof ${u}`;return k}
9
+ export{dr};
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- var Se={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class T extends Error{code;context;constructor(n,e="UNKNOWN_ERROR",t){super(n);if(this.name="DtsxError",this.code=e,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let n=`${this.name} [${this.code}]: ${this.message}`;if(this.context)n+=`
3
- Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class An extends T{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class fi extends T{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class di extends T{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class Dn extends T{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Pn extends T{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class pi extends T{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function Co(n){return n instanceof T}function vo(n){return n instanceof An}function So(n){return n instanceof Dn}function $o(n){return n instanceof Pn}function Eo(n,e="UNKNOWN_ERROR",t){if(n instanceof T)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new T(s,e);if(n instanceof Error)r.cause=n;return r}function ko(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
4
- `)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function To(n,e,t,s){let r=n.split(`
2
+ var je={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class W extends Error{code;context;constructor(n,e="UNKNOWN_ERROR",t){super(n);if(this.name="DtsxError",this.code=e,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let n=`${this.name} [${this.code}]: ${this.message}`;if(this.context)n+=`
3
+ Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class zn extends W{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class Wi extends W{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class Li extends W{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class Hn extends W{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Kn extends W{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class Fi extends W{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function ra(n){return n instanceof W}function ia(n){return n instanceof zn}function sa(n){return n instanceof Hn}function oa(n){return n instanceof Kn}function aa(n,e="UNKNOWN_ERROR",t){if(n instanceof W)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new W(s,e);if(n instanceof Error)r.cause=n;return r}function ca(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
4
+ `)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function la(n,e,t,s){let r=n.split(`
5
5
  `),i=e.line-1,o=[];if(s)o.push(`${s}:${e.line}:${e.column}`);else o.push(`Line ${e.line}, Column ${e.column}`);o.push(`Error: ${t}`),o.push("");let E=Math.max(0,i-1),c=Math.min(r.length-1,i+1);for(let a=E;a<=c;a++){let R=(a+1).toString().padStart(4," "),u=a===i?">":" ";if(o.push(`${u} ${R} | ${r[a]}`),a===i){let l=" ".repeat(8+e.column-1);o.push(`${l}^`)}}return o.join(`
6
- `)}function Qe(n,e,t){let s={file:e,message:"Unknown error",code:Se.UNKNOWN_ERROR};if(n instanceof Error){s.message=n.message,s.stack=n.stack;let r=n.message.match(/\((\d+),(\d+)\)/);if(r)s.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(n.message.includes("Cannot find")||n.message.includes("not found"))s.code=Se.FILE_NOT_FOUND,s.suggestion="Check that the file path is correct and the file exists.";else if(n.message.includes("syntax")||n.message.includes("Unexpected token"))s.code=Se.SYNTAX_ERROR,s.suggestion="Check for syntax errors in your TypeScript code.";else if(n.message.includes("type")&&n.message.includes("cannot"))s.code=Se.TYPE_INFERENCE_ERROR,s.suggestion="Add explicit type annotations to help with type inference.";else if(n.message.includes("parse")||n.message.includes("Parse"))s.code=Se.PARSE_ERROR,s.suggestion="The file contains invalid TypeScript syntax."}else if(typeof n==="string")s.message=n;return s}function Et(n,e){let t=[],s=n.file;if(n.location)s+=`:${n.location.line}:${n.location.column}`;if(n.code)s+=` [${n.code}]`;if(t.push(s),t.push(` Error: ${n.message}`),e&&n.location){t.push("");let r=e.split(`
6
+ `)}function ut(n,e,t){let s={file:e,message:"Unknown error",code:je.UNKNOWN_ERROR};if(n instanceof Error){s.message=n.message,s.stack=n.stack;let r=n.message.match(/\((\d+),(\d+)\)/);if(r)s.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(n.message.includes("Cannot find")||n.message.includes("not found"))s.code=je.FILE_NOT_FOUND,s.suggestion="Check that the file path is correct and the file exists.";else if(n.message.includes("syntax")||n.message.includes("Unexpected token"))s.code=je.SYNTAX_ERROR,s.suggestion="Check for syntax errors in your TypeScript code.";else if(n.message.includes("type")&&n.message.includes("cannot"))s.code=je.TYPE_INFERENCE_ERROR,s.suggestion="Add explicit type annotations to help with type inference.";else if(n.message.includes("parse")||n.message.includes("Parse"))s.code=je.PARSE_ERROR,s.suggestion="The file contains invalid TypeScript syntax."}else if(typeof n==="string")s.message=n;return s}function Gt(n,e){let t=[],s=n.file;if(n.location)s+=`:${n.location.line}:${n.location.column}`;if(n.code)s+=` [${n.code}]`;if(t.push(s),t.push(` Error: ${n.message}`),e&&n.location){t.push("");let r=e.split(`
7
7
  `),i=n.location.line-1;if(i>=0&&i<r.length){let o=Math.max(0,i-1),E=Math.min(r.length-1,i+1);for(let c=o;c<=E;c++){let a=(c+1).toString().padStart(4," "),R=c===i?">":" ";if(t.push(` ${R} ${a} | ${r[c]}`),c===i&&n.location.column>0){let u=" ".repeat(10+n.location.column-1);t.push(` ${u}^`)}}}}if(n.suggestion)t.push(""),t.push(` Suggestion: ${n.suggestion}`);return t.join(`
8
- `)}function Ao(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
8
+ `)}function ua(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
9
9
  `)}
10
- export{Se,T,An,fi,di,Dn,Pn,pi,Co,vo,So,$o,Eo,ko,To,Qe,Et,Ao};
10
+ export{je,W,zn,Wi,Li,Hn,Kn,Fi,ra,ia,sa,oa,aa,ca,la,ut,Gt,ua};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{n,f,Tr}from"./chunk-b5wcbnb8.js";import{Ke}from"./chunk-javyer70.js";function ht(d){let u=d.trim();if(u.length===0)return;let a=u.charCodeAt(0);if(a!==47){let e=a>=65&&a<=90||a>=97&&a<=122||a===95||a===36;if(!e&&a<128)return;if(e){for(let b=1;b<u.length;b++){let r=u.charCodeAt(b);if(!(r>=65&&r<=90||r>=97&&r<=122||r>=48&&r<=57||r===95||r===36)){if(e=!1,r<128&&r!==47&&r!==32&&r!==9&&r!==10&&r!==13)return;break}}if(e)return u==="true"||u==="false"||u==="null"||u==="undefined"||u==="this"||u==="super"?void 0:u}}let h=n(d);if(h.length!==1||h[0].kind!=="word")return;let o=d.slice(h[0].start,h[0].end);return["true","false","null","undefined","this","super"].includes(o)?void 0:o}function Jt(d){let u=n(d);if(u.length===0)return!0;let a=u[u.length-1],h=d.slice(a.start,a.end);if(a.kind==="word"&&["is","extends","keyof","readonly"].includes(h))return!0;if(h==="|"||h==="&"||h==="?"||h===":")return!0;let o=u[u.length-2];return h===">"&&o!==void 0&&d.slice(o.start,o.end)==="="}function Q(d){if(Tr(d))return O(d,f(d));return Yt(d)}function Yt(d){if(!d.includes("export")&&!d.includes("import"))return!1;for(let u=256;u<d.length;u*=8){let a=d.slice(0,u),h=N(a,n(a),u);if(h!==void 0)return h}return O(d,n(d))}function O(d,u){return N(d,u,1/0)??!1}function N(d,u,a){let h=0;for(let o=0;o<u.length;o++){let e=u[o];if(e.end>=a)return;if(e.kind==="punctuation"){let r=d.charCodeAt(e.start);if(r===123||r===40||r===91)h++;else if(r===125||r===41||r===93)h--;continue}if(h!==0||e.kind!=="word"||e.end-e.start!==6)continue;let b=d.slice(e.start,e.end);if(b==="export")return!0;if(b==="import"){let r=u[o+1];if(r===void 0?a!==1/0:r.end>=a)return;let y=r?d.slice(r.start,r.end):"";if(y!=="("&&y!==".")return!0}}return a===1/0?!1:void 0}function br(d){if(d.isExported)return!1;if(["function","variable","interface","type","class","enum","namespace"].includes(d.kind))return!0;return d.kind==="module"&&(d.moduleForm==="namespace"||d.moduleForm==="identifier")}function wr(d,u,a){let h=d.text,o=n(h),e=(s)=>o[s]?h.slice(o[s].start,o[s].end):"",b=(s)=>o[s]?.kind==="word",r=new Map,y=new Map,T=[];for(let s=0;s<o.length;s++){let t=e(s);if(t==="("||t==="["||t==="{"||t==="<")T.push(s);else if(t===")"||t==="]"||t==="}"||t===">"&&e(s-1)!=="="){let i=T.at(-1);if(i!==void 0&&(e(i)==="("&&t===")"||e(i)==="["&&t==="]"||e(i)==="{"&&t==="}"||e(i)==="<"&&t===">")){if(T.pop(),r.set(i,s),e(i)==="<")y.set(s,i)}}}let P=(s)=>{let t=s;while(["readonly","public","private","protected","static","abstract","override","declare","accessor","get","set","async"].includes(e(t))&&(b(t+1)||o[t+1]?.kind==="quoted"||e(t+1)==="["||/^[0-9]/.test(e(t+1))))t++;if(e(t)==="(")return e((r.get(t)??o.length)+1)===":";if(e(t)==="<")return e((r.get(t)??o.length)+1)==="(";let i=t+1;if(e(t)==="[")i=(r.get(t)??o.length)+1;else if(h.charCodeAt(o[t]?.start??h.length)>=48&&h.charCodeAt(o[t]?.start??h.length)<=57)while(i<o.length&&o[i-1].end===o[i].start&&/^[\da-fxob_e.+-]+$/i.test(e(i)))i++;else if(!b(t)&&o[t]?.kind!=="quoted"&&o[t]?.kind!=="literal")return!1;if(e(i)==="?")i++;if(e(i)==="<")i=(r.get(i)??o.length)+1;return e(i)===":"||e(i)==="("},A=[],C=[];for(let s=0;s<o.length;s++){if(e(s)!=="(")continue;let t=r.get(s);if(t===void 0||!(e(t+1)===":"||e(t+1)==="="&&e(t+2)===">"))continue;let i=new Set,x=s+1;while(x<t){let p=x;while(p<t&&e(p)!==","){let g=r.get(p);if(g!==void 0)p=g+1;else p++}let m=x;while(m<p&&e(m)!==":"&&e(m)!=="="){let g=r.get(m);if(g!==void 0)m=g+1;else m++}let l=x;while([".","public","private","protected","readonly","override"].includes(e(l)))l++;if(e(l)==="{"||e(l)==="[")for(let g of Ke(h.slice(o[l].start,o[m-1].end)))i.add(g);else if(b(l))i.add(e(l));x=p+1}let c=t+(e(t+1)===":"?2:3);while(c<o.length){if(c>t+2&&h.slice(o[c-1].end,o[c].start).includes(`
3
+ `)&&!["|","&","?","extends","keyof","typeof","readonly","new","infer","is"].includes(e(c-1))&&P(c))break;if([";",",",")","]","}"].includes(e(c))||e(c)===">"&&e(c-1)!=="=")break;let p=r.get(c);if(p!==void 0)c=p+1;else c++}A.push({start:s,end:c,names:i});let w=y.get(s-1);if(a&&w!==void 0){let p=new Set,m=w+1;while(m<s-1){while(["const","in","out"].includes(e(m)))m++;if(b(m))p.add(e(m));while(m<s-1&&e(m)!==",")m=(r.get(m)??m)+1;m++}C.push({start:w,end:c,names:p})}}let E=a?new Set:void 0,I=(s)=>{if(!b(s))return;E?.add(o[s].start);let t=e(s);if(!A.some((i)=>s>=i.start&&s<i.end&&i.names.has(t)))u.add(t)},v=(s,t)=>{for(let i=s;i<t;i++){if(e(i)==="<"&&r.has(i)){i=r.get(i);continue}if(!b(i)||e(i-1)==="."||e(i+1)===":")continue;if(["true","false","null","undefined","new","this","super","as","satisfies","typeof","void","keyof"].includes(e(i)))continue;I(i)}};for(let s=0;s<o.length;s++){if(e(s)==="typeof")I(s+1);if(e(s)==="export"){let t=s+1;if(e(t)==="default"){if(!["function","class","abstract","interface"].includes(e(t+1))){if(v(t+1,o.length),b(t+1)&&a?.candidates.has(e(t+1))&&(e(t+2)===";"||t+2===o.length))a.references.add(e(t+1))}continue}if(e(t)==="="){if(v(t+1,o.length),b(t+1)&&a?.candidates.has(e(t+1))&&(e(t+2)===";"||t+2===o.length))a.references.add(e(t+1));continue}let i=e(t)==="type";if(i)t++;if(e(t)==="{"){let x=r.get(t);if(x===void 0||e(x+1)==="from")continue;for(let c=t+1;c<x;){let w=e(c)==="type"&&b(c+1)&&e(c+1)!=="as";if(w)c++;let p=a?.candidates.has(e(c));if(p)a.references.add(e(c));if(!p||!i&&!w)I(c);else E?.add(o[c].start);while(c<x&&e(c)!==",")c++;c++}}}if(e(s)==="["){let t=r.get(s);if(t!==void 0&&[":","?","("].includes(e(t+1))&&e(s+2)!==":"&&e(s+2)!=="in")v(s+1,t)}}if(d.kind==="class"){let s=-1;for(let t=0;t<o.length&&e(t)!=="{";t++)if(e(t)==="<"&&r.has(t))t=r.get(t);else if(e(t)==="extends"){s=t;break}if(s!==-1){let t=s+1;while(t<o.length&&e(t)!=="{"&&e(t)!=="implements"){let i=r.get(t);if(i!==void 0)t=i+1;else t++}v(s+1,t)}}if(a){let s=new Set,t=n(d.generics??""),i=0,x=!1;for(let l of t){let g=(d.generics??"").slice(l.start,l.end);if(["<","(","[","{"].includes(g)){if(i++,g==="<"&&i===1)x=!0}else if([">",")","]","}"].includes(g)&&!(g===">"&&(d.generics??"").slice(l.start-1,l.start)==="="))i--;else if(g===","&&i===1)x=!0;else if(x&&i===1&&l.kind==="word"&&!["const","in","out"].includes(g))s.add(g),x=!1}let c=C.flatMap((l)=>[...l.names].flatMap((g)=>[{index:l.start,name:g,delta:1},{index:l.end,name:g,delta:-1}])).sort((l,g)=>l.index-g.index),w=new Map,p=[{closeIndex:-1,sawExtends:!1,condDepth:0}],m=0;for(let l=0;l<o.length;l++){while(m<c.length&&c[m].index<=l){let M=c[m++];w.set(M.name,(w.get(M.name)??0)+M.delta)}let g=e(l);if(p.length>1&&l===p[p.length-1].closeIndex)p.pop();else if(r.has(l))p.push({closeIndex:r.get(l),sawExtends:!1,condDepth:0});let k=p[p.length-1];if(!b(l)){if(g==="?"&&k.sawExtends)k.sawExtends=!1,k.condDepth++;else if(g===":"&&k.condDepth>0)k.condDepth--;else if(g===";"&&k.condDepth===0)k.sawExtends=!1;continue}if(g==="extends"){k.sawExtends=!0;continue}if(E?.has(o[l].start)||!a.candidates.has(g)||s.has(g)||(w.get(g)??0)>0)continue;let S=e(l-1),D=e(l+1);if(S==="."||S==="as"&&d.kind==="export"||["const","let","var","function","class","interface","type","enum","namespace","module"].includes(S))continue;if(D===":"&&S!=="?"&&k.condDepth===0||D==="?"&&[":","("].includes(e(l+2))||D==="("||D==="<"&&e((r.get(l+1)??o.length)+1)==="(")continue;a.references.add(g)}}}
4
+ export{ht,Jt,Q,Yt,br,wr};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- function Bi(m,b={}){let{mergeInterfaces:c=!0,mergeNamespaces:e=!0,mergeTypes:n=!1,mergeEnums:l=!0,deduplicateIdentical:g=!0,conflictStrategy:d="last",preserveAllComments:h=!0}=b,u=[],r=0,f=new Map,o=[];for(let i of m){let a=`${i.kind}:${i.name}`,s=f.get(a);if(!s)s=[],f.set(a,s),o.push(a);s.push(i)}let t=[];for(let i of o){let a=f.get(i),s=a[0];if(a.length===1){t.push(s);continue}if(!(s.kind==="interface"&&c||s.kind==="module"&&e||s.kind==="type"&&n||s.kind==="enum"&&l)){t.push(...a);continue}let p=a;if(g)p=y(a);if(p.length===1){t.push(p[0]);continue}let x;switch(s.kind){case"interface":x=k(p,d,h);break;case"module":x=w(p,d,h);break;case"enum":x=M(p,d,h);break;case"type":x=A(p,d,h);break;default:x=p[0]}t.push(x),r+=p.length-1,u.push({name:s.name,kind:s.kind,sourceCount:p.length,memberCount:x.members?.length||0})}return{declarations:t,mergedCount:r,merges:u}}function y(m){let b=new Map;for(let c of m){let e=D(c.text);if(!b.has(e))b.set(e,c);else{let n=b.get(e);if((c.leadingComments?.length||0)>(n.leadingComments?.length||0))b.set(e,c)}}return Array.from(b.values())}function D(m){return m.replace(/\s+/g," ").replace(/;\s*/g,";").trim()}function k(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let a of m){if(c&&a.leadingComments&&g){for(let s of a.leadingComments)if(!g.has(s))g.add(s),l.push(s)}if(a.members)for(let s of a.members)if(!n.get(s.name))n.set(s.name,s);else switch(b){case"first":break;case"last":n.set(s.name,s);break;case"error":throw Error(`Conflicting member '${s.name}' in interface '${e.name}'`)}}let d=Array.from(n.values()),h=d.map((a)=>` ${a.text}`).join(`
2
+ function Da(m,b={}){let{mergeInterfaces:c=!0,mergeNamespaces:e=!0,mergeTypes:n=!1,mergeEnums:l=!0,deduplicateIdentical:g=!0,conflictStrategy:d="last",preserveAllComments:h=!0}=b,u=[],r=0,f=new Map,o=[];for(let i of m){let a=`${i.kind}:${i.name}`,s=f.get(a);if(!s)s=[],f.set(a,s),o.push(a);s.push(i)}let t=[];for(let i of o){let a=f.get(i),s=a[0];if(a.length===1){t.push(s);continue}if(!(s.kind==="interface"&&c||s.kind==="module"&&e||s.kind==="type"&&n||s.kind==="enum"&&l)){t.push(...a);continue}let p=a;if(g)p=y(a);if(p.length===1){t.push(p[0]);continue}let x;switch(s.kind){case"interface":x=k(p,d,h);break;case"module":x=w(p,d,h);break;case"enum":x=M(p,d,h);break;case"type":x=A(p,d,h);break;default:x=p[0]}t.push(x),r+=p.length-1,u.push({name:s.name,kind:s.kind,sourceCount:p.length,memberCount:x.members?.length||0})}return{declarations:t,mergedCount:r,merges:u}}function y(m){let b=new Map;for(let c of m){let e=D(c.text);if(!b.has(e))b.set(e,c);else{let n=b.get(e);if((c.leadingComments?.length||0)>(n.leadingComments?.length||0))b.set(e,c)}}return Array.from(b.values())}function D(m){return m.replace(/\s+/g," ").replace(/;\s*/g,";").trim()}function k(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let a of m){if(c&&a.leadingComments&&g){for(let s of a.leadingComments)if(!g.has(s))g.add(s),l.push(s)}if(a.members)for(let s of a.members)if(!n.get(s.name))n.set(s.name,s);else switch(b){case"first":break;case"last":n.set(s.name,s);break;case"error":throw Error(`Conflicting member '${s.name}' in interface '${e.name}'`)}}let d=Array.from(n.values()),h=d.map((a)=>` ${a.text}`).join(`
3
3
  `),u=e.generics||"",r=e.extends||"",f=new Set;for(let a of m)if(a.extends){let s=a.extends.split(",");for(let C of s){let p=C.trim();if(p)f.add(p)}}if(f.size>0)r=`extends ${Array.from(f).join(", ")}`;let o=e.isExported?"export ":"",t=e.modifiers?.includes("declare")?"declare ":"",i=`${o}${t}interface ${e.name}${u} ${r} {
4
4
  ${h}
5
5
  }`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:i.replace(/\s+\{/," {").replace(/\{\s*\n\s*\n/,`{
@@ -9,10 +9,10 @@ ${h}
9
9
  }`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:f}}function M(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let t of m){if(c&&t.leadingComments&&g){for(let i of t.leadingComments)if(!g.has(i))g.add(i),l.push(i)}if(t.members)for(let i of t.members)if(!n.get(i.name))n.set(i.name,i);else switch(b){case"first":break;case"last":n.set(i.name,i);break;case"error":throw Error(`Conflicting member '${i.name}' in enum '${e.name}'`)}}let d=Array.from(n.values()),h=d.map((t)=>` ${t.name}${t.value!==void 0?` = ${t.value}`:""}`).join(`,
10
10
  `),u=e.isExported?"export ":"",r=e.modifiers?.includes("declare")?"declare ":"",f=e.modifiers?.includes("const")?"const ":"",o=`${u}${r}${f}enum ${e.name} {
11
11
  ${h}
12
- }`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:o}}function A(m,b,c){let e=m[0],n=[],l=c?new Set:null,g=[],d=new Set;for(let o of m){if(c&&o.leadingComments&&l){for(let t of o.leadingComments)if(!l.has(t))l.add(t),n.push(t)}if(o.typeAnnotation&&!d.has(o.typeAnnotation))d.add(o.typeAnnotation),g.push(o.typeAnnotation)}if(g.length<=1)return{...e,leadingComments:n.length>0?n:e.leadingComments};let h=g.join(" | "),u=e.isExported?"export ":"",r=e.generics||"",f=`${u}type ${e.name}${r} = ${h}`;return{...e,typeAnnotation:h,leadingComments:n.length>0?n:e.leadingComments,text:f}}function Wi(m,b={}){let c=m.split(`
12
+ }`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:o}}function A(m,b,c){let e=m[0],n=[],l=c?new Set:null,g=[],d=new Set;for(let o of m){if(c&&o.leadingComments&&l){for(let t of o.leadingComments)if(!l.has(t))l.add(t),n.push(t)}if(o.typeAnnotation&&!d.has(o.typeAnnotation))d.add(o.typeAnnotation),g.push(o.typeAnnotation)}if(g.length<=1)return{...e,leadingComments:n.length>0?n:e.leadingComments};let h=g.join(" | "),u=e.isExported?"export ":"",r=e.generics||"",f=`${u}type ${e.name}${r} = ${h}`;return{...e,typeAnnotation:h,leadingComments:n.length>0?n:e.leadingComments,text:f}}function Ra(m,b={}){let c=m.split(`
13
13
  `),e=new Map,n=null,l=0;for(let u=0;u<c.length;u++){let r=c[u],f=r.match(/^(export\s+)?(declare\s+)?interface\s+(\w+)/);if(f&&!n){n={name:f[3],start:u,lines:[r]},l=(r.match(/\{/g)||[]).length-(r.match(/\}/g)||[]).length;continue}if(n){if(n.lines.push(r),l+=(r.match(/\{/g)||[]).length-(r.match(/\}/g)||[]).length,l<=0){let o=e.get(n.name)||[];o.push({start:n.start,end:u,content:n.lines}),e.set(n.name,o),n=null,l=0}}}let g=Array.from(e.entries()).filter(([,u])=>u.length>1);if(g.length===0)return m;let d=[...c],h=new Set;for(let[u,r]of g){if(r.length<=1)continue;let[f,...o]=r,t=[],i=new Set;for(let C of r)for(let p of C.content){let x=p.trim();if(x.startsWith("interface")||x.startsWith("export")||x==="{"||x==="}")continue;if(x&&!i.has(x))i.add(x),t.push(p)}for(let C of o)for(let p=C.start;p<=C.end;p++)h.add(p);let a=f.content[0],s=[a.endsWith("{")?a:`${a} {`,...t,"}"];for(let C=f.start;C<=f.end;C++)h.add(C);d[f.start]=s.join(`
14
14
  `)}return d.filter((u,r)=>!h.has(r)||d[r].includes("interface")).join(`
15
15
  `).replace(/\n{3,}/g,`
16
16
 
17
17
  `)}
18
- export{Bi,Wi};
18
+ export{Da,Ra};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{spawn as f}from"child_process";import{readFile as i,stat as n,writeFile as m}from"fs/promises";var E=typeof globalThis.Bun<"u",Ma=!E&&typeof process<"u"&&!!process.versions?.node,Ia=E?"bun":"node";class s{name;_size=-1;constructor(e){this.name=e}async exists(){try{return await n(this.name),!0}catch{return!1}}async text(){return i(this.name,"utf-8")}async arrayBuffer(){let e=await i(this.name);return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}get size(){if(this._size===-1)return-1;return this._size}}class a{pid;stdout;stderr;stdin;exited;process;constructor(e){this.process=e,this.pid=e.pid??0,this.stdout=e.stdout,this.stderr=e.stderr,this.stdin=e.stdin,this.exited=new Promise((r)=>{e.on("exit",(t)=>{r(t??0)}),e.on("error",()=>{r(1)})})}kill(e){this.process.kill(e)}ref(){this.process.ref()}unref(){this.process.unref()}}function ge(e){if(E)return globalThis.Bun.file(e);return new s(e)}async function mt(e,r){if(E)return globalThis.Bun.write(e,r);let t=typeof r==="string"?r:r instanceof ArrayBuffer?Buffer.from(r):r;return await m(e,t),typeof r==="string"?Buffer.byteLength(r):r.byteLength}function Ht(e,r={}){if(E)return globalThis.Bun.spawn(e,r);let t=Array.isArray(e)?e:[e],[o,...u]=t,d={cwd:r.cwd,env:r.env,stdio:[r.stdin??"pipe",r.stdout??"pipe",r.stderr??"pipe"]},l=f(o,u,d);return new a(l)}async function p(e){if(E)return globalThis.Bun.file(e).text();return i(e,"utf-8")}async function Na(e){if(E)return globalThis.Bun.file(e).exists();try{return await n(e),!0}catch{return!1}}async function Wa(e,r){await mt(e,r)}function La(){if(E)return{name:"bun",version:globalThis.Bun.version,isBun:!0,isNode:!1};return{name:"node",version:process.versions.node,isBun:!1,isNode:!0}}
3
+ export{E,Ma,Ia,ge,mt,Ht,p,Na,Wa,La};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- function Ie(h){let a="",i=0,e=0;while(i<h.length){let r=h.charCodeAt(i);if(e){if(a+=h[i],r===92&&i+1<h.length){a+=h[i+1],i+=2;continue}if(r===e)e=0;i++;continue}if(r===34){e=r,a+=h[i++];continue}if(r===47&&h.charCodeAt(i+1)===47){i+=2;while(i<h.length&&h.charCodeAt(i)!==10&&h.charCodeAt(i)!==13)i++;continue}if(r===47&&h.charCodeAt(i+1)===42){i+=2;while(i+1<h.length&&!(h.charCodeAt(i)===42&&h.charCodeAt(i+1)===47)){if(h.charCodeAt(i)===10)a+=`
2
+ function Ge(h){let a="",i=0,e=0;while(i<h.length){let r=h.charCodeAt(i);if(e){if(a+=h[i],r===92&&i+1<h.length){a+=h[i+1],i+=2;continue}if(r===e)e=0;i++;continue}if(r===34){e=r,a+=h[i++];continue}if(r===47&&h.charCodeAt(i+1)===47){i+=2;while(i<h.length&&h.charCodeAt(i)!==10&&h.charCodeAt(i)!==13)i++;continue}if(r===47&&h.charCodeAt(i+1)===42){i+=2;while(i+1<h.length&&!(h.charCodeAt(i)===42&&h.charCodeAt(i+1)===47)){if(h.charCodeAt(i)===10)a+=`
3
3
  `;i++}i=Math.min(i+2,h.length);continue}if(r===44){let c=i+1;while(c<h.length){while(c<h.length&&h.charCodeAt(c)<=32)c++;if(h.charCodeAt(c)===47&&h.charCodeAt(c+1)===47){c+=2;while(c<h.length&&h.charCodeAt(c)!==10&&h.charCodeAt(c)!==13)c++;continue}if(h.charCodeAt(c)===47&&h.charCodeAt(c+1)===42){c+=2;while(c+1<h.length&&!(h.charCodeAt(c)===42&&h.charCodeAt(c+1)===47))c++;c=Math.min(c+2,h.length);continue}break}let t=h.charCodeAt(c);if(t===93||t===125){i++;continue}}a+=h[i++]}return a}
4
- export{Ie};
4
+ export{Ge};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- function f(r,e=!0){if(!e||!r||r.length===0)return"";if(r.length===1){let t=r[0];if(t.length>0&&t.charCodeAt(0)>32&&t.charCodeAt(t.length-1)>32)return`${t}
2
+ function y(r,e=!0){if(!e||!r||r.length===0)return"";if(r.length===1){let t=r[0];if(t.length>0&&t.charCodeAt(0)>32&&t.charCodeAt(t.length-1)>32)return`${t}
3
3
  `;return`${t.trim()}
4
4
  `}let n="";for(let t=0;t<r.length;t++){if(t>0)n+=`
5
5
  `;n+=r[t].trim()}return`${n}
6
- `}function be(r){return r.replaceAll("*/","*\\/")}
7
- export{f,be};
6
+ `}function Ee(r){return r.replaceAll("*/","*\\/")}
7
+ export{y,Ee};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- function V(n,r){let e=Number.isFinite(r)?Math.max(1,Math.floor(r)):1;if(n===void 0||!Number.isFinite(n))return e;return Math.max(1,Math.floor(n))}
3
- export{V};
2
+ function Y(n,r){let e=Number.isFinite(r)?Math.max(1,Math.floor(r)):1;if(n===void 0||!Number.isFinite(n))return e;return Math.max(1,Math.floor(n))}
3
+ export{Y};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{lstat as d,realpath as f,stat as T}from"fs/promises";import{isAbsolute as l,normalize as g,relative as p,resolve as u}from"path";var X={rootDir:process.cwd(),maxFileSize:10485760,maxTotalSize:104857600,timeout:30000,followSymlinks:!1,maxFiles:1e4,blockedPatterns:["**/.git/**","**/node_modules/**","**/.env*","**/secrets/**","**/*.key","**/*.pem"]};class L extends Error{code;path;constructor(t,r,e){super(t);this.code=r;this.path=e;this.name="SecurityError"}}function ft(t,r={}){let{rootDir:e=process.cwd()}=r,i=g(t),n=l(i)?i:u(e,i),o=u(n),s=p(e,o);if(s.startsWith("..")||l(s))throw new L(`Path traversal detected: "${t}" resolves outside root directory`,"PATH_TRAVERSAL",t);return o}function zi(t,r={}){return t.map((e)=>ft(e,r))}function qn(t,r={}){let e=r.blockedPatterns||X.blockedPatterns;for(let i of e)if(h(t,i))return!0;return!1}var m=new Map;function P(t){let r=m.get(t);if(r)return r;let e=t.replace(/\*\*/g,"<<GLOBSTAR>>").replace(/\*/g,"<<STAR>>").replace(/\?/g,"<<QUESTION>>");e=e.replace(/[.+^${}()|[\]\\]/g,"\\$&"),e=e.replace(/^<<GLOBSTAR>>\//,"(.*\\/)?"),e=e.replace(/\/<<GLOBSTAR>>$/,"(\\/.*)?"),e=e.replace(/\/<<GLOBSTAR>>\//g,"(\\/.*)?\\/"),e=e.replace(/<<GLOBSTAR>>/g,".*"),e=e.replace(/<<STAR>>/g,"[^/]*"),e=e.replace(/<<QUESTION>>/g,"[^/]");let i=new RegExp(`^${e}$`);return m.set(t,i),i}function h(t,r){let e=t.indexOf("\\")===-1?t:t.replace(/\\/g,"/");return P(r).test(e)}async function Hi(t,r={}){let e=r.maxFileSize??X.maxFileSize;try{let i=await T(t);if(i.size>e)throw new L(`File too large: "${t}" is ${a(i.size)}, max is ${a(e)}`,"FILE_TOO_LARGE",t);return i.size}catch(i){if(i instanceof L)throw i;throw new L(`Failed to check file size: ${t}`,"INVALID_PATH",t)}}async function Ki(t){try{return(await d(t)).isSymbolicLink()}catch{return!1}}async function qi(t,r={}){let e=r.followSymlinks??X.followSymlinks;if(await Ki(t)){if(!e)throw new L(`Symbolic links not allowed: "${t}"`,"SYMLINK_NOT_ALLOWED",t);let i=await f(t);return ft(i,r)}return t}async function Vt(t,r={}){let e=ft(t,r);if(qn(e,r))throw new L(`Path matches blocked pattern: "${t}"`,"BLOCKED_PATTERN",t);let i=await qi(e,r),n=await Hi(i,r);return{path:i,size:n}}async function Jn(t,r={}){let e=r.maxFiles??X.maxFiles,i=r.maxTotalSize??X.maxTotalSize;if(t.length>e)throw new L(`Too many files: ${t.length} exceeds maximum of ${e}`,"MAX_FILES_EXCEEDED");let n=[],o=0;for(let s of t){let c=await Vt(s,r);if(n.push(c.path),o+=c.size,o>i)throw new L(`Total size exceeded: ${a(o)} exceeds maximum of ${a(i)}`,"TOTAL_SIZE_EXCEEDED")}return{paths:n,totalSize:o}}function Ut(t,r,e="Operation"){return new Promise((i,n)=>{let o=setTimeout(()=>{n(new L(`${e} timed out after ${r}ms`,"TIMEOUT"))},r);t.then((s)=>{clearTimeout(o),i(s)}).catch((s)=>{clearTimeout(o),n(s)})})}function Ji(t,r={}){let e=r.timeout??X.timeout;return async(i)=>{let{path:n}=await Vt(i,r);return Ut(t(n),e,`Processing ${i}`)}}function pa(t,r={}){let e=r.timeout??X.timeout;return async(i)=>{let{paths:n}=await Jn(i,r);return Ut(t(n),e,`Processing ${i.length} files`)}}function ma(t){let r=t.replace(/\\/g,"/").replace(/\0/g,"").replace(/^\/+/,"").replace(/^[A-Z]:/i,""),e="";while(e!==r)e=r,r=r.replace(/\.\.\/|\.\.$/g,"").replace(/\/+/g,"/");return r.replace(/^\/+|\/+$/g,"")}function ha(t){if(t.includes("\x00"))return!1;if(g(t).includes(".."))return!1;if(l(t)&&!t.startsWith(process.cwd()))return!1;return!0}function a(t){if(t===0)return"0 B";let r=["B","KB","MB","GB"],e=1024,i=Math.floor(Math.log(t)/Math.log(e));return`${Number.parseFloat((t/e**i).toFixed(2))} ${r[i]}`}function ga(t={}){let r={...X,...t};return{validatePath:(e)=>ft(e,r),validatePaths:(e)=>zi(e,r),validateFile:(e)=>Vt(e,r),validateBatch:(e)=>Jn(e,r),withTimeout:(e,i)=>Ut(e,r.timeout,i),secureProcessor:(e)=>Ji(e,r),isBlocked:(e)=>qn(e,r),getConfig:()=>r}}
3
+ export{X,L,ft,zi,qn,Hi,Ki,qi,Vt,Jn,Ut,Ji,pa,ma,ha,ga};