@stacksjs/dtsx 0.9.10 → 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.
- package/dist/bin/cli.js +5 -5
- package/dist/branded-types.d.ts +0 -18
- package/dist/{chunk-09zp67d8.js → chunk-1bav913n.js} +1 -1
- package/dist/{chunk-6ppqaypd.js → chunk-2wbhe1k8.js} +1 -1
- package/dist/{chunk-q75q4w1s.js → chunk-3d18fhrg.js} +1 -1
- package/dist/{chunk-e3j9tecw.js → chunk-4qpg9xnt.js} +1 -1
- package/dist/{chunk-c18vx9sq.js → chunk-5vqtjws2.js} +1 -1
- package/dist/chunk-6mwq397e.js +2 -0
- package/dist/{chunk-3mxzfgcv.js → chunk-9a6yn7sv.js} +1 -1
- package/dist/{chunk-j22v8wfe.js → chunk-begk3j01.js} +1 -1
- package/dist/{chunk-9a3jfxnc.js → chunk-cmenkst5.js} +1 -1
- package/dist/{chunk-k5h5ppp5.js → chunk-fb4c98h2.js} +1 -1
- package/dist/{chunk-fw6wcdfd.js → chunk-ggmn4a8c.js} +1 -1
- package/dist/{chunk-1mm3t0nr.js → chunk-hrmnrn4p.js} +1 -1
- package/dist/chunk-j0y71ank.js +2 -0
- package/dist/{chunk-2f046tgr.js → chunk-j6aqdbc4.js} +1 -1
- package/dist/{chunk-jvz9t6pq.js → chunk-knkfbqze.js} +1 -1
- package/dist/{chunk-ffqpf34b.js → chunk-n28rjf9h.js} +1 -1
- package/dist/{chunk-fbqcsr60.js → chunk-w9abhtgg.js} +1 -1
- package/dist/{chunk-9mjc7ddv.js → chunk-wfevdmvd.js} +1 -1
- package/dist/{chunk-h12gdfk9.js → chunk-ws2dmfvj.js} +1 -1
- package/dist/chunk-xnq1xw73.js +15 -0
- package/dist/{chunk-bn29kee5.js → chunk-xyctgc6x.js} +1 -1
- package/dist/{chunk-rrkq4k1n.js → chunk-y3q50bn2.js} +1 -1
- package/dist/{chunk-4ev1n7r7.js → chunk-ywd4k4hn.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/dist/type-mappings.d.ts +0 -24
- package/package.json +1 -1
- package/dist/chunk-0kmfaaz6.js +0 -2
- package/dist/chunk-dk2vv0np.js +0 -15
- package/dist/chunk-pyxbb193.js +0 -2
package/dist/bin/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{cd as Y}from"../chunk-rw6j20e2.js";import V from"process";var f=V.argv[2];if(f==="stdin"||f==="emit"||f==="--project"){if(f==="stdin"){let{processSource:q}=await import("../chunk-
|
|
3
|
-
`)}else if(f==="--project"){let{readdirSync:q,readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv.slice(3),z="",B="",G=!1;for(let X=0;X<$.length;X++)if($[X]==="--outdir"&&$[X+1])B=$[X+1],X++;else if($[X]==="--isolated-declarations")G=!0;else if(!z)z=$[X];N(B,{recursive:!0});let j=q(z).filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")),Z=j.length,E=Array(Z),M=Array(Z);for(let X=0;X<Z;X++)E[X]=`${z}/${j[X]}`,M[X]=`${B}/${j[X].slice(0,-3)}.d.ts`;let T=["bun"],R=A&&Z>=64,I=!1,_=null;if(R){let X=null;try{let{createWorkerPool:F,calculateOptimalBatchSize:D}=await import("../chunk-r1m3q3dj.js"),{cpus:C}=await import("os"),w=Math.max(1,C().length-1),U=Math.min(64,Math.max(8,D(Z,w)*2)),L=Z>=256,a=!0,l=Z>=256;if(!L&&Z>=256){_=Array(Z);for(let x=0;x<Z;x++)_[x]=J.file(E[x]).text()}let O=Math.ceil(Z/U),u=Math.min(O,Math.max(2,w*2));X=F({maxWorkers:w,initialWorkers:w,recycleAfter:Math.max(100,O+1)}),await X.init();let d=X,i=0,r=Date.now(),t=async()=>{for(;;){let x=i++;if(x>=O)return;let S=x*U;if(S>=Z)return;let g=Math.min(Z,S+U)-S,m;if(l){let P=Array(g),y=Array(g),b;if(L)for(let W=0;W<g;W++){let v=S+W;P[W]=E[v],y[W]=M[v]}else{let W=Array(g);for(let v=0;v<g;v++){let c=S+v;P[v]=E[c],y[v]=M[c],W[v]=_?_[c]:J.file(E[c]).text()}b=await Promise.all(W)}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:P[0]||"",filePaths:P,sources:b,outPaths:y,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}else{let P=Array(g);if(L)for(let y=0;y<g;y++){let b=S+y;P[y]={filePath:E[b],outPath:M[b]}}else{let y=Array(g);for(let W=0;W<g;W++){let v=S+W;y[W]=_?_[v]:J.file(E[v]).text()}let b=await Promise.all(y);for(let W=0;W<g;W++){let v=S+W;P[W]={filePath:E[v],sourceCode:b[W],outPath:M[v]}}}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:E[S]||"",files:P,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}if(!m.success)throw Error(m.error||`Worker batch failed for ${E[S]}`);if(m.batchResults?.length){let P=m.batchResults[0];throw Error(P?.error||m.error||`Worker failed for ${E[S]}`)}}},n=[];for(let x=0;x<u;x++)n.push(t());await Promise.all(n),I=!0}catch{I=!1}finally{if(X)await X.shutdown()}}if(!I){let{scanDeclarations:X}=await import("../chunk-axb2kjeq.js"),{processDeclarations:F}=await import("../chunk-
|
|
2
|
+
import{cd as Y}from"../chunk-rw6j20e2.js";import V from"process";var f=V.argv[2];if(f==="stdin"||f==="emit"||f==="--project"){if(f==="stdin"){let{processSource:q}=await import("../chunk-j0y71ank.js"),Q=[];for await(let N of V.stdin)Q.push(N);let K=Buffer.concat(Q).toString("utf-8");if(K.trim())V.stdout.write(q(K,"stdin.ts")),V.stdout.write(`
|
|
3
|
+
`)}else if(f==="--project"){let{readdirSync:q,readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv.slice(3),z="",B="",G=!1;for(let X=0;X<$.length;X++)if($[X]==="--outdir"&&$[X+1])B=$[X+1],X++;else if($[X]==="--isolated-declarations")G=!0;else if(!z)z=$[X];N(B,{recursive:!0});let j=q(z).filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")),Z=j.length,E=Array(Z),M=Array(Z);for(let X=0;X<Z;X++)E[X]=`${z}/${j[X]}`,M[X]=`${B}/${j[X].slice(0,-3)}.d.ts`;let T=["bun"],R=A&&Z>=64,I=!1,_=null;if(R){let X=null;try{let{createWorkerPool:F,calculateOptimalBatchSize:D}=await import("../chunk-r1m3q3dj.js"),{cpus:C}=await import("os"),w=Math.max(1,C().length-1),U=Math.min(64,Math.max(8,D(Z,w)*2)),L=Z>=256,a=!0,l=Z>=256;if(!L&&Z>=256){_=Array(Z);for(let x=0;x<Z;x++)_[x]=J.file(E[x]).text()}let O=Math.ceil(Z/U),u=Math.min(O,Math.max(2,w*2));X=F({maxWorkers:w,initialWorkers:w,recycleAfter:Math.max(100,O+1)}),await X.init();let d=X,i=0,r=Date.now(),t=async()=>{for(;;){let x=i++;if(x>=O)return;let S=x*U;if(S>=Z)return;let g=Math.min(Z,S+U)-S,m;if(l){let P=Array(g),y=Array(g),b;if(L)for(let W=0;W<g;W++){let v=S+W;P[W]=E[v],y[W]=M[v]}else{let W=Array(g);for(let v=0;v<g;v++){let c=S+v;P[v]=E[c],y[v]=M[c],W[v]=_?_[c]:J.file(E[c]).text()}b=await Promise.all(W)}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:P[0]||"",filePaths:P,sources:b,outPaths:y,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}else{let P=Array(g);if(L)for(let y=0;y<g;y++){let b=S+y;P[y]={filePath:E[b],outPath:M[b]}}else{let y=Array(g);for(let W=0;W<g;W++){let v=S+W;y[W]=_?_[v]:J.file(E[v]).text()}let b=await Promise.all(y);for(let W=0;W<g;W++){let v=S+W;P[W]={filePath:E[v],sourceCode:b[W],outPath:M[v]}}}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:E[S]||"",files:P,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}if(!m.success)throw Error(m.error||`Worker batch failed for ${E[S]}`);if(m.batchResults?.length){let P=m.batchResults[0];throw Error(P?.error||m.error||`Worker failed for ${E[S]}`)}}},n=[];for(let x=0;x<u;x++)n.push(t());await Promise.all(n),I=!0}catch{I=!1}finally{if(X)await X.shutdown()}}if(!I){let{scanDeclarations:X}=await import("../chunk-axb2kjeq.js"),{processDeclarations:F}=await import("../chunk-2wbhe1k8.js"),D=Array(Z);if(A){let U=_?await Promise.all(_):await Promise.all(E.map((L)=>J.file(L).text()));for(let L=0;L<Z;L++)D[L]=U[L]}else for(let U=0;U<Z;U++)D[U]=Q(E[U],"utf-8");let C=Array(Z),w={filePath:"",sourceCode:"",declarations:[]};for(let U=0;U<Z;U++){let L=X(D[U],j[U],!0,G);w.filePath=j[U],w.sourceCode=D[U],w.declarations=L,C[U]=F(L,w,!0,T)}if(A){let U=Array(Z);for(let L=0;L<Z;L++)U[L]=J.write(M[L],C[L]);await Promise.all(U)}else for(let U=0;U<Z;U++)K(M[U],C[U])}}else{let{processSource:q}=await import("../chunk-j0y71ank.js"),{readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv[3],z=A?await J.file($).text():Q($,"utf-8"),B=V.argv[4];if(B){let{dirname:G}=await import("path");N(G(B),{recursive:!0});let j=`${q(z,$)}
|
|
4
4
|
`;if(A)await J.write(B,j);else K(B,j)}else V.stdout.write(q(z,$)),V.stdout.write(`
|
|
5
|
-
`)}V.exit(0)}var{resolve:h}=await import("path"),{CLI:s}=await import("../chunk-v96rjx7x.js"),{version:e}=await import("../chunk-
|
|
6
|
-
Total: ${R}B -> ${R-T}B (-${I}%)`)}catch(Q){console.error("Error optimizing files:",Q),V.exit(1)}});k.command("docs","Generate API documentation from source files").option("--root <path>","Root directory to scan for source files",{default:"./src"}).option("--outdir <path>","Output directory for documentation",{default:"./docs"}).option("--format <format>","Output format: markdown or html",{default:"markdown"}).option("--title <title>","Documentation title",{default:"API Documentation"}).option("--include-private","Include private members (prefixed with _)",{default:!1}).option("--include-internal","Include internal members (@internal)",{default:!1}).option("--group-by-category","Group entries by @category tag",{default:!1}).option("--source-url <url>","Base URL for source links").example("dtsx docs").example("dtsx docs --format html --outdir ./api-docs").example('dtsx docs --group-by-category --title "My API"').action(async(q)=>{try{let{generateDocs:Q}=await import("../chunk-
|
|
5
|
+
`)}V.exit(0)}var{resolve:h}=await import("path"),{CLI:s}=await import("../chunk-v96rjx7x.js"),{version:e}=await import("../chunk-ws2dmfvj.js"),{getConfig:o}=await import("../chunk-6s7n1gt0.js"),{generate:qq,processSource:Hq,watch:Kq}=await import("../chunk-6mwq397e.js"),k=new s("dtsx"),H={cwd:V.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!1,tsconfigPath:"tsconfig.json",verbose:!1,importOrder:["bun"],dryRun:!1,stats:!1,continueOnError:!1,logLevel:"info",exclude:[],outputFormat:"text",progress:!1,diff:!1,validate:!1,parallel:!1,concurrency:4};k.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--clean","Clean output directory before generation",{default:H.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:H.tsconfigPath}).option("--verbose","Enable verbose logging",{default:H.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:H.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:H.dryRun}).option("--stats","Show statistics after generation",{default:H.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:H.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:H.outputFormat}).option("--progress","Show progress during generation",{default:H.progress}).option("--diff","Show diff of changes compared to existing files",{default:H.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:H.validate}).option("--parallel","Process files in parallel",{default:H.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:H.concurrency}).option("--declaration-map","Generate declaration map files (.d.ts.map)",{default:!1}).option("--bundle","Bundle all declarations into a single output file",{default:!1}).option("--bundle-output <file>","Output filename when bundling (relative to outdir)",{default:"index.d.ts"}).option("--config <path>","Path to config file (dtsx.config.ts)",{default:""}).option("--incremental","Enable incremental builds (only regenerate changed files)",{default:!1}).option("--clear-cache","Clear the incremental build cache before generating",{default:!1}).option("--indent-style <style>","Indentation style: spaces or tabs",{default:"spaces"}).option("--indent-size <size>","Number of spaces for indentation",{default:2}).option("--prettier","Use Prettier for output formatting if available",{default:!1}).example("dtsx generate").example("dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types").example('dtsx generate --import-order "node:,bun,@myorg/"').example("dtsx generate --dry-run --stats").example('dtsx generate --exclude "**/*.test.ts,**/__tests__/**"').example("dtsx generate --stats --output-format json").example("dtsx generate --bundle --bundle-output types.d.ts").action(async(q)=>{try{let Q=h(q.cwd||H.cwd),K=await o(Q),N={entrypoints:q.entrypoints?q.entrypoints:K.entrypoints||H.entrypoints,cwd:Q,root:h(q.root||K.root||H.root),outdir:h(q.outdir||K.outdir||H.outdir),tsconfigPath:h(q.tsconfigPath||K.tsconfigPath||H.tsconfigPath),keepComments:q.keepComments??K.keepComments??H.keepComments,clean:q.clean??K.clean??H.clean,verbose:q.verbose??K.verbose??H.verbose,importOrder:q.importOrder||K.importOrder||H.importOrder,dryRun:q.dryRun??K.dryRun??H.dryRun,stats:q.stats??K.stats??H.stats,continueOnError:q.continueOnError??K.continueOnError??H.continueOnError,logLevel:q.logLevel??K.logLevel??H.logLevel,exclude:q.exclude?q.exclude.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean)):K.exclude||H.exclude,outputFormat:q.outputFormat??K.outputFormat??H.outputFormat,progress:q.progress??K.progress??H.progress,diff:q.diff??K.diff??H.diff,validate:q.validate??K.validate??H.validate,parallel:q.parallel??K.parallel??H.parallel,concurrency:Number(q.concurrency)||K.concurrency||H.concurrency,declarationMap:q.declarationMap??K.declarationMap??!1,bundle:q.bundle??K.bundle??!1,bundleOutput:q.bundleOutput??K.bundleOutput??"index.d.ts",incremental:q.incremental??K.incremental??!1,clearCache:q.clearCache??!1,indentStyle:q.indentStyle??K.indentStyle??"spaces",indentSize:Number(q.indentSize)||K.indentSize||2,prettier:q.prettier??K.prettier??!1,plugins:K.plugins},A=await qq(N);if(A.filesFailed>0&&A.filesGenerated===0)V.exit(1);else if(A.filesFailed>0)V.exit(2)}catch(Q){console.error("Error generating .d.ts files:",Q),V.exit(1)}});k.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(q)=>{try{let Q={entrypoints:q.entrypoints?q.entrypoints:H.entrypoints,cwd:h(q.cwd||H.cwd),root:h(q.root||H.root),outdir:h(q.outdir||H.outdir),keepComments:q.keepComments??H.keepComments,exclude:q.exclude?q.exclude.flatMap((K)=>K.split(",").map((N)=>N.trim()).filter(Boolean)):H.exclude,logLevel:q.logLevel??H.logLevel};await Kq(Q)}catch(Q){console.error("Error in watch mode:",Q),V.exit(1)}});k.command("stdin","Process TypeScript from stdin and output .d.ts to stdout").option("--keep-comments","Keep comments in generated .d.ts files",{default:!0}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:"bun",type:[String]}).example(`echo "export const foo: string = 'bar'" | dtsx stdin`).example("cat src/index.ts | dtsx stdin").action(async(q)=>{try{let Q=[];for await(let J of V.stdin)Q.push(J);let K=Buffer.concat(Q).toString("utf-8");if(!K.trim())console.error("Error: No input received from stdin"),V.exit(1);let N=["bun"];if(q.importOrder){if(Array.isArray(q.importOrder))N=q.importOrder.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean));else if(typeof q.importOrder==="string")N=q.importOrder.split(",").map((J)=>J.trim()).filter(Boolean)}let A=Hq(K,"stdin.ts",q.keepComments??!0,N);console.log(A)}catch(Q){console.error("Error processing stdin:",Q),V.exit(1)}});k.command("optimize","Optimize declaration files").option("--files <patterns>","Glob patterns for .d.ts files to optimize",{default:"**/*.d.ts",type:[String]}).option("--outdir <path>","Output directory (defaults to in-place)",{default:""}).option("--remove-unused-imports","Remove unused type imports",{default:!0}).option("--deduplicate","Remove duplicate declarations",{default:!0}).option("--merge-interfaces","Merge interface declarations with same name",{default:!0}).option("--inline-types","Inline simple type aliases",{default:!1}).option("--remove-empty","Remove empty interfaces",{default:!0}).option("--sort","Sort declarations alphabetically",{default:!1}).option("--sort-imports","Sort imports",{default:!0}).option("--minify","Minify output (remove whitespace)",{default:!1}).option("--remove-comments","Remove comments",{default:!1}).example('dtsx optimize --files "dist/**/*.d.ts"').example("dtsx optimize --minify --remove-comments").action(async(q)=>{try{let{optimizeFile:Q}=await import("../chunk-fb4c98h2.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N,join:A,relative:J,dirname:$,basename:z}=await import("path"),{mkdirSync:B,copyFileSync:G,existsSync:j}=await import("fs"),Z=V.cwd(),E=q.files||["**/*.d.ts"],M=[];for(let _ of E){let X=new K(_);for await(let F of X.scan({cwd:Z,absolute:!0,onlyFiles:!0}))if(F.endsWith(".d.ts")&&!F.includes("node_modules"))M.push(F)}if(M.length===0)console.error("No .d.ts files found"),V.exit(1);console.log(`Optimizing ${M.length} declaration files...`);let T=0,R=0;for(let _ of M){let X=_;if(q.outdir){let C=J(Z,_);X=A(N(q.outdir),C);let w=$(X);if(!j(w))B(w,{recursive:!0});G(_,X)}let F=await Q(X,{removeUnusedImports:q.removeUnusedImports??!0,deduplicateDeclarations:q.deduplicate??!0,mergeInterfaces:q.mergeInterfaces??!0,inlineSimpleTypes:q.inlineTypes??!1,removeEmptyInterfaces:q.removeEmpty??!0,sortDeclarations:q.sort??!1,sortImports:q.sortImports??!0,minify:q.minify??!1,removeComments:q.removeComments??!1});R+=F.originalSize,T+=F.savings;let D=J(Z,X);console.log(` ${D}: ${F.originalSize}B -> ${F.optimizedSize}B (-${F.savingsPercent}%)`)}let I=R>0?Math.round(T/R*100):0;console.log(`
|
|
6
|
+
Total: ${R}B -> ${R-T}B (-${I}%)`)}catch(Q){console.error("Error optimizing files:",Q),V.exit(1)}});k.command("docs","Generate API documentation from source files").option("--root <path>","Root directory to scan for source files",{default:"./src"}).option("--outdir <path>","Output directory for documentation",{default:"./docs"}).option("--format <format>","Output format: markdown or html",{default:"markdown"}).option("--title <title>","Documentation title",{default:"API Documentation"}).option("--include-private","Include private members (prefixed with _)",{default:!1}).option("--include-internal","Include internal members (@internal)",{default:!1}).option("--group-by-category","Group entries by @category tag",{default:!1}).option("--source-url <url>","Base URL for source links").example("dtsx docs").example("dtsx docs --format html --outdir ./api-docs").example('dtsx docs --group-by-category --title "My API"').action(async(q)=>{try{let{generateDocs:Q}=await import("../chunk-knkfbqze.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N}=await import("path"),A=N(q.root||"./src"),J=new K("**/*.ts"),$=[];for await(let z of J.scan({cwd:A,absolute:!0,onlyFiles:!0}))if(!z.endsWith(".d.ts")&&!z.includes("node_modules"))$.push(z);if($.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Found ${$.length} source files`),await Q($,{format:q.format||"markdown",outdir:N(q.outdir||"./docs"),title:q.title||"API Documentation",includePrivate:q.includePrivate??!1,includeInternal:q.includeInternal??!1,groupByCategory:q.groupByCategory??!1,includeSourceLinks:!!q.sourceUrl,sourceBaseUrl:q.sourceUrl})}catch(Q){console.error("Error generating documentation:",Q),V.exit(1)}});k.command("workspace","Generate declarations for all projects in a monorepo/workspace").option("--cwd <path>","Workspace root directory",{default:V.cwd()}).option("--parallel","Process projects in parallel",{default:!1}).option("--continue-on-error","Continue if a project fails",{default:!0}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:"info"}).example("dtsx workspace").example("dtsx workspace --cwd /path/to/monorepo").action(async(q)=>{try{let{generateMonorepo:Q,generateFromPackageWorkspaces:K}=await import("../chunk-y3q50bn2.js"),{existsSync:N}=await import("fs"),{join:A,resolve:J}=await import("path"),$=J(q.cwd||V.cwd()),z=A($,"tsconfig.json"),B;if(N(z))B=await Q($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});else B=await K($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});if(!B.success)V.exit(1)}catch(Q){console.error("Error generating workspace declarations:",Q),V.exit(1)}});k.command("lsp","Start the Language Server Protocol server for IDE integration").example("dtsx lsp").action(async()=>{let{startLSPServer:q}=await import("../chunk-5vqtjws2.js");q()});k.command("check","Type check TypeScript files or validate generated declarations").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--declarations-only","Only check .d.ts files",{default:!1}).option("--tsconfig <path>","Path to tsconfig.json",{default:"tsconfig.json"}).option("--strict","Enable strict type checking",{default:!1}).option("--skip-lib-check","Skip checking library definitions",{default:!0}).option("--warnings-as-errors","Treat warnings as errors",{default:!1}).option("--max-errors <number>","Maximum errors before stopping",{default:0}).option("--isolated-declarations","Check if code follows isolated declarations best practices (recommended)",{default:!1}).option("--format <format>","Output format: text or json",{default:"text"}).example("dtsx check").example('dtsx check --files "src/**/*.ts" --strict').example('dtsx check --declarations-only --files "dist/**/*.d.ts"').example("dtsx check --isolated-declarations").action(async(q)=>{try{let{typeCheck:Q,checkIsolatedDeclarations:K,formatTypeCheckResults:N}=await import("../chunk-7cpp6v8f.js"),{Glob:A}=awaitPromise.resolve(globalThis.Bun),{resolve:J,relative:$}=await import("path"),z=V.cwd(),B=q.files||["**/*.ts"],G=[];for(let Z of B){let E=new A(Z);for await(let M of E.scan({cwd:z,absolute:!0,onlyFiles:!0}))if(!M.includes("node_modules"))if(q.declarationsOnly){if(M.endsWith(".d.ts"))G.push(M)}else G.push(M)}if(G.length===0)console.error("No files found to check"),V.exit(1);if(q.isolatedDeclarations){console.log(`Checking ${G.length} files for isolated declarations best practices...`);let Z=await K(G,q.tsconfig?J(q.tsconfig):void 0),E=0,M=[];for(let[T,R]of Z){let I=$(z,T);if(!R.compatible)if(E+=R.issues.length,q.format==="json")M.push({file:I,compatible:!1,issues:R.issues});else{console.log(`
|
|
7
7
|
\u2717 ${I}`);for(let _ of R.issues)if(console.log(` ${_.line}:${_.column} - ${_.message}`),_.missingAnnotation)console.log(` Missing: ${_.missingAnnotation} type annotation`)}else if(q.format==="json")M.push({file:I,compatible:!0,issues:[]})}if(q.format==="json")console.log(JSON.stringify(M,null,2));else if(E>0)console.log(`
|
|
8
8
|
${G.length} files checked, ${E} recommendations found`),console.log("Tip: Adding explicit type annotations improves .d.ts accuracy");else console.log(`
|
|
9
|
-
${G.length} files checked, all follow isolated declarations best practices`);V.exit(E>0?1:0)}console.log(`Type checking ${G.length} files...`);let j=await Q(G,{tsconfigPath:q.tsconfig?J(q.tsconfig):void 0,strict:q.strict??!1,declarationsOnly:q.declarationsOnly??!1,skipLibCheck:q.skipLibCheck??!0,warningsAsErrors:q.warningsAsErrors??!1,maxErrors:q.maxErrors||void 0});if(q.format==="json")console.log(JSON.stringify(j,null,2));else console.log(N(j));V.exit(j.success?0:1)}catch(Q){console.error("Error during type checking:",Q),V.exit(1)}});k.command("convert","Convert TypeScript types to different schema formats").option("--files <patterns>","Glob patterns for TypeScript files",{default:"**/*.ts",type:[String]}).option("--format <format>","Output format: json-schema, zod, valibot, io-ts, yup, arktype",{default:"json-schema"}).option("--outdir <path>","Output directory for converted files",{default:"./schemas"}).option("--include-descriptions","Include JSDoc descriptions in output",{default:!0}).option("--all-optional","Make all properties optional",{default:!1}).option("--use-infer","Include inferred types (for Zod, Valibot, etc.)",{default:!0}).option("--json-schema-draft <version>","JSON Schema draft version: 2020-12, 2019-09, draft-07",{default:"2020-12"}).example("dtsx convert --format zod").example('dtsx convert --format json-schema --files "src/types/**/*.ts"').example("dtsx convert --format valibot --outdir ./validation").action(async(q)=>{try{let Q=await import("../chunk-3g2v2ns2.js"),{extractDeclarations:K}=await import("../chunk-
|
|
9
|
+
${G.length} files checked, all follow isolated declarations best practices`);V.exit(E>0?1:0)}console.log(`Type checking ${G.length} files...`);let j=await Q(G,{tsconfigPath:q.tsconfig?J(q.tsconfig):void 0,strict:q.strict??!1,declarationsOnly:q.declarationsOnly??!1,skipLibCheck:q.skipLibCheck??!0,warningsAsErrors:q.warningsAsErrors??!1,maxErrors:q.maxErrors||void 0});if(q.format==="json")console.log(JSON.stringify(j,null,2));else console.log(N(j));V.exit(j.success?0:1)}catch(Q){console.error("Error during type checking:",Q),V.exit(1)}});k.command("convert","Convert TypeScript types to different schema formats").option("--files <patterns>","Glob patterns for TypeScript files",{default:"**/*.ts",type:[String]}).option("--format <format>","Output format: json-schema, zod, valibot, io-ts, yup, arktype",{default:"json-schema"}).option("--outdir <path>","Output directory for converted files",{default:"./schemas"}).option("--include-descriptions","Include JSDoc descriptions in output",{default:!0}).option("--all-optional","Make all properties optional",{default:!1}).option("--use-infer","Include inferred types (for Zod, Valibot, etc.)",{default:!0}).option("--json-schema-draft <version>","JSON Schema draft version: 2020-12, 2019-09, draft-07",{default:"2020-12"}).example("dtsx convert --format zod").example('dtsx convert --format json-schema --files "src/types/**/*.ts"').example("dtsx convert --format valibot --outdir ./validation").action(async(q)=>{try{let Q=await import("../chunk-3g2v2ns2.js"),{extractDeclarations:K}=await import("../chunk-j6aqdbc4.js"),{Glob:N}=awaitPromise.resolve(globalThis.Bun),{resolve:A,relative:J,join:$,dirname:z,basename:B}=await import("path"),{mkdirSync:G,existsSync:j,readFileSync:Z,writeFileSync:E}=await import("fs"),M=V.cwd(),T=q.files||["**/*.ts"],R=q.format||"json-schema",I=A(q.outdir||"./schemas"),_=[];for(let D of T){let C=new N(D);for await(let w of C.scan({cwd:M,absolute:!0,onlyFiles:!0}))if(!w.endsWith(".d.ts")&&!w.includes("node_modules"))_.push(w)}if(_.length===0)console.error("No TypeScript files found"),V.exit(1);if(console.log(`Converting ${_.length} files to ${R} format...`),!j(I))G(I,{recursive:!0});let X=0,F=0;for(let D of _){let C=Z(D,"utf-8"),U=K(C,D).filter((d)=>d.kind==="interface"||d.kind==="type");if(U.length===0)continue;let L=Q.convertToFormat(U,{format:R,includeDescriptions:q.includeDescriptions??!0,allOptional:q.allOptional??!1,useInfer:q.useInfer??!0,jsonSchemaDraft:q.jsonSchemaDraft||"2020-12"}),a=J(M,D),l=B(D,".ts"),p=Q.getFormatExtension(R),O=$(I,z(a),`${l}${p}`),u=z(O);if(!j(u))G(u,{recursive:!0});E(O,L),X+=U.length,F++,console.log(` ${J(M,O)} (${U.length} types)`)}console.log(`
|
|
10
10
|
Converted ${X} declarations from ${F} files`)}catch(Q){console.error("Error converting files:",Q),V.exit(1)}});k.command("circular","Detect circular dependencies in TypeScript files").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--root <path>","Root directory for resolution",{default:"."}).option("--ignore <patterns>","Glob patterns to ignore (comma-separated)",{default:"",type:[String]}).option("--types-only","Only report type-level cycles",{default:!1}).option("--max-depth <number>","Maximum depth for cycle detection",{default:100}).option("--include-node-modules","Include node_modules in analysis",{default:!1}).option("--format <format>","Output format: text, json, dot",{default:"text"}).option("--summary","Show graph summary statistics",{default:!1}).example("dtsx circular").example('dtsx circular --files "src/**/*.ts"').example('dtsx circular --ignore "**/*.test.ts,**/__tests__/**"').example("dtsx circular --format dot > deps.dot").example("dtsx circular --summary").action(async(q)=>{try{let{analyzeCircularDependencies:Q,formatCircularAnalysis:K,getGraphSummary:N,exportGraphAsDot:A,exportGraphAsJson:J}=await import("../chunk-3j7r0fxz.js"),{Glob:$}=awaitPromise.resolve(globalThis.Bun),{resolve:z,relative:B}=await import("path"),G=V.cwd(),j=z(q.root||"."),Z=q.files||["**/*.ts"],E=[];for(let T of Z){let R=new $(T);for await(let I of R.scan({cwd:j,absolute:!0,onlyFiles:!0}))if(!I.endsWith(".d.ts")){if(!q.includeNodeModules&&I.includes("node_modules"))continue;E.push(I)}}if(E.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Analyzing ${E.length} files for circular dependencies...`);let M=await Q(E,{rootDir:j,ignore:q.ignore?.filter(Boolean),typesOnly:q.typesOnly??!1,maxDepth:q.maxDepth??100,includeNodeModules:q.includeNodeModules??!1});if(q.format==="json")console.log(J(M.graph,j));else if(q.format==="dot")console.log(A(M.graph,j));else if(console.log(K(M,j)),q.summary){let T=N(M.graph);if(console.log(`
|
|
11
11
|
--- Dependency Graph Summary ---`),console.log(`Total files: ${T.totalFiles}`),console.log(`Total dependencies: ${T.totalDependencies}`),console.log(`Average dependencies per file: ${T.avgDependencies.toFixed(2)}`),T.maxDependencies.count>0)console.log(`Most dependencies: ${B(j,T.maxDependencies.file)} (${T.maxDependencies.count})`);if(T.mostDepended.count>0)console.log(`Most depended on: ${B(j,T.mostDepended.file)} (${T.mostDepended.count} dependents)`);if(T.isolatedFiles.length>0)console.log(`Isolated files (no dependencies): ${T.isolatedFiles.length}`)}V.exit(M.hasCircular?1:0)}catch(Q){console.error("Error analyzing dependencies:",Q),V.exit(1)}});k.command("version","Show the version of dtsx").action(()=>{console.log(e)});k.version(e);k.help();k.parse();
|
package/dist/branded-types.d.ts
CHANGED
|
@@ -56,29 +56,11 @@ export declare function unwrap<T>(branded: Brand<T, string>): T;
|
|
|
56
56
|
* @defaultValue
|
|
57
57
|
* ```ts
|
|
58
58
|
* {
|
|
59
|
-
* /**
|
|
60
|
-
* * Join path segments, returning appropriate branded type
|
|
61
|
-
* */
|
|
62
59
|
* join: (base: DirectoryPath, ...segments: string[]) => unknown,
|
|
63
|
-
* /**
|
|
64
|
-
* * Get directory name from a file path
|
|
65
|
-
* */
|
|
66
60
|
* dirname: (path: FilePath) => unknown,
|
|
67
|
-
* /**
|
|
68
|
-
* * Get base name from a file path
|
|
69
|
-
* */
|
|
70
61
|
* basename: (path: FilePath) => unknown,
|
|
71
|
-
* /**
|
|
72
|
-
* * Resolve path to absolute
|
|
73
|
-
* */
|
|
74
62
|
* resolve: (...segments: string[]) => unknown,
|
|
75
|
-
* /**
|
|
76
|
-
* * Check if path is absolute
|
|
77
|
-
* */
|
|
78
63
|
* isAbsolute: (path: string) => unknown,
|
|
79
|
-
* /**
|
|
80
|
-
* * Get relative path from one path to another
|
|
81
|
-
* */
|
|
82
64
|
* relative: (from: DirectoryPath, to: FilePath) => unknown
|
|
83
65
|
* }
|
|
84
66
|
* ```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as y}from"./chunk-
|
|
2
|
+
import{tb as y}from"./chunk-9a6yn7sv.js";import{Vc as H,Xc as F}from"./chunk-57agx6g8.js";import{cd as R}from"./chunk-rw6j20e2.js";import{existsSync as V,readFileSync as G}from"fs";import{dirname as M,join as X,resolve as x}from"path";async function S(E){let A=[],z=new Set;async function q(I,L){let w=x(I);if(z.has(w))return;if(z.add(w),!V(w)){H.warn(`tsconfig not found: ${w}`);return}try{let O=G(w,"utf-8").replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),K=JSON.parse(O),U=M(w),Y=B(U,L),W=[];if(K.references)for(let D of K.references){let $=x(U,D.path),J=V(X($,"tsconfig.json"))?X($,"tsconfig.json"):$;await q(J,Y);let b=B(M(J),Y);W.push(b)}let Z="./src";if(K.compilerOptions?.rootDir)Z=K.compilerOptions.rootDir;else if(K.include&&K.include.length>0){if(K.include[0].startsWith("src/"))Z="./src"}let _="./dist";if(K.compilerOptions?.outDir)_=K.compilerOptions.outDir;else if(K.compilerOptions?.declarationDir)_=K.compilerOptions.declarationDir;A.push({name:Y,root:U,tsconfigPath:w,references:W,config:{root:Z,outdir:_}})}catch(Q){let O=Q instanceof Error?Q.message:String(Q);H.warn(`Failed to parse ${w}: ${O}`)}}return await q(E),A}function B(E,A){let z=X(E,"package.json");if(V(z))try{let I=G(z,"utf-8"),L=JSON.parse(I);if(L.name)return L.name}catch{}let q=E.split("/").pop()||"unknown";return A?`${A}/${q}`:q}function N(E){let A=new Map(E.map((w)=>[w.name,w])),z=[],q=new Set,I=new Set;function L(w){if(q.has(w))return;if(I.has(w)){H.warn(`Circular dependency detected involving: ${w}`);return}I.add(w);let Q=A.get(w);if(Q){for(let O of Q.references)L(O);z.push(Q)}I.delete(w),q.add(w)}for(let w of E)L(w.name);return z}async function T(E){let A=Date.now(),z=N(E.projects);H.info(`Generating declarations for ${z.length} projects...`);let q=[],I=!0;for(let O of z){H.info(`
|
|
3
3
|
[${O.name}] Generating...`);try{let K={...E.sharedConfig,...O.config,cwd:O.root,tsconfigPath:O.tsconfigPath},U=await y(K),Y=U.filesFailed===0;if(!Y)I=!1;q.push({name:O.name,stats:U,success:Y}),H.info(`[${O.name}] Generated ${U.filesGenerated} files`)}catch(K){I=!1;let U=K instanceof Error?K.message:String(K);q.push({name:O.name,stats:{filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:U}),H.error(`[${O.name}] Failed: ${U}`)}}let L=Date.now()-A,w=q.filter((O)=>O.success).length,Q=q.length-w;if(H.info(`
|
|
4
4
|
--- Workspace Generation Summary ---`),H.info(`Projects processed: ${q.length}`),H.info(`Successful: ${w}`),Q>0)H.info(`Failed: ${Q}`);return H.info(`Total duration: ${L}ms`),H.info(`------------------------------------
|
|
5
5
|
`),{success:I,projects:q,durationMs:L}}async function f(E,A){if(A?.logLevel)F(A.logLevel);let z=X(E,"tsconfig.json");if(!V(z))throw Error(`Root tsconfig.json not found at: ${z}`);H.info("Discovering workspace projects...");let q=await S(z);if(q.length===0)return H.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return H.info(`Found ${q.length} projects`),T({root:E,projects:q,sharedConfig:A})}async function v(E){let A=X(E,"package.json");if(!V(A))return[];try{let z=G(A,"utf-8"),q=JSON.parse(z),I=[];if(Array.isArray(q.workspaces))I=q.workspaces;else if(q.workspaces?.packages)I=q.workspaces.packages;return I}catch{return[]}}async function C(E,A){let{Glob:z}=awaitPromise.resolve(globalThis.Bun),q=[];for(let I of A){let L=new z(I);for await(let w of L.scan({cwd:E,absolute:!0,onlyFiles:!1})){let Q=X(w,"package.json");if(V(Q))q.push(w)}}return q}async function l(E,A){if(A?.logLevel)F(A.logLevel);let z=await v(E);if(z.length===0)return H.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};H.info(`Found workspace patterns: ${z.join(", ")}`);let q=await C(E,z);if(q.length===0)return H.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};H.info(`Found ${q.length} workspace packages`);let I=q.map((L)=>{let w=X(L,"tsconfig.json");return{name:B(L),root:L,tsconfigPath:V(w)?w:"",references:[]}});return T({root:E,projects:I,sharedConfig:A})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ac as v,Bc as w,oc as j,pc as k,qc as l,rc as m,sc as n,tc as o,uc as p,vc as q,wc as r,xc as s,yc as t,zc as u}from"./chunk-
|
|
2
|
+
import{Ac as v,Bc as w,oc as j,pc as k,qc as l,rc as m,sc as n,tc as o,uc as p,vc as q,wc as r,xc as s,yc as t,zc as u}from"./chunk-begk3j01.js";import{Ec as a,Fc as b,Gc as c,Hc as d,Ic as e,Jc as f,Kc as g,Lc as h,Mc as i}from"./chunk-xnq1xw73.js";import"./chunk-rw6j20e2.js";export{l as processVariableDeclaration,n as processTypeDeclaration,s as processModuleDeclaration,m as processInterfaceDeclaration,q as processImportDeclaration,k as processFunctionDeclaration,r as processExportDeclaration,p as processEnumDeclaration,w as processDeclarations,o as processClassDeclaration,u as parseImportStatement,d as parseArrayElements,h as isGenericType,e as inferObjectType,b as inferNarrowTypeInUnion,a as inferNarrowType,g as inferFunctionType,c as inferArrayType,j as formatComments,f as findMatchingBracket,i as extractSatisfiesType,v as extractAllImportedItems,t as clearProcessorCaches};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as I}from"./chunk-
|
|
2
|
+
import{tb as I}from"./chunk-9a6yn7sv.js";function z(J={}){let{onBuildStart:K=!1,onBuildEnd:L=!0,onGenerated:M,onError:C,...N}=J,w,q,F=async()=>{let j={...N};if(!j.outdir&&w)j.outdir=w;if(!j.entrypoints&&q)j.entrypoints=q;try{let k=await I(j);M?.(k)}catch(k){let H=k instanceof Error?k:Error(String(k));if(C?.(H),!C)console.error("[dtsx] Generation failed:",H.message)}};return{name:"dtsx",esbuildOptions(j){if(j.outdir&&typeof j.outdir==="string")w=j.outdir;if(j.entryPoints){if(Array.isArray(j.entryPoints))q=j.entryPoints;else if(typeof j.entryPoints==="object")q=Object.values(j.entryPoints)}},async buildStart(){if(K)await F()},async buildEnd(j){if(L)await F()}}}var R=z,T=z,V=z;
|
|
3
3
|
export{z as ma,R as na,T as oa,V as pa};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as I}from"./chunk-
|
|
2
|
+
import{tb as I}from"./chunk-9a6yn7sv.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
3
|
export{H as qa,K as ra,M as sa,Q as ta};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
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-w9abhtgg.js";import"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-begk3j01.js";import"./chunk-xnq1xw73.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,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tb as b,ub as c,vb as d}from"./chunk-9a6yn7sv.js";import"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import{ic as a}from"./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{d as watch,a as processSource,c as processFile,b as generate};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ec as u}from"./chunk-
|
|
2
|
+
import{ec as u}from"./chunk-wfevdmvd.js";import{hc as TY}from"./chunk-p1d09y82.js";import{kc as XJ}from"./chunk-74j5mydx.js";import{Bc as gJ}from"./chunk-begk3j01.js";import{Tc as m}from"./chunk-f18nyrrb.js";import{Vc as W,Xc as n}from"./chunk-57agx6g8.js";import{ad as kY,cd as BJ}from"./chunk-rw6j20e2.js";var{Glob:pJ}=globalThis.Bun;import{mkdir as i}from"fs/promises";import{availableParallelism as FY}from"os";import{dirname as g,relative as S,resolve as y}from"path";import{existsSync as YJ,mkdirSync as sJ,readFileSync as aJ,writeFileSync as iJ}from"fs";import{dirname as nJ,relative as oJ,resolve as rJ}from"path";async function KJ(J,Y,$){let X=new Map,Z=[],Q=new Set,U=0,z=0,H=0;for(let q of J){let G=Y.get(q);if(!G)continue;let O=u(G,q,$.keepComments);U+=O.length;for(let V of O)if(V.kind==="import"){z++;let K=V.source||"";if(K.startsWith("."))continue;if(!X.has(K))X.set(K,{source:K,specifiers:new Map,isTypeOnly:V.isTypeOnly||!1,isSideEffect:V.isSideEffect||!1});let B=X.get(K);if(V.specifiers)for(let k of V.specifiers){let T=k.alias||k.name;if(!B.specifiers.has(T))B.specifiers.set(T,{name:k.name,alias:k.alias,isType:k.isType||!1})}if(!V.isTypeOnly)B.isTypeOnly=!1}else if(V.isExported||V.kind==="export"){if(H++,V.name&&Q.has(V.name))continue;if(V.name)Q.add(V.name);Z.push({declaration:V,file:q})}}let j=[];j.push("/**"),j.push(" * Bundled TypeScript declarations"),j.push(` * Generated from ${J.length} source files`),j.push(" */"),j.push("");let _=Array.from(X.values()).sort((q,G)=>{let O=$.importOrder||["bun"],V=O.findIndex((B)=>q.source.startsWith(B)),K=O.findIndex((B)=>G.source.startsWith(B));if(V!==-1&&K!==-1)return V-K;if(V!==-1)return-1;if(K!==-1)return 1;return q.source.localeCompare(G.source)});for(let q of _)if(q.isSideEffect)j.push(`import '${q.source}';`);else if(q.specifiers.size>0){let O=Array.from(q.specifiers.values()).map((K)=>{let B=K.isType?"type ":"";return K.alias?`${B}${K.name} as ${K.alias}`:`${B}${K.name}`}),V=q.isTypeOnly?"type ":"";j.push(`import ${V}{ ${O.join(", ")} } from '${q.source}';`)}if(_.length>0)j.push("");let A=new Map;for(let{declaration:q,file:G}of Z){if(!A.has(G))A.set(G,[]);A.get(G).push(q)}for(let[q,G]of A){let O=oJ($.cwd,q);j.push(`// From: ${O}`);for(let V of G){if($.keepComments&&V.leadingComments)for(let K of V.leadingComments)j.push(K);j.push(OJ(V))}j.push("")}let R=j.join(`
|
|
3
3
|
`);return{content:R,files:J,declarationCount:U,importCount:z,exportCount:H,size:Buffer.byteLength(R,"utf8"),warnings:[]}}function OJ(J){if(J.text){let $=J.text.trim();if(J.isExported&&!$.startsWith("export"))$=`export ${$}`;if(!$.endsWith(";")&&!$.endsWith("}"))$+=";";return $}let Y=[];if(J.isExported)Y.push("export");if(J.isDefault)Y.push("default");switch(J.kind){case"function":if(Y.push("declare function"),Y.push(J.name),J.generics)Y.push(J.generics);if(Y.push(`(${tJ(J.parameters)})`),J.returnType)Y.push(`: ${J.returnType}`);break;case"variable":if(Y.push("declare const"),Y.push(J.name),J.typeAnnotation)Y.push(`: ${J.typeAnnotation}`);break;case"interface":if(Y.push("interface"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${$.name}${$.typeAnnotation?`: ${$.typeAnnotation}`:""};`);Y.push("}");break;case"type":if(Y.push("type"),Y.push(J.name),J.generics)Y.push(J.generics);Y.push("="),Y.push(J.typeAnnotation||"unknown");break;case"class":if(Y.push("declare class"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(J.implements&&J.implements.length>0)Y.push(`implements ${J.implements.join(", ")}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${OJ($)}`);Y.push("}");break;case"enum":if(Y.push("declare enum"),Y.push(J.name),Y.push("{"),J.members){let $=J.members.map((X)=>X.value!==void 0?`${X.name} = ${X.value}`:X.name);Y.push(` ${$.join(`,
|
|
4
4
|
`)}`)}Y.push("}");break;default:return J.text||""}return Y.join(" ")}function tJ(J){if(!J||J.length===0)return"";return J.map((Y)=>{let $="";if(Y.rest)$+="...";if($+=Y.name,Y.optional)$+="?";if(Y.type)$+=`: ${Y.type}`;if(Y.defaultValue)$+=` = ${Y.defaultValue}`;return $}).join(", ")}async function AJ(J,Y={}){let $=[],X=new Map,Z=[],Q=[],U=new Set,z=0,H=0,j=0;for(let q of J){if(!YJ(q)){$.push(`File not found: ${q}`);continue}let G=aJ(q,"utf-8");Q.push(q);let O=G.split(`
|
|
5
5
|
`),V=[],K=0,B=!1;for(let k of O){let T=k.trim();if(!T&&!B)continue;if(T.startsWith("import ")){H++;let M=T.match(/import\s+(type\s+)?(?:\{([^}]+)\}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/);if(M){let[,N,L,D,GJ,F]=M;if(Y.externals?.some((o)=>F.startsWith(o))){Z.push(T);continue}if(F.startsWith("."))continue;if(!X.has(F))X.set(F,{source:F,specifiers:new Map,isTypeOnly:!!N,isSideEffect:!1});let HJ=X.get(F);if(L){let o=L.split(",").map((r)=>r.trim());for(let r of o){let[t,e]=r.split(/\s+as\s+/).map((lJ)=>lJ.trim()),WJ=t.startsWith("type "),JJ=WJ?t.replace("type ",""):t;HJ.specifiers.set(e||JJ,{name:JJ,alias:e!==JJ?e:void 0,isType:WJ})}}if(!N)HJ.isTypeOnly=!1}continue}if(/^(export\s+)?(declare\s+)?(interface|type|class|function|const|let|var|enum|namespace|module)\s/.test(T)){if(B=!0,V=[k],K=(k.match(/\{/g)||[]).length-(k.match(/\}/g)||[]).length,K===0&&(T.endsWith(";")||!T.includes("{"))){let M=p(T);if(!U.has(M)||!Y.mergeDuplicates){if(U.add(M),Z.push(k),z++,T.startsWith("export"))j++}B=!1,V=[]}}else if(B){if(V.push(k),K+=(k.match(/\{/g)||[]).length-(k.match(/\}/g)||[]).length,K<=0){let M=V.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cc as Kz,Dc as Uz,Ec as P,Lc as u,Mc as p,Nc as jz}from"./chunk-
|
|
2
|
+
import{Cc as Kz,Dc as Uz,Ec as P,Lc as u,Mc as p,Nc as jz}from"./chunk-xnq1xw73.js";function _(z,X=!0){if(!X||!z||z.length===0)return"";if(z.length===1)return z[0].trim()+`
|
|
3
3
|
`;let K="";for(let Z=0;Z<z.length;Z++){if(Z>0)K+=`
|
|
4
4
|
`;K+=z[Z].trim()}return`${K}
|
|
5
5
|
`}function Jz(z){if(z.includes(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as K}from"./chunk-
|
|
2
|
+
import{tb as K}from"./chunk-9a6yn7sv.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
3
|
export{L as ca,Y as da,_ as ea};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a,b,c}from"./chunk-
|
|
2
|
+
import{a,b,c}from"./chunk-ggmn4a8c.js";import"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-xnq1xw73.js";import"./chunk-rw6j20e2.js";export{b as optimizeFile,a as optimizeDeclarations,c as minifyDts};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ec as $}from"./chunk-
|
|
2
|
+
import{ec as $}from"./chunk-wfevdmvd.js";import{existsSync as U,readFileSync as O,writeFileSync as q}from"fs";function _(G){let j=[],H=/\b([A-Z][a-zA-Z0-9]*)\b/g,L;while((L=H.exec(G))!==null){let J=L[1];if(!N(J))j.push(J)}return[...new Set(j)]}function N(G){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(G)}function C(G){if(G.kind!=="type")return!1;let j=G.typeAnnotation||"";if(G.generics)return!1;if(j.includes("{")||j.includes("(")||j.includes("<"))return!1;return/^[\w\s|&]+$/.test(j)}function E(G){if(G.kind!=="interface")return!1;if(!G.members||G.members.length===0){if(!G.extends)return!0}return!1}function F(G,j){let H={...G,members:[...G.members||[],...j.members||[]],leadingComments:[...G.leadingComments||[],...j.leadingComments||[]]};if(G.extends&&j.extends){let L=G.extends.split(",").map((K)=>K.trim()),J=j.extends.split(",").map((K)=>K.trim());H.extends=[...new Set([...L,...J])].join(", ")}else H.extends=G.extends||j.extends;return H}function D(G){let j=["import","interface","type","class","enum","function","variable","export"];return[...G].sort((H,L)=>{let J=j.indexOf(H.kind)-j.indexOf(L.kind);if(J!==0)return J;return H.name.localeCompare(L.name)})}function R(G){let j=G.filter((J)=>J.kind==="import"),H=G.filter((J)=>J.kind!=="import");return[...[...j].sort((J,K)=>{let M=J.source||"",Q=K.source||"",V=M.startsWith("node:")||M==="bun",W=Q.startsWith("node:")||Q==="bun";if(V&&!W)return-1;if(!V&&W)return 1;let Y=!M.startsWith("."),X=!Q.startsWith(".");if(Y&&!X)return-1;if(!Y&&X)return 1;return M.localeCompare(Q)}),...H]}function k(G){let j=new Set;for(let J of G){if(J.kind==="import")continue;let K=J.text||"",M=J.typeAnnotation||"",Q=J.returnType||"",V=J.extends||"",W=J.implements?.join(" ")||"",Y=`${K} ${M} ${Q} ${V} ${W}`;for(let X of _(Y))j.add(X);if(J.members)for(let X of J.members){let Z=`${X.typeAnnotation||""} ${X.returnType||""}`;for(let w of _(Z))j.add(w)}if(J.parameters){for(let X of J.parameters)if(X.type)for(let Z of _(X.type))j.add(Z)}}let H=0;return{declarations:G.map((J)=>{if(J.kind!=="import"||!J.specifiers)return J;let K=J.specifiers.filter((M)=>{let Q=M.alias||M.name;return j.has(Q)});if(K.length===0){if(!J.isSideEffect)return H++,null}if(K.length<(J.specifiers?.length||0))return H+=(J.specifiers?.length||0)-K.length,{...J,specifiers:K};return J}).filter((J)=>J!==null),removed:H}}function A(G){let j=new Map,H=0;for(let L of G){if(L.kind==="import"){let K=`import:${L.source}`;if(j.has(K)){let M=j.get(K),Q=[...M.specifiers||[],...L.specifiers||[]],V=Array.from(new Map(Q.map((W)=>[W.alias||W.name,W])).values());j.set(K,{...M,specifiers:V}),H++}else j.set(K,L);continue}let J=`${L.kind}:${L.name}`;if(j.has(J))H++;else j.set(J,L)}return{declarations:Array.from(j.values()),removed:H}}function z(G){let j=new Map,H=[];for(let K of G)if(K.kind==="interface"){let M=K.name;if(!j.has(M))j.set(M,[]);j.get(M).push(K)}else H.push(K);let L=0,J=[];for(let[K,M]of j)if(M.length>1){let Q=M[0];for(let V=1;V<M.length;V++)Q=F(Q,M[V]),L++;J.push(Q)}else J.push(M[0]);return{declarations:[...H,...J],merged:L}}function P(G){let j=new Map,H=new Set;for(let K of G)if(C(K))j.set(K.name,K.typeAnnotation||""),H.add(K.name);if(j.size===0)return{declarations:G,inlined:0};function L(K){let M=K;for(let[Q,V]of j){let W=new RegExp(`\\b${Q}\\b`,"g");M=M.replace(W,V)}return M}return{declarations:G.filter((K)=>K.kind!=="type"||!H.has(K.name)).map((K)=>{if(K.typeAnnotation)K={...K,typeAnnotation:L(K.typeAnnotation)};if(K.returnType)K={...K,returnType:L(K.returnType)};if(K.extends)K={...K,extends:L(K.extends)};return K}),inlined:j.size}}function v(G){let j=G.length,H=G.filter((L)=>!E(L));return{declarations:H,removed:j-H.length}}function B(G,j={}){let H=[...G],L={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(j.removeUnusedImports){let{declarations:J,removed:K}=k(H);H=J,L.removedImports=K}if(j.deduplicateDeclarations){let{declarations:J,removed:K}=A(H);H=J,L.removedDeclarations+=K}if(j.mergeInterfaces){let{declarations:J,merged:K}=z(H);H=J,L.mergedInterfaces=K}if(j.removeEmptyInterfaces){let{declarations:J,removed:K}=v(H);H=J,L.removedDeclarations+=K}if(j.inlineSimpleTypes){let{declarations:J,inlined:K}=P(H);H=J,L.inlinedTypes=K}if(j.sortImports)H=R(H);if(j.sortDeclarations)H=D(H);return{declarations:H,result:L}}async function g(G,j={}){if(!U(G))throw Error(`File not found: ${G}`);let H=O(G,"utf-8"),L=Buffer.byteLength(H,"utf-8"),J=$(H,G,!j.removeComments),{declarations:K,result:M}=B(J,j),Q=h(K,j);if(j.minify)Q=x(Q);let V=Buffer.byteLength(Q,"utf-8");return M.originalSize=L,M.optimizedSize=V,M.savings=L-V,M.savingsPercent=Math.round(M.savings/L*100),q(G,Q),M}function h(G,j){let H=[];for(let L of G){if(!j.removeComments&&L.leadingComments)for(let J of L.leadingComments)H.push(J);if(L.text)H.push(L.text);else H.push(I(L));H.push("")}return H.join(`
|
|
3
3
|
`)}function I(G){let j=[];if(G.isExported)j.push("export");if(G.isDefault)j.push("default");switch(G.kind){case"import":if(G.isTypeOnly)j.push("import type");else j.push("import");if(G.specifiers&&G.specifiers.length>0){let H=G.specifiers.map((L)=>{let J=L.isType?"type ":"";return L.alias?`${J}${L.name} as ${L.alias}`:`${J}${L.name}`}).join(", ");j.push(`{ ${H} }`)}j.push("from"),j.push(`'${G.source}'`);break;case"function":if(j.push("declare function"),j.push(G.name),G.generics)j.push(G.generics);if(j.push(`(${S(G.parameters)})`),G.returnType)j.push(`: ${G.returnType}`);break;case"variable":if(j.push("declare const"),j.push(G.name),G.typeAnnotation)j.push(`: ${G.typeAnnotation}`);break;case"interface":if(j.push("interface"),j.push(G.name),G.generics)j.push(G.generics);if(G.extends)j.push(`extends ${G.extends}`);if(j.push("{"),G.members)for(let H of G.members)j.push(` ${H.name}${H.typeAnnotation?`: ${H.typeAnnotation}`:""}`);j.push("}");break;case"type":if(j.push("type"),j.push(G.name),G.generics)j.push(G.generics);j.push("="),j.push(G.typeAnnotation||"unknown");break;case"class":if(j.push("declare class"),j.push(G.name),G.generics)j.push(G.generics);if(G.extends)j.push(`extends ${G.extends}`);if(G.implements?.length)j.push(`implements ${G.implements.join(", ")}`);j.push("{ }");break;case"enum":j.push("declare enum"),j.push(G.name),j.push("{ }");break;default:return G.text||""}return j.join(" ")}function S(G){if(!G)return"";return G.map((j)=>{let H="";if(j.rest)H+="...";if(H+=j.name,j.optional)H+="?";if(j.type)H+=`: ${j.type}`;return H}).join(", ")}function x(G){return G.replace(/(?<!\/\*\*)\/\/[^\n]*/g,"").replace(/^\s*[\r\n]/gm,"").replace(/ {2,}/g," ").replace(/\s*([{}[\]();,:])\s*/g,"$1").replace(/(\w)(\{)/g,"$1 $2").replace(/(\})([a-z])/gi,"$1 $2").replace(/(export|import|type|interface|class|function|const|let|var|extends|implements|declare)\s*/g,"$1 ").trim()}
|
|
4
4
|
export{B as a,g as b,x as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lc as I}from"./chunk-74j5mydx.js";import{nc as H}from"./chunk-rnt0wkrk.js";import{Bc as G}from"./chunk-
|
|
2
|
+
import{lc as I}from"./chunk-74j5mydx.js";import{nc as H}from"./chunk-rnt0wkrk.js";import{Bc as G}from"./chunk-begk3j01.js";function N(q,v="stdin.ts",z=!0,B=["bun"],E=!1){let A=I(q,v,z,E);return G(A,{filePath:v,sourceCode:q,declarations:A},z,B)}function P(q,v="stdin.ts",z=!0,B=["bun"],E=!1){let A=H(q,v,z,E);return G(A,{filePath:v,sourceCode:q,declarations:A},z,B)}
|
|
3
3
|
export{N as ic,P as jc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$b as G,Ab as e,Bb as g,Cb as h,Db as i,Eb as j,Fb as k,Gb as l,Hb as m,Ib as n,Jb as o,Kb as p,Lb as q,Mb as r,Nb as s,Ob as t,Pb as u,Qb as v,Rb as w,Sb as x,Tb as y,Ub as z,Vb as A,Wb as B,Xb as C,Yb as D,Zb as E,_b as F,ac as H,bc as I,cc as J,dc as K,ec as L,fc as M,gc as N,wb as a,xb as b,yb as c,zb as d}from"./chunk-
|
|
2
|
+
import{$b as G,Ab as e,Bb as g,Cb as h,Db as i,Eb as j,Fb as k,Gb as l,Hb as m,Ib as n,Jb as o,Kb as p,Lb as q,Mb as r,Nb as s,Ob as t,Pb as u,Qb as v,Rb as w,Sb as x,Tb as y,Ub as z,Vb as A,Wb as B,Xb as C,Yb as D,Zb as E,_b as F,ac as H,bc as I,cc as J,dc as K,ec as L,fc as M,gc as N,wb as a,xb as b,yb as c,zb as d}from"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import{Nc as f}from"./chunk-xnq1xw73.js";import"./chunk-rw6j20e2.js";export{d as shouldUseAsyncParsing,m as shouldIncludeNonExportedInterface,l as shouldIncludeNonExportedFunction,n as isBuiltInType,j as hasExportModifier,k as hasAsyncModifier,a as getSourceFileCacheSize,b as getSourceFileAsync,e as getPendingParseCount,i as getParameterName,g as getNodeText,s as getInterfaceBody,I as findReferencedTypes,C as extractVariableStatement,o as extractTypesFromModuleText,E as extractTypeAliasDeclaration,f as extractTripleSlashDirectives,J as extractReferencedTypeDeclarations,H as extractModuleDeclaration,h as extractJSDocComments,D as extractInterfaceDeclaration,y as extractImportDeclaration,B as extractFunctionDeclaration,z as extractExportDeclaration,A as extractExportAssignment,G as extractEnumDeclaration,M as extractDeclarationsAsync,L as extractDeclarations,F as extractClassDeclaration,K as clearSourceFileCache,q as buildVariableDeclaration,t as buildTypeDeclaration,w as buildModuleDeclaration,x as buildModuleBody,r as buildInterfaceDeclaration,p as buildFunctionSignature,u as buildClassDeclaration,v as buildClassBody,c as batchParseSourceFiles,N as batchExtractDeclarations};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h}from"./chunk-
|
|
2
|
+
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h}from"./chunk-xyctgc6x.js";import"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-xnq1xw73.js";import"./chunk-57agx6g8.js";import"./chunk-rw6j20e2.js";export{a as parseJSDoc,f as generateTypeDocJSON,c as generateMarkdown,e as generateJSON,d as generateHTML,g as generateDocs,b as extractDocumentation,h as createDocsGenerator};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as z}from"./chunk-
|
|
2
|
+
import{tb as z}from"./chunk-9a6yn7sv.js";function C(F={}){let{preBuild:H=!1,postBuild:I=!0,onGenerated:J,onError:w,...q}=F,y=async()=>{try{let j=await z(q);J?.(j)}catch(j){let k=j instanceof Error?j:Error(String(j));if(w?.(k),!w)console.error("[dtsx] Generation failed:",k.message)}};return{name:"dtsx",async setup(j){let k=j.config;if(!q.entrypoints&&k.entrypoints)q.entrypoints=k.entrypoints;if(!q.outdir&&k.outdir)q.outdir=k.outdir;if(!q.root&&k.root)q.root=k.root;if(H)j.onStart(async()=>{await y()});if(I){let v=!1;j.onLoad({filter:/.*/},async(K)=>{if(!v)queueMicrotask(async()=>{if(!v)v=!0,await y()});return})}}}}var M=C,P=C;
|
|
3
3
|
export{C as fa,M as ga,P as ha};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ec as F}from"./chunk-
|
|
2
|
+
import{ec as F}from"./chunk-wfevdmvd.js";import{Bc as N}from"./chunk-begk3j01.js";import{existsSync as H,readFileSync as P,unwatchFile as T}from"fs";var k;((J)=>{J[J.Error=1]="Error";J[J.Warning=2]="Warning";J[J.Information=3]="Information";J[J.Hint=4]="Hint"})(k||={});var L;((O)=>{O[O.File=1]="File";O[O.Module=2]="Module";O[O.Namespace=3]="Namespace";O[O.Package=4]="Package";O[O.Class=5]="Class";O[O.Method=6]="Method";O[O.Property=7]="Property";O[O.Field=8]="Field";O[O.Constructor=9]="Constructor";O[O.Enum=10]="Enum";O[O.Interface=11]="Interface";O[O.Function=12]="Function";O[O.Variable=13]="Variable";O[O.Constant=14]="Constant";O[O.String=15]="String";O[O.Number=16]="Number";O[O.Boolean=17]="Boolean";O[O.Array=18]="Array";O[O.Object=19]="Object";O[O.Key=20]="Key";O[O.Null=21]="Null";O[O.EnumMember=22]="EnumMember";O[O.Struct=23]="Struct";O[O.Event=24]="Event";O[O.Operator=25]="Operator";O[O.TypeParameter=26]="TypeParameter"})(L||={});var M;((Q)=>{Q[Q.Text=1]="Text";Q[Q.Method=2]="Method";Q[Q.Function=3]="Function";Q[Q.Constructor=4]="Constructor";Q[Q.Field=5]="Field";Q[Q.Variable=6]="Variable";Q[Q.Class=7]="Class";Q[Q.Interface=8]="Interface";Q[Q.Module=9]="Module";Q[Q.Property=10]="Property";Q[Q.Unit=11]="Unit";Q[Q.Value=12]="Value";Q[Q.Enum=13]="Enum";Q[Q.Keyword=14]="Keyword";Q[Q.Snippet=15]="Snippet";Q[Q.Color=16]="Color";Q[Q.File=17]="File";Q[Q.Reference=18]="Reference";Q[Q.Folder=19]="Folder";Q[Q.EnumMember=20]="EnumMember";Q[Q.Constant=21]="Constant";Q[Q.Struct=22]="Struct";Q[Q.Event=23]="Event";Q[Q.Operator=24]="Operator";Q[Q.TypeParameter=25]="TypeParameter"})(M||={});var v;((A)=>{A[A.Text=1]="Text";A[A.Read=2]="Read";A[A.Write=3]="Write"})(v||={});class E{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(j){return this.rootUri=j.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(j){let{uri:z,text:G,version:A}=j.textDocument;this.updateDocument(z,G,A)}didChange(j){let{uri:z,version:G}=j.textDocument,A=j.contentChanges[0]?.text||"";this.updateDocument(z,A,G)}didClose(j){let z=j.textDocument.uri;if(this.documents.delete(z),this.watchers.get(z))T(this.uriToPath(z)),this.watchers.delete(z)}updateDocument(j,z,G){let A=this.uriToPath(j),J=F(z,A,!0);this.documents.set(j,{content:z,version:G,declarations:J})}getDiagnostics(j){let z=this.documents.get(j);if(!z)return[];let G=[];for(let A of z.declarations){if(A.isExported&&A.kind==="variable"&&!A.typeAnnotation)G.push({range:this.getDeclarationRange(A,z.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${A.name}' should have an explicit type annotation for better declaration generation`});if(A.typeAnnotation==="any"||A.returnType==="any")G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(A.kind==="function"&&A.isExported&&!A.returnType)G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${A.name}' should have an explicit return type for better declaration generation`})}return G}hover(j){let z=this.documents.get(j.textDocument.uri);if(!z)return null;let{line:G,character:A}=j.position,R=z.content.split(`
|
|
3
3
|
`)[G]||"",U=R.slice(0,A).match(/[\w$]+$/),V=R.slice(A).match(/^[\w$]+/);if(!U&&!V)return null;let X=(U?.[0]||"")+(V?.[0]||""),Y=z.declarations.find((W)=>W.name===X);if(!Y)return null;let B=`\`\`\`typescript
|
|
4
4
|
${this.buildSignature(Y)}
|
|
5
5
|
\`\`\``;if(Y.leadingComments&&Y.leadingComments.length>0){let q=Y.leadingComments.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
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
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
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
5
|
${W.join(`,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-rw6j20e2.js";var e="@stacksjs/dtsx",i="module",n="0.9.
|
|
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};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ec as K}from"./chunk-
|
|
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
3
|
`).map((X)=>X.replace(/^\s*\*\s?/,"")).join(`
|
|
4
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
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>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
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};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as C}from"./chunk-
|
|
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
3
|
export{y as ia,L as ja,M as ka,P as la};
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as b9,b as P9,c as x9}from"../chunk-
|
|
2
|
+
import{a as b9,b as P9,c as x9}from"../chunk-ggmn4a8c.js";import{d as O8,e as A8,f as G8,g as B8,h as z8,i as N8,j as j8,k as R8}from"../chunk-xyctgc6x.js";import{l as m9,m as p9,n as d9,o as c9,p as l9,q as o9,r as s9}from"../chunk-1bav913n.js";import{s as w9,t as I9,u as T9,v as S9,w as k9,x as C9,y as v9}from"../chunk-w9abhtgg.js";import{A as I6,B as T6,C as S6,D as k6,E as C6,F as v6,G as b6,H as P6,z as w6}from"../chunk-jm5ywn4e.js";import{I as f8,J as u8,K as m8,L as p8,M as d8,N as c8,O as l8,P as o8}from"../chunk-d0p3jzwb.js";import{Q as x6,R as y6,S as h6,T as g6,U as f6,V as u6,W as m6,X as p6,Y as d6}from"../chunk-r1ywapeb.js";import{$ as g9,Z as y9,_ as h9,aa as f9,ba as u9}from"../chunk-6qv7p9sg.js";import{$a as h8,Aa as M6,Ba as c6,Ca as l6,Da as o6,Ea as QX,Fa as s6,Ga as a6,Ha as i6,Ia as n6,Ja as r6,Ka as t6,La as F8,Ma as D8,Na as E8,Oa as L8,Pa as M8,Qa as w8,Ra as I8,Sa as T8,Ta as S8,Ua as k8,Va as C8,Wa as v8,Xa as b8,Ya as P8,Za as x8,_a as y8,ab as g8,bb as s8,cb as a8,db as i8,eb as n8,fb as r8,gb as t8,hb as mX,ib as e8,jb as X9,kb as Z9,lb as A9,mb as G9,nb as B9,ob as z9,pb as N9,qb as j9,rb as R9,sb as F9,tb as E9,ua as j6,ub as L9,va as R6,vb as M9,wa as F6,xa as D6,ya as E6,za as L6}from"../chunk-9a6yn7sv.js";import{$b as _6,Ab as v4,Bb as gZ,Cb as fZ,Db as p4,Eb as d4,Fb as c4,Gb as l4,Hb as o4,Ib as s4,Jb as a4,Kb as i4,Lb as n4,Mb as r4,Nb as t4,Ob as e4,Pb as X6,Qb as Z6,Rb as $6,Sb as J6,Tb as Q6,Ub as q6,Vb as Y6,Wb as V6,Xb as W6,Yb as K6,Zb as H6,_b as U6,ac as O6,bc as A6,cc as G6,dc as B6,ec as EX,fc as z6,gc as N6,wb as T4,xb as S4,yb as k4,zb as C4}from"../chunk-wfevdmvd.js";import{hc as SZ}from"../chunk-p1d09y82.js";import{ic as D9}from"../chunk-hrmnrn4p.js";import"../chunk-74j5mydx.js";import"../chunk-rnt0wkrk.js";import{Ac as O9,Bc as LX,oc as uZ,pc as $9,qc as J9,rc as Q9,sc as q9,tc as Y9,uc as V9,vc as W9,wc as K9,xc as H9,yc as U9,zc as _9}from"../chunk-begk3j01.js";import{Ec as b4,Fc as P4,Gc as x4,Hc as y4,Ic as h4,Jc as hZ,Kc as g4,Lc as f4,Mc as u4,Nc as m4}from"../chunk-xnq1xw73.js";import{Oc as V8,Pc as W8,Qc as K8,Rc as H8,Sc as U8,Tc as _8}from"../chunk-f18nyrrb.js";import{$c as Y8,Uc as e6,Vc as X8,Wc as Z8,Xc as $8,Yc as J8,Zc as Q8,_c as q8}from"../chunk-57agx6g8.js";import{ad as TZ,cd as v}from"../chunk-rw6j20e2.js";function C0(X){if(!X||typeof X!=="string")throw Error("Invalid file path: must be a non-empty string");return X}function v0(X){if(!X||typeof X!=="string")throw Error("Invalid directory path: must be a non-empty string");return X}function b0(X){if(!X||typeof X!=="string")throw Error("Invalid glob pattern: must be a non-empty string");return X}function P0(X){if(typeof X!=="string")throw TypeError("Invalid source code: must be a string");return X}function x0(X){if(typeof X!=="string")throw TypeError("Invalid DTS content: must be a string");return X}function y0(X){if(!X||typeof X!=="string")throw Error("Invalid module specifier: must be a non-empty string");return X}function h0(X){if(!X||typeof X!=="string")throw Error("Invalid type name: must be a non-empty string");if(!["string","number","boolean","symbol","bigint","undefined","null","void","never","any","unknown","object"].includes(X)&&!/^[A-Z_$]/.test(X));return X}function g0(X){if(!X||typeof X!=="string")throw Error("Invalid declaration name: must be a non-empty string");return X}function f0(X){if(!X||typeof X!=="string")throw Error("Invalid absolute path: must be a non-empty string");if(!X.startsWith("/")&&!/^[A-Z]:/i.test(X))throw Error("Invalid absolute path: must start with / or drive letter");return X}function u0(X){if(!X||typeof X!=="string")throw Error("Invalid relative path: must be a non-empty string");if(X.startsWith("/")||/^[A-Z]:/i.test(X))throw Error("Invalid relative path: must not be absolute");return X}function m0(X){if(typeof X!=="string")throw TypeError("Invalid JSON string: must be a string");try{JSON.parse(X)}catch{throw Error("Invalid JSON string: must be valid JSON")}return X}function p0(X,Z){return typeof X==="string"||typeof X==="number"}function d0(X){return X}var c0={join(X,...Z){let{join:$}=v("path");return $(X,...Z)},dirname(X){let{dirname:Z}=v("path");return Z(X)},basename(X){let{basename:Z}=v("path");return Z(X)},resolve(...X){let{resolve:Z}=v("path");return Z(...X)},isAbsolute(X){let{isAbsolute:Z}=v("path");return Z(X)},relative(X,Z){let{relative:$}=v("path");return $(X,Z)}};function nX(X,Z){let $=X.length,J=Z.length,Q=Array.from({length:$+1},()=>Array(J+1).fill(0));for(let q=1;q<=$;q++)for(let Y=1;Y<=J;Y++)if(X[q-1]===Z[Y-1])Q[q][Y]=Q[q-1][Y-1]+1;else Q[q][Y]=Math.max(Q[q-1][Y],Q[q][Y-1]);return Q}function rX(X,Z,$,J,Q){let q=[];while(J>0||Q>0)if(J>0&&Q>0&&Z[J-1]===$[Q-1])q.unshift({op:"equal",oldIdx:J-1,newIdx:Q-1,line:Z[J-1]}),J--,Q--;else if(Q>0&&(J===0||X[J][Q-1]>=X[J-1][Q]))q.unshift({op:"add",newIdx:Q-1,line:$[Q-1]}),Q--;else if(J>0)q.unshift({op:"remove",oldIdx:J-1,line:Z[J-1]}),J--;return q}function JX(X,Z){let $=X;if(Z.ignoreWhitespace)$=$.replace(/\s+/g," ").trim();return $}function d(X,Z,$,J={}){let{context:Q=3,ignoreWhitespace:q=!1,ignoreBlankLines:Y=!1}=J,V=X.split(`
|
|
3
3
|
`),W=Z.split(`
|
|
4
4
|
`);if(V[V.length-1]==="")V.pop();if(W[W.length-1]==="")W.pop();let K=V.map((F)=>JX(F,{ignoreWhitespace:q})),U=W.map((F)=>JX(F,{ignoreWhitespace:q})),O=K,H=U,A=V.map((F,w)=>w),_=W.map((F,w)=>w);if(Y)O=[],H=[],A=[],_=[],K.forEach((F,w)=>{if(F.trim())O.push(F),A.push(w)}),U.forEach((F,w)=>{if(F.trim())H.push(F),_.push(w)});let G=nX(O,H),B=rX(G,O,H,O.length,H.length),z=B.every((F)=>F.op==="equal"),j=0,N=0,R=0;for(let F of B)if(F.op==="add")j++;else if(F.op==="remove")N++;else R++;let k=tX(B,V,W,A,_,Q);return{filePath:$,identical:z,hunks:k,stats:{additions:j,deletions:N,unchanged:R},oldContent:X,newContent:Z}}function tX(X,Z,$,J,Q,q){let Y=[],V=[];if(X.forEach((U,O)=>{if(U.op!=="equal")V.push(O)}),V.length===0)return Y;let W=[],K=[V[0]];for(let U=1;U<V.length;U++)if(V[U]-V[U-1]<=q*2+1)K.push(V[U]);else W.push(K),K=[V[U]];W.push(K);for(let U of W){let O=Math.max(0,U[0]-q),H=Math.min(X.length-1,U[U.length-1]+q),A=X.slice(O,H+1),_=[],G=1,B=1,z=0,j=0;for(let N=0;N<O;N++){let R=X[N];if(R.op==="equal"||R.op==="remove")G++;if(R.op==="equal"||R.op==="add")B++}for(let N of A)if(N.op==="equal")_.push(` ${N.line}`),z++,j++;else if(N.op==="remove")_.push(`-${N.line}`),z++;else if(N.op==="add")_.push(`+${N.line}`),j++;Y.push({operation:"equal",lines:_,oldStart:G,oldCount:z,newStart:B,newCount:j})}return Y}function s0(X){if(X.identical)return"";let Z=[];Z.push(`--- a/${X.filePath}`),Z.push(`+++ b/${X.filePath}`);for(let $ of X.hunks)Z.push(`@@ -${$.oldStart},${$.oldCount} +${$.newStart},${$.newCount} @@`),Z.push(...$.lines);return Z.join(`
|
|
5
5
|
`)}function eX(X){if(X.identical)return`\x1B[32m\u2713 ${X.filePath} (unchanged)\x1B[0m`;let Z=[],$=`+${X.stats.additions} -${X.stats.deletions}`;Z.push(`\x1B[1m${X.filePath}\x1B[0m \x1B[90m(${$})\x1B[0m`),Z.push("");for(let J of X.hunks){Z.push(`\x1B[36m@@ -${J.oldStart},${J.oldCount} +${J.newStart},${J.newCount} @@\x1B[0m`);for(let Q of J.lines)if(Q.startsWith("+"))Z.push(`\x1B[32m${Q}\x1B[0m`);else if(Q.startsWith("-"))Z.push(`\x1B[31m${Q}\x1B[0m`);else Z.push(`\x1B[90m${Q}\x1B[0m`);Z.push("")}return Z.join(`
|
package/dist/src/plugins/bun.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fa as a,ga as b,ha as c}from"../../chunk-
|
|
2
|
+
import{fa as a,ga as b,ha as c}from"../../chunk-n28rjf9h.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{a as dts,c as default,b as bunDts};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ia as a,ja as b,ka as c,la as d}from"../../chunk-
|
|
2
|
+
import{ia as a,ja as b,ka as c,la as d}from"../../chunk-ywd4k4hn.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 esbuildDts,a as dtsx,c as dts,d as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ca as s}from"../../chunk-
|
|
2
|
+
import{ca as s}from"../../chunk-cmenkst5.js";import{fa as t}from"../../chunk-n28rjf9h.js";import{ia as i,ka as p}from"../../chunk-ywd4k4hn.js";import{ma as e,oa as u}from"../../chunk-3d18fhrg.js";import{qa as l,ra as a,sa as n}from"../../chunk-4qpg9xnt.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{n as webpackPlugin,a as webpackDts,s as viteDts,s as vite,u as tsupPlugin,e as tsupDts,e as tsup,p as esbuildPlugin,i as esbuildDts,i as esbuild,t as bunDts,t as bun,l as DtsxWebpackPlugin};
|
package/dist/src/plugins/tsup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ma as a,na as b,oa as c,pa as d}from"../../chunk-
|
|
2
|
+
import{ma as a,na as b,oa as c,pa as d}from"../../chunk-3d18fhrg.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 tsupDts,a as dtsxPlugin,c as dts,d as default};
|
package/dist/src/plugins/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ca as a,da as b,ea as c}from"../../chunk-
|
|
2
|
+
import{ca as a,da as b,ea as c}from"../../chunk-cmenkst5.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 viteDts,a as dts,c as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qa as a,ra as b,sa as c,ta as d}from"../../chunk-
|
|
2
|
+
import{qa as a,ra as b,sa as c,ta as d}from"../../chunk-4qpg9xnt.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 dtsxWebpack,c as dts,d as default,a as DtsxWebpackPlugin};
|
package/dist/type-mappings.d.ts
CHANGED
|
@@ -23,37 +23,13 @@ export declare const strictTypeMapper: TypeMapper;
|
|
|
23
23
|
* @defaultValue
|
|
24
24
|
* ```ts
|
|
25
25
|
* {
|
|
26
|
-
* /**
|
|
27
|
-
* * Make all types readonly
|
|
28
|
-
* */
|
|
29
26
|
* makeReadonly: (type: string) => any,
|
|
30
|
-
* /**
|
|
31
|
-
* * Make type nullable
|
|
32
|
-
* */
|
|
33
27
|
* makeNullable: (type: string) => any,
|
|
34
|
-
* /**
|
|
35
|
-
* * Make type optional (add undefined)
|
|
36
|
-
* */
|
|
37
28
|
* makeOptional: (type: string) => any,
|
|
38
|
-
* /**
|
|
39
|
-
* * Remove null/undefined from type
|
|
40
|
-
* */
|
|
41
29
|
* makeRequired: (type: string) => any,
|
|
42
|
-
* /**
|
|
43
|
-
* * Wrap in Promise
|
|
44
|
-
* */
|
|
45
30
|
* promisify: (type: string) => any,
|
|
46
|
-
* /**
|
|
47
|
-
* * Unwrap Promise
|
|
48
|
-
* */
|
|
49
31
|
* unpromisify: (type: string) => any,
|
|
50
|
-
* /**
|
|
51
|
-
* * Convert to array type
|
|
52
|
-
* */
|
|
53
32
|
* arrayify: (type: string) => any,
|
|
54
|
-
* /**
|
|
55
|
-
* * Unwrap array type
|
|
56
|
-
* */
|
|
57
33
|
* unarrayify: (type: string) => any
|
|
58
34
|
* }
|
|
59
35
|
* ```
|
package/package.json
CHANGED
package/dist/chunk-0kmfaaz6.js
DELETED
package/dist/chunk-dk2vv0np.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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};
|
package/dist/chunk-pyxbb193.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{tb as b,ub as c,vb as d}from"./chunk-3mxzfgcv.js";import"./chunk-9mjc7ddv.js";import"./chunk-p1d09y82.js";import{ic as a}from"./chunk-1mm3t0nr.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-j22v8wfe.js";import"./chunk-dk2vv0np.js";import"./chunk-f18nyrrb.js";import"./chunk-57agx6g8.js";import"./chunk-rw6j20e2.js";export{d as watch,a as processSource,c as processFile,b as generate};
|