@dtsx/dtsx 0.11.56 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/dist/{chunk-62428w6e.js → chunk-07c41ffx.js} +7 -7
  3. package/dist/{chunk-j7rpp55s.js → chunk-0mj07j66.js} +3 -3
  4. package/dist/chunk-0zwa1tag.js +31 -0
  5. package/dist/chunk-16rpzfwq.js +10 -0
  6. package/dist/chunk-253e6nb4.js +3 -0
  7. package/dist/chunk-27hrxxsh.js +9 -0
  8. package/dist/{chunk-tgaear7n.js → chunk-27rxm6hh.js} +6 -6
  9. package/dist/chunk-30ffarqm.js +4 -0
  10. package/dist/{chunk-kkshxyex.js → chunk-37jcvx0v.js} +3 -3
  11. package/dist/chunk-44a6zpxs.js +3 -0
  12. package/dist/{chunk-g9emajpc.js → chunk-4ce9a877.js} +2 -2
  13. package/dist/{chunk-587w6ktw.js → chunk-4th0w19y.js} +3 -3
  14. package/dist/{chunk-mew3f4wh.js → chunk-50r5qs7t.js} +2 -2
  15. package/dist/chunk-5fgakmq9.js +3 -0
  16. package/dist/chunk-5tcpge5e.js +56 -0
  17. package/dist/{chunk-h6ddkhyq.js → chunk-5vk2x8ee.js} +2 -2
  18. package/dist/{chunk-k8tnz2qd.js → chunk-7116bytq.js} +8 -8
  19. package/dist/{chunk-6j6dvj8a.js → chunk-78ft65vf.js} +2 -2
  20. package/dist/{chunk-v22xpr7j.js → chunk-795w1bb2.js} +2 -2
  21. package/dist/chunk-7vjbc4z7.js +6 -0
  22. package/dist/chunk-85r70e8z.js +3 -0
  23. package/dist/chunk-8t9qp0mq.js +5 -0
  24. package/dist/chunk-9axwjcna.js +21 -0
  25. package/dist/{chunk-qt9gjs57.js → chunk-9wgk5qp1.js} +2 -2
  26. package/dist/{chunk-hbmnkmzb.js → chunk-am4b9zt0.js} +3 -3
  27. package/dist/chunk-b5wcbnb8.js +9 -0
  28. package/dist/{chunk-8vvryt8p.js → chunk-bd048mjd.js} +2 -2
  29. package/dist/chunk-be7f8t6b.js +3 -0
  30. package/dist/chunk-bwb12r8r.js +3 -0
  31. package/dist/chunk-cb5dj4qy.js +3 -0
  32. package/dist/chunk-chj3hn6f.js +3 -0
  33. package/dist/chunk-cnb2rfmv.js +21 -0
  34. package/dist/{chunk-vk5r6pgx.js → chunk-cs6538bw.js} +2 -2
  35. package/dist/chunk-d99qykzn.js +6 -0
  36. package/dist/{chunk-2qbj76ap.js → chunk-e12f4mpd.js} +8 -8
  37. package/dist/chunk-e21ap86b.js +3 -0
  38. package/dist/{chunk-f5jc2v3k.js → chunk-ezhvnzja.js} +2 -2
  39. package/dist/chunk-fnd5bvfd.js +3 -0
  40. package/dist/chunk-fwqdc8fd.js +3 -0
  41. package/dist/{chunk-6r01zgys.js → chunk-gkfchhnr.js} +2 -2
  42. package/dist/chunk-h9gwg4kt.js +9 -0
  43. package/dist/chunk-hd2bq1j5.js +6 -0
  44. package/dist/{chunk-g25sbqbw.js → chunk-hpdmtzhk.js} +3 -3
  45. package/dist/{chunk-v6fwy63g.js → chunk-j2bapmng.js} +2 -2
  46. package/dist/{chunk-pnfjhm01.js → chunk-j41nnny5.js} +2 -2
  47. package/dist/{chunk-btcj8fgc.js → chunk-j60x598n.js} +3 -3
  48. package/dist/{chunk-gwa4hmfa.js → chunk-javyer70.js} +2 -2
  49. package/dist/chunk-ke1h5m7f.js +5 -0
  50. package/dist/chunk-kp395d2p.js +44 -0
  51. package/dist/{chunk-4rsk49xj.js → chunk-mzw42cv7.js} +2 -2
  52. package/dist/chunk-n2fm08w5.js +2 -0
  53. package/dist/chunk-n73yp5s4.js +6 -0
  54. package/dist/{chunk-6ekemc3h.js → chunk-ne7q6jf2.js} +2 -2
  55. package/dist/{chunk-5bdwrsqt.js → chunk-ngb87w7x.js} +7 -7
  56. package/dist/chunk-p15wwraa.js +3 -0
  57. package/dist/{chunk-1mzxq1rg.js → chunk-pb7p64tn.js} +2 -2
  58. package/dist/chunk-peg2exva.js +3 -0
  59. package/dist/chunk-pjrnfmwm.js +3 -0
  60. package/dist/{chunk-mph001z4.js → chunk-pkmjprad.js} +4 -4
  61. package/dist/{chunk-fpa2ea8k.js → chunk-pq6j9bkd.js} +5 -5
  62. package/dist/chunk-r1t34d75.js +3 -0
  63. package/dist/chunk-r48h4anw.js +3 -0
  64. package/dist/chunk-r6bagvr6.js +18 -0
  65. package/dist/chunk-rnm8937h.js +3 -0
  66. package/dist/chunk-rv597vq5.js +3 -0
  67. package/dist/chunk-s7d3d1wx.js +3 -0
  68. package/dist/{chunk-b6994asf.js → chunk-sqhmhd08.js} +2 -2
  69. package/dist/{chunk-8r7rmcz7.js → chunk-t5x9cy8y.js} +5 -5
  70. package/dist/chunk-t9w6e58q.js +22 -0
  71. package/dist/chunk-v0gpmwh9.js +8 -0
  72. package/dist/{chunk-heqx5083.js → chunk-ves5kf6r.js} +4 -4
  73. package/dist/{chunk-6c8nk9rm.js → chunk-veys7ggd.js} +4 -4
  74. package/dist/chunk-vjmwxye4.js +3 -0
  75. package/dist/chunk-war78wdt.js +22 -0
  76. package/dist/chunk-wfkkp4tx.js +29 -0
  77. package/dist/{chunk-mqv5m22t.js → chunk-x4pxkg7c.js} +4 -4
  78. package/dist/chunk-xrtfb38p.js +14 -0
  79. package/dist/chunk-xz57d151.js +3 -0
  80. package/dist/chunk-y7bcjjqd.js +3 -0
  81. package/dist/{chunk-hgg4aqvf.js → chunk-yfgm2ccr.js} +2 -2
  82. package/dist/{chunk-nmht3krt.js → chunk-yje9ebc0.js} +4 -4
  83. package/dist/chunk-yjkhep5n.js +3 -0
  84. package/dist/{chunk-7dmn623d.js → chunk-ykxeeekb.js} +3 -3
  85. package/dist/{chunk-9bj73ygx.js → chunk-ypbjr2b6.js} +3 -3
  86. package/dist/src/augmentation-graph.js +1 -1
  87. package/dist/src/binding-patterns.js +1 -1
  88. package/dist/src/branded-types.js +1 -1
  89. package/dist/src/bundle-linker.d.ts +4 -2
  90. package/dist/src/bundle-linker.js +1 -1
  91. package/dist/src/bundler.js +1 -1
  92. package/dist/src/cache.js +1 -1
  93. package/dist/src/call-signatures.d.ts +2 -0
  94. package/dist/src/call-signatures.js +1 -1
  95. package/dist/src/circular.js +1 -1
  96. package/dist/src/compat.js +1 -1
  97. package/dist/src/computed-keys.js +1 -1
  98. package/dist/src/concurrency.js +1 -1
  99. package/dist/src/config.js +1 -1
  100. package/dist/src/dangling-refs.js +1 -1
  101. package/dist/src/declaration-project.d.ts +4 -2
  102. package/dist/src/declaration-project.js +1 -1
  103. package/dist/src/declaration-publication.d.ts +1 -1
  104. package/dist/src/declaration-publication.js +1 -1
  105. package/dist/src/declaration-references.js +1 -1
  106. package/dist/src/diff.js +1 -1
  107. package/dist/src/docs.js +1 -1
  108. package/dist/src/enum-declarations.js +1 -1
  109. package/dist/src/errors.js +1 -1
  110. package/dist/src/extractor/directives.js +1 -1
  111. package/dist/src/extractor/extract.js +1 -1
  112. package/dist/src/extractor/hash.js +1 -1
  113. package/dist/src/extractor/scanner.d.ts +2 -0
  114. package/dist/src/extractor/scanner.js +1 -1
  115. package/dist/src/extractor.js +1 -1
  116. package/dist/src/formats.js +1 -1
  117. package/dist/src/formatter.js +1 -1
  118. package/dist/src/function-properties.js +1 -1
  119. package/dist/src/generator.js +1 -1
  120. package/dist/src/import-sorter.d.ts +6 -6
  121. package/dist/src/import-sorter.js +1 -1
  122. package/dist/src/incremental.js +1 -1
  123. package/dist/src/index.js +1 -1
  124. package/dist/src/inferred-imports.d.ts +5 -1
  125. package/dist/src/inferred-imports.js +1 -1
  126. package/dist/src/initializer-type-spans.js +1 -1
  127. package/dist/src/json-config.js +1 -1
  128. package/dist/src/lexical.d.ts +3 -0
  129. package/dist/src/lexical.js +1 -1
  130. package/dist/src/logger.js +1 -1
  131. package/dist/src/lsp.js +1 -1
  132. package/dist/src/memory.js +1 -1
  133. package/dist/src/merger.js +1 -1
  134. package/dist/src/module-graph.d.ts +9 -3
  135. package/dist/src/module-graph.js +1 -1
  136. package/dist/src/module-references.d.ts +2 -0
  137. package/dist/src/module-references.js +1 -1
  138. package/dist/src/native-checker.js +1 -1
  139. package/dist/src/native-engine.d.ts +24 -0
  140. package/dist/src/native-engine.js +1 -1
  141. package/dist/src/native-extractor.js +1 -1
  142. package/dist/src/native-generation.js +1 -1
  143. package/dist/src/native-project.js +1 -1
  144. package/dist/src/numeric-literals.js +1 -1
  145. package/dist/src/optimizer.js +1 -1
  146. package/dist/src/output-normalizer.d.ts +5 -5
  147. package/dist/src/output-normalizer.js +1 -1
  148. package/dist/src/parallel-processor.js +1 -1
  149. package/dist/src/parameters.js +1 -1
  150. package/dist/src/parser.js +1 -1
  151. package/dist/src/plugins/bun.js +1 -1
  152. package/dist/src/plugins/esbuild.js +1 -1
  153. package/dist/src/plugins/index.js +1 -1
  154. package/dist/src/plugins/tsdown.js +1 -1
  155. package/dist/src/plugins/tsup.js +1 -1
  156. package/dist/src/plugins/vite.js +1 -1
  157. package/dist/src/plugins/webpack.js +1 -1
  158. package/dist/src/plugins.d.ts +2 -0
  159. package/dist/src/plugins.js +1 -1
  160. package/dist/src/process-source.js +1 -1
  161. package/dist/src/processor/cache.js +1 -1
  162. package/dist/src/processor/comments.js +1 -1
  163. package/dist/src/processor/declarations.js +1 -1
  164. package/dist/src/processor/import-usage.js +1 -1
  165. package/dist/src/processor/imports.d.ts +3 -1
  166. package/dist/src/processor/imports.js +1 -1
  167. package/dist/src/processor/index.js +1 -1
  168. package/dist/src/processor/type-inference.d.ts +27 -7
  169. package/dist/src/processor/type-inference.js +1 -1
  170. package/dist/src/processor.js +1 -1
  171. package/dist/src/profiling.js +1 -1
  172. package/dist/src/return-type-scope.js +1 -1
  173. package/dist/src/security.js +1 -1
  174. package/dist/src/source-cache.js +1 -1
  175. package/dist/src/sourcemap.js +1 -1
  176. package/dist/src/stx.js +1 -1
  177. package/dist/src/syntax-validator.js +1 -1
  178. package/dist/src/tracking.js +1 -1
  179. package/dist/src/transformers.js +1 -1
  180. package/dist/src/tree-shaker.js +1 -1
  181. package/dist/src/tsconfig.js +1 -1
  182. package/dist/src/type-mappings.js +1 -1
  183. package/dist/src/utils.js +1 -1
  184. package/dist/src/value-inference.js +1 -1
  185. package/dist/src/vue.js +1 -1
  186. package/dist/src/watcher.js +1 -1
  187. package/dist/src/worker-thread.js +1 -1
  188. package/dist/src/worker.js +1 -1
  189. package/dist/src/workspace.js +1 -1
  190. package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
  191. package/native/darwin-x64/libzig-dtsx.dylib +0 -0
  192. package/native/freebsd-x64/libzig-dtsx.so +0 -0
  193. package/native/linux-arm64/libzig-dtsx.so +0 -0
  194. package/native/linux-x64/libzig-dtsx.so +0 -0
  195. package/native/windows-x64/zig-dtsx.dll +0 -0
  196. package/package.json +1 -1
  197. package/dist/chunk-0a1xppye.js +0 -3
  198. package/dist/chunk-0d5nemtn.js +0 -3
  199. package/dist/chunk-1t77gtcx.js +0 -3
  200. package/dist/chunk-20jq5v1p.js +0 -14
  201. package/dist/chunk-38r6thfe.js +0 -3
  202. package/dist/chunk-4cr1q0yf.js +0 -4
  203. package/dist/chunk-555w3kcr.js +0 -8
  204. package/dist/chunk-5tn8854w.js +0 -31
  205. package/dist/chunk-5yx2x4v4.js +0 -3
  206. package/dist/chunk-6b6rt0yh.js +0 -3
  207. package/dist/chunk-7pw9ayve.js +0 -9
  208. package/dist/chunk-7rdazac9.js +0 -40
  209. package/dist/chunk-81jrzxr6.js +0 -10
  210. package/dist/chunk-9h17ws4c.js +0 -2
  211. package/dist/chunk-9mdgtq38.js +0 -3
  212. package/dist/chunk-9wwsqemm.js +0 -3
  213. package/dist/chunk-bt2n0b75.js +0 -4
  214. package/dist/chunk-c726s7aj.js +0 -6
  215. package/dist/chunk-cfjd81h8.js +0 -3
  216. package/dist/chunk-cgqg1br8.js +0 -5
  217. package/dist/chunk-daasy0pw.js +0 -3
  218. package/dist/chunk-dak0dhnx.js +0 -3
  219. package/dist/chunk-djbck65n.js +0 -3
  220. package/dist/chunk-ekf33t9z.js +0 -6
  221. package/dist/chunk-eskywkxz.js +0 -22
  222. package/dist/chunk-ewgs91y1.js +0 -3
  223. package/dist/chunk-h28vzayq.js +0 -3
  224. package/dist/chunk-h7ebvy8j.js +0 -3
  225. package/dist/chunk-hj7gs32r.js +0 -3
  226. package/dist/chunk-hkcqbex1.js +0 -3
  227. package/dist/chunk-msa98cgm.js +0 -19
  228. package/dist/chunk-mzxxgnp8.js +0 -3
  229. package/dist/chunk-njknd1pt.js +0 -6
  230. package/dist/chunk-qbk49jz5.js +0 -21
  231. package/dist/chunk-qhkxctek.js +0 -3
  232. package/dist/chunk-r46rw8gr.js +0 -29
  233. package/dist/chunk-rzcnab8j.js +0 -3
  234. package/dist/chunk-sjbm1trn.js +0 -3
  235. package/dist/chunk-spdw3tc0.js +0 -18
  236. package/dist/chunk-srm0ddsk.js +0 -27
  237. package/dist/chunk-t5nmnzy6.js +0 -7
  238. package/dist/chunk-tw99ftp1.js +0 -3
  239. package/dist/chunk-vt5hr8vs.js +0 -3
  240. package/dist/chunk-wq5r1ms9.js +0 -38
  241. package/dist/chunk-x6ddycvm.js +0 -3
  242. package/dist/chunk-yxcyqezk.js +0 -8
