@stacksjs/dtsx 0.9.9 → 0.9.10

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 +168 -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-09zp67d8.js +6 -0
  9. package/dist/chunk-0kmfaaz6.js +2 -0
  10. package/dist/chunk-1mm3t0nr.js +3 -0
  11. package/dist/chunk-2f046tgr.js +2 -0
  12. package/dist/chunk-3g2v2ns2.js +2 -0
  13. package/dist/chunk-3j7r0fxz.js +2 -0
  14. package/dist/chunk-3mxzfgcv.js +75 -0
  15. package/dist/chunk-4ev1n7r7.js +3 -0
  16. package/dist/chunk-57agx6g8.js +3 -0
  17. package/dist/chunk-6ppqaypd.js +2 -0
  18. package/dist/chunk-6qv7p9sg.js +170 -0
  19. package/dist/chunk-6s7n1gt0.js +2 -0
  20. package/dist/chunk-74j5mydx.js +3 -0
  21. package/dist/chunk-7cpp6v8f.js +2 -0
  22. package/dist/chunk-9a3jfxnc.js +3 -0
  23. package/dist/chunk-9mjc7ddv.js +19 -0
  24. package/dist/chunk-axb2kjeq.js +2 -0
  25. package/dist/chunk-bn29kee5.js +102 -0
  26. package/dist/chunk-c18vx9sq.js +2 -0
  27. package/dist/chunk-d0p3jzwb.js +34 -0
  28. package/dist/chunk-dk2vv0np.js +15 -0
  29. package/dist/chunk-e3j9tecw.js +3 -0
  30. package/dist/chunk-f18nyrrb.js +32 -0
  31. package/dist/chunk-fbqcsr60.js +22 -0
  32. package/dist/chunk-ffqpf34b.js +3 -0
  33. package/dist/chunk-fw6wcdfd.js +4 -0
  34. package/dist/chunk-h12gdfk9.js +2 -0
  35. package/dist/chunk-j22v8wfe.js +33 -0
  36. package/dist/chunk-jm5ywn4e.js +13 -0
  37. package/dist/chunk-jvz9t6pq.js +2 -0
  38. package/dist/chunk-k5h5ppp5.js +2 -0
  39. package/dist/chunk-p1d09y82.js +449 -0
  40. package/dist/chunk-pyxbb193.js +2 -0
  41. package/dist/chunk-q75q4w1s.js +3 -0
  42. package/dist/chunk-r1m3q3dj.js +2 -0
  43. package/dist/chunk-r1ywapeb.js +6 -0
  44. package/dist/chunk-rnt0wkrk.js +23 -0
  45. package/dist/chunk-rrkq4k1n.js +2 -0
  46. package/dist/chunk-rw6j20e2.js +3 -0
  47. package/dist/chunk-v96rjx7x.js +134 -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 +148 -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,170 @@
