@dtsx/dtsx 0.11.43 → 0.11.45

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 (216) hide show
  1. package/README.md +6 -0
  2. package/dist/bin/cli.js +9 -9
  3. package/dist/{chunk-9dkjzqm0.js → chunk-05cbfytc.js} +6 -6
  4. package/dist/{chunk-znd7w376.js → chunk-1gy2z5an.js} +5 -5
  5. package/dist/{chunk-p3n0wx32.js → chunk-2cjs4r5v.js} +4 -4
  6. package/dist/chunk-3nmjt94q.js +10 -0
  7. package/dist/{chunk-23w57jk5.js → chunk-3x19egjd.js} +2 -2
  8. package/dist/chunk-41d5ehn0.js +3 -0
  9. package/dist/{chunk-51cdjc3e.js → chunk-48jvmndg.js} +2 -2
  10. package/dist/{chunk-pfvjr5bg.js → chunk-4fspqk22.js} +3 -3
  11. package/dist/chunk-4t1we2h5.js +3 -0
  12. package/dist/chunk-4vtfqwpq.js +8 -0
  13. package/dist/{chunk-9mtn8sk3.js → chunk-51vf9de8.js} +2 -2
  14. package/dist/{chunk-xgj6rxmd.js → chunk-55yw66ha.js} +3 -3
  15. package/dist/{chunk-ep3575a9.js → chunk-57xvwm7c.js} +2 -2
  16. package/dist/{chunk-a3apthex.js → chunk-587w6ktw.js} +2 -2
  17. package/dist/{chunk-0zj4xkky.js → chunk-6gvctv0q.js} +3 -3
  18. package/dist/{chunk-xst4jpr9.js → chunk-755bntty.js} +17 -17
  19. package/dist/{chunk-ah3pwsh5.js → chunk-783erq83.js} +4 -4
  20. package/dist/{chunk-2p8za6vr.js → chunk-7x4eqjfw.js} +2 -2
  21. package/dist/chunk-83w2qbmb.js +3 -0
  22. package/dist/{chunk-xzw0p4nq.js → chunk-870p7sky.js} +2 -2
  23. package/dist/{chunk-01zsk2q8.js → chunk-8c5dzvwk.js} +3 -3
  24. package/dist/{chunk-vsa6gbmz.js → chunk-8c8pgvxv.js} +1 -1
  25. package/dist/{chunk-fhbwwm79.js → chunk-8xpkce3g.js} +4 -4
  26. package/dist/chunk-8zr7m1pk.js +3 -0
  27. package/dist/{chunk-7fytm1ya.js → chunk-9knxvphg.js} +3 -3
  28. package/dist/{chunk-9c0k2b8n.js → chunk-a4791583.js} +2 -2
  29. package/dist/chunk-b3979d26.js +3 -0
  30. package/dist/{chunk-rmg7jdhj.js → chunk-b7azvfdn.js} +2 -2
  31. package/dist/{chunk-a3px4jga.js → chunk-bv1q1w42.js} +4 -4
  32. package/dist/{chunk-ygpyce6w.js → chunk-c94sk67h.js} +4 -4
  33. package/dist/chunk-cd27mg71.js +3 -0
  34. package/dist/{chunk-qqjbaqm6.js → chunk-d5q4qfys.js} +4 -4
  35. package/dist/{chunk-9fz5erbq.js → chunk-e9x8ywhv.js} +6 -6
  36. package/dist/{chunk-7k0e2h9b.js → chunk-exf6bsbe.js} +5 -5
  37. package/dist/{chunk-60wrxcjt.js → chunk-f191378r.js} +11 -11
  38. package/dist/{chunk-3s37g6bh.js → chunk-f3avgz4y.js} +8 -8
  39. package/dist/chunk-fkdq1x5f.js +31 -0
  40. package/dist/{chunk-bkbsg2bv.js → chunk-g9emajpc.js} +2 -2
  41. package/dist/{chunk-4n2mpvmb.js → chunk-gns23mhj.js} +2 -2
  42. package/dist/chunk-grpmcw9x.js +27 -0
  43. package/dist/{chunk-n4hj7rs6.js → chunk-gwsjj23d.js} +4 -4
  44. package/dist/{chunk-vae5wxar.js → chunk-hgg4aqvf.js} +2 -2
  45. package/dist/{chunk-e37cbaq7.js → chunk-hvt855ms.js} +2 -2
  46. package/dist/chunk-hzy5z7x2.js +5 -0
  47. package/dist/chunk-j51p30sb.js +7 -0
  48. package/dist/{chunk-m3ysqm3b.js → chunk-jy5h728q.js} +2 -2
  49. package/dist/chunk-k0vthrqs.js +4 -0
  50. package/dist/{chunk-06jp6gah.js → chunk-kthga8ar.js} +3 -3
  51. package/dist/{chunk-y78fsxjf.js → chunk-m14550z9.js} +2 -2
  52. package/dist/{chunk-b2j236p3.js → chunk-m29ph3cg.js} +2 -2
  53. package/dist/{chunk-0xam980d.js → chunk-m8rvd58d.js} +4 -4
  54. package/dist/{chunk-62bqxy6j.js → chunk-mc9kwthm.js} +2 -2
  55. package/dist/chunk-mvxcxnff.js +3 -0
  56. package/dist/chunk-nfd9v8ba.js +3 -0
  57. package/dist/{chunk-3r9dptyy.js → chunk-pydpyx8x.js} +2 -2
  58. package/dist/{chunk-44zq3xnw.js → chunk-qab5rsk8.js} +6 -6
  59. package/dist/{chunk-1hhk0zm6.js → chunk-qj2yvdjn.js} +2 -2
  60. package/dist/{chunk-b79vtkkt.js → chunk-qkesb95f.js} +2 -2
  61. package/dist/{chunk-b0cdncp3.js → chunk-r2e0r0pd.js} +2 -2
  62. package/dist/chunk-s013113f.js +3 -0
  63. package/dist/chunk-s6t0ff96.js +3 -0
  64. package/dist/chunk-sqa3ke1a.js +3 -0
  65. package/dist/{chunk-k5wz43yh.js → chunk-srfpcjtn.js} +2 -2
  66. package/dist/chunk-t1js8enq.js +8 -0
  67. package/dist/{chunk-fka5apgq.js → chunk-t73v233w.js} +4 -4
  68. package/dist/chunk-t76htvct.js +3 -0
  69. package/dist/{chunk-j3egtn0s.js → chunk-t88j01sz.js} +2 -2
  70. package/dist/chunk-vher6t7j.js +14 -0
  71. package/dist/{chunk-9vj0g89m.js → chunk-vrfp12ts.js} +2 -2
  72. package/dist/{chunk-vv5jdqfj.js → chunk-vye45h9n.js} +2 -2
  73. package/dist/{chunk-w4fj9m56.js → chunk-wwjt0p6m.js} +3 -3
  74. package/dist/{chunk-btc6zbyj.js → chunk-x5z8vprh.js} +2 -2
  75. package/dist/{chunk-w3zqfm8a.js → chunk-x6ddycvm.js} +2 -2
  76. package/dist/chunk-x9vpsya2.js +40 -0
  77. package/dist/chunk-xhgs3gx2.js +4 -0
  78. package/dist/chunk-xtckj8w1.js +3 -0
  79. package/dist/{chunk-zgj8xq4x.js → chunk-xvk9v148.js} +2 -2
  80. package/dist/chunk-y9bxeq10.js +3 -0
  81. package/dist/{chunk-jvqczw2k.js → chunk-ybdp7k49.js} +3 -3
  82. package/dist/{chunk-n1p62kwx.js → chunk-yh04e0n4.js} +2 -2
  83. package/dist/{chunk-cd26g482.js → chunk-z82jsz2r.js} +3 -3
  84. package/dist/{chunk-xewmepxp.js → chunk-zb48dx6a.js} +2 -2
  85. package/dist/chunk-zmnb3yg1.js +37 -0
  86. package/dist/{chunk-eyc0tk75.js → chunk-zwcvtbt4.js} +10 -10
  87. package/dist/src/augmentation-graph.js +1 -1
  88. package/dist/src/binding-patterns.js +1 -1
  89. package/dist/src/branded-types.js +1 -1
  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.js +1 -1
  94. package/dist/src/circular.js +1 -1
  95. package/dist/src/compat.js +1 -1
  96. package/dist/src/computed-keys.js +1 -1
  97. package/dist/src/concurrency.js +1 -1
  98. package/dist/src/config.js +1 -1
  99. package/dist/src/dangling-refs.js +1 -1
  100. package/dist/src/declaration-project.js +1 -1
  101. package/dist/src/declaration-publication.js +1 -1
  102. package/dist/src/declaration-references.js +1 -1
  103. package/dist/src/diff.js +1 -1
  104. package/dist/src/docs.js +1 -1
  105. package/dist/src/enum-declarations.js +1 -1
  106. package/dist/src/errors.js +1 -1
  107. package/dist/src/extractor/directives.js +1 -1
  108. package/dist/src/extractor/extract.d.ts +1 -1
  109. package/dist/src/extractor/extract.js +1 -1
  110. package/dist/src/extractor/scanner.d.ts +4 -4
  111. package/dist/src/extractor/scanner.js +1 -1
  112. package/dist/src/extractor.js +1 -1
  113. package/dist/src/formats.js +1 -1
  114. package/dist/src/formatter.js +1 -1
  115. package/dist/src/function-properties.js +1 -1
  116. package/dist/src/generator.js +1 -1
  117. package/dist/src/global-types.js +1 -1
  118. package/dist/src/import-sorter.js +1 -1
  119. package/dist/src/incremental.js +1 -1
  120. package/dist/src/index.d.ts +2 -1
  121. package/dist/src/index.js +1 -1
  122. package/dist/src/inferred-imports.js +1 -1
  123. package/dist/src/initializer-type-spans.d.ts +7 -0
  124. package/dist/src/initializer-type-spans.js +2 -0
  125. package/dist/src/json-config.js +1 -1
  126. package/dist/src/lexical.d.ts +8 -1
  127. package/dist/src/lexical.js +1 -1
  128. package/dist/src/logger.js +1 -1
  129. package/dist/src/lsp.js +1 -1
  130. package/dist/src/memory.js +1 -1
  131. package/dist/src/merger.js +1 -1
  132. package/dist/src/module-graph.js +1 -1
  133. package/dist/src/module-references.js +1 -1
  134. package/dist/src/native-checker.js +1 -1
  135. package/dist/src/native-engine.d.ts +24 -2
  136. package/dist/src/native-engine.js +1 -1
  137. package/dist/src/native-extractor.js +1 -1
  138. package/dist/src/native-generation.js +1 -1
  139. package/dist/src/native-project.js +1 -1
  140. package/dist/src/numeric-literals.d.ts +9 -0
  141. package/dist/src/numeric-literals.js +2 -0
  142. package/dist/src/optimizer.js +1 -1
  143. package/dist/src/output-normalizer.js +1 -1
  144. package/dist/src/parallel-processor.js +1 -1
  145. package/dist/src/parameters.js +1 -1
  146. package/dist/src/parser.js +1 -1
  147. package/dist/src/plugins/bun.js +1 -1
  148. package/dist/src/plugins/esbuild.js +1 -1
  149. package/dist/src/plugins/index.js +1 -1
  150. package/dist/src/plugins/tsdown.js +1 -1
  151. package/dist/src/plugins/tsup.js +1 -1
  152. package/dist/src/plugins/vite.js +1 -1
  153. package/dist/src/plugins/webpack.js +1 -1
  154. package/dist/src/plugins.js +1 -1
  155. package/dist/src/process-source.d.ts +4 -3
  156. package/dist/src/process-source.js +1 -1
  157. package/dist/src/processor/cache.js +1 -1
  158. package/dist/src/processor/comments.js +1 -1
  159. package/dist/src/processor/declarations.js +1 -1
  160. package/dist/src/processor/import-usage.js +1 -1
  161. package/dist/src/processor/imports.js +1 -1
  162. package/dist/src/processor/index.js +1 -1
  163. package/dist/src/processor/type-inference.d.ts +2 -9
  164. package/dist/src/processor/type-inference.js +1 -1
  165. package/dist/src/processor.js +1 -1
  166. package/dist/src/profiling.js +1 -1
  167. package/dist/src/return-type-scope.js +1 -1
  168. package/dist/src/security.js +1 -1
  169. package/dist/src/source-cache.js +1 -1
  170. package/dist/src/sourcemap.js +1 -1
  171. package/dist/src/stx.js +1 -1
  172. package/dist/src/syntax-validator.js +1 -1
  173. package/dist/src/tracking.js +1 -1
  174. package/dist/src/transformers.js +1 -1
  175. package/dist/src/tree-shaker.js +1 -1
  176. package/dist/src/tsconfig.js +1 -1
  177. package/dist/src/type-mappings.js +1 -1
  178. package/dist/src/types.d.ts +1 -0
  179. package/dist/src/utils.js +1 -1
  180. package/dist/src/value-inference.js +1 -1
  181. package/dist/src/vue.js +1 -1
  182. package/dist/src/watcher.js +1 -1
  183. package/dist/src/worker-thread.js +1 -1
  184. package/dist/src/worker.js +1 -1
  185. package/dist/src/workspace.js +1 -1
  186. package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
  187. package/native/darwin-x64/libzig-dtsx.dylib +0 -0
  188. package/native/freebsd-x64/libzig-dtsx.so +0 -0
  189. package/native/linux-arm64/libzig-dtsx.so +0 -0
  190. package/native/linux-x64/libzig-dtsx.so +0 -0
  191. package/native/windows-x64/zig-dtsx.dll +0 -0
  192. package/package.json +1 -1
  193. package/dist/chunk-0h9dz87w.js +0 -3
  194. package/dist/chunk-1721pyws.js +0 -3
  195. package/dist/chunk-1903h3dm.js +0 -3
  196. package/dist/chunk-1dqa0tex.js +0 -8
  197. package/dist/chunk-36xenw6z.js +0 -3
  198. package/dist/chunk-3pcxxgwq.js +0 -3
  199. package/dist/chunk-4q78f5pg.js +0 -3
  200. package/dist/chunk-5v7drjwg.js +0 -4
  201. package/dist/chunk-8pfyd95y.js +0 -3
  202. package/dist/chunk-a2666k9r.js +0 -3
  203. package/dist/chunk-aqcjv2v5.js +0 -37
  204. package/dist/chunk-bhqpdftq.js +0 -8
  205. package/dist/chunk-ettcbmzw.js +0 -4
  206. package/dist/chunk-km03xc8j.js +0 -14
  207. package/dist/chunk-ksc4xgdz.js +0 -3
  208. package/dist/chunk-m9x72e5j.js +0 -7
  209. package/dist/chunk-mp86smwc.js +0 -38
  210. package/dist/chunk-pebt9j6c.js +0 -3
  211. package/dist/chunk-pekphr39.js +0 -3
  212. package/dist/chunk-pwdmw567.js +0 -3
  213. package/dist/chunk-rwwrrxtc.js +0 -10
  214. package/dist/chunk-rz5jszhe.js +0 -5
  215. package/dist/chunk-tvhg9v4f.js +0 -27
  216. package/dist/chunk-y83jhbpr.js +0 -31