@@ -1,31 +0,0 @@
1
- // @bun
2
- import{w,le,Mt,u}from"./chunk-6b6rt0yh.js";import{V}from"./chunk-mew3f4wh.js";import{L,N}from"./chunk-qbk49jz5.js";import{O,I}from"./chunk-fpa2ea8k.js";import{r}from"./chunk-0a1xppye.js";import{Re}from"./chunk-38r6thfe.js";import{e,M}from"./chunk-8vvryt8p.js";import{Oe,P,Bn,Z}from"./chunk-1t77gtcx.js";import{Rn}from"./chunk-srm0ddsk.js";import{et,kt}from"./chunk-h6ddkhyq.js";import{D}from"./chunk-2qbj76ap.js";import{De,oe,X,Pe}from"./chunk-yxcyqezk.js";import{tt,Y,re,Tt,At,Dt,Pt}from"./chunk-20jq5v1p.js";import{ne,$e}from"./chunk-hj7gs32r.js";import{Qe,Et}from"./chunk-tgaear7n.js";import{te}from"./chunk-spdw3tc0.js";import{Ln,rt}from"./chunk-cfjd81h8.js";import{q,Ee}from"./chunk-dak0dhnx.js";import{Xe}from"./chunk-msa98cgm.js";import{Ae}from"./chunk-7pw9ayve.js";import{l}from"./chunk-81jrzxr6.js";import{ie,Rt}from"./chunk-0d5nemtn.js";import{mkdir as ye}from"fs/promises";import{availableParallelism as Se}from"os";import{basename as fe,dirname as pe,relative as z,resolve as ee}from"path";var Q=new WeakMap,ce=new WeakMap;function se(d){let a=Q.get(d);if(!a)a=Oe(d),Q.set(d,a),a.catch(()=>Q.delete(d));return a}async function de(d,a,t,f,h,g=Y){let o=fe(d)||"output.d.ts",C=z(pe(d),a),T=`${o}.map`,j=t.lastIndexOf(`
3
- ${tt()}`),p=j===-1?t:t.slice(0,j),y=Dt(p,o,C,f),b=`${d}.map`;return await g(b,JSON.stringify(y)),e.debug(` Generated source map: ${z(h,b)}`),T}async function s(d){let a=Date.now(),t={...D,...d};if(t.logLevel)M(t.logLevel);else if(t.verbose)M("debug");let f=new Ae;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(q(t.engine,"engine"),await ne(t),t.isolatedDeclarations===void 0)t.isolatedDeclarations=await re(t);let h=t.typeMappings?ie(t.typeMappings):void 0,g=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 T=await De(t,()=>se(t)),j=T.entryFiles,p=[...T.files],{resolver:y,reachability:b}=T;if(ce.set(t,new Set(p)),t.incremental){let n=T.getResolutionFingerprint();if(!t.isolatedDeclarations){let i=new Set(p),m=new Map;for(let S of p){let F=await u(S);m.set(S,rt(F));for(let U of P(F,{includeImports:!0})){let R=y(U.specifier,S).resolved;if(R&&!R.split(/[/\\]/).includes("node_modules")&&!i.has(R))i.add(R),m.set(R,rt(await u(R)))}}let c=[...m].sort(([S],[F])=>S.localeCompare(F));n=JSON.stringify([n,c])}if(g=new et(t,n),t.clearCache){if(e.debug("Clearing build cache..."),!t.dryRun)g.clear()}else if(g.load()){let m=g.getStats();e.debug(`Loaded build cache with ${m.entries} entries`)}else e.debug("No existing build cache found, starting fresh");if(!t.dryRun)kt(t.cwd)}if(g&&!t.dryRun){let n=g.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 W=new Map,k=new Map,v=async(n,i,m="lf")=>{k.set(n,{content:i,lineEnding:m})},E=async(n,i)=>{let m;try{let c=X(n,t),S=async(x)=>{if(!t.diff)return;try{let B=await u(c),H=At(B,x,z(t.cwd,c));if(H)e.info(`
4
- ${H}`);else e.debug(`[no changes] ${c}`)}catch{e.info(`[new file] ${z(t.cwd,c)}`)}},F=(x)=>{if(!t.validate)return 0;let B=Tt(x,c);if(B.isValid)return e.debug(`[validation] ${c} - OK`),0;e.warn(`[validation] ${z(t.cwd,c)} has ${B.errors.length} error(s):`);for(let H of B.errors){let ae=` Line ${H.line}:${H.column}`;if(H.code)ae+=` [${H.code}]`;if(ae+=` - ${H.message}`,e.warn(ae),H.suggestion)e.warn(` Suggestion: ${H.suggestion}`)}return B.errors.length},U=(x)=>{e.info(`[dry-run] Would generate: ${c}`),e.debug("--- Content preview ---"),e.debug(x.slice(0,500)+(x.length>500?`
5
- ...`:"")),e.debug("--- End preview ---")};if(g){let x=g.getCachedIfValid(n,t.cwd);if(x){if(t.bundle)W.set(n,x);await S(x);let B=F(x);if(t.dryRun)U(x);else{if(t.declarationMap)m=i??await u(n),await de(c,n,x,m,t.cwd,v);await v(c,x,t.lineEnding)}return e.debug(`[cached] ${z(t.cwd,c)}`),{success:!0,file:n,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:B}}}m=i??await u(n);let{content:R,declarationCount:he,importCount:we,exportCount:Ce}=await ge(n,m,t,f,h,T.augmentationImports.get(n));if(t.bundle)W.set(n,R);let A=R;if(t.prettier||t.indentStyle||t.indentSize){let x=await te(A,{usePrettier:t.prettier,builtIn:{indentSize:t.indentSize||2,useTabs:t.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},c);A=x.content;for(let B of x.warnings??[])e.warn(`[format] ${B}`)}if(t.declarationMap){let x=`${fe(c)||"output.d.ts"}.map`;A=Pt(A,x)}await S(A);let be=F(A);if(t.dryRun)U(A);else{if(t.declarationMap&&m)await de(c,n,A,m,t.cwd,v);if(await v(c,A,t.lineEnding),g&&m)g.update(n,m,A,t.cwd);e.debug(`Generated: ${c}`)}return{success:!0,file:n,declarationCount:he,importCount:we,exportCount:Ce,validationErrorCount:be}}catch(c){let S=Qe(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}}},G=t.parallel||t.parallel!==!1&&p.length>=10,J=V(t.concurrency,Se?.()??8),_=new Map;if(G&&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)_.set(i.file,i.source)}let K=(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=Et(n.dtsError);if(t.continueOnError)e.warn(i);else throw e.error(i),Error(n.dtsError.message)}};if(G)for(let n=0;n<p.length;n+=J){let i=p.slice(n,n+J),m=await Promise.all(i.map((c)=>E(c,_.get(c))));for(let c of m)K(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 E(n);if(K(i),t.progress){let m=Math.round(o.filesProcessed/p.length*100),c=i.cached?"[cached]":"";e.info(`[${o.filesProcessed}/${p.length}] ${m}% - ${z(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 P(c)){let F=y(S.specifier,m);if(!F.isRelative)continue;if(!F.resolved)n.push({from:m,specifier:S.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(F.resolved)&&!i.has(F.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=z(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)&&j.length>0)try{e.debug("Bundling declarations...");let n=j.length===1&&!!t.bundleOutput;for(let i of j){let m=await Z([i],{includeImports:!0,resolveSpecifier:y}),c=new Set;for(let R of m.reachable){if(R.endsWith(".d.ts"))continue;if(R.includes("node_modules"))continue;c.add(R)}let S=p.filter((R)=>c.has(R));if(!S.includes(i))S.push(i);let F=Rn(i,S,W,{cwd:t.cwd,keepComments:t.keepComments});for(let R of new Set(F.warnings))e.warn(`[bundle] ${R}`);let U=n?ee(t.cwd,t.outdir,t.bundleOutput):X(i,t);if(t.dryRun)e.info(`[dry-run] Would bundle ${F.files.length} files to: ${z(t.cwd,U)}`);else await v(U,F.content,t.lineEnding),e.debug(`Prepared ${F.files.length} bundled files for: ${z(t.cwd,U)}`);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 $e(t,k);if(g&&!t.dryRun)g.save(),e.debug("Saved build cache");if(o.durationMs=Date.now()-a,t.stats)if(t.outputFormat==="json")console.log(JSON.stringify(o,null,2));else{if(e.info(`
7
- --- Generation Statistics ---`),e.info(`Files processed: ${o.filesProcessed}`),e.info(`Files generated: ${o.filesGenerated}`),C>0)e.info(`Files cached: ${C}`);if(o.filesFailed>0)e.info(`Files failed: ${o.filesFailed}`);if(e.info(`Declarations found: ${o.declarationsFound}`),e.info(`Imports processed: ${o.importsProcessed}`),e.info(`Exports processed: ${o.exportsProcessed}`),o.filesValidated>0){if(e.info(`Files validated: ${o.filesValidated}`),o.validationErrors>0)e.info(`Validation errors: ${o.validationErrors}`)}if(e.info(`Duration: ${o.durationMs}ms`),o.errors.length>0){e.info(`
8
- Errors:`);for(let n of o.errors){let i=` - ${n.file}`;if(n.location)i+=`:${n.location.line}:${n.location.column}`;if(n.code)i+=` [${n.code}]`;if(i+=`: ${n.message}`,e.info(i),n.suggestion)e.info(` Suggestion: ${n.suggestion}`)}}e.info(`-----------------------------
9
- `)}if(t.plugins&&t.plugins.length>0)await f.runOnEnd(o);return e.debug("DTS generation complete!"),o}async function ve(d,a,t){let f=await se(t),h=Pe(a,t,f,ce.get(t));return Bn(d,(g)=>h(g).emittedSpecifier)}async function po(d,a){Q.delete(a),ce.delete(a);let t=await se(a),f=await Z([d],{includeImports:!0,resolveSpecifier:t}),h=await Re([...f.sources.keys()],t,a.isolatedDeclarations??!1,f.sources);return(await me(d,a,void 0,h.get(ee(d)))).content}async function me(d,a,t,f){let h=await u(d),g=a.typeMappings?ie(a.typeMappings):void 0;return ge(d,h,a,t,g,f)}async function ge(d,a,t,f,h,g){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 E of P(o,{includeImports:!0})){let G=v(E.specifier,d).resolved;if(G&&!G.split(/[/\\]/).includes("node_modules"))C.set(E.specifier,await u(G))}}let T=f?.hasDeclarationHooks()?null:Me(o,d,t,C,g);if(T!==null)return ue(T,d,o,t,f,h,xe(T));let j=C.size?Ln(o,C):void 0,p=r(o,d,t.keepComments,t.isolatedDeclarations??!1,j);if(f)p=await f.runOnDeclarations(d,o,p);let y=0,b=0;for(let v=0;v<p.length;v++){let E=p[v];if(E.kind==="import")y++;if(E.kind==="export"||E.isExported)b++}let k=l(p,{filePath:d,sourceCode:o,declarations:p,augmentationImports:g},t.keepComments,t.importOrder);return ue(k,d,o,t,f,h,{declarationCount:p.length,importCount:y,exportCount:b})}function xe(d){let a=0,t=0,f=0;for(let h of d.split(`
10
- `)){if(!h||h.startsWith(" ")||h.startsWith("\t")||h.startsWith("}")||h.startsWith("*")||h.startsWith("/"))continue;if(a++,h.startsWith("import "))t++;else if(h.startsWith("export "))f++}return{declarationCount:a,importCount:t,exportCount:f}}function Me(d,a,t,f,h){let g=t.importOrder??["bun"];if(g.length!==1||g[0]!=="bun")return null;let o=L(a)?N(d):O(a)?I(d):d;return Ee(o,{keepComments:t.keepComments??!0,isolatedDeclarations:t.isolatedDeclarations??!1,engine:t.engine,sourceFile:a,inferenceSources:f,augmentationImports:h})}async function ue(d,a,t,f,h,g,o){let C=await ve(d,a,f);if(g)C=Rt(C,g,{filePath:a});if(f.normalizeOutput===!0||f.declarationOrder)C=Xe(C,{lineEnding:"lf",declarationOrder:f.declarationOrder,indent:{style:f.indentStyle??"spaces",size:f.indentSize??2}});if(h)C=await h.runOnAfterFile(a,t,C);return{content:C,...o}}async function mo(d){let a={...D,...d};if(a.logLevel)M(a.logLevel);let t=ee(a.cwd,a.root),f=150,h=5,g=1e4,o={pendingChanges:new Set,debounceTimer:null,isProcessing:!1,errorCount:0,lastErrorTime:0};e.info(`Watching for changes in ${t}...`),e.info(`Press Ctrl+C to stop
11
- `);try{await s(a),e.info(`[watch] Initial generation complete
12
- `)}catch(y){let b=y instanceof Error?y.message:String(y);e.error(`[watch] Initial generation failed: ${b}`),e.info(`[watch] Continuing to watch for changes...
13
- `)}async function C(){if(o.isProcessing||o.pendingChanges.size===0)return;let y=Date.now();if(o.errorCount>=h){if(y-o.lastErrorTime<g){e.warn(`[watch] Too many errors, pausing for ${Math.ceil((g-(y-o.lastErrorTime))/1000)}s...`);return}o.errorCount=0}o.isProcessing=!0;let b=Array.from(o.pendingChanges);o.pendingChanges.clear();let W=new Date().toLocaleTimeString();if(b.length===1)e.info(`
14
- [${W}] File changed: ${b[0]}`);else e.info(`
15
- [${W}] ${b.length} files changed`);let k=0,v=0;for(let E of b){let G=ee(t,E);try{let J=a.exclude||[];if(oe(G,J,t)){e.debug(` Skipping excluded file: ${E}`);continue}if(!await le(G).exists()){e.debug(` Skipping deleted file: ${E}`);continue}let K=X(G,a),{content:n}=await me(G,a);await ye(pe(K),{recursive:!0}),await Y(K,n,a.lineEnding),e.info(` \u2713 ${z(a.cwd,K)}`),k++}catch(J){v++,o.errorCount++,o.lastErrorTime=Date.now();let _=Qe(J,G);if(e.error(` \u2717 ${E}: ${_.message}`),_.suggestion)e.error(` Suggestion: ${_.suggestion}`)}}if(b.length>1)e.info(` Done: ${k} generated, ${v} failed`);if(v===0)o.errorCount=0;if(o.isProcessing=!1,o.pendingChanges.size>0)o.debounceTimer=setTimeout(C,f)}function T(y){if(o.pendingChanges.add(y),o.debounceTimer)clearTimeout(o.debounceTimer);o.debounceTimer=setTimeout(C,f)}let p=Mt([w?"bun":"node","-e",`
16
- const fs = require('fs');
17
-
18
- const rootPath = '${t}';
19
-
20
- fs.watch(rootPath, { recursive: true }, (eventType, filename) => {
21
- if (filename && /.(?:[cm]?[jt]sx?|vue|stx)$/.test(filename) && !/.d.(?:ts|mts|cts)$/.test(filename)) {
22
- console.log(\`CHANGED:\${filename}\`);
23
- }
24
- });
25
-
26
- // Keep process alive
27
- setInterval(() => {}, 1000);
28
- `],{stdout:"pipe",stderr:"inherit"});if(w){let y=p.stdout.getReader(),b=new TextDecoder,W="";while(!0){let{done:k,value:v}=await y.read();if(k)break;W+=b.decode(v,{stream:!0});let E=W.split(`
29
- `);W=E.pop()||"";for(let G of E)if(G.startsWith("CHANGED:")){let J=G.slice(8);T(J)}}}else{let y=p.stdout,b="";y.on("data",(W)=>{b+=W.toString();let k=b.split(`
30
- `);b=k.pop()||"";for(let v of k)if(v.startsWith("CHANGED:")){let E=v.slice(8);T(E)}}),await p.exited}}
31
- export{s,po,mo};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{L,N}from"./chunk-qbk49jz5.js";import{O,I}from"./chunk-fpa2ea8k.js";import{p}from"./chunk-v6fwy63g.js";import{R,F}from"./chunk-wq5r1ms9.js";import{Le}from"./chunk-vt5hr8vs.js";import{J,Ee}from"./chunk-dak0dhnx.js";import{l}from"./chunk-81jrzxr6.js";function Ze(t,n,r,s,e,i){if(s.length!==1||s[0]!=="bun")return null;if(J(i)==="typescript")return null;let a=L(n??"")?N(t):O(n??"")?I(t):t;return Ee(a,{keepComments:r,isolatedDeclarations:e,engine:i,sourceFile:n})}var y=100,x=0,c=new Map;function $t(t,n,r=!0,s=["bun"],e=!1,i){let a=p(t),b=JSON.stringify([n,r,e,s,J(i)]),g=c.get(b);if(g&&g.contentHash===a)return g.lastAccess=++x,g.result;let h=Ze(t,n,r,s,e,i)??E(t,n,r,s,e);if(c.set(b,{result:h,contentHash:a,lastAccess:++x}),c.size>y){let S=Math.max(1,Math.ceil(c.size*0.1)),u=[];for(let[o,f]of c)u.push([o,f.lastAccess]);u.sort((o,f)=>o[1]-f[1]);for(let o=0;o<S&&o<u.length;o++)c.delete(u[o][0])}return h}function ci(t,n,r=!0,s=["bun"]){return $t(t,n,r,s,!0)}function li(t,n,r=!0,s=["bun"]){return $t(t,n,r,s,!1)}function E(t,n,r,s,e){let i=Le(t,n,r,e);return l(i,{filePath:n??"stdin.ts",sourceCode:t,declarations:i},r,s)}function ui(){c.clear()}function Ba(t,n,r=!0,s=["bun"],e=!1,i){return Ze(t,n,r,s,e,i)??kn(t,n,r,s,e)}function kn(t,n,r=!0,s=["bun"],e=!1){if(L(n??""))t=N(t);else if(O(n??""))t=I(t);let i=e?R(t,n,r):F(t,n,r);return l(i,{filePath:n??"stdin.ts",sourceCode:t,declarations:i},r,s)}
3
- export{Ze,$t,ci,li,ui,Ba,kn};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{spawn as m}from"child_process";import{readFile as i,stat as n,writeFile as p}from"fs/promises";var w=typeof globalThis.Bun<"u",fa=!w&&typeof process<"u"&&!!process.versions?.node,da=w?"bun":"node";class s{name;_size=-1;constructor(e){this.name=e}async exists(){try{return await n(this.name),!0}catch{return!1}}async text(){return i(this.name,"utf-8")}async arrayBuffer(){let e=await i(this.name);return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}get size(){if(this._size===-1)return-1;return this._size}}class a{pid;stdout;stderr;stdin;exited;process;constructor(e){this.process=e,this.pid=e.pid??0,this.stdout=e.stdout,this.stderr=e.stderr,this.stdin=e.stdin,this.exited=new Promise((r)=>{e.on("exit",(t)=>{r(t??0)}),e.on("error",()=>{r(1)})})}kill(e){this.process.kill(e)}ref(){this.process.ref()}unref(){this.process.unref()}}function le(e){if(w)return globalThis.Bun.file(e);return new s(e)}async function st(e,r){if(w)return globalThis.Bun.write(e,r);let t=typeof r==="string"?r:r instanceof ArrayBuffer?Buffer.from(r):r;return await p(e,t),typeof r==="string"?Buffer.byteLength(r):r.byteLength}function Mt(e,r={}){if(w)return globalThis.Bun.spawn(e,r);let t=Array.isArray(e)?e:[e],[o,...d]=t,l={cwd:r.cwd,env:r.env,stdio:[r.stdin??"pipe",r.stdout??"pipe",r.stderr??"pipe"]},f=m(o,d,l);return new a(f)}async function u(e){if(w)return globalThis.Bun.file(e).text();return i(e,"utf-8")}async function pa(e){if(w)return globalThis.Bun.file(e).exists();try{return await n(e),!0}catch{return!1}}async function ma(e,r){await st(e,r)}function ga(){if(w)return{name:"bun",version:globalThis.Bun.version,isBun:!0,isNode:!1};return{name:"node",version:process.versions.node,isBun:!1,isNode:!0}}
3
- export{w,fa,da,le,st,Mt,u,pa,ma,ga};
@@ -1,9 +0,0 @@
1
- // @bun
2
- class Ae{plugins=[];config=null;register(t){if(this.plugins.some((n)=>n.name===t.name))throw Error(`Plugin "${t.name}" is already registered`);this.plugins.push(t)}hasDeclarationHooks(){return this.plugins.some((t)=>t.onDeclarations!==void 0)}unregister(t){let n=this.plugins.findIndex((r)=>r.name===t);if(n>=0)return this.plugins.splice(n,1),!0;return!1}getPlugins(){return this.plugins}createLogger(t){return{debug:(n)=>console.debug(`[${t}] ${n}`),info:(n)=>console.info(`[${t}] ${n}`),warn:(n)=>console.warn(`[${t}] ${n}`),error:(n)=>console.error(`[${t}] ${n}`)}}async runOnStart(t){let n=t;for(let r of this.plugins)if(r.onStart){let e=await r.onStart(n);if(e)n=e}return this.config=n,n}async runOnBeforeFile(t,n){let r=n;for(let e of this.plugins)if(e.onBeforeFile){let i={filePath:t,sourceCode:n,content:r,config:this.config,log:this.createLogger(e.name)},o=await e.onBeforeFile(i);if(typeof o==="string")r=o}return r}async runOnDeclarations(t,n,r){let e=r;for(let i of this.plugins)if(i.onDeclarations){let o={filePath:t,sourceCode:n,declarations:e,config:this.config,log:this.createLogger(i.name)},s=await i.onDeclarations(o);if(s)e=s}return e}async runOnAfterFile(t,n,r){let e=r;for(let i of this.plugins)if(i.onAfterFile){let o={filePath:t,sourceCode:n,content:e,config:this.config,log:this.createLogger(i.name)},s=await i.onAfterFile(o);if(typeof s==="string")e=s}return e}async runOnEnd(t){for(let n of this.plugins)if(n.onEnd)await n.onEnd(t)}async runOnError(t,n,r){for(let e of this.plugins)if(e.onError){let i={filePath:n,sourceCode:r,config:this.config,log:this.createLogger(e.name)};await e.onError(t,i)}}}var ta=new Ae;function se(t){return t}var na=se({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(t)=>t.declarations.filter((n)=>{if(n.leadingComments){if(n.leadingComments.some((e)=>e.includes("@internal")))return t.log.debug(`Stripping internal declaration: ${n.name}`),!1}return!0})});function ra(t){return se({name:"banner",version:"1.0.0",description:"Adds a banner comment to generated files",onAfterFile:(n)=>`/**
3
- * ${t.split(`
4
- `).join(`
5
- * `)}
6
- */
7
-
8
- `+n.content})}function ia(t){return se({name:"filter",version:"1.0.0",description:"Filters declarations by name",onDeclarations:(n)=>n.declarations.filter((r)=>{if(r.kind==="import")return!0;return t(r.name)})})}
9
- export{Ae,ta,se,na,ra,ia};
@@ -1,40 +0,0 @@
1
- // @bun
2
- import{h,g}from"./chunk-cgqg1br8.js";import{t}from"./chunk-t5nmnzy6.js";import{Ge}from"./chunk-gwa4hmfa.js";import{or,ar,cr}from"./chunk-hkcqbex1.js";import{y,ee,K}from"./chunk-vk5r6pgx.js";import{_}from"./chunk-daasy0pw.js";import{_e,we,je}from"./chunk-6r01zgys.js";import{be}from"./chunk-587w6ktw.js";var lt=20,ft=!1,D=null;function ht(e){return Ot(e).replace(/\n[ \t]*(?=\n)/g,"")}function Ot(e){if(e.indexOf("/*")===-1)return e.trim();let i=[],s=0,r=0,l=e.length;while(r<l)if(e.charCodeAt(r)===47&&r+1<l&&e.charCodeAt(r+1)===42){if(r>s)i.push(e.substring(s,r));r+=2;while(r<l-1){if(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47){r+=2;break}r++}s=r}else r++;if(s<l)i.push(e.substring(s));return i.join("").trim()}function zt(){ft=!0,D=null}function Ut(){ft=!1;let e=D;return D=null,e}function ut(e,c){let i=0,s=0;while((s=e.indexOf(c,s))!==-1)i++,s+=c.length;return i}function wt(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function rt(e){let c=e.trim();if(c.length<3||c.charCodeAt(0)!==60)return!1;if(c.startsWith("<>"))return c.endsWith("</>");let i=c.charCodeAt(1);if(!(i>=65&&i<=90||i>=97&&i<=122||i===36||i===95))return!1;let r=2;while(r<c.length&&wt(c.charCodeAt(r)))r++;let l=c.slice(1,r),f=c.charCodeAt(r);if(f>32&&f!==62&&f!==47)return!1;if(c.endsWith("/>"))return!0;let u=c.lastIndexOf("</");if(u===-1)return!1;let a=u+2;while(a<c.length&&wt(c.charCodeAt(a)))a++;return c.slice(u+2,a)===l&&c.charCodeAt(a)===62&&a===c.length-1}function it(e){let c=e.length,i=!1;for(let f=1;f<c;f++)if(e.charCodeAt(f)<=32&&e.charCodeAt(f-1)<=32){i=!0;break}if(!i)for(let f=0;f<c;f++){let u=e.charCodeAt(f);if(u===10||u===13||u===9){i=!0;break}}if(!i)return e;let s=[],r=-1,l=!1;for(let f=0;f<c;f++)if(e.charCodeAt(f)<=32){if(!l){if(r>=0)s.push(e.substring(r,f));s.push(" "),l=!0,r=-1}}else{if(l||r<0)r=f;l=!1}if(r>=0)s.push(e.substring(r));return s.join("")}function n(e,c=!1,i=!1,s=0,r){if(!e||typeof e!=="string")return"unknown";if(s>=lt)return"unknown";let l=e.trim();if(rt(l))return"JSX.Element";let f=jt(l);if(f)return f;if(l.startsWith("BigInt("))return"bigint";if(l.startsWith("Symbol.for("))return"symbol";if(!(l.startsWith("[")&&l.endsWith("]")||l.startsWith("{")&&l.endsWith("}"))&&(l.includes(".raw`")||l.includes("String.raw`")))return"string";if(l.startsWith("`")&&l.endsWith("`")){if(!c||l.includes("${")||l.includes(`
3
- `)||l.includes("\r"))return"string";return l}if(l.charCodeAt(0)===39||l.charCodeAt(0)===34){let d=Bt(l);if(d!==null){if(d==="string"||!c)return"string";return d}}if(y(l)){if(!c)return"number";return K(l)}if(l==="true"||l==="false"){if(!c)return"boolean";return l}if(l==="null")return"null";if(l==="undefined")return"undefined";if(l.startsWith("[")&&l.endsWith("]"))return Be(l,c,s+1,r);if(l.startsWith("{")&&l.endsWith("}"))return dt(l,c,s+1,r);if(l.startsWith("class ")||l.startsWith("class{"))return oe(l);if(l.startsWith("new "))return Kt(l);if(l.endsWith("as const")){let d=l.slice(0,-8).trim();if(d.startsWith("[")&&d.endsWith("]")){let x=d.slice(1,-1).trim();if(!x)return"readonly []";let T=Q(x),w=[];for(let A=0;A<T.length;A++){let p=T[A].trim();if(p.startsWith("...")){let m=p.slice(3).trim();if(Y(m))w.push(`...typeof ${m}`);else{let C=n(m,!0,!1,s+1,r);w.push(C.startsWith("readonly [")||C.endsWith("[]")?`...${C}`:"...unknown[]")}}else w.push(n(p,!0,!1,s+1,r))}return`readonly [${w.join(", ")}]`}return n(d,!0,i,s+1,r)}if(Z(l)!==-1||l.startsWith("function")||l.startsWith("async"))return pt(l,i,s,c);if(l.startsWith("`")&&l.endsWith("`"))return se(l,c);if(l.startsWith("Promise."))return Nt(l,c,s,r);if(l.startsWith("await "))return"unknown";if(l.startsWith("typeof ")&&nt(l.slice(7)))return"string";if(l.startsWith("void ")&&nt(l.slice(5)))return"undefined";if(l.startsWith("delete ")&&nt(l.slice(7)))return"boolean";if(ee(l)){if(c)return K(l);return"bigint"}if(l.startsWith("Symbol(")||l==="Symbol.for")return"symbol";let a=U(l);if(a!==null)return a;if(Pt(l))return"boolean";if(Gt(l))return"number";return"unknown"}function $t(e){let c=e.charCodeAt(0);if(c!==39&&c!==34)return!1;return J(e,0,c)===e.length}function Bt(e){if($t(e))return e;let c=Dt(e);if(c.length<2)return null;let i=!1,s=!0,r="";for(let l of c){let f=l.trim();if($t(f))i=!0,r+=Ft(f);else s=!1}if(s)return Vt(r);if(i)return"string";return null}function Dt(e){let c=[],i=0,s=0,r=0;while(r<e.length){let l=e.charCodeAt(r);if(l===39||l===34||l===96){r=J(e,r,l);continue}if(l===40||l===91||l===123)i++;else if(l===41||l===93||l===125)i--;else if(l===43&&i===0)c.push(e.slice(s,r)),s=r+1;r++}return c.push(e.slice(s)),c}function Ft(e){return e.slice(1,-1).replace(/\\(.)/g,(i,s)=>{if(s==="n")return`
4
- `;if(s==="t")return"\t";if(s==="r")return"\r";if(s==="0")return"\x00";return s})}function Vt(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Gt(e){if(e==="")return!1;let c=!1,i=!1;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s);if(r>=48&&r<=57){c=!0;continue}if(r===43||r===45||r===42||r===47||r===37){i=!0;continue}if(r===60||r===62){let l=s+1;while(l<e.length&&e.charCodeAt(l)===r)l++;let f=l-s;if(f!==2&&!(r===62&&f===3))return!1;i=!0,s=l-1;continue}if(r===46||r===40||r===41||r<=32)continue;return!1}return c&&i}function Pt(e){let c=0,i;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=J(e,s,r)-1;continue}if(r===47){if(e[s+1]==="/"){let l=e.indexOf(`
5
- `,s+2);s=l===-1?e.length:l;continue}if(e[s+1]==="*"){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1;continue}if(h(e,s)){s=g(e,s)-1;continue}}if(r===40||r===91||r===123){c++;continue}if(r===41||r===93||r===125){c--;continue}if(c!==0)continue;if(r===60){i??=_(e);let l=i(s,0);if(l){s=l.end-1;continue}}if(e.startsWith("===",s)||e.startsWith("!==",s)||e.startsWith("==",s)||e.startsWith("!=",s)||e.startsWith(">=",s)||e.startsWith("<=",s))return!0;if((r===62||r===60)&&e.charCodeAt(s+1)===r){while(e.charCodeAt(s+1)===r)s++;continue}if((r===62||r===60)&&e.charCodeAt(s-1)!==61&&e.charCodeAt(s+1)!==61)return!0}return!1}function Ht(e,c=!1,i=0,s){return n(e,c,!0,i,s)}function B(e,c=!1,i="",s,r){let l=gt(i,s),f=[],u=!1,a=0;while(a<e.length){let x=e.charCodeAt(a);if(x===34||x===39||x===96){a=J(e,a,x);continue}if(x===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(x===47&&e.charCodeAt(a+1)===42){let w=e.indexOf("*/",a+2);a=w===-1?e.length:w+2;continue}if(e.startsWith("function",a)&&tt(e,a,8)||e.startsWith("class",a)&&tt(e,a,5)){let w=ie(e,a);if(w!==-1){a=ot(e,w);continue}}if(x===61&&e.charCodeAt(a+1)===62){let w=Mt(e,a+2);if(e.charCodeAt(w)===123){a=ot(e,w);continue}}if(e.startsWith("return",a)&&(a===0||!q(e.charCodeAt(a-1)))&&!q(e.charCodeAt(a+6))){a+=6;let w=!1;while(a<e.length&&e.charCodeAt(a)<=32){let k=e.charCodeAt(a);if(k===10||k===13)w=!0;a++}if(w||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){u=!0;continue}let A=a,p=0,m=0,C=0;while(a<e.length){let k=e.charCodeAt(a);if(k===34||k===39||k===96){a=J(e,a,k);continue}if(k===47&&e.charCodeAt(a+1)===47){if(p===0&&m===0&&C===0)break;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(k===47&&e.charCodeAt(a+1)===42){let O=e.indexOf("*/",a+2);a=O===-1?e.length:O+2;continue}if(k===40)p++;else if(k===41)p--;else if(k===91)m++;else if(k===93)m--;else if(k===123)C++;else if(k===125){if(C===0&&p===0&&m===0)break;C--}else if(k===59&&p===0&&m===0&&C===0)break;else if((k===10||k===13)&&p===0&&m===0&&C===0){let O=a+1;while(O<e.length&&e.charCodeAt(O)<=32)O++;if(e.startsWith("return",O)&&!q(e.charCodeAt(O+6)))break}a++}let S=e.slice(A,a).trim(),b=ht(V(S,l,s,r,A));if(!f.includes(b))f.push(b);continue}a++}if(u&&!f.includes("undefined"))f.push("undefined");let d=f.includes("unknown")?"unknown":f.length===0?"void":Et(f);return c&&!d.startsWith("Promise<")?`Promise<${d}>`:d}function gt(e,c){let i=new Map,s=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,r=t(s),l=0,f=0,u=[];for(let a of r){let d=s.slice(a.start,a.end);if(d===","&&f===0)u.push(s.slice(l,a.start)),l=a.end;if(["(","[","{","<"].includes(d))f++;else if([")","]","}"].includes(d)||d===">"&&s[a.start-1]!=="=")f--}u.push(s.slice(l));for(let a of u){let d=t(a),x=-1,T=-1,w=0;for(let C of d){let S=a.slice(C.start,C.end);if(w===0&&S===":"&&x===-1)x=C.start;if(w===0&&S==="="&&a[C.end]!==">"){T=C.start;break}if(["(","[","{","<"].includes(S))w++;else if([")","]","}"].includes(S)||S===">"&&a[C.start-1]!=="=")w--}let A=a.slice(0,x!==-1?x:T!==-1?T:void 0).trim().replace(/^\.\.\./,"").replace(/\?$/,""),p=x===-1&&T!==-1&&!a.trim().startsWith("...")?we(A,a.slice(T+1)):null;if(p){for(let C of p)i.set(C.alias,c?.(C.value)??n(C.value,!1));continue}if(!v(A)){if(A.startsWith("{")||A.startsWith("["))for(let C of Ge(A))i.set(C,"unknown");continue}let m=x!==-1?a.slice(x+1,T!==-1?T:void 0).trim():"";if(!m&&T!==-1){let C=a.slice(T+1).trim();m=c?.(C)??n(C,!1)}if(m){if(T===-1&&a.slice(0,x).trim().endsWith("?"))m=`(${m}) | undefined`;i.set(A,m)}else i.set(A,"unknown")}return i}var Wt={string:{at:"string | undefined",charAt:"string",charCodeAt:"number",codePointAt:"number | undefined",concat:"string",endsWith:"boolean",includes:"boolean",indexOf:"number",lastIndexOf:"number",localeCompare:"number",normalize:"string",padEnd:"string",padStart:"string",repeat:"string",replace:"string",replaceAll:"string",search:"number",slice:"string",split:"string[]",startsWith:"boolean",substring:"string",toLocaleLowerCase:"string",toLocaleUpperCase:"string",toLowerCase:"string",toString:"string",toUpperCase:"string",trim:"string",trimEnd:"string",trimStart:"string",valueOf:"string"},number:{toExponential:"string",toFixed:"string",toLocaleString:"string",toPrecision:"string",toString:"string",valueOf:"number"},bigint:{toLocaleString:"string",toString:"string",valueOf:"bigint"},boolean:{toString:"string",valueOf:"boolean"}};function $a(e,c){let i=Object.hasOwn(Wt,e)?Wt[e]:void 0;return i&&Object.hasOwn(i,c)?i[c]:void 0}function W(e){return e.includes(`
6
- `)?e.replaceAll(`
7
- `,`
8
- `):e}function Jt(e,c){if(e=e.trim(),!e.startsWith("{")||!e.endsWith("}"))return;let i=e.slice(1,-1),s=t(i),r=0,l=0;for(let f=0;f<=s.length;f++){let u=s[f],a=u?i.slice(u.start,u.end):";";if(l===0&&(a===";"||a===",")){let d=i.slice(r,u?.start).trim(),x=d.indexOf(":");if(x!==-1&&d.slice(0,x).trim()===c)return d.slice(x+1).trim();r=u?.end??i.length}if(["(","[","{","<"].includes(a))l++;else if([")","]","}"].includes(a)||a===">"&&u&&i[u.start-1]!=="=")l--}return}function V(e,c,i,s,r=0,l=0){if(l>=lt)return"unknown";let f=e.trim();while(at(f))f=f.slice(1,-1).trim();let u=i?.(f);if(u)return u;if(rt(f))return"JSX.Element";if(f.startsWith("await ")){let b=V(f.slice(6),c,i,s,r,l+1);return b.startsWith("Promise<")&&b.endsWith(">")?b.slice(8,-1):b}if(c.has(f))return c.get(f);let a=/^([\w$]+)\.([\w$]+(?:\.[\w$]+)*)$/.exec(f),d;if(a){let b=c.get(a[1]),k=b&&Jt(b,a[2]);if(k)return k;if(b)d=`typeof ${f}`}if(f.startsWith("!"))return"boolean";if(f.startsWith("fetch("))return"Promise<Response>";if(re(f))return n(f,!1);let x=Rt(f);if(x){let b=V(x.whenTrue,c,i,s,r,l+1),k=V(x.whenFalse,c,i,s,r,l+1);return b===k?b:Et([b,k])}for(let b of["??","||","&&"]){let k=It(f,b);if(k!==-1){let O=V(f.slice(0,k),c,i,s,r,l+1),P=V(f.slice(k+b.length),c,i,s,r,l+1);return vt(O,P,b)}}let T=Qt(f);if(T&&s)return s(T,r);let w=jt(f);if(w)return s?s(w,r):w;if(Pt(f))return"boolean";let A=0;for(let b=f.length-1;b>=0;b--){let k=f.charCodeAt(b);if(k===41||k===93||k===125)A++;else if(k===40||k===91||k===123)A--;else if(A===0&&(k===43||k===45||k===42||k===47||k===37)){let O=V(f.slice(0,b),c,i,s,r,l+1),P=V(f.slice(b+1),c,i,s,r,l+1);if(k===43&&(O==="string"||P==="string"))return"string";if(O==="number"&&P==="number")return"number";break}}if(f.startsWith("[")&&f.endsWith("]")){let b=Q(f.slice(1,-1));if(b.some((k)=>k.trim().startsWith("..."))){let k=b.map((O)=>{let P=O.trim();if(!P)return"undefined";let I=P.startsWith("..."),j=V(I?P.slice(3):P,c,i,s,r,l+1);return I?`(NonNullable<${j}> extends Iterable<infer Element> ? Element : never)`:j});return`(${[...new Set(k)].join(" | ")||"never"})[]`}}let p=d??(f.startsWith("{")&&f.endsWith("}")?dt(f,!1,l+1,void 0,(b)=>V(b,c,i,s,r,l+1)):n(f,!1));if(p==="unknown"&&v(f)&&s)return s(`typeof ${f}`,r);let m=t(p),C="",S=0;for(let b=0;b<m.length;b++){let k=m[b];if(k.kind!=="word"||p.slice(k.start,k.end)!=="typeof")continue;let O=m[b+1];if(!O||O.kind!=="word")continue;let P=c.get(p.slice(O.start,O.end)),I=P,j=!P,z=k.start,F=O.end,E=b,L=[];b++;while(m[b+1]&&p.slice(m[b+1].start,m[b+1].end)==="."&&m[b+2]?.kind==="word"){let N=m[b+2];if(L.push(p.slice(N.start,N.end)),!j)P=`(${P})["${p.slice(N.start,N.end)}"]`;F=N.end,b+=2}let X=m[b+1];if(X&&p.slice(X.start,X.end)==="<"){let N=o(p,X.start,"<",">");if(N!==-1){F=N+1;while(m[b+1]&&m[b+1].start<=N)b++;P=void 0,I=void 0,j=!0}}let et=E>=2&&p.slice(m[E-2].start,m[E-2].end)==="ReturnType"&&p.slice(m[E-1].start,m[E-1].end)==="<"&&m[b+1]&&p.slice(m[b+1].start,m[b+1].end)===">",M=I&&et&&L.length===1?$a(I.trim(),L[0]):void 0;if(M){z=m[E-2].start,F=m[++b].end;let N=z===0&&F===p.length;C+=p.slice(S,z)+(N||!M.includes("|")?M:`(${M})`),S=F;continue}if(j&&et)z=m[E-2].start,F=m[++b].end;C+=p.slice(S,z)+(P??"unknown"),S=F}return C+p.slice(S)}function Qt(e){let c=t(e),i=0,s=-1;for(let l=0;l<c.length;l++){let f=c[l],u=e.slice(f.start,f.end);if(f.kind!=="punctuation"&&f.kind!=="word")continue;if(["(","[","{"].includes(u))i++;else if([")","]","}"].includes(u))i--;else if(!i&&u==="as"&&l>0&&e.slice(c[l-1].start,c[l-1].end)!==".")s=l}if(s===-1||s+1===c.length)return;let r=e.slice(c[s].end).trim();if(r==="const")return;i=0;for(let l of c.slice(s+1)){if(l.kind!=="punctuation")continue;let f=e.slice(l.start,l.end);if(!i&&["??","||","&&"].some((u)=>e.startsWith(u,l.start)))return;if(["(","[","{","<"].includes(f))i++;else if([")","]","}",">"].includes(f))i--;else if(!i&&["+","-","*","/","%","=","!",";"].includes(f))return}return r}function It(e,c){let i=0;for(let s of t(e)){if(s.kind!=="punctuation")continue;let r=e.slice(s.start,s.end);if(["(","[","{"].includes(r))i++;else if([")","]","}"].includes(r))i--;if(!i&&e.startsWith(c,s.start))return s.start}return-1}function Xt(e){if(e.includes("=>"))return null;let c=[],i=0,s=0;for(let r=0;r<=e.length;r++){let l=r===e.length?"|":e[r];if(l==="'"||l==='"'||l==="`"){r++;while(r<e.length&&e[r]!==l)r+=e[r]==="\\"?2:1;if(r>=e.length)return null}else if(l==="("||l==="["||l==="{"||l==="<")i++;else if(l===")"||l==="]"||l==="}"||l===">")i--;else if(l==="|"&&i===0){let f=e.slice(s,r).trim();if(f)c.push(f);s=r+1}if(i<0)return null}return i===0?c:null}function Yt(e,c){let i=Xt(c);if(!i)return`${e} | ${c}`;let s=[];for(let d of[e,...i]){if(d==="unknown")return"unknown";if(!s.includes(d))s.push(d)}let r=s.includes("boolean")||s.includes("true")&&s.includes("false"),l=s.includes("string"),f=s.includes("number"),u=[],a=!1;for(let d of s)if(r&&(d==="true"||d==="false"||d==="boolean")){if(!a)u.push("boolean");a=!0}else if(l&&Zt(d))continue;else if(f&&/^-?\d+(?:\.\d+)?$/.test(d))continue;else u.push(d);return u.join(" | ")}function Zt(e){let c=e[0];return e.length>=2&&(c==="'"||c==='"')&&e.endsWith(c)&&!e.slice(1,-1).includes(c)}function vt(e,c,i){let s=Z(c)!==-1?`(${c.trim()})`:c;if(e.trim()==="unknown")return i==="&&"||s.trim()==="unknown"?"unknown":`{} | ${s}`;let r=e.trim();if(r==="boolean"||r==="string"||r==="number"){if(i==="??")return r;return Yt(i==="||"?r==="boolean"?"true":r:r==="boolean"?"false":r==="string"?"''":"0",s)}let l="false | 0 | 0n | '' | null | undefined";if(i==="??")return`([${e}] extends [NonNullable<${e}>] ? ${e} : NonNullable<${e}> | ${s})`;if(i==="||")return`([${e}] extends [object] ? ${e} : [Exclude<${e}, object> & (${l})] extends [never] ? ${e} : Exclude<NonNullable<${e}>, ${l}> | ${s})`;return`([${e}] extends [object] ? ${s} : [${e}] extends [${l}] ? ${e} : unknown extends (${e}) ? ${e} : (Exclude<${e}, object> & (${l})) | ${s})`}function te(e){let c=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]: __dtsx_spread_value[__dtsx_spread_key] } : never)`,i=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]?: __dtsx_spread_value[__dtsx_spread_key] } : never)`;return`([${e}] extends [null | undefined] ? {} : [${e}] extends [NonNullable<${e}>] ? ${c} : ${i})`}function ne(e,c){let i=e.trim();while(at(i))i=i.slice(1,-1).trim();let s=It(i,"??");if(s!==-1&&i.slice(s+2).trim()==="{}")return te(c(i.slice(0,s)));let r=Rt(i);if(r){if(r.whenFalse.trim()==="{}")return`Partial<${c(r.whenTrue)}>`;if(r.whenTrue.trim()==="{}")return`Partial<${c(r.whenFalse)}>`}return c(i)}function Et(e){return e.map((c)=>e.length>1&&Z(c)!==-1?`(${c})`:c).join(" | ")}function st(e){let c=0;while(c<e.length){let r=e.charCodeAt(c);if(r<=32)c++;else if(r===47&&e.charCodeAt(c+1)===47){c+=2;while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++}else if(r===47&&e.charCodeAt(c+1)===42){let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+2}else break}let i=c,s=c;while(s<e.length){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=J(e,s,r),i=s;continue}if(r===92){s=Math.min(s+2,e.length),i=s;continue}if(r===47&&e.charCodeAt(s+1)===47){while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(r===47&&e.charCodeAt(s+1)===42){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+2;continue}if(s++,r>32)i=s}return e.slice(c,i)}function jt(e){if(!e.startsWith("<"))return;let c=_(e)(0,0);if(!c||c.parameters||c.completeOperand||!e.slice(c.end).trim()||!nt(e.slice(c.end).trim()))return;return e.slice(1,c.end-1).trim()}function nt(e){e=st(e);let c=0,i;for(let s=0;s<e.length;s++){let r=e[s];if(r==="'"||r==='"'||r==="`"){let l=s+1;while(l<e.length&&e[l]!==r){if(e[l]==="\\")l++;l++}s=l;continue}if(r==="/"){if(e[s+1]==="/"){let l=e.indexOf(`
9
- `,s+2);s=l===-1?e.length:l;continue}if(e[s+1]==="*"){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1;continue}if(h(e,s)){s=g(e,s)-1;continue}}if(r==="<"&&c===0){i??=_(e);let l=i(s,0);if(l){s=l.end-1;continue}}if(r==="("||r==="["||r==="{")c++;else if(r===")"||r==="]"||r==="}")c--;else if(c!==0)continue;else if(r==="?"){if(e[s+1]!==".")return!1}else if("=!<>&|+-*/%,:".includes(r))return!1;else if(r===" "||r==="\t"||r===`
10
- `||r==="\r"){let l=e.slice(s).trimStart(),f=/[A-Za-z]+$/.exec(st(e.slice(0,s)))?.[0];if(s=e.length-l.length-1,f&&["new","void","typeof","delete","await","yield"].includes(f))continue;if(l&&l[0]!=="."&&l[0]!=="?"&&l[0]!=="("&&l[0]!=="[")return!1}}return!0}function re(e){if(e.startsWith("function")&&tt(e,0,8))return!0;let c=Z(e);if(c===-1)return!1;let i=e.slice(0,c).trim();if(i.startsWith("async")&&tt(i,0,5))i=i.slice(5).trim();if(i.startsWith("<")){let r=o(i,0,"<",">");if(r===-1)return!1;i=i.slice(r+1).trim()}if(i.startsWith("(")){let r=o(i,0,"(",")");if(r===-1)return!1;let l=i.slice(r+1).trim();if(l&&!l.startsWith(":"))return!1}let s=Ct(i);return at(s.params)||v(s.params)}function at(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let c=0;for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(s===40)c++;else if(s===41&&--c===0)return i===e.length-1}return!1}function Rt(e){let c=0,i=-1;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=J(e,s,r)-1;continue}if(r===47&&(e.charCodeAt(s+1)===47||e.charCodeAt(s+1)===42)){if(e.charCodeAt(s+1)===47)while(s+1<e.length&&e.charCodeAt(s+1)!==10&&e.charCodeAt(s+1)!==13)s++;else{let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1}continue}if(r===40||r===91||r===123)c++;else if(r===41||r===93||r===125)c--;else if(r===63&&c===0&&e.charCodeAt(s+1)!==63)i=s;else if(r===58&&c===0&&i!==-1)return{whenTrue:st(e.slice(i+1,s)),whenFalse:st(e.slice(s+1))}}return null}function tt(e,c,i){return(c===0||!q(e.charCodeAt(c-1)))&&!q(e.charCodeAt(c+i))}function Mt(e,c){let i=c;while(i<e.length){if(e.charCodeAt(i)<=32){i++;continue}if(e.startsWith("//",i)){while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(e.startsWith("/*",i)){let s=e.indexOf("*/",i+2);i=s<0?e.length:s+2;continue}break}return i}function ie(e,c){let i=0,s=0,r=0,l=!1,f=!1;for(let u=c;u<e.length;u++){if(u=Mt(e,u),u>=e.length)break;let a=e.charCodeAt(u);if(a===34||a===39||a===96){u=J(e,u,a)-1,f=!1;continue}if(q(a)||a>=128){let d=u;while(u+1<e.length&&(q(e.charCodeAt(u+1))||e.charCodeAt(u+1)>=128))u++;f=l&&["keyof","typeof","readonly","unique","new","abstract","infer","extends"].includes(e.slice(d,u+1));continue}if(a===61&&e.charCodeAt(u+1)===62){u++,f=l;continue}if(a===40)i++;else if(a===41)i--,f=!1;else if(a===91)s++;else if(a===93)s--,f=!1;else if(a===60&&i===0&&s===0)r++;else if(a===62&&r>0&&i===0&&s===0)r--,f=!1;else if(a===123)if(i||s||r||l&&f)u=ot(e,u)-1,f=!1;else return u;else if(i===0&&s===0&&r===0){if(a===58)l=!0,f=!0;else if(l&&[124,38,63].includes(a))f=!0;else if(a===59)return-1}}return-1}function ot(e,c){let i=1,s=c+1;while(s<e.length&&i>0){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=J(e,s,r);continue}if(r===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(r===47&&e.charCodeAt(s+1)===42){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+2;continue}if(r===123)i++;else if(r===125)i--;s++}return s}function J(e,c,i){let s=c+1;while(s<e.length){let r=e.charCodeAt(s);if(r===92){s+=2;continue}if(i===96&&r===36&&e.charCodeAt(s+1)===123){s=ot(e,s+1);continue}if(s++,r===i)break}return s}function se(e,c){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!c||e.includes("${")||e.includes(`
11
- `)||e.includes("\r"))return"string";return e}function Kt(e,c){let i=t(e),s=(a)=>i[a]?e.slice(i[a].start,i[a].end):"";if(s(0)!=="new"||i[1]?.kind!=="word"||["class","function","new","super"].includes(s(1)))return"unknown";let r=2,l=[s(1)];while(s(r)==="."&&i[r+1]?.kind==="word")l.push(s(r+1)),r+=2;let f=l.join(".");if(!c&&(f.charCodeAt(0)<65||f.charCodeAt(0)>90))return"unknown";let u="";if(s(r)==="<"){let a=i[r].start,d=_(e)(a,0);if(!d||!d.completeOperand||d.parameters)return"unknown";u=e.slice(a,d.end);while(r<i.length&&i[r].start<d.end)r++}if(r<i.length){if(s(r)!=="(")return"unknown";let a=0,d=!1;for(;r<i.length;r++)if(s(r)==="(")a++;else if(s(r)===")"&&--a===0){d=r===i.length-1;break}if(!d)return"unknown"}if(c)return c(f)?f+u:`InstanceType<typeof ${f}${u}>`;if(u)return f+u;switch(f){case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"Array":return"any[]";case"Object":return"object";case"Promise":return"Promise<any>";default:return f}}function oe(e){return"{ new (...args: any[]): any }"}function Nt(e,c,i=0,s){if(e.startsWith("Promise.resolve(")){let l=e.indexOf(")",16);if(l!==-1){let f=e.slice(16,l).trim();if(f)return`Promise<${n(f,c,!1,i+1,s)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let r=e.indexOf("[",12),l=e.lastIndexOf("]");if(r!==-1&&l>r){let f=e.slice(r+1,l).trim(),u=Q(f),a=[];for(let d=0;d<u.length;d++){let x=u[d].trim();if(x.startsWith("Promise.resolve(")){let T=Nt(x,c,i+1,s),w=T.indexOf("<"),A=T.lastIndexOf(">");a.push(w!==-1&&A>w?T.slice(w+1,A):"unknown")}else a.push(n(x,c,!1,i+1,s))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function Be(e,c,i=0,s){let r=e.slice(1,-1).trim();if(!r)return"never[]";if(i>=lt)return"unknown[]";let l=Q(r),f=!1;for(let A=0;A<l.length;A++){let p=l[A],m=p.length;while(m>0&&p.charCodeAt(m-1)<=32)m--;if(m>=8&&p.slice(m-8,m)==="as const"){f=!0;break}}if(f){let A=[];for(let p=0;p<l.length;p++){let m=l[p].trim();if(m.endsWith("as const")){let C=m.slice(0,-8).trim();if(C.startsWith("[")&&C.endsWith("]")){let S=C.slice(1,-1).trim(),b=Q(S),k=[];for(let O=0;O<b.length;O++)k.push(n(b[O].trim(),!0,!1,i+1,s));A.push(`readonly [${k.join(", ")}]`)}else A.push(n(C,!0,!1,i+1,s))}else if(m.startsWith("[")&&m.endsWith("]"))A.push(Be(m,!0,i+1,s));else A.push(n(m,!0,!1,i+1,s))}return`readonly [
12
- ${A.join(` |
13
- `)}
14
- ]`}let u=ft&&!c,a=[],d=[];for(let A of l){let p=A.trim(),m=D;if(D=null,p.startsWith("...")){let C=p.slice(3).trim(),S=n(C,!1,!1,i+1,s);if(S.endsWith("[]"))a.push(S.slice(0,-2));else if(S.startsWith("readonly [")&&S.endsWith("]"))a.push(S.slice(10,-1));else if(Y(C))a.push(`(typeof ${C})[number]`);else a.push("unknown")}else if(p.startsWith("[")&&p.endsWith("]"))a.push(Be(p,c,i+1,s));else a.push(Ht(p,c,i+1,s));if(u)d.push(D);D=m}if(u)if(mt(e))D=it(e);else{let A=[];for(let p=0;p<l.length;p++){let m=l[p].trim();if(m.endsWith("as const"))continue;if(ct(m)||m==="null"||m==="undefined")A.push(m);else if(m.startsWith("[")&&mt(m))A.push(it(m));else if(m.startsWith("{")){if(d[p])A.push(d[p])}else{let C=n(m,!1,!1,0,s);if(C!=="unknown")A.push(C)}}if(A.length>0)D=`[${A.join(", ")}]`}if(c)return`readonly [${a.join(", ")}]`;let x=new Set,T=[],w=!0;for(let A of a){if(!x.has(A))x.add(A),T.push(A);if(w){if(!(y(A)||A==="true"||A==="false"||A.charCodeAt(0)===34&&A.charCodeAt(A.length-1)===34||A.charCodeAt(0)===39&&A.charCodeAt(A.length-1)===39))w=!1}}if(w&&a.length<=10)return`readonly [${a.join(", ")}]`;if(T.length===1)return`${T[0]}[]`;return`(${T.join(" | ")})[]`}function Q(e){let c=[],i=0,s=!1,r=0,l=-1,f=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(s){if(a===92)u++;else if(a===r)s=!1;f=u+1;continue}if(a===47&&e.charCodeAt(u+1)===47){let d=e.indexOf(`
15
- `,u+2);u=(d===-1?e.length:d)-1;continue}if(a===47&&e.charCodeAt(u+1)===42){let d=e.indexOf("*/",u+2);u=(d===-1?e.length:d+2)-1;continue}if(a===32||a===9||a===10||a===13)continue;if(a===44&&i===0){if(l!==-1)c.push(e.slice(l,f));l=-1;continue}if(a===34||a===39||a===96)s=!0,r=a;else if(a===91||a===123||a===40)i++;else if(a===93||a===125||a===41)i--;if(l===-1)l=u;f=u+1}if(l!==-1)c.push(e.slice(l,f));return c}function ct(e){if(y(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function Lt(e){return e==="number"||e==="string"||e==="boolean"}function ir(e){let c=[],i=0;while(i<e.length){while(i<e.length&&e.charCodeAt(i)<=32)i++;if(e.startsWith("/*",i)){let s=e.indexOf("*/",i+2);if(s===-1)break;c.push(e.slice(i,s+2)),i=s+2}else if(e.startsWith("//",i)){let s=i;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;c.push(e.slice(i,s).trimEnd()),i=s}else break}return c}function qt(e,c,i){let s=c.trim();if(!Lt(i)||!ct(s))return"";let r=(e??[]).map((f)=>f.trim()).filter((f)=>f.startsWith("/**")||f.startsWith("//")).join(`
16
- `),l;if(r.includes("@defaultValue"))l=r;else{let f=`@defaultValue ${be(s)}`;if(!r)l=`/** ${f} */`;else{let u=r.lastIndexOf("*/");if(u!==-1){let a=r.slice(0,u).trimEnd();if(a.startsWith("/** ")&&!a.includes(`
17
- `))a=`/**
18
- * ${a.slice(4)}`;l=`${a}
19
- * ${f}
20
- */`}else l=`/**
21
- * ${r.startsWith("// ")?r.slice(3):r.startsWith("//")?r.slice(2):r}
22
- * ${f}
23
- */`}}return l.split(`
24
- `).map((f)=>{let u=f.trim();if(!u)return"";return u.startsWith("*")?` ${u}`:` ${u}`}).join(`
25
- `)+`
26
- `}function mt(e){let c=!1,i=0,s=e.length;for(let r=0;r<s;r++){let l=e.charCodeAt(r);if(c){if(l===92){r++;continue}if(l===i)c=!1;continue}if(l===34||l===39||l===96){c=!0,i=l;continue}if(l===61&&r+1<s&&e.charCodeAt(r+1)===62)return!1;if(l===47&&(e.charCodeAt(r+1)===47||e.charCodeAt(r+1)===42))return!1;if(l>=97&&l<=122){let f=r;while(r<s&&(e.charCodeAt(r)>=97&&e.charCodeAt(r)<=122||e.charCodeAt(r)>=65&&e.charCodeAt(r)<=90||e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57||e.charCodeAt(r)===95||e.charCodeAt(r)===36))r++;let u=e.slice(f,r);if(u==="new"||u==="async"||u==="await"||u==="function"||u==="yield"||u==="console"||u==="process")return!1;let a=r;while(a<s&&e.charCodeAt(a)<=32)a++;if(a<s&&e.charCodeAt(a)===40)return!1;r--}}return!0}function dt(e,c,i=0,s,r){let l=e.slice(1,-1).trim();if(!l)return"{}";if(i>=lt)return"Record<string, unknown>";let f=ae(l),u=new Set(f.flatMap(([S])=>{let b=Tt(At(S).key);return b?.kind==="get"?[b.name]:[]})),a=[],d=[],x=[],T=!1,w=ft&&!c,A=[],p=0;for(let[S,b]of f){let{comments:k,key:O}=At(S),P=k?`${k}
27
- `:"",I=Tt(O);if(I&&cr(I.name))continue;let j=O,z=!1;if(O==="..."){let R=b.trim(),G=r?ne(R,r):Y(R)?`typeof ${R}`:n(R,c,!1,i+1,s);if(G!=="unknown")d.push(G);if(w&&(Y(R)||R.startsWith("{")))A.push(`...${it(R)}`);continue}let F=D;D=null;let E,L=b.trim();if(L===O&&v(L))E=r?.(b)??(c?void 0:s?.mutableBindingTypes?.get(L))??`typeof ${L}`;else if(he(L)){z=!0;let R=ge(O);if(R){j=R.name;let G="";if(L.startsWith("async "))G="async ";if(L.charCodeAt(G.length)===42)G+="*";E=St(R.name,G+R.typeParams+L.slice(G.length))}else E=St(O,L)}else{if(E=r?.(b)??n(b,c,!1,i+1,s),E==="unknown"&&Y(L))E=(c?void 0:s?.mutableBindingTypes?.get(L))??`typeof ${L}`;if(E.includes("=>")||E.includes("function")||E.includes("async"))E=xt(E)}let X=D;D=F;let et=j,M=b.trim(),N=or(j,s);if(!ar(I?.name??j,s)&&!(I?.kind==="set"&&u.has(I.name)))x.push(I?de(I.kind,E):E);if(N&&"index"in N)T=!0;else{if(N&&"name"in N)j=N.name;if(I){let R=ue(I.kind,I.name,E);if(R){a.push(`${P}${W(R)}`);continue}}if(!c&&Lt(E)&&ct(M))a.push(`${P}/** @defaultValue ${be(M)} */
28
- ${j}: ${W(E)}`);else a.push(`${P}${c?"readonly ":""}${j}: ${W(E)}`)}if(w){let R=Ot(et);if(M.endsWith("as const"));else if(ct(M))A.push(`${R}: ${M}`);else if(M.startsWith("[")&&mt(M))A.push(`${R}: ${it(M)}`);else if(M.startsWith("{")){if(X)A.push(`${R}: ${X}`)}else if(z)A.push(`${R}: ${ht(xt(E))}`),p++;else if(!M.startsWith("[")&&(M.includes("=>")||M.startsWith("function")||M.startsWith("async"))){let G=pt(M,!1,0,!0);A.push(`${R}: ${ht(G)}`),p++}}}if(w&&A.length>p){let S=i>0?(i-1)/2:0,b=`{ ${A.join(", ")} }`;if(b.length<=80)D=b;else{let k=" ".repeat((S+1)*2),O=" ".repeat(S*2);D=`{
29
- ${k}${A.join(`,
30
- ${k}`)}
31
- ${O}}`}}if(T&&d.length===0){let S=[...new Set(x)].map((b)=>b.includes("=>")||b.includes(" & ")?`(${b})`:b);a.unshift(`${c?"readonly ":""}[x: string]: ${W(S.join(" | "))}`)}let m=a.length>0?`{
32
- ${a.join(`;
33
- `)}
34
- }`:"{}";if(d.length===0)return m;let C=d[0];for(let S=1;S<d.length;S++)C=`Omit<${C}, keyof ${d[S]}> & ${d[S]}`;return a.length>0?`Omit<${C}, keyof ${m}> & ${m}`:C}function v(e){if(!e)return!1;let c=e.charCodeAt(0);if(!(c>=65&&c<=90||c>=97&&c<=122||c===95||c===36||c>127))return!1;for(let i=1;i<e.length;i++)if(!q(e.charCodeAt(i)))return!1;return!0}function Y(e){let c=e.split(".");return c.length>0&&c.every(v)}function ce(e){let c=!1,i="";for(let s=0;s<e.length;s++){let r=e[s];if(c){if(r==="\\")s++;else if(r===i)c=!1;continue}if(r==='"'||r==="'"||r==="`"){c=!0,i=r;continue}if(r==="(")return s;if(r==="<"){let l=o(e,s,"<",">");if(l!==-1)s=l}}return-1}function U(e){if(e.length<3||!e.endsWith(")"))return null;let c=ce(e);if(c===-1||o(e,c,"(",")")!==e.length-1)return null;let i=e.slice(0,c).trim(),s=!1;if(i.endsWith("?."))s=!0,i=i.slice(0,-2).trim();let r=i,l=!1,f=i.indexOf("<");if(f!==-1){if(o(i,f,"<",">")!==i.length-1)return null;r=i.slice(0,f).trim(),l=!0}if(r.endsWith("?.")){s=!0;let A=i.slice(r.length);r=r.slice(0,-2).trim(),i=r+A}if(!Y(r))return null;let u=e.slice(c+1,-1).trim(),a=Z(u)!==-1||u.startsWith("function")||u.startsWith("async function"),d=Y(u),x=!a&&u.endsWith(")")&&U(u)!==null,T=r.indexOf(".");if(T!==-1){if(r.indexOf(".",T+1)!==-1)return null}else if(!l&&!s&&!a&&!d&&!x)return null;let w=`ReturnType<typeof ${i}>`;return s?`ReturnType<NonNullable<typeof ${i}>> | (null extends typeof ${r} ? undefined : undefined extends typeof ${r} ? undefined : never)`:w}function xt(e){let i=e.split(`
35
- `).map((x)=>_t(x)).join(`
36
- `),s=i.indexOf("async");if(s!==-1){let x=s>0?i.charCodeAt(s-1):32,T=s+5<i.length?i.charCodeAt(s+5):32;if(!q(x)&&!q(T))i=(i.slice(0,s)+i.slice(s+5)).trim()}let r=i.indexOf("(");if(r!==-1){let x=o(i,r,"(",")");if(x!==-1){let T=i.slice(r,x+1),w=ye(T);i=i.slice(0,r)+w+i.slice(x+1)}}let l=i.length,f="",u=[],a=!1,d=!1;for(let x=0;x<l;x++){let T=i.charCodeAt(x);if(T===123||T===40)u.push(T);else if(T===125||T===41)u.pop();if(T<=32){if(a=!0,T===10||T===13)d=!0;continue}if(a&&f.length>0){let A=(u.length>0?u[u.length-1]:0)===123;if(d&&A){let p=f.charCodeAt(f.length-1),m=p===59||p===44||p===123||T===125,C=f.length>=2&&f.charCodeAt(f.length-1)===47&&f.charCodeAt(f.length-2)===42;if(!m&&!C)f+="; ";else f+=" "}else f+=" "}a=!1,d=!1,f+=i[x]}return f.trim()}function q(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function ye(e){let c=e.trim(),i,s=!1;if(c.startsWith("(")&&c.endsWith(")"))i=c.slice(1,-1),s=!0;else i=c;let r=i.trim();if(!r)return s?"()":"";let l=!1;{let p=0;for(let m=0;m<r.length;m++){let C=r.charCodeAt(m);if(C===40||C===60||C===91||C===123)p++;else if(C===41||C===93||C===125||C===62&&r.charCodeAt(m-1)!==61)p--;else if(p===0&&C===61){let S=m>0?r.charCodeAt(m-1):0,b=m+1<r.length?r.charCodeAt(m+1):0;if(S!==61&&S!==33&&S!==60&&S!==62&&b!==61&&b!==62){l=!0;break}}}}if(!l)return c;let f=[],u=[],a=0,d=0,x=!1,T=0;for(let p=0;p<=r.length;p++){if(p===r.length){f.push(r.slice(a));break}let m=r.charCodeAt(p);if(x){if(m===92){p++;continue}if(m===T)x=!1;continue}if(m===47&&p+1<r.length){let C=r.charCodeAt(p+1);if(C===42){p+=2;while(p+1<r.length&&!(r.charCodeAt(p)===42&&r.charCodeAt(p+1)===47))p++;p++;continue}if(C===47){while(p<r.length&&r.charCodeAt(p)!==10)p++;continue}}if(m===39||m===34||m===96){x=!0,T=m;continue}if(m===40||m===60||m===91||m===123)d++;else if(m===41||m===93||m===125||m===62&&r.charCodeAt(p-1)!==61)d--;else if(m===44&&d===0){f.push(r.slice(a,p));let C=",",S=p+1;while(S<r.length&&r.charCodeAt(S)<=32)C+=r[S],S++;u.push(C),a=S}}let w=[];for(let p of f){let m=p.trim();if(!m){w.push(p);continue}if(m.startsWith("//"))continue;let C=_t(m),S=p.slice(0,p.length-p.trimStart().length);w.push(S+le(C))}let A=w[0]||"";for(let p=1;p<w.length;p++)A+=(u[p-1]||", ")+w[p];return _e(s?`(${A})`:A)}function _t(e){let c=!1,i=0;for(let s=0;s<e.length-1;s++){let r=e.charCodeAt(s);if(c){if(r===92){s++;continue}if(r===i)c=!1;continue}if(r===39||r===34||r===96){c=!0,i=r;continue}if(r===47&&e.charCodeAt(s+1)===47)return e.slice(0,s).trimEnd()}return e}function le(e){if(e.startsWith("..."))return e;let c=-1,i=-1,s=0,r=!1,l=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(r){if(a===92){u++;continue}if(a===l)r=!1;continue}if(a===47&&u+1<e.length){let d=e.charCodeAt(u+1);if(d===42){u+=2;while(u+1<e.length&&!(e.charCodeAt(u)===42&&e.charCodeAt(u+1)===47))u++;u++;continue}if(d===47){while(u<e.length&&e.charCodeAt(u)!==10)u++;continue}}if(a===39||a===34||a===96){r=!0,l=a;continue}if(a===40||a===60||a===91||a===123)s++;else if(a===41||a===93||a===125||a===62&&e.charCodeAt(u-1)!==61)s--;else if(s===0){if(a===58&&c===-1)c=u;else if(a===61&&i===-1&&(u===0||e.charCodeAt(u-1)!==61)&&(u+1>=e.length||e.charCodeAt(u+1)!==61&&e.charCodeAt(u+1)!==62))i=u}}let f=i!==-1;if(c!==-1&&(i===-1||c<i)){let u=e.slice(0,c).trim(),a=i!==-1?e.slice(c+1,i).trim():e.slice(c+1).trim(),d=f&&!u.endsWith("?")?"?":"";return`${u}${d}: ${a}`}else if(i!==-1){let u=e.slice(0,i).trim(),a=we(u,e.slice(i+1));if(a)return je(a,bt);let d=!u.endsWith("?")?"?":"";return`${u}${d}: ${bt(e.slice(i+1))}`}return e}function bt(e){let c=e.trim();if(c==="true"||c==="false")return"boolean";if(y(c))return"number";if(c.startsWith("'")&&c.endsWith("'")||c.startsWith('"')&&c.endsWith('"'))return"string";if(c.startsWith("["))return"unknown[]";if(c.startsWith("{"))return"Record<string, unknown>";return"unknown"}function fe(e){let c=0,i=e.length;while(c<i){while(c<i&&(e.charCodeAt(c)===32||e.charCodeAt(c)===9||e.charCodeAt(c)===10||e.charCodeAt(c)===13))c++;if(c+1<i&&e.charCodeAt(c)===47&&e.charCodeAt(c+1)===42){c+=2;while(c+1<i&&!(e.charCodeAt(c)===42&&e.charCodeAt(c+1)===47))c++;c+=2;continue}break}return c}function At(e){let c=[],i=0,s=e.length;while(i<s){while(i<s&&e.charCodeAt(i)<=32)i++;if(i+1>=s||e.charCodeAt(i)!==47||e.charCodeAt(i+1)!==42)break;let r=i;i+=2;while(i+1<s&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i=Math.min(i+2,s),c.push(e.slice(r,i).trim())}return{comments:c.join(`
37
- `),key:e.slice(i).trim()}}function ae(e){let c=[],i="",s="",r=0,l=!1,f="",u=!0,a=!1,d=0,x=!1,T=!1,w=0,A=!1,p=!1;for(let m=0;m<e.length;m++){let C=e.charCodeAt(m),S=m>0?e.charCodeAt(m-1):0,b=m<e.length-1?e.charCodeAt(m+1):0;if(!l&&!a&&C===47&&b===47){i=i.replace(/[ \t]+$/,""),m+=2;while(m<e.length&&e.charCodeAt(m)!==10)m++;m--;continue}if(!l&&!a&&C===47&&b===42){a=!0,d=1,i+="/*",m++;continue}else if(a&&C===42&&b===47){if(d--,i+="*/",m++,d===0)a=!1;continue}else if(a&&C===47&&b===42){d++,i+="/*",m++;continue}let k=e[m];if(!l&&!a&&(C===34||C===39||C===96))l=!0,f=k,i+=k;else if(l&&k===f&&S!==92)l=!1,i+=k;else if(!l&&!a)if(C===46&&b===46&&e.charCodeAt(m+2)===46&&r===0&&u)s=`${i.trim()}...`,i="",u=!1,A=!1,m+=2;else if(C===40&&r===0&&u&&w===0){s=i.trim();let O=fe(s),P=O>0?s.slice(0,O):"",I=s.slice(O),j="";if(I.startsWith("async ")||I.startsWith("async\t")||I.startsWith(`async
38
- `))I=I.slice(6).trimStart(),j="async ";if(I.startsWith("*"))I=I.slice(1).trimStart(),j+="*";s=P+I,i=j+k,u=!1,A=!0,p=!1,r=1}else if(C===123||C===91||C===40){if(r++,i+=k,p&&C===123)p=!1}else if(C===125||C===93||C===41){if(r--,i+=k,C===41&&r===0&&!u&&!A)x=!0;if(A){if(C===41&&r===0&&!p)p=!0;else if(C===125&&r===0)A=!1,p=!1}}else if(C===58&&r===0&&u&&w===0)s=i.trim(),i="",u=!1;else if(C===58&&r===0&&x)T=!0,i+=k;else if(C===60&&T)w++,i+=k;else if(C===60&&u&&r===0)w++,i+=k;else if(C===62&&w>0&&S!==61)w--,i+=k;else if(C===61&&b===62&&T&&w===0)T=!1,x=!1,i+=k;else if(C===44&&r===0&&w===0&&!p){if(s&&i.trim()){let O=i.trim();c.push([s,O])}else if(u&&i.trim())kt(c,i.trim());i="",s="",u=!0,x=!1,T=!1,w=0}else i+=k;else i+=k}if(s&&i.trim()){let m=i.trim();c.push([s,m])}else if(u&&i.trim())kt(c,i.trim());return c}function kt(e,c){let{comments:i,key:s}=At(c);if(v(s))e.push([i?`${i}
39
- ${s}`:s,s]);else if(s.startsWith("...")&&s.length>3)e.push(["...",s.slice(3).trim()])}function Tt(e){let c=e.trim();if(c.startsWith("get ")&&c.length>4){let i=c.slice(4).trim();if(i)return{kind:"get",name:i}}if(c.startsWith("set ")&&c.length>4){let i=c.slice(4).trim();if(i)return{kind:"set",name:i}}return null}function ue(e,c,i){let s=i.trim();if(s.charCodeAt(0)!==40)return null;let r=o(s,0,"(",")");if(r===-1)return null;let l=s.slice(1,r).trim(),f=s.slice(r+1).trimStart();if(!f.startsWith("=>"))return null;let u=f.slice(2).trim();if(e==="get")return`get ${c}(): ${u||"unknown"}`;return`set ${c}(${l})`}function de(e,c){let i=c.trim(),s=o(i,0,"(",")");if(!i.startsWith("(")||s===-1)return"unknown";if(e==="get"){let u=i.slice(s+1).trim();return u.startsWith("=>")?u.slice(2).trim():"unknown"}let r=i.slice(1,s).trim(),l=r.startsWith("{")?o(r,0,"{","}"):r.startsWith("[")?o(r,0,"[","]"):0,f=r.indexOf(":",Math.max(0,l));return f===-1?"unknown":r.slice(f+1).trim()}function he(e){let c=e;if(c.startsWith("async ")||c.startsWith("async\t"))c=c.slice(5).trimStart();if(c.startsWith("*"))c=c.slice(1).trimStart();if(!c.startsWith("("))return!1;let i=0;for(let s=0;s<c.length;s++){let r=c.charCodeAt(s);if(r===40)i++;else if(r===41){if(i--,i===0){let l=c.slice(s+1).trimStart();if(l.startsWith("{"))return!0;if(l.startsWith(":")){let f=yt(l,1);if(f?.kind==="arrow")return!1;if(f?.kind==="body")return!0}return!1}}}return!1}function ge(e){let c=e.trimEnd();if(!c.endsWith(">"))return null;let i=0,s=-1;for(let l=c.length-1;l>=0;l--){let f=c.charCodeAt(l);if(f===62){if(l>0&&c.charCodeAt(l-1)===61)continue;i++}else if(f===60){if(i--,i===0){s=l;break}}}if(s===-1)return null;let r=c.slice(0,s).trimEnd();if(!r)return null;return{name:r,typeParams:c.slice(s)}}function St(e,c){let i=c.trimStart(),s=!1,r=!1;if(i.startsWith("async ")||i.startsWith("async\t"))s=!0,i=i.slice(5).trimStart();if(i.startsWith("*"))r=!0,i=i.slice(1).trimStart();let l="";if(i.charCodeAt(0)===60){let w=0,A=-1;for(let p=0;p<i.length;p++)if(i.charCodeAt(p)===60)w++;else if(i.charCodeAt(p)===62&&!(p>0&&i.charCodeAt(p-1)===61)){if(w--,w===0){A=p;break}}if(A!==-1)l=i.slice(0,A+1),i=i.slice(A+1).trimStart()}let f=i.indexOf("("),u=o(i,f,"(",")");if(f===-1||u===-1)return"() => unknown";let a=i.slice(f,u+1),d="unknown",x=i.slice(u+1).trimStart();if(x.charCodeAt(0)===58){let w=x.slice(1),A=yt(w,0);if(A)d=w.slice(0,A.index).trim();else d=w.trim()}if(d==="unknown"&&!r&&x.charCodeAt(0)===123){let w=o(x,0,"{","}");if(w!==-1){let A=B(x.slice(1,w),s,a);if(A!=="unknown"&&A!=="Promise<unknown>")d=s&&A.startsWith("Promise<")?A.slice(8,-1):A;else if(s)d="Promise<unknown>"}}if(d==="unknown"){if(s&&r)d="AsyncGenerator<unknown, void, unknown>";else if(r)d="Generator<unknown, void, unknown>";else if(s)d="Promise<void>"}else if(s&&!d.startsWith("Promise<")&&!d.startsWith("AsyncGenerator<"))d=`Promise<${d}>`;let T=ye(a);return`${l}${T} => ${d}`}function yt(e,c){let i=0,s=0,r=0,l=0,f=!1,u=0;for(let a=c;a<e.length;a++){let d=e.charCodeAt(a);if(f){if(d===92)a++;else if(d===u)f=!1;continue}if(d===34||d===39||d===96){f=!0,u=d;continue}if(d===40)i++;else if(d===41&&i>0)i--;else if(d===91)s++;else if(d===93&&s>0)s--;else if(d===60)r++;else if(d===62&&r>0&&e.charCodeAt(a-1)!==61)r--;else if(d===125&&l>0)l--;else if(d===123){let x=i>0||s>0||r>0||l>0,T=e.slice(c,a).trimEnd(),w=T.charCodeAt(T.length-1),A=T.length===0||w===38||w===124||w===40||w===44||w===58||w===61||w===91;if(x||A)l++;else return{index:a,kind:"body"}}else if(d===61&&a+1<e.length&&e.charCodeAt(a+1)===62&&i===0&&s===0&&r===0&&l===0)return{index:a,kind:"arrow"}}return null}function o(e,c,i,s){let r=0;for(let l=c;l<e.length;l++)if(e[l]===i)r++;else if(e[l]===s){if(s===">"&&l>0&&e[l-1]==="=")continue;if(r--,r===0)return l}return-1}function Z(e){let c=0,i=0,s=!1,r="";for(let l=0;l<e.length-1;l++){let f=e[l],u=e[l+1],a=l>0?e[l-1]:"";if(!s&&(f==='"'||f==="'"||f==="`"))s=!0,r=f;else if(s&&f===r&&a!=="\\")s=!1;if(!s){if(f==="<"){let d=o(e,l,"<",">");if(d!==-1){l=d;continue}}if(f==="(")c++;else if(f===")")c--;else if(f==="[")i++;else if(f==="]")i--;if(f==="="&&u===">"&&c===0&&i===0)return l}}return-1}function pt(e,c=!1,i=0,s=!0){let r=e.trim();if(r.length>200&&ut(r,"=>")>2&&ut(r,"<")>5&&!r.startsWith("function"))return c?"((...args: any[]) => any)":"(...args: any[]) => any";if(r.startsWith("async ")&&r.includes("=>")){let f=r.slice(5).trim(),u=Z(f);if(u===-1)return c?"(() => Promise<unknown>)":"() => Promise<unknown>";let a=f.substring(0,u).trim(),d=f.substring(u+2).trim(),x=Ct(a),{params:T,returnType:w}=x;if(T=ye(T),T==="()"||T==="")T="()";else if(!T.startsWith("("))T=`(${T})`;let A=w;if(A);else if(d.startsWith("{"))A=B(d.slice(1,d.endsWith("}")?-1:void 0),!0,x.params);else A=V(d,gt(x.params));let p=`${T} => ${w||A.startsWith("Promise<")?A:`Promise<${A}>`}`;return c?`(${p})`:p}if(r.includes("=>")){let f="",u=r;if(r.startsWith("<")){let C=o(r,0,"<",">");if(C!==-1)f=r.substring(0,C+1),u=r.substring(C+1).trim()}let a=Z(u);if(a===-1)return c?"(() => unknown)":"() => unknown";let d=u.substring(0,a).trim(),x=u.substring(a+2).trim(),T=Ct(d),{params:w,returnType:A}=T;if(w=ye(w),w==="()"||w==="")w="()";else if(!w.startsWith("("))w=`(${w})`;let p="unknown";if(A)p=A;else if(x.startsWith("{"))p=B(x.slice(1,x.endsWith("}")?-1:void 0),!1,T.params);else if(rt(x)||at(x)&&rt(x.slice(1,-1).trim()))p="JSX.Element";else if(x.includes("=>")){let C=x.trimStart(),S=C.indexOf("("),b=S!==-1?o(C,S,"(",")"):-1,k=b!==-1?C.indexOf("=>",b):-1;if(S===0&&b!==-1&&k!==-1){let O=C.substring(S+1,b).trim(),P=ye(O);if(f.includes("T")&&P.includes("T"))p=`(${P}) => T`;else p=`(${P}) => any`}else p="any"}else p=V(x,gt(T.params));let m=`${f}${w} => ${p}`;return c?`(${m})`:m}if(r.startsWith("function")){let f=8,u=r.length;while(f<u&&r.charCodeAt(f)<=32)f++;let a=!1;if(f<u&&r.charCodeAt(f)===42){a=!0,f++;while(f<u&&r.charCodeAt(f)<=32)f++}let d="";if(f<u&&r.charCodeAt(f)===60){let w=f,A=1;f++;while(f<u&&A>0){let p=r.charCodeAt(f);if(p===60)A++;else if(p===62&&r.charCodeAt(f-1)!==61)A--;f++}d=r.substring(w,f);while(f<u&&r.charCodeAt(f)<=32)f++}let x=r.indexOf("(",f);if(x!==-1){let w=1,A=x+1;while(A<u&&w>0){let k=r.charCodeAt(A);if(k===40)w++;else if(k===41)w--;A++}let p=r.substring(x+1,A-1).trim(),m=p?ye(`(${p})`):"()";if(a){let k=r.substring(A).trim(),O=k.indexOf("Generator<");if(O!==-1){let I=O+10,j=k.indexOf(">",I);if(j!==-1){let z=k.substring(I,j),F=`${d}${m} => Generator<${z}>`;return c?`(${F})`:F}}let P=`${d}${m} => Generator<any, any, any>`;return c?`(${P})`:P}let C="unknown",S=r.substring(A).trimStart();if(S.charCodeAt(0)===58){let k=S.slice(1),O=yt(k,0),P=(O?k.slice(0,O.index):k).trim();if(P)C=P}let b=`${d}${m} => ${C}`;return c?`(${b})`:b}let T="(...args: any[]) => unknown";return c?`(${T})`:T}if(r.includes("=>")&&r.includes("(")&&r.includes(")")){if(r.length>100||ut(r,"=>")>2){let f="";if(r.charCodeAt(0)===60){let T=o(r,0,"<",">");if(T!==-1)f=r.substring(0,T+1)}let u=r.indexOf("("),a=u!==-1?o(r,u,"(",")"):-1,d=u!==-1&&a!==-1?r.substring(u,a+1):"(...args: any[])";d=ye(d);let x=`${f}${d} => any`;return c?`(${x})`:x}return c?`(${r})`:r}let l="() => unknown";return c?`(${l})`:l}function Ct(e){let c=e.trim();if(!c.startsWith("("))return{params:c,returnType:""};let i=o(c,0,"(",")");if(i===-1)return{params:c,returnType:""};let s=c.slice(i+1).trim();return{params:c.slice(0,i+1),returnType:s.startsWith(":")?s.slice(1).trim():""}}function We(e){let c=e.trim();if(c==="any"||c==="object"||c==="unknown")return!0;if(c.startsWith("Record<")&&c.endsWith(">"))return!0;if(c.startsWith("Array<")&&c.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(c))return!0;return!1}function H(e){let c=-1,i=0;for(let r=0;r<e.length;r++){let l=e.charCodeAt(r);if(l===34||l===39||l===96){r=J(e,r,l)-1;continue}if(l===47&&e.charCodeAt(r+1)===47){while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(l===47&&e.charCodeAt(r+1)===42){let f=e.indexOf("*/",r+2);r=f===-1?e.length:f+1;continue}if(l===47){let f=r-1;while(f>=0&&e.charCodeAt(f)<=32)f--;if(f<0||"([{:;,=!?&|+*-~>".includes(e[f])){let u=!1;for(r++;r<e.length;r++){let a=e.charCodeAt(r);if(a===92)r++;else if(a===91)u=!0;else if(a===93)u=!1;else if(a===47&&!u)break}continue}}if(l===40||l===91||l===123)i++;else if(l===41||l===93||l===125)i--;else if(i===0&&e.startsWith("satisfies",r)&&tt(e,r,9)&&e[r-1]!==".")c=r}if(c===-1)return null;let s=e.slice(c+9).trim();if(s.endsWith(";"))s=s.slice(0,-1).trim();return s||null}function za(e){let c=e.trim(),i=c.match(/^\{\s*\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(i){let[,l,f,u,a]=i;return`{ [${l} in ${f}]${u?"?":""}: ${a} }`}let s=c.match(/^\{\s*readonly\s+\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(s){let[,l,f,u,a]=s;return`{ readonly [${l} in ${f}]${u?"?":""}: ${a} }`}let r=c.match(/^\{\s*(-?readonly\s+)?\[(\w+)\s+in\s+(.+?)\](-?\?)?\s*:\s*(.+)\s*\}$/);if(r){let[,l,f,u,a,d]=r;return`{ ${l?`${l.trim()} `:""}[${f} in ${u}]${a||""}: ${d} }`}return null}function Ua(e){let c=e.trim(),i=c.indexOf(" extends ");if(i===-1)return null;let s=c.slice(i+9),r=me(s);if(r===-1)return null;let l=pe(s,r);if(l===-1)return null;let f=c.slice(0,i).trim(),u=s.slice(0,r).trim(),a=s.slice(r+1,l).trim(),d=s.slice(l+1).trim();return`${f} extends ${u} ? ${a} : ${d}`}function me(e){let c=0,i=!1,s="";for(let r=0;r<e.length;r++){let l=e[r],f=r>0?e[r-1]:"";if(!i&&(l==='"'||l==="'"||l==="`"))i=!0,s=l;else if(i&&l===s&&f!=="\\")i=!1;if(!i){if(l==="<"||l==="("||l==="["||l==="{")c++;if(l===">"||l===")"||l==="]"||l==="}")c--;if(l==="?"&&c===0)return r}}return-1}function pe(e,c){let i=0,s=!1,r="";for(let l=c+1;l<e.length;l++){let f=e[l],u=l>0?e[l-1]:"";if(!s&&(f==='"'||f==="'"||f==="`"))s=!0,r=f;else if(s&&f===r&&u!=="\\")s=!1;if(!s){if(f==="<"||f==="("||f==="["||f==="{")i++;if(f===">"||f===")"||f==="]"||f==="}")i--;if(f==="?"&&i===0)i++;if(f===":"&&i===0)return l;if(f===":"&&i>0)i--}}return-1}function Ha(e){let c=e.trim();if(!c.startsWith("`")||!c.endsWith("`"))return null;let i=c.slice(1,-1);if(!i.includes("${"))return c;let s=[],r="",l=0;while(l<i.length)if(i[l]==="$"&&i[l+1]==="{"){if(r)s.push(`"${r}"`),r="";let f=1,u="";l+=2;while(l<i.length&&f>0){if(i[l]==="{")f++;if(i[l]==="}")f--;if(f>0)u+=i[l];l++}s.push(u.trim())}else r+=i[l],l++;if(r)s.push(`"${r}"`);return c}function Ka(e){let c=[],i=/infer\s+(\w+)/g,s;while((s=i.exec(e))!==null)c.push(s[1]);return c}function qa(e){let i=e.trim(),s=i.indexOf("[");if(s!==-1){if(i.indexOf(" in ",s)!==-1)return!0}let r=i.indexOf(" extends ");if(r!==-1){let f=i.indexOf(" ? ",r);if(f!==-1&&i.indexOf(" : ",f)!==-1)return!0}if(i.charCodeAt(0)===96&&i.charCodeAt(i.length-1)===96){if(i.indexOf("${")!==-1)return!0}let l=i.indexOf("infer ");if(l!==-1){if(l===0||!q(i.charCodeAt(l-1)))return!0}return!1}function Ja(e,c=3){let i=e.trim(),s=0,r=0;for(let l of i){if(l==="<"||l==="("||l==="["||l==="{")s++,r=Math.max(r,s);if(l===">"||l===")"||l==="]"||l==="}")s--}if(r>c){let l=i.match(/^(\w+)</);if(l)return`${l[1]}<any>`;return"unknown"}return i}function Ya(e){let i=e.trim().match(/^(\w+)<(.+)>$/);if(!i)return null;let s=i[1],r=i[2],l=Ea(r);if(["Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer"].includes(s))return{name:s,params:l};return null}function Ea(e){let c=[],i="",s=0,r=!1,l="";for(let f=0;f<e.length;f++){let u=e[f],a=f>0?e[f-1]:"";if(!r&&(u==='"'||u==="'"||u==="`"))r=!0,l=u;else if(r&&u===l&&a!=="\\")r=!1;if(!r){if(u==="<"||u==="("||u==="["||u==="{")s++;if(u===">"||u===")"||u==="]"||u==="}")s--;if(u===","&&s===0){c.push(i.trim()),i="";continue}}i+=u}if(i.trim())c.push(i.trim());return c}function Xa(e){let c=e.trim();if(c.startsWith("keyof "))return c;return null}function Za(e){let c=e.trim();if(c.startsWith("typeof "))return c;return null}function Qa(e){let c=e.trim();if(c.length===0||c.charCodeAt(0)===91)return!1;if(c.charCodeAt(c.length-1)!==93)return!1;let i=c.indexOf("[");if(i<=0)return!1;for(let s=0;s<i;s++){let r=c.charCodeAt(s);if(!q(r)&&r!==46)return!1}return!0}
40
- export{zt,Ut,n,Ht,B,$a,W,Kt,Be,Q,ir,qt,dt,U,ye,o,pt,We,H,za,Ua,Ha,Ka,qa,Ja,Ya,Ea,Xa,Za,Qa};
@@ -1,10 +0,0 @@
1
- // @bun
2
- import{z,tr,nr}from"./chunk-4cr1q0yf.js";import{Tn}from"./chunk-pnfjhm01.js";import{f}from"./chunk-587w6ktw.js";import{fe,x,de,pe,me,ge,he}from"./chunk-r46rw8gr.js";import{Fe,v}from"./chunk-9mdgtq38.js";import{Me}from"./chunk-bt2n0b75.js";function L(y,D){throw Error(D||`Unexpected value: ${y}`)}var V=null,j=[],q=[];function l(y,D,d=!0,b=["bun"]){let o="",m=D.sourceCode;if(m){let e=0;while(e<m.length&&(m.charCodeAt(e)===32||m.charCodeAt(e)===9||m.charCodeAt(e)===10||m.charCodeAt(e)===13))e++;if(e<m.length-2&&m.charCodeAt(e)===47&&m.charCodeAt(e+1)===47&&m.charCodeAt(e+2)===47){let i=Tn(m);if(i.length>0)for(let r=0;r<i.length;r++){if(o)o+=`
3
- `;o+=i[r]}}}let E=[],N=[],M=[],P=[],U=[],W=[],_=[],w=[],C=[];for(let e of y){let i=e.kind;switch(i){case"import":E.push(e);break;case"function":N.push(e);break;case"variable":M.push(e);break;case"interface":P.push(e);break;case"type":U.push(e);break;case"class":W.push(e);break;case"enum":_.push(e);break;case"module":w.push(e);break;case"export":C.push(e);break;case"namespace":w.push(e);break;case"unknown":break;default:L(i,`Unhandled declaration kind: ${i}`)}}let T=[],S=[],A=[],F=new Set;for(let e of C){let i=f(e.leadingComments,d);if(e.text.startsWith("export default")){let r=e.text.endsWith(";")?e.text:`${e.text};`;A.push(i+r)}else{let r=e.text.trim();if(!r.endsWith(";"))r+=";";let a=i+r;if(!F.has(a))if(F.add(a),a.includes("export type"))T.push(a);else S.push(a)}}let u=[];if(E.length>0){let{usedItems:e}=Me(y);for(let r of E){if(r.isSideEffect){let t=r.text.trim(),p=t.endsWith(";")?t:`${t};`;u.push(p);continue}let a=v(r.text);if(!a)continue;let{defaultName:s,namedItems:n,isTypeOnly:h,namespaceName:c}=a,g=s?e.has(s):!1,G=c?e.has(c):!1;if(a.isImportEquals){if(g){let t=r.text.trim();u.push(t.endsWith(";")?t:`${t};`)}else if(D.augmentationImports?.has(a.source)){let t=Fe(r.text);if(!t)throw Error("Cannot locate an augmentation import module literal");u.push(`import ${t};`)}continue}let k="",I=0;for(let t=0;t<n.length;t++){let p=n[t];if(e.has(p.name)){if(I>0)k+=", ";if(!h&&p.isTypeOnly)k+="type ";k+=p.originalName===p.name?p.name:`${p.originalName} as ${p.name}`,I++}}if(g||G||I>0){let t=h?"import type ":"import ";if(G&&c){if(g&&s)t+=`${s}, `;t+=`* as ${c}`}else if(g&&s)t+=I>0?`${s}, { ${k} }`:s;else if(I>0)t+=`{ ${k} }`;let p=Fe(r.text);if(!p)throw Error("Cannot locate a grammatical module literal in the import declaration");t+=` from ${p};`,u.push(t)}else if(D.augmentationImports?.has(a.source)){let t=Fe(r.text);if(!t)throw Error("Cannot locate an augmentation import module literal");u.push(`import ${t};`)}}let i=b.length;if(u.length>1){if(V!==b)V=b,j=b.map((n)=>`from '${n}`),q=b.map((n)=>`from "${n}`);let r=j,a=q,s=new Map;for(let n of u){let h=i;for(let c=0;c<b.length;c++)if(n.includes(r[c])||n.includes(a[c])){h=c;break}s.set(n,h)}u.sort((n,h)=>{let c=s.get(n),g=s.get(h);return c!==g?c-g:n.localeCompare(h)})}}for(let e=0;e<u.length;e++){if(o)o+=`
4
- `;o+=u[e]}for(let e=0;e<T.length;e++){if(o)o+=`
5
- `;o+=T[e]}let K=[N,M,P,U,W,_,w];for(let e=0;e<K.length;e++){let i=K[e];for(let r=0;r<i.length;r++){let a=i[r],s="",n=a.kind;switch(n){case"function":s=fe(a,d);break;case"variable":s=x(a,d);break;case"interface":s=de(a,d);break;case"type":s=pe(a,d);break;case"class":s=me(a,d);break;case"enum":s=ge(a,d);break;case"module":case"namespace":s=he(a,d);break;case"import":case"export":case"unknown":break;default:L(n,`Unhandled declaration kind in processor: ${n}`)}if(s){if(o)o+=`
6
- `;o+=s}}}for(let e=0;e<S.length;e++){if(o)o+=`
7
- `;o+=S[e]}for(let e=0;e<A.length;e++){if(o)o+=`
8
- `;o+=A[e]}if(C.length===0&&z(D.sourceCode)&&(y.some(nr)||!tr(o)))o+=`${o?`
9
- `:""}export {};`;return o}
10
- export{l};
@@ -1,2 +0,0 @@
1
- // @bun
2
- var e="@dtsx/dtsx",i="module",n="0.11.56",r=!0,c="A modern, fast .d.ts generation tool, powered by Bun.",u="Chris Breuer <chris@stacksjs.org>",b="MIT",a="https://github.com/stacksjs/dtsx#readme",p={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},o={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"},h=["dist"],g={benchmark:"bun benchmark/index.ts","benchmark:prepare":"bun benchmark/prepare.ts","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:ffi-sdk":"bun scripts/verify-ffi-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.35","@stacksjs/bunpress":"^0.2.31","@stacksjs/clapp":"^0.2.17",pickier:"^0.1.93","@stacksjs/gitlint":"^0.1.8","@stacksjs/logsmith":"^0.2.16","@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.158.0","oxc-parser":"^0.158.0",tsdown:"^0.23.7",typescript:"^7.0.2"},f=["packages/*"],y={typescript:"^7.0.2"},v={name:e,type:i,version:n,private:r,description:c,author:u,license:b,homepage:a,repository:p,bugs:o,keywords:d,exports:m,module:k,types:l,bin:x,files:h,scripts:g,devDependencies:j,workspaces:f,overrides:y,"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,o as bugs,v as default,c as description,j as devDependencies,m as exports,h as files,a as homepage,d as keywords,b as license,k as module,e as name,y as overrides,r as private,p as repository,g as scripts,i as type,l as types,n as version,f as workspaces};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{t,E,ze,b}from"./chunk-t5nmnzy6.js";import{Zn,Qn}from"./chunk-6ekemc3h.js";function q(n){return b(n).find((e)=>e.category==="static-import")}function S(n){return t(n).map((e)=>n.slice(e.start,e.end)).join(" ")}function W(n){let e=q(n);return e?n.lastIndexOf(" from ",e.start):-1}function Fe(n){let e=q(n);return e?E(e.specifier,"'"):void 0}function Xn(n){let e=v(n);if(!e)return null;return{defaultName:e.defaultName??e.namespaceName,namedItems:e.namedItems.map((r)=>`${!e.isTypeOnly&&r.isTypeOnly?"type ":""}${r.originalName===r.name?r.name:`${r.originalName} as ${r.name}`}`),source:e.source,isTypeOnly:e.isTypeOnly,isNamespace:e.isNamespace,namespaceName:e.namespaceName,isImportEquals:e.isImportEquals}}function C(n){let e=Zn(n);if(e)return e;let r=v(n),u=r?[r.defaultName,r.namespaceName,...r.namedItems.map((a)=>a.name)].filter((a)=>a!==null):[];return Qn(n,u),u}function w(n){let e=[],r=0;for(let a of t(n)){if(a.kind!=="punctuation"||n.slice(a.start,a.end)!==",")continue;let s=n.slice(r,a.start).trim();if(s)e.push(s);r=a.end}let u=n.slice(r).trim();if(u)e.push(u);return e}function v(n){n=S(n);let e=ze(n);if(e)return{defaultName:e.name,namedItems:[],source:e.source,isTypeOnly:e.isTypeOnly,isNamespace:!1,namespaceName:null,isImportEquals:!0};let r=W(n);if(r===-1)return null;let u=q(n);if(!u)return null;let a=u.specifier,s=n.slice(0,r).trim(),p=u.isTypeOnly;if(s.startsWith("import "))s=s.slice(7).trim();if(p&&s.startsWith("type "))s=s.slice(5).trim();let f=null,o=[],i=!1,m=null,c=s.includes("{")?-1:s.indexOf("* as ");if(c!==-1)return i=!0,m=s.slice(c+5).trim(),f=s.slice(0,c).trim().replace(/,$/,"").trim()||null,{defaultName:f,namedItems:[],source:a,isTypeOnly:p,isNamespace:i,namespaceName:m};let l=s.indexOf("{"),d=s.lastIndexOf("}");if(l!==-1&&d!==-1){let g=s.slice(0,l).trim();if(g.endsWith(","))f=g.slice(0,-1).trim()||null;let I=s.slice(l+1,d),D=w(I);for(let h of D){let T=Li(h),y=T?h.slice(5).trim():h,N=y.lastIndexOf(" as "),O,x;if(N!==-1)x=y.slice(0,N).trim(),O=y.slice(N+4).trim();else O=y,x=y;o.push({name:O,originalName:x,isTypeOnly:p||T,isDefault:!1})}}else f=s.trim()||null;return{defaultName:f,namedItems:o,source:a,isTypeOnly:p,isNamespace:i,namespaceName:m}}function _a(n){let e=n.trim();if(e.startsWith("export default "))return{namedItems:[],source:null,isTypeOnly:!1,isNamespace:!1,isDefault:!0};let r=e.startsWith("export type ");if(e.startsWith("export "))e=e.slice(7).trim();if(r&&e.startsWith("type "))e=e.slice(5).trim();if(e.startsWith("* from ")||e.startsWith("* as ")){let m=e.indexOf(" from "),c=null;if(m!==-1){let l=e.slice(m+6).trim(),d=l[0];if(d==='"'||d==="'"){let g=l.indexOf(d,1);if(g!==-1)c=l.slice(1,g)}}return{namedItems:[],source:c,isTypeOnly:r,isNamespace:!0,isDefault:!1}}let u=e.indexOf("{"),a=e.lastIndexOf("}");if(u===-1||a===-1)return null;let s=null,p=e.indexOf(" from ",a);if(p!==-1){let m=e.slice(p+6).trim(),c=m[0];if(c==='"'||c==="'"){let l=m.indexOf(c,1);if(l!==-1)s=m.slice(1,l)}}let f=[],o=e.slice(u+1,a),i=[];{let m=0;for(let c=0;c<=o.length;c++)if(c===o.length||o.charCodeAt(c)===44){let l=m,d=c;while(l<d&&o.charCodeAt(l)<=32)l++;while(d>l&&o.charCodeAt(d-1)<=32)d--;if(l<d)i.push(o.slice(l,d));m=c+1}}for(let m of i){let c=Li(m),l=c?m.slice(5).trim():m,d=l.lastIndexOf(" as "),g,I;if(d!==-1)I=l.slice(0,d).trim(),g=l.slice(d+4).trim();else g=l,I=l;f.push({name:g,originalName:I,isTypeOnly:r||c,isDefault:!1})}return{namedItems:f,source:s,isTypeOnly:r,isNamespace:!1,isDefault:!1}}function Li(n){let e=t(n),r=e[0];if(!r||r.kind!=="word"||n.slice(r.start,r.end)!=="type"||e.length<2)return!1;return!(e.length===3&&n.slice(e[1].start,e[1].end)==="as")}function ja(n){let e=v(n);if(!e||e.isTypeOnly||e.isImportEquals)return n;if(e.namedItems.every((r)=>r.isTypeOnly))return n.replace(/^import\s+/,"import type ");return n}function Ga(n){let e=new Map,r=[];for(let a of n){let s=v(a);if(!s)continue;if(s.isImportEquals||s.isNamespace){r.push(a);continue}let p=Fe(a);if(!p)throw Error("Cannot locate a grammatical module literal in the import declaration");let f=e.get(s.source)||{types:[],values:[],defaultName:null,sourceLiteral:p};if(s.defaultName)f.defaultName=s.defaultName;for(let o of s.namedItems)if(o.isTypeOnly)f.types.push(o);else f.values.push(o);e.set(s.source,f)}let u=r;for(let{types:a,values:s,defaultName:p,sourceLiteral:f}of e.values())if(a.length===0&&s.length===0&&p)u.push(`import ${p} from ${f};`);else if(a.length>0&&s.length===0&&!p){let o=a.map((i)=>i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`);u.push(`import type { ${o.join(", ")} } from ${f};`)}else if(s.length>0&&a.length===0&&!p){let o=s.map((i)=>i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`);u.push(`import { ${o.join(", ")} } from ${f};`)}else{let o=[];for(let i of a){let m=i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`;o.push(`type ${m}`)}for(let i of s){let m=i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`;o.push(m)}if(p)u.push(`import ${p}, { ${o.join(", ")} } from ${f};`);else u.push(`import { ${o.join(", ")} } from ${f};`)}return u}
3
- export{Fe,Xn,C,v,_a,Li,ja,Ga};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{r}from"./chunk-0a1xppye.js";import{l}from"./chunk-81jrzxr6.js";import{existsSync as v}from"fs";import{readFile as D}from"fs/promises";import{dirname as N,join as k,resolve as S}from"path";async function Er(e,o=process.cwd()){let i=new Map;for(let t of e){let n=S(o,t),s=await F(n,o);i.set(n,{path:n,dependencies:s,dependents:new Set,state:"pending"})}for(let[t,n]of i)for(let s of n.dependencies){let c=i.get(s);if(c)c.dependents.add(t)}return i}async function F(e,o){let i=new Set;try{let t=await D(e,"utf-8"),n=N(e);for(let s of r(t,e,!1)){let c=s.source;if(!c||!c.startsWith(".")&&!c.startsWith("/"))continue;let a=z(c,n,o);if(a)i.add(a)}}catch{}return i}function z(e,o,i){let t=S(o,e);if(/\.(?:ts|tsx|mts|cts)$/.test(e))return t.includes("node_modules")?null:t;let n=[".ts",".tsx",".mts",".cts"];for(let c of n){let a=`${t}${c}`;if(v(a))return a}for(let c of n){let a=k(t,`index${c}`);if(v(a))return a}let s=`${t}.ts`;return s.includes("node_modules")?null:s}function G(e){let o=[];for(let[i,t]of e){if(t.state!=="pending")continue;let n=!0;for(let s of t.dependencies){let c=e.get(s);if(c&&c.state!=="completed"){n=!1;break}}if(n)o.push(i)}return o}async function I(e,o={}){let i=await D(e,"utf-8"),t=o.keepComments??!0,n=r(i,e,t,o.isolatedDeclarations??!1);return l(n,{filePath:e,sourceCode:i,declarations:n},t,o.importOrder)}async function gs(e,o={}){let i=performance.now(),{maxConcurrency:t=4,rootDir:n=process.cwd(),config:s={},onProgress:c,onError:a}=o,g=await Er(e,n),w=new Map,P=new Map,h=[],x=0,u=0,m=0,b=g.size;while(m<b){let y=G(g);if(y.length===0){let f=[...g.values()].filter((d)=>d.state==="pending");if(f.length>0)for(let d of f)d.state="failed",d.error=Error("Circular dependency detected or dependency failed"),P.set(d.path,d.error),m++;break}let C=y.slice(0,t-u);for(let f of C){let d=g.get(f);d.state="processing",u++}x=Math.max(x,u);let E=C.map(async(f)=>{let d=g.get(f),M=performance.now();try{let p=await I(f,s);d.state="completed",d.result=p,d.duration=performance.now()-M,w.set(f,p),h.push(f)}catch(p){if(d.state="failed",d.error=p instanceof Error?p:Error(String(p)),d.duration=performance.now()-M,P.set(f,d.error),a&&!a(f,d.error))throw Error("Processing aborted by error handler")}finally{u--,m++,c?.(m,b,f)}});await Promise.all(E)}return{success:w,failed:P,totalTimeMs:performance.now()-i,maxConcurrent:x,processingOrder:h}}function hs(e){let o=[],i=new Set,t=new Set;function n(s){if(i.has(s))return;if(t.has(s))return;t.add(s);let c=e.get(s);if(c){for(let a of c.dependencies)if(e.has(a))n(a)}t.delete(s),i.add(s),o.push(s)}for(let s of e.keys())n(s);return o}function kr(e){let o=[];for(let[i,t]of e){let n=!1;for(let s of t.dependencies)if(e.has(s)){n=!0;break}if(!n)o.push(i)}return o}function Tr(e){let o=[],i=new Set;while(i.size<e.size){let t=[];for(let[n,s]of e){if(i.has(n))continue;let c=!0;for(let a of s.dependencies)if(e.has(a)&&!i.has(a)){c=!1;break}if(c)t.push(n)}if(t.length===0){for(let n of e.keys())if(!i.has(n))t.push(n)}for(let n of t)i.add(n);o.push(t)}return o}function ys(e){let o=Tr(e),i=kr(e),t=Math.max(...o.map((s)=>s.length)),n=e.size/o.length;return{totalFiles:e.size,independentFiles:i.length,maxParallelism:t,levels:o.length,estimatedSpeedup:n}}
3
- export{Er,gs,hs,kr,Tr,ys};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{a,i}from"./chunk-cgqg1br8.js";import{x}from"./chunk-r46rw8gr.js";import{C}from"./chunk-9mdgtq38.js";function Me(f){let r=new Set,n=[];for(let t of f)if(t.kind==="import")for(let o of C(t.text))r.add(o);else if(t.kind!=="unknown"){if(n.push(t.text),t.kind==="variable"){if(t.typeAnnotation)n.push(t.typeAnnotation);else if(t.value)n.push(x(t,!1))}}let e=n.join(`
3
- `),s=new Set;for(let t=0;t<e.length;){if(!a(e.charCodeAt(t))){t++;continue}let o=t++;while(t<e.length&&i(e.charCodeAt(t)))t++;let c=e.slice(o,t);if(r.has(c))s.add(c)}return{usedItems:s,referenceText:e}}
4
- export{Me};
@@ -1,6 +0,0 @@
1
- // @bun
2
- import{r}from"./chunk-0a1xppye.js";import{ke}from"./chunk-hgg4aqvf.js";import{readFileSync as u}from"fs";import{readFile as p}from"fs/promises";import{resolve as g}from"path";function m(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"").replace(/,\s*([}\]])/g,"$1")}function Ms(t,e){try{return{...JSON.parse(m(u(t,"utf8"))).compilerOptions,...e}}catch(s){throw Error(`Error reading tsconfig.json: ${s instanceof Error?s.message:String(s)}`)}}function f(t,e){let s=e.declarationsOnly?t.filter((o)=>o.endsWith(".d.ts")):t;if(e.include?.length){let o=e.include.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>o.some((i)=>i.test(n)))}if(e.exclude?.length){let o=e.exclude.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>!o.some((i)=>i.test(n)))}return s}async function wt(t,e={}){let s=performance.now(),o=f(t,e),n=[];for(let a of o)try{let c=await p(a,"utf8");for(let l of ke(c))n.push({file:a,line:l.line,column:l.column,message:l.message,code:Number(l.code.slice(4)),severity:"error",category:"Error"})}catch(c){n.push({file:a,line:0,column:0,message:c instanceof Error?c.message:String(c),code:1000,severity:"error",category:"Error"})}let i=e.maxErrors?n.slice(0,e.maxErrors):n;return{success:i.length===0,diagnostics:i,errorCount:i.length,warningCount:0,infoCount:0,filesChecked:o,durationMs:performance.now()-s}}function Lr(t,e={}){return wt(t,{...e,declarationsOnly:!0})}async function Os(t){let e=new Map;for(let s of t){let o=await p(s,"utf8").catch(()=>""),n=[];for(let i of r(o,s,!1,!0))if(i.isExported&&i.kind==="function"&&!i.returnType)n.push({line:1,column:1,message:"Exported function requires an explicit return type",declarationName:i.name,missingAnnotation:"return"});e.set(s,{compatible:n.length===0,issues:n})}return e}function d(t,e,s){let o=t.split(`
3
- `);if(e<1||e>o.length||s<1||s>o[e-1].length+1)return null;let n=s-1;for(let i=0;i<e-1;i++)n+=o[i].length+1;return n}function Nr(t,e,s){try{let o=u(t,"utf8"),n=d(o,e,s);if(n===null)return null;let i=r(o,t,!1).find((a)=>n>=(a.start??0)&&n<=(a.end??o.length));return i?.typeAnnotation??i?.returnType??i?.text??null}catch{return null}}function Is(t,e,s){let o=Nr(t,e,s);return o?{type:o}:null}function Ls(t){if(t.success)return`\u2713 Type check passed (${t.filesChecked.length} files checked in ${t.durationMs}ms)`;return["\u2717 Type check failed",` ${t.errorCount} error(s), ${t.warningCount} warning(s)`,...t.diagnostics.map((e)=>`\u2717 ${e.file}:${e.line}:${e.column}
4
- ${e.message}`)].join(`
5
- `)}function Ns(t){return wt(t.entrypoints.map((e)=>g(t.cwd,e)),{tsconfigPath:t.tsconfigPath,rootDir:t.root})}async function Fs(t,e){let o=(await Promise.all([wt(t),Lr(e)])).flatMap((n)=>n.diagnostics).map((n)=>({sourceName:n.file,sourceType:n.message,dtsType:"<invalid>"}));return{valid:o.length===0,mismatches:o}}
6
- export{Ms,wt,Lr,Os,Nr,Is,Ls,Ns,Fs};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{Ve}from"./chunk-mzxxgnp8.js";import{R}from"./chunk-wq5r1ms9.js";import{v}from"./chunk-9mdgtq38.js";function Ln(i,r){let n=new Set;for(let e of R(i,"imports.ts",!1)){if(e.kind!=="import")continue;let t=v(e.text),a=t&&r.get(t.source);if(!t||t.isTypeOnly||!a)continue;let s=rt(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 rt(i){let r=R(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&&Ve(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
3
- export{Ln,rt};
@@ -1,5 +0,0 @@
1
- // @bun
2
- function a(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e>127}function i(e){return a(e)||e>=48&&e<=57}function L(e,_){let n=_;for(;;){while(n>=0&&(e.charCodeAt(n)===32||e.charCodeAt(n)===9||e.charCodeAt(n)===10||e.charCodeAt(n)===13))n--;if(n<0)return-1;if(e.charCodeAt(n)===47&&n>0&&e.charCodeAt(n-1)===42){let l=e.lastIndexOf("/*",n-2);if(l===-1)return-1;n=l-1;continue}let H=e.lastIndexOf(`
3
- `,n)+1,r=x(e,H,n);if(r!==-1){n=r-1;continue}return n}}function x(e,_,n){if(!e.slice(_,n+1).includes("//"))return-1;return R(e,n).lineCommentStart??-1}function m(e){return e===61||e===40||e===91||e===33||e===38||e===124||e===63||e===58||e===44||e===59||e===123||e===125||e===94||e===126||e===43||e===45||e===42||e===37||e===60||e===62}function p(e){return e==="return"||e==="typeof"||e==="void"||e==="delete"||e==="throw"||e==="new"||e==="in"||e==="of"||e==="case"||e==="instanceof"||e==="yield"||e==="await"||e==="else"||e==="do"}function R(e,_){let n=[],H=[],r=0,l=!1,f="",d="",c=!0,C=0,s=(t,A=!1)=>{d=f,f=t,c=A};while(C<=_){let t=e.charCodeAt(C);if(l){if(t===92){C+=2;continue}if(t===96)l=!1,s("literal");else if(t===36&&e.charCodeAt(C+1)===123)H.push(r++),l=!1,s("{",!0),C++;C++;continue}if(t===32||t===9||t===10||t===13){C++;continue}if(t===47&&e.charCodeAt(C+1)===47){let A=e.indexOf(`
4
- `,C+2);if(A===-1||A>_)return{regexAllowed:c,closesControlHeader:!1,lineCommentStart:C};C=A===-1?e.length:A+1;continue}if(t===47&&e.charCodeAt(C+1)===42){let A=e.indexOf("*/",C+2);C=A===-1?e.length:A+2;continue}if(t===39||t===34){let A=t;C++;while(C<e.length){let S=e.charCodeAt(C++);if(S===92)C++;else if(S===A)break}s("literal");continue}if(t===96){l=!0,C++;continue}if(a(t)||t===35&&a(e.charCodeAt(C+1))){let A=C++;while(i(e.charCodeAt(C)))C++;let S=e.slice(A,C);s(S,f!=="."&&p(S));continue}if((t===43||t===45)&&e.charCodeAt(C+1)===t){s(e.slice(C,C+2),c),C+=2;continue}if(t===33&&e.charCodeAt(C+1)!==61){s("!",c),C++;continue}if(t===40){let A=d!=="."&&(f==="if"||f==="while"||f==="for"||f==="with"||f==="switch"||f==="catch"||f==="await"&&d==="for");n.push(A),s("(",!0)}else if(t===41){let A=n.pop()??!1;if(C===_)return{regexAllowed:A,closesControlHeader:A};s(")",A)}else if(t===47&&c){C=g(e,C),s("literal");continue}else{if(t===123)r++;else if(t===125){if(r--,H.at(-1)===r)H.pop(),l=!0}s(e[C],t===47||m(t))}C++}return{regexAllowed:c,closesControlHeader:!1}}function h(e,_,n){let H=n===void 0?L(e,_-1):n-1;if(H<0)return!0;let r=e.charCodeAt(H);if(r===33||(r===43||r===45)&&e.charCodeAt(H-1)===r)return R(e,H).regexAllowed;if(r===41)return R(e,H).closesControlHeader;if(m(r))return!0;if(i(r)){let l=H;while(l>=0&&i(e.charCodeAt(l)))l--;let f=e.charCodeAt(L(e,l));if(f===46||f===35)return!1;return p(e.slice(l+1,H+1))}return!1}function g(e,_){let n=_,H=e.length;n++;let r=!1;while(n<H){let l=e.charCodeAt(n);if(l===92){n+=2;continue}if(r){if(l===93)r=!1;n++;continue}if(l===91){r=!0,n++;continue}if(l===47){n++;break}if(l===10||l===13)break;n++}while(n<H&&i(e.charCodeAt(n)))n++;return n}function xe(e,_,n){let H=n===void 0?L(e,_-1):n-1;if(H<0)return!0;let r=e[H];if("=([{,:;!?+-*/%&|^~<".includes(r))return!0;if(r===">"&&e[H-1]==="=")return!0;let l=H;while(l>=0&&i(e.charCodeAt(l)))l--;return["return","throw","yield","await","case","void","typeof","delete","new","else","do"].includes(e.slice(l+1,H+1))}function E(e,_,n,H){let r=e.length;if(e.charCodeAt(_)!==60||_+1>=r)return null;let l=e.charCodeAt(_+1);if(l===62)return{delta:1,end:_+1};if(l===47){let o=_+2;if(e.charCodeAt(o)!==62){if(!a(e.charCodeAt(o)))return null;while(o<r&&(i(e.charCodeAt(o))||".:-".includes(e[o])))o++;while(o<r&&/\s/.test(e[o]))o++}return e.charCodeAt(o)===62?{delta:-1,end:o}:null}if(!a(l))return null;let f=_+2;while(f<r){let o=e.charCodeAt(f);if(!i(o)&&o!==46&&o!==58&&o!==45)break;f++}let d=e.slice(_+1,f),c=e.charCodeAt(f);if(c>32&&c!==62&&c!==47)return null;let C=0,s=0,t=f,A=f;for(;t<r;t++){let o=e.charCodeAt(t);if(s!==0){if(o===92)t++;else if(o===s)s=0,A=t+1;continue}if(o===60&&C>0&&(e[t+1]==="/"||xe(e,t,A))){let u=H?H(t):E(e,t,n);if(u){t=u.end,A=t+1;continue}}if(o===47&&C>0){let u=e.charCodeAt(t+1);if(u===47){while(t<r&&e.charCodeAt(t)!==10&&e.charCodeAt(t)!==13)t++;continue}if(u===42){let b=e.indexOf("*/",t+2);if(b===-1)return null;t=b+1;continue}if(h(e,t,A)){t=g(e,t)-1,A=t+1;continue}}if(o===39||o===34||o===96)s=o;else if(o===123)C++;else if(o===125&&C>0)C--;else if(o===60&&C===0)return null;else if(o===62&&C===0)break;if(o>32)A=t+1}if(t>=r)return null;let S=t-1;while(S>_&&e.charCodeAt(S)<=32)S--;if(e.charCodeAt(S)===47)return{delta:0,end:t};return(n?n.get(d)??-1:e.indexOf(`</${d}`,t+1))>t?{delta:1,end:t}:null}function Ue(e,_){let n,H=new Map;function r(l){if(H.has(l))return H.get(l);if(!n){n=new Map;let d=e.indexOf("</");while(d!==-1){let c=E(e,d);if(c){let C=d+2;while(C<c.end&&!/\s/.test(e[C]))C++;n.set(e.slice(d+2,C),d)}d=e.indexOf("</",d+2)}}let f=E(e,l,n,r);if(H.set(l,f),f&&e[f.end-1]==="/")_?.add(f.end-1);return f}return r}
5
- export{a,i,h,g,xe,Ue};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{m}from"./chunk-t5nmnzy6.js";import{y,ee}from"./chunk-vk5r6pgx.js";function _(b){let f=m(b),e=0,v,I,w,z=[new Map,new Map],n=(t=e)=>f[t]?b.slice(f[t].start,f[t].end):"",d=(t=e)=>f[t]?.kind==="word",g=(t,u)=>/[\r\n]/.test(b.slice(t,u));function r(t){if(n()!==t)return!1;return e++,!0}function k(t){let u=e;for(let a of t)if(!r(a)||e>u+1&&f[e-2].end!==f[e-1].start)return e=u,!1;return!0}function h(t){let u=e;if(t())return!0;return e=u,!1}function o(){if(!d())return!1;return e++,!0}function T(){let t=e,u=e;while(u<f.length&&(u===t||f[u-1].end===f[u].start)){let i=n(u),l=(i==="+"||i==="-")&&/[eE]$/.test(n(u-1));if(!d(u)&&!/^[0-9.]$/.test(i)&&!l)break;u++}if(u===t)return!1;let a=b.slice(f[t].start,f[u-1].end);if(!y(a)&&!ee(a))return!1;return e=u,!0}function A(){if(!["(","[","{"].includes(n()))return!1;if(!v){v=new Map;let u=[];for(let a=0;a<f.length;a++){let i=n(a);if(["(","[","{"].includes(i))u.push(a);else if([")","]","}"].includes(i)){let l=u.pop();if(l!==void 0&&["()","[]","{}"].includes(n(l)+i))v.set(l,a+1);else u.length=0}}}let t=v.get(e);if(t===void 0)return!1;return e=t,!0}function D(){return o()||(n()==="{"||n()==="[")&&A()}function N(){if(!r("("))return!1;if(r(")"))return!0;do{if(k("..."),!D())return!1;if(r("?"),r(":")&&!s())return!1;if(n()===")")break}while(r(",")&&n()!==")");return r(")")}function x(){if(!r("<"))return!1;if(n()===">")return!1;do{if(n()==="const")e++;while((n()==="in"||n()==="out")&&d(e+1)&&n(e+1)!=="extends")e++;if(!o())return!1;if(r("extends")&&!s(!1))return!1;if(r("=")&&!s())return!1;if(n()===">")break}while(r(",")&&n()!==">");return r(">")}function O(){if(!r("<")||n()===">")return!1;do{if(!s())return!1;if(n()===">")break}while(r(",")&&n()!==">");return r(">")}function F(){if(r("abstract"),r("new"),n()==="<"&&!x())return!1;return N()&&k("=>")&&q()}function G(){if(f[e]?.kind!=="literal"||b.charCodeAt(f[e].start)!==96)return!1;for(;;){let t=f[e++];if(!t)return!1;if(b.charCodeAt(t.end-1)===96)return!0;if(b.charCodeAt(t.end-1)!==36||!r("{")||!s()||!r("}"))return!1;if(f[e]?.kind!=="literal")return!1}}function H(){if(!r("["))return!1;if(r("]"))return!0;do{k("...");let t=e;if(d()||f[e]?.kind==="quoted"){if(e++,r("?"),!r(":"))e=t}if(!s())return!1;if(r("?"),n()==="]")break}while(r(",")&&n()!=="]");return r("]")}function q(){if(r("asserts")){if(!o())return!1;return!r("is")||s()}if(d()&&n(e+1)==="is")return e+=2,s();return s()}function S(){if(n()==="<"&&!x())return!1;if(!N())return!1;return!r(":")||q()}function J(){if(!r("["))return!1;if(d()&&(n(e+1)==="in"||n(e+1)===":")){e++;let t=r("in");if(!t&&!r(":"))return!1;if(!s())return!1;if(t&&r("as")&&!s())return!1}else{if(!o()&&!T()){if(f[e]?.kind!=="quoted")return!1;e++}while(r("."))if(!o())return!1}return r("]")}function B(){if(n()==="[")return J();if(o()||T())return!0;if(f[e]?.kind!=="quoted")return!1;return e++,!0}function K(){if(n()!=="get"&&n()!=="set")return;let t=e++;e=B()&&n()==="("?t+1:t}function L(){if(!r("{"))return!1;while(!r("}")){if(e>=f.length)return!1;let t=e;if((n()==="+"||n()==="-")&&n(e+1)==="readonly")e++;if(n()==="readonly"&&n(e+1)!==":"&&n(e+1)!=="?"&&n(e+1)!=="("&&n(e+1)!==";"&&n(e+1)!=="}")e++;if(n()==="new"&&(n(e+1)==="("||n(e+1)==="<"))e++;if(n()==="("||n()==="<"){if(!S())return!1}else{if(K(),!B())return!1;if(n()==="+"||n()==="-"){if(e++,!r("?"))return!1}else r("?");if(r(":")){if(!s())return!1}else if(n()==="("||n()==="<"){if(!S())return!1}}if(e===t)return!1;if(r(";")||r(","))continue;if(n()!=="}"&&!g(f[e-1].end,f[e]?.start??b.length))return!1}return!0}function P(){if(h(F))return!0;if(r("("))return s()&&r(")");if(n()==="{")return L();if(n()==="[")return H();if(h(G))return!0;if(f[e]?.kind==="quoted")return e++,!0;if(r("-"))return T();if(h(T))return!0;if(r("typeof")){if(n()==="import")return P();if(!o())return!1;while(r("."))if(!o())return!1;if(n()==="<"&&!O())return!1;return!0}if(r("import")){if(!r("(")||!s())return!1;if(r(",")&&!L())return!1;return r(")")}if(["export","function","class","const","let","var","return","throw","default","new","abstract"].includes(n()))return!1;return o()}function E(){if(n()==="keyof"||n()==="readonly"||n()==="unique")return e++,E();if(r("infer")){if(!o())return!1;if(r("extends")&&!s(!1))return!1;return!0}if(!P())return!1;for(;;)if(r(".")){if(!o())return!1}else if(n()==="<"){if(g(f[e-1].end,f[e].start))return!0;if(!O())return!1}else if(n()==="["){if(g(f[e-1].end,f[e].start))return!0;if(e++,!r("]")&&!(s()&&r("]")))return!1}else return!0}function R(){if(r("&"),!E())return!1;while(r("&"))if(!E())return!1;return!0}function s(t=!0){let u=e,a=z[t?1:0],i=a.get(u);if(i!==void 0){if(i<0)return!1;return e=i,!0}let l=Q(t);if(a.set(u,l?e:-1),!l)e=u;return l}function Q(t){if(r("|"),!R())return!1;while(r("|"))if(!R())return!1;if(t&&n()==="extends"&&!g(f[e-1].end,f[e].start))return e++,s(!1)&&r("?")&&s()&&r(":")&&s();return!0}function U(){if(n()!=="("||!A())return!1;if(r(":")&&!q())return!1;return k("=>")}function V(){r("async");let t=r("function");if(t){if(r("*"),d())e++}if(n()==="<"&&!x())return!1;if(n()!=="("||!A())return!1;if(r(":")&&!q())return!1;return t?n()==="{":k("=>")}function W(){let t=n();if(t==="<"||t===">"||t==="+"||t==="-")return!1;if(t==="("||f[e]?.kind==="literal"&&b.charCodeAt(f[e].start)===96)return!0;if(!f[e]||g(f[e-1].end,f[e].start))return!0;if(["*","/","%","=","&","|","^","?",":",",",";",")","]","}","in","instanceof","as","satisfies"].includes(t))return!0;if(t==="!")return n(e+1)==="="&&f[e].end===f[e+1]?.start;return!d()&&f[e]?.kind!=="quoted"&&f[e]?.kind!=="literal"&&!["{","[","~","#","@"].includes(t)&&!/^[0-9]$/.test(t)}return(t,u,a)=>{let i=0,l=f.length;while(i<l){let p=i+l>>>1;if(f[p].start<t)i=p+1;else l=p}if(f[i]?.start!==t)return;if(I!==u){I=u,w=void 0;let p=0,M=i;while(p<M){let C=p+M>>>1;if(f[C].start<u)p=C+1;else M=C}if(e=p,V())w=n()==="{"?f[e].start:f[e-1].end}if(w!==void 0&&t<w)return{end:w,completeOperand:!1,parameters:!0};if(n(i)!=="<")return;e=i;let c=n(i-1),j=t===u||["=","+","-","*","/","%","&","|","^","!","~","?",":","<",">","void","typeof","await","yield","delete"].includes(c);if((c==="function"||c==="class"||c==="*"&&n(i-2)==="function"||d(i-1)&&(n(i-2)==="function"||n(i-2)==="class"||n(i-2)==="*"&&n(i-3)==="function"))&&h(x))return{end:f[e-1].end,completeOperand:!1,parameters:!0};if(e=i,(j||c==="async")&&h(x)){let p=f[e-1].end;if(h(U))return{end:p,completeOperand:!1,parameters:!0}}e=i;let X=c==="."&&n(i-2)==="?"&&f[i-2].end===f[i-1].start;if((f[i-1]?.end??-1)>=u&&(X||d(i-1)||c===")"||c==="]"||c==="!"||c===">"&&f[i-1].end===a)&&h(O)&&W())return{end:f[e-1].end,completeOperand:!0};if(e=i,j&&r("<")&&s()&&r(">"))return{end:f[e-1].end,completeOperand:!1};return}}
3
- export{_};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import _ from"process";import{existsSync as U}from"fs";import{arch as I,platform as E}from"os";import{fileURLToPath as L}from"url";var T=["native","typescript"];function q(n,t="engine"){if(n===void 0||n===null||n==="")return;if(typeof n==="string"&&T.includes(n))return n;throw Error(`Invalid ${t} ${JSON.stringify(n)}: expected "native" or "typescript"`)}var S;function hi(n){S=q(n)}function J(n){return q(n)??S??q(_.env.DTSX_ENGINE,"DTSX_ENGINE")??"native"}var b;function w(){return`${E()==="win32"?"windows":E()}-${I()}`}function z(n){let t=[],e=_.env.DTSX_NATIVE_LIBRARY;if(e)t.push(e);for(let r of[`../native/${w()}/${n}`,`../../native/${w()}/${n}`,`../../zig-dtsx/zig-out/lib/${n}`,`../../zig-dtsx/zig-out/bin/${n}`])try{t.push(L(new URL(r,import.meta.url)))}catch{}return t}function B(){if(typeof globalThis.Bun>"u")return null;let n;try{n=import.meta.require("bun:ffi")}catch{return null}let{dlopen:t,FFIType:e,ptr:r,suffix:c,toArrayBuffer:a}=n,g=c==="dll"?`zig-dtsx.${c}`:`libzig-dtsx.${c}`;for(let u of z(g)){if(!U(u))continue;try{let p=t(u,{process_source_checked_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.ptr],returns:e.ptr},process_source_with_context_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.u64,e.ptr,e.ptr],returns:e.ptr},free_result:{args:[e.ptr,e.u64],returns:e.void}}),{symbols:l}=p,f=new TextDecoder;return{checked:(i,o,d,m,y,h)=>l.process_source_checked_v1(r(i),o,d,m,r(y),r(h)),contextual:(i,o,d,m,y,h,A,N)=>l.process_source_with_context_v1(r(i),o,d,m,r(y),h,r(A),r(N)),read:(i,o)=>{if(!i)return"";let d=o?f.decode(a(i,0,o)):"";return l.free_result(i,o),d}}}catch{continue}}return null}function k(){if(b===void 0)b=B();return b}function yi(n){return J(n)==="native"&&k()!==null}var D=new TextEncoder,s=new Uint8Array(65536),x=new BigUint64Array(1),v=new Uint32Array(1);function Ee(n,t){if(J(t.engine)==="typescript")return null;let e=k();if(!e)return null;if(n.length*3>s.length)s=new Uint8Array(n.length*3);let{written:r}=D.encodeInto(n,s),c=t.sourceFile!==void 0||(t.inferenceSources?.size??0)>0||(t.augmentationImports?.size??0)>0,a;if(c){let u=t.sourceFile??"source.ts",p=D.encode(JSON.stringify({version:1,moduleSpecifierMode:"preserve",sourceFile:u,outputFile:u.replace(/\.(?:[cm]?[jt]sx?|vue|stx)$/,".d.ts"),sourceHash:new Bun.CryptoHasher("sha256").update(s.subarray(0,r)).digest("hex"),rewrites:[],augmentationImports:[...t.augmentationImports??[]],inferenceSources:[...t.inferenceSources??[]].map(([l,f])=>({specifier:l,source:f}))}));a=e.contextual(s,r,t.keepComments,t.isolatedDeclarations,p,p.length,x,v)}else a=e.checked(s,r,t.keepComments,t.isolatedDeclarations,x,v);let g=Number(x[0]);if(v[0]!==0)return e.read(a,g),null;return e.read(a,g)}
3
- export{q,hi,J,yi,Ee};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{G}from"./chunk-2qbj76ap.js";import{P}from"./chunk-1t77gtcx.js";import{De,Pe}from"./chunk-yxcyqezk.js";import{createHash as x}from"crypto";import{readFile as d}from"fs/promises";import{resolve as m}from"path";async function Fn(g){let e={...G,...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 De(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=Pe(r,e,o.resolver),i=[],S=new Set(P(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
- export{Fn};
@@ -1,6 +0,0 @@
1
- // @bun
2
- import{e,M}from"./chunk-8vvryt8p.js";import{Ie}from"./chunk-g9emajpc.js";import{s}from"./chunk-5tn8854w.js";import{existsSync as u,readFileSync as w}from"fs";import{dirname as W,join as d,resolve as v}from"path";async function ti(i){let c=[],n=new Set;async function t(a,f){let o=v(a);if(n.has(o))return;if(n.add(o),!u(o)){e.warn(`tsconfig not found: ${o}`);return}try{let p=w(o,"utf-8"),r=JSON.parse(Ie(p)),l=W(o),g=P(l,f),m=[];if(r.references)for(let y of r.references){let h=v(l,y.path),C=u(d(h,"tsconfig.json"))?d(h,"tsconfig.json"):h;await t(C,g);let G=P(W(C),g);m.push(G)}let j="./src";if(r.compilerOptions?.rootDir)j=r.compilerOptions.rootDir;else if(r.include&&r.include.length>0){if(r.include[0].startsWith("src/"))j="./src"}let k="./dist";if(r.compilerOptions?.outDir)k=r.compilerOptions.outDir;else if(r.compilerOptions?.declarationDir)k=r.compilerOptions.declarationDir;c.push({name:g,root:l,tsconfigPath:o,references:m,config:{root:j,outdir:k}})}catch(p){let r=p instanceof Error?p.message:String(p);e.warn(`Failed to parse ${o}: ${r}`)}}return await t(i),c}function P(i,c){let n=d(i,"package.json");if(u(n))try{let a=w(n,"utf-8"),f=JSON.parse(a);if(f.name)return f.name}catch{}let t=i.split("/").pop()||"unknown";return c?`${c}/${t}`:t}function ni(i){let c=new Map(i.map((o)=>[o.name,o])),n=[],t=new Set,a=new Set;function f(o){if(t.has(o))return;if(a.has(o)){e.warn(`Circular dependency detected involving: ${o}`);return}a.add(o);let p=c.get(o);if(p){for(let r of p.references)f(r);n.push(p)}a.delete(o),t.add(o)}for(let o of i)f(o.name);return n}async function bn(i){let c=Date.now(),n=ni(i.projects);e.info(`Generating declarations for ${n.length} projects...`);let t=[],a=!0;for(let r of n){e.info(`
3
- [${r.name}] Generating...`);try{let l={...i.sharedConfig,...r.config,cwd:r.root,tsconfigPath:r.tsconfigPath},g=await s(l),m=g.filesFailed===0;if(!m)a=!1;t.push({name:r.name,stats:g,success:m}),e.info(`[${r.name}] Generated ${g.filesGenerated} files`)}catch(l){a=!1;let g=l instanceof Error?l.message:String(l);t.push({name:r.name,stats:{generationMode:r.config?.isolatedDeclarations||i.sharedConfig?.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:g}),e.error(`[${r.name}] Failed: ${g}`)}}let f=Date.now()-c,o=t.filter((r)=>r.success).length,p=t.length-o;if(e.info(`
4
- --- Workspace Generation Summary ---`),e.info(`Projects processed: ${t.length}`),e.info(`Successful: ${o}`),p>0)e.info(`Failed: ${p}`);return e.info(`Total duration: ${f}ms`),e.info(`------------------------------------
5
- `),{success:a,projects:t,durationMs:f}}async function uo(i,c){if(c?.logLevel)M(c.logLevel);let n=d(i,"tsconfig.json");if(!u(n))throw Error(`Root tsconfig.json not found at: ${n}`);e.info("Discovering workspace projects...");let t=await ti(n);if(t.length===0)return e.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return e.info(`Found ${t.length} projects`),bn({root:i,projects:t,sharedConfig:c})}async function ri(i){let c=d(i,"package.json");if(!u(c))return[];try{let n=w(c,"utf-8"),t=JSON.parse(n),a=[];if(Array.isArray(t.workspaces))a=t.workspaces;else if(t.workspaces?.packages)a=t.workspaces.packages;return a}catch{return[]}}async function ii(i,c){let{Glob:n}=await Promise.resolve(globalThis.Bun),t=[];for(let a of c){let f=new n(a);for await(let o of f.scan({cwd:i,absolute:!0,onlyFiles:!1})){let p=d(o,"package.json");if(u(p))t.push(o)}}return t}async function fo(i,c){if(c?.logLevel)M(c.logLevel);let n=await ri(i);if(n.length===0)return e.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};e.info(`Found workspace patterns: ${n.join(", ")}`);let t=await ii(i,n);if(t.length===0)return e.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};e.info(`Found ${t.length} workspace packages`);let a=t.map((f)=>{let o=d(f,"tsconfig.json");return{name:P(f),root:f,tsconfigPath:u(o)?o:"",references:[]}});return bn({root:i,projects:a,sharedConfig:c})}
6
- export{ti,ni,bn,uo,ri,ii,fo};
@@ -1,22 +0,0 @@
1
- // @bun
2
- import{r}from"./chunk-0a1xppye.js";import{l}from"./chunk-81jrzxr6.js";import{existsSync as P,readFileSync as b,unwatchFile as w}from"fs";var Ur;((o)=>{o[o.Error=1]="Error";o[o.Warning=2]="Warning";o[o.Information=3]="Information";o[o.Hint=4]="Hint"})(Ur||={});var Hr;((s)=>{s[s.File=1]="File";s[s.Module=2]="Module";s[s.Namespace=3]="Namespace";s[s.Package=4]="Package";s[s.Class=5]="Class";s[s.Method=6]="Method";s[s.Property=7]="Property";s[s.Field=8]="Field";s[s.Constructor=9]="Constructor";s[s.Enum=10]="Enum";s[s.Interface=11]="Interface";s[s.Function=12]="Function";s[s.Variable=13]="Variable";s[s.Constant=14]="Constant";s[s.String=15]="String";s[s.Number=16]="Number";s[s.Boolean=17]="Boolean";s[s.Array=18]="Array";s[s.Object=19]="Object";s[s.Key=20]="Key";s[s.Null=21]="Null";s[s.EnumMember=22]="EnumMember";s[s.Struct=23]="Struct";s[s.Event=24]="Event";s[s.Operator=25]="Operator";s[s.TypeParameter=26]="TypeParameter"})(Hr||={});var Kr;((c)=>{c[c.Text=1]="Text";c[c.Method=2]="Method";c[c.Function=3]="Function";c[c.Constructor=4]="Constructor";c[c.Field=5]="Field";c[c.Variable=6]="Variable";c[c.Class=7]="Class";c[c.Interface=8]="Interface";c[c.Module=9]="Module";c[c.Property=10]="Property";c[c.Unit=11]="Unit";c[c.Value=12]="Value";c[c.Enum=13]="Enum";c[c.Keyword=14]="Keyword";c[c.Snippet=15]="Snippet";c[c.Color=16]="Color";c[c.File=17]="File";c[c.Reference=18]="Reference";c[c.Folder=19]="Folder";c[c.EnumMember=20]="EnumMember";c[c.Constant=21]="Constant";c[c.Struct=22]="Struct";c[c.Event=23]="Event";c[c.Operator=24]="Operator";c[c.TypeParameter=25]="TypeParameter"})(Kr||={});var qr;((n)=>{n[n.Text=1]="Text";n[n.Read=2]="Read";n[n.Write=3]="Write"})(qr||={});class dn{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(t){return this.rootUri=t.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(t){let{uri:e,text:i,version:n}=t.textDocument;this.updateDocument(e,i,n)}didChange(t){let{uri:e,version:i}=t.textDocument,n=t.contentChanges[0]?.text||"";this.updateDocument(e,n,i)}didClose(t){let e=t.textDocument.uri;if(this.documents.delete(e),this.watchers.get(e))w(this.uriToPath(e)),this.watchers.delete(e)}updateDocument(t,e,i){let n=this.uriToPath(t),o=r(e,n,!0);this.documents.set(t,{content:e,version:i,declarations:o})}getDiagnostics(t){let e=this.documents.get(t);if(!e)return[];let i=[];for(let n of e.declarations){if(n.isExported&&n.kind==="variable"&&!n.typeAnnotation)i.push({range:this.getDeclarationRange(n,e.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${n.name}' should have an explicit type annotation for better declaration generation`});if(n.typeAnnotation==="any"||n.returnType==="any")i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(n.kind==="function"&&n.isExported&&!n.returnType)i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${n.name}' should have an explicit return type for better declaration generation`})}return i}hover(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:i,character:n}=t.position,a=e.content.split(`
3
- `)[i]||"",u=a.slice(0,n).match(/[\w$]+$/),d=a.slice(n).match(/^[\w$]+/);if(!u&&!d)return null;let g=(u?.[0]||"")+(d?.[0]||""),f=e.declarations.find((x)=>x.name===g);if(!f)return null;let m=`\`\`\`typescript
4
- ${this.buildSignature(f)}
5
- \`\`\``;if(f.leadingComments&&f.leadingComments.length>0){let v=f.leadingComments.join(`
6
- `).match(/\*\s*([^@*][^*]*)/);if(v)m+=`
7
-
8
- ${v[1].trim()}`}return{contents:{kind:"markdown",value:m}}}completion(t){let e=this.documents.get(t.textDocument.uri);if(!e)return[];let i=[];for(let n of e.declarations){if(!n.isExported)continue;let o=6;switch(n.kind){case"function":o=3;break;case"class":o=7;break;case"interface":o=8;break;case"type":o=8;break;case"enum":o=13;break}i.push({label:n.name,kind:o,detail:this.buildSignature(n)})}return i}definition(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:i,character:n}=t.position,a=e.content.split(`
9
- `)[i]||"",u=a.slice(0,n).match(/[\w$]+$/),d=a.slice(n).match(/^[\w$]+/);if(!u&&!d)return null;let g=(u?.[0]||"")+(d?.[0]||""),f=e.declarations.find((p)=>p.name===g);if(!f)return null;return{uri:t.textDocument.uri,range:this.getDeclarationRange(f,e.content)}}references(t){let e=[],i=this.getWordAtPosition(t.textDocument.uri,t.position);if(!i)return e;for(let[n,o]of this.documents){let a=o.content.split(`
10
- `);for(let u=0;u<a.length;u++){let d=a[u],g=0;while(g<d.length){let f=d.indexOf(i,g);if(f===-1)break;let p=f>0?d[f-1]:" ",m=f+i.length<d.length?d[f+i.length]:" ";if(!/[\w$]/.test(p)&&!/[\w$]/.test(m))e.push({uri:n,range:{start:{line:u,character:f},end:{line:u,character:f+i.length}}});g=f+1}}}return e}prepareRename(t){let e=this.getWordAtPosition(t.textDocument.uri,t.position);if(!e)return null;let i=this.documents.get(t.textDocument.uri);if(!i)return null;let n=i.declarations.find((a)=>a.name===e);if(!n)return null;return{range:this.getDeclarationRange(n,i.content),placeholder:e}}rename(t){if(!this.getWordAtPosition(t.textDocument.uri,t.position))return null;let i=this.references({textDocument:t.textDocument,position:t.position,context:{includeDeclaration:!0}});if(i.length===0)return null;let n={};for(let o of i){if(!n[o.uri])n[o.uri]=[];n[o.uri].push({range:o.range,newText:t.newName})}return{changes:n}}documentSymbols(t){let e=this.documents.get(t.textDocument.uri);if(!e)return[];let i=[];for(let n of e.declarations){let o=this.getDeclarationRange(n,e.content),a=this.declarationKindToSymbolKind(n.kind),u={name:n.name,detail:this.buildSignature(n),kind:a,range:o,selectionRange:o};if(n.members&&n.members.length>0)u.children=n.members.map((d)=>({name:d.name,kind:this.declarationKindToSymbolKind(d.kind),range:this.getDeclarationRange(d,e.content),selectionRange:this.getDeclarationRange(d,e.content)}));i.push(u)}return i}workspaceSymbols(t){let e=[],i=t.query.toLowerCase();for(let[n,o]of this.documents)for(let a of o.declarations){if(!a.isExported)continue;if(i&&!a.name.toLowerCase().includes(i))continue;e.push({name:a.name,kind:this.declarationKindToSymbolKind(a.kind),location:{uri:n,range:this.getDeclarationRange(a,o.content)}})}return e}codeActions(t){let e=[];if(!this.documents.get(t.textDocument.uri))return e;for(let o of t.context.diagnostics){if(o.code==="missing-type"){let a=this.getWordAtRange(t.textDocument.uri,o.range);if(a)e.push({title:`Add type annotation to '${a}'`,kind:"quickfix",diagnostics:[o],edit:{changes:{[t.textDocument.uri]:[{range:{start:o.range.end,end:o.range.end},newText:": unknown"}]}}})}if(o.code==="any-type")e.push({title:"Replace 'any' with 'unknown'",kind:"quickfix",diagnostics:[o],isPreferred:!0,edit:{changes:{[t.textDocument.uri]:[{range:o.range,newText:"unknown"}]}}});if(o.code==="missing-return-type"){let a=this.getWordAtRange(t.textDocument.uri,o.range);if(a)e.push({title:`Add return type to '${a}'`,kind:"quickfix",diagnostics:[o]})}}let n=this.getDeclarationAtPosition(t.textDocument.uri,t.range.start);if(n){if(n.kind==="function")e.push({title:"Extract function signature to type",kind:"refactor.extract"});if(n.kind==="interface"||n.kind==="type")e.push({title:"Generate runtime validator",kind:"source"})}return e}signatureHelp(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:i,character:n}=t.position,a=e.content.split(`
11
- `)[i]||"",u=0,d=-1,g=0;for(let h=n-1;h>=0;h--){let D=a[h];if(D===")")u++;else if(D==="("){if(u===0){d=h;break}u--}else if(D===","&&u===0)g++}if(d===-1)return null;let p=a.slice(0,d).trimEnd().match(/[\w$]+$/);if(!p)return null;let m=p[0],x=e.declarations.find((h)=>h.name===m&&h.kind==="function");if(!x||!x.parameters)return null;let v=x.parameters.map((h)=>{let D="";if(h.rest)D+="...";if(D+=h.name,h.optional)D+="?";if(h.type)D+=`: ${h.type}`;return D});return{signatures:[{label:`${m}(${v.join(", ")}): ${x.returnType||"void"}`,parameters:x.parameters.map((h)=>({label:h.name,documentation:h.type?`Type: ${h.type}`:void 0}))}],activeSignature:0,activeParameter:Math.min(g,x.parameters.length-1)}}documentHighlight(t){let e=[],i=this.getWordAtPosition(t.textDocument.uri,t.position);if(!i)return e;let n=this.documents.get(t.textDocument.uri);if(!n)return e;let o=n.content.split(`
12
- `);for(let a=0;a<o.length;a++){let u=o[a],d=0;while(d<u.length){let g=u.indexOf(i,d);if(g===-1)break;let f=g>0?u[g-1]:" ",p=g+i.length<u.length?u[g+i.length]:" ";if(!/[\w$]/.test(f)&&!/[\w$]/.test(p)){let m=/^\s*[=:]/.test(u.slice(g+i.length))||/^(const|let|var|function|class|interface|type|enum)\s+$/.test(u.slice(0,g));e.push({range:{start:{line:a,character:g},end:{line:a,character:g+i.length}},kind:m?3:2})}d=g+1}}return e}async formatting(t){let e=this.documents.get(t.textDocument.uri);if(!e)return[];let i=this.generateDts(t.textDocument.uri);if(!i)return[];let n=e.content.split(`
13
- `);return[{range:{start:{line:0,character:0},end:{line:n.length-1,character:n[n.length-1].length}},newText:i}]}getWordAtPosition(t,e){let i=this.documents.get(t);if(!i)return null;let o=i.content.split(`
14
- `)[e.line]||"",a=o.slice(0,e.character).match(/[\w$]+$/),u=o.slice(e.character).match(/^[\w$]+/);if(!a&&!u)return null;return(a?.[0]||"")+(u?.[0]||"")}getWordAtRange(t,e){let i=this.documents.get(t);if(!i)return null;let n=i.content.split(`
15
- `);if(e.start.line===e.end.line)return n[e.start.line]?.slice(e.start.character,e.end.character)||null;return null}getDeclarationAtPosition(t,e){let i=this.documents.get(t);if(!i)return null;for(let n of i.declarations){let o=this.getDeclarationRange(n,i.content);if(this.positionInRange(e,o))return n}return null}positionInRange(t,e){if(t.line<e.start.line||t.line>e.end.line)return!1;if(t.line===e.start.line&&t.character<e.start.character)return!1;if(t.line===e.end.line&&t.character>e.end.character)return!1;return!0}declarationKindToSymbolKind(t){switch(t){case"function":return 12;case"class":return 5;case"interface":return 11;case"type":return 11;case"enum":return 10;case"variable":return 13;case"const":return 14;case"property":return 7;case"method":return 6;case"module":return 2;case"namespace":return 3;default:return 13}}generateDts(t){let e=this.documents.get(t);if(!e)return null;let i={filePath:this.uriToPath(t),sourceCode:e.content,declarations:e.declarations};return l(e.declarations,i,!0,this.config.importOrder)}buildSignature(t){switch(t.kind){case"function":{let e=t.parameters?.map((o)=>{let a="";if(o.rest)a+="...";if(a+=o.name,o.optional)a+="?";if(o.type)a+=`: ${o.type}`;return a}).join(", ")||"",i=t.generics||"",n=t.returnType?`: ${t.returnType}`:"";return`function ${t.name}${i}(${e})${n}`}case"variable":return`const ${t.name}: ${t.typeAnnotation||"unknown"}`;case"interface":return`interface ${t.name}${t.generics||""}${t.extends?` extends ${t.extends}`:""}`;case"type":return`type ${t.name}${t.generics||""} = ${t.typeAnnotation||"unknown"}`;case"class":return`class ${t.name}${t.generics||""}${t.extends?` extends ${t.extends}`:""}`;case"enum":return`enum ${t.name}`;default:return t.name}}getDeclarationRange(t,e){if(t.start!==void 0&&t.end!==void 0)return{start:this.offsetToPosition(t.start,e),end:this.offsetToPosition(t.end,e)};let i=e.split(`
16
- `);for(let n=0;n<i.length;n++){let o=i[n].indexOf(t.name);if(o!==-1)return{start:{line:n,character:o},end:{line:n,character:o+t.name.length}}}return{start:{line:0,character:0},end:{line:0,character:0}}}offsetToPosition(t,e){let i=0,n=0;for(let o=0;o<t&&o<e.length;o++)if(e[o]===`
17
- `)i++,n=0;else n++;return{line:i,character:n}}uriToPath(t){if(t.startsWith("file://"))return decodeURIComponent(t.slice(7));return t}pathToUri(t){return`file://${encodeURIComponent(t).replace(/%2F/g,"/")}`}handleMessage(t){if(t.method==="initialize")return{jsonrpc:"2.0",id:t.id,result:this.initialize(t.params)};if(t.method==="initialized")return null;if(t.method==="shutdown")return{jsonrpc:"2.0",id:t.id,result:null};if(t.method==="exit")process.exit(0);let e=t.params;if(t.method==="textDocument/didOpen")return this.didOpen(e),null;if(t.method==="textDocument/didChange")return this.didChange(e),null;if(t.method==="textDocument/didClose")return this.didClose(e),null;if(t.method==="textDocument/hover")return{jsonrpc:"2.0",id:t.id,result:this.hover(e)};if(t.method==="textDocument/completion")return{jsonrpc:"2.0",id:t.id,result:this.completion(e)};if(t.method==="textDocument/definition")return{jsonrpc:"2.0",id:t.id,result:this.definition(e)};if(t.method==="textDocument/references")return{jsonrpc:"2.0",id:t.id,result:this.references(e)};if(t.method==="textDocument/prepareRename")return{jsonrpc:"2.0",id:t.id,result:this.prepareRename(e)};if(t.method==="textDocument/rename")return{jsonrpc:"2.0",id:t.id,result:this.rename(e)};if(t.method==="textDocument/documentSymbol")return{jsonrpc:"2.0",id:t.id,result:this.documentSymbols(e)};if(t.method==="workspace/symbol")return{jsonrpc:"2.0",id:t.id,result:this.workspaceSymbols(e)};if(t.method==="textDocument/codeAction")return{jsonrpc:"2.0",id:t.id,result:this.codeActions(e)};if(t.method==="textDocument/signatureHelp")return{jsonrpc:"2.0",id:t.id,result:this.signatureHelp(e)};if(t.method==="textDocument/documentHighlight")return{jsonrpc:"2.0",id:t.id,result:this.documentHighlight(e)};if(t.method==="textDocument/formatting")return{jsonrpc:"2.0",id:t.id,result:this.formatting(e)};if(t.method==="textDocument/diagnostic"){let i=e?.textDocument?.uri;return{jsonrpc:"2.0",id:t.id,result:{kind:"full",items:i?this.getDiagnostics(i):[]}}}if(t.id!==void 0)return{jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`Method not found: ${t.method}`}};return null}}function zs(){let t=new dn,e="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(i)=>{e+=i;while(!0){let n=e.indexOf(`\r
18
- \r
19
- `);if(n===-1)break;let a=e.slice(0,n).match(/Content-Length:\s*(\d+)/i);if(!a){e=e.slice(n+4);continue}let u=Number.parseInt(a[1],10),d=n+4,g=d+u;if(e.length<g)break;let f=e.slice(d,g);e=e.slice(g);try{let p=JSON.parse(f),m=t.handleMessage(p);if(m){let x=JSON.stringify(m),v=Buffer.byteLength(x,"utf8");process.stdout.write(`Content-Length: ${v}\r
20
- \r
21
- ${x}`)}}catch(p){console.error("Error parsing LSP message:",p)}}})}function Us(t,e){return(i)=>{if(!P(i))return;let n=b(i,"utf-8"),o=`file://${i}`;t.didOpen({textDocument:{uri:o,languageId:"typescript",version:1,text:n}});let a=t.getDiagnostics(o);e(o,a)}}
22
- export{Ur,Hr,Kr,qr,dn,zs,Us};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{s}from"./chunk-5tn8854w.js";function ve(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 Na=ve,pr=ve,Fa=ve;
3
- export{ve,Na,pr,Fa};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{t,d,E}from"./chunk-t5nmnzy6.js";import{S}from"./chunk-hkcqbex1.js";function D(n){return typeof n==="string"?E(n,"'"):String(n)}function Sa(n,y,m=new Map){let o=t(n),e=new Map(m),i=new Map,f=[],c=1,p=0,q=0;for(let r=1;r<o.length;r++){let w=o[r],K=n.slice(w.start,w.end);if(w.kind==="punctuation"&&p===0&&(K===","||K==="}")){let l=o.slice(c,r),a=l[0];if(a){let u=a.kind==="quoted"?d(n.slice(a.start,a.end)):n.slice(a.start,a.end),v=l.findIndex((g)=>g.kind==="punctuation"&&n[g.start]==="="),s=q;if(v>=0){let g=l.slice(v+1),B="",C=l[v].end;for(let x=0;x+2<g.length;x++){let[h,A,M]=g.slice(x,x+3);if(h.kind!=="word"||M.kind!=="word"||n.slice(A.start,A.end)!==".")continue;let b=e.get(`${n.slice(h.start,h.end)}.${n.slice(M.start,M.end)}`);if(b===void 0||typeof b==="object")continue;B+=n.slice(C,h.start)+D(b),C=M.end,x+=2}B+=n.slice(C,l.at(-1).end),s=S(B,e),f.push({start:l[v].start,end:l.at(-1).end,text:s===void 0?"":`= ${D(s)}`})}else if(s!==void 0)f.push({start:a.end,end:a.end,text:` = ${D(s)}`});if(q=typeof s==="number"?s+1:void 0,u!==void 0){if(e.delete(u),e.delete(`${y}.${u}`),s!==void 0)i.set(u,s),e.set(u,s),e.set(`${y}.${u}`,s)}}c=r+1}else if(w.kind==="punctuation"){if("([{".includes(K))p++;else if(")]}".includes(K))p--}}let k=n;for(let r of f.reverse())k=k.slice(0,r.start)+r.text+k.slice(r.end);return{body:k,members:i}}function Kn(n,y){let m=[...new Set([...n,...y.values()])];if(!m.some((e)=>e.kind==="enum"))return;m.sort((e,i)=>(e.start??0)-(i.start??0));let o=new Map;for(let e of m)if(e.kind==="enum"){let i=e.text.indexOf("{");if(i<0)continue;if(t(e.text.slice(0,i)).some((c)=>e.text.slice(c.start,c.end)==="declare"))continue;let f=Sa(e.text.slice(i),e.name,o);e.text=e.text.slice(0,i)+f.body;for(let[c,p]of f.members)o.set(`${e.name}.${c}`,p)}else if(e.kind==="variable"&&e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion")&&typeof e.value==="string"){let i=S(e.value,o);if(i!==void 0)o.set(e.name,i)}}
3
- export{Sa,Kn};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{a,i}from"./chunk-cgqg1br8.js";import{t,m}from"./chunk-t5nmnzy6.js";import{ft,Vt}from"./chunk-4cr1q0yf.js";import{C}from"./chunk-9mdgtq38.js";import{n,U}from"./chunk-7rdazac9.js";function F(g,b){let k=(B)=>t(B).map((h)=>B.slice(h.start,h.end)).join("");return k(g)===k(b)}function fe(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let b=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(b)?b:void 0}function de(g,b){if(F(g,b))return g;let k=fe(b);if(!k)return;let B=t(g),h=0,T=0,E=[];for(let S of B){let v=g.slice(S.start,S.end);if(v==="("||v==="["||v==="{"||v==="<")h++;else if(v===")"||v==="]"||v==="}"||v===">")h--;else if(v==="|"&&h===0)E.push(g.slice(T,S.start).trim()),T=S.end}E.push(g.slice(T).trim());let O=E.find((S)=>F(S,b));if(O)return O;if(E.includes(k))return k==="boolean"&&(b==="true"||b==="false")?b:k;return}function Gt(g){for(let b of g){if(b.kind!=="variable"||b.typeAnnotation||typeof b.value!=="string")continue;let k=U(b.value);if(k&&n(b.value,!1)===k)b.inferredType=k,b.text=`${b.isExported?"export ":""}declare ${b.modifiers?.[0]??"const"} ${b.name}: ${k};`}}function Yn(g,b,k,B=new Set){Gt([...b,...k.values()]);let h=new Map,T=[],E=new Set;for(let e of[...b,...k.values()]){if(E.has(e))continue;if(E.add(e),T.push(e),e.kind==="import")for(let o of C(e.text))h.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))h.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")h.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}T.sort((e,o)=>(e.start??0)-(o.start??0));let O=new Set(T.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of B)O.add(e);let S=new Map,v=(e)=>{if(e=e.trimStart(),S.has(e))return S.get(e);if(S.set(e,void 0),!a(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 l=e.slice(r[s].start,r[s].end);if(l==="(")d++;else if(l===")"&&--d===0){let c=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return S.set(e,c),c}}return},_=new Set(T.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>v(e.value)).filter((e)=>e!==void 0)).size?m(g):void 0,H=new Map;if(_){let e=0;for(let o=0;o<_.length;o++){let r=g.slice(_[o].start,_[o].end);if(e===0&&r==="function"){let d=_[o+1],s=d&&g.slice(d.start,d.end)==="*"?_[o+2]:d;if(s?.kind==="word"){let l=g.slice(s.start,s.end);H.set(l,(H.get(l)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let R=new Map;for(let e of T)if(e.kind==="function"&&!e.generics&&H.get(e.name)===1)R.set(e.name,e);for(let e of B){let o=T.find((r)=>r.kind==="import"&&C(r.text).includes(e));if(o)R.set(e,o)}let W="__dtsx_call_result";while(g.includes(W))W+="_";let X=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${W} ? ${W} : never`,G=new Map,L=!1;for(let e of T){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=v(e.value);if(o&&R.has(o))G.set(e,X(o)),h.get(e.name).active=!0,h.get(o).active=!0,L=!0;if(e.modifiers?.[0]!=="const")continue;let r=ft(e.value);if(!r||r===e.name||!h.has(r))continue;h.get(r).active=!0,h.get(e.name).active=!0,L=!0}if(!L)return;let u=_??m(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",y=new Map,z=new Map,J=new Set,N=new Set,Q=new Set,Y=new Map,x=[];for(let e=0;e<u.length;e++){let o=f(e),r=x.at(-1);if(r!==void 0)z.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))J.add(e);if(["(","[","{"].includes(o))x.push(e);else if([")","]","}"].includes(o)){let d=x.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))x.pop(),y.set(d,e)}}let Z=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);Z.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=te(e);if(o!==void 0)N.add(o)}for(let e of N)ce(e);let w=0;function ee(e){let o=ft(e);if(o){let l=h.get(o);return{type:l?.flow,unresolved:l?.unresolved??!1}}let r=v(e),d=r?R.get(r):void 0;if(d)return{type:d.returnType&&fe(d.returnType)?d.returnType:X(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function A(e){return Z.get(e)??""}function P(e){if(u[e]?.kind!=="word"||Q.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=h.get(f(e));if(!o?.active)return;let r=A(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(A(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:A(e-2)}}return}function ne(e){let o=P(e);return o?.operator==="="?o.binding:void 0}function te(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=te(o);if(s!==void 0){o=(y.get(s)??s)+1;continue}}if(d==="function"){let s=oe(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&A(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(y.get(o)??o)+1}return}function ie(e,o,r){let d=e,s=!1,l=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(l.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=y.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 c=d+1;while(c<o&&u[c-1].end===u[c].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(c)))c++;if(d<o&&n(g.slice(u[d].start,u[c-1].end),!1)==="number")return{next:c,isStatic:s};return}function V(e,o,r){let d=ie(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let l=1;s++;while(s<o&&l>0){if(f(s)==="<")l++;else if(f(s)===">"&&A(s-1)!=="=>")l--;s=(y.get(s)??s)+1}if(l!==0)return}return s}function re(e,o,r){return V(e,o,r)===o}function ae(e,o){let r=0,d=-1;for(let s=e;s<o;s=(y.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)===">"&&A(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function le(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=V(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function q(e,o,r=!1){let d=y.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&A(s)==="=")return s;if(s>e&&z.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let l=f(s-1),p=!(l===">"&&ae(e,s)&&le(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(l),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!M)return s}s=(y.get(s)??s)+1}return d}function K(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&y.has(r)){r=y.get(r);continue}if(u[r].kind==="word")Q.add(r)}}function ce(e){let o=y.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(y.get(r+1)??r+1)+1;continue}let d=ie(r,o,!0);if(!d){r++;continue}let s=V(r,o,!0);if(s===void 0){r++;continue}if(K(r,s),f(s)==="("){let c=y.get(s),p=c===void 0?void 0:se(c,o);if(p!==void 0){r=(y.get(p)??p)+1;continue}}let l=s;if(f(l)===":")l=q(l+1,e,!0);if(A(l)==="="){K(r,l+1);let c=l+1,p=q(c,e);if(!d.isStatic&&p>c)Y.set(c,p);r=p}else{let c=q(s,e);K(r,c),r=Math.max(r+1,c)}}}function ue(e){let o=z.get(e);if(o===void 0)return!1;let r=N.has(o);if(!r&&!J.has(o))return!1;if(re(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=z.get(d),l=z.get(d)===o&&(f(d)===","||r&&f(d)===";"),c=r&&f(d)==="}"&&s!==void 0&&z.get(s)===o,p=r&&z.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((l||c||p)&&re(d+1,e,r))return!0}return!1}function se(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Vt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(y.get(r)??r)+1}return}function oe(e,o){let r=-1;if(f(e)==="("){let s=y.get(e);if(s!==void 0&&ue(e))r=se(s,o)??-1;else if(s!==void 0&&A(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let l=s+2;while(l<o&&f(l)!==";"){if(A(l)==="=>"){r=l+2;break}l=(y.get(l)??l)+1}}}else if(u[e]?.kind==="word"&&A(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(y.get(s)??s)+1;let l=y.get(s);if(l===void 0)return;r=l+1;let c=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(c===void 0||!Vt(g.slice(u[c].start,u[r].start))))break;r=(y.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(y.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(y.get(d)??d)+1;return{start:e,end:d}}function j(e,o,r=!0){for(let d=e;d<o;d++){let s=Y.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let l=r?oe(d,o):void 0;if(l){let p=l.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")j(l.start,l.end,!1);d=l.end-1;continue}let c=P(d);if(c)c.binding.flow=void 0,c.binding.unresolved=!0}}function ge(e){let o=!1;while(w<u.length&&u[w].start<e){let r=f(w);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let c=y.get(w)??w+1;while(c<u.length&&u[c].start>=e)c--;if(j(w+1,c),w=c+1,r==="{")o=!1;continue}let d=ne(w);if(d){let l=w+2,c=l,p=[];while(c<u.length&&u[c].start<e){let D=f(c);if(p.length===0&&(D===";"||c>l&&/[\r\n]/.test(g.slice(u[c-1].end,u[c].start))&&(ne(c)||["if","for","while","switch","try","do","return","throw"].includes(D))))break;if(D==="("||D==="{"||D==="[")p.push(D==="("?")":D==="{"?"}":"]");else if(D===p.at(-1))p.pop();c++}let M=c>l?g.slice(u[l].start,u[c-1].end):"";j(l,c);let I=ee(M);d.flow=!o&&I.type?d.declared?de(d.declared,I.type):I.type:void 0,d.unresolved=o||I.unresolved||!d.flow,w=c;continue}let s=P(w);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;w++}}for(let e of T){ge(e.start??0);let o=w;while(w<u.length&&u[w].start<(e.end??0))w++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<w&&u[M].start<e.initializerStart)M++;j(M,w)}let r=h.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=ee(d),l=ft(d),c=l?h.get(l):void 0,p=G.get(e);if(p)e.inferredType=p;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&l&&l!==e.name&&c){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=c.declared&&F(c.declared,s.type)?`typeof ${l}`:s.type}if(e.inferredType)e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${e.inferredType};`;if(e.typeAnnotation)r.flow=s.type?de(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",I=d.trim().startsWith("{")||d.trim().startsWith("["),D=n(d,M&&!I);r.declared=D==="unknown"?void 0:D,r.flow=r.declared}r.unresolved=s.unresolved}}
3
- export{Gt,Yn};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{A}from"./chunk-yxcyqezk.js";import{Y}from"./chunk-20jq5v1p.js";import{chmod as G,lstat as P,mkdir as y,readdir as j,realpath as q,rename as D,rm as N,rmdir as L,stat as R,writeFile as W}from"fs/promises";import{basename as _,dirname as m,isAbsolute as M,parse as B,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 q(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),_(e))}}async function ne(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(!A(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===B(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(A(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 S(a,e){try{if(!(await R(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 S(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await R(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await j(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 $e(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await ne(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||!A(t,n)||A(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=[],x=[],T=[],b=!1,E,d,I=!1;async function h(o,c){let t=await g(m(o));if(!A(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(A(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function C(){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 N(r,{recursive:!0})}try{await S(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 W(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 Y(v,i.content,i.lineEnding),!a.clean&&u.existing)await G(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),x.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await S(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),T.push({path:t.path,identity:t.stagedIdentity})}I=!0;try{await C()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(I)throw o;let c=[];for(let i of T.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 N(i.path)}catch(u){c.push(u)}for(let i of x.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 C()}catch(i){t.push(i)}for(let i of p.toReversed())try{await L(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{ne,$e};