1
+ // @bun
2
+ import{Vc as I}from"./chunk-57agx6g8.js";import{cpus as K}from"os";import{resolve as J}from"path";import{Worker as M}from"worker_threads";var __dirname="/home/runner/work/dtsx/dtsx/packages/dtsx/src";class L{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(q={}){let y=q.maxWorkers??Math.max(1,K().length-1);this.config={maxWorkers:y,taskTimeout:q.taskTimeout??30000,recycleAfter:q.recycleAfter??100,idleTimeout:q.idleTimeout??1e4,initialWorkers:q.initialWorkers??Math.min(2,y)}}async init(){let q=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let y=0;y<q;y++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let q=`
3
+ const { parentPort } = require('worker_threads');
4
+ const bun = typeof Bun !== 'undefined' ? Bun : null;
5
+ const fs = bun ? null : require('node:fs');
6
+
7
+ const libsPromise = (async () => {
8
+ const { extractDeclarations } = await import('${J(__dirname,"extractor.js")}');
9
+ const { processDeclarations } = await import('${J(__dirname,"processor.js")}');
10
+ return { extractDeclarations, processDeclarations };
11
+ })();
12
+
13
+ // Dynamic import for ESM compatibility
14
+ async function processTask(task) {
15
+ const startTime = Date.now();
16
+
17
+ try {
18
+ const { extractDeclarations, processDeclarations } = await libsPromise;
19
+
20
+ const keepComments = task.config?.keepComments;
21
+ const isolatedDeclarations = task.config?.isolatedDeclarations;
22
+ const importOrder = task.config?.importOrder;
23
+
24
+ if (task.type === 'process-batch') {
25
+ const filePaths = task.filePaths;
26
+ const outPaths = task.outPaths;
27
+ const files = filePaths ? null : (task.files || []);
28
+ const fileCount = filePaths ? filePaths.length : files.length;
29
+ const writeOutput = task.writeOutput === true;
30
+ const results = writeOutput ? null : new Array(fileCount);
31
+ let errorResults = null;
32
+
33
+ let sources = task.sources;
34
+ if (!sources && fileCount > 0) {
35
+ const readPromises = new Array(fileCount);
36
+ for (let i = 0; i < fileCount; i++) {
37
+ const file = files ? files[i] : null;
38
+ const sourceCode = file ? file.sourceCode : undefined;
39
+ const filePath = filePaths ? filePaths[i] : file.filePath;
40
+ if (sourceCode != null) {
41
+ readPromises[i] = Promise.resolve(sourceCode);
42
+ } else if (bun) {
43
+ readPromises[i] = bun.file(filePath).text();
44
+ } else {
45
+ readPromises[i] = Promise.resolve(fs.readFileSync(filePath, 'utf-8'));
46
+ }
47
+ }
48
+ sources = await Promise.all(readPromises);
49
+ }
50
+
51
+ const ctx = { filePath: '', sourceCode: '', declarations: [] };
52
+ const writePromises = writeOutput && bun ? new Array(fileCount) : null;
53
+ let success = true;
54
+
55
+ for (let i = 0; i < fileCount; i++) {
56
+ const file = files ? files[i] : null;
57
+ const filePath = filePaths ? filePaths[i] : file.filePath;
58
+ const outPath = outPaths ? outPaths[i] : (file ? file.outPath : undefined);
59
+ try {
60
+ const sourceCode = sources ? sources[i] : (file?.sourceCode || '');
61
+ const declarations = extractDeclarations(sourceCode, filePath, keepComments, isolatedDeclarations);
62
+ ctx.filePath = filePath;
63
+ ctx.sourceCode = sourceCode;
64
+ ctx.declarations = declarations;
65
+ const content = processDeclarations(declarations, ctx, true, importOrder);
66
+
67
+ if (writeOutput) {
68
+ if (!outPath) {
69
+ throw new Error('Missing outPath for ' + filePath);
70
+ }
71
+ if (bun) {
72
+ writePromises[i] = bun.write(outPath, content);
73
+ } else {
74
+ fs.writeFileSync(outPath, content);
75
+ }
76
+ } else if (results) {
77
+ results[i] = {
78
+ filePath,
79
+ success: true,
80
+ content,
81
+ declarations,
82
+ };
83
+ }
84
+ } catch (error) {
85
+ const message = error && error.message ? error.message : String(error);
86
+ if (writeOutput) {
87
+ if (!errorResults) {
88
+ errorResults = [];
89
+ }
90
+ errorResults.push({
91
+ filePath,
92
+ success: false,
93
+ error: message,
94
+ });
95
+ } else if (results) {
96
+ results[i] = {
97
+ filePath,
98
+ success: false,
99
+ error: message,
100
+ };
101
+ }
102
+ success = false;
103
+ }
104
+ }
105
+
106
+ if (writePromises) {
107
+ await Promise.all(writePromises);
108
+ }
109
+
110
+ const errorMessage = errorResults?.length
111
+ ? (errorResults[0].filePath + ': ' + (errorResults[0].error || 'Worker batch failed'))
112
+ : undefined;
113
+
114
+ return {
115
+ id: task.id,
116
+ success,
117
+ filePath: task.filePath,
118
+ batchResults: writeOutput ? errorResults || undefined : results,
119
+ error: errorMessage,
120
+ duration: Date.now() - startTime,
121
+ };
122
+ }
123
+
124
+ if (task.type === 'extract') {
125
+ const declarations = extractDeclarations(task.sourceCode, task.filePath, keepComments, isolatedDeclarations);
126
+ return {
127
+ id: task.id,
128
+ success: true,
129
+ filePath: task.filePath,
130
+ declarations,
131
+ duration: Date.now() - startTime,
132
+ };
133
+ }
134
+
135
+ if (task.type === 'process') {
136
+ const declarations = extractDeclarations(task.sourceCode, task.filePath, keepComments, isolatedDeclarations);
137
+ const content = processDeclarations(declarations, {
138
+ filePath: task.filePath,
139
+ sourceCode: task.sourceCode,
140
+ declarations,
141
+ }, true, importOrder);
142
+
143
+ return {
144
+ id: task.id,
145
+ success: true,
146
+ filePath: task.filePath,
147
+ content,
148
+ declarations,
149
+ duration: Date.now() - startTime,
150
+ };
151
+ }
152
+
153
+ throw new Error('Unknown task type: ' + task.type);
154
+ } catch (error) {
155
+ return {
156
+ id: task.id,
157
+ success: false,
158
+ filePath: task.filePath,
159
+ error: error.message,
160
+ duration: Date.now() - startTime,
161
+ };
162
+ }
163
+ }
164
+
165
+ parentPort.on('message', async (task) => {
166
+ const result = await processTask(task);
167
+ parentPort.postMessage(result);
168
+ });
169
+ `,y=new M(q,{eval:!0}),F={worker:y,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return y.on("message",(E)=>{this.handleWorkerResult(F,E)}),y.on("error",(E)=>{I.error("Worker error:",E),this.handleWorkerError(F,E)}),y.on("exit",(E)=>{if(E!==0&&!this.isShuttingDown)I.error(`Worker exited with code ${E}`),this.removeWorker(F)}),this.workers.push(F),this.updateStats(),F}handleWorkerResult(q,y){if(q.busy=!1,q.taskCount++,q.lastActive=Date.now(),q.currentTask&&q.currentTask.id===y.id){clearTimeout(q.currentTask.timeout);let{resolve:E}=q.currentTask;q.currentTask=null,E(y)}if(y.success)this.stats.completedTasks++;else this.stats.failedTasks++;let F=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+y.duration;if(this.stats.averageDuration=F/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),q.taskCount>=this.config.recycleAfter)this.recycleWorker(q);this.processQueue()}handleWorkerError(q,y){if(q.busy=!1,q.currentTask){clearTimeout(q.currentTask.timeout);let{reject:F}=q.currentTask;q.currentTask=null,F(y)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(q),this.processQueue()}removeWorker(q){let y=this.workers.indexOf(q);if(y!==-1)this.workers.splice(y,1),q.worker.terminate();this.updateStats()}recycleWorker(q){if(this.removeWorker(q),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let q=Date.now(),y=1;for(let F=this.workers.length-1;F>=0;F--){let E=this.workers[F];if(!E.busy&&q-E.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(E)}}processQueue(){while(this.taskQueue.length>0){let q;for(let G=0;G<this.workers.length;G++)if(!this.workers[G].busy){q=this.workers[G];break}if(!q&&this.workers.length<this.config.maxWorkers)q=this.createWorker();if(!q)return;let{task:y,resolve:F,reject:E}=this.taskQueue.shift();q.busy=!0,q.lastActive=Date.now();let H=setTimeout(()=>{if(q.currentTask?.id===y.id)q.currentTask=null;E(Error(`Task ${y.id} timed out`)),this.recycleWorker(q)},this.config.taskTimeout);q.currentTask={id:y.id,resolve:F,reject:E,timeout:H},q.worker.postMessage(y),this.updateStats()}}async submit(q){return this.stats.totalTasks++,new Promise((y,F)=>{this.taskQueue.push({task:q,resolve:y,reject:F}),this.processQueue()})}async processFiles(q,y={}){let F=q.map((E,H)=>({id:`task-${H}-${Date.now()}`,type:"process",filePath:E.path,sourceCode:E.content,config:y}));return Promise.all(F.map((E)=>this.submit(E)))}updateStats(){let q=0;for(let y=0;y<this.workers.length;y++)if(this.workers[y].busy)q++;this.stats.activeWorkers=q,this.stats.idleWorkers=this.workers.length-q}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((q)=>q.busy))await new Promise((q)=>setTimeout(q,100));await Promise.all(this.workers.map((q)=>q.worker.terminate())),this.workers=[]}}function N(q={}){return new L(q)}async function U(q,y={},F={}){let E=N(F);await E.init();try{return await E.processFiles(q,y)}finally{await E.shutdown()}}function V(q,y){let F=[];for(let E=0;E<q.length;E+=y)F.push(q.slice(E,E+y));return F}function X(q,y=K().length){if(q<=y)return 1;let E=y*3;return Math.max(1,Math.ceil(q/E))}
170
+ export{L as Z,N as _,U as $,V as aa,X as ba};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Oc as a,Pc as b,Qc as c,Rc as d,Sc as e,Tc as f}from"./chunk-f18nyrrb.js";import"./chunk-57agx6g8.js";import"./chunk-rw6j20e2.js";export{c as resetConfig,b as getConfig,e as defineConfigAsync,d as defineConfig,a as defaultConfig,f as config};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{nc as J}from"./chunk-rnt0wkrk.js";var S=typeof globalThis.Bun?.hash==="function";function z(u){if(S)return Bun.hash(u);let g=0;for(let f=0;f<u.length;f++){let b=u.charCodeAt(f);g=(g<<5)-g+b,g=g&g}return g}var T=100,G=0,B=new Map;function Y(u,g,f=!0,b=!1){let x=z(u),F=`${g}:${f?1:0}:${b?1:0}`,p=B.get(F);if(p&&p.contentHash===x)return p.lastAccess=++G,p.declarations;let j=J(u,g,f,b);if(B.set(F,{declarations:j,contentHash:x,lastAccess:++G}),B.size>T){let w=null,q=1/0;for(let[Q,v]of B)if(v.lastAccess<q)q=v.lastAccess,w=Q;if(w)B.delete(w)}return j}function $(){B.clear()}
3
+ export{z as kc,Y as lc,$ as mc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{A as b,B as c,C as d,D as e,E as f,F as g,G as h,H as i,z as a}from"./chunk-jm5ywn4e.js";import"./chunk-p1d09y82.js";import"./chunk-rw6j20e2.js";export{i as validateGeneratedDeclarations,c as validateDeclarations,h as typeCheckWithConfig,b as typeCheck,a as loadCompilerOptions,e as getTypeAtPosition,f as getQuickInfo,g as formatTypeCheckResults,d as checkIsolatedDeclarations};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{tb as K}from"./chunk-3mxzfgcv.js";function L(N={}){let{buildStart:P=!0,buildEnd:Q=!1,writeBundle:T=!1,modes:y,onGenerated:U,onError:H,...W}=N,I="production",z=async()=>{try{let q=await K(W);U?.(q)}catch(q){let J=q instanceof Error?q:Error(String(q));if(H?.(J),!H)console.error("[dtsx] Generation failed:",J.message)}},F=()=>{if(!y||y.length===0)return!0;return y.includes(I)};return{name:"dtsx",apply(q){return I=q.mode,!0},async buildStart(){if(P&&F())await z()},async buildEnd(){if(Q&&F())await z()},async writeBundle(){if(T&&F())await z()}}}var Y=L,_=L;
3
+ export{L as ca,Y as da,_ as ea};
@@ -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-dk2vv0np.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{nc as a}from"./chunk-rnt0wkrk.js";import"./chunk-rw6j20e2.js";export{a as scanDeclarations};
@@ -0,0 +1,102 @@
1
+ // @bun
2
+ import{ec as K}from"./chunk-9mjc7ddv.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{s as a,t as b,u as c,v as d,w as e,x as f,y as g}from"./chunk-fbqcsr60.js";import"./chunk-9mjc7ddv.js";import"./chunk-p1d09y82.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-j22v8wfe.js";import"./chunk-dk2vv0np.js";import"./chunk-rw6j20e2.js";export{f as startLSPServer,g as createFileWatcher,b as SymbolKind,a as LspDiagnosticSeverity,e as DtsxLanguageServer,d as DocumentHighlightKind,c as CompletionItemKind};
@@ -0,0 +1,34 @@
1
+ // @bun
2
+ function W(B,g){let w=B.trim();if(w==="string")return{type:"string"};if(w==="number")return{type:"number"};if(w==="boolean")return{type:"boolean"};if(w==="null")return{type:"null"};if(w==="undefined")return{type:"null"};if(w==="any"||w==="unknown")return{};if(w==="never")return{not:{}};if(w==="void")return{type:"null"};if(w==="bigint")return{type:"integer"};if(w==="symbol")return{type:"string",description:"Symbol type"};if(w==="object")return{type:"object"};if(w.startsWith("'")||w.startsWith('"'))return{const:w.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(w))return{const:Number.parseFloat(w)};if(w==="true")return{const:!0};if(w==="false")return{const:!1};let j=w.match(/^(.+)\[\]$/)||w.match(/^Array<(.+)>$/i);if(j)return{type:"array",items:W(j[1],g)};let E=w.match(/^\[(.+)\]$/);if(E){let Q=X(E[1],",").map((G)=>W(G.trim(),g));return{type:"array",items:Q,minItems:Q.length,maxItems:Q.length}}if(w.includes("|")){let Q=X(w,"|");if(Q.length>1){let G=Q.filter((K)=>K.trim()!=="null"&&K.trim()!=="undefined");if(Q.some((K)=>K.trim()==="null"||K.trim()==="undefined")&&G.length===1){let K=W(G[0],g);if(K.type&&typeof K.type==="string")return{...K,type:[K.type,"null"]};return{oneOf:[K,{type:"null"}]}}return{oneOf:Q.map((K)=>W(K.trim(),g))}}}if(w.includes("&")){let Q=X(w,"&");if(Q.length>1)return{allOf:Q.map((G)=>W(G.trim(),g))}}let H=w.match(/^Record<(.+),\s*(.+)>$/i);if(H)return{type:"object",additionalProperties:W(H[2],g)};let F=w.match(/^Promise<(.+)>$/i);if(F)return W(F[1],g);let L=w.match(/^Partial<(.+)>$/i);if(L)return{...W(L[1],g),required:[]};let _=w.match(/^Required<(.+)>$/i);if(_)return W(_[1],g);let P=w.match(/^Readonly<(.+)>$/i);if(P)return W(P[1],g);let $=w.match(/^Pick<(.+),\s*(.+)>$/i);if($)return W($[1],g);let D=w.match(/^Omit<(.+),\s*(.+)>$/i);if(D)return W(D[1],g);if(w==="Date")return{type:"string",format:"date-time"};if(/^[A-Z]\w*$/.test(w))return{$ref:`#/$defs/${w}`};return{type:"object"}}function Y(B,g={}){let w=g.indent??2,j=g.jsonSchemaDraft??"2020-12",E={"2020-12":"https://json-schema.org/draft/2020-12/schema","2019-09":"https://json-schema.org/draft/2019-09/schema","draft-07":"http://json-schema.org/draft-07/schema#"}[j],H=new Map,F={$schema:g.includeSchema!==!1?E:void 0,$defs:{}};for(let L of B)if(L.kind==="interface"||L.kind==="type"){let _=q(L,H,g);if(F.$defs)F.$defs[L.name]=_}if(F.$defs&&Object.keys(F.$defs).length===1){let[L,_]=Object.entries(F.$defs)[0];return JSON.stringify({$schema:F.$schema,title:L,..._},null,w)}return JSON.stringify(F,null,w)}function q(B,g,w){let j={type:"object"};if(w.includeDescriptions&&B.leadingComments?.length){let E=C(B.leadingComments);if(E)j.description=E}if(B.members&&B.members.length>0){j.properties={},j.required=[];for(let E of B.members)if(E.name&&E.typeAnnotation){let H=W(E.typeAnnotation,g);if(w.includeDescriptions&&E.leadingComments?.length){let L=C(E.leadingComments);if(L)H.description=L}if(j.properties[E.name]=H,!(E.modifiers?.includes("?")||E.text?.includes("?:")||w.allOptional))j.required.push(E.name)}if(j.required.length===0)delete j.required}else if(B.typeAnnotation)return W(B.typeAnnotation,g);return j}function k(B,g={}){let w=["import { z } from 'zod'",""];for(let j of B)if(j.kind==="interface"||j.kind==="type"){let E=g.exportName||`${j.name}Schema`,H=I(j,g);if(w.push(`export const ${E} = ${H}`),w.push(""),g.useInfer!==!1)w.push(`export type ${j.name} = z.infer<typeof ${E}>`),w.push("")}return w.join(`
3
+ `)}function I(B,g){if(B.members&&B.members.length>0)return`z.object({
4
+ ${B.members.filter((j)=>j.name&&j.typeAnnotation).map((j)=>{let E=R(j.typeAnnotation);if(j.modifiers?.includes("?")||j.text?.includes("?:")||g.allOptional)E=`${E}.optional()`;if(g.includeDescriptions&&j.leadingComments?.length){let F=C(j.leadingComments);if(F)E=`${E}.describe(${JSON.stringify(F)})`}return` ${j.name}: ${E}`}).join(`,
5
+ `)}
6
+ })`;if(B.typeAnnotation)return R(B.typeAnnotation);return"z.unknown()"}function R(B){let g=B.trim();if(g==="string")return"z.string()";if(g==="number")return"z.number()";if(g==="boolean")return"z.boolean()";if(g==="null")return"z.null()";if(g==="undefined")return"z.undefined()";if(g==="any")return"z.any()";if(g==="unknown")return"z.unknown()";if(g==="never")return"z.never()";if(g==="void")return"z.void()";if(g==="bigint")return"z.bigint()";if(g==="symbol")return"z.symbol()";if(g==="Date")return"z.date()";if(g.startsWith("'")||g.startsWith('"'))return`z.literal(${g})`;if(/^-?\d+(\.\d+)?$/.test(g))return`z.literal(${g})`;if(g==="true"||g==="false")return`z.literal(${g})`;let w=g.match(/^(.+)\[\]$/)||g.match(/^Array<(.+)>$/i);if(w)return`z.array(${R(w[1])})`;let j=g.match(/^\[(.+)\]$/);if(j)return`z.tuple([${X(j[1],",").map((D)=>R(D.trim())).join(", ")}])`;if(g.includes("|")){let $=X(g,"|");if($.length>1){let D=$.filter((K)=>K.trim()!=="null"&&K.trim()!=="undefined"),Q=$.some((K)=>K.trim()==="null"),G=$.some((K)=>K.trim()==="undefined");if((Q||G)&&D.length===1){let K=R(D[0]);if(Q)K=`${K}.nullable()`;if(G)K=`${K}.optional()`;return K}return`z.union([${$.map((K)=>R(K.trim())).join(", ")}])`}}if(g.includes("&")){let $=X(g,"&");if($.length>1)return $.map((Q)=>R(Q.trim())).reduce((Q,G)=>`${Q}.and(${G})`)}let E=g.match(/^Record<(.+),\s*(.+)>$/i);if(E)return`z.record(${R(E[1])}, ${R(E[2])})`;let H=g.match(/^Promise<(.+)>$/i);if(H)return`z.promise(${R(H[1])})`;let F=g.match(/^Map<(.+),\s*(.+)>$/i);if(F)return`z.map(${R(F[1])}, ${R(F[2])})`;let L=g.match(/^Set<(.+)>$/i);if(L)return`z.set(${R(L[1])})`;let _=g.match(/^Partial<(.+)>$/i);if(_)return`${R(_[1])}.partial()`;let P=g.match(/^Required<(.+)>$/i);if(P)return`${R(P[1])}.required()`;if(/^[A-Z]\w*$/.test(g))return`${g}Schema`;return"z.unknown()"}function V(B,g={}){let w=["import * as v from 'valibot'",""];for(let j of B)if(j.kind==="interface"||j.kind==="type"){let E=g.exportName||`${j.name}Schema`,H=J(j,g);if(w.push(`export const ${E} = ${H}`),w.push(""),g.useInfer!==!1)w.push(`export type ${j.name} = v.InferOutput<typeof ${E}>`),w.push("")}return w.join(`
7
+ `)}function J(B,g){if(B.members&&B.members.length>0)return`v.object({
8
+ ${B.members.filter((j)=>j.name&&j.typeAnnotation).map((j)=>{let E=O(j.typeAnnotation);if(j.modifiers?.includes("?")||j.text?.includes("?:")||g.allOptional)E=`v.optional(${E})`;return` ${j.name}: ${E}`}).join(`,
9
+ `)}
10
+ })`;if(B.typeAnnotation)return O(B.typeAnnotation);return"v.unknown()"}function O(B){let g=B.trim();if(g==="string")return"v.string()";if(g==="number")return"v.number()";if(g==="boolean")return"v.boolean()";if(g==="null")return"v.null_()";if(g==="undefined")return"v.undefined_()";if(g==="any")return"v.any()";if(g==="unknown")return"v.unknown()";if(g==="never")return"v.never()";if(g==="void")return"v.void_()";if(g==="bigint")return"v.bigint()";if(g==="symbol")return"v.symbol()";if(g==="Date")return"v.date()";if(g.startsWith("'")||g.startsWith('"'))return`v.literal(${g})`;if(/^-?\d+(\.\d+)?$/.test(g))return`v.literal(${g})`;if(g==="true"||g==="false")return`v.literal(${g})`;let w=g.match(/^(.+)\[\]$/)||g.match(/^Array<(.+)>$/i);if(w)return`v.array(${O(w[1])})`;let j=g.match(/^\[(.+)\]$/);if(j)return`v.tuple([${X(j[1],",").map((F)=>O(F.trim())).join(", ")}])`;if(g.includes("|")){let H=X(g,"|");if(H.length>1){let F=H.filter((P)=>P.trim()!=="null"&&P.trim()!=="undefined"),L=H.some((P)=>P.trim()==="null"),_=H.some((P)=>P.trim()==="undefined");if((L||_)&&F.length===1){let P=O(F[0]);if(L)P=`v.nullable(${P})`;if(_)P=`v.optional(${P})`;return P}return`v.union([${H.map((P)=>O(P.trim())).join(", ")}])`}}if(g.includes("&")){let H=X(g,"&");if(H.length>1)return`v.intersect([${H.map((F)=>O(F.trim())).join(", ")}])`}let E=g.match(/^Record<(.+),\s*(.+)>$/i);if(E)return`v.record(${O(E[1])}, ${O(E[2])})`;if(/^[A-Z]\w*$/.test(g))return`${g}Schema`;return"v.unknown()"}function Z(B,g={}){let w=["import * as t from 'io-ts'",""];for(let j of B)if(j.kind==="interface"||j.kind==="type"){let E=g.exportName||`${j.name}Codec`,H=U(j,g);if(w.push(`export const ${E} = ${H}`),w.push(""),g.useInfer!==!1)w.push(`export type ${j.name} = t.TypeOf<typeof ${E}>`),w.push("")}return w.join(`
11
+ `)}function U(B,g){if(B.members&&B.members.length>0){let w=[],j=[];for(let E of B.members){if(!E.name||!E.typeAnnotation)continue;let H=v(E.typeAnnotation),F=E.modifiers?.includes("?")||E.text?.includes("?:")||g.allOptional,L=` ${E.name}: ${H}`;if(F)j.push(L);else w.push(L)}if(j.length>0)return`t.intersection([
12
+ t.type({
13
+ ${w.join(`,
14
+ `)}
15
+ }),
16
+ t.partial({
17
+ ${j.join(`,
18
+ `)}
19
+ })
20
+ ])`;return`t.type({
21
+ ${w.join(`,
22
+ `)}
23
+ })`}if(B.typeAnnotation)return v(B.typeAnnotation);return"t.unknown"}function v(B){let g=B.trim();if(g==="string")return"t.string";if(g==="number")return"t.number";if(g==="boolean")return"t.boolean";if(g==="null")return"t.null";if(g==="undefined")return"t.undefined";if(g==="any")return"t.unknown";if(g==="unknown")return"t.unknown";if(g==="never")return"t.never";if(g==="void")return"t.void";if(g.startsWith("'")||g.startsWith('"'))return`t.literal(${g})`;if(/^-?\d+(\.\d+)?$/.test(g))return`t.literal(${g})`;if(g==="true"||g==="false")return`t.literal(${g})`;let w=g.match(/^(.+)\[\]$/)||g.match(/^Array<(.+)>$/i);if(w)return`t.array(${v(w[1])})`;let j=g.match(/^\[(.+)\]$/);if(j)return`t.tuple([${X(j[1],",").map((F)=>v(F.trim())).join(", ")}])`;if(g.includes("|")){let H=X(g,"|");if(H.length>1)return`t.union([${H.map((F)=>v(F.trim())).join(", ")}])`}if(g.includes("&")){let H=X(g,"&");if(H.length>1)return`t.intersection([${H.map((F)=>v(F.trim())).join(", ")}])`}let E=g.match(/^Record<(.+),\s*(.+)>$/i);if(E)return`t.record(${v(E[1])}, ${v(E[2])})`;if(/^[A-Z]\w*$/.test(g))return`${g}Codec`;return"t.unknown"}function N(B,g={}){let w=["import * as yup from 'yup'",""];for(let j of B)if(j.kind==="interface"||j.kind==="type"){let E=g.exportName||`${j.name}Schema`,H=S(j,g);if(w.push(`export const ${E} = ${H}`),w.push(""),g.useInfer!==!1)w.push(`export type ${j.name} = yup.InferType<typeof ${E}>`),w.push("")}return w.join(`
24
+ `)}function S(B,g){if(B.members&&B.members.length>0)return`yup.object({
25
+ ${B.members.filter((j)=>j.name&&j.typeAnnotation).map((j)=>{let E=x(j.typeAnnotation);if(!(j.modifiers?.includes("?")||j.text?.includes("?:")||g.allOptional))E=`${E}.required()`;return` ${j.name}: ${E}`}).join(`,
26
+ `)}
27
+ })`;if(B.typeAnnotation)return x(B.typeAnnotation);return"yup.mixed()"}function x(B){let g=B.trim();if(g==="string")return"yup.string()";if(g==="number")return"yup.number()";if(g==="boolean")return"yup.boolean()";if(g==="Date")return"yup.date()";if(g==="any"||g==="unknown")return"yup.mixed()";let w=g.match(/^(.+)\[\]$/)||g.match(/^Array<(.+)>$/i);if(w)return`yup.array().of(${x(w[1])})`;if(g.includes("|")){let j=X(g,"|");if(j.length>1){let E=j.filter((F)=>F.trim()!=="null"&&F.trim()!=="undefined");if(j.some((F)=>F.trim()==="null"||F.trim()==="undefined")&&E.length===1)return`${x(E[0])}.nullable()`}}if(/^[A-Z]\w*$/.test(g))return`${g}Schema`;return"yup.mixed()"}function f(B,g={}){let w=["import { type } from 'arktype'",""];for(let j of B)if(j.kind==="interface"||j.kind==="type"){let E=g.exportName||j.name,H=u(j,g);if(w.push(`export const ${E} = ${H}`),w.push(""),g.useInfer!==!1)w.push(`export type ${j.name}Type = typeof ${E}.infer`),w.push("")}return w.join(`
28
+ `)}function u(B,g){if(B.members&&B.members.length>0)return`type({
29
+ ${B.members.filter((j)=>j.name&&j.typeAnnotation).map((j)=>{let E=A(j.typeAnnotation);return` ${j.modifiers?.includes("?")||j.text?.includes("?:")||g.allOptional?`'${j.name}?'`:`${j.name}`}: ${E}`}).join(`,
30
+ `)}
31
+ })`;if(B.typeAnnotation)return`type(${A(B.typeAnnotation)})`;return"type('unknown')"}function A(B){let g=B.trim();if(g==="string")return"'string'";if(g==="number")return"'number'";if(g==="boolean")return"'boolean'";if(g==="null")return"'null'";if(g==="undefined")return"'undefined'";if(g==="bigint")return"'bigint'";if(g==="symbol")return"'symbol'";if(g==="Date")return"'Date'";if(g==="any"||g==="unknown")return"'unknown'";let w=g.match(/^(.+)\[\]$/)||g.match(/^Array<(.+)>$/i);if(w)return`${A(w[1])}.array()`;if(g.includes("|")){let j=X(g,"|");if(j.length>1)return`'${j.map((E)=>E.trim()).join(" | ")}'`}if(g.startsWith("'")||g.startsWith('"'))return`'${g}'`;return`'${g}'`}function X(B,g){let w=[],j="",E=0;for(let H=0;H<B.length;H++){let F=B[H];if(F==="<"||F==="("||F==="["||F==="{")E++,j+=F;else if(F===">"||F===")"||F==="]"||F==="}")E--,j+=F;else if(E===0&&B.slice(H,H+g.length)===g)w.push(j.trim()),j="",H+=g.length-1;else j+=F}if(j.trim())w.push(j.trim());return w}function C(B){for(let g of B){let w=g.replace(/^\/\*\*|\*\/$/g,"").replace(/^\s*\*\s?/gm,"").replace(/@\w.*/g,"").trim();if(w)return w}return null}function M(B,g){switch(g.format){case"json-schema":return Y(B,g);case"zod":return k(B,g);case"valibot":return V(B,g);case"io-ts":return Z(B,g);case"yup":return N(B,g);case"arktype":return f(B,g);case"dts":default:return B.map((w)=>w.text).join(`
32
+
33
+ `)}}function b(B){switch(B){case"json-schema":return".schema.json";case"zod":case"valibot":case"io-ts":case"yup":case"arktype":return".schema.ts";case"dts":default:return".d.ts"}}
34
+ export{Y as I,k as J,V as K,Z as L,N as M,f as N,M as O,b as P};
@@ -0,0 +1,15 @@
1
+ // @bun
2
+ var k=!1,M=null;function a(){k=!0,M=null}function r(){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 o(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 d(z,Y,G+1);if(z.startsWith("new "))return m(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 l(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&&o(z)){if(Y)return z;return"bigint"}if(z.startsWith("Symbol(")||z==="Symbol.for")return"symbol";return"unknown"}function p(J,Y=!1,X=0){return V(J,Y,!0,X)}function l(J,Y){if(J.includes(".raw`")||J.includes("String.raw`"))return"string";if(!Y)return"string";if(!J.includes("${"))return J;return"string"}function m(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("<"),K=O.lastIndexOf(">");return Q!==-1&&K>Q?O.slice(Q+1,K):"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 K=z[Q],F=K.length;while(F>0&&K.charCodeAt(F-1)<=32)F--;if(F>=8&&K.slice(F-8,F)==="as const"){B=!0;break}}if(B)return`readonly [
3
+ ${z.map((K)=>{let F=K.trim();if(F.endsWith("as const")){let L=F.slice(0,-8).trim();if(L.startsWith("[")&&L.endsWith("]")){let W=L.slice(1,-1).trim();return`readonly [${U(W).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 K=Q.trim(),F=M;if(M=null,K.startsWith("[")&&K.endsWith("]"))H.push(D(K,Y,X+1));else H.push(p(K,Y,X+1));if(Z)$.push(M);M=F}if(Z)if(_(J))M=P(J);else{let Q=[];for(let K=0;K<z.length;K++){let F=z[K].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($[K])Q.push($[K])}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 K=!1;for(let F of j)if(Q===F){K=!0;break}if(!K)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 c(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 d(J,Y,X=0){let G=J.slice(1,-1).trim();if(!G)return"{}";if(X>=20)return"Record<string, unknown>";let z=i(G),B=[],Z=k&&!Y,H=[];for(let[$,j]of z){let O=M;M=null;let Q=V(j,Y,!1,X+1),K=M;if(M=O,Q.includes("=>")||Q.includes("function")||Q.includes("async"))Q=I(Q);let F=j.trim();if(!Y&&c(Q)&&w(F))B.push(`/** @defaultValue ${F} */
6
+ ${$}: ${Q}`);else B.push(`${$}: ${Q}`);if(Z){if(F.endsWith("as const"));else if(w(F))H.push(`${$}: ${F}`);else if(F.startsWith("[")&&_(F))H.push(`${$}: ${P(F)}`);else if(F.startsWith("{")){if(K)H.push(`${$}: ${K}`)}else if(!F.startsWith("[")&&(F.includes("=>")||F.startsWith("function")||F.startsWith("async"))){let L=h(F,!1,0,!0);H.push(`${$}: ${L}`)}}}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),K=b(Q);X=X.slice(0,z)+K+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),W=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(!W&&!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 W=0;W<z.length;W++){let q=z.charCodeAt(W);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=W>0?z.charCodeAt(W-1):0,A=W+1<z.length?z.charCodeAt(W+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 W=z.charCodeAt(L);if(O){if(W===92){L++;continue}if(W===Q)O=!1;continue}if(W===39||W===34||W===96){O=!0,Q=W;continue}if(W===40||W===60||W===91||W===123)j++;else if(W===41||W===62||W===93||W===125)j--;else if(W===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 K=[];for(let L of Z){let W=L.trim();if(!W){K.push(L);continue}let q=L.slice(0,L.length-L.trimStart().length);K.push(q+s(W))}let F=K[0]||"";for(let L=1;L<K.length;L++)F+=(H[L-1]||", ")+K[L];return G?`(${F})`:F}function s(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 i(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],K=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&&K!=="\\")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,K=-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){K=F;break}}if(K!==-1)z=X.slice(0,K+1),X=X.slice(K+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 n(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 W=g(z,0,"<",">");if(W!==-1)Z=z.substring(0,W+1),H=z.substring(W+1).trim()}let $=n(H);if($===-1)return Y?"(() => unknown)":"() => unknown";let j=H.substring(0,$).trim(),O=H.substring($+2).trim(),Q="",K=j.lastIndexOf("):");if(K!==-1){let W=j.substring(K+2).trim();if(W&&!W.includes("=>")&&!W.includes("="))Q=W,j=j.substring(0,K+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 W=O.trimStart(),q=W.indexOf("("),N=q!==-1?W.indexOf(")",q):-1,A=N!==-1?W.indexOf("=>",N):-1;if(q===0&&N!==-1&&A!==-1){let R=W.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 K=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(K,Z);while(Z<H&&z.charCodeAt(Z)<=32)Z++}let O=z.indexOf("(",Z);if(O!==-1){let K=1,F=O+1;while(F<H&&K>0){let N=z.charCodeAt(F);if(N===40)K++;else if(N===41)K--;F++}let L=z.substring(O+1,F-1).trim(),W=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}${W} => Generator<${u}>`;return Y?`(${C})`:C}}let R=`${j}${W} => Generator<any, any, any>`;return Y?`(${R})`:R}let q=`${j}${W} => 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 t(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 e(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 Jz(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{a as Cc,r as Dc,V as Ec,p as Fc,D as Gc,U as Hc,d as Ic,g as Jc,h as Kc,t as Lc,e as Mc,Jz as Nc};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{tb as I}from"./chunk-3mxzfgcv.js";class H{options;generateOptions;constructor(j={}){let{onCompile:F=!1,afterEmit:w=!0,onWatchRun:q=!1,onGenerated:z,onError:B,...J}=j;this.options={onCompile:F,afterEmit:w,onWatchRun:q,onGenerated:z,onError:B},this.generateOptions=J}apply(j){if(!this.generateOptions.outdir&&j.options.output?.path)this.generateOptions.outdir=j.options.output.path;if(!this.generateOptions.cwd&&j.options.context)this.generateOptions.cwd=j.options.context;if(!this.generateOptions.entrypoints&&j.options.entry){let w=j.options.entry;if(typeof w==="string")this.generateOptions.entrypoints=[w];else if(Array.isArray(w))this.generateOptions.entrypoints=w;else if(typeof w==="object"&&w!==null){let q=[];for(let z of Object.values(w))if(typeof z==="string")q.push(z);else if(Array.isArray(z))q.push(...z.filter((B)=>typeof B==="string"));else if(typeof z==="object"&&z!==null&&"import"in z){let B=z.import;if(typeof B==="string")q.push(B);else if(Array.isArray(B))q.push(...B)}if(q.length>0)this.generateOptions.entrypoints=q}}if(this.options.onCompile)j.hooks.compile.tap("DtsxWebpackPlugin",()=>{this.runGenerate()});if(this.options.afterEmit)j.hooks.afterEmit.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()});if(this.options.onWatchRun)j.hooks.watchRun.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()})}async runGenerate(){try{let j=await I(this.generateOptions);this.options.onGenerated?.(j)}catch(j){let F=j instanceof Error?j:Error(String(j));if(this.options.onError?.(F),!this.options.onError)console.error("[dtsx] Generation failed:",F.message)}}}function K(j={}){return new H(j)}var M=K,Q=H;
3
+ export{H as qa,K as ra,M as sa,Q as ta};