@dtsx/dtsx 0.11.42 → 0.11.44
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/README.md +6 -0
- package/dist/bin/cli.js +9 -9
- package/dist/{chunk-s0sretav.js → chunk-0cynxv6w.js} +2 -2
- package/dist/{chunk-gc7y4wav.js → chunk-1hz6j7bq.js} +21 -21
- package/dist/{chunk-ywv56grs.js → chunk-2d3nbfth.js} +2 -2
- package/dist/{chunk-6vz1grv8.js → chunk-2y5b6hdw.js} +6 -6
- package/dist/{chunk-t76sqybd.js → chunk-3eb0gc0y.js} +1 -1
- package/dist/{chunk-vae5wxar.js → chunk-3rwbf45t.js} +2 -2
- package/dist/{chunk-veh8ks5v.js → chunk-3shq1bjr.js} +2 -2
- package/dist/{chunk-t8cgznk6.js → chunk-3v0yh5dk.js} +2 -2
- package/dist/{chunk-7g0hjhqy.js → chunk-4ece5g8t.js} +2 -2
- package/dist/{chunk-khyg6w62.js → chunk-4hkf7dda.js} +4 -4
- package/dist/chunk-59jw51gg.js +8 -0
- package/dist/{chunk-dh3y4pf7.js → chunk-5aqwt0a0.js} +4 -4
- package/dist/{chunk-8fg11pr7.js → chunk-65d3dga1.js} +3 -3
- package/dist/{chunk-asqkc0bw.js → chunk-6mryvpxj.js} +5 -5
- package/dist/{chunk-3r9dptyy.js → chunk-6pr23q72.js} +2 -2
- package/dist/{chunk-k9695p66.js → chunk-7ez7gynw.js} +2 -2
- package/dist/{chunk-eatp44nf.js → chunk-7krb9b1s.js} +2 -2
- package/dist/{chunk-gt5k2mff.js → chunk-7x9tawkf.js} +2 -2
- package/dist/{chunk-btwfkzt5.js → chunk-86xvq8km.js} +3 -3
- package/dist/{chunk-cywe5sgm.js → chunk-8v43ne8p.js} +3 -3
- package/dist/chunk-90f37xen.js +3 -0
- package/dist/{chunk-qqjbaqm6.js → chunk-932kxt70.js} +4 -4
- package/dist/{chunk-vjtcxr3q.js → chunk-976r899s.js} +4 -4
- package/dist/{chunk-06jp6gah.js → chunk-9etacmfx.js} +3 -3
- package/dist/{chunk-btc6zbyj.js → chunk-9hjd6p38.js} +2 -2
- package/dist/{chunk-twrcd0q6.js → chunk-9qv34ymq.js} +2 -2
- package/dist/{chunk-537hj5pj.js → chunk-an5ra7tr.js} +4 -4
- package/dist/{chunk-x3arymvk.js → chunk-anvhqbw8.js} +2 -2
- package/dist/{chunk-prst4szw.js → chunk-btmc3e8d.js} +2 -2
- package/dist/{chunk-r27pfg4r.js → chunk-c8s4d7qk.js} +6 -6
- package/dist/{chunk-q4gxj6qk.js → chunk-cgaw8fsn.js} +3 -3
- package/dist/{chunk-cyfnxk8d.js → chunk-cjhmmqxd.js} +2 -2
- package/dist/{chunk-m0tacjrk.js → chunk-cynfv4dt.js} +3 -3
- package/dist/{chunk-fv3x086v.js → chunk-d0aqaj02.js} +2 -2
- package/dist/{chunk-jf8mxazb.js → chunk-d68r83t9.js} +2 -2
- package/dist/{chunk-g4dpvmfy.js → chunk-der2ssgq.js} +2 -2
- package/dist/{chunk-73qsp464.js → chunk-dzdwc2fh.js} +2 -2
- package/dist/{chunk-w3zqfm8a.js → chunk-ehgnwdn9.js} +2 -2
- package/dist/{chunk-ej7jt519.js → chunk-eptz3q7r.js} +4 -4
- package/dist/{chunk-13tjnp25.js → chunk-erymqkk3.js} +6 -6
- package/dist/{chunk-kv3x5jrs.js → chunk-g19c3m7s.js} +2 -2
- package/dist/{chunk-qzb5pswc.js → chunk-g4rmn34j.js} +2 -2
- package/dist/{chunk-xzw0p4nq.js → chunk-gma09qy6.js} +2 -2
- package/dist/{chunk-1vc3eend.js → chunk-h1xwd278.js} +2 -2
- package/dist/{chunk-gv9brtta.js → chunk-hnckev96.js} +4 -4
- package/dist/{chunk-298wqs3n.js → chunk-hwgxwgsh.js} +2 -2
- package/dist/chunk-hyszyzq2.js +3 -0
- package/dist/{chunk-q76b61w9.js → chunk-jbxb317g.js} +6 -6
- package/dist/{chunk-3s37g6bh.js → chunk-ka22zwye.js} +8 -8
- package/dist/chunk-m2kzh519.js +3 -0
- package/dist/{chunk-hqph3vnd.js → chunk-m3y5knzq.js} +5 -5
- package/dist/{chunk-3jtwkmfx.js → chunk-madfh88z.js} +2 -2
- package/dist/{chunk-zbyvnsny.js → chunk-mfp35a3b.js} +9 -9
- package/dist/{chunk-01zsk2q8.js → chunk-mhyqvwcg.js} +3 -3
- package/dist/{chunk-g0dxj89b.js → chunk-mhz6xe61.js} +4 -4
- package/dist/{chunk-2ngfncfx.js → chunk-mjzee617.js} +11 -11
- package/dist/{chunk-54d8mt4c.js → chunk-nek63555.js} +2 -2
- package/dist/{chunk-550teag8.js → chunk-njqzhkzy.js} +10 -10
- package/dist/{chunk-j0p7bwj6.js → chunk-ns44qxdd.js} +4 -4
- package/dist/chunk-nxk4h5hy.js +3 -0
- package/dist/{chunk-9gp0e3kn.js → chunk-ptbd3dac.js} +2 -2
- package/dist/{chunk-zf96k060.js → chunk-q45jkpya.js} +2 -2
- package/dist/{chunk-x4qkjqda.js → chunk-q4ebd4qe.js} +2 -2
- package/dist/{chunk-f2yhf6gj.js → chunk-qevb6d6j.js} +2 -2
- package/dist/{chunk-bre2x1bd.js → chunk-rka9z03a.js} +4 -4
- package/dist/{chunk-8wk7nw3c.js → chunk-s7k223zx.js} +2 -2
- package/dist/{chunk-7bt7x8sy.js → chunk-sqnhxtbk.js} +3 -3
- package/dist/{chunk-a3apthex.js → chunk-th9tcxga.js} +2 -2
- package/dist/{chunk-8kj9pkw5.js → chunk-v3n9zzhm.js} +2 -2
- package/dist/{chunk-aq7y0s2v.js → chunk-vgyjw95e.js} +4 -4
- package/dist/{chunk-85d82vn3.js → chunk-vv8e8pa3.js} +2 -2
- package/dist/{chunk-jvqczw2k.js → chunk-vxghzchm.js} +3 -3
- package/dist/{chunk-00m9cbar.js → chunk-vz4fc70e.js} +3 -3
- package/dist/{chunk-60wrxcjt.js → chunk-waan03ga.js} +3 -3
- package/dist/chunk-x1j88x37.js +38 -0
- package/dist/{chunk-a2dn9j88.js → chunk-xa9vcbjj.js} +2 -2
- package/dist/chunk-xb2nr89a.js +3 -0
- package/dist/{chunk-bkbsg2bv.js → chunk-xgf6djk3.js} +2 -2
- package/dist/chunk-ykrdzatr.js +31 -0
- package/dist/{chunk-kdnqedyb.js → chunk-yqvn592m.js} +2 -2
- package/dist/{chunk-7387m006.js → chunk-zp93zcn5.js} +2 -2
- 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/config.js +1 -1
- package/dist/src/dangling-refs.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/directives.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/formats.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/global-types.js +1 -1
- package/dist/src/import-sorter.js +1 -1
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/json-config.js +1 -1
- package/dist/src/lexical.js +1 -1
- package/dist/src/logger.js +1 -1
- package/dist/src/lsp.js +1 -1
- package/dist/src/memory.js +1 -1
- package/dist/src/merger.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-engine.d.ts +24 -2
- package/dist/src/native-engine.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/output-normalizer.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.d.ts +4 -3
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/cache.js +1 -1
- package/dist/src/processor/comments.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/security.js +1 -1
- package/dist/src/source-cache.js +1 -1
- package/dist/src/sourcemap.js +1 -1
- package/dist/src/stx.js +1 -1
- package/dist/src/syntax-validator.js +1 -1
- package/dist/src/tracking.js +1 -1
- package/dist/src/transformers.js +1 -1
- package/dist/src/tree-shaker.js +1 -1
- package/dist/src/tsconfig.js +1 -1
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/types.d.ts +1 -0
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/vue.js +1 -1
- package/dist/src/watcher.js +1 -1
- package/dist/src/worker-thread.js +1 -1
- package/dist/src/worker.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-3qx4ys4v.js +0 -38
- package/dist/chunk-4q78f5pg.js +0 -3
- package/dist/chunk-5ezj0r3g.js +0 -3
- package/dist/chunk-7khy25x0.js +0 -3
- package/dist/chunk-msr5zymd.js +0 -31
- package/dist/chunk-pd30356m.js +0 -8
- package/dist/chunk-q4fhsthj.js +0 -3
- package/dist/chunk-zy5jxjmg.js +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class
|
|
3
|
-
export{
|
|
2
|
+
import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class Xt{config;profiles=[];cleanupTimer=null;constructor(e={}){this.config={maxMemoryMB:e.maxMemoryMB??512,chunkSize:e.chunkSize??65536,aggressiveGC:e.aggressiveGC??!0,maxDeclarationsInMemory:e.maxDeclarationsInMemory??1e4,profile:e.profile??!1,cleanupInterval:e.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let e=process.memoryUsage();return{heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers,rss:e.rss,heapUsedMB:Math.ceil(e.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(e.heapUsed/e.heapTotal*100))}}async profile(e,t){if(!this.config.profile)return t();let r=this.getMemoryStats(),i=Date.now();try{return await t()}finally{let n=this.getMemoryStats(),s=Date.now()-i;this.profiles.push({timestamp:Date.now(),operation:e,memoryBefore:r,memoryAfter:n,duration:s})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(e){let t=l(e,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),r=u({input:t,crlfDelay:1/0});for await(let i of r)yield i}async processFileInChunks(e,t,r=1000){let i=[],n=[];for await(let s of this.streamFile(e))if(n.push(s),n.length>=r){let a=await t(n);i.push(...a),n=[],this.checkMemoryAndCleanup()}if(n.length>0){let s=await t(n);i.push(...s)}return i}async streamWrite(e,t){let r=c(e,{encoding:"utf-8"});return new Promise((i,n)=>{let s=async()=>{try{for await(let a of t)if(!r.write(a))await new Promise((o)=>r.once("drain",()=>o()));r.end(),r.once("finish",i)}catch(a){n(a)}};r.once("error",n),s()})}}class Er{declarations=new Map;registry=new FinalizationRegistry((e)=>{this.declarations.delete(e)});maxSize;constructor(e=1e4){this.maxSize=e}add(e,t){if(this.declarations.size>=this.maxSize)this.evictOldest();let r=new WeakRef(t);this.declarations.set(e,r),this.registry.register(t,e)}get(e){return this.declarations.get(e)?.deref()}has(e){return this.declarations.get(e)?.deref()!==void 0}delete(e){this.declarations.delete(e)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let e=Math.ceil(this.maxSize*0.2),t=Array.from(this.declarations.keys());for(let r=0;r<e&&r<t.length;r++)this.declarations.delete(t[r])}}class kr{value=null;loaded=!1;loader;constructor(e){this.loader=e}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class Tr{strings=new Map;maxSize;constructor(e=50000){this.maxSize=e}intern(e){if(e.length>100)return e;let t=this.strings.get(e);if(t!==void 0)return t;if(this.strings.size>=this.maxSize){let r=Array.from(this.strings.keys());for(let i=0;i<r.length/2;i++)this.strings.delete(r[i])}return this.strings.set(e,e),e}get size(){return this.strings.size}clear(){this.strings.clear()}}class Ar{pool=[];factory;reset;maxSize;constructor(e,t,r=1000){this.factory=e,this.reset=t,this.maxSize=r}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(e){if(this.pool.length<this.maxSize)this.reset(e),this.pool.push(e)}get size(){return this.pool.length}clear(){this.pool=[]}}function vs(e,t={}){return{...e,memory:{maxMemoryMB:t.maxMemoryMB??512,chunkSize:t.chunkSize??65536,aggressiveGC:t.aggressiveGC??!0,maxDeclarationsInMemory:t.maxDeclarationsInMemory??1e4,profile:t.profile??!1,cleanupInterval:t.cleanupInterval??5000}}}function Ss(e){let r=m(e).size/1024/1024,i=r*4,n=65536;if(r>10)n=32768;if(r>50)n=16384;return{fileSizeMB:Math.round(r*100)/100,estimatedMemoryMB:Math.round(i*100)/100,recommendedChunkSize:n}}function $s(e){return[`Heap: ${e.heapUsedMB}MB / ${Math.round(e.heapTotal/1024/1024)}MB (${e.percentUsed}%)`,`RSS: ${Math.round(e.rss/1024/1024)}MB`,`External: ${Math.round(e.external/1024/1024)}MB`].join(" | ")}function Es(e={}){return new Xt(e)}
|
|
3
|
+
export{Xt,Er,kr,Tr,Ar,vs,Ss,$s,Es};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
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
|
|
2
|
+
import{r}from"./chunk-90f37xen.js";import{we}from"./chunk-3rwbf45t.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 ks(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 gt(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 we(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 Dr(t,e={}){return gt(t,{...e,declarationsOnly:!0})}async function Ts(t){let e=new Map;for(let s of t){let o=await p(s,"utf8").catch(()=>""),n=[];for(let i of r(o,s,!1,!0))if(i.isExported&&i.kind==="function"&&!i.returnType)n.push({line:1,column:1,message:"Exported function requires an explicit return type",declarationName:i.name,missingAnnotation:"return"});e.set(s,{compatible:n.length===0,issues:n})}return e}function d(t,e,s){let o=t.split(`
|
|
3
|
+
`);if(e<1||e>o.length||s<1||s>o[e-1].length+1)return null;let n=s-1;for(let i=0;i<e-1;i++)n+=o[i].length+1;return n}function Pr(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 As(t,e,s){let o=Pr(t,e,s);return o?{type:o}:null}function Ds(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
|
-
`)}function
|
|
6
|
-
export{
|
|
5
|
+
`)}function Ps(t){return gt(t.entrypoints.map((e)=>g(t.cwd,e)),{tsconfigPath:t.tsconfigPath,rootDir:t.root})}async function Rs(t,e){let o=(await Promise.all([gt(t),Dr(e)])).flatMap((n)=>n.diagnostics).map((n)=>({sourceName:n.file,sourceType:n.message,dtsType:"<invalid>"}));return{valid:o.length===0,mismatches:o}}
|
|
6
|
+
export{ks,gt,Dr,Ts,Pr,As,Ds,Ps,Rs};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lstat as d,realpath as f,stat as T}from"fs/promises";import{isAbsolute as l,normalize as g,relative as p,resolve as u}from"path";var N={rootDir:process.cwd(),maxFileSize:10485760,maxTotalSize:104857600,timeout:30000,followSymlinks:!1,maxFiles:1e4,blockedPatterns:["**/.git/**","**/node_modules/**","**/.env*","**/secrets/**","**/*.key","**/*.pem"]};class C extends Error{code;path;constructor(t,r,e){super(t);this.code=r;this.path=e;this.name="SecurityError"}}function
|
|
3
|
-
export{N,C,
|
|
2
|
+
import{lstat as d,realpath as f,stat as T}from"fs/promises";import{isAbsolute as l,normalize as g,relative as p,resolve as u}from"path";var N={rootDir:process.cwd(),maxFileSize:10485760,maxTotalSize:104857600,timeout:30000,followSymlinks:!1,maxFiles:1e4,blockedPatterns:["**/.git/**","**/node_modules/**","**/.env*","**/secrets/**","**/*.key","**/*.pem"]};class C extends Error{code;path;constructor(t,r,e){super(t);this.code=r;this.path=e;this.name="SecurityError"}}function ze(t,r={}){let{rootDir:e=process.cwd()}=r,i=g(t),n=l(i)?i:u(e,i),o=u(n),s=p(e,o);if(s.startsWith("..")||l(s))throw new C(`Path traversal detected: "${t}" resolves outside root directory`,"PATH_TRAVERSAL",t);return o}function Ur(t,r={}){return t.map((e)=>ze(e,r))}function un(t,r={}){let e=r.blockedPatterns||N.blockedPatterns;for(let i of e)if(h(t,i))return!0;return!1}var m=new Map;function P(t){let r=m.get(t);if(r)return r;let e=t.replace(/\*\*/g,"<<GLOBSTAR>>").replace(/\*/g,"<<STAR>>").replace(/\?/g,"<<QUESTION>>");e=e.replace(/[.+^${}()|[\]\\]/g,"\\$&"),e=e.replace(/^<<GLOBSTAR>>\//,"(.*\\/)?"),e=e.replace(/\/<<GLOBSTAR>>$/,"(\\/.*)?"),e=e.replace(/\/<<GLOBSTAR>>\//g,"(\\/.*)?\\/"),e=e.replace(/<<GLOBSTAR>>/g,".*"),e=e.replace(/<<STAR>>/g,"[^/]*"),e=e.replace(/<<QUESTION>>/g,"[^/]");let i=new RegExp(`^${e}$`);return m.set(t,i),i}function h(t,r){let e=t.indexOf("\\")===-1?t:t.replace(/\\/g,"/");return P(r).test(e)}async function zr(t,r={}){let e=r.maxFileSize??N.maxFileSize;try{let i=await T(t);if(i.size>e)throw new C(`File too large: "${t}" is ${a(i.size)}, max is ${a(e)}`,"FILE_TOO_LARGE",t);return i.size}catch(i){if(i instanceof C)throw i;throw new C(`Failed to check file size: ${t}`,"INVALID_PATH",t)}}async function Hr(t){try{return(await d(t)).isSymbolicLink()}catch{return!1}}async function Kr(t,r={}){let e=r.followSymlinks??N.followSymlinks;if(await Hr(t)){if(!e)throw new C(`Symbolic links not allowed: "${t}"`,"SYMLINK_NOT_ALLOWED",t);let i=await f(t);return ze(i,r)}return t}async function bt(t,r={}){let e=ze(t,r);if(un(e,r))throw new C(`Path matches blocked pattern: "${t}"`,"BLOCKED_PATTERN",t);let i=await Kr(e,r),n=await zr(i,r);return{path:i,size:n}}async function fn(t,r={}){let e=r.maxFiles??N.maxFiles,i=r.maxTotalSize??N.maxTotalSize;if(t.length>e)throw new C(`Too many files: ${t.length} exceeds maximum of ${e}`,"MAX_FILES_EXCEEDED");let n=[],o=0;for(let s of t){let c=await bt(s,r);if(n.push(c.path),o+=c.size,o>i)throw new C(`Total size exceeded: ${a(o)} exceeds maximum of ${a(i)}`,"TOTAL_SIZE_EXCEEDED")}return{paths:n,totalSize:o}}function xt(t,r,e="Operation"){return new Promise((i,n)=>{let o=setTimeout(()=>{n(new C(`${e} timed out after ${r}ms`,"TIMEOUT"))},r);t.then((s)=>{clearTimeout(o),i(s)}).catch((s)=>{clearTimeout(o),n(s)})})}function qr(t,r={}){let e=r.timeout??N.timeout;return async(i)=>{let{path:n}=await bt(i,r);return xt(t(n),e,`Processing ${i}`)}}function eo(t,r={}){let e=r.timeout??N.timeout;return async(i)=>{let{paths:n}=await fn(i,r);return xt(t(n),e,`Processing ${i.length} files`)}}function to(t){let r=t.replace(/\\/g,"/").replace(/\0/g,"").replace(/^\/+/,"").replace(/^[A-Z]:/i,""),e="";while(e!==r)e=r,r=r.replace(/\.\.\/|\.\.$/g,"").replace(/\/+/g,"/");return r.replace(/^\/+|\/+$/g,"")}function no(t){if(t.includes("\x00"))return!1;if(g(t).includes(".."))return!1;if(l(t)&&!t.startsWith(process.cwd()))return!1;return!0}function a(t){if(t===0)return"0 B";let r=["B","KB","MB","GB"],e=1024,i=Math.floor(Math.log(t)/Math.log(e));return`${Number.parseFloat((t/e**i).toFixed(2))} ${r[i]}`}function ro(t={}){let r={...N,...t};return{validatePath:(e)=>ze(e,r),validatePaths:(e)=>Ur(e,r),validateFile:(e)=>bt(e,r),validateBatch:(e)=>fn(e,r),withTimeout:(e,i)=>xt(e,r.timeout,i),secureProcessor:(e)=>qr(e,r),isBlocked:(e)=>un(e,r),getConfig:()=>r}}
|
|
3
|
+
export{N,C,ze,Ur,un,zr,Hr,Kr,bt,fn,xt,qr,eo,to,no,ro};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{S}from"./chunk-59jw51gg.js";import{U}from"./chunk-erymqkk3.js";import{chmod as G,lstat as P,mkdir as y,readdir as j,realpath as q,rename as D,rm as R,rmdir as L,stat as A,writeFile as W}from"fs/promises";import{basename as _,dirname as m,isAbsolute as M,parse as B,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await q(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),_(e))}}async function Y(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!S(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===B(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(S(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function x(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await x(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await j(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function be(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await Y(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!S(t,n)||S(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],T=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!S(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(S(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await x(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await W(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await U(v,i.content,i.lineEnding),!a.clean&&u.existing)await G(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),T.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await x(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of T.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await L(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
|
|
3
|
+
export{Y,be};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-90f37xen.js";import{e}from"./chunk-9hjd6p38.js";import{existsSync as j,mkdirSync as S,readFileSync as E,writeFileSync as f}from"fs";import{basename as h,join as g}from"path";function tn(t){let n={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!t||t.length===0)return n;for(let s of t){let o=s.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
|
|
3
3
|
`).map((p)=>p.replace(/^\s*\*\s?/,"")).join(`
|
|
4
|
-
`).trim(),i=o.search(/@\w+/);if(i===-1){n.description=o;continue}else if(i>0)n.description=o.slice(0,i).trim(),o=o.slice(i);let a=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,c;while((c=a.exec(o))!==null){let[,p,u,d]=c,m=d.trim();switch(p){case"param":{let l=m.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(l)n.params.push({name:l[2],type:u,description:l[3].trim(),optional:!!l[1]});break}case"returns":case"return":n.returns={type:u,description:m};break;case"example":n.examples.push(m);break;case"deprecated":n.deprecated=m||"Deprecated";break;case"since":n.since=m;break;case"see":n.see.push(m);break;case"throws":case"throw":n.throws.push({type:u,description:m});break;case"category":n.category=m;break;default:if(!n.tags[p])n.tags[p]=[];n.tags[p].push(m)}}}return n}function w(t,n){let s=
|
|
5
|
-
`)}function k(t,n){let s=[];if(s.push(`### ${t.name}`),s.push(""),t.jsdoc.deprecated)s.push(`> **Deprecated:** ${t.jsdoc.deprecated}`),s.push("");if(s.push("```typescript"),s.push(t.signature),s.push("```"),s.push(""),t.jsdoc.description)s.push(t.jsdoc.description),s.push("");if(t.jsdoc.params.length>0){s.push("**Parameters:**"),s.push(""),s.push("| Name | Type | Description |"),s.push("|------|------|-------------|");for(let o of t.jsdoc.params){let i=o.optional?" (optional)":"",a=o.type||"any";s.push(`| \`${o.name}\`${i} | \`${a}\` | ${o.description} |`)}s.push("")}if(t.jsdoc.returns){s.push("**Returns:**"),s.push("");let o=t.jsdoc.returns.type?`\`${t.jsdoc.returns.type}\``:"";s.push(`${o} ${t.jsdoc.returns.description}`),s.push("")}if(t.jsdoc.throws.length>0){s.push("**Throws:**"),s.push("");for(let o of t.jsdoc.throws){let i=o.type?`\`${o.type}\``:"";s.push(`- ${i} ${o.description}`)}s.push("")}if(t.jsdoc.examples.length>0){s.push("**Examples:**"),s.push("");for(let o of t.jsdoc.examples)s.push("```typescript"),s.push(o),s.push("```"),s.push("")}if(t.jsdoc.see.length>0){s.push("**See also:**"),s.push("");for(let o of t.jsdoc.see)s.push(`- ${o}`);s.push("")}if(t.jsdoc.since)s.push(`*Since: ${t.jsdoc.since}*`),s.push("");if(n.includeSourceLinks&&t.sourceFile){let o=t.sourceFile;if(n.sourceBaseUrl)s.push(`[Source](${n.sourceBaseUrl}/${o})`);else s.push(`*Source: ${o}*`);s.push("")}if(t.members&&t.members.length>0){s.push("**Members:**"),s.push("");for(let o of t.members)if(s.push(`#### ${o.name}`),s.push(""),s.push("```typescript"),s.push(o.signature),s.push("```"),s.push(""),o.jsdoc.description)s.push(o.jsdoc.description),s.push("")}return s.push("---"),s.push(""),s}function
|
|
4
|
+
`).trim(),i=o.search(/@\w+/);if(i===-1){n.description=o;continue}else if(i>0)n.description=o.slice(0,i).trim(),o=o.slice(i);let a=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,c;while((c=a.exec(o))!==null){let[,p,u,d]=c,m=d.trim();switch(p){case"param":{let l=m.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(l)n.params.push({name:l[2],type:u,description:l[3].trim(),optional:!!l[1]});break}case"returns":case"return":n.returns={type:u,description:m};break;case"example":n.examples.push(m);break;case"deprecated":n.deprecated=m||"Deprecated";break;case"since":n.since=m;break;case"see":n.see.push(m);break;case"throws":case"throw":n.throws.push({type:u,description:m});break;case"category":n.category=m;break;default:if(!n.tags[p])n.tags[p]=[];n.tags[p].push(m)}}}return n}function w(t,n){let s=tn(t.leadingComments),o="";switch(t.kind){case"function":o=M(t);break;case"variable":o=C(t);break;case"interface":o=P(t);break;case"type":o=v(t);break;case"class":o=T(t);break;case"enum":o=F(t);break;default:o=t.text||t.name}let i={name:t.name,kind:t.kind,signature:o,jsdoc:s,isExported:t.isExported,isDefault:t.isDefault,sourceFile:n};if(t.members&&t.members.length>0)i.members=t.members.map((a)=>w(a,n));return i}function M(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("function"),n.push(t.name),t.generics)n.push(t.generics);if(t.parameters){let s=t.parameters.map((o)=>{let i="";if(o.rest)i+="...";if(i+=o.name,o.optional)i+="?";if(o.type)i+=`: ${o.type}`;return i}).join(", ");n.push(`(${s})`)}else n.push("()");if(t.returnType)n.push(`: ${t.returnType}`);return n.join(" ").replace(/\s+/g," ")}function C(t){let n=[];if(t.isExported)n.push("export");if(n.push("const"),n.push(t.name),t.typeAnnotation)n.push(`: ${t.typeAnnotation}`);return n.join(" ")}function P(t){let n=[];if(t.isExported)n.push("export");if(n.push("interface"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);return n.join(" ")}function v(t){let n=[];if(t.isExported)n.push("export");if(n.push("type"),n.push(t.name),t.generics)n.push(t.generics);if(n.push("="),t.typeAnnotation)n.push(t.typeAnnotation);return n.join(" ")}function T(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("class"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)n.push(`implements ${t.implements.join(", ")}`);return n.join(" ")}function F(t){let n=[];if(t.isExported)n.push("export");return n.push("enum"),n.push(t.name),n.join(" ")}async function nn(t,n={}){let s=[],o=new Map;for(let i of t){if(!j(i)){e.warn(`File not found: ${i}`);continue}let a=E(i,"utf-8"),c=r(a,i,!0);for(let p of c){if(p.kind==="import")continue;if(!n.includePrivate&&p.name.startsWith("_"))continue;if(!n.includeInternal&&p.leadingComments?.some((d)=>d.includes("@internal")))continue;let u=w(p,i);if(s.push(u),n.groupByCategory&&u.jsdoc.category){let d=u.jsdoc.category;if(!o.has(d))o.set(d,[]);o.get(d).push(u)}}}return{title:n.title||"API Documentation",description:n.description,entries:s,categories:o,generatedAt:new Date}}function Ue(t,n={}){let s=[];if(s.push(`# ${t.title}`),s.push(""),t.description)s.push(t.description),s.push("");if(s.push(`> Generated on ${t.generatedAt.toISOString()}`),s.push(""),s.push("## Table of Contents"),s.push(""),n.groupByCategory&&t.categories.size>0)for(let o of t.categories.keys())s.push(`- [${o}](#${D(o)})`);else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0)s.push(`- [${b(i)}](#${D(b(i))})`)}if(s.push(""),n.groupByCategory&&t.categories.size>0)for(let[o,i]of t.categories){s.push(`## ${o}`),s.push("");for(let a of i)s.push(...k(a,n))}else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0){s.push(`## ${b(i)}`),s.push("");for(let c of a)s.push(...k(c,n))}}return s.join(`
|
|
5
|
+
`)}function k(t,n){let s=[];if(s.push(`### ${t.name}`),s.push(""),t.jsdoc.deprecated)s.push(`> **Deprecated:** ${t.jsdoc.deprecated}`),s.push("");if(s.push("```typescript"),s.push(t.signature),s.push("```"),s.push(""),t.jsdoc.description)s.push(t.jsdoc.description),s.push("");if(t.jsdoc.params.length>0){s.push("**Parameters:**"),s.push(""),s.push("| Name | Type | Description |"),s.push("|------|------|-------------|");for(let o of t.jsdoc.params){let i=o.optional?" (optional)":"",a=o.type||"any";s.push(`| \`${o.name}\`${i} | \`${a}\` | ${o.description} |`)}s.push("")}if(t.jsdoc.returns){s.push("**Returns:**"),s.push("");let o=t.jsdoc.returns.type?`\`${t.jsdoc.returns.type}\``:"";s.push(`${o} ${t.jsdoc.returns.description}`),s.push("")}if(t.jsdoc.throws.length>0){s.push("**Throws:**"),s.push("");for(let o of t.jsdoc.throws){let i=o.type?`\`${o.type}\``:"";s.push(`- ${i} ${o.description}`)}s.push("")}if(t.jsdoc.examples.length>0){s.push("**Examples:**"),s.push("");for(let o of t.jsdoc.examples)s.push("```typescript"),s.push(o),s.push("```"),s.push("")}if(t.jsdoc.see.length>0){s.push("**See also:**"),s.push("");for(let o of t.jsdoc.see)s.push(`- ${o}`);s.push("")}if(t.jsdoc.since)s.push(`*Since: ${t.jsdoc.since}*`),s.push("");if(n.includeSourceLinks&&t.sourceFile){let o=t.sourceFile;if(n.sourceBaseUrl)s.push(`[Source](${n.sourceBaseUrl}/${o})`);else s.push(`*Source: ${o}*`);s.push("")}if(t.members&&t.members.length>0){s.push("**Members:**"),s.push("");for(let o of t.members)if(s.push(`#### ${o.name}`),s.push(""),s.push("```typescript"),s.push(o.signature),s.push("```"),s.push(""),o.jsdoc.description)s.push(o.jsdoc.description),s.push("")}return s.push("---"),s.push(""),s}function rn(t,n={}){let s=Ue(t,n);return`<!DOCTYPE html>
|
|
6
6
|
<html lang="en">
|
|
7
7
|
<head>
|
|
8
8
|
<meta charset="UTF-8">
|
|
@@ -97,6 +97,6 @@ import{r}from"./chunk-q4fhsthj.js";import{e}from"./chunk-btc6zbyj.js";import{exi
|
|
|
97
97
|
document.getElementById('content').innerHTML = marked.parse(markdown);
|
|
98
98
|
</script>
|
|
99
99
|
</body>
|
|
100
|
-
</html>`}function
|
|
101
|
-
`)),e.info(`Generated: ${g(n.outdir,"README.md")}`)}else{let o=
|
|
102
|
-
export{
|
|
100
|
+
</html>`}function sn(t,n={}){let s={title:t.title,description:t.description,generatedAt:t.generatedAt.toISOString(),version:"1.0.0",entries:t.entries.map((o)=>({name:o.name,kind:o.kind,signature:o.signature,description:o.jsdoc.description,isExported:o.isExported,isDefault:o.isDefault,deprecated:o.jsdoc.deprecated,since:o.jsdoc.since,category:o.jsdoc.category,params:o.jsdoc.params,returns:o.jsdoc.returns,examples:o.jsdoc.examples,throws:o.jsdoc.throws,see:o.jsdoc.see,tags:o.jsdoc.tags,sourceFile:o.sourceFile,sourceLine:o.sourceLine,members:o.members?.map((i)=>({name:i.name,kind:i.kind,signature:i.signature,description:i.jsdoc.description,deprecated:i.jsdoc.deprecated,params:i.jsdoc.params,returns:i.jsdoc.returns}))})),categories:n.groupByCategory?Object.fromEntries(Array.from(t.categories.entries()).map(([o,i])=>[o,i.map((a)=>a.name)])):void 0};return JSON.stringify(s,null,2)}function Mr(t){let n={id:0,name:t.title,kind:1,kindString:"Project",flags:{},children:t.entries.map((s,o)=>({id:o+1,name:s.name,kind:y(s.kind),kindString:s.kind,flags:{isExported:s.isExported,isDefault:s.isDefault},comment:s.jsdoc.description?{summary:[{kind:"text",text:s.jsdoc.description}],blockTags:s.jsdoc.deprecated?[{tag:"@deprecated",content:[{kind:"text",text:s.jsdoc.deprecated}]}]:void 0}:void 0,sources:s.sourceFile?[{fileName:s.sourceFile,line:s.sourceLine||1,character:0}]:void 0,signatures:s.kind==="function"?[{id:o+1000,name:s.name,kind:4096,kindString:"Call signature",parameters:s.jsdoc.params.map((i,a)=>({id:o+2000+a,name:i.name,kind:32768,kindString:"Parameter",flags:{isOptional:i.optional},type:i.type?{type:"intrinsic",name:i.type}:void 0,comment:i.description?{summary:[{kind:"text",text:i.description}]}:void 0})),type:s.jsdoc.returns?.type?{type:"intrinsic",name:s.jsdoc.returns.type}:void 0}]:void 0,children:s.members?.map((i,a)=>({id:o+3000+a,name:i.name,kind:y(i.kind),kindString:i.kind,comment:i.jsdoc.description?{summary:[{kind:"text",text:i.jsdoc.description}]}:void 0}))}))};return JSON.stringify(n,null,2)}async function Is(t,n){e.info("Extracting documentation...");let s=await nn(t,n);if(e.info(`Found ${s.entries.length} documented entries`),!j(n.outdir))S(n.outdir,{recursive:!0});if(n.format==="markdown")if(n.splitByModule){let o=I(s.entries);for(let[a,c]of o){let p={title:h(a,".ts"),description:`Documentation for ${a}`,entries:c,categories:new Map,generatedAt:s.generatedAt},u=Ue(p,n),d=g(n.outdir,`${h(a,".ts")}.md`);f(d,u),e.info(`Generated: ${d}`)}let i=[`# ${s.title}`,"",s.description||"","","## Modules",""];for(let[a]of o){let c=h(a,".ts");i.push(`- [${c}](./${c}.md)`)}f(g(n.outdir,"README.md"),i.join(`
|
|
101
|
+
`)),e.info(`Generated: ${g(n.outdir,"README.md")}`)}else{let o=Ue(s,n),i=g(n.outdir,"API.md");f(i,o),e.info(`Generated: ${i}`)}else if(n.format==="json"){let o=sn(s,n),i=g(n.outdir,"api.json");f(i,o),e.info(`Generated: ${i}`);let a=Mr(s),c=g(n.outdir,"typedoc.json");f(c,a),e.info(`Generated: ${c}`)}else{let o=rn(s,n),i=g(n.outdir,"index.html");f(i,o),e.info(`Generated: ${i}`)}}function D(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function b(t){return{function:"Functions",variable:"Variables",interface:"Interfaces",type:"Type Aliases",class:"Classes",enum:"Enums",export:"Exports",module:"Modules"}[t]||t}function x(t){let n=new Map,s=["function","class","interface","type","enum","variable"];for(let o of s)n.set(o,[]);for(let o of t){let i=o.kind;if(!n.has(i))n.set(i,[]);n.get(i).push(o)}return n}function A(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function I(t){let n=new Map;for(let s of t){let o=s.sourceFile||"unknown";if(!n.has(o))n.set(o,[]);n.get(o).push(s)}return n}function y(t){return{function:64,variable:32,interface:256,type:4194304,class:128,enum:8,property:1024,method:2048,module:2,namespace:4}[t]||0}function Ls(t={}){return{extract:(n)=>nn(n,t),generateMarkdown:(n)=>Ue(n,t),generateHTML:(n)=>rn(n,t),generateJSON:(n)=>sn(n,t),parseJSDoc:tn}}
|
|
102
|
+
export{tn,nn,Ue,rn,sn,Mr,Is,Ls};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
3
|
-
`)}function E(t){let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"import":if(t.isTypeOnly)e.push("import type");else e.push("import");if(t.specifiers&&t.specifiers.length>0){let s=t.specifiers.map((o)=>{let i=o.isType?"type ":"";return o.alias?`${i}${o.name} as ${o.alias}`:`${i}${o.name}`}).join(", ");e.push(`{ ${s} }`)}e.push("from"),e.push(`'${t.source}'`);break;case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${B(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let s of t.members)e.push(` ${s.name}${s.typeAnnotation?`: ${s.typeAnnotation}`:""}`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements?.length)e.push(`implements ${t.implements.join(", ")}`);e.push("{ }");break;case"enum":e.push("declare enum"),e.push(t.name),e.push("{ }");break;default:return t.text||""}return e.join(" ")}function B(t){if(!t)return"";return t.map((e)=>{let s="";if(e.rest)s+="...";if(s+=e.name,e.optional)s+="?";if(e.type)s+=`: ${e.type}`;return s}).join(", ")}function
|
|
4
|
-
export{
|
|
2
|
+
import{r}from"./chunk-90f37xen.js";import{existsSync as g,readFileSync as h,writeFileSync as b}from"fs";function d(t){let e=[],s=/\b([A-Z][a-zA-Z0-9]*)\b/g,o;while((o=s.exec(t))!==null){let i=o[1];if(!D(i))e.push(i)}return[...new Set(e)]}function D(t){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(t)}function x(t){if(t.kind!=="type")return!1;let e=t.typeAnnotation||"";if(t.generics)return!1;if(e.includes("{")||e.includes("(")||e.includes("<"))return!1;return/^[\w\s|&]+$/.test(e)}function v(t){if(t.kind!=="interface")return!1;if(!t.members||t.members.length===0){if(!t.extends)return!0}return!1}function I(t,e){let s={...t,members:[...t.members||[],...e.members||[]],leadingComments:[...t.leadingComments||[],...e.leadingComments||[]]};if(t.extends&&e.extends){let o=t.extends.split(",").map((n)=>n.trim()),i=e.extends.split(",").map((n)=>n.trim());s.extends=[...new Set([...o,...i])].join(", ")}else s.extends=t.extends||e.extends;return s}function A(t){let e={import:0,interface:1,type:2,class:3,enum:4,function:5,variable:6,export:7};return[...t].sort((s,o)=>{let i=e[s.kind]??99,n=e[o.kind]??99;if(i!==n)return i-n;return s.name.localeCompare(o.name)})}function T(t){let e=[],s=[];for(let i=0;i<t.length;i++){let n=t[i];if(n.kind==="import")e.push(n);else s.push(n)}return[...[...e].sort((i,n)=>{let a=i.source||"",c=n.source||"",p=a.startsWith("node:")||a==="bun",m=c.startsWith("node:")||c==="bun";if(p&&!m)return-1;if(!p&&m)return 1;let l=!a.startsWith("."),u=!c.startsWith(".");if(l&&!u)return-1;if(!l&&u)return 1;return a.localeCompare(c)}),...s]}function S(t){let e=new Set;for(let i of t){if(i.kind==="import")continue;let n=i.text||"",a=i.typeAnnotation||"",c=i.returnType||"",p=i.extends||"",m=i.implements?.join(" ")||"",l=`${n} ${a} ${c} ${p} ${m}`;for(let u of d(l))e.add(u);if(i.members)for(let u of i.members){let f=`${u.typeAnnotation||""} ${u.returnType||""}`;for(let y of d(f))e.add(y)}if(i.parameters){for(let u of i.parameters)if(u.type)for(let f of d(u.type))e.add(f)}}let s=0;return{declarations:t.map((i)=>{if(i.kind!=="import"||!i.specifiers)return i;let n=i.specifiers.filter((a)=>{let c=a.alias||a.name;return e.has(c)});if(n.length===0){if(!i.isSideEffect)return s++,null}if(n.length<(i.specifiers?.length||0))return s+=(i.specifiers?.length||0)-n.length,{...i,specifiers:n};return i}).filter((i)=>i!==null),removed:s}}function k(t){let e=new Map,s=0;for(let o of t){if(o.kind==="import"){let n=`import:${o.source}`;if(e.has(n)){let a=e.get(n),c=[...a.specifiers||[],...o.specifiers||[]],p=Array.from(new Map(c.map((m)=>[m.alias||m.name,m])).values());e.set(n,{...a,specifiers:p}),s++}else e.set(n,o);continue}let i=`${o.kind}:${o.name}`;if(e.has(i))s++;else e.set(i,o)}return{declarations:Array.from(e.values()),removed:s}}function z(t){let e=new Map,s=[];for(let n of t)if(n.kind==="interface"){let a=n.name;if(!e.has(a))e.set(a,[]);e.get(a).push(n)}else s.push(n);let o=0,i=[];for(let[n,a]of e)if(a.length>1){let c=a[0];for(let p=1;p<a.length;p++)c=I(c,a[p]),o++;i.push(c)}else i.push(a[0]);return{declarations:[...s,...i],merged:o}}function w(t){let e=new Map,s=new Set;for(let n of t)if(x(n))e.set(n.name,n.typeAnnotation||""),s.add(n.name);if(e.size===0)return{declarations:t,inlined:0};function o(n){let a=n;for(let[c,p]of e){let m=new RegExp(`\\b${c}\\b`,"g");a=a.replace(m,p)}return a}return{declarations:t.filter((n)=>n.kind!=="type"||!s.has(n.name)).map((n)=>{if(n.typeAnnotation)n={...n,typeAnnotation:o(n.typeAnnotation)};if(n.returnType)n={...n,returnType:o(n.returnType)};if(n.extends)n={...n,extends:o(n.extends)};return n}),inlined:e.size}}function R(t){let e=t.length,s=t.filter((o)=>!v(o));return{declarations:s,removed:e-s.length}}function cr(t,e={}){let s=[...t],o={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(e.removeUnusedImports){let{declarations:i,removed:n}=S(s);s=i,o.removedImports=n}if(e.deduplicateDeclarations){let{declarations:i,removed:n}=k(s);s=i,o.removedDeclarations+=n}if(e.mergeInterfaces){let{declarations:i,merged:n}=z(s);s=i,o.mergedInterfaces=n}if(e.removeEmptyInterfaces){let{declarations:i,removed:n}=R(s);s=i,o.removedDeclarations+=n}if(e.inlineSimpleTypes){let{declarations:i,inlined:n}=w(s);s=i,o.inlinedTypes=n}if(e.sortImports)s=T(s);if(e.sortDeclarations)s=A(s);return{declarations:s,result:o}}async function Mi(t,e={}){if(!g(t))throw Error(`File not found: ${t}`);let s=h(t,"utf-8"),o=Buffer.byteLength(s,"utf-8"),i=r(s,t,!e.removeComments),{declarations:n,result:a}=cr(i,e),c=C(n,e);if(e.minify)c=lr(c);let p=Buffer.byteLength(c,"utf-8");return a.originalSize=o,a.optimizedSize=p,a.savings=o-p,a.savingsPercent=Math.round(a.savings/o*100),b(t,c),a}function C(t,e){let s=[];for(let o of t){if(!e.removeComments&&o.leadingComments)for(let i of o.leadingComments)s.push(i);if(o.text)s.push(o.text);else s.push(E(o));s.push("")}return s.join(`
|
|
3
|
+
`)}function E(t){let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"import":if(t.isTypeOnly)e.push("import type");else e.push("import");if(t.specifiers&&t.specifiers.length>0){let s=t.specifiers.map((o)=>{let i=o.isType?"type ":"";return o.alias?`${i}${o.name} as ${o.alias}`:`${i}${o.name}`}).join(", ");e.push(`{ ${s} }`)}e.push("from"),e.push(`'${t.source}'`);break;case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${B(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let s of t.members)e.push(` ${s.name}${s.typeAnnotation?`: ${s.typeAnnotation}`:""}`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements?.length)e.push(`implements ${t.implements.join(", ")}`);e.push("{ }");break;case"enum":e.push("declare enum"),e.push(t.name),e.push("{ }");break;default:return t.text||""}return e.join(" ")}function B(t){if(!t)return"";return t.map((e)=>{let s="";if(e.rest)s+="...";if(s+=e.name,e.optional)s+="?";if(e.type)s+=`: ${e.type}`;return s}).join(", ")}function lr(t){return t.replace(/(?<!\/\*\*)\/\/[^\n]*/g,"").replace(/^\s*[\r\n]/gm,"").replace(/ {2,}/g," ").replace(/\s*([{}[\]();,:])\s*/g,"$1").replace(/(\w)(\{)/g,"$1 $2").replace(/(\})([a-z])/gi,"$1 $2").replace(/(export|import|type|interface|class|function|const|let|var|extends|implements|declare)\s*/g,"$1 ").trim()}
|
|
4
|
+
export{cr,Mi,lr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{r}from"./chunk-90f37xen.js";import{l}from"./chunk-976r899s.js";import{existsSync as v}from"fs";import{readFile as D}from"fs/promises";import{dirname as N,join as k,resolve as S}from"path";async function xr(e,o=process.cwd()){let i=new Map;for(let t of e){let n=S(o,t),s=await F(n,o);i.set(n,{path:n,dependencies:s,dependents:new Set,state:"pending"})}for(let[t,n]of i)for(let s of n.dependencies){let c=i.get(s);if(c)c.dependents.add(t)}return i}async function F(e,o){let i=new Set;try{let t=await D(e,"utf-8"),n=N(e);for(let s of r(t,e,!1)){let c=s.source;if(!c||!c.startsWith(".")&&!c.startsWith("/"))continue;let a=z(c,n,o);if(a)i.add(a)}}catch{}return i}function z(e,o,i){let t=S(o,e);if(/\.(?:ts|tsx|mts|cts)$/.test(e))return t.includes("node_modules")?null:t;let n=[".ts",".tsx",".mts",".cts"];for(let c of n){let a=`${t}${c}`;if(v(a))return a}for(let c of n){let a=k(t,`index${c}`);if(v(a))return a}let s=`${t}.ts`;return s.includes("node_modules")?null:s}function G(e){let o=[];for(let[i,t]of e){if(t.state!=="pending")continue;let n=!0;for(let s of t.dependencies){let c=e.get(s);if(c&&c.state!=="completed"){n=!1;break}}if(n)o.push(i)}return o}async function I(e,o={}){let i=await D(e,"utf-8"),t=o.keepComments??!0,n=r(i,e,t,o.isolatedDeclarations??!1);return l(n,{filePath:e,sourceCode:i,declarations:n},t,o.importOrder)}async function as(e,o={}){let i=performance.now(),{maxConcurrency:t=4,rootDir:n=process.cwd(),config:s={},onProgress:c,onError:a}=o,g=await xr(e,n),w=new Map,P=new Map,h=[],x=0,u=0,m=0,b=g.size;while(m<b){let y=G(g);if(y.length===0){let f=[...g.values()].filter((d)=>d.state==="pending");if(f.length>0)for(let d of f)d.state="failed",d.error=Error("Circular dependency detected or dependency failed"),P.set(d.path,d.error),m++;break}let C=y.slice(0,t-u);for(let f of C){let d=g.get(f);d.state="processing",u++}x=Math.max(x,u);let E=C.map(async(f)=>{let d=g.get(f),M=performance.now();try{let p=await I(f,s);d.state="completed",d.result=p,d.duration=performance.now()-M,w.set(f,p),h.push(f)}catch(p){if(d.state="failed",d.error=p instanceof Error?p:Error(String(p)),d.duration=performance.now()-M,P.set(f,d.error),a&&!a(f,d.error))throw Error("Processing aborted by error handler")}finally{u--,m++,c?.(m,b,f)}});await Promise.all(E)}return{success:w,failed:P,totalTimeMs:performance.now()-i,maxConcurrent:x,processingOrder:h}}function cs(e){let o=[],i=new Set,t=new Set;function n(s){if(i.has(s))return;if(t.has(s))return;t.add(s);let c=e.get(s);if(c){for(let a of c.dependencies)if(e.has(a))n(a)}t.delete(s),i.add(s),o.push(s)}for(let s of e.keys())n(s);return o}function wr(e){let o=[];for(let[i,t]of e){let n=!1;for(let s of t.dependencies)if(e.has(s)){n=!0;break}if(!n)o.push(i)}return o}function Cr(e){let o=[],i=new Set;while(i.size<e.size){let t=[];for(let[n,s]of e){if(i.has(n))continue;let c=!0;for(let a of s.dependencies)if(e.has(a)&&!i.has(a)){c=!1;break}if(c)t.push(n)}if(t.length===0){for(let n of e.keys())if(!i.has(n))t.push(n)}for(let n of t)i.add(n);o.push(t)}return o}function ls(e){let o=Cr(e),i=wr(e),t=Math.max(...o.map((s)=>s.length)),n=e.size/o.length;return{totalFiles:e.size,independentFiles:i.length,maxParallelism:t,levels:o.length,estimatedSpeedup:n}}
|
|
3
|
+
export{xr,as,cs,wr,Cr,ls};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
class
|
|
3
|
-
`)}}function
|
|
4
|
-
export{
|
|
2
|
+
class Kt{config;types=new Map;imports=new Map;relationships=[];usageMap=new Map;constructor(e={}){this.config={types:!1,relationships:!1,usage:!1,imports:!1,importUsage:!1,importRelationships:!1,...e}}trackType(e,s){if(!this.config.types)return;if(["interface","type","class","enum"].includes(e.kind)){if(this.types.get(e.name))return;let i={name:e.name,kind:e.kind,file:s,usedBy:new Set,references:new Set,extendsFrom:e.extends?[e.extends]:void 0,implementsFrom:e.implements};if(this.types.set(e.name,i),this.config.relationships){if(e.extends)this.relationships.push({from:e.name,to:e.extends,kind:"extends",file:s});if(e.implements)for(let n of e.implements)this.relationships.push({from:e.name,to:n,kind:"implements",file:s})}}}trackTypeUsage(e,s,t){if(!this.config.usage)return;let i=this.types.get(e);if(i)i.usedBy.add(s);let n=this.usageMap.get(e)||new Set;if(n.add(`${t}:${s}`),this.usageMap.set(e,n),this.config.relationships)this.relationships.push({from:s,to:e,kind:"uses",file:t})}trackImport(e,s,t,i){if(!this.config.imports)return;let n={source:e,specifiers:s,isTypeOnly:t,file:i,usedSpecifiers:new Set,unusedSpecifiers:new Set(s)},r=this.imports.get(i)||[];r.push(n),this.imports.set(i,r)}trackImportUsage(e,s){if(!this.config.importUsage)return;let t=this.imports.get(s);if(!t)return;for(let i of t)if(i.specifiers.includes(e))i.usedSpecifiers.add(e),i.unusedSpecifiers.delete(e)}trackTypeReference(e,s){if(!this.config.types)return;let t=this.types.get(e);if(t)t.references.add(s)}getResults(){let e=[],s=[];for(let[n,r]of this.types)if(r.usedBy.size===0&&r.references.size===0)e.push(n);for(let n of this.imports.values())for(let r of n)if(r.unusedSpecifiers.size===r.specifiers.length)s.push(r);let t=this.detectCircularReferences(),i={totalTypes:this.types.size,usedTypes:this.types.size-e.length,unusedTypes:e.length,totalImports:Array.from(this.imports.values()).flat().length,usedImports:Array.from(this.imports.values()).flat().filter((n)=>n.usedSpecifiers.size>0).length,unusedImports:s.length,totalRelationships:this.relationships.length,circularDependencies:t.length};return{types:this.types,imports:this.imports,relationships:this.relationships,unusedTypes:e,unusedImports:s,circularReferences:t,statistics:i}}detectCircularReferences(){let e=[],s=new Set,t=[],i=(n)=>{if(t.includes(n)){let o=t.indexOf(n);e.push(t.slice(o));return}if(s.has(n))return;s.add(n),t.push(n);let r=this.relationships.filter((o)=>o.from===n&&(o.kind==="extends"||o.kind==="implements"||o.kind==="references")).map((o)=>o.to);for(let o of r)i(o);t.pop()};for(let n of this.types.keys())i(n);return e}clear(){this.types.clear(),this.imports.clear(),this.relationships=[],this.usageMap.clear()}formatResults(){let e=this.getResults(),s=["=== Tracking Results ===",""];if(s.push("Statistics:"),s.push(` Total types: ${e.statistics.totalTypes}`),s.push(` Used types: ${e.statistics.usedTypes}`),s.push(` Unused types: ${e.statistics.unusedTypes}`),s.push(` Total imports: ${e.statistics.totalImports}`),s.push(` Used imports: ${e.statistics.usedImports}`),s.push(` Unused imports: ${e.statistics.unusedImports}`),s.push(` Type relationships: ${e.statistics.totalRelationships}`),s.push(` Circular dependencies: ${e.statistics.circularDependencies}`),s.push(""),e.unusedTypes.length>0){s.push("Unused types:");for(let t of e.unusedTypes){let i=e.types.get(t);s.push(` - ${t} (${i?.kind}) in ${i?.file}`)}s.push("")}if(e.unusedImports.length>0){s.push("Unused imports:");for(let t of e.unusedImports)s.push(` - ${t.source} in ${t.file}`),s.push(` Specifiers: ${Array.from(t.unusedSpecifiers).join(", ")}`);s.push("")}if(e.circularReferences.length>0){s.push("Circular references:");for(let t of e.circularReferences)s.push(` - ${t.join(" -> ")} -> ${t[0]}`);s.push("")}return s.join(`
|
|
3
|
+
`)}}function qt(e){return new Kt(e)}function Jt(e,s,t){for(let i of e){if(t.trackType(i,s),i.typeAnnotation){let n=p(i.typeAnnotation);for(let r of n)t.trackTypeUsage(r,i.name,s)}if(i.extends)t.trackTypeUsage(i.extends,i.name,s);if(i.implements)for(let n of i.implements)t.trackTypeUsage(n,i.name,s);if(i.kind==="import"&&i.source&&i.specifiers)t.trackImport(i.source,i.specifiers.map((n)=>n.name),i.isTypeOnly||!1,s)}}function p(e){let s=[],t=new Set(["string","number","boolean","any","unknown","void","never","null","undefined","object","symbol","bigint","true","false","readonly","keyof","typeof","infer","extends","in","out"]),i=/\b([A-Z]\w*)\b/g,n;while((n=i.exec(e))!==null){let r=n[1];if(!t.has(r.toLowerCase())&&!s.includes(r))s.push(r)}return s}function us(e,s){let t=qt({imports:!0,importUsage:!0,importRelationships:!0,...s});for(let[i,n]of e)Jt(n,i,t);return t.getResults()}function fs(e,s){let t=qt({types:!0,relationships:!0,usage:!0,...s});for(let[i,n]of e)Jt(n,i,t);return t.getResults()}
|
|
4
|
+
export{Kt,qt,Jt,us,fs};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,d,w}from"./chunk-
|
|
3
|
-
export{x,
|
|
2
|
+
import{t,d,w}from"./chunk-mhz6xe61.js";var C={kind:"symbol"},K=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:[\d_]+(?:\.[\d_]*)?|\.[\d_]+)(?:[eE][+-]?[\d_]+)?)/,v={"|":1,"^":2,"&":3,"<<":4,">>":4,">>>":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},M=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"];function x(l,c,o=0){if(o>=64)return;let n=l.trim(),r=t(n);if(!r.length)return;if(r[0].start!==0||r[r.length-1].end!==n.length)return x(n.slice(r[0].start,r[r.length-1].end),c,o+1);if(r.length===1&&r[0].kind==="quoted")return d(n);if(r.length===1&&r[0].kind==="word"){let e=c.get(n);return typeof e==="object"?void 0:e}if(K.exec(n)?.[0].length===n.length){let e=Number(n.replaceAll("_",""));return Number.isFinite(e)?e:void 0}let i=0,a;for(let e=0;e<r.length;e++){let s=r[e],u=n.slice(s.start,s.end);if(s.kind!=="punctuation")continue;if(["(","[","{"].includes(u)){i++;continue}if([")","]","}"].includes(u)){i--;continue}let m=K.exec(n.slice(s.start));if(m){while(r[e+1]?.start<s.start+m[0].length)e++;continue}if(i)continue;let f=M.find((S)=>n.startsWith(S,s.start));if(!f)continue;let p=r[e-1],h=p?n.slice(p.start,p.end):"";if(!(!p||p.kind==="punctuation"&&![")","]"].includes(h)&&!/\d/.test(h))&&(!a||v[f]<a.priority||v[f]===a.priority&&f!=="**"))a={start:s.start,operator:f,priority:v[f]};while(r[e+1]?.start<s.start+f.length)e++}if(a){let e=x(n.slice(0,a.start),c,o+1),s=x(n.slice(a.start+a.operator.length),c,o+1);if(e===void 0||s===void 0)return;if(a.operator==="+"&&(typeof e==="string"||typeof s==="string"))return String(e)+String(s);if(typeof e!=="number"||typeof s!=="number")return;let u;switch(a.operator){case"+":u=e+s;break;case"-":u=e-s;break;case"*":u=e*s;break;case"/":u=e/s;break;case"%":u=e%s;break;case"**":u=e**s;break;case"<<":u=e<<s;break;case">>":u=e>>s;break;case">>>":u=e>>>s;break;case"|":u=e|s;break;case"^":u=e^s;break;case"&":u=e&s;break;default:return}return Number.isFinite(u)?u:void 0}if(n.startsWith("(")&&n.endsWith(")")){let e=0;if(r.every((u,m)=>{let f=n.slice(u.start,u.end);if(f==="(")e++;if(f===")")e--;return e!==0||m===r.length-1}))return x(n.slice(1,-1),c,o+1)}if(["+","-","~"].includes(n[0])){let e=x(n.slice(1),c,o+1);if(typeof e!=="number")return;return n[0]==="-"?-e:n[0]==="~"?~e:e}if(!n.startsWith("`")||!n.endsWith("`"))return;let y="",b=1;for(let e=1;e<n.length-1;e++){if(n[e]==="\\"){e++;continue}if(n[e]!=="$"||n[e+1]!=="{")continue;let s=d(`\`${n.slice(b,e)}\``);if(s===void 0)return;y+=s;let u=0,m=r.find((p)=>{if(p.start<e+2||p.kind!=="punctuation")return!1;let h=n.slice(p.start,p.end);if(h==="{")u++;if(h!=="}")return!1;if(u===0)return!0;return u--,!1});if(!m)return;let f=x(n.slice(e+2,m.start),c,o+1);if(f===void 0)return;y+=String(f),e=m.start,b=e+1}let g=d(`\`${n.slice(b,-1)}\``);return g===void 0?void 0:y+g}function Qn(l,c){let o=[...new Set([...l,...c.values()])];if(!o.some((i)=>i.kind==="variable"&&typeof i.value==="string"&&/[\[{]/.test(i.value)))return;o.sort((i,a)=>(i.start??0)-(a.start??0));let n=new Map,r=new Map,k=o.some((i)=>i.name==="Symbol");for(let i of o){if(i.kind!=="variable"||typeof i.value!=="string")continue;if(i.value.includes("{")||i.value.includes("[")){let g=new Map(n);g.mutableBindingTypes=new Map(r),i.computedKeyConstants=g}let a=t(i.value),y=a.length===1&&a[0].kind==="word"?n.get(i.value.slice(a[0].start,a[0].end)):void 0;if(i.typeAnnotation==="unique symbol"||i.typeAnnotation==="symbol"||typeof y==="object"||!k&&a[0]?.kind==="word"&&i.value.slice(a[0].start,a[0].end)==="Symbol"&&["(","."].includes(i.value.slice(a[1]?.start,a[1]?.end))){n.set(i.name,C);continue}if(i.modifiers?.[0]!=="const"||i.typeAnnotation||i.modifiers.includes("const assertion"))continue;let b=x(i.value,n);if(b!==void 0){if(n.set(i.name,b),!(a.length===1&&a[0].kind==="word")||r.has(i.value.trim()))r.set(i.name,typeof b)}else if(i.value.trim()==="true"||i.value.trim()==="false")r.set(i.name,"boolean");else if(a.length===1&&a[0].kind==="word"){let g=r.get(i.value.trim());if(g)r.set(i.name,g)}}}function er(l,c){if(!l.trimStart().startsWith("[")||!l.includes("`"))return;let o=t(l);if(l[o[0]?.start]!=="["||l[o[1]?.start]!=="`"||l[o.at(-1)?.start??-1]!=="]")return;let n=l.slice(o[0].end,o.at(-1).start).trim(),r=x(n,c??new Map);return typeof r==="string"?{name:w(r,"'")}:{index:!0}}function tr(l,c){if(!c||!l.trimStart().startsWith("["))return!1;let o=t(l);return o.length===3&&l[o[0].start]==="["&&o[1].kind==="word"&&l[o[2].start]==="]"&&typeof c.get(l.slice(o[1].start,o[1].end))==="object"}function nr(l){if(!l.trimStart().startsWith("[")||!l.includes("`"))return!1;let c=t(l);return l[c[1]?.start]==="`"&&c.some((o)=>o.kind==="punctuation"&&l[o.start]==="{")}
|
|
3
|
+
export{x,Qn,er,tr,nr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{Be}from"./chunk-2d3nbfth.js";import{T}from"./chunk-1hz6j7bq.js";import{b}from"./chunk-xa9vcbjj.js";function Dn(i,r){let n=new Set;for(let e of T(i,"imports.ts",!1)){if(e.kind!=="import")continue;let t=b(e.text),a=t&&r.get(t.source);if(!t||t.isTypeOnly||!a)continue;let s=Ze(a);for(let o of t.namedItems)if(!o.isTypeOnly&&s.some((m)=>m.name===o.originalName))n.add(o.name);if(t.defaultName&&s.some((o)=>o.isDefault))n.add(t.defaultName)}return n}function Ze(i){let r=T(i,"dependency.ts",!1).filter((n)=>n.kind==="function");return r.filter((n)=>n.isExported&&!n.generics&&r.filter((e)=>e.name===n.name).length===1&&Be(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
|
|
3
|
+
export{Dn,Ze};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{s}from"./chunk-ykrdzatr.js";import{mkdtemp as y,readFile as v,realpath as l,rm as x}from"fs/promises";import{tmpdir as b}from"os";import{join as p,resolve as i}from"path";function ut(r={}){if(Reflect.get(r,"declarationMap"))throw Error("dtsx: bundled declaration maps are not supported");let u=new Map,c=(t,n)=>`${i(t)}\x00${n}`;return{name:"dtsx",tsdownConfig:()=>({dts:!1}),tsdownConfigResolved(t){u.set(c(i(t.cwd??process.cwd(),t.outDir??"dist"),t.format),t)},async generateBundle(t,n){let d=u.get(c(t.dir??"dist",t.format??"es"));if(!d)throw Error("dtsx: expected a resolved tsdown build before generating declarations");let f=await l(i(r.cwd??d.cwd??process.cwd())),m=await l(i(f,r.root??d.root)),a=await y(p(b(),"dtsx-tsdown-"));try{for(let e of Object.values(n)){if(e.type!=="chunk"||!e.isEntry||!e.facadeModuleId)continue;let w=await l(e.facadeModuleId),g=e.fileName.endsWith(".cjs")?".d.cts":e.fileName.endsWith(".mjs")?".d.mts":".d.ts",o=e.fileName.replace(/\.(?:c|m)?js$/,g);if(o===e.fileName)throw Error(`dtsx: unsupported tsdown JavaScript output ${e.fileName}`);if((await s({...r,cwd:f,root:m,entrypoints:[w],outdir:a,bundle:!0,bundleOutput:o,clean:!1,dryRun:!1,outputStructure:"mirror",declarationMap:!1,moduleSpecifierMode:r.moduleSpecifierMode??"node"})).filesFailed)throw Error(`dtsx: declaration generation failed for ${e.facadeModuleId}`);this.emitFile({type:"asset",fileName:o,source:await v(p(a,o),"utf8")})}}finally{await x(a,{recursive:!0,force:!0})}}}}var Ta=ut;
|
|
3
|
+
export{ut,Ta};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{t}from"./chunk-mhz6xe61.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 Ne(n){let s=[];return y(j(n),s),s}function rr(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
|
+
export{Ne,rr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{Ae}from"./chunk-xgf6djk3.js";import{readFileSync as m,statSync as w}from"fs";import{readFile as y}from"fs/promises";import{createRequire as v}from"module";import{dirname as g,isAbsolute as b,join as u,resolve as p}from"path";function l(t){let o=[t];if(!t.endsWith(".json"))o.push(`${t}.json`);o.push(u(t,"tsconfig.json"));for(let a of o)try{if(w(a).isFile())return a}catch{}return null}function E(t,o){if(b(t)||t.startsWith("."))return l(p(g(o),t));let a=v(o),n=t.startsWith("@")?/^@[^/]+\/[^/]+/.exec(t)?.[0]:t.split("/")[0];if(n)for(let d of a.resolve.paths(n)??[]){let e=l(u(d,n,"package.json"));if(!e)continue;let i=JSON.parse(m(e,"utf8"));if(t===n){if(i.tsconfig!==void 0){if(typeof i.tsconfig!=="string")throw Error(`Invalid tsconfig field in ${e}`);let r=l(p(g(e),i.tsconfig));if(!r)throw Error(`Cannot resolve tsconfig ${JSON.stringify(i.tsconfig)} from ${e}`);return r}let s=l(u(g(e),"tsconfig.json"));if(s)return s}break}for(let d of[`${t}/tsconfig.json`,t])try{let e=a.resolve(d),i=e.endsWith(".json")?l(e):null;if(i)return i}catch{}return null}async function ne(t,o={},a=new Set){let n=l(t);if(!n)return;if(a.has(n)){if(o.allowCircular)return;throw Error(`Circular tsconfig extends: ${n}`)}let d=new Set(a).add(n),e=JSON.parse(Ae(await y(n,"utf8"))),i=typeof e.extends==="string"?[e.extends]:e.extends??[];if(!Array.isArray(i)||i.some((f)=>typeof f!=="string"))throw Error(`Invalid tsconfig extends in ${n}`);let s={};for(let f of i){let c=E(f,n);if(!c)throw Error(`Cannot resolve tsconfig extends ${JSON.stringify(f)} from ${n}`);s={...s,...await ne(c,o,d)}}let r=e.compilerOptions??{};if(r.isolatedDeclarations!==void 0)s.isolatedDeclarations=r.isolatedDeclarations;if(r.baseUrl!==void 0){if(typeof r.baseUrl!=="string")throw Error(`Invalid baseUrl in ${n}`);s.baseUrl=p(g(n),r.baseUrl)}if(r.paths!==void 0){if(!r.paths||typeof r.paths!=="object"||Array.isArray(r.paths))throw Error(`Invalid paths in ${n}`);for(let[f,c]of Object.entries(r.paths))if(f.split("*").length>2||!Array.isArray(c)||c.length===0||c.some((h)=>typeof h!=="string"||h.split("*").length>2))throw Error(`Invalid path mapping ${JSON.stringify(f)} in ${n}`);s.paths=r.paths,s.pathsBasePath=g(n)}return s}
|
|
3
|
+
export{ne};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-90f37xen.js";import{l}from"./chunk-976r899s.js";import{existsSync as P,readFileSync as b,unwatchFile as w}from"fs";var Wr;((o)=>{o[o.Error=1]="Error";o[o.Warning=2]="Warning";o[o.Information=3]="Information";o[o.Hint=4]="Hint"})(Wr||={});var _r;((s)=>{s[s.File=1]="File";s[s.Module=2]="Module";s[s.Namespace=3]="Namespace";s[s.Package=4]="Package";s[s.Class=5]="Class";s[s.Method=6]="Method";s[s.Property=7]="Property";s[s.Field=8]="Field";s[s.Constructor=9]="Constructor";s[s.Enum=10]="Enum";s[s.Interface=11]="Interface";s[s.Function=12]="Function";s[s.Variable=13]="Variable";s[s.Constant=14]="Constant";s[s.String=15]="String";s[s.Number=16]="Number";s[s.Boolean=17]="Boolean";s[s.Array=18]="Array";s[s.Object=19]="Object";s[s.Key=20]="Key";s[s.Null=21]="Null";s[s.EnumMember=22]="EnumMember";s[s.Struct=23]="Struct";s[s.Event=24]="Event";s[s.Operator=25]="Operator";s[s.TypeParameter=26]="TypeParameter"})(_r||={});var jr;((c)=>{c[c.Text=1]="Text";c[c.Method=2]="Method";c[c.Function=3]="Function";c[c.Constructor=4]="Constructor";c[c.Field=5]="Field";c[c.Variable=6]="Variable";c[c.Class=7]="Class";c[c.Interface=8]="Interface";c[c.Module=9]="Module";c[c.Property=10]="Property";c[c.Unit=11]="Unit";c[c.Value=12]="Value";c[c.Enum=13]="Enum";c[c.Keyword=14]="Keyword";c[c.Snippet=15]="Snippet";c[c.Color=16]="Color";c[c.File=17]="File";c[c.Reference=18]="Reference";c[c.Folder=19]="Folder";c[c.EnumMember=20]="EnumMember";c[c.Constant=21]="Constant";c[c.Struct=22]="Struct";c[c.Event=23]="Event";c[c.Operator=24]="Operator";c[c.TypeParameter=25]="TypeParameter"})(jr||={});var Gr;((n)=>{n[n.Text=1]="Text";n[n.Read=2]="Read";n[n.Write=3]="Write"})(Gr||={});class on{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(t){return this.rootUri=t.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(t){let{uri:e,text:i,version:n}=t.textDocument;this.updateDocument(e,i,n)}didChange(t){let{uri:e,version:i}=t.textDocument,n=t.contentChanges[0]?.text||"";this.updateDocument(e,n,i)}didClose(t){let e=t.textDocument.uri;if(this.documents.delete(e),this.watchers.get(e))w(this.uriToPath(e)),this.watchers.delete(e)}updateDocument(t,e,i){let n=this.uriToPath(t),o=r(e,n,!0);this.documents.set(t,{content:e,version:i,declarations:o})}getDiagnostics(t){let e=this.documents.get(t);if(!e)return[];let i=[];for(let n of e.declarations){if(n.isExported&&n.kind==="variable"&&!n.typeAnnotation)i.push({range:this.getDeclarationRange(n,e.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${n.name}' should have an explicit type annotation for better declaration generation`});if(n.typeAnnotation==="any"||n.returnType==="any")i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(n.kind==="function"&&n.isExported&&!n.returnType)i.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${n.name}' should have an explicit return type for better declaration generation`})}return i}hover(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:i,character:n}=t.position,a=e.content.split(`
|
|
3
3
|
`)[i]||"",u=a.slice(0,n).match(/[\w$]+$/),d=a.slice(n).match(/^[\w$]+/);if(!u&&!d)return null;let g=(u?.[0]||"")+(d?.[0]||""),f=e.declarations.find((x)=>x.name===g);if(!f)return null;let m=`\`\`\`typescript
|
|
4
4
|
${this.buildSignature(f)}
|
|
5
5
|
\`\`\``;if(f.leadingComments&&f.leadingComments.length>0){let v=f.leadingComments.join(`
|
|
@@ -14,9 +14,9 @@ ${v[1].trim()}`}return{contents:{kind:"markdown",value:m}}}completion(t){let e=t
|
|
|
14
14
|
`)[e.line]||"",a=o.slice(0,e.character).match(/[\w$]+$/),u=o.slice(e.character).match(/^[\w$]+/);if(!a&&!u)return null;return(a?.[0]||"")+(u?.[0]||"")}getWordAtRange(t,e){let i=this.documents.get(t);if(!i)return null;let n=i.content.split(`
|
|
15
15
|
`);if(e.start.line===e.end.line)return n[e.start.line]?.slice(e.start.character,e.end.character)||null;return null}getDeclarationAtPosition(t,e){let i=this.documents.get(t);if(!i)return null;for(let n of i.declarations){let o=this.getDeclarationRange(n,i.content);if(this.positionInRange(e,o))return n}return null}positionInRange(t,e){if(t.line<e.start.line||t.line>e.end.line)return!1;if(t.line===e.start.line&&t.character<e.start.character)return!1;if(t.line===e.end.line&&t.character>e.end.character)return!1;return!0}declarationKindToSymbolKind(t){switch(t){case"function":return 12;case"class":return 5;case"interface":return 11;case"type":return 11;case"enum":return 10;case"variable":return 13;case"const":return 14;case"property":return 7;case"method":return 6;case"module":return 2;case"namespace":return 3;default:return 13}}generateDts(t){let e=this.documents.get(t);if(!e)return null;let i={filePath:this.uriToPath(t),sourceCode:e.content,declarations:e.declarations};return l(e.declarations,i,!0,this.config.importOrder)}buildSignature(t){switch(t.kind){case"function":{let e=t.parameters?.map((o)=>{let a="";if(o.rest)a+="...";if(a+=o.name,o.optional)a+="?";if(o.type)a+=`: ${o.type}`;return a}).join(", ")||"",i=t.generics||"",n=t.returnType?`: ${t.returnType}`:"";return`function ${t.name}${i}(${e})${n}`}case"variable":return`const ${t.name}: ${t.typeAnnotation||"unknown"}`;case"interface":return`interface ${t.name}${t.generics||""}${t.extends?` extends ${t.extends}`:""}`;case"type":return`type ${t.name}${t.generics||""} = ${t.typeAnnotation||"unknown"}`;case"class":return`class ${t.name}${t.generics||""}${t.extends?` extends ${t.extends}`:""}`;case"enum":return`enum ${t.name}`;default:return t.name}}getDeclarationRange(t,e){if(t.start!==void 0&&t.end!==void 0)return{start:this.offsetToPosition(t.start,e),end:this.offsetToPosition(t.end,e)};let i=e.split(`
|
|
16
16
|
`);for(let n=0;n<i.length;n++){let o=i[n].indexOf(t.name);if(o!==-1)return{start:{line:n,character:o},end:{line:n,character:o+t.name.length}}}return{start:{line:0,character:0},end:{line:0,character:0}}}offsetToPosition(t,e){let i=0,n=0;for(let o=0;o<t&&o<e.length;o++)if(e[o]===`
|
|
17
|
-
`)i++,n=0;else n++;return{line:i,character:n}}uriToPath(t){if(t.startsWith("file://"))return decodeURIComponent(t.slice(7));return t}pathToUri(t){return`file://${encodeURIComponent(t).replace(/%2F/g,"/")}`}handleMessage(t){if(t.method==="initialize")return{jsonrpc:"2.0",id:t.id,result:this.initialize(t.params)};if(t.method==="initialized")return null;if(t.method==="shutdown")return{jsonrpc:"2.0",id:t.id,result:null};if(t.method==="exit")process.exit(0);let e=t.params;if(t.method==="textDocument/didOpen")return this.didOpen(e),null;if(t.method==="textDocument/didChange")return this.didChange(e),null;if(t.method==="textDocument/didClose")return this.didClose(e),null;if(t.method==="textDocument/hover")return{jsonrpc:"2.0",id:t.id,result:this.hover(e)};if(t.method==="textDocument/completion")return{jsonrpc:"2.0",id:t.id,result:this.completion(e)};if(t.method==="textDocument/definition")return{jsonrpc:"2.0",id:t.id,result:this.definition(e)};if(t.method==="textDocument/references")return{jsonrpc:"2.0",id:t.id,result:this.references(e)};if(t.method==="textDocument/prepareRename")return{jsonrpc:"2.0",id:t.id,result:this.prepareRename(e)};if(t.method==="textDocument/rename")return{jsonrpc:"2.0",id:t.id,result:this.rename(e)};if(t.method==="textDocument/documentSymbol")return{jsonrpc:"2.0",id:t.id,result:this.documentSymbols(e)};if(t.method==="workspace/symbol")return{jsonrpc:"2.0",id:t.id,result:this.workspaceSymbols(e)};if(t.method==="textDocument/codeAction")return{jsonrpc:"2.0",id:t.id,result:this.codeActions(e)};if(t.method==="textDocument/signatureHelp")return{jsonrpc:"2.0",id:t.id,result:this.signatureHelp(e)};if(t.method==="textDocument/documentHighlight")return{jsonrpc:"2.0",id:t.id,result:this.documentHighlight(e)};if(t.method==="textDocument/formatting")return{jsonrpc:"2.0",id:t.id,result:this.formatting(e)};if(t.method==="textDocument/diagnostic"){let i=e?.textDocument?.uri;return{jsonrpc:"2.0",id:t.id,result:{kind:"full",items:i?this.getDiagnostics(i):[]}}}if(t.id!==void 0)return{jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`Method not found: ${t.method}`}};return null}}function
|
|
17
|
+
`)i++,n=0;else n++;return{line:i,character:n}}uriToPath(t){if(t.startsWith("file://"))return decodeURIComponent(t.slice(7));return t}pathToUri(t){return`file://${encodeURIComponent(t).replace(/%2F/g,"/")}`}handleMessage(t){if(t.method==="initialize")return{jsonrpc:"2.0",id:t.id,result:this.initialize(t.params)};if(t.method==="initialized")return null;if(t.method==="shutdown")return{jsonrpc:"2.0",id:t.id,result:null};if(t.method==="exit")process.exit(0);let e=t.params;if(t.method==="textDocument/didOpen")return this.didOpen(e),null;if(t.method==="textDocument/didChange")return this.didChange(e),null;if(t.method==="textDocument/didClose")return this.didClose(e),null;if(t.method==="textDocument/hover")return{jsonrpc:"2.0",id:t.id,result:this.hover(e)};if(t.method==="textDocument/completion")return{jsonrpc:"2.0",id:t.id,result:this.completion(e)};if(t.method==="textDocument/definition")return{jsonrpc:"2.0",id:t.id,result:this.definition(e)};if(t.method==="textDocument/references")return{jsonrpc:"2.0",id:t.id,result:this.references(e)};if(t.method==="textDocument/prepareRename")return{jsonrpc:"2.0",id:t.id,result:this.prepareRename(e)};if(t.method==="textDocument/rename")return{jsonrpc:"2.0",id:t.id,result:this.rename(e)};if(t.method==="textDocument/documentSymbol")return{jsonrpc:"2.0",id:t.id,result:this.documentSymbols(e)};if(t.method==="workspace/symbol")return{jsonrpc:"2.0",id:t.id,result:this.workspaceSymbols(e)};if(t.method==="textDocument/codeAction")return{jsonrpc:"2.0",id:t.id,result:this.codeActions(e)};if(t.method==="textDocument/signatureHelp")return{jsonrpc:"2.0",id:t.id,result:this.signatureHelp(e)};if(t.method==="textDocument/documentHighlight")return{jsonrpc:"2.0",id:t.id,result:this.documentHighlight(e)};if(t.method==="textDocument/formatting")return{jsonrpc:"2.0",id:t.id,result:this.formatting(e)};if(t.method==="textDocument/diagnostic"){let i=e?.textDocument?.uri;return{jsonrpc:"2.0",id:t.id,result:{kind:"full",items:i?this.getDiagnostics(i):[]}}}if(t.id!==void 0)return{jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`Method not found: ${t.method}`}};return null}}function Bs(){let t=new on,e="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(i)=>{e+=i;while(!0){let n=e.indexOf(`\r
|
|
18
18
|
\r
|
|
19
19
|
`);if(n===-1)break;let a=e.slice(0,n).match(/Content-Length:\s*(\d+)/i);if(!a){e=e.slice(n+4);continue}let u=Number.parseInt(a[1],10),d=n+4,g=d+u;if(e.length<g)break;let f=e.slice(d,g);e=e.slice(g);try{let p=JSON.parse(f),m=t.handleMessage(p);if(m){let x=JSON.stringify(m),v=Buffer.byteLength(x,"utf8");process.stdout.write(`Content-Length: ${v}\r
|
|
20
20
|
\r
|
|
21
|
-
${x}`)}}catch(p){console.error("Error parsing LSP message:",p)}}})}function
|
|
22
|
-
export{
|
|
21
|
+
${x}`)}}catch(p){console.error("Error parsing LSP message:",p)}}})}function Ws(t,e){return(i)=>{if(!P(i))return;let n=b(i,"utf-8"),o=`file://${i}`;t.didOpen({textDocument:{uri:o,languageId:"typescript",version:1,text:n}});let a=t.getDiagnostics(o);e(o,a)}}
|
|
22
|
+
export{Wr,_r,jr,Gr,on,Bs,Ws};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{et}from"./chunk-vv8e8pa3.js";import{E}from"./chunk-waan03ga.js";import{Tn}from"./chunk-sqnhxtbk.js";import{we}from"./chunk-3rwbf45t.js";import{ne}from"./chunk-ehgnwdn9.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function Ye(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function To(n,r){throw Error(r||`Unexpected value: ${n}`)}async function U(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
|
|
6
|
+
`);if(await et(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function di(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()?di(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 X(n){try{let r=n?.cwd||y.cwd();return(await ne(D(r,n?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function St(n,r){let o={isValid:!0,errors:[]};for(let t of we(n))o.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of Tn(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 $t(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
|
-
`)}function
|
|
9
|
+
`)}function Et(n,r,o,t){let i=n.split(`
|
|
10
10
|
`),c=[];function a(s){let l="",f=s<0?-s<<1|1:s<<1;do{let d=f&31;if(f>>>=5,f>0)d|=32;l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d]}while(f>0);return l}let g=0,u=0,p=0,e=t.split(`
|
|
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
|
|
12
|
-
${
|
|
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 kt(n,r){return`${n}
|
|
12
|
+
${Ye()}${r}
|
|
13
13
|
`}
|
|
14
|
-
export{
|
|
14
|
+
export{Ye,To,U,di,X,St,$t,Et,kt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var s=new Map,n=new Map;function
|
|
3
|
-
export{
|
|
2
|
+
var s=new Map,n=new Map;function Ba(e){let t=s.get(e);if(t)return s.delete(e),s.set(e,t),t;let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`\\b${o}\\b`);if(s.set(e,c),s.size>500){let r=0;for(let i of s.keys()){if(r++>=50)break;s.delete(i)}}return c}function Hn(e){let t=n.get(e);if(t)return n.delete(e),n.set(e,t),t;return null}function Kn(e,t){if(n.set(e,t),n.size>200){let o=0;for(let c of n.keys()){if(o++>=20)break;n.delete(c)}}}function qn(){s.clear(),n.clear()}
|
|
3
|
+
export{Ba,Hn,Kn,qn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
export{
|
|
2
|
+
var pi=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],mi=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],gi=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],hi=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function yi(e){switch(e){case"strict":return mi;case"readonly":return gi;case"simplified":return hi;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class kn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...pi);if(e.presets)for(let r of e.presets)this.rules.push(...yi(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function Z(e={rules:[]}){return new kn(e)}var Do=Z({rules:[]}),Po=Z({rules:[],presets:["strict"]});function Tt(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var Ro={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
|
|
3
|
+
export{pi,mi,gi,hi,yi,kn,Z,Do,Po,Tt,Ro};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{basename as e,dirname as n,isAbsolute as i,join as o,relative as a,resolve as s}from"path";function
|
|
3
|
-
export{
|
|
2
|
+
import{basename as e,dirname as n,isAbsolute as i,join as o,relative as a,resolve as s}from"path";function Ii(t){if(!t||typeof t!=="string")throw Error("Invalid file path: must be a non-empty string");return t}function Li(t){if(!t||typeof t!=="string")throw Error("Invalid directory path: must be a non-empty string");return t}function Fi(t){if(!t||typeof t!=="string")throw Error("Invalid glob pattern: must be a non-empty string");return t}function Ni(t){if(typeof t!=="string")throw TypeError("Invalid source code: must be a string");return t}function Bi(t){if(typeof t!=="string")throw TypeError("Invalid DTS content: must be a string");return t}function Wi(t){if(!t||typeof t!=="string")throw Error("Invalid module specifier: must be a non-empty string");return t}function _i(t){if(!t||typeof t!=="string")throw Error("Invalid type name: must be a non-empty string");if(!["string","number","boolean","symbol","bigint","undefined","null","void","never","any","unknown","object"].includes(t)&&!/^[A-Z_$]/.test(t));return t}function ji(t){if(!t||typeof t!=="string")throw Error("Invalid declaration name: must be a non-empty string");return t}function Gi(t){if(!t||typeof t!=="string")throw Error("Invalid absolute path: must be a non-empty string");if(!t.startsWith("/")&&!/^[A-Z]:/i.test(t))throw Error("Invalid absolute path: must start with / or drive letter");return t}function Vi(t){if(!t||typeof t!=="string")throw Error("Invalid relative path: must be a non-empty string");if(t.startsWith("/")||/^[A-Z]:/i.test(t))throw Error("Invalid relative path: must not be absolute");return t}function Ui(t){if(typeof t!=="string")throw TypeError("Invalid JSON string: must be a string");try{JSON.parse(t)}catch{throw Error("Invalid JSON string: must be valid JSON")}return t}function zi(t,r){return typeof t==="string"||typeof t==="number"}function Hi(t){return t}var Ki={join(t,...r){return o(t,...r)},dirname(t){return n(t)},basename(t){return e(t)},resolve(...t){return s(...t)},isAbsolute(t){return i(t)},relative(t,r){return a(t,r)}};
|
|
3
|
+
export{Ii,Li,Fi,Ni,Bi,Wi,_i,ji,Gi,Vi,Ui,zi,Hi,Ki};
|
|
@@ -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
|
|
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 ci(t){try{C(d(t,v),{force:!0});try{D(t)}catch{}}catch{}}class Je{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,ci(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 vt(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{
|
|
7
|
+
export{ci,Je,vt};
|