@stacksjs/dtsx 0.9.9 → 0.9.11

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 (113) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +243 -15
  3. package/dist/bin/cli.js +10 -22
  4. package/dist/branded-types.d.ts +150 -0
  5. package/dist/bundler.d.ts +55 -0
  6. package/dist/cache.d.ts +43 -0
  7. package/dist/checker.d.ts +107 -0
  8. package/dist/chunk-1bav913n.js +6 -0
  9. package/dist/chunk-2wbhe1k8.js +2 -0
  10. package/dist/chunk-3d18fhrg.js +3 -0
  11. package/dist/chunk-3g2v2ns2.js +2 -0
  12. package/dist/chunk-3j7r0fxz.js +2 -0
  13. package/dist/chunk-4qpg9xnt.js +3 -0
  14. package/dist/chunk-57agx6g8.js +3 -0
  15. package/dist/chunk-5vqtjws2.js +2 -0
  16. package/dist/chunk-6mwq397e.js +2 -0
  17. package/dist/chunk-6qv7p9sg.js +170 -0
  18. package/dist/chunk-6s7n1gt0.js +2 -0
  19. package/dist/chunk-74j5mydx.js +3 -0
  20. package/dist/chunk-7cpp6v8f.js +2 -0
  21. package/dist/chunk-9a6yn7sv.js +75 -0
  22. package/dist/chunk-axb2kjeq.js +2 -0
  23. package/dist/chunk-begk3j01.js +33 -0
  24. package/dist/chunk-cmenkst5.js +3 -0
  25. package/dist/chunk-d0p3jzwb.js +34 -0
  26. package/dist/chunk-f18nyrrb.js +32 -0
  27. package/dist/chunk-fb4c98h2.js +2 -0
  28. package/dist/chunk-ggmn4a8c.js +4 -0
  29. package/dist/chunk-hrmnrn4p.js +3 -0
  30. package/dist/chunk-j0y71ank.js +2 -0
  31. package/dist/chunk-j6aqdbc4.js +2 -0
  32. package/dist/chunk-jm5ywn4e.js +13 -0
  33. package/dist/chunk-knkfbqze.js +2 -0
  34. package/dist/chunk-n28rjf9h.js +3 -0
  35. package/dist/chunk-p1d09y82.js +449 -0
  36. package/dist/chunk-r1m3q3dj.js +2 -0
  37. package/dist/chunk-r1ywapeb.js +6 -0
  38. package/dist/chunk-rnt0wkrk.js +23 -0
  39. package/dist/chunk-rw6j20e2.js +3 -0
  40. package/dist/chunk-v96rjx7x.js +134 -0
  41. package/dist/chunk-w9abhtgg.js +22 -0
  42. package/dist/chunk-wfevdmvd.js +19 -0
  43. package/dist/chunk-ws2dmfvj.js +2 -0
  44. package/dist/chunk-xnq1xw73.js +15 -0
  45. package/dist/chunk-xyctgc6x.js +102 -0
  46. package/dist/chunk-y3q50bn2.js +2 -0
  47. package/dist/chunk-ywd4k4hn.js +3 -0
  48. package/dist/circular.d.ts +82 -0
  49. package/dist/compat.d.ts +108 -0
  50. package/dist/config.d.ts +33 -3
  51. package/dist/diff.d.ts +82 -0
  52. package/dist/docs.d.ts +97 -0
  53. package/dist/errors.d.ts +113 -0
  54. package/dist/extractor/builders.d.ts +38 -0
  55. package/dist/extractor/cache.d.ts +47 -0
  56. package/dist/extractor/declarations.d.ts +50 -0
  57. package/dist/extractor/directives.d.ts +9 -0
  58. package/dist/extractor/extract.d.ts +10 -0
  59. package/dist/extractor/hash.d.ts +1 -0
  60. package/dist/extractor/helpers.d.ts +39 -0
  61. package/dist/extractor/index.d.ts +70 -0
  62. package/dist/extractor/scanner.d.ts +6 -0
  63. package/dist/extractor.d.ts +3 -4
  64. package/dist/formats.d.ts +50 -0
  65. package/dist/formatter.d.ts +61 -0
  66. package/dist/generator.d.ts +12 -3
  67. package/dist/import-sorter.d.ts +99 -0
  68. package/dist/incremental.d.ts +84 -0
  69. package/dist/index.d.ts +54 -1
  70. package/dist/logger.d.ts +57 -0
  71. package/dist/lsp.d.ts +317 -0
  72. package/dist/memory.d.ts +110 -0
  73. package/dist/merger.d.ts +38 -0
  74. package/dist/optimizer.d.ts +52 -0
  75. package/dist/output-normalizer.d.ts +123 -0
  76. package/dist/parallel-processor.d.ts +63 -0
  77. package/dist/parser.d.ts +24 -15
  78. package/dist/plugins/bun.d.ts +58 -0
  79. package/dist/plugins/esbuild.d.ts +63 -0
  80. package/dist/plugins/index.d.ts +14 -0
  81. package/dist/plugins/tsup.d.ts +53 -0
  82. package/dist/plugins/vite.d.ts +49 -0
  83. package/dist/plugins/webpack.d.ts +66 -0
  84. package/dist/plugins.d.ts +83 -0
  85. package/dist/process-source.d.ts +11 -0
  86. package/dist/processor/cache.d.ts +16 -0
  87. package/dist/processor/comments.d.ts +7 -0
  88. package/dist/processor/declarations.d.ts +37 -0
  89. package/dist/processor/imports.d.ts +65 -0
  90. package/dist/processor/index.d.ts +34 -0
  91. package/dist/processor/type-inference.d.ts +106 -0
  92. package/dist/processor.d.ts +3 -43
  93. package/dist/profiling.d.ts +101 -0
  94. package/dist/security.d.ts +100 -0
  95. package/dist/sourcemap.d.ts +125 -0
  96. package/dist/src/index.js +55 -2
  97. package/dist/src/plugins/bun.js +2 -0
  98. package/dist/src/plugins/esbuild.js +2 -0
  99. package/dist/src/plugins/index.js +2 -0
  100. package/dist/src/plugins/tsup.js +2 -0
  101. package/dist/src/plugins/vite.js +2 -0
  102. package/dist/src/plugins/webpack.js +2 -0
  103. package/dist/tracking.d.ts +89 -0
  104. package/dist/transformers.d.ts +173 -0
  105. package/dist/tree-shaker.d.ts +69 -0
  106. package/dist/type-mappings.d.ts +124 -0
  107. package/dist/types.d.ts +137 -7
  108. package/dist/utils.d.ts +53 -1
  109. package/dist/watcher.d.ts +64 -0
  110. package/dist/worker.d.ts +84 -0
  111. package/dist/workspace.d.ts +62 -0
  112. package/package.json +49 -11
  113. package/dist/chunk-qsyn1k3w.js +0 -504
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ import{hc as D}from"./chunk-p1d09y82.js";import{kc as p,lc as Jq,mc as Oq}from"./chunk-74j5mydx.js";import{Ec as wq}from"./chunk-xnq1xw73.js";import{ad as E}from"./chunk-rw6j20e2.js";var z=E(D(),1);var I=E(D(),1);var A=new Map,S=new Map,Gq=100;function _q(){if(A.size<=Gq)return;let q=null,$=1/0;for(let[W,Q]of A)if(Q.lastAccess<$)$=Q.lastAccess,q=W;if(q)A.delete(q)}function jq(){A.clear()}function Bq(){return A.size}var Uq={asyncThreshold:1e5,chunkSize:50000,yieldInterval:0};function u(q){return new Promise(($)=>{if(q===0)if(typeof setImmediate<"u")setImmediate($);else setTimeout($,0);else setTimeout($,q)})}async function zq(q,$,W){if($.length<W.asyncThreshold)return I.createSourceFile(q,$,I.ScriptTarget.Latest,!0,I.ScriptKind.TS);await u(W.yieldInterval);let Q=I.createSourceFile(q,$,I.ScriptTarget.Latest,!1,I.ScriptKind.TS);return await u(W.yieldInterval),Q}async function g(q,$,W={}){let Q={...Uq,...W},V=p($),j=q,U=Date.now(),X=A.get(j);if(X&&X.contentHash===V)return X.lastAccess=U,X.sourceFile;let Z=S.get(j);if(Z)return Z;let w=(async()=>{try{let H=await zq(q,$,Q);return A.set(j,{sourceFile:H,contentHash:V,lastAccess:U}),_q(),H}finally{S.delete(j)}})();return S.set(j,w),w}async function Lq(q,$={}){let W=$.concurrency??4,Q=new Map,V=[];for(let j=0;j<q.length;j+=W){let U=q.slice(j,j+W),X=await Promise.allSettled(U.map(async({filePath:Z,sourceCode:w})=>{let H=await g(Z,w,$);return{filePath:Z,sourceFile:H}}));for(let Z of X)if(Z.status==="fulfilled")Q.set(Z.value.filePath,Z.value.sourceFile);else V.push({filePath:U[X.indexOf(Z)].filePath,error:Z.reason});if(j+W<q.length)await u(0)}if(V.length>0)console.warn(`[dtsx] ${V.length} file(s) failed to parse:`,V.map((j)=>j.filePath));return Q}function Iq(q,$={}){let W=$.asyncThreshold??Uq.asyncThreshold;return q.length>=W}function vq(){return S.size}var R=E(D(),1);var Y=E(D(),1);var B=E(D(),1);function M(q,$,W){return $.slice(W?q.getStart(W):q.getStart(),q.getEnd())}function L(q,$){let W=[],Q=q.getFullStart(),V=q.getStart($);if(Q!==V){let j=$.text.substring(Q,V),U=j.match(/\/\*\*[\s\S]*?\*\//g);if(U)W.push(...U);let X=j.match(/\/\*(?!\*)[\s\S]*?\*\//g);if(X)W.push(...X);let Z=j.split(`
3
+ `),w=[];for(let H=Z.length-1;H>=0;H--){let O=Z[H].trim();if(O.startsWith("//"))w.unshift(O);else if(O==="")continue;else break}if(w.length>0)W.push(w.join(`
4
+ `))}return W}function P(q,$){if(B.isObjectBindingPattern(q.name)){let W=q.name.elements.map((Q)=>{if(B.isBindingElement(Q)&&B.isIdentifier(Q.name))return Q.name.getText($);return""}).filter(Boolean);if(W.length>3)return`{
5
+ ${W.join(`,
6
+ `)},
7
+ }`;return`{ ${W.join(", ")} }`}else if(B.isArrayBindingPattern(q.name))return`[${q.name.elements.map((Q)=>{if(Q&&B.isBindingElement(Q)&&B.isIdentifier(Q.name))return Q.name.getText($);return""}).filter(Boolean).join(", ")}]`;else return q.name.getText($)}function _(q){if(!("modifiers"in q)||!q.modifiers)return!1;return q.modifiers.some((W)=>W.kind===B.SyntaxKind.ExportKeyword)}function l(q){return q.modifiers?.some(($)=>$.kind===B.SyntaxKind.AsyncKeyword)||!1}function c(q,$){return!1}var N=new Map;function d(q,$){let W=N.get(q);if(!W){let Q=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(W={funcPattern:new RegExp(`export\\s+[^\\n]*:\\s*[^\\n]*\\b${Q}\\b`,"gm"),typePattern:new RegExp(`export\\s+[^\\n]*\\b${Q}\\b`,"gm")},N.set(q,W),N.size>200){let V=Array.from(N.keys()).slice(0,50);for(let j of V)N.delete(j)}}return W.funcPattern.lastIndex=0,W.typePattern.lastIndex=0,W.funcPattern.test($)||W.typePattern.test($)}var Pq=new Set(["string","number","boolean","object","any","unknown","never","void","undefined","null","Array","Promise","Record","Partial","Required","Pick","Omit","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Function","Date","RegExp","Error","Map","Set","WeakMap","WeakSet","T","K","V","U","R","P","E","A","B","C","D","F","G","H","I","J","L","M","N","O","Q","S","W","X","Y","Z"]);function m(q){return Pq.has(q)}function i(q){let $=[],W=q.match(/(?:export\s+)?interface\s+([A-Z][a-zA-Z0-9]*)/g);if(W)W.forEach((U)=>{let X=U.replace(/(?:export\s+)?interface\s+/,"");$.push(X)});let Q=q.match(/(?:export\s+)?type\s+([A-Z][a-zA-Z0-9]*)/g);if(Q)Q.forEach((U)=>{let X=U.replace(/(?:export\s+)?type\s+/,"");$.push(X)});let V=q.match(/(?:export\s+)?(?:declare\s+)?class\s+([A-Z][a-zA-Z0-9]*)/g);if(V)V.forEach((U)=>{let X=U.replace(/(?:export\s+)?(?:declare\s+)?class\s+/,"");$.push(X)});let j=q.match(/(?:export\s+)?(?:declare\s+)?(?:const\s+)?enum\s+([A-Z][a-zA-Z0-9]*)/g);if(j)j.forEach((U)=>{let X=U.replace(/(?:export\s+)?(?:declare\s+)?(?:const\s+)?enum\s+/,"");$.push(X)});return $}var Kq=/\s+as\s+(\S+)\s*$/;function K(q,$){let W=q.trim();if(!W.endsWith("as const")){let V=W.match(Kq);if(V)return V[1]}let Q=wq(W,$);if(Q==="unknown")return"unknown";if(!$){if(Q==="true"||Q==="false")return"boolean";if(/^-?\d+(\.\d+)?$/.test(Q))return"number";if(Q.startsWith('"')&&Q.endsWith('"')||Q.startsWith("'")&&Q.endsWith("'"))return"string"}return Q}function t(q,$){let W=[],Q=q.modifiers?.some((X)=>X.kind===Y.SyntaxKind.AsyncKeyword),V=!!q.asteriskToken;if(_(q))W.push("export ");if(W.push("declare function "),q.name)W.push(q.name.getText($));if(q.typeParameters){let X=q.typeParameters.map((Z)=>Z.getText($)).join(", ");W.push("<",X,">")}let j=q.parameters.map((X)=>{let Z=P(X,$),w=X.type?.getText($)||(X.initializer?K(X.initializer.getText($),!1):"unknown"),H=X.questionToken||X.initializer?"?":"";if(!!X.dotDotDotToken)return`...${Z}: ${w}`;return`${Z}${H}: ${w}`}).join(", ");W.push("(",j,")");let U=q.type?.getText($);if(!U)if(Q&&V)U="AsyncGenerator<unknown, void, unknown>";else if(V)U="Generator<unknown, void, unknown>";else if(Q)U="Promise<void>";else U="void";return W.push(": ",U,";"),W.join("")}function a(q,$,W,Q){let V=[];if(Q)V.push("export ");if(V.push("declare ",W," ",q),$)V.push(": ",$);return V.push(";"),V.join("")}function n(q,$,W){let Q=[];if($)Q.push("export ");if(Q.push("declare interface ",q.name.getText(W)),q.typeParameters){let j=q.typeParameters.map((U)=>U.getText(W)).join(", ");Q.push("<",j,">")}if(q.heritageClauses){let j=q.heritageClauses.find((U)=>U.token===Y.SyntaxKind.ExtendsKeyword);if(j){let U=j.types.map((X)=>X.getText(W)).join(", ");Q.push(" extends ",U)}}let V=r(q,W);return Q.push(" ",V),Q.join("")}function Yq(q,$){if(!q.name)return"";return q.name.getText($)}function r(q,$){let W=[];for(let Q of q.members)if(Y.isPropertySignature(Q)){let V=Yq(Q,$),j=Q.type?.getText($)||"unknown",U=Q.questionToken?"?":"",X=Q.modifiers?.some((Z)=>Z.kind===Y.SyntaxKind.ReadonlyKeyword)?"readonly ":"";W.push(` ${X}${V}${U}: ${j}`)}else if(Y.isMethodSignature(Q)){let V=Yq(Q,$),j="";if(Q.typeParameters&&Q.typeParameters.length>0)j=`<${Q.typeParameters.map((w)=>w.getText($)).join(", ")}>`;let U=Q.parameters.map((w)=>{let H=w.name.getText($),O=w.type?.getText($)||"unknown",J=w.questionToken?"?":"";if(!!w.dotDotDotToken)return`...${H}: ${O}`;return`${H}${J}: ${O}`}).join(", "),X=Q.type?.getText($)||"void",Z=Q.questionToken?"?":"";W.push(` ${V}${Z}${j}(${U}): ${X}`)}else if(Y.isCallSignatureDeclaration(Q)){let V=Q.parameters.map((U)=>{let X=U.name.getText($),Z=U.type?.getText($)||"unknown",w=U.questionToken?"?":"";if(!!U.dotDotDotToken)return`...${X}: ${Z}`;return`${X}${w}: ${Z}`}).join(", "),j=Q.type?.getText($)||"void";W.push(` (${V}): ${j}`)}else if(Y.isConstructSignatureDeclaration(Q)){let V=Q.parameters.map((U)=>{let X=U.name.getText($),Z=U.type?.getText($)||"unknown",w=U.questionToken?"?":"";if(!!U.dotDotDotToken)return`...${X}: ${Z}`;return`${X}${w}: ${Z}`}).join(", "),j=Q.type?.getText($)||"unknown";W.push(` new (${V}): ${j}`)}else if(Y.isIndexSignatureDeclaration(Q)){let V=Q.parameters.map((U)=>{let X=U.name.getText($),Z=U.type?.getText($)||"any";return`${X}: ${Z}`}).join(", "),j=Q.type?.getText($)||"unknown";W.push(` [${V}]: ${j}`)}return`{
8
+ ${W.join(`
9
+ `)}
10
+ }`}function s(q,$,W){let Q=[];if($)Q.push("export ");if(Q.push("type ",q.name.getText(W)),q.typeParameters){let V=q.typeParameters.map((j)=>j.getText(W)).join(", ");Q.push("<",V,">")}return Q.push(" = ",q.type.getText(W)),Q.join("")}function o(q,$,W){let Q=[];if($)Q.push("export ");if(Q.push("declare "),q.modifiers?.some((X)=>X.kind===Y.SyntaxKind.AbstractKeyword))Q.push("abstract ");if(Q.push("class ",q.name?.getText(W)||"AnonymousClass"),q.typeParameters){let X=q.typeParameters.map((Z)=>Z.getText(W)).join(", ");Q.push("<",X,">")}let j=q.heritageClauses?.find((X)=>X.token===Y.SyntaxKind.ExtendsKeyword)?.types[0]?.getText(W);if(j)Q.push(" extends ",j);let U=q.heritageClauses?.find((X)=>X.token===Y.SyntaxKind.ImplementsKeyword)?.types.map((X)=>X.getText(W));if(U&&U.length>0)Q.push(" implements ",U.join(", "));return Q.push(" ",Hq(q,W)),Q.join("")}function T(q,$,W,Q,V){let j=[" "];if(Q)j.push("private ");else if(V)j.push("protected ");if(q)j.push("static ");if($)j.push("abstract ");if(W)j.push("readonly ");return j.join("")}function h(q){return q.name?Y.isPrivateIdentifier(q.name):!1}function b(q,$){if(!q.name)return"";return q.name.getText($)}function Hq(q,$){let W=[];for(let Q of q.members){if(Q.kind===Y.SyntaxKind.ClassStaticBlockDeclaration)continue;if(Y.isConstructorDeclaration(Q)){for(let j of Q.parameters)if(j.modifiers&&j.modifiers.length>0){if(j.modifiers.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let X=P(j,$),Z=j.type?.getText($)||(j.initializer?K(j.initializer.getText($),!1):"unknown"),w=j.questionToken||j.initializer?"?":"",H=j.modifiers.map((J)=>J.getText($)).join(" "),O=H?`${H} `:"";W.push(` ${O}${X}${w}: ${Z};`)}let V=Q.parameters.map((j)=>{let U=P(j,$),X=j.type?.getText($)||(j.initializer?K(j.initializer.getText($),!1):"unknown"),Z=j.questionToken||j.initializer?"?":"";return`${U}${Z}: ${X}`}).join(", ");W.push(` constructor(${V});`)}else if(Y.isMethodDeclaration(Q)){if(h(Q))continue;if(Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let j=b(Q,$),U=!!Q.asteriskToken,Z=[T(!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ProtectedKeyword))];if(U)Z.push("*");if(Z.push(j),Q.typeParameters){let J=Q.typeParameters.map((G)=>G.getText($)).join(", ");Z.push("<",J,">")}let w=Q.parameters.map((J)=>{let G=P(J,$),k=J.type?.getText($)||(J.initializer?K(J.initializer.getText($),!1):"unknown"),v=J.questionToken||J.initializer?"?":"";return`${G}${v}: ${k}`}).join(", ");Z.push("(",w,")");let H=!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AsyncKeyword),O=Q.type?.getText($);if(!O)if(H&&U)O="AsyncGenerator<unknown, void, unknown>";else if(U)O="Generator<unknown, void, unknown>";else if(H)O="Promise<void>";else O="void";Z.push(": ",O,";"),W.push(Z.join(""))}else if(Y.isPropertyDeclaration(Q)){if(h(Q))continue;if(Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let j=b(Q,$),U=T(!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AbstractKeyword),!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ReadonlyKeyword),!1,!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ProtectedKeyword)),X=Q.questionToken?"?":"",Z=!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),w=!!Q.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ReadonlyKeyword),H=Z&&w,O=Q.type?.getText($)||(Q.initializer?K(Q.initializer.getText($),H):"unknown");W.push(`${U}${j}${X}: ${O};`)}else if(Y.isGetAccessorDeclaration(Q)){if(h(Q))continue;if(Q.modifiers?.some((Z)=>Z.kind===Y.SyntaxKind.PrivateKeyword))continue;let j=b(Q,$),U=T(!!Q.modifiers?.some((Z)=>Z.kind===Y.SyntaxKind.StaticKeyword),!!Q.modifiers?.some((Z)=>Z.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!Q.modifiers?.some((Z)=>Z.kind===Y.SyntaxKind.ProtectedKeyword)),X=Q.type?.getText($)||"unknown";W.push(`${U}get ${j}(): ${X};`)}else if(Y.isSetAccessorDeclaration(Q)){if(h(Q))continue;if(Q.modifiers?.some((H)=>H.kind===Y.SyntaxKind.PrivateKeyword))continue;let j=b(Q,$),U=T(!!Q.modifiers?.some((H)=>H.kind===Y.SyntaxKind.StaticKeyword),!!Q.modifiers?.some((H)=>H.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!Q.modifiers?.some((H)=>H.kind===Y.SyntaxKind.ProtectedKeyword)),X=Q.parameters[0],Z=X?.type?.getText($)||"unknown",w=X?.name?.getText($)||"value";W.push(`${U}set ${j}(${w}: ${Z});`)}}return`{
11
+ ${W.join(`
12
+ `)}
13
+ }`}function e(q,$,W){let Q=[];if(q.flags&Y.NodeFlags.GlobalAugmentation)return`declare global ${x(q,W)}`;if($)Q.push("export ");Q.push("declare ");let j=q.flags&Y.NodeFlags.Namespace;return Q.push(j?"namespace ":"module "),Q.push(q.name.getText(W)),Q.push(" ",x(q,W)),Q.join("")}function x(q,$){if(!q.body)return"{}";let W=[];function Q(V){if(Y.isFunctionDeclaration(V)){let j=_(V),U=V.name?.getText($)||"",X=[" "];if(j)X.push("export ");if(X.push("function ",U),V.typeParameters){let H=V.typeParameters.map((O)=>O.getText($)).join(", ");X.push("<",H,">")}let Z=V.parameters.map((H)=>{let O=P(H,$),J=H.type?.getText($)||(H.initializer?K(H.initializer.getText($),!1):"unknown"),G=H.questionToken||H.initializer?"?":"";return`${O}${G}: ${J}`}).join(", ");X.push("(",Z,")");let w=V.type?.getText($)||"void";X.push(": ",w,";"),W.push(X.join(""))}else if(Y.isVariableStatement(V)){let j=_(V);for(let U of V.declarationList.declarations)if(U.name&&Y.isIdentifier(U.name)){let X=U.name.getText($),Z=U.type?.getText($),w=U.initializer?.getText($),H=V.declarationList.flags&Y.NodeFlags.Const?"const":V.declarationList.flags&Y.NodeFlags.Let?"let":"var",O=[" "];if(j)O.push("export ");if(O.push(H," ",X),Z)O.push(": ",Z);else if(w){let J=K(w,H==="const");O.push(": ",J)}else O.push(": unknown");O.push(";"),W.push(O.join(""))}}else if(Y.isInterfaceDeclaration(V)){let j=_(V),U=V.name.getText($),X=[" "];if(j)X.push("export ");if(X.push("interface ",U),V.typeParameters){let w=V.typeParameters.map((H)=>H.getText($)).join(", ");X.push("<",w,">")}if(V.heritageClauses){let w=V.heritageClauses.find((H)=>H.token===Y.SyntaxKind.ExtendsKeyword);if(w){let H=w.types.map((O)=>O.getText($)).join(", ");X.push(" extends ",H)}}let Z=r(V,$);X.push(" ",Z),W.push(X.join(""))}else if(Y.isTypeAliasDeclaration(V)){let j=_(V),U=V.name.getText($),X=[" "];if(j)X.push("export ");if(X.push("type ",U),V.typeParameters){let Z=V.typeParameters.map((w)=>w.getText($)).join(", ");X.push("<",Z,">")}X.push(" = ",V.type.getText($)),W.push(X.join(""))}else if(Y.isEnumDeclaration(V)){let j=_(V),U=V.name.getText($),X=V.modifiers?.some((H)=>H.kind===Y.SyntaxKind.ConstKeyword),Z=[" "];if(j)Z.push("export ");if(X)Z.push("const ");Z.push("enum ",U);let w=[];for(let H of V.members)if(Y.isEnumMember(H)){let O=H.name.getText($);if(H.initializer){let J=H.initializer.getText($);w.push(` ${O} = ${J}`)}else w.push(` ${O}`)}Z.push(` {
14
+ `,w.join(`,
15
+ `),`
16
+ }`),W.push(Z.join(""))}else if(Y.isModuleDeclaration(V)){let j=_(V),U=V.name.getText($),X=[" "];if(j)X.push("export ");let Z=V.flags&Y.NodeFlags.Namespace;X.push(Z?"namespace ":"module "),X.push(U," ",x(V,$)),W.push(X.join(""))}else if(Y.isExportAssignment(V)){let j=[" export default "];if(V.expression)j.push(V.expression.getText($));j.push(";"),W.push(j.join(""))}}if(Y.isModuleBlock(q.body))for(let V of q.body.statements)Q(V);else if(Y.isModuleDeclaration(q.body))Q(q.body);return`{
17
+ ${W.join(`
18
+ `)}
19
+ }`}function qq(q,$,W){let Q=M(q,$,W),V=!!q.importClause?.isTypeOnly,j=!q.importClause;return{kind:"import",name:"",text:Q,isExported:!1,isTypeOnly:V,isSideEffect:j,source:q.moduleSpecifier.getText(W).slice(1,-1),start:q.getStart(W),end:q.getEnd()}}function Qq(q,$,W,Q=!1){let V=M(q,$,W),j=!!q.isTypeOnly,U=Q?L(q,W):void 0;return{kind:"export",name:"",text:V,isExported:!0,isTypeOnly:j,leadingComments:U,source:q.moduleSpecifier?.getText(W).slice(1,-1),start:q.getStart(W),end:q.getEnd()}}function Wq(q,$,W,Q=!1){let V=M(q,$,W),j=Q?L(q,W):void 0;return{kind:"export",name:"default",text:V,isExported:!0,isTypeOnly:!1,leadingComments:j,start:q.getStart(W),end:q.getEnd()}}function $q(q,$,W,Q){if(!q.name)return null;if(q.body){let G=q.name.getText(W),k=!1;if(R.forEachChild(W,(v)=>{if(R.isFunctionDeclaration(v)&&v!==q&&v.name?.getText(W)===G&&!v.body)k=!0}),k)return null}let V=q.name.getText(W),j=_(q),U=l(q),X=!!q.asteriskToken,Z=t(q,W),w=q.parameters.map((G)=>({name:G.name.getText(W),type:G.type?.getText(W)||"any",optional:!!G.questionToken,defaultValue:G.initializer?.getText(W)})),H=q.type?.getText(W);if(!H)if(U&&X)H="AsyncGenerator<unknown, void, unknown>";else if(X)H="Generator<unknown, void, unknown>";else if(U)H="Promise<void>";else H="void";let O=q.typeParameters?.map((G)=>G.getText(W)).join(", "),J=Q?L(q,W):void 0;return{kind:"function",name:V,text:Z,isExported:j,isAsync:U,isGenerator:X,parameters:w,returnType:H,generics:O?`<${O}>`:void 0,leadingComments:J,start:q.getStart(W),end:q.getEnd()}}function kq(q,$){let W=q.getText($);if(q.kind===R.SyntaxKind.ObjectLiteralExpression)return`typeof ${W} as const`;if(q.kind===R.SyntaxKind.ArrayLiteralExpression)return`readonly ${W}`;if(q.kind===R.SyntaxKind.StringLiteral)return W;if(q.kind===R.SyntaxKind.NumericLiteral)return W;if(q.kind===R.SyntaxKind.TrueKeyword||q.kind===R.SyntaxKind.FalseKeyword)return W;return`typeof ${W}`}function Xq(q,$,W,Q){let V=[];if(!_(q))return V;for(let U of q.declarationList.declarations){if(!U.name||!R.isIdentifier(U.name))continue;let X=U.name.getText(W),Z=U.type?.getText(W),w=U.initializer,H=w?.getText(W),O=q.declarationList.flags&R.NodeFlags.Const?"const":q.declarationList.flags&R.NodeFlags.Let?"let":"var",J=!1;if(w&&R.isAsExpression(w)){if(w.type.getText(W)==="const"){J=!0;let Rq=w.expression;if(!Z)Z=kq(Rq,W)}}let G=a(X,Z,O,!0),k=Q?L(q,W):void 0;V.push({kind:"variable",name:X,text:G,isExported:!0,typeAnnotation:Z,value:H,modifiers:J?[O,"const assertion"]:[O],leadingComments:k,start:q.getStart(W),end:q.getEnd()})}return V}function F(q,$,W,Q){let V=q.name.getText(W),j=_(q),U=n(q,j,W),X=q.heritageClauses?.find((H)=>H.token===R.SyntaxKind.ExtendsKeyword)?.types.map((H)=>H.getText(W)).join(", "),Z=q.typeParameters?.map((H)=>H.getText(W)).join(", "),w=Q?L(q,W):void 0;return{kind:"interface",name:V,text:U,isExported:j,extends:X,generics:Z?`<${Z}>`:void 0,leadingComments:w,start:q.getStart(W),end:q.getEnd()}}function C(q,$,W,Q){let V=q.name.getText(W),j=_(q),U=s(q,j,W),X=q.typeParameters?.map((w)=>w.getText(W)).join(", "),Z=Q?L(q,W):void 0;return{kind:"type",name:V,text:U,isExported:j,generics:X?`<${X}>`:void 0,leadingComments:Z,start:q.getStart(W),end:q.getEnd()}}function y(q,$,W,Q){let V=q.name?.getText(W)||"AnonymousClass",j=_(q),U=o(q,j,W),X=q.heritageClauses?.find((J)=>J.token===R.SyntaxKind.ExtendsKeyword)?.types[0]?.getText(W),Z=q.heritageClauses?.find((J)=>J.token===R.SyntaxKind.ImplementsKeyword)?.types.map((J)=>J.getText(W)),w=q.typeParameters?.map((J)=>J.getText(W)).join(", "),H=q.modifiers?.some((J)=>J.kind===R.SyntaxKind.AbstractKeyword),O=Q?L(q,W):void 0;return{kind:"class",name:V,text:U,isExported:j,extends:X,implements:Z,generics:w?`<${w}>`:void 0,modifiers:H?["abstract"]:void 0,leadingComments:O,start:q.getStart(W),end:q.getEnd()}}function f(q,$,W,Q){let V=q.name.getText(W),j=_(q),U=M(q,$,W),X=q.modifiers?.some((w)=>w.kind===R.SyntaxKind.ConstKeyword),Z=Q?L(q,W):void 0;return{kind:"enum",name:V,text:U,isExported:j,modifiers:X?["const"]:void 0,leadingComments:Z,start:q.getStart(W),end:q.getEnd()}}function Zq(q,$,W,Q){let V=q.name.getText(W),j=_(q),U=e(q,j,W),X=R.isStringLiteral(q.name),Z=Q?L(q,W):void 0;return{kind:"module",name:V,text:U,isExported:j,source:X?V.slice(1,-1):void 0,leadingComments:Z,start:q.getStart(W),end:q.getEnd()}}function Vq(q,$){let W=new Set,Q=new Set,V=new Set;for(let j of q)if(j.kind==="import"){let U=j.text.match(/import\s+(?:type\s+)?\{([^}]+)\}/g);if(U)for(let X of U){let Z=X.replace(/import\s+(?:type\s+)?\{([^}]+)\}/,"$1").split(",");for(let w of Z){let H=w.replace(/^type\s+/,"").trim();Q.add(H)}}}for(let j of q){if(["interface","type","class","enum"].includes(j.kind))V.add(j.name);if(j.kind==="module")i(j.text).forEach((X)=>V.add(X))}for(let j of q)if(j.kind!=="import"&&j.kind!=="export"){let U=j.text.match(/:\s*([A-Z][a-zA-Z0-9]*)/g)||[];for(let X of U){let Z=X.replace(/:\s*/,"");if(!Q.has(Z)&&!V.has(Z)&&!m(Z))W.add(Z)}}return W}function Mq(q,$,W,Q=!0){let V=[];if($.size===0)return V;function j(U){switch(U.kind){case R.SyntaxKind.InterfaceDeclaration:{let X=U,Z=X.name.getText(q);if($.has(Z)){let w=F(X,W,q,Q);V.push(w),$.delete(Z)}break}case R.SyntaxKind.TypeAliasDeclaration:{let X=U,Z=X.name.getText(q);if($.has(Z)){let w=C(X,W,q,Q);V.push(w),$.delete(Z)}break}case R.SyntaxKind.ClassDeclaration:{let X=U;if(X.name){let Z=X.name.getText(q);if($.has(Z)){let w=y(X,W,q,Q);V.push(w),$.delete(Z)}}break}case R.SyntaxKind.EnumDeclaration:{let X=U,Z=X.name.getText(q);if($.has(Z)){let w=f(X,W,q,Q);V.push(w),$.delete(Z)}break}}R.forEachChild(U,j)}return j(q),V}function mq(){jq(),Oq()}function iq(q,$,W=!0,Q=!1){return Jq(q,$,W,Q)}function Eq(q,$,W){let Q=[],V=new Map,j=0;function U(X){if(j!==1){j++,z.forEachChild(X,U),j--;return}switch(X.kind){case z.SyntaxKind.ImportDeclaration:Q.push(qq(X,$,q));break;case z.SyntaxKind.ExportDeclaration:Q.push(Qq(X,$,q,W));break;case z.SyntaxKind.ExportAssignment:Q.push(Wq(X,$,q,W));break;case z.SyntaxKind.FunctionDeclaration:{let Z=$q(X,$,q,W);if(Z&&(Z.isExported||c(Z.name,$)))Q.push(Z);break}case z.SyntaxKind.VariableStatement:{let Z=Xq(X,$,q,W);Q.push(...Z);break}case z.SyntaxKind.InterfaceDeclaration:{let Z=F(X,$,q,W);if(Z.isExported||d(Z.name,$))Q.push(Z);else V.set(Z.name,Z);break}case z.SyntaxKind.TypeAliasDeclaration:{let Z=C(X,$,q,W);if(Q.push(Z),!Z.isExported)V.set(Z.name,Z);break}case z.SyntaxKind.ClassDeclaration:{let Z=y(X,$,q,W);if(Q.push(Z),!Z.isExported&&Z.name)V.set(Z.name,Z);break}case z.SyntaxKind.EnumDeclaration:{let Z=f(X,$,q,W);if(Q.push(Z),!Z.isExported)V.set(Z.name,Z);break}case z.SyntaxKind.ModuleDeclaration:Q.push(Zq(X,$,q,W));break}}if(U(q),V.size>0){let X=Vq(Q,$);for(let Z of X){let w=V.get(Z);if(w)Q.push(w)}}return Q}async function Dq(q,$,W=!0,Q={}){let V=await g($,q,Q);return Eq(V,q,W)}async function tq(q,$={}){let W=$.concurrency??4,Q=new Map;for(let V=0;V<q.length;V+=W){let j=q.slice(V,V+W),U=await Promise.all(j.map(async({filePath:X,sourceCode:Z,keepComments:w})=>{let H=await Dq(Z,X,w,$);return{filePath:X,declarations:H}}));for(let{filePath:X,declarations:Z}of U)Q.set(X,Z)}return Q}export{Bq as wb,g as xb,Lq as yb,Iq as zb,vq as Ab,M as Bb,L as Cb,P as Db,_ as Eb,l as Fb,c as Gb,d as Hb,m as Ib,i as Jb,t as Kb,a as Lb,n as Mb,r as Nb,s as Ob,o as Pb,Hq as Qb,e as Rb,x as Sb,qq as Tb,Qq as Ub,Wq as Vb,$q as Wb,Xq as Xb,F as Yb,C as Zb,y as _b,f as $b,Zq as ac,Vq as bc,Mq as cc,mq as dc,iq as ec,Dq as fc,tq as gc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./chunk-rw6j20e2.js";var e="@stacksjs/dtsx",i="module",n="0.9.11",r=!0,c="A modern, fast .d.ts generation tool, powered by Bun.",o="Chris Breuer <chris@stacksjs.org>",u="MIT",d="https://github.com/stacksjs/dtsx#readme",p={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},a={url:"https://github.com/stacksjs/dtsx/issues"},b=["dts","generation","isolated declarations","development","bun","stacks","typescript","javascript"],g={".":{import:"./dist/index.js"},"./*":{import:"./dist/*"}},l="./dist/index.js",m="./dist/index.d.ts",k={dtsx:"./dist/cli.js"},x=["dist"],h={benchmark:"bun benchmark/index.ts",build:"bun --filter './packages/dtsx' build",test:"bun test",lint:"bunx --bun pickier run . --mode lint --config .config/pickier.ts","lint:fix":"bunx --bun pickier run . --mode lint --fix --config .config/pickier.ts",changelog:"bunx logsmith --verbose","changelog:generate":"bunx logsmith --output CHANGELOG.md",release:"bun --bun run changelog:generate && bunx --bun bumpx prompt --recursive",typecheck:"bunx tsc --noEmit","dev:docs":"bun --bun vitepress dev docs","build:docs":"bun --bun vitepress build docs","preview:docs":"bun --bun vitepress preview docs"},v={"@stacksjs/bumpx":"^0.2.4","@stacksjs/bunpress":"^0.1.1","@stacksjs/clapp":"^0.2.0",pickier:"^0.1.18","@stacksjs/gitlint":"^0.1.5","@stacksjs/logsmith":"^0.2.1","@types/bun":"^1.3.9","@typescript/native-preview":"^7.0.0-dev.20260216.1","buddy-bot":"^0.9.16","bun-git-hooks":"^0.3.1","bun-plugin-dtsx":"workspace:*",mitata:"^1.0.34","oxc-transform":"^0.112.0",typescript:"^5.9.3"},j=["packages/*"],y={name:e,type:i,version:n,private:r,description:c,author:o,license:u,homepage:d,repository:p,bugs:a,keywords:b,exports:g,module:l,types:m,bin:k,files:x,scripts:h,devDependencies:v,workspaces:j};export{j as workspaces,n as version,m as types,i as type,h as scripts,p as repository,r as private,e as name,l as module,u as license,b as keywords,d as homepage,x as files,g as exports,v as devDependencies,c as description,y as default,a as bugs,k as bin,o as author};
@@ -0,0 +1,15 @@
1
+ // @bun
2
+ var k=!1,M=null;function o(J){let Y="",X=0;while(X<J.length)if(J.charCodeAt(X)===47&&X+1<J.length&&J.charCodeAt(X+1)===42){X+=2;while(X<J.length-1){if(J.charCodeAt(X)===42&&J.charCodeAt(X+1)===47){X+=2;break}X++}}else Y+=J.charAt(X),X++;return Y.trim()}function r(){k=!0,M=null}function t(){k=!1;let J=M;return M=null,J}function T(J){let Y=J.length;if(Y===0)return!1;let X=0;if(J.charCodeAt(X)===45)X++;if(X>=Y)return!1;let G=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===G)return!1;if(X<Y&&J.charCodeAt(X)===46){X++;let z=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===z)return!1}return X===Y}function p(J){for(let Y=0,X=J.length-1;Y<X;Y++){let G=J.charCodeAt(Y);if(G<48||G>57)return!1}return!0}function E(J,Y){let X=0,G=0;while((G=J.indexOf(Y,G))!==-1)X++,G+=Y.length;return X}function P(J){let Y=J.length,X=!1;for(let Z=1;Z<Y;Z++)if(J.charCodeAt(Z)<=32&&J.charCodeAt(Z-1)<=32){X=!0;break}if(!X)for(let Z=0;Z<Y;Z++){let H=J.charCodeAt(Z);if(H===10||H===13||H===9){X=!0;break}}if(!X)return J;let G=[],z=-1,B=!1;for(let Z=0;Z<Y;Z++)if(J.charCodeAt(Z)<=32){if(!B){if(z>=0)G.push(J.substring(z,Z));G.push(" "),B=!0,z=-1}}else{if(B||z<0)z=Z;B=!1}if(z>=0)G.push(J.substring(z));return G.join("")}function V(J,Y=!1,X=!1,G=0){if(!J||typeof J!=="string")return"unknown";if(G>=20)return"unknown";let z=J.trim();if(z.startsWith("BigInt("))return"bigint";if(z.startsWith("Symbol.for("))return"symbol";if(z.includes(".raw`")||z.includes("String.raw`"))return"string";if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'")||z.startsWith("`")&&z.endsWith("`")){if(!z.includes("${")){if(!Y)return"string";return z}if(Y)return z;return"string"}if(T(z)){if(!Y)return"number";return z}if(z==="true"||z==="false"){if(!Y)return"boolean";return z}if(z==="null")return"null";if(z==="undefined")return"undefined";if(z.startsWith("[")&&z.endsWith("]"))return D(z,Y,G+1);if(z.startsWith("{")&&z.endsWith("}"))return s(z,Y,G+1);if(z.startsWith("new "))return c(z);if(z.includes("=>")||z.startsWith("function")||z.startsWith("async"))return h(z,X,G,Y);if(z.endsWith("as const")){let B=z.slice(0,-8).trim();if(B.startsWith("[")&&B.endsWith("]")){let Z=B.slice(1,-1).trim();if(!Z)return"readonly []";return`readonly [${U(Z).map((j)=>V(j.trim(),!0,!1,G+1)).join(", ")}]`}return V(B,!0,X,G+1)}if(z.startsWith("`")&&z.endsWith("`"))return m(z,Y);if(z.startsWith("Promise."))return y(z,Y,G);if(z.startsWith("await "))return"unknown";if(z.charCodeAt(z.length-1)===110&&z.length>1&&p(z)){if(Y)return z;return"bigint"}if(z.startsWith("Symbol(")||z==="Symbol.for")return"symbol";return"unknown"}function l(J,Y=!1,X=0){return V(J,Y,!0,X)}function m(J,Y){if(J.includes(".raw`")||J.includes("String.raw`"))return"string";if(!Y)return"string";if(!J.includes("${"))return J;return"string"}function c(J){let Y=4;while(Y<J.length&&J.charCodeAt(Y)<=32)Y++;let X=Y,G=J.charCodeAt(Y);if(G<65||G>90)return"unknown";while(Y<J.length&&x(J.charCodeAt(Y)))Y++;if(Y===X)return"unknown";let z=J.slice(X,Y);{let B=J.slice(Y);if(B.startsWith("<")){let Z=0,H=-1;for(let $=0;$<B.length;$++)if(B[$]==="<")Z++;else if(B[$]===">"){if(Z--,Z===0){H=$;break}}if(H!==-1){let $=B.slice(0,H+1);return`${z}${$}`}}switch(z){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return z}}return"unknown"}function y(J,Y,X=0){if(J.startsWith("Promise.resolve(")){let z=J.indexOf(")",16);if(z!==-1){let B=J.slice(16,z).trim();if(B)return`Promise<${V(B,Y,!1,X+1)}>`}return"Promise<unknown>"}if(J.startsWith("Promise.reject("))return"Promise<never>";if(J.startsWith("Promise.all(")){let G=J.indexOf("[",12),z=J.lastIndexOf("]");if(G!==-1&&z>G){let B=J.slice(G+1,z).trim();return`Promise<[${U(B).map(($)=>{let j=$.trim();if(j.startsWith("Promise.resolve(")){let O=y(j,Y,X+1),Q=O.indexOf("<"),W=O.lastIndexOf(">");return Q!==-1&&W>Q?O.slice(Q+1,W):"unknown"}return V(j,Y,!1,X+1)}).join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function D(J,Y,X=0){let G=J.slice(1,-1).trim();if(!G)return"never[]";if(X>=20)return"unknown[]";let z=U(G),B=!1;for(let Q=0;Q<z.length;Q++){let W=z[Q],F=W.length;while(F>0&&W.charCodeAt(F-1)<=32)F--;if(F>=8&&W.slice(F-8,F)==="as const"){B=!0;break}}if(B)return`readonly [
3
+ ${z.map((W)=>{let F=W.trim();if(F.endsWith("as const")){let L=F.slice(0,-8).trim();if(L.startsWith("[")&&L.endsWith("]")){let K=L.slice(1,-1).trim();return`readonly [${U(K).map((A)=>V(A.trim(),!0,!1,X+1)).join(", ")}]`}return V(L,!0,!1,X+1)}if(F.startsWith("[")&&F.endsWith("]"))return D(F,!0,X+1);return V(F,!0,!1,X+1)}).join(` |
4
+ `)}
5
+ ]`;let Z=k&&!Y,H=[],$=[];for(let Q of z){let W=Q.trim(),F=M;if(M=null,W.startsWith("[")&&W.endsWith("]"))H.push(D(W,Y,X+1));else H.push(l(W,Y,X+1));if(Z)$.push(M);M=F}if(Z)if(_(J))M=P(J);else{let Q=[];for(let W=0;W<z.length;W++){let F=z[W].trim();if(F.endsWith("as const"))continue;if(w(F)||F==="null"||F==="undefined")Q.push(F);else if(F.startsWith("[")&&_(F))Q.push(P(F));else if(F.startsWith("{")){if($[W])Q.push($[W])}else{let L=V(F,!1,!1,0);if(L!=="unknown")Q.push(L)}}if(Q.length>0)M=`[${Q.join(", ")}]`}if(Y)return`readonly [${H.join(", ")}]`;let j=[],O=!0;for(let Q of H){let W=!1;for(let F of j)if(Q===F){W=!0;break}if(!W)j.push(Q);if(O){if(!(T(Q)||Q==="true"||Q==="false"||Q.charCodeAt(0)===34&&Q.charCodeAt(Q.length-1)===34||Q.charCodeAt(0)===39&&Q.charCodeAt(Q.length-1)===39))O=!1}}if(O&&H.length<=10)return`readonly [${H.join(", ")}]`;if(j.length===1)return`${j[0]}[]`;return`(${j.join(" | ")})[]`}function U(J){let Y=[],X=0,G=0,z=!1,B=0;for(let H=0;H<J.length;H++){let $=J.charCodeAt(H);if(!z&&($===34||$===39||$===96))z=!0,B=$;else if(z&&$===B&&(H===0||J.charCodeAt(H-1)!==92))z=!1;if(!z){if($===91||$===123||$===40)G++;else if($===93||$===125||$===41)G--;else if($===44&&G===0){let j=J.substring(X,H).trim();if(j)Y.push(j);X=H+1;continue}}}let Z=J.substring(X).trim();if(Z)Y.push(Z);return Y}function w(J){if(T(J))return!0;if(J==="true"||J==="false")return!0;if(J.startsWith('"')&&J.endsWith('"')||J.startsWith("'")&&J.endsWith("'"))return!0;return!1}function d(J){return J==="number"||J==="string"||J==="boolean"}function _(J){let Y=!1,X=0,G=J.length;for(let z=0;z<G;z++){let B=J.charCodeAt(z);if(Y){if(B===92){z++;continue}if(B===X)Y=!1;continue}if(B===34||B===39||B===96){Y=!0,X=B;continue}if(B===61&&z+1<G&&J.charCodeAt(z+1)===62)return!1;if(B>=97&&B<=122){let Z=z;while(z<G&&(J.charCodeAt(z)>=97&&J.charCodeAt(z)<=122||J.charCodeAt(z)>=65&&J.charCodeAt(z)<=90||J.charCodeAt(z)>=48&&J.charCodeAt(z)<=57||J.charCodeAt(z)===95||J.charCodeAt(z)===36))z++;let H=J.slice(Z,z);if(H==="new"||H==="async"||H==="await"||H==="function"||H==="yield"||H==="console"||H==="process")return!1;let $=z;while($<G&&J.charCodeAt($)<=32)$++;if($<G&&J.charCodeAt($)===40)return!1;z--}}return!0}function s(J,Y,X=0){let G=J.slice(1,-1).trim();if(!G)return"{}";if(X>=20)return"Record<string, unknown>";let z=n(G),B=[],Z=k&&!Y,H=[];for(let[$,j]of z){let O=M;M=null;let Q=V(j,Y,!1,X+1),W=M;if(M=O,Q.includes("=>")||Q.includes("function")||Q.includes("async"))Q=I(Q);let F=j.trim();if(!Y&&d(Q)&&w(F))B.push(`/** @defaultValue ${F} */
6
+ ${$}: ${Q}`);else B.push(`${$}: ${Q}`);if(Z){let L=o($);if(F.endsWith("as const"));else if(w(F))H.push(`${L}: ${F}`);else if(F.startsWith("[")&&_(F))H.push(`${L}: ${P(F)}`);else if(F.startsWith("{")){if(W)H.push(`${L}: ${W}`)}else if(!F.startsWith("[")&&(F.includes("=>")||F.startsWith("function")||F.startsWith("async"))){let K=h(F,!1,0,!0);H.push(`${L}: ${K}`)}}}if(Z&&H.length>0){let $=X>0?(X-1)/2:0,j=`{ ${H.join(", ")} }`;if(j.length<=80)M=j;else{let O=" ".repeat(($+1)*2),Q=" ".repeat($*2);M=`{
7
+ ${O}${H.join(`,
8
+ ${O}`)}
9
+ ${Q}}`}}return`{
10
+ ${B.join(`;
11
+ `)}
12
+ }`}function I(J){let X=J,G=X.indexOf("async");if(G!==-1){let O=G>0?X.charCodeAt(G-1):32,Q=G+5<X.length?X.charCodeAt(G+5):32;if(!x(O)&&!x(Q))X=(X.slice(0,G)+X.slice(G+5)).trim()}let z=X.indexOf("(");if(z!==-1){let O=g(X,z,"(",")");if(O!==-1){let Q=X.slice(z,O+1),W=b(Q);X=X.slice(0,z)+W+X.slice(O+1)}}let B=X.length,Z="",H=[],$=!1,j=!1;for(let O=0;O<B;O++){let Q=X.charCodeAt(O);if(Q===123||Q===40)H.push(Q);else if(Q===125||Q===41)H.pop();if(Q<=32){if($=!0,Q===10||Q===13)j=!0;continue}if($&&Z.length>0){let F=(H.length>0?H[H.length-1]:0)===123;if(j&&F){let L=Z.charCodeAt(Z.length-1),K=L===59||L===44||L===123||Q===125,q=Z.length>=2&&Z.charCodeAt(Z.length-1)===47&&Z.charCodeAt(Z.length-2)===42;if(!K&&!q)Z+="; ";else Z+=" "}else Z+=" "}$=!1,j=!1,Z+=X[O]}return Z.trim()}function x(J){return J>=97&&J<=122||J>=65&&J<=90||J>=48&&J<=57||J===95||J===36}function b(J){let Y=J.trim(),X,G=!1;if(Y.startsWith("(")&&Y.endsWith(")"))X=Y.slice(1,-1),G=!0;else X=Y;let z=X.trim();if(!z)return G?"()":"";let B=!1;{let L=0;for(let K=0;K<z.length;K++){let q=z.charCodeAt(K);if(q===40||q===60||q===91||q===123)L++;else if(q===41||q===62||q===93||q===125)L--;else if(L===0&&q===61){let N=K>0?z.charCodeAt(K-1):0,A=K+1<z.length?z.charCodeAt(K+1):0;if(N!==61&&N!==33&&N!==60&&N!==62&&A!==61&&A!==62){B=!0;break}}}}if(!B)return Y;let Z=[],H=[],$=0,j=0,O=!1,Q=0;for(let L=0;L<=z.length;L++){if(L===z.length){Z.push(z.slice($));break}let K=z.charCodeAt(L);if(O){if(K===92){L++;continue}if(K===Q)O=!1;continue}if(K===39||K===34||K===96){O=!0,Q=K;continue}if(K===40||K===60||K===91||K===123)j++;else if(K===41||K===62||K===93||K===125)j--;else if(K===44&&j===0){Z.push(z.slice($,L));let q=",",N=L+1;while(N<z.length&&z.charCodeAt(N)<=32)q+=z[N],N++;H.push(q),$=N}}let W=[];for(let L of Z){let K=L.trim();if(!K){W.push(L);continue}let q=L.slice(0,L.length-L.trimStart().length);W.push(q+i(K))}let F=W[0]||"";for(let L=1;L<W.length;L++)F+=(H[L-1]||", ")+W[L];return G?`(${F})`:F}function i(J){if(J.startsWith("..."))return J;let Y=-1,X=-1,G=0,z=!1,B=0;for(let H=0;H<J.length;H++){let $=J.charCodeAt(H);if(z){if($===92){H++;continue}if($===B)z=!1;continue}if($===39||$===34||$===96){z=!0,B=$;continue}if($===40||$===60||$===91||$===123)G++;else if($===41||$===62||$===93||$===125)G--;else if(G===0){if($===58&&Y===-1)Y=H;else if($===61&&X===-1&&(H===0||J.charCodeAt(H-1)!==61)&&(H+1>=J.length||J.charCodeAt(H+1)!==61&&J.charCodeAt(H+1)!==62))X=H}}let Z=X!==-1;if(Y!==-1&&(X===-1||Y<X)){let H=J.slice(0,Y).trim(),$=X!==-1?J.slice(Y+1,X).trim():J.slice(Y+1).trim(),j=Z&&!H.endsWith("?")?"?":"";return`${H}${j}: ${$}`}else if(X!==-1){let H=J.slice(0,X).trim(),$=!H.endsWith("?")?"?":"",j=J.slice(X+1).trim(),O="unknown";if(j==="true"||j==="false")O="boolean";else if(/^-?\d+(\.\d+)?$/.test(j))O="number";else if(j.startsWith("'")&&j.endsWith("'")||j.startsWith('"')&&j.endsWith('"'))O="string";else if(j.startsWith("["))O="unknown[]";else if(j.startsWith("{"))O="Record<string, unknown>";return`${H}${$}: ${O}`}return J}function n(J){let Y=[],X="",G="",z=0,B=!1,Z="",H=!0,$=!1,j=0;for(let O=0;O<J.length;O++){let Q=J[O],W=O>0?J[O-1]:"",F=O<J.length-1?J[O+1]:"";if(!B&&!$&&Q==="/"&&F==="/"){O+=2;while(O<J.length&&J[O]!==`
13
+ `)O++;continue}if(!B&&!$&&Q==="/"&&F==="*"){$=!0,j=1,X+="/*",O++;continue}else if($&&Q==="*"&&F==="/"){if(j--,X+="*/",O++,j===0)$=!1;continue}else if($&&Q==="/"&&F==="*"){j++,X+="/*",O++;continue}if(!B&&(Q==='"'||Q==="'"||Q==="`"))B=!0,Z=Q,X+=Q;else if(B&&Q===Z&&W!=="\\")B=!1,X+=Q;else if(!B&&!$)if(Q==="("&&z===0&&H){if(G=X.trim(),G.startsWith("async "))G=G.slice(6).trim();X=Q,H=!1,z=1}else if(Q==="{"||Q==="["||Q==="(")z++,X+=Q;else if(Q==="}"||Q==="]"||Q===")")z--,X+=Q;else if(Q===":"&&z===0&&H)G=X.trim(),X="",H=!1;else if(Q===","&&z===0){if(G&&X.trim()){let L=X.trim();if(L.startsWith("("))L=v(G,L);else if(L.includes("=>")||L.includes("function")||L.includes("async"))L=I(L);Y.push([G,L])}X="",G="",H=!0}else X+=Q;else X+=Q}if(G&&X.trim()){let O=X.trim();if(O.startsWith("("))O=v(G,O);else if(O.includes("=>")||O.includes("function")||O.includes("async"))O=I(O);Y.push([G,O])}return Y}function v(J,Y){let X=Y,G=0;while(G<X.length&&X.charCodeAt(G)<=32)G++;if(X.startsWith("async",G)&&G+5<X.length&&X.charCodeAt(G+5)<=32)X=X.slice(G+5).trimStart();let z="";if(X.charCodeAt(0)===60){let Q=0,W=-1;for(let F=0;F<X.length;F++)if(X.charCodeAt(F)===60)Q++;else if(X.charCodeAt(F)===62){if(Q--,Q===0){W=F;break}}if(W!==-1)z=X.slice(0,W+1),X=X.slice(W+1).trimStart()}let B=X.indexOf("("),Z=g(X,B,"(",")");if(B===-1||Z===-1)return"() => unknown";let H=X.slice(B,Z+1),$="unknown",j=X.slice(Z+1).trimStart();if(j.charCodeAt(0)===58){let Q=j.indexOf("{");if(Q!==-1)$=j.slice(1,Q).trim();else $=j.slice(1).trim()}let O=b(H);return`${z}${O} => ${$}`}function g(J,Y,X,G){let z=0;for(let B=Y;B<J.length;B++)if(J[B]===X)z++;else if(J[B]===G){if(z--,z===0)return B}return-1}function a(J){let Y=0,X=0,G=!1,z="";for(let B=0;B<J.length-1;B++){let Z=J[B],H=J[B+1],$=B>0?J[B-1]:"";if(!G&&(Z==='"'||Z==="'"||Z==="`"))G=!0,z=Z;else if(G&&Z===z&&$!=="\\")G=!1;if(!G){if(Z==="(")Y++;else if(Z===")")Y--;else if(Z==="[")X++;else if(Z==="]")X--;if(Z==="="&&H===">"&&Y===0&&X===0)return B}}return-1}function h(J,Y=!1,X=0,G=!0){let z=J.trim();if(z.length>200&&E(z,"=>")>2&&E(z,"<")>5&&!z.startsWith("function"))return Y?"((...args: any[]) => any)":"(...args: any[]) => any";if(z.startsWith("async ")&&z.includes("=>")){let Z=z.slice(5).trim(),H=Z.indexOf("=>"),$=Z.substring(0,H).trim(),j=Z.substring(H+2).trim();if($=b($),$==="()"||$==="")$="()";else if(!$.startsWith("("))$=`(${$})`;let O="unknown";if(j.startsWith("{"))O="unknown";else O=V(j,G,!1,X+1);let Q=`${$} => Promise<${O}>`;return Y?`(${Q})`:Q}if(z.includes("=>")){let Z="",H=z;if(z.startsWith("<")){let K=g(z,0,"<",">");if(K!==-1)Z=z.substring(0,K+1),H=z.substring(K+1).trim()}let $=a(H);if($===-1)return Y?"(() => unknown)":"() => unknown";let j=H.substring(0,$).trim(),O=H.substring($+2).trim(),Q="",W=j.lastIndexOf("):");if(W!==-1){let K=j.substring(W+2).trim();if(K&&!K.includes("=>")&&!K.includes("="))Q=K,j=j.substring(0,W+1)}if(j=b(j),j==="()"||j==="")j="()";else if(!j.startsWith("("))j=`(${j})`;let F="unknown";if(Q)F=Q;else if(O.startsWith("{"))F="unknown";else if(O.includes("=>")){let K=O.trimStart(),q=K.indexOf("("),N=q!==-1?K.indexOf(")",q):-1,A=N!==-1?K.indexOf("=>",N):-1;if(q===0&&N!==-1&&A!==-1){let R=K.substring(q+1,N).trim();if(Z.includes("T")&&R.includes("T"))F=`(${R}) => T`;else F=`(${R}) => any`}else F="any"}else if(Y)F="unknown";else F=V(O,G,!1,X+1);let L=`${Z}${j} => ${F}`;return Y?`(${L})`:L}if(z.startsWith("function")){let Z=8,H=z.length;while(Z<H&&z.charCodeAt(Z)<=32)Z++;let $=!1;if(Z<H&&z.charCodeAt(Z)===42){$=!0,Z++;while(Z<H&&z.charCodeAt(Z)<=32)Z++}let j="";if(Z<H&&z.charCodeAt(Z)===60){let W=Z,F=1;Z++;while(Z<H&&F>0){let L=z.charCodeAt(Z);if(L===60)F++;else if(L===62)F--;Z++}j=z.substring(W,Z);while(Z<H&&z.charCodeAt(Z)<=32)Z++}let O=z.indexOf("(",Z);if(O!==-1){let W=1,F=O+1;while(F<H&&W>0){let N=z.charCodeAt(F);if(N===40)W++;else if(N===41)W--;F++}let L=z.substring(O+1,F-1).trim(),K=L?`(${L})`:"()";if($){let N=z.substring(F).trim(),A=N.indexOf("Generator<");if(A!==-1){let S=A+10,f=N.indexOf(">",S);if(f!==-1){let u=N.substring(S,f),C=`${j}${K} => Generator<${u}>`;return Y?`(${C})`:C}}let R=`${j}${K} => Generator<any, any, any>`;return Y?`(${R})`:R}let q=`${j}${K} => unknown`;return Y?`(${q})`:q}let Q="(...args: any[]) => unknown";return Y?`(${Q})`:Q}if(z.includes("=>")&&z.includes("(")&&z.includes(")")){if(z.length>100||E(z,"=>")>2){let Z="";if(z.charCodeAt(0)===60){let Q=z.indexOf(">");if(Q!==-1)Z=z.substring(0,Q+1)}let H=z.indexOf("("),$=H!==-1?z.indexOf(")",H):-1,j=H!==-1&&$!==-1?z.substring(H,$+1):"(...args: any[])",O=`${Z}${j} => any`;return Y?`(${O})`:O}return Y?`(${z})`:z}let B="() => unknown";return Y?`(${B})`:B}function e(J){let Y=J.trim();if(Y==="any"||Y==="object"||Y==="unknown")return!0;if(Y.startsWith("Record<")&&Y.endsWith(">"))return!0;if(Y.startsWith("Array<")&&Y.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(Y))return!0;return!1}function zz(J){let Y=J.lastIndexOf(" satisfies ");if(Y===-1)return null;let X=J.slice(Y+11).trim();if(X.endsWith(";"))X=X.slice(0,-1).trim();return X||null}function Xz(J){let Y=[],X=0;for(let G=0;G<=J.length;G++)if(G===J.length||J[G]===`
14
+ `){let z=X,B=G;while(z<B&&(J[z]===" "||J[z]==="\t"||J[z]==="\r"))z++;while(B>z&&(J[B-1]===" "||J[B-1]==="\t"||J[B-1]==="\r"))B--;let Z=J.slice(z,B);if(X=G+1,Z.startsWith("///")){if(Z.match(/^\/\/\/\s*<reference\s+(path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/))Y.push(Z);else if(Z.match(/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/))Y.push(Z);else if(Z.match(/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/))Y.push(Z)}else if(Z===""||Z.startsWith("//"))continue;else break}return Y}
15
+ export{r as Cc,t as Dc,V as Ec,l as Fc,D as Gc,U as Hc,s as Ic,g as Jc,h as Kc,e as Lc,zz as Mc,Xz as Nc};
@@ -0,0 +1,102 @@
1
+ // @bun
2
+ import{ec as K}from"./chunk-wfevdmvd.js";import{Vc as _}from"./chunk-57agx6g8.js";import{existsSync as j,mkdirSync as w,readFileSync as b,writeFileSync as V}from"fs";import{basename as H,join as R}from"path";function N(q){let z={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!q||q.length===0)return z;for(let A of q){let G=A.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
3
+ `).map((X)=>X.replace(/^\s*\*\s?/,"")).join(`
4
+ `).trim(),Q=G.search(/@\w+/);if(Q===-1){z.description=G;continue}else if(Q>0)z.description=G.slice(0,Q).trim(),G=G.slice(Q);let U=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,W;while((W=U.exec(G))!==null){let[,X,Y,Z]=W,$=Z.trim();switch(X){case"param":{let v=$.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(v)z.params.push({name:v[2],type:Y,description:v[3].trim(),optional:!!v[1]});break}case"returns":case"return":z.returns={type:Y,description:$};break;case"example":z.examples.push($);break;case"deprecated":z.deprecated=$||"Deprecated";break;case"since":z.since=$;break;case"see":z.see.push($);break;case"throws":case"throw":z.throws.push({type:Y,description:$});break;case"category":z.category=$;break;default:if(!z.tags[X])z.tags[X]=[];z.tags[X].push($)}}}return z}function M(q,z){let A=N(q.leadingComments),G="";switch(q.kind){case"function":G=h(q);break;case"variable":G=T(q);break;case"interface":G=F(q);break;case"type":G=S(q);break;case"class":G=k(q);break;case"enum":G=x(q);break;default:G=q.text||q.name}let Q={name:q.name,kind:q.kind,signature:G,jsdoc:A,isExported:q.isExported,isDefault:q.isDefault,sourceFile:z};if(q.members&&q.members.length>0)Q.members=q.members.map((U)=>M(U,z));return Q}function h(q){let z=[];if(q.isExported)z.push("export");if(q.isDefault)z.push("default");if(z.push("function"),z.push(q.name),q.generics)z.push(q.generics);if(q.parameters){let A=q.parameters.map((G)=>{let Q="";if(G.rest)Q+="...";if(Q+=G.name,G.optional)Q+="?";if(G.type)Q+=`: ${G.type}`;return Q}).join(", ");z.push(`(${A})`)}else z.push("()");if(q.returnType)z.push(`: ${q.returnType}`);return z.join(" ").replace(/\s+/g," ")}function T(q){let z=[];if(q.isExported)z.push("export");if(z.push("const"),z.push(q.name),q.typeAnnotation)z.push(`: ${q.typeAnnotation}`);return z.join(" ")}function F(q){let z=[];if(q.isExported)z.push("export");if(z.push("interface"),z.push(q.name),q.generics)z.push(q.generics);if(q.extends)z.push(`extends ${q.extends}`);return z.join(" ")}function S(q){let z=[];if(q.isExported)z.push("export");if(z.push("type"),z.push(q.name),q.generics)z.push(q.generics);if(z.push("="),q.typeAnnotation)z.push(q.typeAnnotation);return z.join(" ")}function k(q){let z=[];if(q.isExported)z.push("export");if(q.isDefault)z.push("default");if(z.push("class"),z.push(q.name),q.generics)z.push(q.generics);if(q.extends)z.push(`extends ${q.extends}`);if(q.implements&&q.implements.length>0)z.push(`implements ${q.implements.join(", ")}`);return z.join(" ")}function x(q){let z=[];if(q.isExported)z.push("export");return z.push("enum"),z.push(q.name),z.join(" ")}async function P(q,z={}){let A=[],G=new Map;for(let Q of q){if(!j(Q)){_.warn(`File not found: ${Q}`);continue}let U=b(Q,"utf-8"),W=K(U,Q,!0);for(let X of W){if(X.kind==="import")continue;if(!z.includePrivate&&X.name.startsWith("_"))continue;if(!z.includeInternal&&X.leadingComments?.some((Z)=>Z.includes("@internal")))continue;let Y=M(X,Q);if(A.push(Y),z.groupByCategory&&Y.jsdoc.category){let Z=Y.jsdoc.category;if(!G.has(Z))G.set(Z,[]);G.get(Z).push(Y)}}}return{title:z.title||"API Documentation",description:z.description,entries:A,categories:G,generatedAt:new Date}}function B(q,z={}){let A=[];if(A.push(`# ${q.title}`),A.push(""),q.description)A.push(q.description),A.push("");if(A.push(`> Generated on ${q.generatedAt.toISOString()}`),A.push(""),A.push("## Table of Contents"),A.push(""),z.groupByCategory&&q.categories.size>0)for(let G of q.categories.keys())A.push(`- [${G}](#${E(G)})`);else{let G=I(q.entries);for(let[Q,U]of G)if(U.length>0)A.push(`- [${O(Q)}](#${E(O(Q))})`)}if(A.push(""),z.groupByCategory&&q.categories.size>0)for(let[G,Q]of q.categories){A.push(`## ${G}`),A.push("");for(let U of Q)A.push(...L(U,z))}else{let G=I(q.entries);for(let[Q,U]of G)if(U.length>0){A.push(`## ${O(Q)}`),A.push("");for(let W of U)A.push(...L(W,z))}}return A.join(`
5
+ `)}function L(q,z){let A=[];if(A.push(`### ${q.name}`),A.push(""),q.jsdoc.deprecated)A.push(`> **Deprecated:** ${q.jsdoc.deprecated}`),A.push("");if(A.push("```typescript"),A.push(q.signature),A.push("```"),A.push(""),q.jsdoc.description)A.push(q.jsdoc.description),A.push("");if(q.jsdoc.params.length>0){A.push("**Parameters:**"),A.push(""),A.push("| Name | Type | Description |"),A.push("|------|------|-------------|");for(let G of q.jsdoc.params){let Q=G.optional?" (optional)":"",U=G.type||"any";A.push(`| \`${G.name}\`${Q} | \`${U}\` | ${G.description} |`)}A.push("")}if(q.jsdoc.returns){A.push("**Returns:**"),A.push("");let G=q.jsdoc.returns.type?`\`${q.jsdoc.returns.type}\``:"";A.push(`${G} ${q.jsdoc.returns.description}`),A.push("")}if(q.jsdoc.throws.length>0){A.push("**Throws:**"),A.push("");for(let G of q.jsdoc.throws){let Q=G.type?`\`${G.type}\``:"";A.push(`- ${Q} ${G.description}`)}A.push("")}if(q.jsdoc.examples.length>0){A.push("**Examples:**"),A.push("");for(let G of q.jsdoc.examples)A.push("```typescript"),A.push(G),A.push("```"),A.push("")}if(q.jsdoc.see.length>0){A.push("**See also:**"),A.push("");for(let G of q.jsdoc.see)A.push(`- ${G}`);A.push("")}if(q.jsdoc.since)A.push(`*Since: ${q.jsdoc.since}*`),A.push("");if(z.includeSourceLinks&&q.sourceFile){let G=q.sourceFile;if(z.sourceBaseUrl)A.push(`[Source](${z.sourceBaseUrl}/${G})`);else A.push(`*Source: ${G}*`);A.push("")}if(q.members&&q.members.length>0){A.push("**Members:**"),A.push("");for(let G of q.members)if(A.push(`#### ${G.name}`),A.push(""),A.push("```typescript"),A.push(G.signature),A.push("```"),A.push(""),G.jsdoc.description)A.push(G.jsdoc.description),A.push("")}return A.push("---"),A.push(""),A}function C(q,z={}){let A=B(q,z);return`<!DOCTYPE html>
6
+ <html lang="en">
7
+ <head>
8
+ <meta charset="UTF-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
+ <title>${f(q.title)}</title>
11
+ <style>
12
+ :root {
13
+ --bg: #ffffff;
14
+ --text: #1a1a1a;
15
+ --code-bg: #f4f4f4;
16
+ --border: #e0e0e0;
17
+ --link: #0066cc;
18
+ }
19
+ @media (prefers-color-scheme: dark) {
20
+ :root {
21
+ --bg: #1a1a1a;
22
+ --text: #e0e0e0;
23
+ --code-bg: #2d2d2d;
24
+ --border: #404040;
25
+ --link: #66b3ff;
26
+ }
27
+ }
28
+ body {
29
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
30
+ line-height: 1.6;
31
+ max-width: 900px;
32
+ margin: 0 auto;
33
+ padding: 2rem;
34
+ background: var(--bg);
35
+ color: var(--text);
36
+ }
37
+ h1, h2, h3, h4 { margin-top: 2rem; }
38
+ code {
39
+ background: var(--code-bg);
40
+ padding: 0.2em 0.4em;
41
+ border-radius: 3px;
42
+ font-family: 'Monaco', 'Menlo', monospace;
43
+ font-size: 0.9em;
44
+ }
45
+ pre {
46
+ background: var(--code-bg);
47
+ padding: 1rem;
48
+ border-radius: 6px;
49
+ overflow-x: auto;
50
+ }
51
+ pre code {
52
+ padding: 0;
53
+ background: none;
54
+ }
55
+ table {
56
+ border-collapse: collapse;
57
+ width: 100%;
58
+ margin: 1rem 0;
59
+ }
60
+ th, td {
61
+ border: 1px solid var(--border);
62
+ padding: 0.5rem;
63
+ text-align: left;
64
+ }
65
+ th { background: var(--code-bg); }
66
+ a { color: var(--link); }
67
+ blockquote {
68
+ border-left: 4px solid var(--border);
69
+ margin: 1rem 0;
70
+ padding-left: 1rem;
71
+ color: #666;
72
+ }
73
+ hr {
74
+ border: none;
75
+ border-top: 1px solid var(--border);
76
+ margin: 2rem 0;
77
+ }
78
+ .deprecated {
79
+ background: #fff3cd;
80
+ border-left: 4px solid #ffc107;
81
+ padding: 0.5rem 1rem;
82
+ margin: 1rem 0;
83
+ }
84
+ @media (prefers-color-scheme: dark) {
85
+ .deprecated {
86
+ background: #3d3000;
87
+ border-left-color: #ffc107;
88
+ }
89
+ }
90
+ </style>
91
+ </head>
92
+ <body>
93
+ <article id="content"></article>
94
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
95
+ <script>
96
+ const markdown = ${JSON.stringify(A)};
97
+ document.getElementById('content').innerHTML = marked.parse(markdown);
98
+ </script>
99
+ </body>
100
+ </html>`}function D(q,z={}){let A={title:q.title,description:q.description,generatedAt:q.generatedAt.toISOString(),version:"1.0.0",entries:q.entries.map((G)=>({name:G.name,kind:G.kind,signature:G.signature,description:G.jsdoc.description,isExported:G.isExported,isDefault:G.isDefault,deprecated:G.jsdoc.deprecated,since:G.jsdoc.since,category:G.jsdoc.category,params:G.jsdoc.params,returns:G.jsdoc.returns,examples:G.jsdoc.examples,throws:G.jsdoc.throws,see:G.jsdoc.see,tags:G.jsdoc.tags,sourceFile:G.sourceFile,sourceLine:G.sourceLine,members:G.members?.map((Q)=>({name:Q.name,kind:Q.kind,signature:Q.signature,description:Q.jsdoc.description,deprecated:Q.jsdoc.deprecated,params:Q.jsdoc.params,returns:Q.jsdoc.returns}))})),categories:z.groupByCategory?Object.fromEntries(Array.from(q.categories.entries()).map(([G,Q])=>[G,Q.map((U)=>U.name)])):void 0};return JSON.stringify(A,null,2)}function u(q){let z={id:0,name:q.title,kind:1,kindString:"Project",flags:{},children:q.entries.map((A,G)=>({id:G+1,name:A.name,kind:J(A.kind),kindString:A.kind,flags:{isExported:A.isExported,isDefault:A.isDefault},comment:A.jsdoc.description?{summary:[{kind:"text",text:A.jsdoc.description}],blockTags:A.jsdoc.deprecated?[{tag:"@deprecated",content:[{kind:"text",text:A.jsdoc.deprecated}]}]:void 0}:void 0,sources:A.sourceFile?[{fileName:A.sourceFile,line:A.sourceLine||1,character:0}]:void 0,signatures:A.kind==="function"?[{id:G+1000,name:A.name,kind:4096,kindString:"Call signature",parameters:A.jsdoc.params.map((Q,U)=>({id:G+2000+U,name:Q.name,kind:32768,kindString:"Parameter",flags:{isOptional:Q.optional},type:Q.type?{type:"intrinsic",name:Q.type}:void 0,comment:Q.description?{summary:[{kind:"text",text:Q.description}]}:void 0})),type:A.jsdoc.returns?.type?{type:"intrinsic",name:A.jsdoc.returns.type}:void 0}]:void 0,children:A.members?.map((Q,U)=>({id:G+3000+U,name:Q.name,kind:J(Q.kind),kindString:Q.kind,comment:Q.jsdoc.description?{summary:[{kind:"text",text:Q.jsdoc.description}]}:void 0}))}))};return JSON.stringify(z,null,2)}async function d(q,z){_.info("Extracting documentation...");let A=await P(q,z);if(_.info(`Found ${A.entries.length} documented entries`),!j(z.outdir))w(z.outdir,{recursive:!0});if(z.format==="markdown")if(z.splitByModule){let G=m(A.entries);for(let[U,W]of G){let X={title:H(U,".ts"),description:`Documentation for ${U}`,entries:W,categories:new Map,generatedAt:A.generatedAt},Y=B(X,z),Z=R(z.outdir,`${H(U,".ts")}.md`);V(Z,Y),_.info(`Generated: ${Z}`)}let Q=[`# ${A.title}`,"",A.description||"","","## Modules",""];for(let[U]of G){let W=H(U,".ts");Q.push(`- [${W}](./${W}.md)`)}V(R(z.outdir,"README.md"),Q.join(`
101
+ `)),_.info(`Generated: ${R(z.outdir,"README.md")}`)}else{let G=B(A,z),Q=R(z.outdir,"API.md");V(Q,G),_.info(`Generated: ${Q}`)}else if(z.format==="json"){let G=D(A,z),Q=R(z.outdir,"api.json");V(Q,G),_.info(`Generated: ${Q}`);let U=u(A),W=R(z.outdir,"typedoc.json");V(W,U),_.info(`Generated: ${W}`)}else{let G=C(A,z),Q=R(z.outdir,"index.html");V(Q,G),_.info(`Generated: ${Q}`)}}function E(q){return q.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function O(q){return{function:"Functions",variable:"Variables",interface:"Interfaces",type:"Type Aliases",class:"Classes",enum:"Enums",export:"Exports",module:"Modules"}[q]||q}function I(q){let z=new Map,A=["function","class","interface","type","enum","variable"];for(let G of A)z.set(G,[]);for(let G of q){let Q=G.kind;if(!z.has(Q))z.set(Q,[]);z.get(Q).push(G)}return z}function f(q){return q.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function m(q){let z=new Map;for(let A of q){let G=A.sourceFile||"unknown";if(!z.has(G))z.set(G,[]);z.get(G).push(A)}return z}function J(q){return{function:64,variable:32,interface:256,type:4194304,class:128,enum:8,property:1024,method:2048,module:2,namespace:4}[q]||0}function l(q={}){return{extract:(z)=>P(z,q),generateMarkdown:(z)=>B(z,q),generateHTML:(z)=>C(z,q),generateJSON:(z)=>D(z,q),parseJSDoc:N}}
102
+ export{N as d,P as e,B as f,C as g,D as h,u as i,d as j,l as k};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{l as a,m as b,n as c,o as d,p as e,q as f,r as g}from"./chunk-1bav913n.js";import"./chunk-9a6yn7sv.js";import"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import"./chunk-hrmnrn4p.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-begk3j01.js";import"./chunk-xnq1xw73.js";import"./chunk-f18nyrrb.js";import"./chunk-57agx6g8.js";import"./chunk-rw6j20e2.js";export{b as sortProjectsByDependencies,f as resolveWorkspacePatterns,c as generateWorkspace,d as generateMonorepo,g as generateFromPackageWorkspaces,a as discoverWorkspaceProjects,e as discoverWorkspaceFromPackageJson};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{tb as C}from"./chunk-9a6yn7sv.js";function y(F={}){let{onStart:H=!1,onEnd:I=!0,onGenerated:J,onError:z,...q}=F,B=async()=>{try{let k=await C(q);J?.(k)}catch(k){let j=k instanceof Error?k:Error(String(k));if(z?.(j),!z)console.error("[dtsx] Generation failed:",j.message)}};return{name:"dtsx",setup(k){let j=k.initialOptions;if(!q.entrypoints&&j.entryPoints)if(Array.isArray(j.entryPoints))q.entrypoints=j.entryPoints;else q.entrypoints=Object.values(j.entryPoints);if(!q.outdir){if(j.outdir)q.outdir=j.outdir;else if(j.outfile){let w=j.outfile.lastIndexOf("/");if(w!==-1)q.outdir=j.outfile.substring(0,w)}}if(H)k.onStart(async()=>{await B()});if(I)k.onEnd(async(w)=>{if(w.errors.length===0)await B()})}}}var L=y,M=y,P=y;
3
+ export{y as ia,L as ja,M as ka,P as la};
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Build a dependency graph from TypeScript source files
3
+ */
4
+ export declare function buildDependencyGraph(files: string[], options?: CircularDetectionOptions): Promise<Map<string, DependencyNode>>;
5
+ /**
6
+ * Detect circular dependencies in a dependency graph
7
+ */
8
+ export declare function detectCircularDependencies(graph: Map<string, DependencyNode>, options?: CircularDetectionOptions): CircularDependency[];
9
+ /**
10
+ * Analyze files for circular dependencies
11
+ */
12
+ export declare function analyzeCircularDependencies(files: string[], options?: CircularDetectionOptions): Promise<CircularAnalysisResult>;
13
+ /**
14
+ * Format circular dependency analysis as a string
15
+ */
16
+ export declare function formatCircularAnalysis(result: CircularAnalysisResult, rootDir?: string): string;
17
+ /**
18
+ * Get a summary of the dependency graph
19
+ */
20
+ export declare function getGraphSummary(graph: Map<string, DependencyNode>): {
21
+ totalFiles: number
22
+ totalDependencies: number
23
+ avgDependencies: number
24
+ maxDependencies: { file: string, count: number }
25
+ isolatedFiles: string[]
26
+ mostDepended: { file: string, count: number }
27
+ };
28
+ /**
29
+ * Find all files that depend on a given file (transitive)
30
+ */
31
+ export declare function findAllDependents(filePath: string, graph: Map<string, DependencyNode>): Set<string>;
32
+ /**
33
+ * Find all dependencies of a given file (transitive)
34
+ */
35
+ export declare function findAllDependencies(filePath: string, graph: Map<string, DependencyNode>): Set<string>;
36
+ /**
37
+ * Export dependency graph as DOT format (for visualization with Graphviz)
38
+ */
39
+ export declare function exportGraphAsDot(graph: Map<string, DependencyNode>, rootDir?: string): string;
40
+ /**
41
+ * Export dependency graph as JSON
42
+ */
43
+ export declare function exportGraphAsJson(graph: Map<string, DependencyNode>, rootDir?: string): string;
44
+ /**
45
+ * A node in the dependency graph
46
+ */
47
+ export declare interface DependencyNode {
48
+ path: string
49
+ exports: Set<string>
50
+ imports: Map<string, string>
51
+ dependencies: Set<string>
52
+ dependents: Set<string>
53
+ }
54
+ /**
55
+ * A circular dependency chain
56
+ */
57
+ export declare interface CircularDependency {
58
+ chain: string[]
59
+ symbols: string[]
60
+ severity: 'error' | 'warning'
61
+ reason: string
62
+ }
63
+ /**
64
+ * Result of circular dependency analysis
65
+ */
66
+ export declare interface CircularAnalysisResult {
67
+ hasCircular: boolean
68
+ cycles: CircularDependency[]
69
+ graph: Map<string, DependencyNode>
70
+ filesAnalyzed: string[]
71
+ durationMs: number
72
+ }
73
+ /**
74
+ * Options for circular dependency detection
75
+ */
76
+ export declare interface CircularDetectionOptions {
77
+ rootDir?: string
78
+ ignore?: string[]
79
+ typesOnly?: boolean
80
+ maxDepth?: number
81
+ includeNodeModules?: boolean
82
+ }
@@ -0,0 +1,108 @@
1
+ import type { ChildProcess } from 'node:child_process';
2
+ /**
3
+ * Cross-runtime file handle creator
4
+ * Compatible with Bun.file() API
5
+ */
6
+ export declare function file(path: string): FileHandle;
7
+ /**
8
+ * Cross-runtime file writer
9
+ * Compatible with Bun.write() API
10
+ */
11
+ export declare function write(path: string, content: string | Uint8Array | ArrayBuffer): Promise<number>;
12
+ /**
13
+ * Cross-runtime process spawner
14
+ * Compatible with Bun.spawn() API
15
+ */
16
+ export declare function spawnProcess(command: string | string[], options?: CompatSpawnOptions): SpawnResult;
17
+ /**
18
+ * Read a file as text with cross-runtime compatibility
19
+ */
20
+ export declare function readTextFile(path: string): Promise<string>;
21
+ /**
22
+ * Check if a file exists with cross-runtime compatibility
23
+ */
24
+ export declare function fileExists(path: string): Promise<boolean>;
25
+ /**
26
+ * Write text to a file with cross-runtime compatibility
27
+ */
28
+ export declare function writeTextFile(path: string, content: string): Promise<void>;
29
+ /**
30
+ * Get runtime information
31
+ */
32
+ export declare function getRuntimeInfo(): RuntimeInfo;
33
+ /**
34
+ * Runtime detection
35
+ */
36
+ export declare const isBun: boolean;
37
+ export declare const isNode: boolean;
38
+ /**
39
+ * Current runtime name
40
+ */
41
+ export declare const runtime: 'bun' | 'node';
42
+ /**
43
+ * File handle interface compatible with Bun.file()
44
+ */
45
+ export declare interface FileHandle {
46
+ exists: () => Promise<boolean>
47
+ text: () => Promise<string>
48
+ arrayBuffer: () => Promise<ArrayBuffer>
49
+ size: number
50
+ name: string
51
+ }
52
+ /**
53
+ * Spawn result interface compatible with Bun.spawn()
54
+ */
55
+ export declare interface SpawnResult {
56
+ pid: number
57
+ stdout: ReadableStream<Uint8Array> | NodeJS.ReadableStream
58
+ stderr: ReadableStream<Uint8Array> | NodeJS.ReadableStream
59
+ stdin: WritableStream<Uint8Array> | NodeJS.WritableStream | null
60
+ exited: Promise<number>
61
+ kill: (signal?: number) => void
62
+ ref: () => void
63
+ unref: () => void
64
+ }
65
+ /**
66
+ * Spawn options compatible with Bun.spawn()
67
+ */
68
+ export declare interface CompatSpawnOptions {
69
+ cwd?: string
70
+ env?: Record<string, string | undefined>
71
+ stdin?: 'inherit' | 'pipe' | 'ignore' | null
72
+ stdout?: 'inherit' | 'pipe' | 'ignore' | null
73
+ stderr?: 'inherit' | 'pipe' | 'ignore' | null
74
+ }
75
+ /**
76
+ * Runtime information
77
+ */
78
+ export declare interface RuntimeInfo {
79
+ name: 'bun' | 'node'
80
+ version: string
81
+ isBun: boolean
82
+ isNode: boolean
83
+ }
84
+ /**
85
+ * Node.js implementation of Bun-like file handle
86
+ */
87
+ declare class NodeFileHandle implements FileHandle {
88
+ name: string;
89
+ constructor(path: string);
90
+ exists(): Promise<boolean>;
91
+ text(): Promise<string>;
92
+ arrayBuffer(): Promise<ArrayBuffer>;
93
+ get size(): number;
94
+ }
95
+ /**
96
+ * Node.js implementation of Bun-like spawn result
97
+ */
98
+ declare class NodeSpawnResult implements SpawnResult {
99
+ pid: number;
100
+ stdout: NodeJS.ReadableStream;
101
+ stderr: NodeJS.ReadableStream;
102
+ stdin: NodeJS.WritableStream | null;
103
+ exited: Promise<number>;
104
+ constructor(proc: ChildProcess);
105
+ kill(signal?: number): void;
106
+ ref(): void;
107
+ unref(): void;
108
+ }
package/dist/config.d.ts CHANGED
@@ -1,5 +1,35 @@
1
1
  import type { DtsGenerationConfig } from './types';
2
+ /**
3
+ * Get the configuration, loading from config file if available
4
+ */
5
+ export declare function getConfig(cwd?: string): Promise<DtsGenerationConfig>;
6
+ /**
7
+ * Reset the cached config (useful for testing)
8
+ */
9
+ export declare function resetConfig(): void;
10
+ /*.ts'],
11
+ * keepComments: true,
12
+ * })
13
+ * ```
14
+ */
15
+ export declare function defineConfig(config: Partial<DtsGenerationConfig>): DtsGenerationConfig;
16
+ /**
17
+ * Define a dtsx configuration with async support
18
+ * Allows loading plugins or other async dependencies
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // dtsx.config.ts
23
+ * import { defineConfigAsync } from 'dtsx'
24
+ *
25
+ * export default defineConfigAsync(async () => ({
26
+ * root: './src',
27
+ * outdir: './dist',
28
+ * plugins: [await loadPlugin()],
29
+ * }))
30
+ * ```
31
+ */
32
+ export declare function defineConfigAsync(configFn: () => Promise<Partial<DtsGenerationConfig>>): () => Promise<DtsGenerationConfig>;
2
33
  export declare const defaultConfig: DtsGenerationConfig;
3
- // Get loaded config
4
- // eslint-disable-next-line antfu/no-top-level-await
5
- export declare const config: DtsGenerationConfig;
34
+ // For backwards compatibility - synchronous access with default fallback
35
+ export declare const config: DtsGenerationConfig;
package/dist/diff.d.ts ADDED
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Compute diff between two strings
3
+ */
4
+ export declare function computeDiff(oldContent: string, newContent: string, filePath: string, options?: DiffOptions): DiffResult;
5
+ /**
6
+ * Format diff result as unified diff string
7
+ */
8
+ export declare function formatUnifiedDiff(result: DiffResult): string;
9
+ /**
10
+ * Format diff with colors for terminal output
11
+ */
12
+ export declare function formatColoredDiff(result: DiffResult): string;
13
+ /**
14
+ * Format diff as simple summary
15
+ */
16
+ export declare function formatDiffSummary(result: DiffResult): string;
17
+ /**
18
+ * Compare a file against new content
19
+ */
20
+ export declare function diffFile(filePath: string, newContent: string, options?: DiffOptions): Promise<DiffResult>;
21
+ /**
22
+ * Compare multiple files
23
+ */
24
+ export declare function diffFiles(files: Map<string, string>, options?: DiffOptions): Promise<Map<string, DiffResult>>;
25
+ /**
26
+ * Generate a summary of all diffs
27
+ */
28
+ export declare function summarizeDiffs(results: Map<string, DiffResult>): {
29
+ totalFiles: number
30
+ changedFiles: number
31
+ unchangedFiles: number
32
+ totalAdditions: number
33
+ totalDeletions: number
34
+ newFiles: number
35
+ };
36
+ /**
37
+ * Print colored diff to console
38
+ */
39
+ export declare function printDiff(result: DiffResult): void;
40
+ /**
41
+ * Print all diffs to console
42
+ */
43
+ export declare function printDiffs(results: Map<string, DiffResult>, showUnchanged?: boolean): void;
44
+ /**
45
+ * A single diff hunk (change)
46
+ */
47
+ export declare interface DiffHunk {
48
+ operation: DiffOperation
49
+ lines: string[]
50
+ oldStart: number
51
+ oldCount: number
52
+ newStart: number
53
+ newCount: number
54
+ }
55
+ /**
56
+ * Complete diff result
57
+ */
58
+ export declare interface DiffResult {
59
+ filePath: string
60
+ identical: boolean
61
+ hunks: DiffHunk[]
62
+ stats: {
63
+ additions: number
64
+ deletions: number
65
+ unchanged: number
66
+ }
67
+ oldContent?: string
68
+ newContent: string
69
+ }
70
+ /**
71
+ * Options for diff generation
72
+ */
73
+ export declare interface DiffOptions {
74
+ context?: number
75
+ ignoreWhitespace?: boolean
76
+ ignoreBlankLines?: boolean
77
+ treatMissingAsEmpty?: boolean
78
+ }
79
+ /**
80
+ * Diff operation type
81
+ */
82
+ export type DiffOperation = 'add' | 'remove' | 'equal';