@@ -1,10 +0,0 @@
1
- // @bun
2
- import{_,Kn,qn}from"./chunk-23w57jk5.js";import{xn}from"./chunk-9c0k2b8n.js";import{f}from"./chunk-a3apthex.js";import{re,h,ie,se,oe,ae,ce}from"./chunk-9dkjzqm0.js";import{Pe,b}from"./chunk-1721pyws.js";import{$e}from"./chunk-5v7drjwg.js";function V(k,x){throw Error(x||`Unexpected value: ${k}`)}var j=null,q=[],z=[];function l(k,x,d=!0,y=["bun"]){let o="",m=x.sourceCode;if(m){let e=0;while(e<m.length&&(m.charCodeAt(e)===32||m.charCodeAt(e)===9||m.charCodeAt(e)===10||m.charCodeAt(e)===13))e++;if(e<m.length-2&&m.charCodeAt(e)===47&&m.charCodeAt(e+1)===47&&m.charCodeAt(e+2)===47){let i=xn(m);if(i.length>0)for(let r=0;r<i.length;r++){if(o)o+=`
3
- `;o+=i[r]}}}let w=[],N=[],M=[],P=[],U=[],W=[],F=[],C=[],T=[];for(let e of k){let i=e.kind;switch(i){case"import":w.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":F.push(e);break;case"module":C.push(e);break;case"export":T.push(e);break;case"namespace":C.push(e);break;case"unknown":break;default:V(i,`Unhandled declaration kind: ${i}`)}}let S=[],v=[],A=[],K=new Set;for(let e of T){let i=f(e.leadingComments,d);if(e.text.startsWith("export default")){let r=e.text.endsWith(";")?e.text:`${e.text};`;A.push(i+r)}else{let r=e.text.trim();if(!r.endsWith(";"))r+=";";let a=i+r;if(!K.has(a))if(K.add(a),a.includes("export type"))S.push(a);else v.push(a)}}let u=[];if(w.length>0){let{usedItems:e}=$e(k);for(let r of w){if(r.isSideEffect){let t=r.text.trim(),p=t.endsWith(";")?t:`${t};`;u.push(p);continue}let a=b(r.text);if(!a)continue;let{defaultName:s,namedItems:n,isTypeOnly:g,namespaceName:c}=a,D=s?e.has(s):!1,L=c?e.has(c):!1;if(a.isImportEquals){if(D){let t=r.text.trim();u.push(t.endsWith(";")?t:`${t};`)}else if(x.augmentationImports?.has(a.source)){let t=Pe(r.text);if(!t)throw Error("Cannot locate an augmentation import module literal");u.push(`import ${t};`)}continue}let I="",E=0;for(let t=0;t<n.length;t++){let p=n[t];if(e.has(p.name)){if(E>0)I+=", ";if(!g&&p.isTypeOnly)I+="type ";I+=p.originalName===p.name?p.name:`${p.originalName} as ${p.name}`,E++}}if(D||L||E>0){let t=g?"import type ":"import ";if(L&&c){if(D&&s)t+=`${s}, `;t+=`* as ${c}`}else if(D&&s)t+=E>0?`${s}, { ${I} }`:s;else if(E>0)t+=`{ ${I} }`;let p=Pe(r.text);if(!p)throw Error("Cannot locate a grammatical module literal in the import declaration");t+=` from ${p};`,u.push(t)}else if(x.augmentationImports?.has(a.source)){let t=Pe(r.text);if(!t)throw Error("Cannot locate an augmentation import module literal");u.push(`import ${t};`)}}let i=y.length;if(u.length>1){if(j!==y)j=y,q=y.map((n)=>`from '${n}`),z=y.map((n)=>`from "${n}`);let r=q,a=z,s=new Map;for(let n of u){let g=i;for(let c=0;c<y.length;c++)if(n.includes(r[c])||n.includes(a[c])){g=c;break}s.set(n,g)}u.sort((n,g)=>{let c=s.get(n),D=s.get(g);return c!==D?c-D:n.localeCompare(g)})}}for(let e=0;e<u.length;e++){if(o)o+=`
4
- `;o+=u[e]}for(let e=0;e<S.length;e++){if(o)o+=`
5
- `;o+=S[e]}let G=[N,M,P,U,W,F,C];for(let e=0;e<G.length;e++){let i=G[e];for(let r=0;r<i.length;r++){let a=i[r],s="",n=a.kind;switch(n){case"function":s=re(a,d);break;case"variable":s=h(a,d);break;case"interface":s=ie(a,d);break;case"type":s=se(a,d);break;case"class":s=oe(a,d);break;case"enum":s=ae(a,d);break;case"module":case"namespace":s=ce(a,d);break;case"import":case"export":case"unknown":break;default:V(n,`Unhandled declaration kind in processor: ${n}`)}if(s){if(o)o+=`
6
- `;o+=s}}}for(let e=0;e<v.length;e++){if(o)o+=`
7
- `;o+=v[e]}for(let e=0;e<A.length;e++){if(o)o+=`
8
- `;o+=A[e]}if(T.length===0&&_(x.sourceCode)&&(k.some(qn)||!Kn(o)))o+=`${o?`
9
- `:""}export {};`;return o}
10
- export{l};
@@ -1,5 +0,0 @@
1
- // @bun
2
- function c(t){return t>=65&&t<=90||t>=97&&t<=122||t===95||t===36||t>127}function i(t){return c(t)||t>=48&&t<=57}function L(t,_){let n=_;for(;;){while(n>=0&&(t.charCodeAt(n)===32||t.charCodeAt(n)===9||t.charCodeAt(n)===10||t.charCodeAt(n)===13))n--;if(n<0)return-1;if(t.charCodeAt(n)===47&&n>0&&t.charCodeAt(n-1)===42){let C=t.lastIndexOf("/*",n-2);if(C===-1)return-1;n=C-1;continue}let r=t.lastIndexOf(`
3
- `,n)+1,o=E(t,r,n);if(o!==-1){n=o-1;continue}return n}}function E(t,_,n){let r=0;for(let o=_;o<=n;o++){let C=t.charCodeAt(o);if(r){if(C===92){o++;continue}if(C===r)r=0;continue}if(C===39||C===34||C===96){r=C;continue}if(C===47&&o+1<=n&&t.charCodeAt(o+1)===47)return o}return-1}function u(t){return t===61||t===40||t===91||t===33||t===38||t===124||t===63||t===58||t===44||t===59||t===123||t===125||t===94||t===126||t===43||t===45||t===42||t===37||t===60||t===62}function R(t){return t==="return"||t==="typeof"||t==="void"||t==="delete"||t==="throw"||t==="new"||t==="in"||t==="of"||t==="case"||t==="instanceof"||t==="yield"||t==="await"||t==="else"||t==="do"}function b(t,_){let n=[],r=[],o=0,C=!1,l="",s="",S=!0,e=0,f=(H,A=!1)=>{s=l,l=H,S=A};while(e<=_){let H=t.charCodeAt(e);if(C){if(H===92){e+=2;continue}if(H===96)C=!1,f("literal");else if(H===36&&t.charCodeAt(e+1)===123)r.push(o++),C=!1,f("{",!0),e++;e++;continue}if(H===32||H===9||H===10||H===13){e++;continue}if(H===47&&t.charCodeAt(e+1)===47){let A=t.indexOf(`
4
- `,e+2);e=A===-1?t.length:A+1;continue}if(H===47&&t.charCodeAt(e+1)===42){let A=t.indexOf("*/",e+2);e=A===-1?t.length:A+2;continue}if(H===39||H===34){let A=H;e++;while(e<t.length){let a=t.charCodeAt(e++);if(a===92)e++;else if(a===A)break}f("literal");continue}if(H===96){C=!0,e++;continue}if(c(H)||H===35&&c(t.charCodeAt(e+1))){let A=e++;while(i(t.charCodeAt(e)))e++;let a=t.slice(A,e);f(a,l!=="."&&R(a));continue}if(H===40){let A=s!=="."&&(l==="if"||l==="while"||l==="for"||l==="with"||l==="switch"||l==="catch"||l==="await"&&s==="for");n.push(A),f("(",!0)}else if(H===41){let A=n.pop()??!1;if(e===_)return A;f(")",A)}else if(H===47&&S){e=de(t,e),f("literal");continue}else{if(H===123)o++;else if(H===125){if(o--,r.at(-1)===o)r.pop(),C=!0}f(t[e],H===47||u(H))}e++}return!1}function Be(t,_){let n=L(t,_-1);if(n<0)return!0;let r=t.charCodeAt(n);if(r===41)return b(t,n);if(u(r))return!0;if(i(r)){let o=n;while(o>=0&&i(t.charCodeAt(o)))o--;let C=t.charCodeAt(L(t,o));if(C===46||C===35)return!1;return R(t.slice(o+1,n+1))}return!1}function de(t,_){let n=_,r=t.length;n++;let o=!1;while(n<r){let C=t.charCodeAt(n);if(C===92){n+=2;continue}if(o){if(C===93)o=!1;n++;continue}if(C===91){o=!0,n++;continue}if(C===47){n++;break}if(C===10||C===13)break;n++}while(n<r&&i(t.charCodeAt(n)))n++;return n}
5
- export{c,i,Be,de};
@@ -1,27 +0,0 @@
1
- // @bun
2
- import{t,d}from"./chunk-m9x72e5j.js";import{_}from"./chunk-23w57jk5.js";import{Lt}from"./chunk-aqcjv2v5.js";import{b}from"./chunk-1721pyws.js";import{Q}from"./chunk-pwdmw567.js";import{relative as O}from"path";function J(n){let y=t(n),c=(l)=>y[l]?n.slice(y[l].start,y[l].end):"",i=c(0)==="export"?1:0;if(c(i++)!=="declare")return;let f;if(c(i)==="module"&&y[i+1]?.kind==="quoted"){if(f=d(c(i+1)),f===void 0)return;i+=2}else if(c(i++)!=="global")return;if(c(i)!=="{")return;let h=y[i].end,S=1;for(i++;i<y.length;i++)if(c(i)==="{")S++;else if(c(i)==="}"&&--S===0)return{specifier:f,body:n.slice(h,y[i].start),start:h,end:y[i].start};return}var ne=/^[A-Z_$][\w$]*$/i;function Eo(n){let y=[],c=[],i=0,f=0,h=[],S=!1,l=0,E=n.length,R=(a)=>{let w=n.slice(i,a).trim();if(i=a,!w)return;if(se(w)){c.push(w);return}y.push({text:w,comments:c}),c=[]};while(l<E){let a=n[l];if(S){if(a==="\\"){l+=2;continue}if(a==="`"){S=!1,l++;continue}if(a==="$"&&n[l+1]==="{"){h.push(f),f++,S=!1,l+=2;continue}l++;continue}if(a==="/"&&n[l+1]==="*"){let w=n.indexOf("*/",l+2);l=w===-1?E:w+2;continue}if(a==="/"&&n[l+1]==="/"){let w=n.indexOf(`
3
- `,l);l=w===-1?E:w;continue}if(a==="'"||a==='"'){l++;while(l<E&&n[l]!==a&&n[l]!==`
4
- `){if(n[l]==="\\")l++;l++}l++;continue}if(a==="`"){S=!0,l++;continue}if(a==="("||a==="["||a==="{"){f++,l++;continue}if(a===")"||a==="]"||a==="}"){if(f--,h.length>0&&a==="}"&&f===h[h.length-1])h.pop(),S=!0;l++;continue}if(f===0&&a===";"){R(l+1),l++;continue}if(f===0&&a===`
5
- `){let w=n[l+1];if(w!==void 0&&/[\w$@/]/.test(w))R(l+1);l++;continue}l++}return R(E),y}function se(n){let y=0;while(y<n.length){while(y<n.length&&/\s/.test(n[y]))y++;if(y>=n.length)return!0;if(n.startsWith("//",y)){let c=n.indexOf(`
6
- `,y);y=c===-1?n.length:c;continue}if(n.startsWith("/*",y)){let c=n.indexOf("*/",y+2);if(c===-1)return!0;y=c+2;continue}return!1}return!0}function Y(n){let y=[];for(let c of n.split(",")){let i=c.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!i)continue;let f=i.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;y.push({local:f[1],exported:f[2]??f[1]})}return y}var ie=/^(?:export\s+)?(default\s+)?(?:declare\s+)?(abstract\s+)?(class|interface|type|function\s*\*?|enum|const\s+enum|namespace|module|const|let|var|async\s+function)\b\s*([\w$]+)?/;function oe(n,y){let c=n.replace(/^export\s+/,""),i=/^default\s+/.test(c);if(c=c.replace(/^default\s+/,""),i)c=c.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(f,h)=>`${h.trimEnd()} ${y}`);if(/^(?:interface|type)\b/.test(c)||/^declare\b/.test(c))return c;return`declare ${c}`}function F(n,y,c=!1){let i={file:n,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],augmentations:[],directives:[]},f=c?Lt(y,n).map((h)=>({text:h.text,comments:[...h.leadingComments??[]]})):Eo(y);for(let h of f){h.comments=h.comments.filter((w)=>{if(/^\/\/\/\s*</.test(w))return i.directives.push(...w.split(`
7
- `).map((v)=>v.trim()).filter((v)=>v.startsWith("///"))),!1;return!0});let S=h.text.replace(/;\s*$/,"").trim(),l=S.startsWith("import")?b(S):null;if(l&&!l.isImportEquals){let w=l.source;if(l.defaultName)i.imports.set(l.defaultName,{specifier:w,imported:"default"});if(l.namespaceName)i.imports.set(l.namespaceName,{specifier:w,imported:"*"});for(let v of l.namedItems)i.imports.set(v.name,{specifier:w,imported:/^['"]/.test(v.originalName)?d(v.originalName):v.originalName});continue}if(/^import\s+['"]/.test(S)){i.verbatim.push(h);continue}let E=S.match(/^export\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s+(['"])([^'"]+)\2/);if(E){i.namespaceReExports.push({specifier:E[3],exported:E[1]});continue}if(E=S.match(/^export\s+(?:type\s+)?\*\s+from\s+(['"])([^'"]+)\1/),E){i.starReExports.push(E[2]);continue}if(E=S.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}\s+from\s+(['"])([^'"]+)\2/),E){for(let w of Y(E[1]))i.namedReExports.push({specifier:E[3],imported:w.local,exported:w.exported});continue}if(E=S.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}$/),E){for(let w of Y(E[1]))i.localExports.set(w.exported,w.local);continue}if(E=S.match(/^export\s+default\s+([\w$]+)$/),E&&ne.test(E[1])){i.localExports.set("default",E[1]);continue}let R=J(S);if(R?.specifier!==void 0&&_(y)){i.augmentations.push({statement:h,specifier:R.specifier,body:R.body});continue}if(/^export\s+as\s+namespace\b/.test(S)||R){i.verbatim.push(h);continue}let a=S.match(ie);if(a){let w=!!a[1],v=a[4]??(w?"_default":null);if(v){if(i.declared.add(v),/^export\s/.test(S))i.localExports.set(w?"default":v,v);i.declarations.push({statement:h,name:v,emit:oe(h.text,v)});continue}}i.declarations.push({statement:h,name:null,emit:h.text})}return i}function Je(n,y){if(y.size===0)return n;let c=t(n),i=new Map(c.filter((m)=>m.kind==="literal").map((m)=>[m.start,m.end])),f=(m)=>c[m]?n.slice(c[m].start,c[m].end):"",h=new Map,S=[];for(let m=0;m<c.length;m++){let x=f(m);if(["(","[","{","<"].includes(x))S.push(m);else if([")","]","}",">"].includes(x)&&!(x===">"&&f(m-1)==="=")){let k=S.at(-1);if(k!==void 0&&["()","[]","{}","<>"].includes(f(k)+x))S.pop(),h.set(k,m)}}let l=(m)=>{for(let x=m;x<c.length;x++){if([";",",",")","]","}"].includes(f(x))||f(x)===">"&&f(x-1)!=="=")return x;let k=h.get(x);if(k!==void 0)x=k}return c.length},E=new Set;for(let m=0;m<c.length;m++){let x=h.get(m);if(f(m)!=="<"||x===void 0)continue;let k=["class","interface","type"].includes(f(m-2));if(!k&&f(x+1)!=="(")continue;let N=new Set;for(let u=m+1;u<x;u++){if(u===m+1||f(u-1)===","){while(["const","in","out"].includes(f(u)))u++;if(c[u]?.kind==="word")N.add(f(u))}let D=h.get(u);if(D!==void 0)u=D}let I=l(x+1);if(k&&f(m-2)!=="type")for(let u=x+1;u<c.length;u++){if(f(u)==="{"){I=h.get(u)??I;break}let D=h.get(u);if(D!==void 0)u=D}for(let u=m+1;u<I;u++){let D=f(m-2)==="class"&&u>x&&f(u-1)==="extends";if(N.has(f(u))&&f(u-1)!=="typeof"&&!D)E.add(c[u].start)}}for(let m=0;m<c.length;m++){if(!["namespace","module"].includes(f(m))||c[m+1]?.kind!=="word"||f(m+2)!=="{")continue;let x=h.get(m+2);if(x===void 0)continue;let k=Lt(n.slice(c[m+2].end,c[x].start),"bundle-namespace.ts"),N=new Set(k.filter((u)=>["class","interface","type","enum","module","namespace"].includes(u.kind)).map((u)=>u.name)),I=new Set(k.filter((u)=>["class","variable","function","enum","module","namespace"].includes(u.kind)).map((u)=>u.name));for(let u=m+3;u<x;u++)if((f(u-1)==="typeof"?I:N).has(f(u)))E.add(c[u].start)}let R="",a=0,w=n.length,v=`
8
- `;while(a<w){let m=i.get(a);if(m!==void 0){R+=n.slice(a,m),a=m,v="`";continue}let x=n[a];if(x==="/"&&n[a+1]==="*"){let k=n.indexOf("*/",a+2),N=k===-1?w:k+2;R+=n.slice(a,N),a=N;continue}if(x==="/"&&n[a+1]==="/"){let k=n.indexOf(`
9
- `,a),N=k===-1?w:k;R+=n.slice(a,N),a=N;continue}if(x==="'"||x==='"'){let k=a+1;while(k<w&&n[k]!==x&&n[k]!==`
10
- `){if(n[k]==="\\")k++;k++}R+=n.slice(a,k+1),a=k+1,v=x;continue}if(/[A-Z_$]/i.test(x)){let k=a+1;while(k<w&&/[\w$]/.test(n[k]))k++;let N=n.slice(a,k),I=y.get(N);if(I!==void 0&&v!=="."&&!E.has(a)){let u=k;while(u<w&&(n[u]===" "||n[u]==="\t"))u++;let D=(n[u]===":"||n[u]==="?"&&n[u+1]===":")&&/[{;,(\n]/.test(v);R+=D?N:I}else R+=N;v="a",a=k;continue}if(R+=x,x===`
11
- `||!/\s/.test(x))v=x;a++}return R}function Sn(n,y,c,i){let f=[],h=new Map,S=[n,...y.filter((e)=>e!==n)];for(let e of S){let s=c.get(e);if(s===void 0){f.push(`No declarations were generated for ${O(i.cwd,e)}; it is left out of the bundle`);continue}h.set(e,F(e,s))}let l=(e,s)=>{if(!e.startsWith(".")&&!e.startsWith("/"))return null;let o=Q(e,s).resolved;return o&&h.has(o)?o:null},E=(e)=>e.startsWith(".")||e.startsWith("/"),R=new Set,a=(e)=>{let s=e;for(let o=1;R.has(s);o++)s=`${e}_${o}`;return R.add(s),s},w=new Map;for(let[e,s]of h){let o=new Map;for(let g of s.declared)o.set(g,a(g));w.set(e,o)}let v=new Map,m=(e,s,o)=>{let g=`${e}\x00${s}`,r=v.get(g);if(!r)r=a(o),v.set(g,r);return r},x=new Map,k=new Map,N=new Set,I=new Map,u=!0,D=(e,s,o)=>{let g=l(s,e.file);if(g){if(o==="*")return{kind:"namespace",file:g};let r=L(g).get(o);if(!r&&!u)f.push(`${O(i.cwd,e.file)}: '${o}' is not exported by '${s}'`);return r??null}if(E(s))return f.push(`${O(i.cwd,e.file)}: '${s}' is not part of the bundle`),null;return o==="*"?{kind:"external-namespace",source:s}:{kind:"external",source:s,imported:o}},ee=(e,s)=>{if(e.declared.has(s))return{kind:"local",name:w.get(e.file).get(s)};let o=e.imports.get(s);if(o)return D(e,o.specifier,o.imported);return f.push(`${O(i.cwd,e.file)}: cannot resolve exported name '${s}'`),null};function L(e){let s=x.get(e);if(s)return s;let o=new Map,g=h.get(e);if(!g||N.has(e))return o;N.add(e);let r=new Set;for(let[p,M]of g.localExports){let B=ee(g,M);if(B)o.set(p,B)}for(let p of g.namedReExports){let M=D(g,p.specifier,p.imported);if(M)o.set(p.exported,M)}for(let p of g.namespaceReExports){let M=D(g,p.specifier,"*");if(M)o.set(p.exported,M)}for(let p of g.starReExports){let M=l(p,e);if(M){for(let[B,C]of L(M))if(B!=="default"&&!o.has(B))o.set(B,C);for(let B of k.get(M)??[])r.add(B)}else if(E(p))f.push(`${O(i.cwd,e)}: '${p}' is not part of the bundle`);else r.add(p)}for(let[p,M]of I.get(e)??[])o.set(p,M);return N.delete(e),x.set(e,o),k.set(e,r),o}for(let[e,s]of h)for(let o of s.augmentations){let g=l(o.specifier,e);if(!g)continue;for(let r of F(e,o.body,!0).declared){if(L(g).has(r))continue;let p=I.get(g);if(!p)p=new Map,I.set(g,p);p.set(r,{kind:"local",name:a(r)}),x.clear()}}u=!1,x.clear(),k.clear();let U=new Map,H=[],T=(e,s)=>{switch(e.kind){case"local":return e.name;case"external":return m(e.source,e.imported,e.imported==="default"?s:e.imported);case"external-namespace":return m(e.source,"*",s);case"namespace":return te(e.file,s)}};function te(e,s){let o=U.get(e);if(o)return o;let g=a(s);U.set(e,g);let r=[];for(let[p,M]of L(e)){if(p==="default")continue;let B=T(M,p);r.push(B===p?p:`${B} as ${p}`)}if(k.get(e)?.size)f.push(`${O(i.cwd,e)}: 'export * from' an external module cannot be expressed inside namespace '${g}'`);return H.push(`declare namespace ${g} {
12
- export { ${r.join(", ")} };
13
- }`),g}let V=[],A=[],Z=new Set;for(let[e,s]of h){for(let r of s.directives)Z.add(r);let o=new Map;for(let[r,p]of w.get(e))if(r!==p)o.set(r,p);for(let[r,p]of s.imports){if(s.declared.has(r))continue;let M=D(s,p.specifier,p.imported);if(!M)continue;let B=T(M,r);if(B!==r)o.set(r,B)}let g=[];for(let r of s.declarations){if(i.keepComments)g.push(...r.statement.comments);let p=Je(r.emit,o);if(!/[;}]$/.test(p))p+=";";g.push(p)}for(let r of s.verbatim){if(i.keepComments)A.push(...r.comments);let p=J(r.text);if(p){let M=new Map(o);for(let B of F(e,p.body,!0).declared)M.delete(B);A.push(r.text.slice(0,p.start)+Je(p.body,M)+r.text.slice(p.end))}else{let M=t(r.text),B=M[1]?.kind==="quoted"?d(r.text.slice(M[1].start,M[1].end)):void 0;if(B===void 0||!l(B,e))A.push(Je(r.text,o))}}for(let r of s.augmentations){let p=l(r.specifier,e),M=F(e,r.body,!0),B=new Map(o);if(!p){for(let P of M.declared)B.delete(P);let C=J(r.statement.text);if(i.keepComments)A.push(...r.statement.comments);A.push(r.statement.text.slice(0,C.start)+Je(C.body,B)+r.statement.text.slice(C.end));continue}for(let[C,P]of L(p))B.set(C,T(P,C));if(i.keepComments)g.push(...r.statement.comments);for(let C of M.declarations){if(!C.name||!L(p).has(C.name))throw Error(`Cannot link augmentation '${r.specifier}' member '${C.name??C.emit}'`);if(i.keepComments)g.push(...C.statement.comments);g.push(Je(C.emit,B))}}if(g.length>0)V.push(`// From: ${O(i.cwd,e)}
14
- ${g.join(`
15
- `)}`)}let X=L(n),G=[],q=[];for(let[e,s]of X){if(s.kind==="external"){q.push(`export { ${s.imported===e?e:`${s.imported} as ${e}`} } from '${s.source}';`);continue}if(s.kind==="external-namespace"){q.push(`export * as ${e} from '${s.source}';`);continue}let o=T(s,e==="default"?"_default":e);G.push(o===e?e:`${o} as ${e}`)}for(let e of k.get(n)??[])q.push(`export * from '${e}';`);let K=new Map;for(let[e,s]of v){let[o,g]=e.split("\x00"),r=K.get(o)??{named:[],defaults:[],namespaces:[]};if(K.set(o,r),g==="*")r.namespaces.push(s);else if(g==="default")r.defaults.push(s);else r.named.push(g===s?s:`${g} as ${s}`)}let W=[];for(let[e,s]of[...K].sort(([o],[g])=>o.localeCompare(g))){for(let o of s.defaults)W.push(`import ${o} from '${e}';`);for(let o of s.namespaces)W.push(`import * as ${o} from '${e}';`);if(s.named.length>0)W.push(`import { ${s.named.join(", ")} } from '${e}';`)}let j=[];if(Z.size>0)j.push([...Z].join(`
16
- `));if(j.push(`/**
17
- * Bundled TypeScript declarations
18
- * Generated from ${h.size} source files
19
- */`),W.length>0)j.push(W.join(`
20
- `));if(j.push(...V),H.length>0)j.push(H.join(`
21
- `));if(A.length>0)j.push(A.join(`
22
- `));let z=[];if(G.length>0)z.push(`export { ${G.join(", ")} };`);if(z.push(...q),z.length===0)z.push("export {};");return j.push(z.join(`
23
- `)),{content:`${j.join(`
24
-
25
- `)}
26
- `,files:[...h.keys()],exportCount:X.size,warnings:f}}
27
- export{Eo,Je,Sn};
@@ -1,31 +0,0 @@
1
- // @bun
2
- import{g,te,kt,u}from"./chunk-m3ysqm3b.js";import{W}from"./chunk-k5wz43yh.js";import{R,M}from"./chunk-xst4jpr9.js";import{P,D}from"./chunk-7k0e2h9b.js";import{r}from"./chunk-3pcxxgwq.js";import{Se}from"./chunk-e37cbaq7.js";import{e,A}from"./chunk-btc6zbyj.js";import{Ee,k,Dn,U}from"./chunk-pwdmw567.js";import{Sn}from"./chunk-tvhg9v4f.js";import{Ke,wt}from"./chunk-y78fsxjf.js";import{E}from"./chunk-60wrxcjt.js";import{Ce,Z,V,ve}from"./chunk-1dqa0tex.js";import{qe,G,J,Ct,vt,St,$t}from"./chunk-km03xc8j.js";import{q,he}from"./chunk-pekphr39.js";import{He,xt}from"./chunk-9fz5erbq.js";import{K}from"./chunk-3r9dptyy.js";import{Tn,Ye}from"./chunk-36xenw6z.js";import{ye}from"./chunk-4q78f5pg.js";import{Ue}from"./chunk-eyc0tk75.js";import{we}from"./chunk-01zsk2q8.js";import{l}from"./chunk-rwwrrxtc.js";import{Y,Et}from"./chunk-4n2mpvmb.js";import{mkdir as xe}from"fs/promises";import{availableParallelism as Pe}from"os";import{basename as ue,dirname as fe,relative as B,resolve as ie}from"path";var oe=new WeakMap,ce=new WeakMap;function se(d){let a=oe.get(d);if(!a)a=Ee(d),oe.set(d,a),a.catch(()=>oe.delete(d));return a}async function le(d,a,t,f,w,h=G){let o=ue(d)||"output.d.ts",C=B(fe(d),a),I=`${o}.map`,Q=t.lastIndexOf(`
3
- ${qe()}`),p=Q===-1?t:t.slice(0,Q),y=St(p,o,C,f),b=`${d}.map`;return await h(b,JSON.stringify(y)),e.debug(` Generated source map: ${B(w,b)}`),I}async function s(d){let a=Date.now(),t={...E,...d};if(t.logLevel)A(t.logLevel);else if(t.verbose)A("debug");let f=new we;if(t.plugins&&t.plugins.length>0){for(let n of t.plugins)f.register(n),e.debug(`Registered plugin: ${n.name}`);t=await f.runOnStart(t)}if(t.moduleSpecifierMode!==void 0&&t.moduleSpecifierMode!=="preserve"&&t.moduleSpecifierMode!=="node")throw Error("moduleSpecifierMode must be preserve or node");if(await q(t),t.isolatedDeclarations===void 0)t.isolatedDeclarations=await J(t);let w=t.typeMappings?Y(t.typeMappings):void 0,h=null,o={generationMode:t.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},C=0;e.debug("Starting DTS generation..."),e.debug(`Using ${o.generationMode} declaration generation path`),e.debug("Config:",t);let I=await Ce(t,()=>se(t)),Q=I.entryFiles,p=[...I.files],{resolver:y,reachability:b}=I;if(ce.set(t,new Set(p)),t.incremental){let n=I.getResolutionFingerprint();if(!t.isolatedDeclarations){let i=new Set(p),m=new Map;for(let S of p){let T=await u(S);m.set(S,Ye(T));for(let ee of k(T,{includeImports:!0})){let O=y(ee.specifier,S).resolved;if(O&&!O.split(/[/\\]/).includes("node_modules")&&!i.has(O))i.add(O),m.set(O,Ye(await u(O)))}}let c=[...m].sort(([S],[T])=>S.localeCompare(T));n=JSON.stringify([n,c])}if(h=new Ke(t,n),t.clearCache){if(e.debug("Clearing build cache..."),!t.dryRun)h.clear()}else if(h.load()){let m=h.getStats();e.debug(`Loaded build cache with ${m.entries} entries`)}else e.debug("No existing build cache found, starting fresh");if(!t.dryRun)wt(t.cwd)}if(h&&!t.dryRun){let n=h.prune(new Set(p),t.cwd);if(n>0)e.debug(`Pruned ${n} deleted files from cache`)}if(e.debug(`Found ${p.length} TypeScript files`),t.progress&&p.length>0){let n=t.parallel?"parallel":"sequential";e.info(`Processing ${p.length} files (${n})...`)}let L=new Map,N=new Map,v=async(n,i,m="lf")=>{N.set(n,{content:i,lineEnding:m})},x=async(n,i)=>{let m;try{let c=V(n,t),S=async(F)=>{if(!t.diff)return;try{let j=await u(c),_=vt(j,F,B(t.cwd,c));if(_)e.info(`
4
- ${_}`);else e.debug(`[no changes] ${c}`)}catch{e.info(`[new file] ${B(t.cwd,c)}`)}},T=(F)=>{if(!t.validate)return 0;let j=Ct(F,c);if(j.isValid)return e.debug(`[validation] ${c} - OK`),0;e.warn(`[validation] ${B(t.cwd,c)} has ${j.errors.length} error(s):`);for(let _ of j.errors){let ae=` Line ${_.line}:${_.column}`;if(_.code)ae+=` [${_.code}]`;if(ae+=` - ${_.message}`,e.warn(ae),_.suggestion)e.warn(` Suggestion: ${_.suggestion}`)}return j.errors.length},ee=(F)=>{e.info(`[dry-run] Would generate: ${c}`),e.debug("--- Content preview ---"),e.debug(F.slice(0,500)+(F.length>500?`
5
- ...`:"")),e.debug("--- End preview ---")};if(h){let F=h.getCachedIfValid(n,t.cwd);if(F){if(t.bundle)L.set(n,F);await S(F);let j=T(F);if(t.dryRun)ee(F);else{if(t.declarationMap)m=i??await u(n),await le(c,n,F,m,t.cwd,v);await v(c,F,t.lineEnding)}return e.debug(`[cached] ${B(t.cwd,c)}`),{success:!0,file:n,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:j}}}m=i??await u(n);let{content:O,declarationCount:ge,importCount:be,exportCount:$e}=await me(n,m,t,f,w,I.augmentationImports.get(n));if(t.bundle)L.set(n,O);let H=O;if(t.prettier||t.indentStyle||t.indentSize){let F=await K(H,{usePrettier:t.prettier,builtIn:{indentSize:t.indentSize||2,useTabs:t.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},c);H=F.content;for(let j of F.warnings??[])e.warn(`[format] ${j}`)}if(t.declarationMap){let F=`${ue(c)||"output.d.ts"}.map`;H=$t(H,F)}await S(H);let De=T(H);if(t.dryRun)ee(H);else{if(t.declarationMap&&m)await le(c,n,H,m,t.cwd,v);if(await v(c,H,t.lineEnding),h&&m)h.update(n,m,H,t.cwd);e.debug(`Generated: ${c}`)}return{success:!0,file:n,declarationCount:ge,importCount:be,exportCount:$e,validationErrorCount:De}}catch(c){let S=He(c,n,m);if(t.plugins&&t.plugins.length>0)await f.runOnError(c instanceof Error?c:Error(String(c)),n,m||"");return{success:!1,file:n,declarationCount:0,importCount:0,exportCount:0,dtsError:S,validationErrorCount:0}}},z=t.parallel||t.parallel!==!1&&p.length>=10,X=W(t.concurrency,Pe?.()??8),ne=new Map;if(z&&p.length>1){let n=p.map(async(i)=>{try{let m=await u(i);return{file:i,source:m}}catch{return{file:i,source:null}}});for(let i of await Promise.all(n))if(i.source!==null)ne.set(i.file,i.source)}let re=(n)=>{if(o.filesProcessed++,n.success){if(n.cached)C++;else o.filesGenerated++,o.declarationsFound+=n.declarationCount,o.importsProcessed+=n.importCount,o.exportsProcessed+=n.exportCount;if(t.validate){if(o.filesValidated++,n.validationErrorCount)o.validationErrors+=n.validationErrorCount}}else if(o.filesFailed++,n.dtsError){o.errors.push(n.dtsError);let i=xt(n.dtsError);if(t.continueOnError)e.warn(i);else throw e.error(i),Error(n.dtsError.message)}};if(z)for(let n=0;n<p.length;n+=X){let i=p.slice(n,n+X),m=await Promise.all(i.map((c)=>x(c,ne.get(c))));for(let c of m)re(c);if(t.progress){let c=Math.round(o.filesProcessed/p.length*100);e.info(`[${o.filesProcessed}/${p.length}] ${c}%`)}}else for(let n of p){let i=await x(n);if(re(i),t.progress){let m=Math.round(o.filesProcessed/p.length*100),c=i.cached?"[cached]":"";e.info(`[${o.filesProcessed}/${p.length}] ${m}% - ${B(t.cwd,n)} ${c}`)}}if(!t.bundle){let n=[];if(b)for(let i of b.unresolved)n.push({from:i.from,specifier:i.specifier,reason:"missing"});if(t.autoIncludeReExports===!1&&p.length>0){let i=new Set(p);for(let m of p){let c;try{c=await u(m)}catch{continue}for(let S of k(c)){let T=y(S.specifier,m);if(!T.isRelative)continue;if(!T.resolved)n.push({from:m,specifier:S.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(T.resolved)&&!i.has(T.resolved))n.push({from:m,specifier:S.specifier,reason:"not-emitted"})}}}if(n.length>0){let i=[];i.push(`Found ${n.length} re-export(s) pointing at siblings that won't be in the output:`);for(let c of n){let S=B(t.cwd,c.from);if(c.reason==="missing")i.push(` ${S} \u2192 '${c.specifier}' (path not found on disk)`);else i.push(` ${S} \u2192 '${c.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let m=i.join(`
6
- `);if(t.failOnUnresolvedReExport)throw Error(m);e.warn(m),e.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(t.bundle&&(o.filesGenerated>0||C>0)&&Q.length>0)try{e.debug("Bundling declarations...");let n=Q.length===1&&!!t.bundleOutput;for(let i of Q){let m=await U([i],{includeImports:!0,resolveSpecifier:y}),c=new Set;for(let O of m.reachable){if(O.endsWith(".d.ts"))continue;if(O.includes("node_modules"))continue;c.add(O)}let S=p.filter((O)=>c.has(O));if(!S.includes(i))S.push(i);let T=Sn(i,S,L,{cwd:t.cwd,keepComments:t.keepComments});for(let O of new Set(T.warnings))e.warn(`[bundle] ${O}`);let ee=n?ie(t.cwd,t.outdir,t.bundleOutput):V(i,t);if(t.dryRun)e.info(`[dry-run] Would bundle ${T.files.length} files to: ${B(t.cwd,ee)}`);else await v(ee,T.content,t.lineEnding),e.debug(`Prepared ${T.files.length} bundled files for: ${B(t.cwd,ee)}`);if(n)break}}catch(n){let i=n instanceof Error?n.message:String(n);throw e.error(`Bundle failed: ${i}`),n}if(!t.dryRun)await he(t,N);if(h&&!t.dryRun)h.save(),e.debug("Saved build cache");if(o.durationMs=Date.now()-a,t.stats)if(t.outputFormat==="json")console.log(JSON.stringify(o,null,2));else{if(e.info(`
7
- --- Generation Statistics ---`),e.info(`Files processed: ${o.filesProcessed}`),e.info(`Files generated: ${o.filesGenerated}`),C>0)e.info(`Files cached: ${C}`);if(o.filesFailed>0)e.info(`Files failed: ${o.filesFailed}`);if(e.info(`Declarations found: ${o.declarationsFound}`),e.info(`Imports processed: ${o.importsProcessed}`),e.info(`Exports processed: ${o.exportsProcessed}`),o.filesValidated>0){if(e.info(`Files validated: ${o.filesValidated}`),o.validationErrors>0)e.info(`Validation errors: ${o.validationErrors}`)}if(e.info(`Duration: ${o.durationMs}ms`),o.errors.length>0){e.info(`
8
- Errors:`);for(let n of o.errors){let i=` - ${n.file}`;if(n.location)i+=`:${n.location.line}:${n.location.column}`;if(n.code)i+=` [${n.code}]`;if(i+=`: ${n.message}`,e.info(i),n.suggestion)e.info(` Suggestion: ${n.suggestion}`)}}e.info(`-----------------------------
9
- `)}if(t.plugins&&t.plugins.length>0)await f.runOnEnd(o);return e.debug("DTS generation complete!"),o}async function Me(d,a,t){let f=await se(t),w=ve(a,t,f,ce.get(t));return Dn(d,(h)=>w(h).emittedSpecifier)}async function ro(d,a){oe.delete(a),ce.delete(a);let t=await se(a),f=await U([d],{includeImports:!0,resolveSpecifier:t}),w=await Se([...f.sources.keys()],t,a.isolatedDeclarations??!1,f.sources);return(await pe(d,a,void 0,w.get(ie(d)))).content}async function pe(d,a,t,f){let w=await u(d),h=a.typeMappings?Y(a.typeMappings):void 0;return me(d,w,a,t,h,f)}async function me(d,a,t,f,w,h){let o=a;if(f)o=await f.runOnBeforeFile(d,a);let C=new Map;if(!t.isolatedDeclarations){let v=await se(t);for(let x of k(o,{includeImports:!0})){let z=v(x.specifier,d).resolved;if(z&&!z.split(/[/\\]/).includes("node_modules"))C.set(x.specifier,await u(z))}}let I=f?.hasDeclarationHooks()?null:Re(o,d,t,C,h);if(I!==null)return de(I,d,o,t,f,w,Fe(I));let Q=C.size?Tn(o,C):void 0,p=r(o,d,t.keepComments,t.isolatedDeclarations??!1,Q);if(f)p=await f.runOnDeclarations(d,o,p);let y=0,b=0;for(let v=0;v<p.length;v++){let x=p[v];if(x.kind==="import")y++;if(x.kind==="export"||x.isExported)b++}let N=l(p,{filePath:d,sourceCode:o,declarations:p,augmentationImports:h},t.keepComments,t.importOrder);return de(N,d,o,t,f,w,{declarationCount:p.length,importCount:y,exportCount:b})}function Fe(d){let a=0,t=0,f=0;for(let w of d.split(`
10
- `)){if(!w||w.startsWith(" ")||w.startsWith("\t")||w.startsWith("}")||w.startsWith("*")||w.startsWith("/"))continue;if(a++,w.startsWith("import "))t++;else if(w.startsWith("export "))f++}return{declarationCount:a,importCount:t,exportCount:f}}function Re(d,a,t,f,w){let h=t.importOrder??["bun"];if(h.length!==1||h[0]!=="bun")return null;let o=R(a)?M(d):P(a)?D(d):d;return ye(o,{keepComments:t.keepComments??!0,isolatedDeclarations:t.isolatedDeclarations??!1,sourceFile:a,inferenceSources:f,augmentationImports:w})}async function de(d,a,t,f,w,h,o){let C=await Me(d,a,f);if(h)C=Et(C,h,{filePath:a});if(f.normalizeOutput===!0||f.declarationOrder)C=Ue(C,{lineEnding:"lf",declarationOrder:f.declarationOrder,indent:{style:f.indentStyle??"spaces",size:f.indentSize??2}});if(w)C=await w.runOnAfterFile(a,t,C);return{content:C,...o}}async function io(d){let a={...E,...d};if(a.logLevel)A(a.logLevel);let t=ie(a.cwd,a.root),f=150,w=5,h=1e4,o={pendingChanges:new Set,debounceTimer:null,isProcessing:!1,errorCount:0,lastErrorTime:0};e.info(`Watching for changes in ${t}...`),e.info(`Press Ctrl+C to stop
11
- `);try{await s(a),e.info(`[watch] Initial generation complete
12
- `)}catch(y){let b=y instanceof Error?y.message:String(y);e.error(`[watch] Initial generation failed: ${b}`),e.info(`[watch] Continuing to watch for changes...
13
- `)}async function C(){if(o.isProcessing||o.pendingChanges.size===0)return;let y=Date.now();if(o.errorCount>=w){if(y-o.lastErrorTime<h){e.warn(`[watch] Too many errors, pausing for ${Math.ceil((h-(y-o.lastErrorTime))/1000)}s...`);return}o.errorCount=0}o.isProcessing=!0;let b=Array.from(o.pendingChanges);o.pendingChanges.clear();let L=new Date().toLocaleTimeString();if(b.length===1)e.info(`
14
- [${L}] File changed: ${b[0]}`);else e.info(`
15
- [${L}] ${b.length} files changed`);let N=0,v=0;for(let x of b){let z=ie(t,x);try{let X=a.exclude||[];if(Z(z,X,t)){e.debug(` Skipping excluded file: ${x}`);continue}if(!await te(z).exists()){e.debug(` Skipping deleted file: ${x}`);continue}let re=V(z,a),{content:n}=await pe(z,a);await xe(fe(re),{recursive:!0}),await G(re,n,a.lineEnding),e.info(` \u2713 ${B(a.cwd,re)}`),N++}catch(X){v++,o.errorCount++,o.lastErrorTime=Date.now();let ne=He(X,z);if(e.error(` \u2717 ${x}: ${ne.message}`),ne.suggestion)e.error(` Suggestion: ${ne.suggestion}`)}}if(b.length>1)e.info(` Done: ${N} generated, ${v} failed`);if(v===0)o.errorCount=0;if(o.isProcessing=!1,o.pendingChanges.size>0)o.debounceTimer=setTimeout(C,f)}function I(y){if(o.pendingChanges.add(y),o.debounceTimer)clearTimeout(o.debounceTimer);o.debounceTimer=setTimeout(C,f)}let p=kt([g?"bun":"node","-e",`
16
- const fs = require('fs');
17
-
18
- const rootPath = '${t}';
19
-
20
- fs.watch(rootPath, { recursive: true }, (eventType, filename) => {
21
- if (filename && /.(?:[cm]?[jt]sx?|vue|stx)$/.test(filename) && !/.d.(?:ts|mts|cts)$/.test(filename)) {
22
- console.log(\`CHANGED:\${filename}\`);
23
- }
24
- });
25
-
26
- // Keep process alive
27
- setInterval(() => {}, 1000);
28
- `],{stdout:"pipe",stderr:"inherit"});if(g){let y=p.stdout.getReader(),b=new TextDecoder,L="";while(!0){let{done:N,value:v}=await y.read();if(N)break;L+=b.decode(v,{stream:!0});let x=L.split(`
29
- `);L=x.pop()||"";for(let z of x)if(z.startsWith("CHANGED:")){let X=z.slice(8);I(X)}}}else{let y=p.stdout,b="";y.on("data",(L)=>{b+=L.toString();let N=b.split(`
30
- `);b=N.pop()||"";for(let v of N)if(v.startsWith("CHANGED:")){let x=v.slice(8);I(x)}}),await p.exited}}
31
- export{s,ro,io};