@dtsx/dtsx 0.11.40 → 0.11.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +1 -1
- package/dist/{chunk-31kbs9mj.js → chunk-00m9cbar.js} +3 -3
- package/dist/{chunk-jswvvjkr.js → chunk-01zsk2q8.js} +3 -3
- package/dist/{chunk-tm2j0feh.js → chunk-06jp6gah.js} +2 -2
- package/dist/{chunk-3jjrn16z.js → chunk-13tjnp25.js} +3 -3
- package/dist/{chunk-ka8mbyjb.js → chunk-1vc3eend.js} +2 -2
- package/dist/{chunk-zk55g2cb.js → chunk-298wqs3n.js} +1 -1
- package/dist/{chunk-45fpbdw3.js → chunk-3jtwkmfx.js} +1 -1
- package/dist/chunk-3qx4ys4v.js +38 -0
- package/dist/{chunk-8dvxjzhy.js → chunk-3r9dptyy.js} +2 -2
- package/dist/{chunk-w26wgqh8.js → chunk-537hj5pj.js} +1 -1
- package/dist/{chunk-2dstvjpv.js → chunk-54d8mt4c.js} +1 -1
- package/dist/{chunk-js4m0y2m.js → chunk-5ezj0r3g.js} +1 -1
- package/dist/{chunk-p4hf9bwj.js → chunk-6vz1grv8.js} +3 -3
- package/dist/{chunk-8zvjkzsv.js → chunk-7387m006.js} +2 -2
- package/dist/{chunk-kccc6p2t.js → chunk-73qsp464.js} +1 -1
- package/dist/{chunk-0c03j9eq.js → chunk-7g0hjhqy.js} +1 -1
- package/dist/chunk-7khy25x0.js +3 -0
- package/dist/{chunk-ayyb1jpe.js → chunk-85d82vn3.js} +2 -2
- package/dist/{chunk-hvy1zvk6.js → chunk-8wk7nw3c.js} +1 -1
- package/dist/{chunk-jfygtm4r.js → chunk-a2dn9j88.js} +1 -1
- package/dist/{chunk-phwfth21.js → chunk-asqkc0bw.js} +2 -2
- package/dist/{chunk-nqgfrehj.js → chunk-bre2x1bd.js} +1 -1
- package/dist/{chunk-nd0sbh5r.js → chunk-btwfkzt5.js} +3 -3
- package/dist/{chunk-t6ds7drh.js → chunk-cyfnxk8d.js} +2 -2
- package/dist/{chunk-a3vfqhnp.js → chunk-cywe5sgm.js} +1 -1
- package/dist/{chunk-3dweac93.js → chunk-eatp44nf.js} +1 -1
- package/dist/{chunk-bc7ahgxz.js → chunk-ej7jt519.js} +2 -2
- package/dist/{chunk-jyq39qjt.js → chunk-f2yhf6gj.js} +2 -2
- package/dist/{chunk-0m1wt3db.js → chunk-fv3x086v.js} +2 -2
- package/dist/chunk-g0dxj89b.js +7 -0
- package/dist/{chunk-dpcvehxp.js → chunk-g4dpvmfy.js} +1 -1
- package/dist/{chunk-3mcz22q8.js → chunk-gc7y4wav.js} +4 -4
- package/dist/{chunk-axj2w6hp.js → chunk-gt5k2mff.js} +1 -1
- package/dist/{chunk-zn2gvwve.js → chunk-gv9brtta.js} +3 -3
- package/dist/{chunk-qrwst9bb.js → chunk-j0p7bwj6.js} +2 -2
- package/dist/{chunk-zbe06f63.js → chunk-jf8mxazb.js} +1 -1
- package/dist/{chunk-y3x7p6jf.js → chunk-k9695p66.js} +1 -1
- package/dist/{chunk-g3zt5h6d.js → chunk-kdnqedyb.js} +2 -2
- package/dist/{chunk-yde8rmfm.js → chunk-msr5zymd.js} +8 -8
- package/dist/{chunk-y4wykrya.js → chunk-pd30356m.js} +3 -3
- package/dist/{chunk-aak9xzy7.js → chunk-prst4szw.js} +2 -2
- package/dist/{chunk-z6mpxpxt.js → chunk-q4fhsthj.js} +1 -1
- package/dist/{chunk-6epjc5rj.js → chunk-q4gxj6qk.js} +1 -1
- package/dist/{chunk-7ynrmx5b.js → chunk-q76b61w9.js} +4 -4
- package/dist/{chunk-hgscwj1y.js → chunk-qqjbaqm6.js} +2 -2
- package/dist/{chunk-sgcne5bb.js → chunk-qzb5pswc.js} +2 -2
- package/dist/{chunk-ee109s3r.js → chunk-r27pfg4r.js} +6 -6
- package/dist/{chunk-kv0bpgyw.js → chunk-s0sretav.js} +1 -1
- package/dist/{chunk-5yjyb87w.js → chunk-t76sqybd.js} +1 -1
- package/dist/{chunk-996gqrz6.js → chunk-t8cgznk6.js} +2 -2
- package/dist/{chunk-fay5vymp.js → chunk-twrcd0q6.js} +2 -2
- package/dist/{chunk-yzdh207n.js → chunk-vjtcxr3q.js} +4 -4
- package/dist/chunk-w3zqfm8a.js +3 -0
- package/dist/{chunk-jhpfmjnx.js → chunk-x4qkjqda.js} +1 -1
- package/dist/{chunk-ybzz1jg7.js → chunk-xzw0p4nq.js} +2 -2
- package/dist/{chunk-ex03kbwr.js → chunk-ywv56grs.js} +1 -1
- package/dist/{chunk-vgmnxnjf.js → chunk-zbyvnsny.js} +11 -11
- package/dist/{chunk-7j4cgkb4.js → chunk-zf96k060.js} +2 -2
- package/dist/{chunk-vbzchjvq.js → chunk-zy5jxjmg.js} +1 -1
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.js +1 -1
- package/dist/src/branded-types.js +1 -1
- package/dist/src/bundle-linker.js +1 -1
- package/dist/src/bundler.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/call-signatures.js +1 -1
- package/dist/src/circular.js +1 -1
- package/dist/src/compat.js +1 -1
- package/dist/src/computed-keys.js +1 -1
- package/dist/src/declaration-project.js +1 -1
- package/dist/src/declaration-publication.js +1 -1
- package/dist/src/declaration-references.js +1 -1
- package/dist/src/diff.js +1 -1
- package/dist/src/docs.js +1 -1
- package/dist/src/enum-declarations.js +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/extractor/extract.js +1 -1
- package/dist/src/extractor/scanner.js +1 -1
- package/dist/src/extractor.js +1 -1
- package/dist/src/formatter.js +1 -1
- package/dist/src/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/lsp.js +1 -1
- package/dist/src/memory.js +1 -1
- package/dist/src/module-graph.js +1 -1
- package/dist/src/module-references.js +1 -1
- package/dist/src/native-checker.js +1 -1
- package/dist/src/native-extractor.js +1 -1
- package/dist/src/native-generation.js +1 -1
- package/dist/src/native-project.js +1 -1
- package/dist/src/optimizer.js +1 -1
- package/dist/src/parallel-processor.js +1 -1
- package/dist/src/parameters.js +1 -1
- package/dist/src/parser.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/tsdown.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/src/plugins.js +1 -1
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/declarations.js +1 -1
- package/dist/src/processor/import-usage.js +1 -1
- package/dist/src/processor/imports.js +1 -1
- package/dist/src/processor/index.js +1 -1
- package/dist/src/processor/type-inference.js +1 -1
- package/dist/src/processor.js +1 -1
- package/dist/src/profiling.js +1 -1
- package/dist/src/return-type-scope.js +1 -1
- package/dist/src/source-cache.js +1 -1
- package/dist/src/sourcemap.js +1 -1
- package/dist/src/transformers.js +1 -1
- package/dist/src/tsconfig.js +1 -1
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/watcher.js +1 -1
- package/dist/src/worker-thread.js +1 -1
- package/dist/src/workspace.js +1 -1
- package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
- package/native/darwin-x64/libzig-dtsx.dylib +0 -0
- package/native/freebsd-x64/libzig-dtsx.so +0 -0
- package/native/linux-arm64/libzig-dtsx.so +0 -0
- package/native/linux-x64/libzig-dtsx.so +0 -0
- package/native/windows-x64/zig-dtsx.dll +0 -0
- package/package.json +1 -1
- package/dist/chunk-7z8pykqp.js +0 -3
- package/dist/chunk-c7a07a26.js +0 -7
- package/dist/chunk-qq5x44y9.js +0 -38
- package/dist/chunk-vf8jmdsp.js +0 -3
package/dist/bin/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import n from"process";var U=n.argv[2];if(U==="stdin"||U==="emit"||U==="--project"){if(U==="stdin"){let{processSource:e}=await import("../src/process-source.js"),t=[];for await(let f of n.stdin)t.push(f);let o=Buffer.concat(t).toString("utf-8");if(o.trim())n.stdout.write(e(o,"stdin.ts")),n.stdout.write(`
|
|
4
4
|
`)}else if(U==="--project"){let{readdirSync:e,readFileSync:t,writeFileSync:o,mkdirSync:f}=await import("fs"),p=typeof globalThis.Bun<"u",a=p?globalThis.Bun:null,l=n.argv.slice(3),y="",w="",h=!1;for(let s=0;s<l.length;s++)if(l[s]==="--outdir"&&l[s+1])w=l[s+1],s++;else if(l[s]==="--isolated-declarations")h=!0;else if(!y)y=l[s];f(w,{recursive:!0});let m=e(y).filter((s)=>s.endsWith(".ts")&&!s.endsWith(".d.ts")),i=m.length,u=Array(i),c=Array(i);for(let s=0;s<i;s++)u[s]=`${y}/${m[s]}`,c[s]=`${w}/${m[s].slice(0,-3)}.d.ts`;let g=["bun"],k=16777216,{nativeEngineAvailable:P}=await import("../src/native-engine.js"),x=!1;if(p&&i>=256&&!P()){let s=0;for(let E=0;E<i&&!x;E++)s+=a.file(u[E]).size,x=s>=k}let C=!1,b=null;if(x){let s=null;try{let{createWorkerPool:E,calculateOptimalBatchSize:L}=await import("../src/worker.js"),{cpus:I}=await import("os"),F=Math.max(1,I().length-1),T=Math.min(64,Math.max(8,L(i,F)*2)),d=i>=256,S=!0,W=i>=256;if(!d&&i>=256){b=Array(i);for(let j=0;j<i;j++)b[j]=a.file(u[j]).text()}let _=Math.ceil(i/T),X=Math.min(_,Math.max(2,F*2));s=E({maxWorkers:F,initialWorkers:F,recycleAfter:Math.max(100,_+1)}),await s.init();let Z=s,Y=0,q=Date.now(),ee=async()=>{for(;;){let j=Y++;if(j>=_)return;let M=j*T;if(M>=i)return;let G=Math.min(i,M+T)-M,z;if(W){let B=Array(G),A=Array(G),R;if(d)for(let v=0;v<G;v++){let O=M+v;B[v]=u[O],A[v]=c[O]}else{let v=Array(G);for(let O=0;O<G;O++){let J=M+O;B[O]=u[J],A[O]=c[J],v[O]=b?b[J]:a.file(u[J]).text()}R=await Promise.all(v)}z=await Z.submit({id:`batch-${q}-${j}`,type:"process-batch",filePath:B[0]||"",filePaths:B,sources:R,outPaths:A,writeOutput:!0,config:{keepComments:!0,importOrder:g,isolatedDeclarations:h}})}else{let B=Array(G);if(d)for(let A=0;A<G;A++){let R=M+A;B[A]={filePath:u[R],outPath:c[R]}}else{let A=Array(G);for(let v=0;v<G;v++){let O=M+v;A[v]=b?b[O]:a.file(u[O]).text()}let R=await Promise.all(A);for(let v=0;v<G;v++){let O=M+v;B[v]={filePath:u[O],sourceCode:R[v],outPath:c[O]}}}z=await Z.submit({id:`batch-${q}-${j}`,type:"process-batch",filePath:u[M]||"",files:B,writeOutput:!0,config:{keepComments:!0,importOrder:g,isolatedDeclarations:h}})}if(!z.success)throw Error(z.error||`Worker batch failed for ${u[M]}`);if(z.batchResults?.length){let B=z.batchResults[0];throw Error(B?.error||z.error||`Worker failed for ${u[M]}`)}}},H=[];for(let j=0;j<X;j++)H.push(ee());await Promise.all(H),C=!0}catch{C=!1}finally{if(s)await s.shutdown()}}if(!C){let{scanDeclarations:s}=await import("../src/extractor/scanner.js"),{processDeclarations:E}=await import("../src/processor.js"),{emitNatively:L}=await import("../src/process-source.js"),I=Array(i);if(p){let d=b?await Promise.all(b):await Promise.all(u.map((S)=>a.file(S).text()));for(let S=0;S<i;S++)I[S]=d[S]}else for(let d=0;d<i;d++)I[d]=t(u[d],"utf-8");let F=Array(i),T={filePath:"",sourceCode:"",declarations:[]};for(let d=0;d<i;d++){let S=L(I[d],m[d],!0,g,h);if(S!==null){F[d]=S;continue}let W=s(I[d],m[d],!0,h);T.filePath=m[d],T.sourceCode=I[d],T.declarations=W,F[d]=E(W,T,!0,g)}if(p){let d=Array(i);for(let S=0;S<i;S++)d[S]=a.write(c[S],F[S]);await Promise.all(d)}else for(let d=0;d<i;d++)o(c[d],F[d])}}else{let{processSource:e}=await import("../src/process-source.js"),{readFileSync:t,writeFileSync:o,mkdirSync:f}=await import("fs"),p=typeof globalThis.Bun<"u",a=p?globalThis.Bun:null,l=n.argv[3],y=p?await a.file(l).text():t(l,"utf-8"),w=n.argv[4];if(w){let{dirname:h}=await import("path");f(h(w),{recursive:!0});let m=`${e(y,l)}
|
|
5
5
|
`;if(p)await a.write(w,m);else o(w,m)}else n.stdout.write(e(y,l)),n.stdout.write(`
|
|
6
|
-
`)}n.exit(0)}var{resolve:N}=await import("path"),{CLI:te}=await import("../chunk-asws39qs.js"),{version:Q}=await import("../chunk-5yjyb87w.js"),{getConfig:oe}=await import("../src/config.js"),{generate:re,processSource:ne,watch:se}=await import("../src/generator.js"),D=new te("dtsx"),r={cwd:n.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};function V(e){if(e===void 0)return;let t=(Array.isArray(e)?e:[e]).flatMap((o)=>String(o).split(",")).map((o)=>o.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}D.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--clean","Clean output directory before generation",{default:r.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:r.tsconfigPath}).option("--module-specifier-mode <mode>","Declaration module specifiers: preserve or node").option("--verbose","Enable verbose logging",{default:r.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:r.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:r.dryRun}).option("--stats","Show statistics after generation",{default:r.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:r.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:r.outputFormat}).option("--progress","Show progress during generation",{default:r.progress}).option("--diff","Show diff of changes compared to existing files",{default:r.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:r.validate}).option("--parallel","Process files in parallel",{default:r.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:r.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 --entrypoints index.ts --entrypoints mime/index.ts --root src").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(e)=>{try{let t=N(e.cwd||r.cwd),o=await oe(t),f={entrypoints:V(e.entrypoints)??o.entrypoints??r.entrypoints,cwd:t,root:N(e.root||o.root||r.root),outdir:N(e.outdir||o.outdir||r.outdir),tsconfigPath:N(e.tsconfigPath||o.tsconfigPath||r.tsconfigPath),moduleSpecifierMode:e.moduleSpecifierMode??o.moduleSpecifierMode??r.moduleSpecifierMode,keepComments:e.keepComments??o.keepComments??r.keepComments,clean:e.clean??o.clean??r.clean,verbose:e.verbose??o.verbose??r.verbose,importOrder:V(e.importOrder)??o.importOrder??r.importOrder,dryRun:e.dryRun??o.dryRun??r.dryRun,stats:e.stats??o.stats??r.stats,continueOnError:e.continueOnError??o.continueOnError??r.continueOnError,logLevel:e.logLevel??o.logLevel??r.logLevel,exclude:e.exclude?e.exclude.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean)):o.exclude||r.exclude,outputFormat:e.outputFormat??o.outputFormat??r.outputFormat,progress:e.progress??o.progress??r.progress,diff:e.diff??o.diff??r.diff,validate:e.validate??o.validate??r.validate,parallel:e.parallel??o.parallel??r.parallel,concurrency:Number(e.concurrency)||o.concurrency||r.concurrency,declarationMap:e.declarationMap??o.declarationMap??!1,bundle:e.bundle??o.bundle??!1,bundleOutput:e.bundleOutput??o.bundleOutput??"index.d.ts",incremental:e.incremental??o.incremental??!1,cacheDir:o.cacheDir,clearCache:e.clearCache??!1,indentStyle:e.indentStyle??o.indentStyle??"spaces",indentSize:Number(e.indentSize)||o.indentSize||2,prettier:e.prettier??o.prettier??!1,plugins:o.plugins},p=await re(f);if(p.filesFailed>0&&p.filesGenerated===0)n.exit(1);else if(p.filesFailed>0)n.exit(2)}catch(t){if(console.error(`Error generating .d.ts files: ${t instanceof Error?t.message:String(t)}`),e.verbose&&t instanceof Error&&t.stack)console.error(t.stack);n.exit(1)}});D.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(e)=>{try{let t={entrypoints:V(e.entrypoints)??r.entrypoints,cwd:N(e.cwd||r.cwd),root:N(e.root||r.root),outdir:N(e.outdir||r.outdir),keepComments:e.keepComments??r.keepComments,exclude:e.exclude?e.exclude.flatMap((o)=>o.split(",").map((f)=>f.trim()).filter(Boolean)):r.exclude,logLevel:e.logLevel??r.logLevel};await se(t)}catch(t){console.error("Error in watch mode:",t),n.exit(1)}});D.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(e)=>{try{let t=[];for await(let a of n.stdin)t.push(a);let o=Buffer.concat(t).toString("utf-8");if(!o.trim())console.error("Error: No input received from stdin"),n.exit(1);let f=["bun"];if(e.importOrder){if(Array.isArray(e.importOrder))f=e.importOrder.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean));else if(typeof e.importOrder==="string")f=e.importOrder.split(",").map((a)=>a.trim()).filter(Boolean)}let p=ne(o,"stdin.ts",e.keepComments??!0,f);console.log(p)}catch(t){console.error("Error processing stdin:",t),n.exit(1)}});D.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(e)=>{try{let{optimizeFile:t}=await import("../src/optimizer.js"),{Glob:o}=await Promise.resolve(globalThis.Bun),{resolve:f,join:p,relative:a,dirname:l,basename:y}=await import("path"),{mkdirSync:w,copyFileSync:h,existsSync:m}=await import("fs"),i=n.cwd(),u=e.files||["**/*.d.ts"],c=[];for(let x of u){let C=new o(x);for await(let b of C.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(b.endsWith(".d.ts")&&!b.includes("node_modules"))c.push(b)}if(c.length===0)console.error("No .d.ts files found"),n.exit(1);console.log(`Optimizing ${c.length} declaration files...`);let g=0,k=0;for(let x of c){let C=x;if(e.outdir){let E=a(i,x);C=p(f(e.outdir),E);let L=l(C);if(!m(L))w(L,{recursive:!0});h(x,C)}let b=await t(C,{removeUnusedImports:e.removeUnusedImports??!0,deduplicateDeclarations:e.deduplicate??!0,mergeInterfaces:e.mergeInterfaces??!0,inlineSimpleTypes:e.inlineTypes??!1,removeEmptyInterfaces:e.removeEmpty??!0,sortDeclarations:e.sort??!1,sortImports:e.sortImports??!0,minify:e.minify??!1,removeComments:e.removeComments??!1});k+=b.originalSize,g+=b.savings;let s=a(i,C);console.log(` ${s}: ${b.originalSize}B -> ${b.optimizedSize}B (-${b.savingsPercent}%)`)}let P=k>0?Math.round(g/k*100):0;console.log(`
|
|
6
|
+
`)}n.exit(0)}var{resolve:N}=await import("path"),{CLI:te}=await import("../chunk-asws39qs.js"),{version:Q}=await import("../chunk-t76sqybd.js"),{getConfig:oe}=await import("../src/config.js"),{generate:re,processSource:ne,watch:se}=await import("../src/generator.js"),D=new te("dtsx"),r={cwd:n.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};function V(e){if(e===void 0)return;let t=(Array.isArray(e)?e:[e]).flatMap((o)=>String(o).split(",")).map((o)=>o.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}D.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--clean","Clean output directory before generation",{default:r.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:r.tsconfigPath}).option("--module-specifier-mode <mode>","Declaration module specifiers: preserve or node").option("--verbose","Enable verbose logging",{default:r.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:r.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:r.dryRun}).option("--stats","Show statistics after generation",{default:r.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:r.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:r.outputFormat}).option("--progress","Show progress during generation",{default:r.progress}).option("--diff","Show diff of changes compared to existing files",{default:r.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:r.validate}).option("--parallel","Process files in parallel",{default:r.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:r.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 --entrypoints index.ts --entrypoints mime/index.ts --root src").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(e)=>{try{let t=N(e.cwd||r.cwd),o=await oe(t),f={entrypoints:V(e.entrypoints)??o.entrypoints??r.entrypoints,cwd:t,root:N(e.root||o.root||r.root),outdir:N(e.outdir||o.outdir||r.outdir),tsconfigPath:N(e.tsconfigPath||o.tsconfigPath||r.tsconfigPath),moduleSpecifierMode:e.moduleSpecifierMode??o.moduleSpecifierMode??r.moduleSpecifierMode,keepComments:e.keepComments??o.keepComments??r.keepComments,clean:e.clean??o.clean??r.clean,verbose:e.verbose??o.verbose??r.verbose,importOrder:V(e.importOrder)??o.importOrder??r.importOrder,dryRun:e.dryRun??o.dryRun??r.dryRun,stats:e.stats??o.stats??r.stats,continueOnError:e.continueOnError??o.continueOnError??r.continueOnError,logLevel:e.logLevel??o.logLevel??r.logLevel,exclude:e.exclude?e.exclude.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean)):o.exclude||r.exclude,outputFormat:e.outputFormat??o.outputFormat??r.outputFormat,progress:e.progress??o.progress??r.progress,diff:e.diff??o.diff??r.diff,validate:e.validate??o.validate??r.validate,parallel:e.parallel??o.parallel??r.parallel,concurrency:Number(e.concurrency)||o.concurrency||r.concurrency,declarationMap:e.declarationMap??o.declarationMap??!1,bundle:e.bundle??o.bundle??!1,bundleOutput:e.bundleOutput??o.bundleOutput??"index.d.ts",incremental:e.incremental??o.incremental??!1,cacheDir:o.cacheDir,clearCache:e.clearCache??!1,indentStyle:e.indentStyle??o.indentStyle??"spaces",indentSize:Number(e.indentSize)||o.indentSize||2,prettier:e.prettier??o.prettier??!1,plugins:o.plugins},p=await re(f);if(p.filesFailed>0&&p.filesGenerated===0)n.exit(1);else if(p.filesFailed>0)n.exit(2)}catch(t){if(console.error(`Error generating .d.ts files: ${t instanceof Error?t.message:String(t)}`),e.verbose&&t instanceof Error&&t.stack)console.error(t.stack);n.exit(1)}});D.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:r.cwd}).option("--root <path>","Root directory of the project",{default:r.root}).option("--entrypoints <files>",`Entry point files; repeat the flag or comma-separate (default: ${r.entrypoints?.join(",")})`,{type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:r.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:r.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:r.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:r.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(e)=>{try{let t={entrypoints:V(e.entrypoints)??r.entrypoints,cwd:N(e.cwd||r.cwd),root:N(e.root||r.root),outdir:N(e.outdir||r.outdir),keepComments:e.keepComments??r.keepComments,exclude:e.exclude?e.exclude.flatMap((o)=>o.split(",").map((f)=>f.trim()).filter(Boolean)):r.exclude,logLevel:e.logLevel??r.logLevel};await se(t)}catch(t){console.error("Error in watch mode:",t),n.exit(1)}});D.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(e)=>{try{let t=[];for await(let a of n.stdin)t.push(a);let o=Buffer.concat(t).toString("utf-8");if(!o.trim())console.error("Error: No input received from stdin"),n.exit(1);let f=["bun"];if(e.importOrder){if(Array.isArray(e.importOrder))f=e.importOrder.flatMap((a)=>a.split(",").map((l)=>l.trim()).filter(Boolean));else if(typeof e.importOrder==="string")f=e.importOrder.split(",").map((a)=>a.trim()).filter(Boolean)}let p=ne(o,"stdin.ts",e.keepComments??!0,f);console.log(p)}catch(t){console.error("Error processing stdin:",t),n.exit(1)}});D.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(e)=>{try{let{optimizeFile:t}=await import("../src/optimizer.js"),{Glob:o}=await Promise.resolve(globalThis.Bun),{resolve:f,join:p,relative:a,dirname:l,basename:y}=await import("path"),{mkdirSync:w,copyFileSync:h,existsSync:m}=await import("fs"),i=n.cwd(),u=e.files||["**/*.d.ts"],c=[];for(let x of u){let C=new o(x);for await(let b of C.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(b.endsWith(".d.ts")&&!b.includes("node_modules"))c.push(b)}if(c.length===0)console.error("No .d.ts files found"),n.exit(1);console.log(`Optimizing ${c.length} declaration files...`);let g=0,k=0;for(let x of c){let C=x;if(e.outdir){let E=a(i,x);C=p(f(e.outdir),E);let L=l(C);if(!m(L))w(L,{recursive:!0});h(x,C)}let b=await t(C,{removeUnusedImports:e.removeUnusedImports??!0,deduplicateDeclarations:e.deduplicate??!0,mergeInterfaces:e.mergeInterfaces??!0,inlineSimpleTypes:e.inlineTypes??!1,removeEmptyInterfaces:e.removeEmpty??!0,sortDeclarations:e.sort??!1,sortImports:e.sortImports??!0,minify:e.minify??!1,removeComments:e.removeComments??!1});k+=b.originalSize,g+=b.savings;let s=a(i,C);console.log(` ${s}: ${b.originalSize}B -> ${b.optimizedSize}B (-${b.savingsPercent}%)`)}let P=k>0?Math.round(g/k*100):0;console.log(`
|
|
7
7
|
Total: ${k}B -> ${k-g}B (-${P}%)`)}catch(t){console.error("Error optimizing files:",t),n.exit(1)}});D.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(e)=>{try{let{generateDocs:t}=await import("../src/docs.js"),{Glob:o}=await Promise.resolve(globalThis.Bun),{resolve:f}=await import("path"),p=f(e.root||"./src"),a=new o("**/*.ts"),l=[];for await(let y of a.scan({cwd:p,absolute:!0,onlyFiles:!0}))if(!y.endsWith(".d.ts")&&!y.includes("node_modules"))l.push(y);if(l.length===0)console.error("No TypeScript files found"),n.exit(1);console.log(`Found ${l.length} source files`),await t(l,{format:e.format||"markdown",outdir:f(e.outdir||"./docs"),title:e.title||"API Documentation",includePrivate:e.includePrivate??!1,includeInternal:e.includeInternal??!1,groupByCategory:e.groupByCategory??!1,includeSourceLinks:!!e.sourceUrl,sourceBaseUrl:e.sourceUrl})}catch(t){console.error("Error generating documentation:",t),n.exit(1)}});D.command("workspace","Generate declarations for all projects in a monorepo/workspace").option("--cwd <path>","Workspace root directory",{default:n.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(e)=>{try{let{generateMonorepo:t,generateFromPackageWorkspaces:o}=await import("../src/workspace.js"),{existsSync:f}=await import("fs"),{join:p,resolve:a}=await import("path"),l=a(e.cwd||n.cwd()),y=p(l,"tsconfig.json"),w;if(f(y))w=await t(l,{logLevel:e.logLevel||"info",continueOnError:e.continueOnError??!0});else w=await o(l,{logLevel:e.logLevel||"info",continueOnError:e.continueOnError??!0});if(!w.success)n.exit(1)}catch(t){console.error("Error generating workspace declarations:",t),n.exit(1)}});D.command("lsp","Start the Language Server Protocol server for IDE integration").example("dtsx lsp").action(async()=>{let{startLSPServer:e}=await import("../src/lsp.js");e()});D.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(e)=>{try{let{typeCheck:t,checkIsolatedDeclarations:o,formatTypeCheckResults:f}=await import("../chunk-5hyv43ps.js"),{Glob:p}=await Promise.resolve(globalThis.Bun),{resolve:a,relative:l}=await import("path"),y=n.cwd(),w=e.files||["**/*.ts"],h=[];for(let i of w){let u=new p(i);for await(let c of u.scan({cwd:y,absolute:!0,onlyFiles:!0}))if(!c.includes("node_modules"))if(e.declarationsOnly){if(c.endsWith(".d.ts"))h.push(c)}else h.push(c)}if(h.length===0)console.error("No files found to check"),n.exit(1);if(e.isolatedDeclarations){console.log(`Checking ${h.length} files for isolated declarations best practices...`);let i=await o(h,e.tsconfig?a(e.tsconfig):void 0),u=0,c=[];for(let[g,k]of i){let P=l(y,g);if(!k.compatible)if(u+=k.issues.length,e.format==="json")c.push({file:P,compatible:!1,issues:k.issues});else{console.log(`
|
|
8
8
|
\u2717 ${P}`);for(let x of k.issues)if(console.log(` ${x.line}:${x.column} - ${x.message}`),x.missingAnnotation)console.log(` Missing: ${x.missingAnnotation} type annotation`)}else if(e.format==="json")c.push({file:P,compatible:!0,issues:[]})}if(e.format==="json")console.log(JSON.stringify(c,null,2));else if(u>0)console.log(`
|
|
9
9
|
${h.length} files checked, ${u} recommendations found`),console.log("Tip: Adding explicit type annotations improves .d.ts accuracy");else console.log(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
class
|
|
3
|
-
`)}async writeResults(){if(!this.config.outputFile)return;let e=this.getResults(),t=JSON.stringify(e,null,2);try{let s=await import("fs/promises");await s.writeFile(this.config.outputFile,t,"utf-8")}catch{await Bun.write(this.config.outputFile,t)}}}function y(){if(typeof process<"u"&&process.memoryUsage){let e=process.memoryUsage();return{timestamp:Date.now(),heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers||0,rss:e.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function d(){if(typeof process<"u"&&process.cpuUsage){let e=process.cpuUsage();return{user:e.user,system:e.system}}return{user:0,system:0}}function n(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],s=1024,r=Math.floor(Math.log(e)/Math.log(s));return`${Number.parseFloat((e/s**r).toFixed(2))} ${t[r]}`}function gr(e){return new
|
|
4
|
-
export{
|
|
2
|
+
class jt{config;memorySamples=[];cpuSamples=[];ioOperations=[];startTime=0;memoryInterval=null;cpuInterval=null;lastCpuUsage=null;isRunning=!1;constructor(e={}){this.config={memory:e.memory??!1,memoryLimit:e.memoryLimit??1024,cpu:e.cpu??!1,samplingInterval:e.samplingInterval??100,io:e.io??!1,trackOperations:e.trackOperations??["read","write"],outputFile:e.outputFile??""}}start(){if(this.isRunning)return;if(this.isRunning=!0,this.startTime=Date.now(),this.memorySamples=[],this.cpuSamples=[],this.ioOperations=[],this.lastCpuUsage=null,this.config.memory)this.sampleMemory(),this.memoryInterval=setInterval(()=>this.sampleMemory(),this.config.samplingInterval);if(this.config.cpu)this.sampleCpu(),this.cpuInterval=setInterval(()=>this.sampleCpu(),this.config.samplingInterval)}stop(){if(!this.isRunning)return;if(this.isRunning=!1,this.memoryInterval)clearInterval(this.memoryInterval),this.memoryInterval=null;if(this.cpuInterval)clearInterval(this.cpuInterval),this.cpuInterval=null}sampleMemory(){let e=y();this.memorySamples.push(e)}sampleCpu(){let e=d();if(this.lastCpuUsage){let t={timestamp:Date.now(),user:e.user-this.lastCpuUsage.user,system:e.system-this.lastCpuUsage.system,total:e.user-this.lastCpuUsage.user+(e.system-this.lastCpuUsage.system)};this.cpuSamples.push(t)}this.lastCpuUsage=e}recordIo(e,t,s,r){if(!this.config.io)return;if(!this.config.trackOperations.includes(e))return;this.ioOperations.push({timestamp:Date.now(),operation:e,path:t,size:s,durationMs:r})}getResults(){let e=Date.now(),t=[],s=this.memorySamples[0]||y(),r=0;for(let a of this.memorySamples){if(r+=a.heapUsed,a.heapUsed>s.heapUsed)s=a;let g=a.heapUsed/1048576;if(g>this.config.memoryLimit)t.push(`Memory limit exceeded at ${new Date(a.timestamp).toISOString()}: ${g.toFixed(2)}MB > ${this.config.memoryLimit}MB`)}let i=this.memorySamples.length>0?r/this.memorySamples.length:0,o=0,m=0;for(let a of this.cpuSamples)o+=a.user,m+=a.system;let u=0,l=0,p=0,h=0,c=0,f=0;for(let a of this.ioOperations)if(a.operation==="read")u++,p+=a.size,c+=a.durationMs;else l++,h+=a.size,f+=a.durationMs;return{startTime:this.startTime,endTime:e,durationMs:e-this.startTime,memory:{samples:this.memorySamples,peak:s,average:{timestamp:0,heapUsed:i,heapTotal:0,external:0,arrayBuffers:0,rss:0},warnings:t},cpu:{samples:this.cpuSamples,totalUser:o,totalSystem:m},io:{operations:this.ioOperations,totalReads:u,totalWrites:l,totalReadBytes:p,totalWriteBytes:h,totalReadMs:c,totalWriteMs:f}}}formatResults(){let e=this.getResults(),t=["=== Profiling Results ===",""];if(t.push(`Duration: ${e.durationMs}ms`),t.push(""),this.config.memory){if(t.push("Memory:"),t.push(` Samples: ${e.memory.samples.length}`),t.push(` Peak heap: ${n(e.memory.peak.heapUsed)}`),t.push(` Average heap: ${n(e.memory.average.heapUsed)}`),e.memory.warnings.length>0){t.push(" Warnings:");for(let s of e.memory.warnings)t.push(` - ${s}`)}t.push("")}if(this.config.cpu)t.push("CPU:"),t.push(` Samples: ${e.cpu.samples.length}`),t.push(` Total user time: ${(e.cpu.totalUser/1000).toFixed(2)}ms`),t.push(` Total system time: ${(e.cpu.totalSystem/1000).toFixed(2)}ms`),t.push("");if(this.config.io)t.push("I/O:"),t.push(` Total reads: ${e.io.totalReads}`),t.push(` Total writes: ${e.io.totalWrites}`),t.push(` Total read: ${n(e.io.totalReadBytes)} in ${e.io.totalReadMs.toFixed(2)}ms`),t.push(` Total write: ${n(e.io.totalWriteBytes)} in ${e.io.totalWriteMs.toFixed(2)}ms`),t.push("");return t.join(`
|
|
3
|
+
`)}async writeResults(){if(!this.config.outputFile)return;let e=this.getResults(),t=JSON.stringify(e,null,2);try{let s=await import("fs/promises");await s.writeFile(this.config.outputFile,t,"utf-8")}catch{await Bun.write(this.config.outputFile,t)}}}function y(){if(typeof process<"u"&&process.memoryUsage){let e=process.memoryUsage();return{timestamp:Date.now(),heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers||0,rss:e.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function d(){if(typeof process<"u"&&process.cpuUsage){let e=process.cpuUsage();return{user:e.user,system:e.system}}return{user:0,system:0}}function n(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],s=1024,r=Math.floor(Math.log(e)/Math.log(s));return`${Number.parseFloat((e/s**r).toFixed(2))} ${t[r]}`}function gr(e){return new jt(e)}async function Zi(e,t){let s=gr({memory:!0,cpu:!0,...t});s.start();try{return{result:await e(),profile:s.getResults()}}finally{s.stop()}}function Qi(e){return{async read(t,s){let r=Date.now();try{let i=await s(),o=typeof i==="string"?i.length:0;return e.recordIo("read",t,o,Date.now()-r),i}catch(i){throw e.recordIo("read",t,0,Date.now()-r),i}},async write(t,s,r){let i=Date.now();try{await s(),e.recordIo("write",t,r,Date.now()-i)}catch(o){throw e.recordIo("write",t,0,Date.now()-i),o}}}}class Gt{marks=new Map;durations=new Map;mark(e){this.marks.set(e,performance.now())}measure(e,t){let s=this.marks.get(t);if(s===void 0)throw Error(`Mark "${t}" not found`);let r=performance.now()-s,i=this.durations.get(e)||[];return i.push(r),this.durations.set(e,i),r}getDurations(e){return this.durations.get(e)||[]}getAverage(e){let t=this.getDurations(e);if(t.length===0)return 0;return t.reduce((s,r)=>s+r,0)/t.length}getSummary(){let e=new Map;for(let[t,s]of this.durations)e.set(t,{count:s.length,total:s.reduce((r,i)=>r+i,0),average:s.reduce((r,i)=>r+i,0)/s.length,min:Math.min(...s),max:Math.max(...s)});return e}clear(){this.marks.clear(),this.durations.clear()}}function es(){return new Gt}
|
|
4
|
+
export{jt,gr,Zi,Qi,Gt,es};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
class
|
|
2
|
+
class we{plugins=[];config=null;register(t){if(this.plugins.some((n)=>n.name===t.name))throw Error(`Plugin "${t.name}" is already registered`);this.plugins.push(t)}hasDeclarationHooks(){return this.plugins.some((t)=>t.onDeclarations!==void 0)}unregister(t){let n=this.plugins.findIndex((r)=>r.name===t);if(n>=0)return this.plugins.splice(n,1),!0;return!1}getPlugins(){return this.plugins}createLogger(t){return{debug:(n)=>console.debug(`[${t}] ${n}`),info:(n)=>console.info(`[${t}] ${n}`),warn:(n)=>console.warn(`[${t}] ${n}`),error:(n)=>console.error(`[${t}] ${n}`)}}async runOnStart(t){let n=t;for(let r of this.plugins)if(r.onStart){let e=await r.onStart(n);if(e)n=e}return this.config=n,n}async runOnBeforeFile(t,n){let r=n;for(let e of this.plugins)if(e.onBeforeFile){let i={filePath:t,sourceCode:n,content:r,config:this.config,log:this.createLogger(e.name)},o=await e.onBeforeFile(i);if(typeof o==="string")r=o}return r}async runOnDeclarations(t,n,r){let e=r;for(let i of this.plugins)if(i.onDeclarations){let o={filePath:t,sourceCode:n,declarations:e,config:this.config,log:this.createLogger(i.name)},s=await i.onDeclarations(o);if(s)e=s}return e}async runOnAfterFile(t,n,r){let e=r;for(let i of this.plugins)if(i.onAfterFile){let o={filePath:t,sourceCode:n,content:e,config:this.config,log:this.createLogger(i.name)},s=await i.onAfterFile(o);if(typeof s==="string")e=s}return e}async runOnEnd(t){for(let n of this.plugins)if(n.onEnd)await n.onEnd(t)}async runOnError(t,n,r){for(let e of this.plugins)if(e.onError){let i={filePath:n,sourceCode:r,config:this.config,log:this.createLogger(e.name)};await e.onError(t,i)}}}var Ho=new we;function X(t){return t}var Ko=X({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(t)=>t.declarations.filter((n)=>{if(n.leadingComments){if(n.leadingComments.some((e)=>e.includes("@internal")))return t.log.debug(`Stripping internal declaration: ${n.name}`),!1}return!0})});function qo(t){return X({name:"banner",version:"1.0.0",description:"Adds a banner comment to generated files",onAfterFile:(n)=>`/**
|
|
3
3
|
* ${t.split(`
|
|
4
4
|
`).join(`
|
|
5
5
|
* `)}
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
`+n.content})}function Jo(t){return
|
|
9
|
-
export{
|
|
8
|
+
`+n.content})}function Jo(t){return X({name:"filter",version:"1.0.0",description:"Filters declarations by name",onDeclarations:(n)=>n.declarations.filter((r)=>{if(r.kind==="import")return!0;return t(r.name)})})}
|
|
9
|
+
export{we,Ho,X,Ko,qo,Jo};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class ai{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(t={}){this.config={enabled:t.enabled??!0,cacheDir:t.cacheDir??b,format:t.format??"json",maxAge:t.maxAge??86400000,force:t.force??!1,validateCache:t.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await y(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let t=o(this.config.cacheDir,d);try{let e=await l(t,"utf-8");if(this.manifest=JSON.parse(e),this.manifest.version!==c){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let t=o(this.config.cacheDir,d);this.manifest.updatedAt=Date.now(),await v(t,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(t,e){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let s=this.manifest.entries[t];if(!s)return this.stats.misses++,null;if(s.configHash!==e)return this.stats.misses++,null;if(Date.now()-s.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null;if(this.config.validateCache)try{let a=(await m(t)).mtimeMs;if(a!==s.mtime){let i=await l(t,"utf-8");if(this.hashContent(i)!==s.hash)return this.stats.misses++,null;s.mtime=a,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null}if(s.dependencies.length>0){if((await Promise.all(s.dependencies.map(async(a)=>{let i=this.manifest.entries[a];if(!i)return!0;try{return(await m(a)).mtimeMs===i.mtime}catch{return!1}}))).some((a)=>!a))return this.stats.misses++,null}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),s}async set(t,e,s,r,a,i){if(!this.config.enabled||!this.manifest)return;let n=Date.now();try{n=(await m(t)).mtimeMs}catch{}let h={filePath:t,hash:this.hashContent(e),mtime:n,declarations:s,dtsContent:r,dependencies:a,cachedAt:Date.now(),configHash:i};if(!(t in this.manifest.entries))this.stats.totalEntries++;this.manifest.entries[t]=h,this.dirty=!0}invalidate(t){if(!this.manifest)return;delete this.manifest.entries[t],this.dirty=!0;for(let[e,s]of Object.entries(this.manifest.entries))if(s.dependencies.includes(t))delete this.manifest.entries[e]}async clear(){this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(t){return String(p(t))}updateHitRatio(){let t=this.stats.hits+this.stats.misses;this.stats.hitRatio=t>0?this.stats.hits/t:0}static hashConfig(t){let e={outdir:t.outdir,clean:t.clean,tsconfigPath:t.tsconfigPath};return g("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}}function
|
|
2
|
+
import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class ai{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(t={}){this.config={enabled:t.enabled??!0,cacheDir:t.cacheDir??b,format:t.format??"json",maxAge:t.maxAge??86400000,force:t.force??!1,validateCache:t.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await y(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let t=o(this.config.cacheDir,d);try{let e=await l(t,"utf-8");if(this.manifest=JSON.parse(e),this.manifest.version!==c){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let t=o(this.config.cacheDir,d);this.manifest.updatedAt=Date.now(),await v(t,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(t,e){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let s=this.manifest.entries[t];if(!s)return this.stats.misses++,null;if(s.configHash!==e)return this.stats.misses++,null;if(Date.now()-s.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null;if(this.config.validateCache)try{let a=(await m(t)).mtimeMs;if(a!==s.mtime){let i=await l(t,"utf-8");if(this.hashContent(i)!==s.hash)return this.stats.misses++,null;s.mtime=a,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null}if(s.dependencies.length>0){if((await Promise.all(s.dependencies.map(async(a)=>{let i=this.manifest.entries[a];if(!i)return!0;try{return(await m(a)).mtimeMs===i.mtime}catch{return!1}}))).some((a)=>!a))return this.stats.misses++,null}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),s}async set(t,e,s,r,a,i){if(!this.config.enabled||!this.manifest)return;let n=Date.now();try{n=(await m(t)).mtimeMs}catch{}let h={filePath:t,hash:this.hashContent(e),mtime:n,declarations:s,dtsContent:r,dependencies:a,cachedAt:Date.now(),configHash:i};if(!(t in this.manifest.entries))this.stats.totalEntries++;this.manifest.entries[t]=h,this.dirty=!0}invalidate(t){if(!this.manifest)return;delete this.manifest.entries[t],this.dirty=!0;for(let[e,s]of Object.entries(this.manifest.entries))if(s.dependencies.includes(t))delete this.manifest.entries[e]}async clear(){this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(t){return String(p(t))}updateHitRatio(){let t=this.stats.hits+this.stats.misses;this.stats.hitRatio=t>0?this.stats.hits/t:0}static hashConfig(t){let e={outdir:t.outdir,clean:t.clean,tsconfigPath:t.tsconfigPath};return g("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}}function wo(t,e){let s=[],r=[],a=[];return{async needsRebuild(i){return await t.get(i,e)===null},async getCachedDeclarations(i){let n=await t.get(i,e);if(n)return r.push(i),n.declarations;return null},async getCachedDts(i){let n=await t.get(i,e);if(n)return n.dtsContent;return null},async cacheResult(i,n,h,u,f=[]){await t.set(i,n,h,u,f,e),s.push(i)},skip(i){a.push(i)},getResult(){return{rebuilt:s,cached:r,skipped:a,stats:t.getStats()}},async save(){await t.save()}}}async function Co(t,e=604800000){let s=t.getStats();if(s.totalEntries>1000)return await t.clear(),s.totalEntries;return 0}function vo(t){let e=[];return e.push("Incremental Build Results:"),e.push(` Rebuilt: ${t.rebuilt.length} files`),e.push(` From cache: ${t.cached.length} files`),e.push(` Skipped: ${t.skipped.length} files`),e.push(""),e.push("Cache Statistics:"),e.push(` Total entries: ${t.stats.totalEntries}`),e.push(` Hit ratio: ${(t.stats.hitRatio*100).toFixed(1)}%`),e.push(` Time saved: ~${t.stats.timeSavedMs}ms`),e.join(`
|
|
3
3
|
`)}function So(t,e){let s=[],r=/import\s+(?:type\s+)?(?:.+(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])from\s+)?['"]([^'"]+)['"]/g,a;while((a=r.exec(t))!==null){let i=a[1];if(i.startsWith(".")){let n=o(C(e),i);s.push(n),s.push(`${n}.ts`),s.push(`${n}.tsx`),s.push(o(n,"index.ts")),s.push(o(n,"index.tsx"))}}return s}
|
|
4
|
-
export{ai,
|
|
4
|
+
export{ai,wo,Co,vo,So};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Xe}from"./chunk-
|
|
2
|
+
import{Xe}from"./chunk-85d82vn3.js";import{E}from"./chunk-60wrxcjt.js";import{$n}from"./chunk-7bt7x8sy.js";import{be}from"./chunk-vae5wxar.js";import{ee}from"./chunk-w3zqfm8a.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function Ke(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function $o(n,r){throw Error(r||`Unexpected value: ${n}`)}async function G(n,r,o="lf"){let t=r.replace(/\r\n/g,`
|
|
3
3
|
`);if(!t.endsWith(`
|
|
4
4
|
`))t+=`
|
|
5
5
|
`;if(o==="crlf")t=t.replace(/\n/g,`\r
|
|
6
|
-
`);if(await Xe(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function li(n){let r=n??E.root,o=await v(r,{withFileTypes:!0});return(await Promise.all(o.map((i)=>{let c=C(r,i.name);return i.isDirectory()?li(c):c}))).flat(1/0).filter((i)=>{if(typeof i!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(i)&&!/\.d\.(?:ts|mts|cts)$/.test(i)})}async function
|
|
6
|
+
`);if(await Xe(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function li(n){let r=n??E.root,o=await v(r,{withFileTypes:!0});return(await Promise.all(o.map((i)=>{let c=C(r,i.name);return i.isDirectory()?li(c):c}))).flat(1/0).filter((i)=>{if(typeof i!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(i)&&!/\.d\.(?:ts|mts|cts)$/.test(i)})}async function J(n){try{let r=n?.cwd||y.cwd();return(await ee(D(r,n?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function wt(n,r){let o={isValid:!0,errors:[]};for(let t of be(n))o.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of $n(n))o.errors.push({line:t.line,column:1,message:`'${t.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${t.context}`,code:"dangling-type-reference"});return o.isValid=o.errors.length===0,o}function Ct(n,r,o){if(n===r)return"";let t=n.split(`
|
|
7
7
|
`),i=r.split(`
|
|
8
8
|
`),c=new Map,a=new Map;for(let e=0;e<t.length;e++)c.set(t[e],(c.get(t[e])??0)+1);for(let e=0;e<i.length;e++)a.set(i[e],(a.get(i[e])??0)+1);let g=[],u=[];for(let[e,s]of c){let m=s-(a.get(e)??0);for(let l=0;l<m;l++)g.push(e)}for(let[e,s]of a){let m=s-(c.get(e)??0);for(let l=0;l<m;l++)u.push(e)}if(g.length===0&&u.length===0)return"";let p=[`--- ${o}`,`+++ ${o}`];for(let e=0;e<g.length;e++)p.push(`- ${g[e]}`);for(let e=0;e<u.length;e++)p.push(`+ ${u[e]}`);return p.join(`
|
|
9
9
|
`)}function vt(n,r,o,t){let i=n.split(`
|
|
@@ -11,4 +11,4 @@ import{Xe}from"./chunk-ayyb1jpe.js";import{E}from"./chunk-60wrxcjt.js";import{$n
|
|
|
11
11
|
`).length;for(let s=0;s<i.length;s++){if(i[s].trim()===""){c.push("");continue}g=0;let l=Math.min(s,e-1),f=[],d=0-g,h=0,w=l-u,x=0-p;f.push(a(d)+a(h)+a(w)+a(x)),g=0,u=l,p=0,c.push(f.join(","))}return{version:3,file:r,sourceRoot:"",sources:[o],sourcesContent:[t],mappings:c.join(";")}}function St(n,r){return`${n}
|
|
12
12
|
${Ke()}${r}
|
|
13
13
|
`}
|
|
14
|
-
export{Ke,$o,G,li,
|
|
14
|
+
export{Ke,$o,G,li,J,wt,Ct,vt,St};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p}from"./chunk-v6fwy63g.js";import{existsSync as u,mkdirSync as H,readFileSync as l,renameSync as b,rmdirSync as D,rmSync as C,statSync as g,writeFileSync as S}from"fs";import{join as d,relative as h,resolve as y}from"path";var f=24,m=".dtsx-cache",v="manifest.json";function oi(t){try{C(d(t,v),{force:!0});try{D(t)}catch{}}catch{}}class He{cacheDir;manifestPath;manifest=null;configHash;constructor(t,n){this.cacheDir=y(t.cwd,t.cacheDir??m),this.manifestPath=d(this.cacheDir,v),this.configHash=this.hashConfig(t,n)}hashConfig(t,n){let s={resolutionContext:n,keepComments:t.keepComments,importOrder:t.importOrder,outputStructure:t.outputStructure,moduleSpecifierMode:t.moduleSpecifierMode??"preserve",root:y(t.cwd,t.root),exclude:t.exclude??[],isolatedDeclarations:t.isolatedDeclarations,declarationMap:t.declarationMap,indentStyle:t.indentStyle,indentSize:t.indentSize,prettier:t.prettier,typeMappings:t.typeMappings?{includeDefaults:t.typeMappings.includeDefaults,presets:t.typeMappings.presets,cacheKey:t.typeMappings.cacheKey,rules:t.typeMappings.rules.map((e)=>({pattern:typeof e.pattern==="string"?{kind:"string",value:e.pattern}:{kind:"regex",source:e.pattern.source,flags:e.pattern.flags},replacement:e.replacement,global:e.global,priority:e.priority,hasCondition:Boolean(e.condition)}))}:void 0,lineEnding:t.lineEnding,normalizeOutput:t.normalizeOutput,declarationOrder:t.declarationOrder,plugins:t.plugins?.map((e)=>({name:e.name,version:e.version,cacheKey:e.cacheKey}))};return String(p(JSON.stringify(s)))}hashString(t){return String(p(t))}load(){try{if(!u(this.manifestPath))return!1;let t=l(this.manifestPath,"utf-8"),n=JSON.parse(t);if(n.version!==f)return!1;if(n.configHash!==this.configHash)return!1;if(!n.entries||typeof n.entries!=="object"||Array.isArray(n.entries))return!1;return this.manifest=n,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!u(this.cacheDir))H(this.cacheDir,{recursive:!0});let t=`${this.manifestPath}.${process.pid}.tmp`;try{S(t,JSON.stringify(this.manifest,null,2)),b(t,this.manifestPath)}finally{if(u(t))C(t,{force:!0})}}needsRegeneration(t,n){return this.getCachedIfValid(t,n)===null}getCached(t,n){return this.getCachedIfValid(t,n)}getCachedIfValid(t,n){if(!this.manifest)return null;let s=h(n,t),e=this.manifest.entries[s];if(!e)return null;if(typeof e.dtsContent!=="string"||typeof e.dtsHash!=="string"||e.configHash!==this.configHash||this.hashString(e.dtsContent)!==e.dtsHash)return null;try{let i=g(t),{mtimeMs:r,ctimeMs:a}=i;if(i.size!==e.sourceSize)return null;if(r!==e.sourceMtime||a!==e.sourceCtime){let o=l(t,"utf-8");if(this.hashString(o)!==e.sourceHash)return null;e.sourceMtime=r,e.sourceCtime=a}return e.dtsContent}catch{return null}}update(t,n,s,e){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=h(e,t),r,a,o;try{let c=g(t);r=c.mtimeMs,a=c.ctimeMs,o=c.size}catch{r=Date.now(),a=r,o=Buffer.byteLength(n)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(n),sourceMtime:r,sourceCtime:a,sourceSize:o,dtsContent:s,dtsHash:this.hashString(s),generatedAt:Date.now(),configHash:this.configHash}}remove(t,n){if(!this.manifest)return;let s=h(n,t);delete this.manifest.entries[s]}clear(){this.manifest=null,oi(this.cacheDir)}getStats(){if(!this.manifest)return{entries:0,size:0};let t=Object.keys(this.manifest.entries).length,n=0;for(let s of Object.values(this.manifest.entries))n+=s.dtsContent.length;return{entries:t,size:n}}prune(t,n){if(!this.manifest)return 0;let s=0,e=new Set(Array.from(t).map((i)=>h(n,i)));for(let i of Object.keys(this.manifest.entries))if(!e.has(i))delete this.manifest.entries[i],s++;return s}}function
|
|
2
|
+
import{p}from"./chunk-v6fwy63g.js";import{existsSync as u,mkdirSync as H,readFileSync as l,renameSync as b,rmdirSync as D,rmSync as C,statSync as g,writeFileSync as S}from"fs";import{join as d,relative as h,resolve as y}from"path";var f=24,m=".dtsx-cache",v="manifest.json";function oi(t){try{C(d(t,v),{force:!0});try{D(t)}catch{}}catch{}}class He{cacheDir;manifestPath;manifest=null;configHash;constructor(t,n){this.cacheDir=y(t.cwd,t.cacheDir??m),this.manifestPath=d(this.cacheDir,v),this.configHash=this.hashConfig(t,n)}hashConfig(t,n){let s={resolutionContext:n,keepComments:t.keepComments,importOrder:t.importOrder,outputStructure:t.outputStructure,moduleSpecifierMode:t.moduleSpecifierMode??"preserve",root:y(t.cwd,t.root),exclude:t.exclude??[],isolatedDeclarations:t.isolatedDeclarations,declarationMap:t.declarationMap,indentStyle:t.indentStyle,indentSize:t.indentSize,prettier:t.prettier,typeMappings:t.typeMappings?{includeDefaults:t.typeMappings.includeDefaults,presets:t.typeMappings.presets,cacheKey:t.typeMappings.cacheKey,rules:t.typeMappings.rules.map((e)=>({pattern:typeof e.pattern==="string"?{kind:"string",value:e.pattern}:{kind:"regex",source:e.pattern.source,flags:e.pattern.flags},replacement:e.replacement,global:e.global,priority:e.priority,hasCondition:Boolean(e.condition)}))}:void 0,lineEnding:t.lineEnding,normalizeOutput:t.normalizeOutput,declarationOrder:t.declarationOrder,plugins:t.plugins?.map((e)=>({name:e.name,version:e.version,cacheKey:e.cacheKey}))};return String(p(JSON.stringify(s)))}hashString(t){return String(p(t))}load(){try{if(!u(this.manifestPath))return!1;let t=l(this.manifestPath,"utf-8"),n=JSON.parse(t);if(n.version!==f)return!1;if(n.configHash!==this.configHash)return!1;if(!n.entries||typeof n.entries!=="object"||Array.isArray(n.entries))return!1;return this.manifest=n,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!u(this.cacheDir))H(this.cacheDir,{recursive:!0});let t=`${this.manifestPath}.${process.pid}.tmp`;try{S(t,JSON.stringify(this.manifest,null,2)),b(t,this.manifestPath)}finally{if(u(t))C(t,{force:!0})}}needsRegeneration(t,n){return this.getCachedIfValid(t,n)===null}getCached(t,n){return this.getCachedIfValid(t,n)}getCachedIfValid(t,n){if(!this.manifest)return null;let s=h(n,t),e=this.manifest.entries[s];if(!e)return null;if(typeof e.dtsContent!=="string"||typeof e.dtsHash!=="string"||e.configHash!==this.configHash||this.hashString(e.dtsContent)!==e.dtsHash)return null;try{let i=g(t),{mtimeMs:r,ctimeMs:a}=i;if(i.size!==e.sourceSize)return null;if(r!==e.sourceMtime||a!==e.sourceCtime){let o=l(t,"utf-8");if(this.hashString(o)!==e.sourceHash)return null;e.sourceMtime=r,e.sourceCtime=a}return e.dtsContent}catch{return null}}update(t,n,s,e){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=h(e,t),r,a,o;try{let c=g(t);r=c.mtimeMs,a=c.ctimeMs,o=c.size}catch{r=Date.now(),a=r,o=Buffer.byteLength(n)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(n),sourceMtime:r,sourceCtime:a,sourceSize:o,dtsContent:s,dtsHash:this.hashString(s),generatedAt:Date.now(),configHash:this.configHash}}remove(t,n){if(!this.manifest)return;let s=h(n,t);delete this.manifest.entries[s]}clear(){this.manifest=null,oi(this.cacheDir)}getStats(){if(!this.manifest)return{entries:0,size:0};let t=Object.keys(this.manifest.entries).length,n=0;for(let s of Object.values(this.manifest.entries))n+=s.dtsContent.length;return{entries:t,size:n}}prune(t,n){if(!this.manifest)return 0;let s=0,e=new Set(Array.from(t).map((i)=>h(n,i)));for(let i of Object.keys(this.manifest.entries))if(!e.has(i))delete this.manifest.entries[i],s++;return s}}function xt(t){let n=d(t,".gitignore");try{let s="";if(u(n))s=l(n,"utf-8");if(!s.split(/\r?\n/).some((i)=>i.trim()===m||i.trim()===`${m}/`)){let i=s.trimEnd(),r=`${i}${i?`
|
|
3
3
|
|
|
4
4
|
`:""}# dtsx cache
|
|
5
5
|
${m}/
|
|
6
6
|
`;S(n,r)}}catch{}}
|
|
7
|
-
export{oi,He,
|
|
7
|
+
export{oi,He,xt};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{c,i}from"./chunk-8kj9pkw5.js";import{h}from"./chunk-
|
|
2
|
+
import{c,i}from"./chunk-8kj9pkw5.js";import{h}from"./chunk-q76b61w9.js";import{y}from"./chunk-a2dn9j88.js";function $e(f){let r=new Set,n=[];for(let t of f)if(t.kind==="import")for(let o of y(t.text))r.add(o);else if(t.kind!=="unknown"){if(n.push(t.text),t.kind==="variable"){if(t.typeAnnotation)n.push(t.typeAnnotation);else if(t.value)n.push(h(t,!1))}}let e=n.join(`
|
|
3
3
|
`),s=new Set;for(let t=0;t<e.length;){if(!c(e.charCodeAt(t))){t++;continue}let o=t++;while(t<e.length&&i(e.charCodeAt(t)))t++;let a=e.slice(o,t);if(r.has(a))s.add(a)}return{usedItems:s,referenceText:e}}
|
|
4
4
|
export{$e};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{E}from"./chunk-60wrxcjt.js";import{
|
|
2
|
+
import{E}from"./chunk-60wrxcjt.js";import{J}from"./chunk-13tjnp25.js";import{q,he}from"./chunk-prst4szw.js";import{An}from"./chunk-k9695p66.js";import{spawn as N}from"child_process";var x=new Set(["cwd","root","outdir","entrypoints","include","exclude","autoIncludeReExports","outputStructure","tsconfigPath","moduleSpecifierMode","keepComments","isolatedDeclarations","clean","lineEnding"]);function y(l,f,d,n,u){let s=u.signal;s?.throwIfAborted();let c=u.timeoutMs??30000;if(!Number.isSafeInteger(c)||c<=0||c>2147483647)throw RangeError("Native project timeoutMs must be an integer between 1 and 2147483647");return new Promise((g,r)=>{let o=N(l,f,{cwd:n,stdio:["pipe","pipe","pipe"],windowsHide:!0}),i=[],a=[],e,h,v=!1,p=(t)=>{e??=t,o.kill()},m=()=>p(s?.reason instanceof Error?s.reason:Error("Native declaration project aborted",{cause:s?.reason})),j=setTimeout(()=>p(Error(`Native declaration project exceeded ${c}ms`)),c),b=(t,w)=>{if(v)return;if(v=!0,clearTimeout(j),s?.removeEventListener("abort",m),t)r(t);else g(w)};if(o.once("error",(t)=>b(t)),o.stdout.on("data",(t)=>i.push(Buffer.from(t))),o.stderr.on("data",(t)=>a.push(Buffer.from(t))),o.stdout.once("error",p),o.stderr.once("error",p),o.stdin.once("error",(t)=>{h??=t}),o.once("close",(t,w)=>{if(t!==0&&!e)e=Error(`Native declaration project failed (${w??t}): ${Buffer.concat(a).toString("utf8")}`);b(e??h,Buffer.concat(i).toString("utf8"))}),s?.addEventListener("abort",m,{once:!0}),s?.aborted)m();o.stdin.end(Buffer.from(d,"utf8"))})}async function Di(l,f={},d={}){if(!l||l.includes("\x00"))throw Error("A native zig-dtsx executable is required");for(let i of Object.keys(f))if(!x.has(i))throw Error(`Native declaration project does not support option: ${i}`);d.signal?.throwIfAborted();let n={...E,...f};if(await q(n),n.isolatedDeclarations===void 0)n.isolatedDeclarations=await J(n);let u=await An(n),s=["--batch"];if(!n.keepComments)s.push("--no-comments");if(n.isolatedDeclarations)s.push("--isolated-declarations");let c=JSON.stringify({protocol:"zig-dtsx-project",version:1,files:u.files.map((i)=>({source:i.source,context:i.context}))}),g=await y(l,s,c,n.cwd,d),r;try{r=JSON.parse(g)}catch(i){throw Error("Native executable did not return a valid zig-dtsx project protocol response",{cause:i})}if(!r||typeof r!=="object"||!("protocol"in r)||r.protocol!=="zig-dtsx-project"||!("version"in r)||r.version!==1||!("files"in r)||!Array.isArray(r.files)||r.files.length!==u.files.length)throw Error("Native executable returned an unsupported or incomplete project response");let o=new Map;for(let[i,a]of u.files.entries()){let e=r.files[i];if(!e||typeof e!=="object"||!("sourceFile"in e)||e.sourceFile!==a.sourceFile||!("outputFile"in e)||e.outputFile!==a.outputFile||!("sourceHash"in e)||e.sourceHash!==a.context.sourceHash||!("content"in e)||typeof e.content!=="string")throw Error(`Native executable returned a mismatched project result for ${a.sourceFile}`);o.set(a.outputFile,{content:e.content,lineEnding:n.lineEnding})}return d.signal?.throwIfAborted(),await he(n,o),Object.freeze({filesGenerated:o.size,outputFiles:Object.freeze([...o.keys()])})}
|
|
3
3
|
export{Di};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t}from"./chunk-g0dxj89b.js";import{Xn,Zn,Qn}from"./chunk-fv3x086v.js";import{Oe,fe,Ie}from"./chunk-8wk7nw3c.js";import{ue}from"./chunk-a3apthex.js";var nt=20,rt=!1,M=null;function at(e){return St(e).replace(/\n[ \t]*(?=\n)/g,"")}function St(e){if(e.indexOf("/*")===-1)return e.trim();let r=[],c=0,s=0,l=e.length;while(s<l)if(e.charCodeAt(s)===47&&s+1<l&&e.charCodeAt(s+1)===42){if(s>c)r.push(e.substring(c,s));s+=2;while(s<l-1){if(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47){s+=2;break}s++}c=s}else s++;if(c<l)r.push(e.substring(c));return r.join("").trim()}function Ft(){rt=!0,M=null}function Nt(){rt=!1;let e=M;return M=null,e}function pt(e,i){if(i===2)return e===48||e===49;if(i===8)return e>=48&&e<=55;if(i===10)return e>=48&&e<=57;return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function J(e,i,r){let c=!1,s=!1;while(i.at<e.length){let l=e.charCodeAt(i.at);if(pt(l,r))c=!0,s=!1,i.at++;else if(l===95&&c&&!s&&i.at+1<e.length&&pt(e.charCodeAt(i.at+1),r))s=!0,i.at++;else break}return c&&!s}function Pt(e,i){if(e.charCodeAt(i)!==48||i+1>=e.length)return 0;let r=e.charCodeAt(i+1)|32;return r===120?16:r===98?2:r===111?8:0}function z(e){if(e.length===0)return!1;let i={at:0};if(e.charCodeAt(0)===45)i.at++;if(i.at>=e.length)return!1;let r=Pt(e,i.at);if(r)return i.at+=2,J(e,i,r)&&i.at===e.length;let c=J(e,i,10);if(e.charCodeAt(i.at)===46){i.at++;let l=J(e,i,10);if(!c&&!l)return!1}else if(!c)return!1;let s=e.charCodeAt(i.at);if(s===101||s===69){if(i.at++,e.charCodeAt(i.at)===43||e.charCodeAt(i.at)===45)i.at++;if(!J(e,i,10))return!1}return i.at===e.length}function ga(e){if(e.length<2||e.charCodeAt(e.length-1)!==110)return!1;let i=e.slice(0,-1),r={at:0};if(i.charCodeAt(0)===45)r.at++;if(r.at>=i.length)return!1;let c=Pt(i,r.at);if(c)return r.at+=2,J(i,r,c)&&r.at===i.length;return J(i,r,10)&&r.at===i.length}function it(e){return e.includes("_")?e.replaceAll("_",""):e}function lt(e,i){let r=0,c=0;while((c=e.indexOf(i,c))!==-1)r++,c+=i.length;return r}function Ct(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function U(e){let i=e.trim();if(i.length<3||i.charCodeAt(0)!==60)return!1;if(i.startsWith("<>"))return i.endsWith("</>");let r=i.charCodeAt(1);if(!(r>=65&&r<=90||r>=97&&r<=122||r===36||r===95))return!1;let s=2;while(s<i.length&&Ct(i.charCodeAt(s)))s++;let l=i.slice(1,s),f=i.charCodeAt(s);if(f>32&&f!==62&&f!==47)return!1;if(i.endsWith("/>"))return!0;let u=i.lastIndexOf("</");if(u===-1)return!1;let a=u+2;while(a<i.length&&Ct(i.charCodeAt(a)))a++;return i.slice(u+2,a)===l&&i.charCodeAt(a)===62&&a===i.length-1}function v(e){let i=e.length,r=!1;for(let f=1;f<i;f++)if(e.charCodeAt(f)<=32&&e.charCodeAt(f-1)<=32){r=!0;break}if(!r)for(let f=0;f<i;f++){let u=e.charCodeAt(f);if(u===10||u===13||u===9){r=!0;break}}if(!r)return e;let c=[],s=-1,l=!1;for(let f=0;f<i;f++)if(e.charCodeAt(f)<=32){if(!l){if(s>=0)c.push(e.substring(s,f));c.push(" "),l=!0,s=-1}}else{if(l||s<0)s=f;l=!1}if(s>=0)c.push(e.substring(s));return c.join("")}function n(e,i=!1,r=!1,c=0,s){if(!e||typeof e!=="string")return"unknown";if(c>=nt)return"unknown";let l=e.trim();if(U(l))return"JSX.Element";if(l.startsWith("BigInt("))return"bigint";if(l.startsWith("Symbol.for("))return"symbol";if(l.includes(".raw`")||l.includes("String.raw`"))return"string";if(l.startsWith("`")&&l.endsWith("`")){if(!i||l.includes("${")||l.includes(`
|
|
3
|
+
`)||l.includes("\r"))return"string";return l}if(l.charCodeAt(0)===39||l.charCodeAt(0)===34){let u=Lt(l);if(u!==null){if(u==="string"||!i)return"string";return u}}if(z(l)){if(!i)return"number";return it(l)}if(l==="true"||l==="false"){if(!i)return"boolean";return l}if(l==="null")return"null";if(l==="undefined")return"undefined";if(l.startsWith("[")&&l.endsWith("]"))return De(l,i,c+1,s);if(l.startsWith("{")&&l.endsWith("}"))return st(l,i,c+1,s);if(l.startsWith("class ")||l.startsWith("class{"))return te(l);if(l.startsWith("new "))return vt(l);if(l.endsWith("as const")){let u=l.slice(0,-8).trim();if(u.startsWith("[")&&u.endsWith("]")){let a=u.slice(1,-1).trim();if(!a)return"readonly []";let d=H(a),m=[];for(let w=0;w<d.length;w++){let A=d[w].trim();if(A.startsWith("...")){let g=A.slice(3).trim();if(G(g))m.push(`...typeof ${g}`);else{let h=n(g,!0,!1,c+1,s);m.push(h.startsWith("readonly [")||h.endsWith("[]")?`...${h}`:"...unknown[]")}}else m.push(n(A,!0,!1,c+1,s))}return`readonly [${m.join(", ")}]`}return n(u,!0,r,c+1,s)}if(X(l)!==-1||l.startsWith("function")||l.startsWith("async"))return ot(l,r,c,i);if(l.startsWith("`")&&l.endsWith("`"))return Ut(l,i);if(l.startsWith("Promise."))return Rt(l,i,c,s);if(l.startsWith("await "))return"unknown";if(l.startsWith("typeof ")&&ft(l.slice(7)))return"string";if(l.startsWith("void ")&&ft(l.slice(5)))return"undefined";if(l.startsWith("delete ")&&ft(l.slice(7)))return"boolean";if(ga(l)){if(i)return it(l);return"bigint"}if(l.startsWith("Symbol(")||l==="Symbol.for")return"symbol";let f=Re(l);if(f!==null)return f;if(Ot(l))return"boolean";if(Gt(l))return"number";return"unknown"}function At(e){let i=e.charCodeAt(0);if(i!==39&&i!==34)return!1;return K(e,0,i)===e.length}function Lt(e){if(At(e))return e;let i=Kt(e);if(i.length<2)return null;let r=!1,c=!0,s="";for(let l of i){let f=l.trim();if(At(f))r=!0,s+=Vt(f);else c=!1}if(c)return qt(s);if(r)return"string";return null}function Kt(e){let i=[],r=0,c=0,s=0;while(s<e.length){let l=e.charCodeAt(s);if(l===39||l===34||l===96){s=K(e,s,l);continue}if(l===40||l===91||l===123)r++;else if(l===41||l===93||l===125)r--;else if(l===43&&r===0)i.push(e.slice(c,s)),c=s+1;s++}return i.push(e.slice(c)),i}function Vt(e){return e.slice(1,-1).replace(/\\(.)/g,(r,c)=>{if(c==="n")return`
|
|
4
|
+
`;if(c==="t")return"\t";if(c==="r")return"\r";if(c==="0")return"\x00";return c})}function qt(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Gt(e){if(e==="")return!1;let i=!1,r=!1;for(let c=0;c<e.length;c++){let s=e.charCodeAt(c);if(s>=48&&s<=57){i=!0;continue}if(s===43||s===45||s===42||s===47||s===37){r=!0;continue}if(s===46||s===40||s===41||s<=32)continue;return!1}return i&&r}function Ot(e){let i=0;for(let r=0;r<e.length;r++){let c=e.charCodeAt(r);if(c===34||c===39||c===96){r=K(e,r,c)-1;continue}if(c===40||c===91||c===123){i++;continue}if(c===41||c===93||c===125){i--;continue}if(i!==0)continue;if(e.startsWith("===",r)||e.startsWith("!==",r)||e.startsWith("==",r)||e.startsWith("!=",r)||e.startsWith(">=",r)||e.startsWith("<=",r))return!0;if((c===62||c===60)&&e.charCodeAt(r-1)!==61&&e.charCodeAt(r+1)!==61)return!0}return!1}function Bt(e,i=!1,r=0,c){return n(e,i,!0,r,c)}function I(e,i=!1,r="",c,s){let l=ut(r,c),f=[],u=!1,a=0;while(a<e.length){let m=e.charCodeAt(a);if(m===34||m===39||m===96){a=K(e,a,m);continue}if(m===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(m===47&&e.charCodeAt(a+1)===42){let A=e.indexOf("*/",a+2);a=A===-1?e.length:A+2;continue}if(e.startsWith("function",a)&&Y(e,a,8)||e.startsWith("class",a)&&Y(e,a,5)){let A=Zt(e,a);if(A!==-1){a=tt(e,A);continue}}if(m===61&&e.charCodeAt(a+1)===62){let A=Mt(e,a+2);if(e.charCodeAt(A)===123){a=tt(e,A);continue}}if(e.startsWith("return",a)&&(a===0||!N(e.charCodeAt(a-1)))&&!N(e.charCodeAt(a+6))){a+=6;let A=!1;while(a<e.length&&e.charCodeAt(a)<=32){let x=e.charCodeAt(a);if(x===10||x===13)A=!0;a++}if(A||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){u=!0;continue}let g=a,h=0,p=0,C=0;while(a<e.length){let x=e.charCodeAt(a);if(x===34||x===39||x===96){a=K(e,a,x);continue}if(x===47&&e.charCodeAt(a+1)===47){if(h===0&&p===0&&C===0)break;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(x===47&&e.charCodeAt(a+1)===42){let b=e.indexOf("*/",a+2);a=b===-1?e.length:b+2;continue}if(x===40)h++;else if(x===41)h--;else if(x===91)p++;else if(x===93)p--;else if(x===123)C++;else if(x===125){if(C===0&&h===0&&p===0)break;C--}else if(x===59&&h===0&&p===0&&C===0)break;else if((x===10||x===13)&&h===0&&p===0&&C===0){let b=a+1;while(b<e.length&&e.charCodeAt(b)<=32)b++;if(e.startsWith("return",b)&&!N(e.charCodeAt(b+6)))break}a++}let y=e.slice(g,a).trim(),W=at(D(y,l,c,s,g));if(!f.includes(W))f.push(W);continue}a++}if(u&&!f.includes("undefined"))f.push("undefined");let d=f.includes("unknown")?"unknown":f.length===0?"void":Et(f);return i&&!d.startsWith("Promise<")?`Promise<${d}>`:d}function ut(e,i){let r=new Map,c=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,s=t(c),l=0,f=0,u=[];for(let a of s){let d=c.slice(a.start,a.end);if(d===","&&f===0)u.push(c.slice(l,a.start)),l=a.end;if(["(","[","{","<"].includes(d))f++;else if([")","]","}"].includes(d)||d===">"&&c[a.start-1]!=="=")f--}u.push(c.slice(l));for(let a of u){let d=t(a),m=-1,w=-1,A=0;for(let C of d){let y=a.slice(C.start,C.end);if(A===0&&y===":"&&m===-1)m=C.start;if(A===0&&y==="="&&a[C.end]!==">"){w=C.start;break}if(["(","[","{","<"].includes(y))A++;else if([")","]","}"].includes(y)||y===">"&&a[C.start-1]!=="=")A--}let g=a.slice(0,m!==-1?m:w!==-1?w:void 0).trim().replace(/^\.\.\./,"").replace(/\?$/,""),h=m===-1&&w!==-1&&!a.trim().startsWith("...")?fe(g,a.slice(w+1)):null;if(h){for(let C of h)r.set(C.alias,i?.(C.value)??n(C.value,!1));continue}if(!Z(g))continue;let p=m!==-1?a.slice(m+1,w!==-1?w:void 0).trim():"";if(!p&&w!==-1){let C=a.slice(w+1).trim();p=i?.(C)??n(C,!1)}if(p){if(w===-1&&a.slice(0,m).trim().endsWith("?"))p=`(${p}) | undefined`;r.set(g,p)}}return r}var yt={string:{at:"string | undefined",charAt:"string",charCodeAt:"number",codePointAt:"number | undefined",concat:"string",endsWith:"boolean",includes:"boolean",indexOf:"number",lastIndexOf:"number",localeCompare:"number",normalize:"string",padEnd:"string",padStart:"string",repeat:"string",replace:"string",replaceAll:"string",search:"number",slice:"string",split:"string[]",startsWith:"boolean",substring:"string",toLocaleLowerCase:"string",toLocaleUpperCase:"string",toLowerCase:"string",toString:"string",toUpperCase:"string",trim:"string",trimEnd:"string",trimStart:"string",valueOf:"string"},number:{toExponential:"string",toFixed:"string",toLocaleString:"string",toPrecision:"string",toString:"string",valueOf:"number"},bigint:{toLocaleString:"string",toString:"string",valueOf:"bigint"},boolean:{toString:"string",valueOf:"boolean"}};function ha(e,i){let r=Object.hasOwn(yt,e)?yt[e]:void 0;return r&&Object.hasOwn(r,i)?r[i]:void 0}function L(e){return e.includes(`
|
|
5
|
+
`)?e.replaceAll(`
|
|
6
|
+
`,`
|
|
7
|
+
`):e}function Jt(e,i){if(e=e.trim(),!e.startsWith("{")||!e.endsWith("}"))return;let r=e.slice(1,-1),c=t(r),s=0,l=0;for(let f=0;f<=c.length;f++){let u=c[f],a=u?r.slice(u.start,u.end):";";if(l===0&&(a===";"||a===",")){let d=r.slice(s,u?.start).trim(),m=d.indexOf(":");if(m!==-1&&d.slice(0,m).trim()===i)return d.slice(m+1).trim();s=u?.end??r.length}if(["(","[","{","<"].includes(a))l++;else if([")","]","}"].includes(a)||a===">"&&u&&r[u.start-1]!=="=")l--}return}function D(e,i,r,c,s=0,l=0){if(l>=nt)return"unknown";let f=e.trim();while(ct(f))f=f.slice(1,-1).trim();let u=r?.(f);if(u)return u;if(U(f))return"JSX.Element";if(f.startsWith("await ")){let y=D(f.slice(6),i,r,c,s,l+1);return y.startsWith("Promise<")&&y.endsWith(">")?y.slice(8,-1):y}if(i.has(f))return i.get(f);let a=/^([\w$]+)\.([\w$]+(?:\.[\w$]+)*)$/.exec(f),d;if(a){let y=i.get(a[1]),W=y&&Jt(y,a[2]);if(W)return W;if(y)d=`typeof ${f}`}if(f.startsWith("!"))return"boolean";if(f.startsWith("fetch("))return"Promise<Response>";if(Yt(f))return n(f,!1);let m=jt(f);if(m){let y=D(m.whenTrue,i,r,c,s,l+1),W=D(m.whenFalse,i,r,c,s,l+1);return y===W?y:Et([y,W])}for(let y of["??","||","&&"]){let W=It(f,y);if(W!==-1){let x=D(f.slice(0,W),i,r,c,s,l+1),b=D(f.slice(W+y.length),i,r,c,s,l+1);return Xt(x,b,y)}}let w=zt(f);if(w&&c)return c(w,s);if(Ot(f))return"boolean";let A=0;for(let y=f.length-1;y>=0;y--){let W=f.charCodeAt(y);if(W===41||W===93||W===125)A++;else if(W===40||W===91||W===123)A--;else if(A===0&&(W===43||W===45||W===42||W===47||W===37)){let x=D(f.slice(0,y),i,r,c,s,l+1),b=D(f.slice(y+1),i,r,c,s,l+1);if(W===43&&(x==="string"||b==="string"))return"string";if(x==="number"&&b==="number")return"number";break}}if(f.startsWith("[")&&f.endsWith("]")){let y=H(f.slice(1,-1));if(y.some((W)=>W.trim().startsWith("..."))){let W=y.map((x)=>{let b=x.trim();if(!b)return"undefined";let S=b.startsWith("..."),k=D(S?b.slice(3):b,i,r,c,s,l+1);return S?`(NonNullable<${k}> extends Iterable<infer Element> ? Element : never)`:k});return`(${[...new Set(W)].join(" | ")||"never"})[]`}}let g=d??(f.startsWith("{")&&f.endsWith("}")?st(f,!1,l+1,void 0,(y)=>D(y,i,r,c,s,l+1)):n(f,!1)),h=t(g),p="",C=0;for(let y=0;y<h.length;y++){let W=h[y];if(W.kind!=="word"||g.slice(W.start,W.end)!=="typeof")continue;let x=h[y+1];if(!x||x.kind!=="word")continue;let b=i.get(g.slice(x.start,x.end)),S=b,k=!b,O=W.start,B=x.end,_=y,T=[];y++;while(h[y+1]&&g.slice(h[y+1].start,h[y+1].end)==="."&&h[y+2]?.kind==="word"){let V=h[y+2];if(T.push(g.slice(V.start,V.end)),!k)b=`(${b})["${g.slice(V.start,V.end)}"]`;B=V.end,y+=2}let E=_>=2&&g.slice(h[_-2].start,h[_-2].end)==="ReturnType"&&g.slice(h[_-1].start,h[_-1].end)==="<"&&h[y+1]&&g.slice(h[y+1].start,h[y+1].end)===">",q=S&&E&&T.length===1?ha(S.trim(),T[0]):void 0;if(q){O=h[_-2].start,B=h[++y].end;let V=O===0&&B===g.length;p+=g.slice(C,O)+(V||!q.includes("|")?q:`(${q})`),C=B;continue}if(k&&E)O=h[_-2].start,B=h[++y].end;p+=g.slice(C,O)+(b??"unknown"),C=B}return p+g.slice(C)}function zt(e){let i=t(e),r=0,c=-1;for(let l=0;l<i.length;l++){let f=i[l],u=e.slice(f.start,f.end);if(f.kind!=="punctuation"&&f.kind!=="word")continue;if(["(","[","{"].includes(u))r++;else if([")","]","}"].includes(u))r--;else if(!r&&u==="as"&&l>0&&e.slice(i[l-1].start,i[l-1].end)!==".")c=l}if(c===-1||c+1===i.length)return;let s=e.slice(i[c].end).trim();if(s==="const")return;r=0;for(let l of i.slice(c+1)){if(l.kind!=="punctuation")continue;let f=e.slice(l.start,l.end);if(!r&&["??","||","&&"].some((u)=>e.startsWith(u,l.start)))return;if(["(","[","{","<"].includes(f))r++;else if([")","]","}",">"].includes(f))r--;else if(!r&&["+","-","*","/","%","=","!",";"].includes(f))return}return s}function It(e,i){let r=0;for(let c of t(e)){if(c.kind!=="punctuation")continue;let s=e.slice(c.start,c.end);if(["(","[","{"].includes(s))r++;else if([")","]","}"].includes(s))r--;if(!r&&e.startsWith(i,c.start))return c.start}return-1}function Xt(e,i,r){if(e.trim()==="unknown")return r==="&&"||i.trim()==="unknown"?"unknown":`{} | ${i}`;let c="false | 0 | 0n | '' | null | undefined";if(r==="??")return`([${e}] extends [NonNullable<${e}>] ? ${e} : NonNullable<${e}> | ${i})`;if(r==="||")return`([${e}] extends [object] ? ${e} : [Exclude<${e}, object> & (${c})] extends [never] ? ${e} : Exclude<NonNullable<${e}>, ${c}> | ${i})`;return`([${e}] extends [object] ? ${i} : [${e}] extends [${c}] ? ${e} : unknown extends (${e}) ? ${e} : (Exclude<${e}, object> & (${c})) | ${i})`}function Ht(e){let i=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]: __dtsx_spread_value[__dtsx_spread_key] } : never)`,r=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]?: __dtsx_spread_value[__dtsx_spread_key] } : never)`;return`([${e}] extends [null | undefined] ? {} : [${e}] extends [NonNullable<${e}>] ? ${i} : ${r})`}function Qt(e,i){let r=e.trim();while(ct(r))r=r.slice(1,-1).trim();let c=It(r,"??");if(c!==-1&&r.slice(c+2).trim()==="{}")return Ht(i(r.slice(0,c)));let s=jt(r);if(s){if(s.whenFalse.trim()==="{}")return`Partial<${i(s.whenTrue)}>`;if(s.whenTrue.trim()==="{}")return`Partial<${i(s.whenFalse)}>`}return i(r)}function Et(e){return e.map((i)=>e.length>1&&X(i)!==-1?`(${i})`:i).join(" | ")}function wt(e){let i=0;while(i<e.length){let s=e.charCodeAt(i);if(s<=32)i++;else if(s===47&&e.charCodeAt(i+1)===47){i+=2;while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++}else if(s===47&&e.charCodeAt(i+1)===42){let l=e.indexOf("*/",i+2);i=l===-1?e.length:l+2}else break}let r=i,c=i;while(c<e.length){let s=e.charCodeAt(c);if(s===34||s===39||s===96){c=K(e,c,s),r=c;continue}if(s===92){c=Math.min(c+2,e.length),r=c;continue}if(s===47&&e.charCodeAt(c+1)===47){while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++;continue}if(s===47&&e.charCodeAt(c+1)===42){let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+2;continue}if(c++,s>32)r=c}return e.slice(i,r)}function ft(e){let i=0;for(let r=0;r<e.length;r++){let c=e[r];if(c==="'"||c==='"'||c==="`"){let s=r+1;while(s<e.length&&e[s]!==c){if(e[s]==="\\")s++;s++}r=s;continue}if(c==="("||c==="["||c==="{")i++;else if(c===")"||c==="]"||c==="}")i--;else if(i!==0)continue;else if(c==="?"){if(e[r+1]!==".")return!1}else if("=!<>&|+-*/%,:".includes(c))return!1;else if(c===" "||c==="\t"||c===`
|
|
8
|
+
`||c==="\r"){let s=e.slice(r).trimStart();if(s&&s[0]!=="."&&s[0]!=="?"&&s[0]!=="("&&s[0]!=="[")return!1}}return!0}function Yt(e){if(e.startsWith("function")&&Y(e,0,8))return!0;let i=X(e);if(i===-1)return!1;let r=e.slice(0,i).trim();if(r.startsWith("async")&&Y(r,0,5))r=r.slice(5).trim();if(r.startsWith("<")){let s=o(r,0,"<",">");if(s===-1)return!1;r=r.slice(s+1).trim()}if(r.startsWith("(")){let s=o(r,0,"(",")");if(s===-1)return!1;let l=r.slice(s+1).trim();if(l&&!l.startsWith(":"))return!1}let c=gt(r);return ct(c.params)||Z(c.params)}function ct(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let i=0;for(let r=0;r<e.length;r++){let c=e.charCodeAt(r);if(c===40)i++;else if(c===41&&--i===0)return r===e.length-1}return!1}function jt(e){let i=0,r=-1;for(let c=0;c<e.length;c++){let s=e.charCodeAt(c);if(s===34||s===39||s===96){c=K(e,c,s)-1;continue}if(s===47&&(e.charCodeAt(c+1)===47||e.charCodeAt(c+1)===42)){if(e.charCodeAt(c+1)===47)while(c+1<e.length&&e.charCodeAt(c+1)!==10&&e.charCodeAt(c+1)!==13)c++;else{let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+1}continue}if(s===40||s===91||s===123)i++;else if(s===41||s===93||s===125)i--;else if(s===63&&i===0&&e.charCodeAt(c+1)!==63)r=c;else if(s===58&&i===0&&r!==-1)return{whenTrue:wt(e.slice(r+1,c)),whenFalse:wt(e.slice(c+1))}}return null}function Y(e,i,r){return(i===0||!N(e.charCodeAt(i-1)))&&!N(e.charCodeAt(i+r))}function Mt(e,i){let r=i;while(r<e.length){if(e.charCodeAt(r)<=32){r++;continue}if(e.startsWith("//",r)){while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;continue}if(e.startsWith("/*",r)){let c=e.indexOf("*/",r+2);r=c<0?e.length:c+2;continue}break}return r}function Zt(e,i){let r=0,c=0,s=0,l=!1,f=!1;for(let u=i;u<e.length;u++){if(u=Mt(e,u),u>=e.length)break;let a=e.charCodeAt(u);if(a===34||a===39||a===96){u=K(e,u,a)-1,f=!1;continue}if(N(a)||a>=128){let d=u;while(u+1<e.length&&(N(e.charCodeAt(u+1))||e.charCodeAt(u+1)>=128))u++;f=l&&["keyof","typeof","readonly","unique","new","abstract","infer","extends"].includes(e.slice(d,u+1));continue}if(a===61&&e.charCodeAt(u+1)===62){u++,f=l;continue}if(a===40)r++;else if(a===41)r--,f=!1;else if(a===91)c++;else if(a===93)c--,f=!1;else if(a===60&&r===0&&c===0)s++;else if(a===62&&s>0&&r===0&&c===0)s--,f=!1;else if(a===123)if(r||c||s||l&&f)u=tt(e,u)-1,f=!1;else return u;else if(r===0&&c===0&&s===0){if(a===58)l=!0,f=!0;else if(l&&[124,38,63].includes(a))f=!0;else if(a===59)return-1}}return-1}function tt(e,i){let r=1,c=i+1;while(c<e.length&&r>0){let s=e.charCodeAt(c);if(s===34||s===39||s===96){c=K(e,c,s);continue}if(s===47&&e.charCodeAt(c+1)===47){c+=2;while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++;continue}if(s===47&&e.charCodeAt(c+1)===42){let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+2;continue}if(s===123)r++;else if(s===125)r--;c++}return c}function K(e,i,r){let c=i+1;while(c<e.length){let s=e.charCodeAt(c);if(s===92){c+=2;continue}if(r===96&&s===36&&e.charCodeAt(c+1)===123){c=tt(e,c+1);continue}if(c++,s===r)break}return c}function Ut(e,i){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!i||e.includes("${")||e.includes(`
|
|
9
|
+
`)||e.includes("\r"))return"string";return e}function vt(e){let i=4;while(i<e.length&&e.charCodeAt(i)<=32)i++;let r=i,c=e.charCodeAt(i);if(c<65||c>90)return"unknown";while(i<e.length&&(N(e.charCodeAt(i))||e.charCodeAt(i)===46))i++;if(i===r)return"unknown";let s=e.slice(r,i);{let l=e.slice(i),f=l;if(l.startsWith("<")){let a=0,d=-1;for(let m=0;m<l.length;m++)if(l[m]==="<")a++;else if(l[m]===">"){if(a--,a===0){d=m;break}}if(d!==-1){let m=l.slice(0,d+1);f=l.slice(d+1);let w=f.indexOf("(");if(w!==-1){let A=0,g=-1;for(let h=w;h<f.length;h++)if(f[h]==="(")A++;else if(f[h]===")"){if(A--,A===0){g=h;break}}if(g!==-1){if(f.slice(g+1).trimStart().startsWith("."))return"unknown"}}return`${s}${m}`}}let u=f.indexOf("(");if(u!==-1){let a=0,d=-1;for(let m=u;m<f.length;m++)if(f[m]==="(")a++;else if(f[m]===")"){if(a--,a===0){d=m;break}}if(d!==-1){if(f.slice(d+1).trimStart().startsWith("."))return"unknown"}}switch(s){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 s}}return"unknown"}function te(e){return"{ new (...args: any[]): any }"}function Rt(e,i,r=0,c){if(e.startsWith("Promise.resolve(")){let l=e.indexOf(")",16);if(l!==-1){let f=e.slice(16,l).trim();if(f)return`Promise<${n(f,i,!1,r+1,c)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let s=e.indexOf("[",12),l=e.lastIndexOf("]");if(s!==-1&&l>s){let f=e.slice(s+1,l).trim(),u=H(f),a=[];for(let d=0;d<u.length;d++){let m=u[d].trim();if(m.startsWith("Promise.resolve(")){let w=Rt(m,i,r+1,c),A=w.indexOf("<"),g=w.lastIndexOf(">");a.push(A!==-1&&g>A?w.slice(A+1,g):"unknown")}else a.push(n(m,i,!1,r+1,c))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function De(e,i,r=0,c){let s=e.slice(1,-1).trim();if(!s)return"never[]";if(r>=nt)return"unknown[]";let l=H(s),f=!1;for(let g=0;g<l.length;g++){let h=l[g],p=h.length;while(p>0&&h.charCodeAt(p-1)<=32)p--;if(p>=8&&h.slice(p-8,p)==="as const"){f=!0;break}}if(f){let g=[];for(let h=0;h<l.length;h++){let p=l[h].trim();if(p.endsWith("as const")){let C=p.slice(0,-8).trim();if(C.startsWith("[")&&C.endsWith("]")){let y=C.slice(1,-1).trim(),W=H(y),x=[];for(let b=0;b<W.length;b++)x.push(n(W[b].trim(),!0,!1,r+1,c));g.push(`readonly [${x.join(", ")}]`)}else g.push(n(C,!0,!1,r+1,c))}else if(p.startsWith("[")&&p.endsWith("]"))g.push(De(p,!0,r+1,c));else g.push(n(p,!0,!1,r+1,c))}return`readonly [
|
|
10
|
+
${g.join(` |
|
|
11
|
+
`)}
|
|
12
|
+
]`}let u=rt&&!i,a=[],d=[];for(let g of l){let h=g.trim(),p=M;if(M=null,h.startsWith("...")){let C=h.slice(3).trim(),y=n(C,!1,!1,r+1,c);if(y.endsWith("[]"))a.push(y.slice(0,-2));else if(y.startsWith("readonly [")&&y.endsWith("]"))a.push(y.slice(10,-1));else if(G(C))a.push(`(typeof ${C})[number]`);else a.push("unknown")}else if(h.startsWith("[")&&h.endsWith("]"))a.push(De(h,i,r+1,c));else a.push(Bt(h,i,r+1,c));if(u)d.push(M);M=p}if(u)if(ht(e))M=v(e);else{let g=[];for(let h=0;h<l.length;h++){let p=l[h].trim();if(p.endsWith("as const"))continue;if(et(p)||p==="null"||p==="undefined")g.push(p);else if(p.startsWith("[")&&ht(p))g.push(v(p));else if(p.startsWith("{")){if(d[h])g.push(d[h])}else{let C=n(p,!1,!1,0,c);if(C!=="unknown")g.push(C)}}if(g.length>0)M=`[${g.join(", ")}]`}if(i)return`readonly [${a.join(", ")}]`;let m=new Set,w=[],A=!0;for(let g of a){if(!m.has(g))m.add(g),w.push(g);if(A){if(!(z(g)||g==="true"||g==="false"||g.charCodeAt(0)===34&&g.charCodeAt(g.length-1)===34||g.charCodeAt(0)===39&&g.charCodeAt(g.length-1)===39))A=!1}}if(A&&a.length<=10)return`readonly [${a.join(", ")}]`;if(w.length===1)return`${w[0]}[]`;return`(${w.join(" | ")})[]`}function H(e){let i=[],r=0,c=!1,s=0,l=-1,f=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(c){if(a===92)u++;else if(a===s)c=!1;f=u+1;continue}if(a===47&&e.charCodeAt(u+1)===47){let d=e.indexOf(`
|
|
13
|
+
`,u+2);u=(d===-1?e.length:d)-1;continue}if(a===47&&e.charCodeAt(u+1)===42){let d=e.indexOf("*/",u+2);u=(d===-1?e.length:d+2)-1;continue}if(a===32||a===9||a===10||a===13)continue;if(a===44&&r===0){if(l!==-1)i.push(e.slice(l,f));l=-1;continue}if(a===34||a===39||a===96)c=!0,s=a;else if(a===91||a===123||a===40)r++;else if(a===93||a===125||a===41)r--;if(l===-1)l=u;f=u+1}if(l!==-1)i.push(e.slice(l,f));return i}function et(e){if(z(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function _t(e){return e==="number"||e==="string"||e==="boolean"}function Jn(e){let i=[],r=0;while(r<e.length){while(r<e.length&&e.charCodeAt(r)<=32)r++;if(e.startsWith("/*",r)){let c=e.indexOf("*/",r+2);if(c===-1)break;i.push(e.slice(r,c+2)),r=c+2}else if(e.startsWith("//",r)){let c=r;while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++;i.push(e.slice(r,c).trimEnd()),r=c}else break}return i}function Wt(e,i,r){let c=i.trim();if(!_t(r)||!et(c))return"";let s=(e??[]).map((f)=>f.trim()).filter((f)=>f.startsWith("/**")||f.startsWith("//")).join(`
|
|
14
|
+
`),l;if(s.includes("@defaultValue"))l=s;else{let f=`@defaultValue ${ue(c)}`;if(!s)l=`/** ${f} */`;else{let u=s.lastIndexOf("*/");if(u!==-1){let a=s.slice(0,u).trimEnd();if(a.startsWith("/** ")&&!a.includes(`
|
|
15
|
+
`))a=`/**
|
|
16
|
+
* ${a.slice(4)}`;l=`${a}
|
|
17
|
+
* ${f}
|
|
18
|
+
*/`}else l=`/**
|
|
19
|
+
* ${s.startsWith("// ")?s.slice(3):s.startsWith("//")?s.slice(2):s}
|
|
20
|
+
* ${f}
|
|
21
|
+
*/`}}return l.split(`
|
|
22
|
+
`).map((f)=>{let u=f.trim();if(!u)return"";return u.startsWith("*")?` ${u}`:` ${u}`}).join(`
|
|
23
|
+
`)+`
|
|
24
|
+
`}function ht(e){let i=!1,r=0,c=e.length;for(let s=0;s<c;s++){let l=e.charCodeAt(s);if(i){if(l===92){s++;continue}if(l===r)i=!1;continue}if(l===34||l===39||l===96){i=!0,r=l;continue}if(l===61&&s+1<c&&e.charCodeAt(s+1)===62)return!1;if(l===47&&(e.charCodeAt(s+1)===47||e.charCodeAt(s+1)===42))return!1;if(l>=97&&l<=122){let f=s;while(s<c&&(e.charCodeAt(s)>=97&&e.charCodeAt(s)<=122||e.charCodeAt(s)>=65&&e.charCodeAt(s)<=90||e.charCodeAt(s)>=48&&e.charCodeAt(s)<=57||e.charCodeAt(s)===95||e.charCodeAt(s)===36))s++;let u=e.slice(f,s);if(u==="new"||u==="async"||u==="await"||u==="function"||u==="yield"||u==="console"||u==="process")return!1;let a=s;while(a<c&&e.charCodeAt(a)<=32)a++;if(a<c&&e.charCodeAt(a)===40)return!1;s--}}return!0}function st(e,i,r=0,c,s){let l=e.slice(1,-1).trim();if(!l)return"{}";if(r>=nt)return"Record<string, unknown>";let f=ie(l),u=new Set(f.flatMap(([y])=>{let W=kt(dt(y).key);return W?.kind==="get"?[W.name]:[]})),a=[],d=[],m=[],w=!1,A=rt&&!i,g=[],h=0;for(let[y,W]of f){let{comments:x,key:b}=dt(y),S=x?`${x}
|
|
25
|
+
`:"",k=kt(b);if(k&&Qn(k.name))continue;let O=b,B=!1;if(b==="..."){let P=W.trim(),F=s?Qt(P,s):G(P)?`typeof ${P}`:n(P,i,!1,r+1,c);if(F!=="unknown")d.push(F);if(A&&(G(P)||P.startsWith("{")))g.push(`...${v(P)}`);continue}let _=M;M=null;let T,E=W.trim();if(E===b&&Z(E))T=(i?void 0:c?.mutableBindingTypes?.get(E))??`typeof ${E}`;else if(ce(E)){B=!0;let P=ae(b);if(P){O=P.name;let F="";if(E.startsWith("async "))F="async ";if(E.charCodeAt(F.length)===42)F+="*";T=Tt(P.name,F+P.typeParams+E.slice(F.length))}else T=Tt(b,E)}else{if(T=s?.(W)??n(W,i,!1,r+1,c),T==="unknown"&&G(E))T=(i?void 0:c?.mutableBindingTypes?.get(E))??`typeof ${E}`;if(T.includes("=>")||T.includes("function")||T.includes("async"))T=$t(T)}let q=M;M=_;let V=O,R=W.trim(),Q=Xn(O,c);if(!Zn(k?.name??O,c)&&!(k?.kind==="set"&&u.has(k.name)))m.push(k?oe(k.kind,T):T);if(Q&&"index"in Q)w=!0;else{if(Q&&"name"in Q)O=Q.name;if(k){let P=se(k.kind,k.name,T);if(P){a.push(`${S}${L(P)}`);continue}}if(!i&&_t(T)&&et(R))a.push(`${S}/** @defaultValue ${ue(R)} */
|
|
26
|
+
${O}: ${L(T)}`);else a.push(`${S}${i?"readonly ":""}${O}: ${L(T)}`)}if(A){let P=St(V);if(R.endsWith("as const"));else if(et(R))g.push(`${P}: ${R}`);else if(R.startsWith("[")&&ht(R))g.push(`${P}: ${v(R)}`);else if(R.startsWith("{")){if(q)g.push(`${P}: ${q}`)}else if(B)g.push(`${P}: ${at($t(T))}`),h++;else if(!R.startsWith("[")&&(R.includes("=>")||R.startsWith("function")||R.startsWith("async"))){let F=ot(R,!1,0,!0);g.push(`${P}: ${at(F)}`),h++}}}if(A&&g.length>h){let y=r>0?(r-1)/2:0,W=`{ ${g.join(", ")} }`;if(W.length<=80)M=W;else{let x=" ".repeat((y+1)*2),b=" ".repeat(y*2);M=`{
|
|
27
|
+
${x}${g.join(`,
|
|
28
|
+
${x}`)}
|
|
29
|
+
${b}}`}}if(w&&d.length===0){let y=[...new Set(m)].map((W)=>W.includes("=>")||W.includes(" & ")?`(${W})`:W);a.unshift(`${i?"readonly ":""}[x: string]: ${L(y.join(" | "))}`)}let p=a.length>0?`{
|
|
30
|
+
${a.join(`;
|
|
31
|
+
`)}
|
|
32
|
+
}`:"{}";if(d.length===0)return p;let C=d[0];for(let y=1;y<d.length;y++)C=`Omit<${C}, keyof ${d[y]}> & ${d[y]}`;return a.length>0?`Omit<${C}, keyof ${p}> & ${p}`:C}function Z(e){if(!e)return!1;let i=e.charCodeAt(0);if(!(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127))return!1;for(let r=1;r<e.length;r++)if(!N(e.charCodeAt(r)))return!1;return!0}function G(e){let i=e.split(".");return i.length>0&&i.every(Z)}function ee(e){let i=!1,r="";for(let c=0;c<e.length;c++){let s=e[c];if(i){if(s==="\\")c++;else if(s===r)i=!1;continue}if(s==='"'||s==="'"||s==="`"){i=!0,r=s;continue}if(s==="(")return c;if(s==="<"){let l=o(e,c,"<",">");if(l!==-1)c=l}}return-1}function Re(e){if(e.length<3||!e.endsWith(")"))return null;let i=ee(e);if(i===-1||o(e,i,"(",")")!==e.length-1)return null;let r=e.slice(0,i).trim(),c=!1;if(r.endsWith("?."))c=!0,r=r.slice(0,-2).trim();let s=r,l=!1,f=r.indexOf("<");if(f!==-1){if(o(r,f,"<",">")!==r.length-1)return null;s=r.slice(0,f).trim(),l=!0}if(!G(s))return null;let u=e.slice(i+1,-1).trim(),a=X(u)!==-1||u.startsWith("function")||u.startsWith("async function"),d=G(u),m=!a&&u.endsWith(")")&&Re(u)!==null,w=s.indexOf(".");if(w!==-1){if(s.indexOf(".",w+1)!==-1)return null}else if(!l&&!c&&!a&&!d&&!m)return null;let A=`ReturnType<typeof ${r}>`;return c?`${A} | undefined`:A}function $t(e){let r=e.split(`
|
|
33
|
+
`).map((m)=>Dt(m)).join(`
|
|
34
|
+
`),c=r.indexOf("async");if(c!==-1){let m=c>0?r.charCodeAt(c-1):32,w=c+5<r.length?r.charCodeAt(c+5):32;if(!N(m)&&!N(w))r=(r.slice(0,c)+r.slice(c+5)).trim()}let s=r.indexOf("(");if(s!==-1){let m=o(r,s,"(",")");if(m!==-1){let w=r.slice(s,m+1),A=le(w);r=r.slice(0,s)+A+r.slice(m+1)}}let l=r.length,f="",u=[],a=!1,d=!1;for(let m=0;m<l;m++){let w=r.charCodeAt(m);if(w===123||w===40)u.push(w);else if(w===125||w===41)u.pop();if(w<=32){if(a=!0,w===10||w===13)d=!0;continue}if(a&&f.length>0){let g=(u.length>0?u[u.length-1]:0)===123;if(d&&g){let h=f.charCodeAt(f.length-1),p=h===59||h===44||h===123||w===125,C=f.length>=2&&f.charCodeAt(f.length-1)===47&&f.charCodeAt(f.length-2)===42;if(!p&&!C)f+="; ";else f+=" "}else f+=" "}a=!1,d=!1,f+=r[m]}return f.trim()}function N(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function le(e){let i=e.trim(),r,c=!1;if(i.startsWith("(")&&i.endsWith(")"))r=i.slice(1,-1),c=!0;else r=i;let s=r.trim();if(!s)return c?"()":"";let l=!1;{let h=0;for(let p=0;p<s.length;p++){let C=s.charCodeAt(p);if(C===40||C===60||C===91||C===123)h++;else if(C===41||C===93||C===125||C===62&&s.charCodeAt(p-1)!==61)h--;else if(h===0&&C===61){let y=p>0?s.charCodeAt(p-1):0,W=p+1<s.length?s.charCodeAt(p+1):0;if(y!==61&&y!==33&&y!==60&&y!==62&&W!==61&&W!==62){l=!0;break}}}}if(!l)return i;let f=[],u=[],a=0,d=0,m=!1,w=0;for(let h=0;h<=s.length;h++){if(h===s.length){f.push(s.slice(a));break}let p=s.charCodeAt(h);if(m){if(p===92){h++;continue}if(p===w)m=!1;continue}if(p===47&&h+1<s.length){let C=s.charCodeAt(h+1);if(C===42){h+=2;while(h+1<s.length&&!(s.charCodeAt(h)===42&&s.charCodeAt(h+1)===47))h++;h++;continue}if(C===47){while(h<s.length&&s.charCodeAt(h)!==10)h++;continue}}if(p===39||p===34||p===96){m=!0,w=p;continue}if(p===40||p===60||p===91||p===123)d++;else if(p===41||p===93||p===125||p===62&&s.charCodeAt(h-1)!==61)d--;else if(p===44&&d===0){f.push(s.slice(a,h));let C=",",y=h+1;while(y<s.length&&s.charCodeAt(y)<=32)C+=s[y],y++;u.push(C),a=y}}let A=[];for(let h of f){let p=h.trim();if(!p){A.push(h);continue}if(p.startsWith("//"))continue;let C=Dt(p),y=h.slice(0,h.length-h.trimStart().length);A.push(y+ne(C))}let g=A[0]||"";for(let h=1;h<A.length;h++)g+=(u[h-1]||", ")+A[h];return Oe(c?`(${g})`:g)}function Dt(e){let i=!1,r=0;for(let c=0;c<e.length-1;c++){let s=e.charCodeAt(c);if(i){if(s===92){c++;continue}if(s===r)i=!1;continue}if(s===39||s===34||s===96){i=!0,r=s;continue}if(s===47&&e.charCodeAt(c+1)===47)return e.slice(0,c).trimEnd()}return e}function ne(e){if(e.startsWith("..."))return e;let i=-1,r=-1,c=0,s=!1,l=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(s){if(a===92){u++;continue}if(a===l)s=!1;continue}if(a===47&&u+1<e.length){let d=e.charCodeAt(u+1);if(d===42){u+=2;while(u+1<e.length&&!(e.charCodeAt(u)===42&&e.charCodeAt(u+1)===47))u++;u++;continue}if(d===47){while(u<e.length&&e.charCodeAt(u)!==10)u++;continue}}if(a===39||a===34||a===96){s=!0,l=a;continue}if(a===40||a===60||a===91||a===123)c++;else if(a===41||a===93||a===125||a===62&&e.charCodeAt(u-1)!==61)c--;else if(c===0){if(a===58&&i===-1)i=u;else if(a===61&&r===-1&&(u===0||e.charCodeAt(u-1)!==61)&&(u+1>=e.length||e.charCodeAt(u+1)!==61&&e.charCodeAt(u+1)!==62))r=u}}let f=r!==-1;if(i!==-1&&(r===-1||i<r)){let u=e.slice(0,i).trim(),a=r!==-1?e.slice(i+1,r).trim():e.slice(i+1).trim(),d=f&&!u.endsWith("?")?"?":"";return`${u}${d}: ${a}`}else if(r!==-1){let u=e.slice(0,r).trim(),a=fe(u,e.slice(r+1));if(a)return Ie(a,xt);let d=!u.endsWith("?")?"?":"";return`${u}${d}: ${xt(e.slice(r+1))}`}return e}function xt(e){let i=e.trim();if(i==="true"||i==="false")return"boolean";if(z(i))return"number";if(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))return"string";if(i.startsWith("["))return"unknown[]";if(i.startsWith("{"))return"Record<string, unknown>";return"unknown"}function re(e){let i=0,r=e.length;while(i<r){while(i<r&&(e.charCodeAt(i)===32||e.charCodeAt(i)===9||e.charCodeAt(i)===10||e.charCodeAt(i)===13))i++;if(i+1<r&&e.charCodeAt(i)===47&&e.charCodeAt(i+1)===42){i+=2;while(i+1<r&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i+=2;continue}break}return i}function dt(e){let i=[],r=0,c=e.length;while(r<c){while(r<c&&e.charCodeAt(r)<=32)r++;if(r+1>=c||e.charCodeAt(r)!==47||e.charCodeAt(r+1)!==42)break;let s=r;r+=2;while(r+1<c&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))r++;r=Math.min(r+2,c),i.push(e.slice(s,r).trim())}return{comments:i.join(`
|
|
35
|
+
`),key:e.slice(r).trim()}}function ie(e){let i=[],r="",c="",s=0,l=!1,f="",u=!0,a=!1,d=0,m=!1,w=!1,A=0,g=!1,h=!1;for(let p=0;p<e.length;p++){let C=e.charCodeAt(p),y=p>0?e.charCodeAt(p-1):0,W=p<e.length-1?e.charCodeAt(p+1):0;if(!l&&!a&&C===47&&W===47){r=r.replace(/[ \t]+$/,""),p+=2;while(p<e.length&&e.charCodeAt(p)!==10)p++;p--;continue}if(!l&&!a&&C===47&&W===42){a=!0,d=1,r+="/*",p++;continue}else if(a&&C===42&&W===47){if(d--,r+="*/",p++,d===0)a=!1;continue}else if(a&&C===47&&W===42){d++,r+="/*",p++;continue}let x=e[p];if(!l&&!a&&(C===34||C===39||C===96))l=!0,f=x,r+=x;else if(l&&x===f&&y!==92)l=!1,r+=x;else if(!l&&!a)if(C===46&&W===46&&e.charCodeAt(p+2)===46&&s===0&&u)c=`${r.trim()}...`,r="",u=!1,g=!1,p+=2;else if(C===40&&s===0&&u&&A===0){c=r.trim();let b=re(c),S=b>0?c.slice(0,b):"",k=c.slice(b),O="";if(k.startsWith("async ")||k.startsWith("async\t")||k.startsWith(`async
|
|
36
|
+
`))k=k.slice(6).trimStart(),O="async ";if(k.startsWith("*"))k=k.slice(1).trimStart(),O+="*";c=S+k,r=O+x,u=!1,g=!0,h=!1,s=1}else if(C===123||C===91||C===40){if(s++,r+=x,h&&C===123)h=!1}else if(C===125||C===93||C===41){if(s--,r+=x,C===41&&s===0&&!u&&!g)m=!0;if(g){if(C===41&&s===0&&!h)h=!0;else if(C===125&&s===0)g=!1,h=!1}}else if(C===58&&s===0&&u&&A===0)c=r.trim(),r="",u=!1;else if(C===58&&s===0&&m)w=!0,r+=x;else if(C===60&&w)A++,r+=x;else if(C===60&&u&&s===0)A++,r+=x;else if(C===62&&A>0&&y!==61)A--,r+=x;else if(C===61&&W===62&&w&&A===0)w=!1,m=!1,r+=x;else if(C===44&&s===0&&A===0&&!h){if(c&&r.trim()){let b=r.trim();i.push([c,b])}else if(u&&r.trim())bt(i,r.trim());r="",c="",u=!0,m=!1,w=!1,A=0}else r+=x;else r+=x}if(c&&r.trim()){let p=r.trim();i.push([c,p])}else if(u&&r.trim())bt(i,r.trim());return i}function bt(e,i){let{comments:r,key:c}=dt(i);if(Z(c))e.push([r?`${r}
|
|
37
|
+
${c}`:c,c]);else if(c.startsWith("...")&&c.length>3)e.push(["...",c.slice(3).trim()])}function kt(e){let i=e.trim();if(i.startsWith("get ")&&i.length>4){let r=i.slice(4).trim();if(r)return{kind:"get",name:r}}if(i.startsWith("set ")&&i.length>4){let r=i.slice(4).trim();if(r)return{kind:"set",name:r}}return null}function se(e,i,r){let c=r.trim();if(c.charCodeAt(0)!==40)return null;let s=o(c,0,"(",")");if(s===-1)return null;let l=c.slice(1,s).trim(),f=c.slice(s+1).trimStart();if(!f.startsWith("=>"))return null;let u=f.slice(2).trim();if(e==="get")return`get ${i}(): ${u||"unknown"}`;return`set ${i}(${l})`}function oe(e,i){let r=i.trim(),c=o(r,0,"(",")");if(!r.startsWith("(")||c===-1)return"unknown";if(e==="get"){let u=r.slice(c+1).trim();return u.startsWith("=>")?u.slice(2).trim():"unknown"}let s=r.slice(1,c).trim(),l=s.startsWith("{")?o(s,0,"{","}"):s.startsWith("[")?o(s,0,"[","]"):0,f=s.indexOf(":",Math.max(0,l));return f===-1?"unknown":s.slice(f+1).trim()}function ce(e){let i=e;if(i.startsWith("async ")||i.startsWith("async\t"))i=i.slice(5).trimStart();if(i.startsWith("*"))i=i.slice(1).trimStart();if(!i.startsWith("("))return!1;let r=0;for(let c=0;c<i.length;c++){let s=i.charCodeAt(c);if(s===40)r++;else if(s===41){if(r--,r===0){let l=i.slice(c+1).trimStart();if(l.startsWith("{"))return!0;if(l.startsWith(":")){let f=mt(l,1);if(f?.kind==="arrow")return!1;if(f?.kind==="body")return!0}return!1}}}return!1}function ae(e){let i=e.trimEnd();if(!i.endsWith(">"))return null;let r=0,c=-1;for(let l=i.length-1;l>=0;l--){let f=i.charCodeAt(l);if(f===62){if(l>0&&i.charCodeAt(l-1)===61)continue;r++}else if(f===60){if(r--,r===0){c=l;break}}}if(c===-1)return null;let s=i.slice(0,c).trimEnd();if(!s)return null;return{name:s,typeParams:i.slice(c)}}function Tt(e,i){let r=i.trimStart(),c=!1,s=!1;if(r.startsWith("async ")||r.startsWith("async\t"))c=!0,r=r.slice(5).trimStart();if(r.startsWith("*"))s=!0,r=r.slice(1).trimStart();let l="";if(r.charCodeAt(0)===60){let A=0,g=-1;for(let h=0;h<r.length;h++)if(r.charCodeAt(h)===60)A++;else if(r.charCodeAt(h)===62&&!(h>0&&r.charCodeAt(h-1)===61)){if(A--,A===0){g=h;break}}if(g!==-1)l=r.slice(0,g+1),r=r.slice(g+1).trimStart()}let f=r.indexOf("("),u=o(r,f,"(",")");if(f===-1||u===-1)return"() => unknown";let a=r.slice(f,u+1),d="unknown",m=r.slice(u+1).trimStart();if(m.charCodeAt(0)===58){let A=m.slice(1),g=mt(A,0);if(g)d=A.slice(0,g.index).trim();else d=A.trim()}if(d==="unknown"&&!s&&m.charCodeAt(0)===123){let A=o(m,0,"{","}");if(A!==-1){let g=I(m.slice(1,A),c,a);if(g!=="unknown"&&g!=="Promise<unknown>")d=c&&g.startsWith("Promise<")?g.slice(8,-1):g;else if(c)d="Promise<unknown>"}}if(d==="unknown"){if(c&&s)d="AsyncGenerator<unknown, void, unknown>";else if(s)d="Generator<unknown, void, unknown>";else if(c)d="Promise<void>"}else if(c&&!d.startsWith("Promise<")&&!d.startsWith("AsyncGenerator<"))d=`Promise<${d}>`;let w=le(a);return`${l}${w} => ${d}`}function mt(e,i){let r=0,c=0,s=0,l=0,f=!1,u=0;for(let a=i;a<e.length;a++){let d=e.charCodeAt(a);if(f){if(d===92)a++;else if(d===u)f=!1;continue}if(d===34||d===39||d===96){f=!0,u=d;continue}if(d===40)r++;else if(d===41&&r>0)r--;else if(d===91)c++;else if(d===93&&c>0)c--;else if(d===60)s++;else if(d===62&&s>0&&e.charCodeAt(a-1)!==61)s--;else if(d===125&&l>0)l--;else if(d===123){let m=r>0||c>0||s>0||l>0,w=e.slice(i,a).trimEnd(),A=w.charCodeAt(w.length-1),g=w.length===0||A===38||A===124||A===40||A===44||A===58||A===61||A===91;if(m||g)l++;else return{index:a,kind:"body"}}else if(d===61&&a+1<e.length&&e.charCodeAt(a+1)===62&&r===0&&c===0&&s===0&&l===0)return{index:a,kind:"arrow"}}return null}function o(e,i,r,c){let s=0;for(let l=i;l<e.length;l++)if(e[l]===r)s++;else if(e[l]===c){if(c===">"&&l>0&&e[l-1]==="=")continue;if(s--,s===0)return l}return-1}function X(e){let i=0,r=0,c=!1,s="";for(let l=0;l<e.length-1;l++){let f=e[l],u=e[l+1],a=l>0?e[l-1]:"";if(!c&&(f==='"'||f==="'"||f==="`"))c=!0,s=f;else if(c&&f===s&&a!=="\\")c=!1;if(!c){if(f==="<"){let d=o(e,l,"<",">");if(d!==-1){l=d;continue}}if(f==="(")i++;else if(f===")")i--;else if(f==="[")r++;else if(f==="]")r--;if(f==="="&&u===">"&&i===0&&r===0)return l}}return-1}function ot(e,i=!1,r=0,c=!0){let s=e.trim();if(s.length>200&<(s,"=>")>2&<(s,"<")>5&&!s.startsWith("function"))return i?"((...args: any[]) => any)":"(...args: any[]) => any";if(s.startsWith("async ")&&s.includes("=>")){let f=s.slice(5).trim(),u=X(f);if(u===-1)return i?"(() => Promise<unknown>)":"() => Promise<unknown>";let a=f.substring(0,u).trim(),d=f.substring(u+2).trim(),m=gt(a),{params:w,returnType:A}=m;if(w=le(w),w==="()"||w==="")w="()";else if(!w.startsWith("("))w=`(${w})`;let g=A;if(g);else if(d.startsWith("{"))g=I(d.slice(1,d.endsWith("}")?-1:void 0),!0,m.params);else g=D(d,ut(m.params));let h=`${w} => ${A||g.startsWith("Promise<")?g:`Promise<${g}>`}`;return i?`(${h})`:h}if(s.includes("=>")){let f="",u=s;if(s.startsWith("<")){let C=o(s,0,"<",">");if(C!==-1)f=s.substring(0,C+1),u=s.substring(C+1).trim()}let a=X(u);if(a===-1)return i?"(() => unknown)":"() => unknown";let d=u.substring(0,a).trim(),m=u.substring(a+2).trim(),w=gt(d),{params:A,returnType:g}=w;if(A=le(A),A==="()"||A==="")A="()";else if(!A.startsWith("("))A=`(${A})`;let h="unknown";if(g)h=g;else if(m.startsWith("{"))h=I(m.slice(1,m.endsWith("}")?-1:void 0),!1,w.params);else if(U(m)||ct(m)&&U(m.slice(1,-1).trim()))h="JSX.Element";else if(m.includes("=>")){let C=m.trimStart(),y=C.indexOf("("),W=y!==-1?o(C,y,"(",")"):-1,x=W!==-1?C.indexOf("=>",W):-1;if(y===0&&W!==-1&&x!==-1){let b=C.substring(y+1,W).trim(),S=le(b);if(f.includes("T")&&S.includes("T"))h=`(${S}) => T`;else h=`(${S}) => any`}else h="any"}else h=D(m,ut(w.params));let p=`${f}${A} => ${h}`;return i?`(${p})`:p}if(s.startsWith("function")){let f=8,u=s.length;while(f<u&&s.charCodeAt(f)<=32)f++;let a=!1;if(f<u&&s.charCodeAt(f)===42){a=!0,f++;while(f<u&&s.charCodeAt(f)<=32)f++}let d="";if(f<u&&s.charCodeAt(f)===60){let A=f,g=1;f++;while(f<u&&g>0){let h=s.charCodeAt(f);if(h===60)g++;else if(h===62&&s.charCodeAt(f-1)!==61)g--;f++}d=s.substring(A,f);while(f<u&&s.charCodeAt(f)<=32)f++}let m=s.indexOf("(",f);if(m!==-1){let A=1,g=m+1;while(g<u&&A>0){let x=s.charCodeAt(g);if(x===40)A++;else if(x===41)A--;g++}let h=s.substring(m+1,g-1).trim(),p=h?le(`(${h})`):"()";if(a){let x=s.substring(g).trim(),b=x.indexOf("Generator<");if(b!==-1){let k=b+10,O=x.indexOf(">",k);if(O!==-1){let B=x.substring(k,O),_=`${d}${p} => Generator<${B}>`;return i?`(${_})`:_}}let S=`${d}${p} => Generator<any, any, any>`;return i?`(${S})`:S}let C="unknown",y=s.substring(g).trimStart();if(y.charCodeAt(0)===58){let x=y.slice(1),b=mt(x,0),S=(b?x.slice(0,b.index):x).trim();if(S)C=S}let W=`${d}${p} => ${C}`;return i?`(${W})`:W}let w="(...args: any[]) => unknown";return i?`(${w})`:w}if(s.includes("=>")&&s.includes("(")&&s.includes(")")){if(s.length>100||lt(s,"=>")>2){let f="";if(s.charCodeAt(0)===60){let w=o(s,0,"<",">");if(w!==-1)f=s.substring(0,w+1)}let u=s.indexOf("("),a=u!==-1?o(s,u,"(",")"):-1,d=u!==-1&&a!==-1?s.substring(u,a+1):"(...args: any[])";d=le(d);let m=`${f}${d} => any`;return i?`(${m})`:m}return i?`(${s})`:s}let l="() => unknown";return i?`(${l})`:l}function gt(e){let i=e.trim();if(!i.startsWith("("))return{params:i,returnType:""};let r=o(i,0,"(",")");if(r===-1)return{params:i,returnType:""};let c=i.slice(r+1).trim();return{params:i.slice(0,r+1),returnType:c.startsWith(":")?c.slice(1).trim():""}}function Me(e){let i=e.trim();if(i==="any"||i==="object"||i==="unknown")return!0;if(i.startsWith("Record<")&&i.endsWith(">"))return!0;if(i.startsWith("Array<")&&i.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(i))return!0;return!1}function j(e){let i=-1,r=0;for(let s=0;s<e.length;s++){let l=e.charCodeAt(s);if(l===34||l===39||l===96){s=K(e,s,l)-1;continue}if(l===47&&e.charCodeAt(s+1)===47){while(s<e.length&&e.charCodeAt(s)!==10)s++;continue}if(l===47&&e.charCodeAt(s+1)===42){let f=e.indexOf("*/",s+2);s=f===-1?e.length:f+1;continue}if(l===47){let f=s-1;while(f>=0&&e.charCodeAt(f)<=32)f--;if(f<0||"([{:;,=!?&|+*-~>".includes(e[f])){let u=!1;for(s++;s<e.length;s++){let a=e.charCodeAt(s);if(a===92)s++;else if(a===91)u=!0;else if(a===93)u=!1;else if(a===47&&!u)break}continue}}if(l===40||l===91||l===123)r++;else if(l===41||l===93||l===125)r--;else if(r===0&&e.startsWith("satisfies",s)&&Y(e,s,9)&&e[s-1]!==".")i=s}if(i===-1)return null;let c=e.slice(i+9).trim();if(c.endsWith(";"))c=c.slice(0,-1).trim();return c||null}function Fa(e){let i=e.trim(),r=i.match(/^\{\s*\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(r){let[,l,f,u,a]=r;return`{ [${l} in ${f}]${u?"?":""}: ${a} }`}let c=i.match(/^\{\s*readonly\s+\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(c){let[,l,f,u,a]=c;return`{ readonly [${l} in ${f}]${u?"?":""}: ${a} }`}let s=i.match(/^\{\s*(-?readonly\s+)?\[(\w+)\s+in\s+(.+?)\](-?\?)?\s*:\s*(.+)\s*\}$/);if(s){let[,l,f,u,a,d]=s;return`{ ${l?`${l.trim()} `:""}[${f} in ${u}]${a||""}: ${d} }`}return null}function Na(e){let i=e.trim(),r=i.indexOf(" extends ");if(r===-1)return null;let c=i.slice(r+9),s=he(c);if(s===-1)return null;let l=de(c,s);if(l===-1)return null;let f=i.slice(0,r).trim(),u=c.slice(0,s).trim(),a=c.slice(s+1,l).trim(),d=c.slice(l+1).trim();return`${f} extends ${u} ? ${a} : ${d}`}function he(e){let i=0,r=!1,c="";for(let s=0;s<e.length;s++){let l=e[s],f=s>0?e[s-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,c=l;else if(r&&l===c&&f!=="\\")r=!1;if(!r){if(l==="<"||l==="("||l==="["||l==="{")i++;if(l===">"||l===")"||l==="]"||l==="}")i--;if(l==="?"&&i===0)return s}}return-1}function de(e,i){let r=0,c=!1,s="";for(let l=i+1;l<e.length;l++){let f=e[l],u=l>0?e[l-1]:"";if(!c&&(f==='"'||f==="'"||f==="`"))c=!0,s=f;else if(c&&f===s&&u!=="\\")c=!1;if(!c){if(f==="<"||f==="("||f==="["||f==="{")r++;if(f===">"||f===")"||f==="]"||f==="}")r--;if(f==="?"&&r===0)r++;if(f===":"&&r===0)return l;if(f===":"&&r>0)r--}}return-1}function Ba(e){let i=e.trim();if(!i.startsWith("`")||!i.endsWith("`"))return null;let r=i.slice(1,-1);if(!r.includes("${"))return i;let c=[],s="",l=0;while(l<r.length)if(r[l]==="$"&&r[l+1]==="{"){if(s)c.push(`"${s}"`),s="";let f=1,u="";l+=2;while(l<r.length&&f>0){if(r[l]==="{")f++;if(r[l]==="}")f--;if(f>0)u+=r[l];l++}c.push(u.trim())}else s+=r[l],l++;if(s)c.push(`"${s}"`);return i}function Wa(e){let i=[],r=/infer\s+(\w+)/g,c;while((c=r.exec(e))!==null)i.push(c[1]);return i}function _a(e){let r=e.trim(),c=r.indexOf("[");if(c!==-1){if(r.indexOf(" in ",c)!==-1)return!0}let s=r.indexOf(" extends ");if(s!==-1){let f=r.indexOf(" ? ",s);if(f!==-1&&r.indexOf(" : ",f)!==-1)return!0}if(r.charCodeAt(0)===96&&r.charCodeAt(r.length-1)===96){if(r.indexOf("${")!==-1)return!0}let l=r.indexOf("infer ");if(l!==-1){if(l===0||!N(r.charCodeAt(l-1)))return!0}return!1}function ja(e,i=3){let r=e.trim(),c=0,s=0;for(let l of r){if(l==="<"||l==="("||l==="["||l==="{")c++,s=Math.max(s,c);if(l===">"||l===")"||l==="]"||l==="}")c--}if(s>i){let l=r.match(/^(\w+)</);if(l)return`${l[1]}<any>`;return"unknown"}return r}function Ga(e){let r=e.trim().match(/^(\w+)<(.+)>$/);if(!r)return null;let c=r[1],s=r[2],l=ya(s);if(["Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer"].includes(c))return{name:c,params:l};return null}function ya(e){let i=[],r="",c=0,s=!1,l="";for(let f=0;f<e.length;f++){let u=e[f],a=f>0?e[f-1]:"";if(!s&&(u==='"'||u==="'"||u==="`"))s=!0,l=u;else if(s&&u===l&&a!=="\\")s=!1;if(!s){if(u==="<"||u==="("||u==="["||u==="{")c++;if(u===">"||u===")"||u==="]"||u==="}")c--;if(u===","&&c===0){i.push(r.trim()),r="";continue}}r+=u}if(r.trim())i.push(r.trim());return i}function Va(e){let i=e.trim();if(i.startsWith("keyof "))return i;return null}function Ua(e){let i=e.trim();if(i.startsWith("typeof "))return i;return null}function za(e){let i=e.trim();if(i.length===0||i.charCodeAt(0)===91)return!1;if(i.charCodeAt(i.length-1)!==93)return!1;let r=i.indexOf("[");if(r<=0)return!1;for(let c=0;c<r;c++){let s=i.charCodeAt(c);if(!N(s)&&s!==46)return!1}return!0}
|
|
38
|
+
export{Ft,Nt,z,ga,it,n,Bt,I,ha,L,De,H,Jn,Wt,st,Re,le,o,ot,Me,j,Fa,Na,Ba,Wa,_a,ja,Ga,ya,Va,Ua,za};
|
|
@@ -14,5 +14,5 @@ var d=null,m=null;async function P(){if(d!==null)return d;try{return m=await imp
|
|
|
14
14
|
`),s=[],a=[],i=!1,u=0;for(let o=0;o<n.length;o++){let t=n[o],p=t.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(p){i=!0,u=o;let c=p[1];s.push({line:t,source:p[2],isType:c.startsWith("import type ")||c.startsWith("import type\t")})}else if(i&&t.trim()==="")continue;else{if(i)i=!1;a.push(t)}}if(s.length===0)return r;if(e.sort)s.sort((o,t)=>{if(o.isType!==t.isType)return o.isType?1:-1;return M(o.source,t.source)});let l;if(e.group){let o=[],t=[],p=[],c=[],b=[];for(let f=0;f<s.length;f++){let g=s[f],h=g.source;if(h.charCodeAt(0)===46)b.push(g);else if(h.startsWith("node:"))o.push(g);else if(h.charCodeAt(0)===64)c.push(g);else if(h.includes("/"))p.push(g);else t.push(g)}l=[...o.map((f)=>f.line),...o.length>0&&t.length>0?[""]:[],...t.map((f)=>f.line),...(o.length>0||t.length>0)&&p.length>0?[""]:[],...p.map((f)=>f.line),...c.length>0&&(o.length>0||t.length>0||p.length>0)?[""]:[],...c.map((f)=>f.line),...b.length>0?[""]:[],...b.map((f)=>f.line)]}else l=s.map((o)=>o.line);return[...l,"",...a].join(`
|
|
15
15
|
`)}function M(r,e){let n=r.startsWith("node:"),s=e.startsWith("node:");if(n!==s)return n?-1:1;let a=r.startsWith("."),i=e.startsWith(".");if(a!==i)return a?1:-1;return r.localeCompare(e)}function W(r,e,n){let s=r.split(`
|
|
16
16
|
`),a=[];for(let i of s){if(i.length<=e){a.push(i);continue}if(i.trimStart().startsWith("import ")){a.push(i);continue}let u=i.match(/^(\s*)/)?.[1]||"",l=u+n,o=O(i,u,l);if(o){a.push(...o);continue}if(i.includes("{")&&i.includes("}")){let t=v(i,e,u,l);a.push(...t);continue}if(i.includes(" | ")){let t=R(i,e,u,l);a.push(...t);continue}a.push(i)}return a.join(`
|
|
17
|
-
`)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(r,e,n){let s=r.match(F);if(!s)return null;let[,a,i,u,l]=s,o=u.split(",").map((c)=>c.trim()).filter(Boolean);if(o.length<=1)return[r];let t=`${e}${a}${i??""} {`,p=l?`${e}} ${l};`:`${e}};`;return[t,...o.map((c)=>`${n}${c},`),p]}function v(r,e,n,s){let a=r.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!a)return[r];let[,,i,u,l,o]=a,t=l.split(/;\s*|,\s*/).filter((c)=>c.trim());if(t.length<=1)return[r];return[`${n}${i}${u}`,...t.map((c)=>`${s}${c.trim()};`),`${n}${o.trim()}`]}function R(r,e,n,s){let a=r.match(/^(\s*)(.*?=\s*)(.+)$/);if(!a)return[r];let[,,i,u]=a,l=u.split(/\s*\|\s*/).filter((t)=>t.trim());if(l.length<=2)return[r];return[`${n}${i}`,...l.map((t,p)=>`${s}${p>0?"| ":" "}${t.trim()}`)]}async function
|
|
18
|
-
export{
|
|
17
|
+
`)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(r,e,n){let s=r.match(F);if(!s)return null;let[,a,i,u,l]=s,o=u.split(",").map((c)=>c.trim()).filter(Boolean);if(o.length<=1)return[r];let t=`${e}${a}${i??""} {`,p=l?`${e}} ${l};`:`${e}};`;return[t,...o.map((c)=>`${n}${c},`),p]}function v(r,e,n,s){let a=r.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!a)return[r];let[,,i,u,l,o]=a,t=l.split(/;\s*|,\s*/).filter((c)=>c.trim());if(t.length<=1)return[r];return[`${n}${i}${u}`,...t.map((c)=>`${s}${c.trim()};`),`${n}${o.trim()}`]}function R(r,e,n,s){let a=r.match(/^(\s*)(.*?=\s*)(.+)$/);if(!a)return[r];let[,,i,u]=a,l=u.split(/\s*\|\s*/).filter((t)=>t.trim());if(l.length<=2)return[r];return[`${n}${i}`,...l.map((t,p)=>`${s}${p>0?"| ":" "}${t.trim()}`)]}async function K(r,e={},n){let s=[];if(e.usePrettier!==!1){if(await P())try{let l={...await y(e.prettierConfigPath,n),...e.prettierOptions,parser:"typescript"};return{content:await w(r,l),usedPrettier:!0}}catch(u){s.push(`Prettier formatting failed: ${u}. Using built-in formatter.`)}else if(e.usePrettier===!0)s.push("Prettier requested but not available. Using built-in formatter.")}return{content:C(r,e.builtIn),usedPrettier:!1,warnings:s.length>0?s:void 0}}async function Xr(r,e={}){let n=new Map;for(let[s,a]of r){let i=await K(a,e,s);n.set(s,i)}return n}function so(r={}){return{format:(e,n)=>K(e,r,n),formatMany:(e)=>Xr(e,r)}}async function oo(r){return(await K(r,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}
|
|
18
|
+
export{K,Xr,so,oo};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-q4fhsthj.js";import{be}from"./chunk-vae5wxar.js";import{readFileSync as u}from"fs";import{readFile as p}from"fs/promises";import{resolve as g}from"path";function m(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"").replace(/,\s*([}\]])/g,"$1")}function Ss(t,e){try{return{...JSON.parse(m(u(t,"utf8"))).compilerOptions,...e}}catch(s){throw Error(`Error reading tsconfig.json: ${s instanceof Error?s.message:String(s)}`)}}function f(t,e){let s=e.declarationsOnly?t.filter((o)=>o.endsWith(".d.ts")):t;if(e.include?.length){let o=e.include.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>o.some((i)=>i.test(n)))}if(e.exclude?.length){let o=e.exclude.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>!o.some((i)=>i.test(n)))}return s}async function dt(t,e={}){let s=performance.now(),o=f(t,e),n=[];for(let a of o)try{let c=await p(a,"utf8");for(let l of be(c))n.push({file:a,line:l.line,column:l.column,message:l.message,code:Number(l.code.slice(4)),severity:"error",category:"Error"})}catch(c){n.push({file:a,line:0,column:0,message:c instanceof Error?c.message:String(c),code:1000,severity:"error",category:"Error"})}let i=e.maxErrors?n.slice(0,e.maxErrors):n;return{success:i.length===0,diagnostics:i,errorCount:i.length,warningCount:0,infoCount:0,filesChecked:o,durationMs:performance.now()-s}}function Tr(t,e={}){return dt(t,{...e,declarationsOnly:!0})}async function $s(t){let e=new Map;for(let s of t){let o=await p(s,"utf8").catch(()=>""),n=[];for(let i of r(o,s,!1,!0))if(i.isExported&&i.kind==="function"&&!i.returnType)n.push({line:1,column:1,message:"Exported function requires an explicit return type",declarationName:i.name,missingAnnotation:"return"});e.set(s,{compatible:n.length===0,issues:n})}return e}function d(t,e,s){let o=t.split(`
|
|
3
3
|
`);if(e<1||e>o.length||s<1||s>o[e-1].length+1)return null;let n=s-1;for(let i=0;i<e-1;i++)n+=o[i].length+1;return n}function Ar(t,e,s){try{let o=u(t,"utf8"),n=d(o,e,s);if(n===null)return null;let i=r(o,t,!1).find((a)=>n>=(a.start??0)&&n<=(a.end??o.length));return i?.typeAnnotation??i?.returnType??i?.text??null}catch{return null}}function Es(t,e,s){let o=Ar(t,e,s);return o?{type:o}:null}function ks(t){if(t.success)return`\u2713 Type check passed (${t.filesChecked.length} files checked in ${t.durationMs}ms)`;return["\u2717 Type check failed",` ${t.errorCount} error(s), ${t.warningCount} warning(s)`,...t.diagnostics.map((e)=>`\u2717 ${e.file}:${e.line}:${e.column}
|
|
4
4
|
${e.message}`)].join(`
|
|
5
5
|
`)}function Ts(t){return dt(t.entrypoints.map((e)=>g(t.cwd,e)),{tsconfigPath:t.tsconfigPath,rootDir:t.root})}async function As(t,e){let o=(await Promise.all([dt(t),Tr(e)])).flatMap((n)=>n.diagnostics).map((n)=>({sourceName:n.file,sourceType:n.message,dtsType:"<invalid>"}));return{valid:o.length===0,mismatches:o}}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{u}from"./chunk-
|
|
2
|
+
import{u}from"./chunk-85d82vn3.js";import{m}from"./chunk-g0dxj89b.js";import{y}from"./chunk-a2dn9j88.js";import{r}from"./chunk-q4fhsthj.js";import{$e}from"./chunk-298wqs3n.js";function Xo(c){if(!c.includes("declare")||!c.includes("module"))return[];return m(c).filter((d)=>d.category==="augmentation").map((d)=>d.specifier)}function E(c,d){let p=new Set([c]);for(let v of p)for(let h of d(v))p.add(h);return p}async function Se(c,d,p=!1,v){let h=new Map,x=new Map;for(let e of c){let g=v?.get(e)??await u(e);h.set(e,g);let s=Xo(g);if(s.length)x.set(e,s)}let M=new Map;if(x.size===0)return M;let l=new Map,b=(e,g)=>{let s=d(e,g);if(s.resolved)return s.resolved;if(!s.isRelative&&!s.isAlias)return`external:${e}`;return};for(let[e,g]of h){let s=r(g,e,!1,p),a=$e(s),f={edges:[],declarations:new Set,augmentations:new Set},w=(n,i,t)=>{let o=b(n.specifier,e);if(!o)return;if(h.has(o))f.edges.push({specifier:n.specifier,target:o,import:i});if(t)f.declarations.add(o)};for(let n of s){if(n.kind!=="import")continue;let i=n.isSideEffect||y(n.text).some((t)=>a.usedItems.has(t));for(let t of m(n.text))w(t,!0,!!i)}for(let n of m(a.referenceText))w(n,!1,!0);for(let n of x.get(e)??[]){let i=b(n,e);if(i)f.augmentations.add(i),f.declarations.add(i)}l.set(e,f)}let R=!0;while(R){R=!1;for(let[e,g]of l){let s=E(e,(a)=>l.get(a)?.declarations??[]);for(let[a,f]of l){if(s.has(a)||!f.augmentations.size||![...f.augmentations].some((t)=>s.has(t)))continue;let w=[e],n=new Map,i=new Set([e]);for(let t of w){if(t===a)break;for(let o of l.get(t).edges){if(i.has(o.target))continue;i.add(o.target),n.set(o.target,{from:t,edge:o}),w.push(o.target)}}if(!n.has(a))continue;for(let t=a;t!==e;){let{from:o,edge:I}=n.get(t),A=l.get(o);if(I.import){let S=M.get(o);if(!S)S=new Set,M.set(o,S);S.add(I.specifier)}if(!A.declarations.has(t))A.declarations.add(t),R=!0;t=o}}}}return M}
|
|
3
3
|
export{Xo,Se};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R,M}from"./chunk-2ngfncfx.js";import{P,D}from"./chunk-hqph3vnd.js";import{p}from"./chunk-v6fwy63g.js";import{T,O}from"./chunk-
|
|
2
|
+
import{R,M}from"./chunk-2ngfncfx.js";import{P,D}from"./chunk-hqph3vnd.js";import{p}from"./chunk-v6fwy63g.js";import{T,O}from"./chunk-gc7y4wav.js";import{Te}from"./chunk-zy5jxjmg.js";import{l}from"./chunk-vjtcxr3q.js";import{ye}from"./chunk-4q78f5pg.js";function Ue(t,n,s,r,i){if(r.length!==1||r[0]!=="bun")return null;let o=R(n)?M(t):P(n)?D(t):t;return ye(o,{keepComments:s,isolatedDeclarations:i})}var S=100,h=0,c=new Map;function yt(t,n="stdin.ts",s=!0,r=["bun"],i=!1){let o=p(t),a=JSON.stringify([n,s,i,r]),g=c.get(a);if(g&&g.contentHash===o)return g.lastAccess=++h,g.result;let b=Ue(t,n,s,r,i)??y(t,n,s,r,i);if(c.set(a,{result:b,contentHash:o,lastAccess:++h}),c.size>S){let x=Math.max(1,Math.ceil(c.size*0.1)),u=[];for(let[e,f]of c)u.push([e,f.lastAccess]);u.sort((e,f)=>e[1]-f[1]);for(let e=0;e<x&&e<u.length;e++)c.delete(u[e][0])}return b}function ei(t,n="stdin.ts",s=!0,r=["bun"]){return yt(t,n,s,r,!0)}function ti(t,n="stdin.ts",s=!0,r=["bun"]){return yt(t,n,s,r,!1)}function y(t,n,s,r,i){let o=Te(t,n,s,i);return l(o,{filePath:n,sourceCode:t,declarations:o},s,r)}function ni(){c.clear()}function Da(t,n="stdin.ts",s=!0,r=["bun"],i=!1){return Ue(t,n,s,r,i)??yn(t,n,s,r,i)}function yn(t,n="stdin.ts",s=!0,r=["bun"],i=!1){if(R(n))t=M(t);else if(P(n))t=D(t);let o=i?T(t,n,s):O(t,n,s);return l(o,{filePath:n,sourceCode:t,declarations:o},s,r)}
|
|
3
3
|
export{Ue,yt,ei,ti,ni,Da,yn};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var ge={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class v extends Error{code;context;constructor(n,e="UNKNOWN_ERROR",t){super(n);if(this.name="DtsxError",this.code=e,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let n=`${this.name} [${this.code}]: ${this.message}`;if(this.context)n+=`
|
|
3
|
-
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class
|
|
3
|
+
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class xn extends v{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class ri extends v{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class ii extends v{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class wn extends v{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Cn extends v{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class si extends v{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function fo(n){return n instanceof v}function po(n){return n instanceof xn}function mo(n){return n instanceof wn}function go(n){return n instanceof Cn}function ho(n,e="UNKNOWN_ERROR",t){if(n instanceof v)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new v(s,e);if(n instanceof Error)r.cause=n;return r}function yo(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
|
|
4
4
|
`)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function bo(n,e,t,s){let r=n.split(`
|
|
5
5
|
`),i=e.line-1,o=[];if(s)o.push(`${s}:${e.line}:${e.column}`);else o.push(`Line ${e.line}, Column ${e.column}`);o.push(`Error: ${t}`),o.push("");let E=Math.max(0,i-1),c=Math.min(r.length-1,i+1);for(let a=E;a<=c;a++){let R=(a+1).toString().padStart(4," "),u=a===i?">":" ";if(o.push(`${u} ${R} | ${r[a]}`),a===i){let l=" ".repeat(8+e.column-1);o.push(`${l}^`)}}return o.join(`
|
|
6
6
|
`)}function ze(n,e,t){let s={file:e,message:"Unknown error",code:ge.UNKNOWN_ERROR};if(n instanceof Error){s.message=n.message,s.stack=n.stack;let r=n.message.match(/\((\d+),(\d+)\)/);if(r)s.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(n.message.includes("Cannot find")||n.message.includes("not found"))s.code=ge.FILE_NOT_FOUND,s.suggestion="Check that the file path is correct and the file exists.";else if(n.message.includes("syntax")||n.message.includes("Unexpected token"))s.code=ge.SYNTAX_ERROR,s.suggestion="Check for syntax errors in your TypeScript code.";else if(n.message.includes("type")&&n.message.includes("cannot"))s.code=ge.TYPE_INFERENCE_ERROR,s.suggestion="Add explicit type annotations to help with type inference.";else if(n.message.includes("parse")||n.message.includes("Parse"))s.code=ge.PARSE_ERROR,s.suggestion="The file contains invalid TypeScript syntax."}else if(typeof n==="string")s.message=n;return s}function bt(n,e){let t=[],s=n.file;if(n.location)s+=`:${n.location.line}:${n.location.column}`;if(n.code)s+=` [${n.code}]`;if(t.push(s),t.push(` Error: ${n.message}`),e&&n.location){t.push("");let r=e.split(`
|
|
7
7
|
`),i=n.location.line-1;if(i>=0&&i<r.length){let o=Math.max(0,i-1),E=Math.min(r.length-1,i+1);for(let c=o;c<=E;c++){let a=(c+1).toString().padStart(4," "),R=c===i?">":" ";if(t.push(` ${R} ${a} | ${r[c]}`),c===i&&n.location.column>0){let u=" ".repeat(10+n.location.column-1);t.push(` ${u}^`)}}}}if(n.suggestion)t.push(""),t.push(` Suggestion: ${n.suggestion}`);return t.join(`
|
|
8
|
-
`)}function
|
|
8
|
+
`)}function xo(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
|
|
9
9
|
`)}
|
|
10
|
-
export{ge,v,
|
|
10
|
+
export{ge,v,xn,ri,ii,wn,Cn,si,fo,po,mo,go,ho,yo,bo,ze,bt,xo};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{W}from"./chunk-k5wz43yh.js";import{p}from"./chunk-v6fwy63g.js";var f=100,c=new Map,a=new Map,u=new Map,g=0;function d(e,n,t){let r={fileName:e,text:n};c.delete(e),c.set(e,{file:r,hash:t});while(c.size>f){let s=c.keys().next().value;if(s===void 0)break;c.delete(s)}return r}function b(e,n,t){return u.set(e,(u.get(e)??0)+1),d(e,n,t)}function Ot(e,n,t=p(n)){let r=c.get(e);if(r?.hash===t)return c.delete(e),c.set(e,r),r.file;return b(e,n,t)}async function
|
|
3
|
-
export{Ot,
|
|
2
|
+
import{W}from"./chunk-k5wz43yh.js";import{p}from"./chunk-v6fwy63g.js";var f=100,c=new Map,a=new Map,u=new Map,g=0;function d(e,n,t){let r={fileName:e,text:n};c.delete(e),c.set(e,{file:r,hash:t});while(c.size>f){let s=c.keys().next().value;if(s===void 0)break;c.delete(s)}return r}function b(e,n,t){return u.set(e,(u.get(e)??0)+1),d(e,n,t)}function Ot(e,n,t=p(n)){let r=c.get(e);if(r?.hash===t)return c.delete(e),c.set(e,r),r.file;return b(e,n,t)}async function ne(e,n,t={}){let r=p(n);if(c.get(e)?.hash===r)return Ot(e,n,r);let o=`${e}\x00${String(r)}`,i=a.get(o);if(i)return i;let h=(u.get(e)??0)+1;u.set(e,h);let m=g,l;return l=Promise.resolve().then(async()=>{try{if(n.length>=(t.asyncThreshold??1e5))await new Promise((y)=>setTimeout(y,Math.max(0,t.yieldInterval??0)));if(m===g&&u.get(e)===h)return d(e,n,r);return{fileName:e,text:n}}finally{if(a.get(o)===l)a.delete(o)}}),a.set(o,l),l}async function Mn(e,n={}){let t=new Map,r=W(n.concurrency,4);for(let s=0;s<e.length;s+=r){let o=await Promise.all(e.slice(s,s+r).map(async(i)=>({path:i.filePath,file:await ne(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function On(){g++,c.clear(),a.clear(),u.clear()}function In(){return c.size}function Ln(){return a.size}function Fn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
|
|
3
|
+
export{Ot,ne,Mn,On,In,Ln,Fn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t}from"./chunk-
|
|
2
|
+
import{t}from"./chunk-g0dxj89b.js";function j(n){let s=t(n),r=(e)=>s[e]?n.slice(s[e].start,s[e].end):"",d=new Map,k=[];for(let e=0;e<s.length;e++)if(["(","[","{"].includes(r(e)))k.push(e);else if([")","]","}"].includes(r(e))){let i=k.pop();if(i===void 0||!["()","[]","{}"].includes(r(i)+r(e)))throw Error("Unbalanced binding pattern");d.set(i,e)}if(k.length)throw Error("Unbalanced binding pattern");for(let e=0;e<s.length;e++){if(r(e)!=="<")continue;let i=["=",",","(",":","?","[","{"].includes(r(e-1)),f=1;for(let a=e+1;a<s.length;a++){if(r(a)==="="&&r(a+1)!==">"&&f===1&&!i)break;if(r(a)==="<")f++;else if(r(a)===">"&&r(a-1)!=="="&&--f===0){if(a+1===s.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(r(a+1)))d.set(e,a);break}let u=d.get(a);if(u!==void 0)a=u}}let g=(e,i)=>({text:e<i?n.slice(s[e].start,s[i-1].end):"",offset:s[e]?.start??n.length}),w=(e,i,f)=>{for(let a=e;a<i;a++){if(r(a)===f)return a;let u=d.get(a);if(u!==void 0)a=u}return},b=(e,i)=>{let f=w(e,i,"="),a=f===void 0?void 0:g(f+1,i);if(f!==void 0)i=f;if(e+1===i&&s[e]?.kind==="word")return{kind:"name",name:r(e),defaultValue:a};let u=r(e)==="{"?"object":r(e)==="["?"array":void 0;if(!u||d.get(e)!==i-1)throw Error(`Invalid binding target: ${g(e,i).text}`);let m=[],o=e+1;while(o<i-1){let h=w(o,i-1,","),p=h??i-1;if(o===p)m.push(void 0);else if(r(o)==="."&&r(o+1)==="."&&r(o+2)===".")m.push({rest:!0,target:b(o+3,p)});else if(u==="array")m.push({rest:!1,target:b(o,p)});else if(r(o)==="["){let c=d.get(o);if(c===void 0||r(c+1)!==":")throw Error("Computed binding needs a target");m.push({computed:g(o+1,c),rest:!1,target:b(c+2,p)})}else{let c=o+1;if(s[o].kind!=="word"&&s[o].kind!=="quoted")while(c<p&&r(c)!==":")c++;let l=r(c)===":";if(!l&&s[o].kind!=="word")throw Error("Invalid object binding key");m.push({key:g(o,l?c:o+1).text,rest:!1,target:b(l?c+1:o,p)})}if(h===void 0)break;o=h+1}return{kind:u,elements:m,defaultValue:a}};return b(0,s.length)}function y(n,s){if(n.kind==="name")s.push(n.name);else for(let r of n.elements)if(r)y(r.target,s)}function er(n){let s=[];return y(j(n),s),s}function tr(n){let s=j(n.pattern),r=[];if(y(s,r),!r.length)return[];let d=[n.root],k=!1,g={start:n.root.start,end:n.root.end},w=(e,i)=>{let f=n.allocateName();return d.push({kind:"variable",name:f,text:`declare ${i} ${f}: unknown;`,value:e.text,initializerStart:n.patternOffset+e.offset,modifiers:[i],isExported:!1,...g}),f},b=(e,i)=>{if(e.defaultValue){let l=w(e.defaultValue,n.kind),x=n.allocateName();i=`(${i}) extends infer ${x} ? ${x} extends undefined ? typeof ${l} : ${x} : never`}if(e.kind==="name"){let l=k?void 0:n.comments;k=!0,d.push({kind:"variable",name:e.name,text:`${n.exported?"export ":""}declare ${n.kind} ${e.name}: ${i};`,typeAnnotation:i,modifiers:[n.kind],isExported:n.exported,leadingComments:l,...g});return}let f=e.elements,a=[],u=[],m=[];for(let l of f){if(!l){a.push("");continue}let x=n.allocateName(),E=l.key;if(l.computed)E=`[${w(l.computed,"const")}]`;a.push(l.rest?`...${x}`:e.kind==="object"?`${E}: ${x}`:x),u.push({target:l.target,index:m.length}),m.push(`typeof ${x}`)}let o=n.allocateName(),h=n.allocateName(),p=n.allocateName(),c=e.kind==="object"?`{ ${a.join(", ")} }`:`[${a.join(", ")}]`;d.push({kind:"function",name:o,text:`declare function ${o}(${c}: ${i}): [${m.join(", ")}];`,isExported:!1,...g}),d.push({kind:"type",name:h,text:`type ${h} = (typeof ${o}) extends (...args: never[]) => infer ${p} ? ${p} : never;`,isExported:!1,...g});for(let l of u)b(l.target,`${h}[${l.index}]`)};return b(s,`typeof ${n.root.name}`),d}
|
|
3
3
|
export{er,tr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,d,
|
|
2
|
+
import{t,d,w}from"./chunk-g0dxj89b.js";import{x}from"./chunk-fv3x086v.js";function q(n){return typeof n==="string"?w(n,"'"):String(n)}function ma(n,k,m=new Map){let o=t(n),e=new Map(m),i=new Map,f=[],c=1,p=0,A=0;for(let r=1;r<o.length;r++){let v=o[r],h=n.slice(v.start,v.end);if(v.kind==="punctuation"&&p===0&&(h===","||h==="}")){let l=o.slice(c,r),a=l[0];if(a){let u=a.kind==="quoted"?d(n.slice(a.start,a.end)):n.slice(a.start,a.end),M=l.findIndex((g)=>g.kind==="punctuation"&&n[g.start]==="="),s=A;if(M>=0){let g=l.slice(M+1),b="",S=l[M].end;for(let y=0;y+2<g.length;y++){let[B,E,C]=g.slice(y,y+3);if(B.kind!=="word"||C.kind!=="word"||n.slice(E.start,E.end)!==".")continue;let D=e.get(`${n.slice(B.start,B.end)}.${n.slice(C.start,C.end)}`);if(D===void 0||typeof D==="object")continue;b+=n.slice(S,B.start)+q(D),S=C.end,y+=2}b+=n.slice(S,l.at(-1).end),s=x(b,e),f.push({start:l[M].start,end:l.at(-1).end,text:s===void 0?"":`= ${q(s)}`})}else if(s!==void 0)f.push({start:a.end,end:a.end,text:` = ${q(s)}`});if(A=typeof s==="number"?s+1:void 0,u!==void 0){if(e.delete(u),e.delete(`${k}.${u}`),s!==void 0)i.set(u,s),e.set(u,s),e.set(`${k}.${u}`,s)}}c=r+1}else if(v.kind==="punctuation"){if("([{".includes(h))p++;else if(")]}".includes(h))p--}}let K=n;for(let r of f.reverse())K=K.slice(0,r.start)+r.text+K.slice(r.end);return{body:K,members:i}}function Bn(n,k){let m=[...new Set([...n,...k.values()])];if(!m.some((e)=>e.kind==="enum"))return;m.sort((e,i)=>(e.start??0)-(i.start??0));let o=new Map;for(let e of m)if(e.kind==="enum"){let i=e.text.indexOf("{");if(i<0)continue;if(t(e.text.slice(0,i)).some((c)=>e.text.slice(c.start,c.end)==="declare"))continue;let f=ma(e.text.slice(i),e.name,o);e.text=e.text.slice(0,i)+f.body;for(let[c,p]of f.members)o.set(`${e.name}.${c}`,p)}else if(e.kind==="variable"&&e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion")&&typeof e.value==="string"){let i=x(e.value,o);if(i!==void 0)o.set(e.name,i)}}
|
|
3
3
|
export{ma,Bn};
|