@dtsx/dtsx 0.11.40 → 0.11.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/dist/{chunk-31kbs9mj.js → chunk-00m9cbar.js} +3 -3
  3. package/dist/{chunk-jswvvjkr.js → chunk-01zsk2q8.js} +3 -3
  4. package/dist/{chunk-tm2j0feh.js → chunk-06jp6gah.js} +2 -2
  5. package/dist/{chunk-3jjrn16z.js → chunk-13tjnp25.js} +3 -3
  6. package/dist/{chunk-ka8mbyjb.js → chunk-1vc3eend.js} +2 -2
  7. package/dist/{chunk-zk55g2cb.js → chunk-298wqs3n.js} +1 -1
  8. package/dist/{chunk-45fpbdw3.js → chunk-3jtwkmfx.js} +1 -1
  9. package/dist/chunk-3qx4ys4v.js +38 -0
  10. package/dist/{chunk-8dvxjzhy.js → chunk-3r9dptyy.js} +2 -2
  11. package/dist/{chunk-w26wgqh8.js → chunk-537hj5pj.js} +1 -1
  12. package/dist/{chunk-2dstvjpv.js → chunk-54d8mt4c.js} +1 -1
  13. package/dist/{chunk-js4m0y2m.js → chunk-5ezj0r3g.js} +1 -1
  14. package/dist/{chunk-p4hf9bwj.js → chunk-6vz1grv8.js} +3 -3
  15. package/dist/{chunk-8zvjkzsv.js → chunk-7387m006.js} +2 -2
  16. package/dist/{chunk-kccc6p2t.js → chunk-73qsp464.js} +1 -1
  17. package/dist/{chunk-0c03j9eq.js → chunk-7g0hjhqy.js} +1 -1
  18. package/dist/chunk-7khy25x0.js +3 -0
  19. package/dist/{chunk-ayyb1jpe.js → chunk-85d82vn3.js} +2 -2
  20. package/dist/{chunk-hvy1zvk6.js → chunk-8wk7nw3c.js} +1 -1
  21. package/dist/{chunk-jfygtm4r.js → chunk-a2dn9j88.js} +1 -1
  22. package/dist/{chunk-phwfth21.js → chunk-asqkc0bw.js} +2 -2
  23. package/dist/{chunk-nqgfrehj.js → chunk-bre2x1bd.js} +1 -1
  24. package/dist/{chunk-nd0sbh5r.js → chunk-btwfkzt5.js} +3 -3
  25. package/dist/{chunk-t6ds7drh.js → chunk-cyfnxk8d.js} +2 -2
  26. package/dist/{chunk-a3vfqhnp.js → chunk-cywe5sgm.js} +1 -1
  27. package/dist/{chunk-3dweac93.js → chunk-eatp44nf.js} +1 -1
  28. package/dist/{chunk-bc7ahgxz.js → chunk-ej7jt519.js} +2 -2
  29. package/dist/{chunk-jyq39qjt.js → chunk-f2yhf6gj.js} +2 -2
  30. package/dist/{chunk-0m1wt3db.js → chunk-fv3x086v.js} +2 -2
  31. package/dist/chunk-g0dxj89b.js +7 -0
  32. package/dist/{chunk-dpcvehxp.js → chunk-g4dpvmfy.js} +1 -1
  33. package/dist/{chunk-3mcz22q8.js → chunk-gc7y4wav.js} +4 -4
  34. package/dist/{chunk-axj2w6hp.js → chunk-gt5k2mff.js} +1 -1
  35. package/dist/{chunk-zn2gvwve.js → chunk-gv9brtta.js} +3 -3
  36. package/dist/{chunk-qrwst9bb.js → chunk-j0p7bwj6.js} +2 -2
  37. package/dist/{chunk-zbe06f63.js → chunk-jf8mxazb.js} +1 -1
  38. package/dist/{chunk-y3x7p6jf.js → chunk-k9695p66.js} +1 -1
  39. package/dist/{chunk-g3zt5h6d.js → chunk-kdnqedyb.js} +2 -2
  40. package/dist/{chunk-yde8rmfm.js → chunk-msr5zymd.js} +8 -8
  41. package/dist/{chunk-y4wykrya.js → chunk-pd30356m.js} +3 -3
  42. package/dist/{chunk-aak9xzy7.js → chunk-prst4szw.js} +2 -2
  43. package/dist/{chunk-z6mpxpxt.js → chunk-q4fhsthj.js} +1 -1
  44. package/dist/{chunk-6epjc5rj.js → chunk-q4gxj6qk.js} +1 -1
  45. package/dist/{chunk-7ynrmx5b.js → chunk-q76b61w9.js} +4 -4
  46. package/dist/{chunk-hgscwj1y.js → chunk-qqjbaqm6.js} +2 -2
  47. package/dist/{chunk-sgcne5bb.js → chunk-qzb5pswc.js} +2 -2
  48. package/dist/{chunk-ee109s3r.js → chunk-r27pfg4r.js} +6 -6
  49. package/dist/{chunk-kv0bpgyw.js → chunk-s0sretav.js} +1 -1
  50. package/dist/{chunk-5yjyb87w.js → chunk-t76sqybd.js} +1 -1
  51. package/dist/{chunk-996gqrz6.js → chunk-t8cgznk6.js} +2 -2
  52. package/dist/{chunk-fay5vymp.js → chunk-twrcd0q6.js} +2 -2
  53. package/dist/{chunk-yzdh207n.js → chunk-vjtcxr3q.js} +4 -4
  54. package/dist/chunk-w3zqfm8a.js +3 -0
  55. package/dist/{chunk-jhpfmjnx.js → chunk-x4qkjqda.js} +1 -1
  56. package/dist/{chunk-ybzz1jg7.js → chunk-xzw0p4nq.js} +2 -2
  57. package/dist/{chunk-ex03kbwr.js → chunk-ywv56grs.js} +1 -1
  58. package/dist/{chunk-vgmnxnjf.js → chunk-zbyvnsny.js} +11 -11
  59. package/dist/{chunk-7j4cgkb4.js → chunk-zf96k060.js} +2 -2
  60. package/dist/{chunk-vbzchjvq.js → chunk-zy5jxjmg.js} +1 -1
  61. package/dist/src/augmentation-graph.js +1 -1
  62. package/dist/src/binding-patterns.js +1 -1
  63. package/dist/src/branded-types.js +1 -1
  64. package/dist/src/bundle-linker.js +1 -1
  65. package/dist/src/bundler.js +1 -1
  66. package/dist/src/cache.js +1 -1
  67. package/dist/src/call-signatures.js +1 -1
  68. package/dist/src/circular.js +1 -1
  69. package/dist/src/compat.js +1 -1
  70. package/dist/src/computed-keys.js +1 -1
  71. package/dist/src/declaration-project.js +1 -1
  72. package/dist/src/declaration-publication.js +1 -1
  73. package/dist/src/declaration-references.js +1 -1
  74. package/dist/src/diff.js +1 -1
  75. package/dist/src/docs.js +1 -1
  76. package/dist/src/enum-declarations.js +1 -1
  77. package/dist/src/errors.js +1 -1
  78. package/dist/src/extractor/extract.js +1 -1
  79. package/dist/src/extractor/scanner.js +1 -1
  80. package/dist/src/extractor.js +1 -1
  81. package/dist/src/formatter.js +1 -1
  82. package/dist/src/function-properties.js +1 -1
  83. package/dist/src/generator.js +1 -1
  84. package/dist/src/incremental.js +1 -1
  85. package/dist/src/index.js +1 -1
  86. package/dist/src/inferred-imports.js +1 -1
  87. package/dist/src/lsp.js +1 -1
  88. package/dist/src/memory.js +1 -1
  89. package/dist/src/module-graph.js +1 -1
  90. package/dist/src/module-references.js +1 -1
  91. package/dist/src/native-checker.js +1 -1
  92. package/dist/src/native-extractor.js +1 -1
  93. package/dist/src/native-generation.js +1 -1
  94. package/dist/src/native-project.js +1 -1
  95. package/dist/src/optimizer.js +1 -1
  96. package/dist/src/parallel-processor.js +1 -1
  97. package/dist/src/parameters.js +1 -1
  98. package/dist/src/parser.js +1 -1
  99. package/dist/src/plugins/bun.js +1 -1
  100. package/dist/src/plugins/esbuild.js +1 -1
  101. package/dist/src/plugins/index.js +1 -1
  102. package/dist/src/plugins/tsdown.js +1 -1
  103. package/dist/src/plugins/tsup.js +1 -1
  104. package/dist/src/plugins/vite.js +1 -1
  105. package/dist/src/plugins/webpack.js +1 -1
  106. package/dist/src/plugins.js +1 -1
  107. package/dist/src/process-source.js +1 -1
  108. package/dist/src/processor/declarations.js +1 -1
  109. package/dist/src/processor/import-usage.js +1 -1
  110. package/dist/src/processor/imports.js +1 -1
  111. package/dist/src/processor/index.js +1 -1
  112. package/dist/src/processor/type-inference.js +1 -1
  113. package/dist/src/processor.js +1 -1
  114. package/dist/src/profiling.js +1 -1
  115. package/dist/src/return-type-scope.js +1 -1
  116. package/dist/src/source-cache.js +1 -1
  117. package/dist/src/sourcemap.js +1 -1
  118. package/dist/src/transformers.js +1 -1
  119. package/dist/src/tsconfig.js +1 -1
  120. package/dist/src/type-mappings.js +1 -1
  121. package/dist/src/utils.js +1 -1
  122. package/dist/src/value-inference.js +1 -1
  123. package/dist/src/watcher.js +1 -1
  124. package/dist/src/worker-thread.js +1 -1
  125. package/dist/src/workspace.js +1 -1
  126. package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
  127. package/native/darwin-x64/libzig-dtsx.dylib +0 -0
  128. package/native/freebsd-x64/libzig-dtsx.so +0 -0
  129. package/native/linux-arm64/libzig-dtsx.so +0 -0
  130. package/native/linux-x64/libzig-dtsx.so +0 -0
  131. package/native/windows-x64/zig-dtsx.dll +0 -0
  132. package/package.json +1 -1
  133. package/dist/chunk-7z8pykqp.js +0 -3
  134. package/dist/chunk-c7a07a26.js +0 -7
  135. package/dist/chunk-qq5x44y9.js +0 -38
  136. package/dist/chunk-vf8jmdsp.js +0 -3
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{r}from"./chunk-z6mpxpxt.js";import{existsSync as j,mkdirSync as N,readFileSync as z,writeFileSync as G}from"fs";import{dirname as K,relative as L,resolve as _}from"path";async function ls(t,e,n){let u=new Map,f=[],x=new Set,D=0,w=0,S=0,C=[];for(let i of t){let o=e.get(i);if(!o)continue;C.push({file:i,decls:r(o,i,n.keepComments)})}for(let{file:i,decls:o}of C){D+=o.length;for(let s of o)if(s.kind==="import"){w++;let c=s.source||"";if(c.startsWith("."))continue;if(!u.has(c))u.set(c,{source:c,specifiers:new Map,isTypeOnly:s.isTypeOnly||!1,isSideEffect:s.isSideEffect||!1});let l=u.get(c);if(s.specifiers)for(let h of s.specifiers){let W=h.alias||h.name;if(!l.specifiers.has(W))l.specifiers.set(W,{name:h.name,alias:h.alias,isType:h.isType||!1})}if(!s.isTypeOnly)l.isTypeOnly=!1}else if(s.isExported||s.kind==="export"){if(S++,s.kind==="export"&&s.source&&(s.source.startsWith(".")||s.source.startsWith("/")))continue;if(s.name&&x.has(s.name))continue;if(s.name)x.add(s.name);f.push({declaration:s,file:i})}}let a=[];a.push("/**"),a.push(" * Bundled TypeScript declarations"),a.push(` * Generated from ${t.length} source files`),a.push(" */"),a.push("");let T=n.importOrder||["bun"],y=Array.from(u.values()),p=Array(y.length);for(let i=0;i<y.length;i++){let o=y[i].source,s=T.length;for(let c=0;c<T.length;c++)if(o.startsWith(T[c])){s=c;break}p[i]=s}let g=y.map((i,o)=>o);g.sort((i,o)=>{let s=p[i],c=p[o];if(s!==c)return s-c;return y[i].source.localeCompare(y[o].source)});let b=g.map((i)=>y[i]);for(let i of b)if(i.isSideEffect)a.push(`import '${i.source}';`);else if(i.specifiers.size>0){let s=Array.from(i.specifiers.values()).map((l)=>{let h=l.isType?"type ":"";return l.alias?`${h}${l.name} as ${l.alias}`:`${h}${l.name}`}),c=i.isTypeOnly?"type ":"";a.push(`import ${c}{ ${s.join(", ")} } from '${i.source}';`)}if(b.length>0)a.push("");let m=new Map;for(let{declaration:i,file:o}of f){if(!m.has(o))m.set(o,[]);m.get(o).push(i)}for(let[i,o]of m){let s=L(n.cwd,i);a.push(`// From: ${s}`);for(let c of o){if(n.keepComments&&c.leadingComments)for(let l of c.leadingComments)a.push(l);a.push(F(c))}a.push("")}let d=a.join(`
2
+ import{r}from"./chunk-q4fhsthj.js";import{existsSync as j,mkdirSync as N,readFileSync as z,writeFileSync as G}from"fs";import{dirname as K,relative as L,resolve as _}from"path";async function ls(t,e,n){let u=new Map,f=[],x=new Set,D=0,w=0,S=0,C=[];for(let i of t){let o=e.get(i);if(!o)continue;C.push({file:i,decls:r(o,i,n.keepComments)})}for(let{file:i,decls:o}of C){D+=o.length;for(let s of o)if(s.kind==="import"){w++;let c=s.source||"";if(c.startsWith("."))continue;if(!u.has(c))u.set(c,{source:c,specifiers:new Map,isTypeOnly:s.isTypeOnly||!1,isSideEffect:s.isSideEffect||!1});let l=u.get(c);if(s.specifiers)for(let h of s.specifiers){let W=h.alias||h.name;if(!l.specifiers.has(W))l.specifiers.set(W,{name:h.name,alias:h.alias,isType:h.isType||!1})}if(!s.isTypeOnly)l.isTypeOnly=!1}else if(s.isExported||s.kind==="export"){if(S++,s.kind==="export"&&s.source&&(s.source.startsWith(".")||s.source.startsWith("/")))continue;if(s.name&&x.has(s.name))continue;if(s.name)x.add(s.name);f.push({declaration:s,file:i})}}let a=[];a.push("/**"),a.push(" * Bundled TypeScript declarations"),a.push(` * Generated from ${t.length} source files`),a.push(" */"),a.push("");let T=n.importOrder||["bun"],y=Array.from(u.values()),p=Array(y.length);for(let i=0;i<y.length;i++){let o=y[i].source,s=T.length;for(let c=0;c<T.length;c++)if(o.startsWith(T[c])){s=c;break}p[i]=s}let g=y.map((i,o)=>o);g.sort((i,o)=>{let s=p[i],c=p[o];if(s!==c)return s-c;return y[i].source.localeCompare(y[o].source)});let b=g.map((i)=>y[i]);for(let i of b)if(i.isSideEffect)a.push(`import '${i.source}';`);else if(i.specifiers.size>0){let s=Array.from(i.specifiers.values()).map((l)=>{let h=l.isType?"type ":"";return l.alias?`${h}${l.name} as ${l.alias}`:`${h}${l.name}`}),c=i.isTypeOnly?"type ":"";a.push(`import ${c}{ ${s.join(", ")} } from '${i.source}';`)}if(b.length>0)a.push("");let m=new Map;for(let{declaration:i,file:o}of f){if(!m.has(o))m.set(o,[]);m.get(o).push(i)}for(let[i,o]of m){let s=L(n.cwd,i);a.push(`// From: ${s}`);for(let c of o){if(n.keepComments&&c.leadingComments)for(let l of c.leadingComments)a.push(l);a.push(F(c))}a.push("")}let d=a.join(`
3
3
  `);return{content:d,files:t,declarationCount:D,importCount:w,exportCount:S,size:Buffer.byteLength(d,"utf8"),warnings:[]}}function F(t){if(t.text){let n=t.text.trim();if(t.isExported&&!n.startsWith("export"))n=`export ${n}`;if(!n.endsWith(";")&&!n.endsWith("}"))n+=";";return n}let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${V(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let n of t.members)e.push(` ${n.name}${n.typeAnnotation?`: ${n.typeAnnotation}`:""};`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)e.push(`implements ${t.implements.join(", ")}`);if(e.push("{"),t.members)for(let n of t.members)e.push(` ${F(n)}`);e.push("}");break;case"enum":if(e.push("declare enum"),e.push(t.name),e.push("{"),t.members){let n=t.members.map((u)=>u.value!==void 0?`${u.name} = ${u.value}`:u.name);e.push(` ${n.join(`,
4
4
  `)}`)}e.push("}");break;default:return t.text||""}return e.join(" ")}function V(t){if(!t||t.length===0)return"";return t.map((e)=>{let n="";if(e.rest)n+="...";if(n+=e.name,e.optional)n+="?";if(e.type)n+=`: ${e.type}`;if(e.defaultValue)n+=` = ${e.defaultValue}`;return n}).join(", ")}async function Kt(t,e={}){let n=[],u=new Map,f=[],x=[],D=new Set,w=0,S=0,C=0;for(let p of t){if(!j(p)){n.push(`File not found: ${p}`);continue}let g=z(p,"utf-8");x.push(p);let b=g.split(`
5
5
  `),m=[],d=0,i=!1;for(let o of b){let s=o.trim();if(!s&&!i)continue;if(s.startsWith("import ")){S++;let l=s.match(/import\s+(type\s+)?(?:\{([^}]+)\}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/);if(l){let[,h,W,q,H,A]=l;if(e.externals?.some((P)=>A.startsWith(P))){f.push(s);continue}if(A.startsWith("."))continue;if(!u.has(A))u.set(A,{source:A,specifiers:new Map,isTypeOnly:!!h,isSideEffect:!1});let E=u.get(A);if(W){let P=W.split(",").map((k)=>k.trim());for(let k of P){let[I,v]=k.split(/\s+as\s+/).map((M)=>M.trim()),R=I.startsWith("type "),O=R?I.replace("type ",""):I;E.specifiers.set(v||O,{name:O,alias:v!==O?v:void 0,isType:R})}}if(!h)E.isTypeOnly=!1}continue}if(/^(export\s+)?(declare\s+)?(interface|type|class|function|const|let|var|enum|namespace|module)\s/.test(s)){if(i=!0,m=[o],d=(o.match(/\{/g)||[]).length-(o.match(/\}/g)||[]).length,d===0&&(s.endsWith(";")||!s.includes("{"))){let l=B(s);if(!D.has(l)||!e.mergeDuplicates){if(D.add(l),f.push(o),w++,s.startsWith("export"))C++}i=!1,m=[]}}else if(i){if(m.push(o),d+=(o.match(/\{/g)||[]).length-(o.match(/\}/g)||[]).length,d<=0){let l=m.join(`
6
6
  `),h=B(m[0]);if(!D.has(h)||!e.mergeDuplicates){if(D.add(h),f.push(l),w++,m[0].trim().startsWith("export"))C++}i=!1,m=[]}}else if(s.startsWith("export ")&&!s.includes("declare"))f.push(o),C++}}let a=[];if(e.banner)a.push(e.banner),a.push("");if(e.includeReferences&&e.references){for(let p of e.references)a.push(`/// <reference types="${p}" />`);a.push("")}let T=Array.from(u.values()).sort((p,g)=>p.source.localeCompare(g.source));for(let p of T)if(p.specifiers.size>0){let b=Array.from(p.specifiers.values()).map((d)=>{let i=d.isType?"type ":"";return d.alias?`${i}${d.name} as ${d.alias}`:`${i}${d.name}`}),m=p.isTypeOnly?"type ":"";a.push(`import ${m}{ ${b.join(", ")} } from '${p.source}';`)}if(T.length>0)a.push("");if(e.ambient&&e.moduleName){a.push(`declare module '${e.moduleName}' {`);for(let p of f){let g=p.split(`
7
7
  `).map((b)=>` ${b.replace(/^(\s*)(export\s+)?declare\s+/,"$1$2")}`).join(`
8
8
  `);a.push(g)}a.push("}")}else{if(e.sortDeclarations)f.sort((p,g)=>{let b=B(p),m=B(g);return b.localeCompare(m)});for(let p of f)a.push(p)}if(e.footer)a.push(""),a.push(e.footer);let y=a.join(`
9
- `);return{content:y,files:x,declarationCount:w,importCount:S,exportCount:C,size:Buffer.byteLength(y,"utf-8"),warnings:n}}function B(t){let e=t.match(/(interface|type|class|function|const|let|var|enum|namespace|module)\s+(\w+)/);return e?`${e[1]}:${e[2]}`:t.trim()}async function xr(t,e,n={}){let u=await Kt(t,n),f=K(e);if(!j(f))N(f,{recursive:!0});return G(e,u.content),u}function us(t={}){return{bundle:(e)=>Kt(e,t),bundleAndWrite:(e,n)=>xr(e,n,{...t,output:n})}}async function fs(t,e=process.cwd()){let n=Array.isArray(t)?t:[t],u=[];for(let f of n){if(f.includes("*"))continue;let x=_(e,f);if(j(x))u.push(x)}return u}
10
- export{ls,Kt,xr,us,fs};
9
+ `);return{content:y,files:x,declarationCount:w,importCount:S,exportCount:C,size:Buffer.byteLength(y,"utf-8"),warnings:n}}function B(t){let e=t.match(/(interface|type|class|function|const|let|var|enum|namespace|module)\s+(\w+)/);return e?`${e[1]}:${e[2]}`:t.trim()}async function wr(t,e,n={}){let u=await Kt(t,n),f=K(e);if(!j(f))N(f,{recursive:!0});return G(e,u.content),u}function us(t={}){return{bundle:(e)=>Kt(e,t),bundleAndWrite:(e,n)=>wr(e,n,{...t,output:n})}}async function fs(t,e=process.cwd()){let n=Array.isArray(t)?t:[t],u=[];for(let f of n){if(f.includes("*"))continue;let x=_(e,f);if(j(x))u.push(x)}return u}
10
+ export{ls,Kt,wr,us,fs};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  import{readFile as M,writeFile as S}from"fs/promises";import{basename as x,dirname as d,relative as b,resolve as C}from"path";function f(e){return`${String.fromCharCode(47,47,35)} sourceMappingURL=${e}`}class rn{file;sourceRoot;sources=[];sourcesContent=[];names=[];mappings=[];sourceIndexMap=new Map;nameIndexMap=new Map;constructor(e){this.file=e.file,this.sourceRoot=e.sourceRoot}addSource(e,n){let r=this.sourceIndexMap.get(e);if(r===void 0)r=this.sources.length,this.sources.push(e),this.sourcesContent.push(n??null),this.sourceIndexMap.set(e,r);else if(n&&!this.sourcesContent[r])this.sourcesContent[r]=n;return r}addName(e){let n=this.nameIndexMap.get(e);if(n===void 0)n=this.names.length,this.names.push(e),this.nameIndexMap.set(e,n);return n}addMapping(e){let n=this.addSource(e.source),r;if(e.name)r=this.addName(e.name);this.mappings.push({generated:e.generated,original:e.original,sourceIndex:n,nameIndex:r})}generate(e=!1){this.mappings.sort((r,t)=>{if(r.generated.line!==t.generated.line)return r.generated.line-t.generated.line;return r.generated.column-t.generated.column});let n={version:3,file:this.file,sources:this.sources,names:this.names,mappings:this.encodeMappings()};if(this.sourceRoot)n.sourceRoot=this.sourceRoot;if(e)n.sourcesContent=this.sourcesContent;return n}encodeMappings(){let e=[],n=0,r=0,t=0,i=0,o=0,s=0,u=[];for(let a of this.mappings){while(n<a.generated.line)e.push(u.join(",")),u=[],n++,r=0;let l=[];if(l.push(a.generated.column-r),r=a.generated.column,l.push(a.sourceIndex-t),t=a.sourceIndex,l.push(a.original.line-i),i=a.original.line,l.push(a.original.column-o),o=a.original.column,a.nameIndex!==void 0)l.push(a.nameIndex-s),s=a.nameIndex;u.push(I(l))}return e.push(u.join(",")),e.join(";")}toString(e=!1){return JSON.stringify(this.generate(e))}toDataUrl(e=!1){let n=this.toString(e);return`data:application/json;charset=utf-8;base64,${Buffer.from(n).toString("base64")}`}toComment(e=!1){return f(this.toDataUrl(e))}}class mt{map;decodedMappings=null;constructor(e){this.map=typeof e==="string"?JSON.parse(e):e}originalPositionFor(e){let n=this.getMappings(),r=0,t=n.length-1,i=null;while(r<=t){let o=Math.floor((r+t)/2),s=n[o];if(s.generated.line===e.line)if(s.generated.column===e.column){i=s;break}else if(s.generated.column<e.column)i=s,r=o+1;else t=o-1;else if(s.generated.line<e.line)r=o+1;else t=o-1}if(!i)return{source:null,line:null,column:null,name:null};return{source:this.map.sources[i.sourceIndex]||null,line:i.original.line,column:i.original.column,name:i.nameIndex!==void 0?this.map.names[i.nameIndex]:null}}generatedPositionFor(e){let n=this.map.sources.indexOf(e.source);if(n===-1)return null;let r=this.getMappings();for(let t of r)if(t.sourceIndex===n&&t.original.line===e.line&&t.original.column<=e.column)return t.generated;return null}getMappings(){if(!this.decodedMappings)this.decodedMappings=v(this.map.mappings);return this.decodedMappings}sourceContentFor(e){let n=this.map.sources.indexOf(e);if(n===-1||!this.map.sourcesContent)return null;return this.map.sourcesContent[n]}}function I(e){return e.map(L).join("")}function L(e){let o="",s=e<0?-e<<1|1:e<<1;do{let u=s&31;if(s>>>=5,s>0)u|=32;o+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u]}while(s>0);return o}function v(e){let n=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,i=0,o=0,s=0,u=0,a=0,l=e.split(";");for(let g of l){if(i=0,g){let h=g.split(",");for(let p of h){if(!p)continue;let c=N(p,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");if(c.length>=1)i+=c[0];if(c.length>=4){o+=c[1],s+=c[2],u+=c[3];let m={generated:{line:t,column:i},original:{line:s,column:u},sourceIndex:o};if(c.length>=5)a+=c[4],m.nameIndex=a;n.push(m)}}}t++}return n}function N(e,n){let t=[],i=0,o=0;for(let s of e){let u=n.indexOf(s);if(u===-1)continue;let a=u&32;if(o+=(u&31)<<i,a)i+=5;else{let l=o&1;o>>=1,t.push(l?-o:o),o=0,i=0}}return t}function Ns(e){let n=new rn({file:x(e.generatedFile),sourceRoot:e.sourceRoot}),r=b(d(e.generatedFile),e.sourceFile);n.addSource(r,e.sourceContent);for(let t of e.mappings)n.addMapping({generated:{line:t.generatedLine,column:t.generatedColumn},original:{line:t.originalLine,column:t.originalColumn},source:r,name:t.name});return n}function Bs(e,n){return`${e}
3
3
  ${f(n)}`}function Ws(e,n,r=!1){return`${e}
4
- ${n.toComment(r)}`}async function js(e,n,r=!1){await S(e,n.toString(r))}async function _r(e){let n=await M(e,"utf-8");return new mt(n)}async function _s(e,n){let r=e.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if(r){let i=r[1],o=Buffer.from(i,"base64").toString("utf-8");return new mt(o)}let t=e.match(/\/\/# sourceMappingURL=(.+)$/);if(t){let i=C(d(n),t[1].trim());try{return await _r(i)}catch{return null}}return null}function Gs(e,n){let r=e,t=n,i=r.split(`
4
+ ${n.toComment(r)}`}async function _s(e,n,r=!1){await S(e,n.toString(r))}async function jr(e){let n=await M(e,"utf-8");return new mt(n)}async function js(e,n){let r=e.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if(r){let i=r[1],o=Buffer.from(i,"base64").toString("utf-8");return new mt(o)}let t=e.match(/\/\/# sourceMappingURL=(.+)$/);if(t){let i=C(d(n),t[1].trim());try{return await jr(i)}catch{return null}}return null}function Gs(e,n){let r=e,t=n,i=r.split(`
5
5
  `),o=[],s=0,u=0;for(let a of t){while(s+i[u].length+1<=a.generatedStart&&u<i.length-1)s+=i[u].length+1,u++;let l=a.generatedStart-s;o.push({generatedLine:u,generatedColumn:Math.max(0,l),originalLine:a.originalLine,originalColumn:a.originalColumn,name:a.name})}return o}
6
- export{rn,mt,Ns,Bs,Ws,js,_r,_s,Gs};
6
+ export{rn,mt,Ns,Bs,Ws,_s,jr,js,Gs};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Le}from"./chunk-ex03kbwr.js";import{T}from"./chunk-3mcz22q8.js";import{b}from"./chunk-jfygtm4r.js";function kn(i,r){let n=new Set;for(let e of T(i,"imports.ts",!1)){if(e.kind!=="import")continue;let t=b(e.text),a=t&&r.get(t.source);if(!t||t.isTypeOnly||!a)continue;let s=Je(a);for(let o of t.namedItems)if(!o.isTypeOnly&&s.some((m)=>m.name===o.originalName))n.add(o.name);if(t.defaultName&&s.some((o)=>o.isDefault))n.add(t.defaultName)}return n}function Je(i){let r=T(i,"dependency.ts",!1).filter((n)=>n.kind==="function");return r.filter((n)=>n.isExported&&!n.generics&&r.filter((e)=>e.name===n.name).length===1&&Le(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
2
+ import{Le}from"./chunk-ywv56grs.js";import{T}from"./chunk-gc7y4wav.js";import{b}from"./chunk-a2dn9j88.js";function kn(i,r){let n=new Set;for(let e of T(i,"imports.ts",!1)){if(e.kind!=="import")continue;let t=b(e.text),a=t&&r.get(t.source);if(!t||t.isTypeOnly||!a)continue;let s=Je(a);for(let o of t.namedItems)if(!o.isTypeOnly&&s.some((m)=>m.name===o.originalName))n.add(o.name);if(t.defaultName&&s.some((o)=>o.isDefault))n.add(t.defaultName)}return n}function Je(i){let r=T(i,"dependency.ts",!1).filter((n)=>n.kind==="function");return r.filter((n)=>n.isExported&&!n.generics&&r.filter((e)=>e.name===n.name).length===1&&Le(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
3
3
  export{kn,Je};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{B}from"./chunk-60wrxcjt.js";import{k}from"./chunk-7z8pykqp.js";import{Ce,ve}from"./chunk-y4wykrya.js";import{createHash as x}from"crypto";import{readFile as d}from"fs/promises";import{resolve as m}from"path";async function An(g){let e={...B,...g},n=e.moduleSpecifierMode??"preserve";if(n!=="node"&&n!=="preserve")throw Error("moduleSpecifierMode must be preserve or node");if(e.plugins?.length)throw Error("Native project planning does not support generation plugins");let o=await Ce(e),l=[];for(let r of o.files){let s=await d(r),a=s.toString("utf8");if(!Buffer.from(a,"utf8").equals(s))throw Error(`Native declaration source must be valid UTF-8: ${r}`);let u=o.outputBySource.get(r),v=ve(r,e,o.resolver),i=[],S=new Set(k(a,{includeImports:!0}).map((t)=>t.specifier));for(let t of S){let p=v(t);if(p.kind!=="local")continue;let{resolvedSource:h,declarationOutput:w,emittedSpecifier:y}=p;i.push({specifier:t,resolvedSource:h,declarationOutput:w,emittedSpecifier:y})}let c={version:1,moduleSpecifierMode:n,sourceFile:r,outputFile:u,sourceHash:x("sha256").update(s).digest("hex"),rewrites:i};if(!e.isolatedDeclarations&&i.length)c.inferenceSources=await Promise.all(i.map(async(t)=>({specifier:t.specifier,source:await d(t.resolvedSource,"utf8")})));let f=o.augmentationImports.get(r);if(f?.size)c.augmentationImports=[...f];l.push(Object.freeze({sourceFile:r,outputFile:u,source:a,context:c}))}return Object.freeze({version:1,rootPath:m(e.cwd,e.root),outdirPath:m(e.cwd,e.outdir),files:Object.freeze(l)})}
2
+ import{B}from"./chunk-60wrxcjt.js";import{k}from"./chunk-7khy25x0.js";import{Ce,ve}from"./chunk-pd30356m.js";import{createHash as x}from"crypto";import{readFile as d}from"fs/promises";import{resolve as m}from"path";async function An(g){let e={...B,...g},n=e.moduleSpecifierMode??"preserve";if(n!=="node"&&n!=="preserve")throw Error("moduleSpecifierMode must be preserve or node");if(e.plugins?.length)throw Error("Native project planning does not support generation plugins");let o=await Ce(e),l=[];for(let r of o.files){let s=await d(r),a=s.toString("utf8");if(!Buffer.from(a,"utf8").equals(s))throw Error(`Native declaration source must be valid UTF-8: ${r}`);let u=o.outputBySource.get(r),v=ve(r,e,o.resolver),i=[],S=new Set(k(a,{includeImports:!0}).map((t)=>t.specifier));for(let t of S){let p=v(t);if(p.kind!=="local")continue;let{resolvedSource:h,declarationOutput:w,emittedSpecifier:y}=p;i.push({specifier:t,resolvedSource:h,declarationOutput:w,emittedSpecifier:y})}let c={version:1,moduleSpecifierMode:n,sourceFile:r,outputFile:u,sourceHash:x("sha256").update(s).digest("hex"),rewrites:i};if(!e.isolatedDeclarations&&i.length)c.inferenceSources=await Promise.all(i.map(async(t)=>({specifier:t.specifier,source:await d(t.resolvedSource,"utf8")})));let f=o.augmentationImports.get(r);if(f?.size)c.augmentationImports=[...f];l.push(Object.freeze({sourceFile:r,outputFile:u,source:a,context:c}))}return Object.freeze({version:1,rootPath:m(e.cwd,e.root),outdirPath:m(e.cwd,e.outdir),files:Object.freeze(l)})}
3
3
  export{An};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{s}from"./chunk-yde8rmfm.js";function Be(d={}){let{buildStart:l=!0,buildEnd:u=!1,writeBundle:c=!1,modes:t,onGenerated:f,onError:o,...p}=d,i="production",r=async()=>{try{let e=await s(p);f?.(e)}catch(e){let a=e instanceof Error?e:Error(String(e));if(o?.(a),!o)console.error("[dtsx] Generation failed:",a.message)}},n=()=>{if(!t||t.length===0)return!0;return t.includes(i)};return{name:"dtsx",apply(e){return i=e.mode,!0},async buildStart(){if(l&&n())await r()},async buildEnd(){if(u&&n())await r()},async writeBundle(){if(c&&n())await r()}}}var xa=Be,Ca=Be;
3
- export{Be,xa,Ca};
2
+ import{s}from"./chunk-msr5zymd.js";function Be(d={}){let{buildStart:l=!0,buildEnd:u=!1,writeBundle:c=!1,modes:t,onGenerated:f,onError:o,...p}=d,i="production",r=async()=>{try{let e=await s(p);f?.(e)}catch(e){let a=e instanceof Error?e:Error(String(e));if(o?.(a),!o)console.error("[dtsx] Generation failed:",a.message)}},n=()=>{if(!t||t.length===0)return!0;return t.includes(i)};return{name:"dtsx",apply(e){return i=e.mode,!0},async buildStart(){if(l&&n())await r()},async buildEnd(){if(u&&n())await r()},async writeBundle(){if(c&&n())await r()}}}var wa=Be,Ca=Be;
3
+ export{Be,wa,Ca};
@@ -1,18 +1,18 @@
1
1
  // @bun
2
- import{g,ee,Et,u}from"./chunk-ayyb1jpe.js";import{W}from"./chunk-k5wz43yh.js";import{R,M}from"./chunk-2ngfncfx.js";import{P,D}from"./chunk-hqph3vnd.js";import{r}from"./chunk-z6mpxpxt.js";import{Se}from"./chunk-2dstvjpv.js";import{e,A}from"./chunk-btc6zbyj.js";import{Ee,k,Pn,U}from"./chunk-7z8pykqp.js";import{vn}from"./chunk-vgmnxnjf.js";import{He,wt}from"./chunk-ka8mbyjb.js";import{E}from"./chunk-60wrxcjt.js";import{Ce,X,V,ve}from"./chunk-y4wykrya.js";import{Ke,G,q,xt,Ct,vt,St}from"./chunk-3jjrn16z.js";import{K,he}from"./chunk-aak9xzy7.js";import{ze,bt}from"./chunk-p4hf9bwj.js";import{H}from"./chunk-8dvxjzhy.js";import{kn,Je}from"./chunk-zbe06f63.js";import{ye}from"./chunk-4q78f5pg.js";import{Ve}from"./chunk-550teag8.js";import{xe}from"./chunk-jswvvjkr.js";import{l}from"./chunk-yzdh207n.js";import{J,$t}from"./chunk-sgcne5bb.js";import{mkdir as De}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`,Y=t.lastIndexOf(`
3
- ${Ke()}`),p=Y===-1?t:t.slice(0,Y),y=vt(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 xe;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 K(t),t.isolatedDeclarations===void 0)t.isolatedDeclarations=await q(t);let w=t.typeMappings?J(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)),Y=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,Je(T));for(let te of k(T,{includeImports:!0})){let O=y(te.specifier,S).resolved;if(O&&!O.split(/[/\\]/).includes("node_modules")&&!i.has(O))i.add(O),m.set(O,Je(await u(O)))}}let c=[...m].sort(([S],[T])=>S.localeCompare(T));n=JSON.stringify([n,c])}if(h=new He(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 _=await u(c),Q=Ct(_,F,B(t.cwd,c));if(Q)e.info(`
4
- ${Q}`);else e.debug(`[no changes] ${c}`)}catch{e.info(`[new file] ${B(t.cwd,c)}`)}},T=(F)=>{if(!t.validate)return 0;let _=xt(F,c);if(_.isValid)return e.debug(`[validation] ${c} - OK`),0;e.warn(`[validation] ${B(t.cwd,c)} has ${_.errors.length} error(s):`);for(let Q of _.errors){let ae=` Line ${Q.line}:${Q.column}`;if(Q.code)ae+=` [${Q.code}]`;if(ae+=` - ${Q.message}`,e.warn(ae),Q.suggestion)e.warn(` Suggestion: ${Q.suggestion}`)}return _.errors.length},te=(F)=>{e.info(`[dry-run] Would generate: ${c}`),e.debug("--- Content preview ---"),e.debug(F.slice(0,500)+(F.length>500?`
5
- ...`:"")),e.debug("--- End preview ---")};if(h){let F=h.getCachedIfValid(n,t.cwd);if(F){if(t.bundle)L.set(n,F);await S(F);let _=T(F);if(t.dryRun)te(F);else{if(t.declarationMap)m=i??await u(n),await le(c,n,F,m,t.cwd,v);await v(c,F,t.lineEnding)}return e.debug(`[cached] ${B(t.cwd,c)}`),{success:!0,file:n,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:_}}}m=i??await u(n);let{content:O,declarationCount:ge,importCount:we,exportCount:be}=await me(n,m,t,f,w,I.augmentationImports.get(n));if(t.bundle)L.set(n,O);let j=O;if(t.prettier||t.indentStyle||t.indentSize){let F=await H(j,{usePrettier:t.prettier,builtIn:{indentSize:t.indentSize||2,useTabs:t.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},c);j=F.content;for(let _ of F.warnings??[])e.warn(`[format] ${_}`)}if(t.declarationMap){let F=`${ue(c)||"output.d.ts"}.map`;j=St(j,F)}await S(j);let $e=T(j);if(t.dryRun)te(j);else{if(t.declarationMap&&m)await le(c,n,j,m,t.cwd,v);if(await v(c,j,t.lineEnding),h&&m)h.update(n,m,j,t.cwd);e.debug(`Generated: ${c}`)}return{success:!0,file:n,declarationCount:ge,importCount:we,exportCount:be,validationErrorCount:$e}}catch(c){let S=ze(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,Z=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=bt(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+=Z){let i=p.slice(n,n+Z),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)&&Y.length>0)try{e.debug("Bundling declarations...");let n=Y.length===1&&!!t.bundleOutput;for(let i of Y){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=vn(i,S,L,{cwd:t.cwd,keepComments:t.keepComments});for(let O of new Set(T.warnings))e.warn(`[bundle] ${O}`);let te=n?ie(t.cwd,t.outdir,t.bundleOutput):V(i,t);if(t.dryRun)e.info(`[dry-run] Would bundle ${T.files.length} files to: ${B(t.cwd,te)}`);else await v(te,T.content,t.lineEnding),e.debug(`Prepared ${T.files.length} bundled files for: ${B(t.cwd,te)}`);if(n)break}}catch(n){let i=n instanceof Error?n.message:String(n);throw e.error(`Bundle failed: ${i}`),n}if(!t.dryRun)await 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(`
2
+ import{g,te,Et,u}from"./chunk-85d82vn3.js";import{W}from"./chunk-k5wz43yh.js";import{R,M}from"./chunk-2ngfncfx.js";import{P,D}from"./chunk-hqph3vnd.js";import{r}from"./chunk-q4fhsthj.js";import{Se}from"./chunk-54d8mt4c.js";import{e,A}from"./chunk-btc6zbyj.js";import{Ee,k,Pn,U}from"./chunk-7khy25x0.js";import{vn}from"./chunk-zbyvnsny.js";import{He,xt}from"./chunk-1vc3eend.js";import{E}from"./chunk-60wrxcjt.js";import{Ce,Z,V,ve}from"./chunk-pd30356m.js";import{Ke,G,J,wt,Ct,vt,St}from"./chunk-13tjnp25.js";import{q,he}from"./chunk-prst4szw.js";import{ze,bt}from"./chunk-6vz1grv8.js";import{K}from"./chunk-3r9dptyy.js";import{kn,Je}from"./chunk-jf8mxazb.js";import{ye}from"./chunk-4q78f5pg.js";import{Ve}from"./chunk-550teag8.js";import{we}from"./chunk-01zsk2q8.js";import{l}from"./chunk-vjtcxr3q.js";import{Y,$t}from"./chunk-qzb5pswc.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
+ ${Ke()}`),p=Q===-1?t:t.slice(0,Q),y=vt(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,Je(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,Je(await u(O)))}}let c=[...m].sort(([S],[T])=>S.localeCompare(T));n=JSON.stringify([n,c])}if(h=new He(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)xt(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),_=Ct(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=wt(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=St(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=ze(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=bt(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=vn(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
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
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 Pn(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?J(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 Y=C.size?kn(o,C):void 0,p=r(o,d,t.keepComments,t.isolatedDeclarations??!1,Y);if(f)p=await f.runOnDeclarations(d,o,p);let y=0,b=0;for(let v=0;v<p.length;v++){let x=p[v];if(x.kind==="import")y++;if(x.kind==="export"||x.isExported)b++}let N=l(p,{filePath:d,sourceCode:o,declarations:p,augmentationImports:h},t.keepComments,t.importOrder);return 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(`
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 Pn(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?kn(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
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=$t(C,h,{filePath:a});if(f.normalizeOutput===!0||f.declarationOrder)C=Ve(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
11
  `);try{await s(a),e.info(`[watch] Initial generation complete
12
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
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
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 Z=a.exclude||[];if(X(z,Z,t)){e.debug(` Skipping excluded file: ${x}`);continue}if(!await ee(z).exists()){e.debug(` Skipping deleted file: ${x}`);continue}let re=V(z,a),{content:n}=await pe(z,a);await De(fe(re),{recursive:!0}),await G(re,n,a.lineEnding),e.info(` \u2713 ${B(a.cwd,re)}`),N++}catch(Z){v++,o.errorCount++,o.lastErrorTime=Date.now();let ne=ze(Z,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=Et([g?"bun":"node","-e",`
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=ze(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=Et([g?"bun":"node","-e",`
16
16
  const fs = require('fs');
17
17
 
18
18
  const rootPath = '${t}';
@@ -26,6 +26,6 @@ Errors:`);for(let n of o.errors){let i=` - ${n.file}`;if(n.location)i+=`:${n.lo
26
26
  // Keep process alive
27
27
  setInterval(() => {}, 1000);
28
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 Z=z.slice(8);I(Z)}}}else{let y=p.stdout,b="";y.on("data",(L)=>{b+=L.toString();let N=b.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
30
  `);b=N.pop()||"";for(let v of N)if(v.startsWith("CHANGED:")){let x=v.slice(8);I(x)}}),await p.exited}}
31
31
  export{s,ro,io};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{Se}from"./chunk-2dstvjpv.js";import{e}from"./chunk-btc6zbyj.js";import{Ee,U}from"./chunk-7z8pykqp.js";import{existsSync as x}from"fs";import{basename as D,dirname as M,extname as R,isAbsolute as v,relative as p,resolve as m}from"path";var{Glob:j}=globalThis.Bun;async function Ce(r,o){let s=await F(r);C(r,s);let n=s.slice(),a=await(o?o():Ee(r)),t=null;if(r.autoIncludeReExports!==!1&&n.length>0){t=await U(n,{includeImports:!0,resolveSpecifier:a});let l=m(r.cwd,r.root),u=r.exclude||[],f=[];for(let c of t.reachable){if(n.includes(c))continue;if(!b(c))continue;if(c.endsWith(".d.ts"))continue;if(c.includes("node_modules"))continue;let E=r.outputStructure==="flat"&&s.some((O)=>a.isPackageLocal?.(O,c));if(!S(c,l)&&!E){e.warn(`Skipping auto-included source outside root: ${p(r.cwd,c)}`);continue}if(X(c,u,l))continue;f.push(c)}if(f.length>0)n=[...n,...f],e.debug(`Auto-included ${f.length} file(s) reached via relative re-exports`)}let i=N(n,r),d=t??await U(n,{includeImports:!0,resolveSpecifier:a}),g=await Se([...d.sources.keys()],a,r.isolatedDeclarations??!1,d.sources),h=new Set(n);for(let[l,u]of g){if(!h.has(l))continue;for(let f of u){let c=a(f,l).resolved;if(c&&!h.has(c))throw Error(`Module augmentation import ${JSON.stringify(f)} from ${l} requires a source not emitted by this package build: ${c}`)}}let y=[...g].map(([l,u])=>[l,[...u].sort()]).sort(([l],[u])=>l.localeCompare(u));return Object.freeze({entryFiles:Object.freeze(s),files:Object.freeze(n),outputBySource:i,resolver:a,reachability:t,augmentationImports:g,getResolutionFingerprint:()=>JSON.stringify({resolution:a.cacheKey?.(n),augmentations:y})})}var P=50,w=new Map;function k(r){let o=w.get(r);if(!o){if(o=new j(r),w.set(r,o),w.size>P){let s=w.keys().next().value;if(s!==void 0)w.delete(s)}}return o}function X(r,o,s){if(!o||o.length===0)return!1;let n=p(s,r);for(let a of o){let t=k(a);if(t.match(n)||t.match(r))return!0}return!1}var G=/[*?[\]{}!]/;function C(r,o){let s=m(r.cwd,r.root),n=` root: ${s}
2
+ import{Se}from"./chunk-54d8mt4c.js";import{e}from"./chunk-btc6zbyj.js";import{Ee,U}from"./chunk-7khy25x0.js";import{existsSync as x}from"fs";import{basename as D,dirname as M,extname as R,isAbsolute as v,relative as p,resolve as m}from"path";var{Glob:j}=globalThis.Bun;async function Ce(r,o){let s=await F(r);C(r,s);let n=s.slice(),a=await(o?o():Ee(r)),t=null;if(r.autoIncludeReExports!==!1&&n.length>0){t=await U(n,{includeImports:!0,resolveSpecifier:a});let l=m(r.cwd,r.root),u=r.exclude||[],f=[];for(let c of t.reachable){if(n.includes(c))continue;if(!b(c))continue;if(c.endsWith(".d.ts"))continue;if(c.includes("node_modules"))continue;let E=r.outputStructure==="flat"&&s.some((O)=>a.isPackageLocal?.(O,c));if(!S(c,l)&&!E){e.warn(`Skipping auto-included source outside root: ${p(r.cwd,c)}`);continue}if(Z(c,u,l))continue;f.push(c)}if(f.length>0)n=[...n,...f],e.debug(`Auto-included ${f.length} file(s) reached via relative re-exports`)}let i=N(n,r),d=t??await U(n,{includeImports:!0,resolveSpecifier:a}),g=await Se([...d.sources.keys()],a,r.isolatedDeclarations??!1,d.sources),h=new Set(n);for(let[l,u]of g){if(!h.has(l))continue;for(let f of u){let c=a(f,l).resolved;if(c&&!h.has(c))throw Error(`Module augmentation import ${JSON.stringify(f)} from ${l} requires a source not emitted by this package build: ${c}`)}}let y=[...g].map(([l,u])=>[l,[...u].sort()]).sort(([l],[u])=>l.localeCompare(u));return Object.freeze({entryFiles:Object.freeze(s),files:Object.freeze(n),outputBySource:i,resolver:a,reachability:t,augmentationImports:g,getResolutionFingerprint:()=>JSON.stringify({resolution:a.cacheKey?.(n),augmentations:y})})}var P=50,w=new Map;function k(r){let o=w.get(r);if(!o){if(o=new j(r),w.set(r,o),w.size>P){let s=w.keys().next().value;if(s!==void 0)w.delete(s)}}return o}function Z(r,o,s){if(!o||o.length===0)return!1;let n=p(s,r);for(let a of o){let t=k(a);if(t.match(n)||t.match(r))return!0}return!1}var G=/[*?[\]{}!]/;function C(r,o){let s=m(r.cwd,r.root),n=` root: ${s}
3
3
  entrypoints: ${r.entrypoints.map((t)=>JSON.stringify(t)).join(", ")||"(none)"}
4
4
  `+(r.exclude?.length?` exclude: ${r.exclude.map((t)=>JSON.stringify(t)).join(", ")}
5
5
  `:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(o.length===0){if(r.entrypoints.filter((i)=>v(i)&&x(i)&&!S(i,s)).length===r.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
6
6
  ${n}`)}let a=r.entrypoints.filter((t)=>{if(G.test(t))return!1;return!x(v(t)?t:m(s,t))});if(a.length>0)throw Error(`Entrypoint${a.length>1?"s":""} not found: ${a.map((t)=>JSON.stringify(t)).join(", ")}
7
- ${n}`)}async function F(r){let o=[],s=m(r.cwd,r.root),n=r.exclude||[],a=[...r.entrypoints,...r.include??[]];for(let t of a)if(v(t)&&b(t)){if(!t.includes("node_modules")){if(!S(t,s)&&r.outputStructure!=="flat")e.warn(`Skipping entrypoint outside root: ${p(r.cwd,t)}`);else if(!X(t,n,s))o.push(t)}}else{let i=new j(t);for await(let d of i.scan({cwd:s,absolute:!0,onlyFiles:!0}))if(b(d)&&!d.includes("node_modules")){if(!X(d,n,s))o.push(d)}}return[...new Set(o.map((t)=>m(t)))].sort()}function S(r,o){let s=p(o,r);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!v(s)}function N(r,o){let s=new Map,n=new Map;for(let a of r){let t=V(a,o),i=s.get(t);if(i&&i!==a)throw Error(`Output path collision: ${p(o.cwd,i)} and ${p(o.cwd,a)} both emit ${p(o.cwd,t)}`);s.set(t,a),n.set(a,t)}return n}function b(r){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(r)&&!/\.d\.(?:ts|mts|cts)$/.test(r)}function V(r,o){let s=m(o.cwd,o.root),n=p(s,r),a=/\.d\.(?:ts|mts|cts)$/.test(n)?n:n.replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(t)=>{if(t===".mts"||t===".mjs")return".d.mts";if(t===".cts"||t===".cjs")return".d.cts";return".d.ts"});if(o.outputStructure==="mirror")return m(o.cwd,o.outdir,a);else{let t=D(a);return m(o.cwd,o.outdir,t)}}function Yo(r,o,s=""){let n=p(M(r),o).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),s)n+=s;if(!n.startsWith("."))n=`./${n}`;return n}function ve(r,o,s,n){let a=V(r,o);return(t)=>{let i=s(t,r);if(!i.isRelative||!i.resolved)return{kind:"unchanged",reason:i.isRelative?"unresolved":"external",specifier:t,emittedSpecifier:t};if(/\.d\.(?:ts|mts|cts)$/.test(i.resolved)){if(o.moduleSpecifierMode!=="node")return{kind:"unchanged",reason:"preserved-declaration",specifier:t,emittedSpecifier:t};if(n&&!n.has(i.resolved))throw Error(`Local declaration ${JSON.stringify(t)} from ${r} targets an authored declaration not emitted by this package build: ${i.resolved}. Declaration-only dependencies must be delivered with the package before this importer can be emitted.`)}if(i.isAlias&&n&&!n.has(i.resolved))throw Error(`Local alias ${JSON.stringify(t)} from ${r} targets a declaration excluded from this package build: ${i.resolved}`);if(n&&!n.has(i.resolved)&&X(i.resolved,o.exclude??[],m(o.cwd,o.root)))throw Error(`Local reference ${JSON.stringify(t)} from ${r} targets a source excluded from this package build: ${i.resolved}`);let d=i.isAlias?i.suffix??"":t.match(/[?#].*$/)?.[0]??"",g=d?t.slice(0,-d.length):t,h=R(g),y=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(h)?h:"";if(!y&&o.moduleSpecifierMode==="node"){let u=R(i.resolved);y=u===".mts"||u===".mjs"?".mjs":u===".cts"||u===".cjs"?".cjs":".js"}let l=V(i.resolved,o);return{kind:"local",specifier:t,resolvedSource:i.resolved,declarationOutput:l,emittedSpecifier:Yo(a,l,y)+d}}}
8
- export{Ce,X,S,V,Yo,ve};
7
+ ${n}`)}async function F(r){let o=[],s=m(r.cwd,r.root),n=r.exclude||[],a=[...r.entrypoints,...r.include??[]];for(let t of a)if(v(t)&&b(t)){if(!t.includes("node_modules")){if(!S(t,s)&&r.outputStructure!=="flat")e.warn(`Skipping entrypoint outside root: ${p(r.cwd,t)}`);else if(!Z(t,n,s))o.push(t)}}else{let i=new j(t);for await(let d of i.scan({cwd:s,absolute:!0,onlyFiles:!0}))if(b(d)&&!d.includes("node_modules")){if(!Z(d,n,s))o.push(d)}}return[...new Set(o.map((t)=>m(t)))].sort()}function S(r,o){let s=p(o,r);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!v(s)}function N(r,o){let s=new Map,n=new Map;for(let a of r){let t=V(a,o),i=s.get(t);if(i&&i!==a)throw Error(`Output path collision: ${p(o.cwd,i)} and ${p(o.cwd,a)} both emit ${p(o.cwd,t)}`);s.set(t,a),n.set(a,t)}return n}function b(r){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(r)&&!/\.d\.(?:ts|mts|cts)$/.test(r)}function V(r,o){let s=m(o.cwd,o.root),n=p(s,r),a=/\.d\.(?:ts|mts|cts)$/.test(n)?n:n.replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(t)=>{if(t===".mts"||t===".mjs")return".d.mts";if(t===".cts"||t===".cjs")return".d.cts";return".d.ts"});if(o.outputStructure==="mirror")return m(o.cwd,o.outdir,a);else{let t=D(a);return m(o.cwd,o.outdir,t)}}function Yo(r,o,s=""){let n=p(M(r),o).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),s)n+=s;if(!n.startsWith("."))n=`./${n}`;return n}function ve(r,o,s,n){let a=V(r,o);return(t)=>{let i=s(t,r);if(!i.isRelative||!i.resolved)return{kind:"unchanged",reason:i.isRelative?"unresolved":"external",specifier:t,emittedSpecifier:t};if(/\.d\.(?:ts|mts|cts)$/.test(i.resolved)){if(o.moduleSpecifierMode!=="node")return{kind:"unchanged",reason:"preserved-declaration",specifier:t,emittedSpecifier:t};if(n&&!n.has(i.resolved))throw Error(`Local declaration ${JSON.stringify(t)} from ${r} targets an authored declaration not emitted by this package build: ${i.resolved}. Declaration-only dependencies must be delivered with the package before this importer can be emitted.`)}if(i.isAlias&&n&&!n.has(i.resolved))throw Error(`Local alias ${JSON.stringify(t)} from ${r} targets a declaration excluded from this package build: ${i.resolved}`);if(n&&!n.has(i.resolved)&&Z(i.resolved,o.exclude??[],m(o.cwd,o.root)))throw Error(`Local reference ${JSON.stringify(t)} from ${r} targets a source excluded from this package build: ${i.resolved}`);let d=i.isAlias?i.suffix??"":t.match(/[?#].*$/)?.[0]??"",g=d?t.slice(0,-d.length):t,h=R(g),y=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(h)?h:"";if(!y&&o.moduleSpecifierMode==="node"){let u=R(i.resolved);y=u===".mts"||u===".mjs"?".mjs":u===".cts"||u===".cjs"?".cjs":".js"}let l=V(i.resolved,o);return{kind:"local",specifier:t,resolvedSource:i.resolved,declarationOutput:l,emittedSpecifier:Yo(a,l,y)+d}}}
8
+ export{Ce,Z,S,V,Yo,ve};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{S}from"./chunk-y4wykrya.js";import{G}from"./chunk-3jjrn16z.js";import{chmod as j,lstat as P,mkdir as y,readdir as q,realpath as L,rename as D,rm as R,rmdir as W,stat as A,writeFile as _}from"fs/promises";import{basename as B,dirname as m,isAbsolute as M,parse as J,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await L(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),B(e))}}async function K(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!S(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===J(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(S(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function x(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await x(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await q(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function he(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await K(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!S(t,n)||S(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],T=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!S(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(S(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await x(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await _(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await G(v,i.content,i.lineEnding),!a.clean&&u.existing)await j(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),T.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await x(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of T.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await W(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
3
- export{K,he};
2
+ import{S}from"./chunk-pd30356m.js";import{G}from"./chunk-13tjnp25.js";import{chmod as j,lstat as P,mkdir as y,readdir as L,realpath as W,rename as D,rm as R,rmdir as _,stat as A,writeFile as B}from"fs/promises";import{basename as J,dirname as m,isAbsolute as M,parse as U,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await W(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),J(e))}}async function q(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!S(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===U(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(S(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function x(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await x(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await L(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function he(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await q(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!S(t,n)||S(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],T=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!S(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(S(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await x(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await B(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await G(v,i.content,i.lineEnding),!a.clean&&u.existing)await j(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),T.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await x(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of T.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await _(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
3
+ export{q,he};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{W}from"./chunk-k5wz43yh.js";import{Te,Rn}from"./chunk-vbzchjvq.js";import{te,On}from"./chunk-8zvjkzsv.js";function Si(){On(),Rn()}function r(e,t,c=!0,n=!1,o){return Te(e,t,c,n,o)}async function Dn(e,t,c=!0,n={}){return await te(t,e,n),r(e,t,c)}async function $i(e,t={}){let c=W(t.concurrency,4),n=new Map;for(let o=0;o<e.length;o+=c){let s=e.slice(o,o+c),i=await Promise.all(s.map(async(a)=>({path:a.filePath,declarations:await Dn(a.sourceCode,a.filePath,a.keepComments,t)})));for(let a of i)n.set(a.path,a.declarations)}return n}
2
+ import{W}from"./chunk-k5wz43yh.js";import{Te,Rn}from"./chunk-zy5jxjmg.js";import{ne,On}from"./chunk-7387m006.js";function Si(){On(),Rn()}function r(e,t,c=!0,n=!1,o){return Te(e,t,c,n,o)}async function Dn(e,t,c=!0,n={}){return await ne(t,e,n),r(e,t,c)}async function $i(e,t={}){let c=W(t.concurrency,4),n=new Map;for(let o=0;o<e.length;o+=c){let s=e.slice(o,o+c),i=await Promise.all(s.map(async(a)=>({path:a.filePath,declarations:await Dn(a.sourceCode,a.filePath,a.keepComments,t)})));for(let a of i)n.set(a.path,a.declarations)}return n}
3
3
  export{Si,r,Dn,$i};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{r}from"./chunk-z6mpxpxt.js";import{existsSync as g,readFileSync as h,writeFileSync as b}from"fs";function d(t){let e=[],s=/\b([A-Z][a-zA-Z0-9]*)\b/g,o;while((o=s.exec(t))!==null){let i=o[1];if(!D(i))e.push(i)}return[...new Set(e)]}function D(t){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(t)}function x(t){if(t.kind!=="type")return!1;let e=t.typeAnnotation||"";if(t.generics)return!1;if(e.includes("{")||e.includes("(")||e.includes("<"))return!1;return/^[\w\s|&]+$/.test(e)}function v(t){if(t.kind!=="interface")return!1;if(!t.members||t.members.length===0){if(!t.extends)return!0}return!1}function I(t,e){let s={...t,members:[...t.members||[],...e.members||[]],leadingComments:[...t.leadingComments||[],...e.leadingComments||[]]};if(t.extends&&e.extends){let o=t.extends.split(",").map((n)=>n.trim()),i=e.extends.split(",").map((n)=>n.trim());s.extends=[...new Set([...o,...i])].join(", ")}else s.extends=t.extends||e.extends;return s}function A(t){let e={import:0,interface:1,type:2,class:3,enum:4,function:5,variable:6,export:7};return[...t].sort((s,o)=>{let i=e[s.kind]??99,n=e[o.kind]??99;if(i!==n)return i-n;return s.name.localeCompare(o.name)})}function T(t){let e=[],s=[];for(let i=0;i<t.length;i++){let n=t[i];if(n.kind==="import")e.push(n);else s.push(n)}return[...[...e].sort((i,n)=>{let a=i.source||"",c=n.source||"",p=a.startsWith("node:")||a==="bun",m=c.startsWith("node:")||c==="bun";if(p&&!m)return-1;if(!p&&m)return 1;let l=!a.startsWith("."),u=!c.startsWith(".");if(l&&!u)return-1;if(!l&&u)return 1;return a.localeCompare(c)}),...s]}function S(t){let e=new Set;for(let i of t){if(i.kind==="import")continue;let n=i.text||"",a=i.typeAnnotation||"",c=i.returnType||"",p=i.extends||"",m=i.implements?.join(" ")||"",l=`${n} ${a} ${c} ${p} ${m}`;for(let u of d(l))e.add(u);if(i.members)for(let u of i.members){let f=`${u.typeAnnotation||""} ${u.returnType||""}`;for(let y of d(f))e.add(y)}if(i.parameters){for(let u of i.parameters)if(u.type)for(let f of d(u.type))e.add(f)}}let s=0;return{declarations:t.map((i)=>{if(i.kind!=="import"||!i.specifiers)return i;let n=i.specifiers.filter((a)=>{let c=a.alias||a.name;return e.has(c)});if(n.length===0){if(!i.isSideEffect)return s++,null}if(n.length<(i.specifiers?.length||0))return s+=(i.specifiers?.length||0)-n.length,{...i,specifiers:n};return i}).filter((i)=>i!==null),removed:s}}function k(t){let e=new Map,s=0;for(let o of t){if(o.kind==="import"){let n=`import:${o.source}`;if(e.has(n)){let a=e.get(n),c=[...a.specifiers||[],...o.specifiers||[]],p=Array.from(new Map(c.map((m)=>[m.alias||m.name,m])).values());e.set(n,{...a,specifiers:p}),s++}else e.set(n,o);continue}let i=`${o.kind}:${o.name}`;if(e.has(i))s++;else e.set(i,o)}return{declarations:Array.from(e.values()),removed:s}}function z(t){let e=new Map,s=[];for(let n of t)if(n.kind==="interface"){let a=n.name;if(!e.has(a))e.set(a,[]);e.get(a).push(n)}else s.push(n);let o=0,i=[];for(let[n,a]of e)if(a.length>1){let c=a[0];for(let p=1;p<a.length;p++)c=I(c,a[p]),o++;i.push(c)}else i.push(a[0]);return{declarations:[...s,...i],merged:o}}function w(t){let e=new Map,s=new Set;for(let n of t)if(x(n))e.set(n.name,n.typeAnnotation||""),s.add(n.name);if(e.size===0)return{declarations:t,inlined:0};function o(n){let a=n;for(let[c,p]of e){let m=new RegExp(`\\b${c}\\b`,"g");a=a.replace(m,p)}return a}return{declarations:t.filter((n)=>n.kind!=="type"||!s.has(n.name)).map((n)=>{if(n.typeAnnotation)n={...n,typeAnnotation:o(n.typeAnnotation)};if(n.returnType)n={...n,returnType:o(n.returnType)};if(n.extends)n={...n,extends:o(n.extends)};return n}),inlined:e.size}}function R(t){let e=t.length,s=t.filter((o)=>!v(o));return{declarations:s,removed:e-s.length}}function or(t,e={}){let s=[...t],o={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(e.removeUnusedImports){let{declarations:i,removed:n}=S(s);s=i,o.removedImports=n}if(e.deduplicateDeclarations){let{declarations:i,removed:n}=k(s);s=i,o.removedDeclarations+=n}if(e.mergeInterfaces){let{declarations:i,merged:n}=z(s);s=i,o.mergedInterfaces=n}if(e.removeEmptyInterfaces){let{declarations:i,removed:n}=R(s);s=i,o.removedDeclarations+=n}if(e.inlineSimpleTypes){let{declarations:i,inlined:n}=w(s);s=i,o.inlinedTypes=n}if(e.sortImports)s=T(s);if(e.sortDeclarations)s=A(s);return{declarations:s,result:o}}async function Pi(t,e={}){if(!g(t))throw Error(`File not found: ${t}`);let s=h(t,"utf-8"),o=Buffer.byteLength(s,"utf-8"),i=r(s,t,!e.removeComments),{declarations:n,result:a}=or(i,e),c=C(n,e);if(e.minify)c=ar(c);let p=Buffer.byteLength(c,"utf-8");return a.originalSize=o,a.optimizedSize=p,a.savings=o-p,a.savingsPercent=Math.round(a.savings/o*100),b(t,c),a}function C(t,e){let s=[];for(let o of t){if(!e.removeComments&&o.leadingComments)for(let i of o.leadingComments)s.push(i);if(o.text)s.push(o.text);else s.push(E(o));s.push("")}return s.join(`
2
+ import{r}from"./chunk-q4fhsthj.js";import{existsSync as g,readFileSync as h,writeFileSync as b}from"fs";function d(t){let e=[],s=/\b([A-Z][a-zA-Z0-9]*)\b/g,o;while((o=s.exec(t))!==null){let i=o[1];if(!D(i))e.push(i)}return[...new Set(e)]}function D(t){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(t)}function x(t){if(t.kind!=="type")return!1;let e=t.typeAnnotation||"";if(t.generics)return!1;if(e.includes("{")||e.includes("(")||e.includes("<"))return!1;return/^[\w\s|&]+$/.test(e)}function v(t){if(t.kind!=="interface")return!1;if(!t.members||t.members.length===0){if(!t.extends)return!0}return!1}function I(t,e){let s={...t,members:[...t.members||[],...e.members||[]],leadingComments:[...t.leadingComments||[],...e.leadingComments||[]]};if(t.extends&&e.extends){let o=t.extends.split(",").map((n)=>n.trim()),i=e.extends.split(",").map((n)=>n.trim());s.extends=[...new Set([...o,...i])].join(", ")}else s.extends=t.extends||e.extends;return s}function A(t){let e={import:0,interface:1,type:2,class:3,enum:4,function:5,variable:6,export:7};return[...t].sort((s,o)=>{let i=e[s.kind]??99,n=e[o.kind]??99;if(i!==n)return i-n;return s.name.localeCompare(o.name)})}function T(t){let e=[],s=[];for(let i=0;i<t.length;i++){let n=t[i];if(n.kind==="import")e.push(n);else s.push(n)}return[...[...e].sort((i,n)=>{let a=i.source||"",c=n.source||"",p=a.startsWith("node:")||a==="bun",m=c.startsWith("node:")||c==="bun";if(p&&!m)return-1;if(!p&&m)return 1;let l=!a.startsWith("."),u=!c.startsWith(".");if(l&&!u)return-1;if(!l&&u)return 1;return a.localeCompare(c)}),...s]}function S(t){let e=new Set;for(let i of t){if(i.kind==="import")continue;let n=i.text||"",a=i.typeAnnotation||"",c=i.returnType||"",p=i.extends||"",m=i.implements?.join(" ")||"",l=`${n} ${a} ${c} ${p} ${m}`;for(let u of d(l))e.add(u);if(i.members)for(let u of i.members){let f=`${u.typeAnnotation||""} ${u.returnType||""}`;for(let y of d(f))e.add(y)}if(i.parameters){for(let u of i.parameters)if(u.type)for(let f of d(u.type))e.add(f)}}let s=0;return{declarations:t.map((i)=>{if(i.kind!=="import"||!i.specifiers)return i;let n=i.specifiers.filter((a)=>{let c=a.alias||a.name;return e.has(c)});if(n.length===0){if(!i.isSideEffect)return s++,null}if(n.length<(i.specifiers?.length||0))return s+=(i.specifiers?.length||0)-n.length,{...i,specifiers:n};return i}).filter((i)=>i!==null),removed:s}}function k(t){let e=new Map,s=0;for(let o of t){if(o.kind==="import"){let n=`import:${o.source}`;if(e.has(n)){let a=e.get(n),c=[...a.specifiers||[],...o.specifiers||[]],p=Array.from(new Map(c.map((m)=>[m.alias||m.name,m])).values());e.set(n,{...a,specifiers:p}),s++}else e.set(n,o);continue}let i=`${o.kind}:${o.name}`;if(e.has(i))s++;else e.set(i,o)}return{declarations:Array.from(e.values()),removed:s}}function z(t){let e=new Map,s=[];for(let n of t)if(n.kind==="interface"){let a=n.name;if(!e.has(a))e.set(a,[]);e.get(a).push(n)}else s.push(n);let o=0,i=[];for(let[n,a]of e)if(a.length>1){let c=a[0];for(let p=1;p<a.length;p++)c=I(c,a[p]),o++;i.push(c)}else i.push(a[0]);return{declarations:[...s,...i],merged:o}}function w(t){let e=new Map,s=new Set;for(let n of t)if(x(n))e.set(n.name,n.typeAnnotation||""),s.add(n.name);if(e.size===0)return{declarations:t,inlined:0};function o(n){let a=n;for(let[c,p]of e){let m=new RegExp(`\\b${c}\\b`,"g");a=a.replace(m,p)}return a}return{declarations:t.filter((n)=>n.kind!=="type"||!s.has(n.name)).map((n)=>{if(n.typeAnnotation)n={...n,typeAnnotation:o(n.typeAnnotation)};if(n.returnType)n={...n,returnType:o(n.returnType)};if(n.extends)n={...n,extends:o(n.extends)};return n}),inlined:e.size}}function R(t){let e=t.length,s=t.filter((o)=>!v(o));return{declarations:s,removed:e-s.length}}function or(t,e={}){let s=[...t],o={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(e.removeUnusedImports){let{declarations:i,removed:n}=S(s);s=i,o.removedImports=n}if(e.deduplicateDeclarations){let{declarations:i,removed:n}=k(s);s=i,o.removedDeclarations+=n}if(e.mergeInterfaces){let{declarations:i,merged:n}=z(s);s=i,o.mergedInterfaces=n}if(e.removeEmptyInterfaces){let{declarations:i,removed:n}=R(s);s=i,o.removedDeclarations+=n}if(e.inlineSimpleTypes){let{declarations:i,inlined:n}=w(s);s=i,o.inlinedTypes=n}if(e.sortImports)s=T(s);if(e.sortDeclarations)s=A(s);return{declarations:s,result:o}}async function Pi(t,e={}){if(!g(t))throw Error(`File not found: ${t}`);let s=h(t,"utf-8"),o=Buffer.byteLength(s,"utf-8"),i=r(s,t,!e.removeComments),{declarations:n,result:a}=or(i,e),c=C(n,e);if(e.minify)c=ar(c);let p=Buffer.byteLength(c,"utf-8");return a.originalSize=o,a.optimizedSize=p,a.savings=o-p,a.savingsPercent=Math.round(a.savings/o*100),b(t,c),a}function C(t,e){let s=[];for(let o of t){if(!e.removeComments&&o.leadingComments)for(let i of o.leadingComments)s.push(i);if(o.text)s.push(o.text);else s.push(E(o));s.push("")}return s.join(`
3
3
  `)}function E(t){let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"import":if(t.isTypeOnly)e.push("import type");else e.push("import");if(t.specifiers&&t.specifiers.length>0){let s=t.specifiers.map((o)=>{let i=o.isType?"type ":"";return o.alias?`${i}${o.name} as ${o.alias}`:`${i}${o.name}`}).join(", ");e.push(`{ ${s} }`)}e.push("from"),e.push(`'${t.source}'`);break;case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${B(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let s of t.members)e.push(` ${s.name}${s.typeAnnotation?`: ${s.typeAnnotation}`:""}`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements?.length)e.push(`implements ${t.implements.join(", ")}`);e.push("{ }");break;case"enum":e.push("declare enum"),e.push(t.name),e.push("{ }");break;default:return t.text||""}return e.join(" ")}function B(t){if(!t)return"";return t.map((e)=>{let s="";if(e.rest)s+="...";if(s+=e.name,e.optional)s+="?";if(e.type)s+=`: ${e.type}`;return s}).join(", ")}function ar(t){return t.replace(/(?<!\/\*\*)\/\/[^\n]*/g,"").replace(/^\s*[\r\n]/gm,"").replace(/ {2,}/g," ").replace(/\s*([{}[\]();,:])\s*/g,"$1").replace(/(\w)(\{)/g,"$1 $2").replace(/(\})([a-z])/gi,"$1 $2").replace(/(export|import|type|interface|class|function|const|let|var|extends|implements|declare)\s*/g,"$1 ").trim()}
4
4
  export{or,Pi,ar};
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{f,ue}from"./chunk-a3apthex.js";import{Ft,Nt,n,Me,_}from"./chunk-qq5x44y9.js";function g(t){if(t.includes(`
2
+ import{f,ue}from"./chunk-a3apthex.js";import{Ft,Nt,n,Me,j}from"./chunk-3qx4ys4v.js";function g(t){if(t.includes(`
3
3
  `))return`/**
4
4
  * ${t}
5
5
  */
6
6
  `;return`/** ${t} */
7
- `}function D(t){let o=t.indexOf("{");if(o===-1)return-1;let s=t.indexOf("<");if(s===-1||s>o)return o;let e=0,r=!1,a="";for(let i=0;i<t.length;i++){let l=t[i],u=i>0?t[i-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,a=l;else if(r&&l===a&&u!=="\\")r=!1;if(!r){if(l==="<")e++;else if(l===">")e--;else if(l==="{"&&e===0)return i}}return-1}function ne(t,o=!0){return f(t.leadingComments,o)+t.text}function h(t,o=!0){if(t.inferenceError)throw Object.assign(Error(`Cannot infer alias '${t.name}': unsupported source value flow`),{code:t.inferenceError});let s=f(t.leadingComments,o);if(!t.typeAnnotation&&t.inferredType)return s+t.text;if(t.typeAnnotation&&!t.value)return s+t.text;let e="";if(t.isExported)e+="export ";e+="declare ";let r=t.modifiers?.[0]||"const";e+=`${r} `,e+=t.name;let{typeAnnotation:a,value:i}=t,l=!a&&i?_(i):null;if(l)a=l;else if(!a&&i&&i.trim().endsWith("as const"))a=n(i,!0,!1,0,t.computedKeyConstants);else if(!a&&i&&r==="const"){let c=i.trim(),m=c.startsWith("{")||c.startsWith("[");if(m)Ft();a=n(i,!m,!1,0,t.computedKeyConstants)}else if(!a&&i)a=n(i,r==="const",!1,0,t.computedKeyConstants);if(!a)a="unknown";let u="";if(o&&i&&!t.typeAnnotation&&!i.trim().endsWith("as const")){let c=i.trim();if(r!=="const"){if((a==="string"||a==="number"||a==="boolean")&&c.length>0)u=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let m=Nt();if(m)if(m.includes(`
7
+ `}function D(t){let o=t.indexOf("{");if(o===-1)return-1;let s=t.indexOf("<");if(s===-1||s>o)return o;let e=0,r=!1,a="";for(let i=0;i<t.length;i++){let l=t[i],u=i>0?t[i-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,a=l;else if(r&&l===a&&u!=="\\")r=!1;if(!r){if(l==="<")e++;else if(l===">")e--;else if(l==="{"&&e===0)return i}}return-1}function re(t,o=!0){return f(t.leadingComments,o)+t.text}function h(t,o=!0){if(t.inferenceError)throw Object.assign(Error(`Cannot infer alias '${t.name}': unsupported source value flow`),{code:t.inferenceError});let s=f(t.leadingComments,o);if(!t.typeAnnotation&&t.inferredType)return s+t.text;if(t.typeAnnotation&&!t.value)return s+t.text;let e="";if(t.isExported)e+="export ";e+="declare ";let r=t.modifiers?.[0]||"const";e+=`${r} `,e+=t.name;let{typeAnnotation:a,value:i}=t,l=!a&&i?j(i):null;if(l)a=l;else if(!a&&i&&i.trim().endsWith("as const"))a=n(i,!0,!1,0,t.computedKeyConstants);else if(!a&&i&&r==="const"){let c=i.trim(),m=c.startsWith("{")||c.startsWith("[");if(m)Ft();a=n(i,!m,!1,0,t.computedKeyConstants)}else if(!a&&i)a=n(i,r==="const",!1,0,t.computedKeyConstants);if(!a)a="unknown";let u="";if(o&&i&&!t.typeAnnotation&&!i.trim().endsWith("as const")){let c=i.trim();if(r!=="const"){if((a==="string"||a==="number"||a==="boolean")&&c.length>0)u=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let m=Nt();if(m)if(m.includes(`
8
8
  `))u=`@defaultValue
9
9
  * \`\`\`ts
10
10
  ${m.split(`
@@ -25,5 +25,5 @@ ${x.split(`
25
25
  * ${c.replace(/^\/\/\s*/,"")}
26
26
  * ${u}
27
27
  */
28
- ${e}`}if(u)return`${g(u)}${e}`;return s+e}function re(t,o=!0){let s=f(t.leadingComments,o),e=t.text;if(e.startsWith("export declare interface")||e.startsWith("declare interface"))return s+e;let r="";if(t.isExported)r+="export ";if(r+="declare interface ",r+=t.name,t.generics)r+=t.generics;if(t.extends)r+=` extends ${t.extends}`;let a=D(t.text);if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}function ie(t,o=!0){let s=f(t.leadingComments,o);if(t.text.includes("{")&&t.text.includes("}")&&t.text.includes("from"))return s+t.text;let e="";if(t.isExported)e+="export ";if(!t.isExported&&!t.text.includes(" from "))e+="declare ";let r=t.text.indexOf("type ");if(r!==-1){let i=t.text.slice(r),l=i.length;while(l>0&&(i.charCodeAt(l-1)===59||i.charCodeAt(l-1)===32||i.charCodeAt(l-1)===10||i.charCodeAt(l-1)===13))l--;if(l<i.length)i=i.slice(0,l);e+=i}else{if(e+=`type ${t.name}`,t.generics)e+=t.generics;e+=" = any"}let a=e.trimEnd();if(!a.endsWith(";")&&!a.endsWith("}"))e+=";";return s+e}function se(t,o=!0){return f(t.leadingComments,o)+t.text}function oe(t,o=!0){let s=f(t.leadingComments,o),e="";if(t.isExported)e+="export ";if(e+="declare ",t.modifiers?.includes("const"))e+="const ";e+="enum ",e+=t.name;let r=t.text.indexOf("{");if(r!==-1)e+=` ${t.text.slice(r)}`;else e+=" {}";return s+e}function Wn(t){let o=t.text.trim(),s=o.length;while(s>0&&o.charCodeAt(s-1)===59)s--;if(s<o.length)o=o.slice(0,s);return o+=";",o}function jn(t,o=!0){return f(t.leadingComments,o)+t.text.trim()}function ae(t,o=!0){let s=f(t.leadingComments,o);if(t.text.startsWith("declare global"))return s+t.text;if(t.source||(t.name.startsWith('"')||t.name.startsWith("'")||t.name.startsWith("`"))){let i="declare module ";i+=t.name;let l=t.text.indexOf("{");if(l!==-1)i+=` ${t.text.slice(l)}`;else i+=" {}";return s+i}let r="";if(t.isExported)r+="export ";if(!t.modifiers?.includes("declare"))r+="declare ";r+="namespace ",r+=t.name;let a=t.text.indexOf("{");if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}
29
- export{ne,h,re,ie,se,oe,Wn,jn,ae};
28
+ ${e}`}if(u)return`${g(u)}${e}`;return s+e}function ie(t,o=!0){let s=f(t.leadingComments,o),e=t.text;if(e.startsWith("export declare interface")||e.startsWith("declare interface"))return s+e;let r="";if(t.isExported)r+="export ";if(r+="declare interface ",r+=t.name,t.generics)r+=t.generics;if(t.extends)r+=` extends ${t.extends}`;let a=D(t.text);if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}function se(t,o=!0){let s=f(t.leadingComments,o);if(t.text.includes("{")&&t.text.includes("}")&&t.text.includes("from"))return s+t.text;let e="";if(t.isExported)e+="export ";if(!t.isExported&&!t.text.includes(" from "))e+="declare ";let r=t.text.indexOf("type ");if(r!==-1){let i=t.text.slice(r),l=i.length;while(l>0&&(i.charCodeAt(l-1)===59||i.charCodeAt(l-1)===32||i.charCodeAt(l-1)===10||i.charCodeAt(l-1)===13))l--;if(l<i.length)i=i.slice(0,l);e+=i}else{if(e+=`type ${t.name}`,t.generics)e+=t.generics;e+=" = any"}let a=e.trimEnd();if(!a.endsWith(";")&&!a.endsWith("}"))e+=";";return s+e}function oe(t,o=!0){return f(t.leadingComments,o)+t.text}function ae(t,o=!0){let s=f(t.leadingComments,o),e="";if(t.isExported)e+="export ";if(e+="declare ",t.modifiers?.includes("const"))e+="const ";e+="enum ",e+=t.name;let r=t.text.indexOf("{");if(r!==-1)e+=` ${t.text.slice(r)}`;else e+=" {}";return s+e}function Wn(t){let o=t.text.trim(),s=o.length;while(s>0&&o.charCodeAt(s-1)===59)s--;if(s<o.length)o=o.slice(0,s);return o+=";",o}function _n(t,o=!0){return f(t.leadingComments,o)+t.text.trim()}function ce(t,o=!0){let s=f(t.leadingComments,o);if(t.text.startsWith("declare global"))return s+t.text;if(t.source||(t.name.startsWith('"')||t.name.startsWith("'")||t.name.startsWith("`"))){let i="declare module ";i+=t.name;let l=t.text.indexOf("{");if(l!==-1)i+=` ${t.text.slice(l)}`;else i+=" {}";return s+i}let r="";if(t.isExported)r+="export ";if(!t.modifiers?.includes("declare"))r+="declare ";r+="namespace ",r+=t.name;let a=t.text.indexOf("{");if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}
29
+ export{re,h,ie,se,oe,ae,Wn,_n,ce};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  import{watch as z}from"fs";import{readdir as O,stat as U}from"fs/promises";import{join as S,relative as E}from"path";function Ti(e,i){let{root:s,include:u=["**/*.ts","**/*.tsx","**/*.vue","**/*.stx"],exclude:v=["**/node_modules/**","**/*.d.ts","**/dist/**"],debounce:f=100,initialBuild:a=!0,clearScreen:D=!1,onChange:T,onBuildStart:w,onBuildComplete:B,onError:W}=e,P=[],g=new Set,h=!1,d=new Map,c=null,y=!1;function A(o){let r=E(s,o);for(let n of v)if(p(r,n))return!1;for(let n of u)if(p(r,n))return!0;return!1}function p(o,r){let n=r.replace(/\./g,"\\.").replace(/\*\*/g,"{{DOUBLESTAR}}").replace(/\*/g,"[^/]*").replace(/\{\{DOUBLESTAR\}\}/g,".*").replace(/\?/g,".");return new RegExp(`^${n}$`).test(o.replace(/\\/g,"/"))}async function F(){if(y||d.size===0)return;y=!0;let o=Array.from(d.values());d.clear();try{for(let t of o)await T?.(t);if(D)console.clear();await w?.();let r=o.filter((t)=>t.type!=="unlink").map((t)=>t.path),n=await i(r.length>0?r:void 0);await B?.(n)}catch(r){await W?.(r)}finally{if(y=!1,d.size>0)C()}}function C(){if(c)clearTimeout(c);c=setTimeout(()=>{c=null,F()},f)}function k(o,r,n){if(!r||!h)return;let t=S(n,r);if(!A(t))return;let l={type:o==="rename"?"add":"change",path:t,relativePath:E(s,t)};U(t).then(()=>{g.add(t)}).catch(()=>{l.type="unlink",g.delete(t)}).finally(()=>{d.set(t,l),C()})}async function b(o){let r=[o];try{let n=await O(o,{withFileTypes:!0});for(let t of n)if(t.isDirectory()){let l=S(o,t.name),x=E(s,l),R=!1;for(let m of v)if(p(x,m)||p(`${x}/`,m)){R=!0;break}if(!R){let m=await b(l);r.push(...m)}}}catch{}return r}async function G(){if(h)return;h=!0;let o=await b(s);for(let r of o)try{let n=z(r,{persistent:!0},(t,l)=>{k(t,l,r)});n.on("error",(t)=>{W?.(t)}),P.push(n)}catch(n){await W?.(n)}if(a){await w?.();let r=await i();await B?.(r)}}function L(){if(h=!1,c)clearTimeout(c),c=null;for(let o of P)o.close();P.length=0,g.clear(),d.clear()}async function j(){await w?.();let o=await i();return await B?.(o),o}return{start:G,stop:L,rebuild:j,isWatching:()=>h,getWatchedFiles:()=>Array.from(g)}}async function ba(e,i){let s=async(v)=>{let f=Date.now();try{let a=await i(e);return{success:a.errors.length===0,duration:Date.now()-f,filesProcessed:a.filesProcessed,errors:a.errors}}catch(a){return{success:!1,duration:Date.now()-f,filesProcessed:0,errors:[a.message]}}},u=Ti({root:e.root||e.cwd||process.cwd(),include:e.include,exclude:e.exclude,debounce:e.debounce,initialBuild:e.initialBuild,clearScreen:e.clearScreen,onChange:e.onChange,onBuildStart:e.onBuildStart,onBuildComplete:e.onBuildComplete,onError:e.onError},s);return await u.start(),u}function Ai(e){let i=e.success?"\u2713":"\u2717",s=`${e.duration}ms`;if(e.success)return`${i} Built ${e.filesProcessed} file(s) in ${s}`;else return`${i} Build failed in ${s}
3
3
  ${e.errors.map((u)=>` - ${u}`).join(`
4
- `)}`}function wa(){return{onChange:(e)=>{let i=e.type==="add"?"+":e.type==="unlink"?"-":"~";console.log(`[${i}] ${e.relativePath}`)},onBuildStart:()=>{console.log(`
4
+ `)}`}function xa(){return{onChange:(e)=>{let i=e.type==="add"?"+":e.type==="unlink"?"-":"~";console.log(`[${i}] ${e.relativePath}`)},onBuildStart:()=>{console.log(`
5
5
  Rebuilding...`)},onBuildComplete:(e)=>{console.log(Ai(e))},onError:(e)=>{console.error(`Error: ${e.message}`)}}}
6
- export{Ti,ba,Ai,wa};
6
+ export{Ti,ba,Ai,xa};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var ui=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],fi=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],di=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],pi=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function mi(e){switch(e){case"strict":return fi;case"readonly":return di;case"simplified":return pi;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class Sn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...ui);if(e.presets)for(let r of e.presets)this.rules.push(...mi(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function J(e={rules:[]}){return new Sn(e)}var ko=J({rules:[]}),To=J({rules:[],presets:["strict"]});function $t(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var Ao={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
3
- export{ui,fi,di,pi,mi,Sn,J,ko,To,$t,Ao};
2
+ var ui=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],fi=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],di=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],pi=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function mi(e){switch(e){case"strict":return fi;case"readonly":return di;case"simplified":return pi;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class Sn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...ui);if(e.presets)for(let r of e.presets)this.rules.push(...mi(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function Y(e={rules:[]}){return new Sn(e)}var ko=Y({rules:[]}),To=Y({rules:[],presets:["strict"]});function $t(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var Ao={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
3
+ export{ui,fi,di,pi,mi,Sn,Y,ko,To,$t,Ao};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{r}from"./chunk-z6mpxpxt.js";import{e}from"./chunk-btc6zbyj.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 Zt(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{r}from"./chunk-q4fhsthj.js";import{e}from"./chunk-btc6zbyj.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 Zt(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(`
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=Zt(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 Qt(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 _e(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 en(t,n={}){let s=_e(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 s=Zt(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 Qt(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 en(t,n={}){let s=je(t,n);return`<!DOCTYPE html>
6
6
  <html lang="en">
7
7
  <head>
8
8
  <meta charset="UTF-8">
@@ -97,6 +97,6 @@ import{r}from"./chunk-z6mpxpxt.js";import{e}from"./chunk-btc6zbyj.js";import{exi
97
97
  document.getElementById('content').innerHTML = marked.parse(markdown);
98
98
  </script>
99
99
  </body>
100
- </html>`}function tn(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 Dr(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 Rs(t,n){e.info("Extracting documentation...");let s=await Qt(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=_e(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=_e(s,n),i=g(n.outdir,"API.md");f(i,o),e.info(`Generated: ${i}`)}else if(n.format==="json"){let o=tn(s,n),i=g(n.outdir,"api.json");f(i,o),e.info(`Generated: ${i}`);let a=Dr(s),c=g(n.outdir,"typedoc.json");f(c,a),e.info(`Generated: ${c}`)}else{let o=en(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 Ms(t={}){return{extract:(n)=>Qt(n,t),generateMarkdown:(n)=>_e(n,t),generateHTML:(n)=>en(n,t),generateJSON:(n)=>tn(n,t),parseJSDoc:Zt}}
102
- export{Zt,Qt,_e,en,tn,Dr,Rs,Ms};
100
+ </html>`}function tn(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 Dr(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 Rs(t,n){e.info("Extracting documentation...");let s=await Qt(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=tn(s,n),i=g(n.outdir,"api.json");f(i,o),e.info(`Generated: ${i}`);let a=Dr(s),c=g(n.outdir,"typedoc.json");f(c,a),e.info(`Generated: ${c}`)}else{let o=en(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 Ms(t={}){return{extract:(n)=>Qt(n,t),generateMarkdown:(n)=>je(n,t),generateHTML:(n)=>en(n,t),generateJSON:(n)=>tn(n,t),parseJSDoc:Zt}}
102
+ export{Zt,Qt,je,en,tn,Dr,Rs,Ms};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{s}from"./chunk-yde8rmfm.js";function pe(d={}){let{onBuildStart:u=!1,onBuildEnd:f=!0,onGenerated:l,onError:i,...c}=d,o,r,e=async()=>{let t={...c};if(!t.outdir&&o)t.outdir=o;if(!t.entrypoints&&r)t.entrypoints=r;try{let n=await s(t);l?.(n)}catch(n){let a=n instanceof Error?n:Error(String(n));if(i?.(a),!i)console.error("[dtsx] Generation failed:",a.message)}};return{name:"dtsx",esbuildOptions(t){if(t.outdir&&typeof t.outdir==="string")o=t.outdir;if(t.entryPoints){if(Array.isArray(t.entryPoints))r=t.entryPoints;else if(typeof t.entryPoints==="object")r=Object.values(t.entryPoints)}},async buildStart(){if(u)await e()},async buildEnd(t){if(f)await e()}}}var Ea=pe,rr=pe,ka=pe;
2
+ import{s}from"./chunk-msr5zymd.js";function pe(d={}){let{onBuildStart:u=!1,onBuildEnd:f=!0,onGenerated:l,onError:i,...c}=d,o,r,e=async()=>{let t={...c};if(!t.outdir&&o)t.outdir=o;if(!t.entrypoints&&r)t.entrypoints=r;try{let n=await s(t);l?.(n)}catch(n){let a=n instanceof Error?n:Error(String(n));if(i?.(a),!i)console.error("[dtsx] Generation failed:",a.message)}};return{name:"dtsx",esbuildOptions(t){if(t.outdir&&typeof t.outdir==="string")o=t.outdir;if(t.entryPoints){if(Array.isArray(t.entryPoints))r=t.entryPoints;else if(typeof t.entryPoints==="object")r=Object.values(t.entryPoints)}},async buildStart(){if(u)await e()},async buildEnd(t){if(f)await e()}}}var Ea=pe,rr=pe,ka=pe;
3
3
  export{pe,Ea,rr,ka};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- var e="@dtsx/dtsx",i="module",n="0.11.40",r=!0,c="A modern, fast .d.ts generation tool, powered by Bun.",u="Chris Breuer <chris@stacksjs.org>",a="MIT",b="https://github.com/stacksjs/dtsx#readme",o={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},p={url:"https://github.com/stacksjs/dtsx/issues"},d=["dts","generation","isolated declarations","development","bun","stacks","typescript","javascript"],m={".":{import:"./dist/index.js"},"./*":{import:"./dist/*"}},k="./dist/index.js",l="./dist/index.d.ts",x={dtsx:"./dist/cli.js"},g=["dist"],h={benchmark:"bun benchmark/index.ts","benchmark:prepare":"cd packages/zig-dtsx && zig build -Doptimize=ReleaseFast && cd ../.. && bun build benchmark/oxc-emit.ts --compile --splitting --bytecode --minify --format=esm --outfile benchmark/oxc-emit","benchmark:publish":"bun benchmark/index.ts --json benchmark/results.json --runs 3 && bun benchmark/render.ts","benchmark:tsdown":"bun benchmark/tsdown.ts",build:"bun --filter './packages/dtsx' build",test:"find packages -name '*.test.ts' -print | xargs bun test","test:public-sdk":"bun scripts/verify-public-sdk.ts","test:standalone":"bun scripts/verify-standalone.ts","typecheck:public-sdk":"bun x tsc --project tsconfig.public-sdk.json",lint:"bun x --bun pickier .","lint:fix":"bun x --bun pickier . --fix",format:"bun x --bun pickier . --format","format:fix":"bun x --bun pickier . --format --write",changelog:"bun x @stacksjs/logsmith --verbose","changelog:generate":"bun x @stacksjs/logsmith --output CHANGELOG.md",release:"bun x --bun @stacksjs/bumpx prompt --recursive","release:patch":"bun x --bun @stacksjs/bumpx patch --recursive --commit --tag --push --yes","release:minor":"bun x --bun @stacksjs/bumpx minor --recursive --commit --tag --push --yes",typecheck:"bun x tsc --noEmit","dev:docs":"bun --bun bunpress dev docs","build:docs":"bun --bun bunpress build docs","preview:docs":"bun --bun bunpress preview docs"},j={"@stacksjs/bumpx":"^0.2.32","@stacksjs/bunpress":"^0.2.31","@stacksjs/clapp":"^0.2.16",pickier:"^0.1.88","@stacksjs/gitlint":"^0.1.8","@stacksjs/logsmith":"^0.2.14","@types/bun":"^1.4.4","buddy-bot":"^0.10.5","bun-git-hooks":"^0.3.3","@dtsx/bun":"workspace:*",mitata:"^1.0.34","oxc-transform":"^0.157.0","oxc-parser":"^0.157.0",tsdown:"^0.23.7",typescript:"^7.0.2"},y=["packages/*"],f={typescript:"^7.0.2"},v={name:e,type:i,version:n,private:r,description:c,author:u,license:a,homepage:b,repository:o,bugs:p,keywords:d,exports:m,module:k,types:l,bin:x,files:g,scripts:h,devDependencies:j,workspaces:y,overrides:f,"git-hooks":{"pre-commit":{"staged-lint":{"*.{js,ts,json,yaml,yml,md}":"bun x --bun pickier lint --fix"}},"commit-msg":"bun x gitlint --edit .git/COMMIT_EDITMSG"}};export{u as author,x as bin,p as bugs,v as default,c as description,j as devDependencies,m as exports,g as files,b as homepage,d as keywords,a as license,k as module,e as name,f as overrides,r as private,o as repository,h as scripts,i as type,l as types,n as version,y as workspaces};
2
+ var e="@dtsx/dtsx",i="module",n="0.11.42",r=!0,c="A modern, fast .d.ts generation tool, powered by Bun.",u="Chris Breuer <chris@stacksjs.org>",a="MIT",b="https://github.com/stacksjs/dtsx#readme",o={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},p={url:"https://github.com/stacksjs/dtsx/issues"},d=["dts","generation","isolated declarations","development","bun","stacks","typescript","javascript"],m={".":{import:"./dist/index.js"},"./*":{import:"./dist/*"}},k="./dist/index.js",l="./dist/index.d.ts",x={dtsx:"./dist/cli.js"},g=["dist"],h={benchmark:"bun benchmark/index.ts","benchmark:prepare":"cd packages/zig-dtsx && zig build -Doptimize=ReleaseFast && cd ../.. && bun build benchmark/oxc-emit.ts --compile --splitting --bytecode --minify --format=esm --outfile benchmark/oxc-emit","benchmark:publish":"bun benchmark/index.ts --json benchmark/results.json --runs 3 && bun benchmark/render.ts","benchmark:tsdown":"bun benchmark/tsdown.ts",build:"bun --filter './packages/dtsx' build",test:"find packages -name '*.test.ts' -print | xargs bun test","test:public-sdk":"bun scripts/verify-public-sdk.ts","test:standalone":"bun scripts/verify-standalone.ts","typecheck:public-sdk":"bun x tsc --project tsconfig.public-sdk.json",lint:"bun x --bun pickier .","lint:fix":"bun x --bun pickier . --fix",format:"bun x --bun pickier . --format","format:fix":"bun x --bun pickier . --format --write",changelog:"bun x @stacksjs/logsmith --verbose","changelog:generate":"bun x @stacksjs/logsmith --output CHANGELOG.md",release:"bun x --bun @stacksjs/bumpx prompt --recursive","release:patch":"bun x --bun @stacksjs/bumpx patch --recursive --commit --tag --push --yes","release:minor":"bun x --bun @stacksjs/bumpx minor --recursive --commit --tag --push --yes",typecheck:"bun x tsc --noEmit","dev:docs":"bun --bun bunpress dev docs","build:docs":"bun --bun bunpress build docs","preview:docs":"bun --bun bunpress preview docs"},j={"@stacksjs/bumpx":"^0.2.32","@stacksjs/bunpress":"^0.2.31","@stacksjs/clapp":"^0.2.16",pickier:"^0.1.88","@stacksjs/gitlint":"^0.1.8","@stacksjs/logsmith":"^0.2.14","@types/bun":"^1.4.4","buddy-bot":"^0.10.5","bun-git-hooks":"^0.3.3","@dtsx/bun":"workspace:*",mitata:"^1.0.34","oxc-transform":"^0.157.0","oxc-parser":"^0.157.0",tsdown:"^0.23.7",typescript:"^7.0.2"},y=["packages/*"],f={typescript:"^7.0.2"},v={name:e,type:i,version:n,private:r,description:c,author:u,license:a,homepage:b,repository:o,bugs:p,keywords:d,exports:m,module:k,types:l,bin:x,files:g,scripts:h,devDependencies:j,workspaces:y,overrides:f,"git-hooks":{"pre-commit":{"staged-lint":{"*.{js,ts,json,yaml,yml,md}":"bun x --bun pickier lint --fix"}},"commit-msg":"bun x gitlint --edit .git/COMMIT_EDITMSG"}};export{u as author,x as bin,p as bugs,v as default,c as description,j as devDependencies,m as exports,g as files,b as homepage,d as keywords,a as license,k as module,e as name,f as overrides,r as private,o as repository,h as scripts,i as type,l as types,n as version,y as workspaces};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{c,i}from"./chunk-8kj9pkw5.js";import{t,F}from"./chunk-c7a07a26.js";import{rt,Lt}from"./chunk-7j4cgkb4.js";import{y}from"./chunk-jfygtm4r.js";import{n}from"./chunk-qq5x44y9.js";function q(g,w){let C=(D)=>t(D).map((b)=>D.slice(b.start,b.end)).join("");return C(g)===C(w)}function de(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let w=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(w)?w:void 0}function oe(g,w){if(q(g,w))return g;let C=de(w);if(!C)return;let D=t(g),b=0,v=0,B=[];for(let S of D){let k=g.slice(S.start,S.end);if(k==="("||k==="["||k==="{"||k==="<")b++;else if(k===")"||k==="]"||k==="}"||k===">")b--;else if(k==="|"&&b===0)B.push(g.slice(v,S.start).trim()),v=S.end}B.push(g.slice(v).trim());let O=B.find((S)=>q(S,w));if(O)return O;if(B.includes(C))return C==="boolean"&&(w==="true"||w==="false")?w:C;return}function _n(g,w,C,D=new Set){let b=new Map,v=[],B=new Set;for(let e of[...w,...C.values()]){if(B.has(e))continue;if(B.add(e),v.push(e),e.kind==="import")for(let o of y(e.text))b.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))b.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")b.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}v.sort((e,o)=>(e.start??0)-(o.start??0));let O=new Set(v.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of D)O.add(e);let S=new Map,k=(e)=>{if(e=e.trimStart(),S.has(e))return S.get(e);if(S.set(e,void 0),!c(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!O.has(e.slice(0,o)))return;let r=t(e);if(r[0]?.kind!=="word"||!r[1]||e.slice(r[1].start,r[1].end)!=="(")return;let d=1;for(let s=2;s<r.length;s++){let a=e.slice(r[s].start,r[s].end);if(a==="(")d++;else if(a===")"&&--d===0){let l=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return S.set(e,l),l}}return},E=new Set(v.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>k(e.value)).filter((e)=>e!==void 0)).size?F(g):void 0,x=new Map;if(E){let e=0;for(let o=0;o<E.length;o++){let r=g.slice(E[o].start,E[o].end);if(e===0&&r==="function"){let d=E[o+1],s=d&&g.slice(d.start,d.end)==="*"?E[o+2]:d;if(s?.kind==="word"){let a=g.slice(s.start,s.end);x.set(a,(x.get(a)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let R=new Map;for(let e of v)if(e.kind==="function"&&!e.generics&&x.get(e.name)===1)R.set(e.name,e);for(let e of D){let o=v.find((r)=>r.kind==="import"&&y(r.text).includes(e));if(o)R.set(e,o)}let W="__dtsx_call_result";while(g.includes(W))W+="_";let K=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${W} ? ${W} : never`,X=new Map,H=!1;for(let e of v){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=k(e.value);if(o&&R.has(o))X.set(e,K(o)),b.get(e.name).active=!0,b.get(o).active=!0,H=!0;if(e.modifiers?.[0]!=="const")continue;let r=rt(e.value);if(!r||r===e.name||!b.has(r))continue;b.get(r).active=!0,b.get(e.name).active=!0,H=!0}if(!H)return;let u=E??F(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",m=new Map,_=new Map,G=new Set,L=new Set,J=new Set,Q=new Map,I=[];for(let e=0;e<u.length;e++){let o=f(e),r=I.at(-1);if(r!==void 0)_.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))G.add(e);if(["(","[","{"].includes(o))I.push(e);else if([")","]","}"].includes(o)){let d=I.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))I.pop(),m.set(d,e)}}let Y=new Map;for(let e=0;e<u.length;){if(u[e].kind!=="punctuation"){e++;continue}let r=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>g.startsWith(s,u[e].start))??f(e);Y.set(e,r);let d=u[e].start+r.length;do e++;while(e<u.length&&u[e].start<d)}for(let e=0;e<u.length;e++){let o=ne(e);if(o!==void 0)L.add(o)}for(let e of L)le(e);let h=0;function Z(e){let o=rt(e);if(o){let a=b.get(o);return{type:a?.flow,unresolved:a?.unresolved??!1}}let r=k(e),d=r?R.get(r):void 0;if(d)return{type:d.returnType&&de(d.returnType)?d.returnType:K(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function T(e){return Y.get(e)??""}function N(e){if(u[e]?.kind!=="word"||J.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=b.get(f(e));if(!o?.active)return;let r=T(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(r))return{binding:o,operator:r};if(["++","--"].includes(r)&&!/[\r\n]/.test(g.slice(u[e].end,u[e+1].start)))return{binding:o,operator:r};if(e>=2&&["++","--"].includes(T(e-2))){let d=u[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(f(e-3)));if(!d||!s||/[\r\n;]/.test(g.slice(d.end,u[e-2].start)))return{binding:o,operator:T(e-2)}}return}function ee(e){let o=N(e);return o?.operator==="="?o.binding:void 0}function ne(e){if(u[e]?.kind!=="word"||f(e)!=="class"||f(e-1)==="."||["(",":","="].includes(f(e+1)))return;let o=e+1,r=0;while(o<u.length){let d=f(o);if(d==="{"&&r===0)return o;if(d==="class"){let s=ne(o);if(s!==void 0){o=(m.get(s)??s)+1;continue}}if(d==="function"){let s=se(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&T(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(m.get(o)??o)+1}return}function te(e,o,r){let d=e,s=!1,a=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(a.includes(f(d))&&!["(","<","?","!",":","=",";","}"].includes(f(d+1))){if(f(d)==="static")s=!0;d++}if(f(d)==="*")d++;if(r&&f(d)==="#")d++;if(f(d)==="["){let p=m.get(d);return p===void 0?void 0:{next:p+1,isStatic:s}}if(u[d]?.kind==="word"||u[d]?.kind==="quoted")return{next:d+1,isStatic:s};let l=d+1;while(l<o&&u[l-1].end===u[l].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(l)))l++;if(d<o&&n(g.slice(u[d].start,u[l-1].end),!1)==="number")return{next:l,isStatic:s};return}function P(e,o,r){let d=te(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let a=1;s++;while(s<o&&a>0){if(f(s)==="<")a++;else if(f(s)===">"&&T(s-1)!=="=>")a--;s=(m.get(s)??s)+1}if(a!==0)return}return s}function ie(e,o,r){return P(e,o,r)===o}function fe(e,o){let r=0,d=-1;for(let s=e;s<o;s=(m.get(s)??s)+1)if(f(s)==="<"&&(r>0||s>e&&(u[s-1].kind==="word"||[")","]"].includes(f(s-1))))){if(r===0)d=s;r++}else if(f(s)===">"&&T(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function ae(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=P(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function U(e,o,r=!1){let d=m.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&T(s)==="=")return s;if(s>e&&_.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let a=f(s-1),p=!(a===">"&&fe(e,s)&&ae(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(a),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!M)return s}s=(m.get(s)??s)+1}return d}function V(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&m.has(r)){r=m.get(r);continue}if(u[r].kind==="word")J.add(r)}}function le(e){let o=m.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(m.get(r+1)??r+1)+1;continue}let d=te(r,o,!0);if(!d){r++;continue}let s=P(r,o,!0);if(s===void 0){r++;continue}if(V(r,s),f(s)==="("){let l=m.get(s),p=l===void 0?void 0:re(l,o);if(p!==void 0){r=(m.get(p)??p)+1;continue}}let a=s;if(f(a)===":")a=U(a+1,e,!0);if(T(a)==="="){V(r,a+1);let l=a+1,p=U(l,e);if(!d.isStatic&&p>l)Q.set(l,p);r=p}else{let l=U(s,e);V(r,l),r=Math.max(r+1,l)}}}function ce(e){let o=_.get(e);if(o===void 0)return!1;let r=L.has(o);if(!r&&!G.has(o))return!1;if(ie(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=_.get(d),a=_.get(d)===o&&(f(d)===","||r&&f(d)===";"),l=r&&f(d)==="}"&&s!==void 0&&_.get(s)===o,p=r&&_.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((a||l||p)&&ie(d+1,e,r))return!0}return!1}function re(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Lt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(m.get(r)??r)+1}return}function se(e,o){let r=-1;if(f(e)==="("){let s=m.get(e);if(s!==void 0&&ce(e))r=re(s,o)??-1;else if(s!==void 0&&T(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let a=s+2;while(a<o&&f(a)!==";"){if(T(a)==="=>"){r=a+2;break}a=(m.get(a)??a)+1}}}else if(u[e]?.kind==="word"&&T(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(m.get(s)??s)+1;let a=m.get(s);if(a===void 0)return;r=a+1;let l=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(l===void 0||!Lt(g.slice(u[l].start,u[r].start))))break;r=(m.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(m.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(m.get(d)??d)+1;return{start:e,end:d}}function j(e,o,r=!0){for(let d=e;d<o;d++){let s=Q.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let a=r?se(d,o):void 0;if(a){let p=a.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")j(a.start,a.end,!1);d=a.end-1;continue}let l=N(d);if(l)l.binding.flow=void 0,l.binding.unresolved=!0}}function ue(e){let o=!1;while(h<u.length&&u[h].start<e){let r=f(h);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let l=m.get(h)??h+1;while(l<u.length&&u[l].start>=e)l--;if(j(h+1,l),h=l+1,r==="{")o=!1;continue}let d=ee(h);if(d){let a=h+2,l=a,p=[];while(l<u.length&&u[l].start<e){let A=f(l);if(p.length===0&&(A===";"||l>a&&/[\r\n]/.test(g.slice(u[l-1].end,u[l].start))&&(ee(l)||["if","for","while","switch","try","do","return","throw"].includes(A))))break;if(A==="("||A==="{"||A==="[")p.push(A==="("?")":A==="{"?"}":"]");else if(A===p.at(-1))p.pop();l++}let M=l>a?g.slice(u[a].start,u[l-1].end):"";j(a,l);let z=Z(M);d.flow=!o&&z.type?d.declared?oe(d.declared,z.type):z.type:void 0,d.unresolved=o||z.unresolved||!d.flow,h=l;continue}let s=N(h);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;h++}}for(let e of v){ue(e.start??0);let o=h;while(h<u.length&&u[h].start<(e.end??0))h++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<h&&u[M].start<e.initializerStart)M++;j(M,h)}let r=b.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=Z(d),a=rt(d),l=a?b.get(a):void 0,p=X.get(e);if(p)e.inferredType=p,e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${p};`;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&a&&a!==e.name&&l){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=l.declared&&q(l.declared,s.type)?`typeof ${a}`:s.type,e.text=`${e.isExported?"export ":""}declare const ${e.name}: ${e.inferredType};`}if(e.typeAnnotation)r.flow=s.type?oe(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)r.declared=e.inferredType,r.flow=e.inferredType;else{let M=e.modifiers?.[0]==="const",z=d.trim().startsWith("{")||d.trim().startsWith("["),A=n(d,M&&!z);r.declared=A==="unknown"?void 0:A,r.flow=r.declared}r.unresolved=s.unresolved}}
3
- export{_n};
2
+ import{c,i}from"./chunk-8kj9pkw5.js";import{t,F}from"./chunk-g0dxj89b.js";import{rt,Lt}from"./chunk-zf96k060.js";import{y}from"./chunk-a2dn9j88.js";import{n}from"./chunk-3qx4ys4v.js";function q(g,w){let C=(D)=>t(D).map((b)=>D.slice(b.start,b.end)).join("");return C(g)===C(w)}function de(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let w=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(w)?w:void 0}function oe(g,w){if(q(g,w))return g;let C=de(w);if(!C)return;let D=t(g),b=0,v=0,B=[];for(let S of D){let k=g.slice(S.start,S.end);if(k==="("||k==="["||k==="{"||k==="<")b++;else if(k===")"||k==="]"||k==="}"||k===">")b--;else if(k==="|"&&b===0)B.push(g.slice(v,S.start).trim()),v=S.end}B.push(g.slice(v).trim());let O=B.find((S)=>q(S,w));if(O)return O;if(B.includes(C))return C==="boolean"&&(w==="true"||w==="false")?w:C;return}function jn(g,w,C,D=new Set){let b=new Map,v=[],B=new Set;for(let e of[...w,...C.values()]){if(B.has(e))continue;if(B.add(e),v.push(e),e.kind==="import")for(let o of y(e.text))b.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))b.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")b.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}v.sort((e,o)=>(e.start??0)-(o.start??0));let O=new Set(v.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of D)O.add(e);let S=new Map,k=(e)=>{if(e=e.trimStart(),S.has(e))return S.get(e);if(S.set(e,void 0),!c(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!O.has(e.slice(0,o)))return;let r=t(e);if(r[0]?.kind!=="word"||!r[1]||e.slice(r[1].start,r[1].end)!=="(")return;let d=1;for(let s=2;s<r.length;s++){let a=e.slice(r[s].start,r[s].end);if(a==="(")d++;else if(a===")"&&--d===0){let l=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return S.set(e,l),l}}return},E=new Set(v.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>k(e.value)).filter((e)=>e!==void 0)).size?F(g):void 0,x=new Map;if(E){let e=0;for(let o=0;o<E.length;o++){let r=g.slice(E[o].start,E[o].end);if(e===0&&r==="function"){let d=E[o+1],s=d&&g.slice(d.start,d.end)==="*"?E[o+2]:d;if(s?.kind==="word"){let a=g.slice(s.start,s.end);x.set(a,(x.get(a)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let R=new Map;for(let e of v)if(e.kind==="function"&&!e.generics&&x.get(e.name)===1)R.set(e.name,e);for(let e of D){let o=v.find((r)=>r.kind==="import"&&y(r.text).includes(e));if(o)R.set(e,o)}let W="__dtsx_call_result";while(g.includes(W))W+="_";let K=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${W} ? ${W} : never`,X=new Map,H=!1;for(let e of v){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=k(e.value);if(o&&R.has(o))X.set(e,K(o)),b.get(e.name).active=!0,b.get(o).active=!0,H=!0;if(e.modifiers?.[0]!=="const")continue;let r=rt(e.value);if(!r||r===e.name||!b.has(r))continue;b.get(r).active=!0,b.get(e.name).active=!0,H=!0}if(!H)return;let u=E??F(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",m=new Map,_=new Map,G=new Set,L=new Set,J=new Set,Q=new Map,I=[];for(let e=0;e<u.length;e++){let o=f(e),r=I.at(-1);if(r!==void 0)_.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))G.add(e);if(["(","[","{"].includes(o))I.push(e);else if([")","]","}"].includes(o)){let d=I.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))I.pop(),m.set(d,e)}}let Y=new Map;for(let e=0;e<u.length;){if(u[e].kind!=="punctuation"){e++;continue}let r=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>g.startsWith(s,u[e].start))??f(e);Y.set(e,r);let d=u[e].start+r.length;do e++;while(e<u.length&&u[e].start<d)}for(let e=0;e<u.length;e++){let o=ne(e);if(o!==void 0)L.add(o)}for(let e of L)le(e);let h=0;function Z(e){let o=rt(e);if(o){let a=b.get(o);return{type:a?.flow,unresolved:a?.unresolved??!1}}let r=k(e),d=r?R.get(r):void 0;if(d)return{type:d.returnType&&de(d.returnType)?d.returnType:K(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function T(e){return Y.get(e)??""}function N(e){if(u[e]?.kind!=="word"||J.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=b.get(f(e));if(!o?.active)return;let r=T(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(r))return{binding:o,operator:r};if(["++","--"].includes(r)&&!/[\r\n]/.test(g.slice(u[e].end,u[e+1].start)))return{binding:o,operator:r};if(e>=2&&["++","--"].includes(T(e-2))){let d=u[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(f(e-3)));if(!d||!s||/[\r\n;]/.test(g.slice(d.end,u[e-2].start)))return{binding:o,operator:T(e-2)}}return}function ee(e){let o=N(e);return o?.operator==="="?o.binding:void 0}function ne(e){if(u[e]?.kind!=="word"||f(e)!=="class"||f(e-1)==="."||["(",":","="].includes(f(e+1)))return;let o=e+1,r=0;while(o<u.length){let d=f(o);if(d==="{"&&r===0)return o;if(d==="class"){let s=ne(o);if(s!==void 0){o=(m.get(s)??s)+1;continue}}if(d==="function"){let s=se(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&T(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(m.get(o)??o)+1}return}function te(e,o,r){let d=e,s=!1,a=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(a.includes(f(d))&&!["(","<","?","!",":","=",";","}"].includes(f(d+1))){if(f(d)==="static")s=!0;d++}if(f(d)==="*")d++;if(r&&f(d)==="#")d++;if(f(d)==="["){let p=m.get(d);return p===void 0?void 0:{next:p+1,isStatic:s}}if(u[d]?.kind==="word"||u[d]?.kind==="quoted")return{next:d+1,isStatic:s};let l=d+1;while(l<o&&u[l-1].end===u[l].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(l)))l++;if(d<o&&n(g.slice(u[d].start,u[l-1].end),!1)==="number")return{next:l,isStatic:s};return}function P(e,o,r){let d=te(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let a=1;s++;while(s<o&&a>0){if(f(s)==="<")a++;else if(f(s)===">"&&T(s-1)!=="=>")a--;s=(m.get(s)??s)+1}if(a!==0)return}return s}function ie(e,o,r){return P(e,o,r)===o}function fe(e,o){let r=0,d=-1;for(let s=e;s<o;s=(m.get(s)??s)+1)if(f(s)==="<"&&(r>0||s>e&&(u[s-1].kind==="word"||[")","]"].includes(f(s-1))))){if(r===0)d=s;r++}else if(f(s)===">"&&T(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function ae(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=P(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function U(e,o,r=!1){let d=m.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&T(s)==="=")return s;if(s>e&&_.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let a=f(s-1),p=!(a===">"&&fe(e,s)&&ae(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(a),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!M)return s}s=(m.get(s)??s)+1}return d}function V(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&m.has(r)){r=m.get(r);continue}if(u[r].kind==="word")J.add(r)}}function le(e){let o=m.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(m.get(r+1)??r+1)+1;continue}let d=te(r,o,!0);if(!d){r++;continue}let s=P(r,o,!0);if(s===void 0){r++;continue}if(V(r,s),f(s)==="("){let l=m.get(s),p=l===void 0?void 0:re(l,o);if(p!==void 0){r=(m.get(p)??p)+1;continue}}let a=s;if(f(a)===":")a=U(a+1,e,!0);if(T(a)==="="){V(r,a+1);let l=a+1,p=U(l,e);if(!d.isStatic&&p>l)Q.set(l,p);r=p}else{let l=U(s,e);V(r,l),r=Math.max(r+1,l)}}}function ce(e){let o=_.get(e);if(o===void 0)return!1;let r=L.has(o);if(!r&&!G.has(o))return!1;if(ie(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=_.get(d),a=_.get(d)===o&&(f(d)===","||r&&f(d)===";"),l=r&&f(d)==="}"&&s!==void 0&&_.get(s)===o,p=r&&_.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((a||l||p)&&ie(d+1,e,r))return!0}return!1}function re(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Lt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(m.get(r)??r)+1}return}function se(e,o){let r=-1;if(f(e)==="("){let s=m.get(e);if(s!==void 0&&ce(e))r=re(s,o)??-1;else if(s!==void 0&&T(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let a=s+2;while(a<o&&f(a)!==";"){if(T(a)==="=>"){r=a+2;break}a=(m.get(a)??a)+1}}}else if(u[e]?.kind==="word"&&T(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(m.get(s)??s)+1;let a=m.get(s);if(a===void 0)return;r=a+1;let l=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(l===void 0||!Lt(g.slice(u[l].start,u[r].start))))break;r=(m.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(m.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(m.get(d)??d)+1;return{start:e,end:d}}function j(e,o,r=!0){for(let d=e;d<o;d++){let s=Q.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let a=r?se(d,o):void 0;if(a){let p=a.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")j(a.start,a.end,!1);d=a.end-1;continue}let l=N(d);if(l)l.binding.flow=void 0,l.binding.unresolved=!0}}function ue(e){let o=!1;while(h<u.length&&u[h].start<e){let r=f(h);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let l=m.get(h)??h+1;while(l<u.length&&u[l].start>=e)l--;if(j(h+1,l),h=l+1,r==="{")o=!1;continue}let d=ee(h);if(d){let a=h+2,l=a,p=[];while(l<u.length&&u[l].start<e){let A=f(l);if(p.length===0&&(A===";"||l>a&&/[\r\n]/.test(g.slice(u[l-1].end,u[l].start))&&(ee(l)||["if","for","while","switch","try","do","return","throw"].includes(A))))break;if(A==="("||A==="{"||A==="[")p.push(A==="("?")":A==="{"?"}":"]");else if(A===p.at(-1))p.pop();l++}let M=l>a?g.slice(u[a].start,u[l-1].end):"";j(a,l);let z=Z(M);d.flow=!o&&z.type?d.declared?oe(d.declared,z.type):z.type:void 0,d.unresolved=o||z.unresolved||!d.flow,h=l;continue}let s=N(h);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;h++}}for(let e of v){ue(e.start??0);let o=h;while(h<u.length&&u[h].start<(e.end??0))h++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<h&&u[M].start<e.initializerStart)M++;j(M,h)}let r=b.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=Z(d),a=rt(d),l=a?b.get(a):void 0,p=X.get(e);if(p)e.inferredType=p,e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${p};`;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&a&&a!==e.name&&l){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=l.declared&&q(l.declared,s.type)?`typeof ${a}`:s.type,e.text=`${e.isExported?"export ":""}declare const ${e.name}: ${e.inferredType};`}if(e.typeAnnotation)r.flow=s.type?oe(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)r.declared=e.inferredType,r.flow=e.inferredType;else{let M=e.modifiers?.[0]==="const",z=d.trim().startsWith("{")||d.trim().startsWith("["),A=n(d,M&&!z);r.declared=A==="unknown"?void 0:A,r.flow=r.declared}r.unresolved=s.unresolved}}
3
+ export{jn};