@dtsx/dtsx 0.11.37 → 0.11.39
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 +18 -12
- package/dist/bin/cli.js +3 -3
- package/dist/{chunk-gsb3ty07.js → chunk-0c03j9eq.js} +2 -2
- package/dist/{chunk-n2nyd0ck.js → chunk-0m1wt3db.js} +2 -2
- package/dist/chunk-2dstvjpv.js +3 -0
- package/dist/{chunk-z4mvkazp.js → chunk-2ngfncfx.js} +11 -11
- package/dist/{chunk-ckq8g1ck.js → chunk-31kbs9mj.js} +3 -3
- package/dist/{chunk-m1khpcqb.js → chunk-3dweac93.js} +2 -2
- package/dist/chunk-3jjrn16z.js +14 -0
- package/dist/chunk-3mcz22q8.js +37 -0
- package/dist/{chunk-sjneg7p7.js → chunk-3s37g6bh.js} +8 -8
- package/dist/{chunk-r4s18nn5.js → chunk-45fpbdw3.js} +2 -2
- package/dist/{chunk-w9av39jy.js → chunk-4q78f5pg.js} +2 -2
- package/dist/{chunk-psrgw9f8.js → chunk-550teag8.js} +10 -10
- package/dist/{chunk-v44crx69.js → chunk-60wrxcjt.js} +11 -11
- package/dist/{chunk-0ke9xh7t.js → chunk-6epjc5rj.js} +3 -3
- package/dist/{chunk-n37yj3xv.js → chunk-7bt7x8sy.js} +3 -3
- package/dist/{chunk-j6pfxvy8.js → chunk-7j4cgkb4.js} +2 -2
- package/dist/chunk-7ynrmx5b.js +29 -0
- package/dist/chunk-7z8pykqp.js +3 -0
- package/dist/{chunk-acyj1dev.js → chunk-8dvxjzhy.js} +2 -2
- package/dist/{chunk-437g8zz6.js → chunk-8fg11pr7.js} +3 -3
- package/dist/{chunk-zq93f8ca.js → chunk-8kj9pkw5.js} +2 -2
- package/dist/chunk-8zvjkzsv.js +3 -0
- package/dist/{chunk-g9d5r6a8.js → chunk-996gqrz6.js} +2 -2
- package/dist/{chunk-aw48mk3t.js → chunk-9gp0e3kn.js} +2 -2
- package/dist/{chunk-rdzfdjkb.js → chunk-a3apthex.js} +3 -3
- package/dist/{chunk-5n0tfrpc.js → chunk-a3vfqhnp.js} +3 -3
- package/dist/{chunk-s0mvstt0.js → chunk-aak9xzy7.js} +2 -2
- package/dist/{chunk-p7w9ydhe.js → chunk-aq7y0s2v.js} +4 -4
- package/dist/{chunk-nchp0pqa.js → chunk-axj2w6hp.js} +2 -2
- package/dist/{chunk-dfye109x.js → chunk-ayyb1jpe.js} +2 -2
- package/dist/{chunk-srg5qhch.js → chunk-bc7ahgxz.js} +4 -4
- package/dist/{chunk-pzedkn7z.js → chunk-bkbsg2bv.js} +2 -2
- package/dist/{chunk-km8t8gqg.js → chunk-btc6zbyj.js} +2 -2
- package/dist/{chunk-1j6092xz.js → chunk-c7a07a26.js} +4 -4
- package/dist/{chunk-gs7wfk8b.js → chunk-cyw59tgm.js} +1 -1
- package/dist/{chunk-4f2mwn7p.js → chunk-dh3y4pf7.js} +4 -4
- package/dist/{chunk-strqhcqs.js → chunk-dpcvehxp.js} +2 -2
- package/dist/{chunk-knrtwppp.js → chunk-ee109s3r.js} +6 -6
- package/dist/{chunk-cen2t56g.js → chunk-ex03kbwr.js} +2 -2
- package/dist/{chunk-r4zkf9ag.js → chunk-fay5vymp.js} +2 -2
- package/dist/{chunk-xsf941gw.js → chunk-g3zt5h6d.js} +2 -2
- package/dist/{chunk-gsv5yc32.js → chunk-hgscwj1y.js} +4 -4
- package/dist/{chunk-mt9219xc.js → chunk-hqph3vnd.js} +5 -5
- package/dist/chunk-hvy1zvk6.js +3 -0
- package/dist/{chunk-wnk9yjw2.js → chunk-jfygtm4r.js} +2 -2
- package/dist/{chunk-xr1h3tv2.js → chunk-jhpfmjnx.js} +2 -2
- package/dist/chunk-js4m0y2m.js +3 -0
- package/dist/{chunk-wzcwctba.js → chunk-jswvvjkr.js} +3 -3
- package/dist/{chunk-1e10w914.js → chunk-jvqczw2k.js} +3 -3
- package/dist/{chunk-7610h2tf.js → chunk-jyq39qjt.js} +2 -2
- package/dist/{chunk-pga5m4wm.js → chunk-k5wz43yh.js} +2 -2
- package/dist/{chunk-bqabznps.js → chunk-ka8mbyjb.js} +2 -2
- package/dist/{chunk-2kwjbk55.js → chunk-kccc6p2t.js} +2 -2
- package/dist/{chunk-py7pj8aj.js → chunk-khyg6w62.js} +4 -4
- package/dist/{chunk-sq34kkhy.js → chunk-kv0bpgyw.js} +2 -2
- package/dist/{chunk-gpq2kggq.js → chunk-kv3x5jrs.js} +2 -2
- package/dist/{chunk-ggbahdr2.js → chunk-m0tacjrk.js} +3 -3
- package/dist/{chunk-bdxq6500.js → chunk-nd0sbh5r.js} +3 -3
- package/dist/{chunk-fgbdm1y6.js → chunk-nqgfrehj.js} +4 -4
- package/dist/{chunk-ezbp8tss.js → chunk-p4hf9bwj.js} +8 -8
- package/dist/{chunk-n6nw7sn2.js → chunk-phwfth21.js} +5 -5
- package/dist/chunk-qq5x44y9.js +38 -0
- package/dist/{chunk-q0hn0ymb.js → chunk-qrwst9bb.js} +4 -4
- package/dist/{chunk-nn9tpxx3.js → chunk-sgcne5bb.js} +2 -2
- package/dist/{chunk-dv5hhg1a.js → chunk-t6ds7drh.js} +2 -2
- package/dist/{chunk-wrnz0e76.js → chunk-tm2j0feh.js} +3 -3
- package/dist/chunk-vbzchjvq.js +3 -0
- package/dist/{chunk-60ssvwc8.js → chunk-veh8ks5v.js} +2 -2
- package/dist/chunk-vf8jmdsp.js +3 -0
- package/dist/chunk-vgmnxnjf.js +27 -0
- package/dist/{chunk-1h6ycqza.js → chunk-w26wgqh8.js} +4 -4
- package/dist/{chunk-n3p7wedp.js → chunk-x3arymvk.js} +2 -2
- package/dist/{chunk-fy97syc2.js → chunk-y3x7p6jf.js} +2 -2
- package/dist/{chunk-853ftm92.js → chunk-y4wykrya.js} +5 -5
- package/dist/{chunk-h7k9wamx.js → chunk-ybzz1jg7.js} +2 -2
- package/dist/chunk-yde8rmfm.js +31 -0
- package/dist/chunk-yzdh207n.js +10 -0
- package/dist/chunk-z6mpxpxt.js +3 -0
- package/dist/chunk-zbe06f63.js +3 -0
- package/dist/{chunk-vtskg4r2.js → chunk-zk55g2cb.js} +2 -2
- package/dist/{chunk-1bpv3tck.js → chunk-zn2gvwve.js} +4 -4
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.js +1 -1
- package/dist/src/branded-types.d.ts +0 -11
- 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/concurrency.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.d.ts +4 -4
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/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.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.d.ts +18 -0
- package/dist/src/parameters.js +1 -1
- package/dist/src/parser.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsdown.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/dist/src/plugins.js +1 -1
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/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.d.ts +29 -0
- 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/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.d.ts +0 -13
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/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-0azm93j9.js +0 -31
- package/dist/chunk-1pz7zxhc.js +0 -3
- package/dist/chunk-25vyhfzh.js +0 -3
- package/dist/chunk-69dbf6de.js +0 -3
- package/dist/chunk-79nv7twc.js +0 -14
- package/dist/chunk-90aptjh6.js +0 -24
- package/dist/chunk-cs4gwz1k.js +0 -27
- package/dist/chunk-d43bpfk6.js +0 -3
- package/dist/chunk-n94729d9.js +0 -3
- package/dist/chunk-p2qz2nk2.js +0 -3
- package/dist/chunk-qnf4byak.js +0 -3
- package/dist/chunk-rmdwvzgn.js +0 -3
- package/dist/chunk-s6c98nad.js +0 -29
- package/dist/chunk-t1jtn2r0.js +0 -10
- package/dist/chunk-ttc5pr8y.js +0 -37
- package/dist/chunk-xb92nrsm.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`));if(!t.some((a,i)=>a!==e.leadingComments[i]))return;return{...e,leadingComments:t}}}function
|
|
4
|
-
export{
|
|
2
|
+
import{Y}from"./chunk-jswvvjkr.js";function gi(n,r,e,t={}){return{kind:n,name:r,text:e,isExported:t.isExported??!1,...t}}function hi(n){if(typeof structuredClone==="function")return structuredClone(n);return JSON.parse(JSON.stringify(n))}function Tn(n,r,e=null){for(let t of n){r.enter?.(t,e);let o=r[t.kind];if(o)o(t,e);if(t.members&&t.members.length>0)Tn(t.members,r,t);r.leave?.(t,e)}}function Po(n,r){let e=[];return Tn(n,{enter:(t)=>{if(r(t))e.push(t)}}),e}async function yi(n,r,e){let t=[],o=n.length;for(let a=0;a<n.length;a++){let i=n[a],s={...e,index:a,total:o,allDeclarations:n},l=await r(i,s);if(l===null)continue;else if(l===void 0)t.push(i);else if(Array.isArray(l))t.push(...l);else t.push(l)}return t}function Do(...n){return async(r,e)=>{let t=r;for(let o of n){if(t===null)return null;if(Array.isArray(t)){let a=[];for(let i of t){let s=await o(i,e);if(s===null)continue;if(s===void 0)a.push(i);else if(Array.isArray(s))a.push(...s);else a.push(s)}t=a.length>0?a:null}else{let a=await o(t,e);if(a===null)t=null;else if(a===void 0);else t=a}}return t}}function we(n,r){let e=new Set(Array.isArray(n)?n:[n]);return async(t,o)=>{if(e.has(t.kind))return r(t,o);return}}function Ro(n,r){return async(e,t)=>{if(n(e))return r(e,t);return}}function Ye(n){let r={createDeclaration:gi,cloneDeclaration:hi,modifyText:(e,t)=>({...e,text:t}),addModifier:(e,t)=>({...e,modifiers:[...e.modifiers||[],t]}),removeModifier:(e,t)=>({...e,modifiers:(e.modifiers||[]).filter((o)=>o!==t)})};return Y({name:n.name,version:n.version,description:n.description,onBeforeFile:n.beforeParse?async(e)=>n.beforeParse(e.content,{filePath:e.filePath,phase:"before"}):void 0,onDeclarations:n.transform?async(e)=>yi(e.declarations,n.transform,{filePath:e.filePath,sourceCode:e.sourceCode,...r}):void 0,onAfterFile:n.afterGenerate?async(e)=>n.afterGenerate(e.content,{filePath:e.filePath,phase:"after"}):void 0})}function Mo(n,r){let e=typeof n==="string"?new RegExp(n):n;return(t)=>{if(e.test(t.name)){let o=typeof r==="function"?r(t.name,t):t.name.replace(e,r),a=t.text.replace(new RegExp(`\\b${f(t.name)}\\b`),o);return{...t,name:o,text:a}}return}}function bi(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${n}${e.name}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function Oo(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${e.name}${n}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function wi(n){let r=typeof n==="function"?n:(e)=>(typeof n==="string"?new RegExp(n):n).test(e.name);return(e)=>{if(r(e))return null;return}}function Io(n){return(r)=>{let e=n(r);if(!e)return;let o=(Array.isArray(e)?e:[e]).map((a)=>{if(a.startsWith("/**"))return a;if(a.startsWith("/*"))return a;return`/** ${a} */`});return{...r,leadingComments:[...r.leadingComments||[],...o]}}}function Lo(n){return(r)=>{if(!r.typeAnnotation)return;let e=n(r.typeAnnotation,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`:[ ]*${f(r.typeAnnotation)}`),`: ${e}`);return{...r,typeAnnotation:e,text:t}}}function Fo(n){return we("function",(r)=>{if(!r.returnType)return;let e=n(r.returnType,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`\\):[ ]*${f(r.returnType)}`),`): ${e}`);return{...r,returnType:e,text:t}})}function No(n){return we(["function","class"],(r)=>{if(!r.parameters)return;let e=n(r.parameters,r);if(e===null)return null;if(e===void 0)return;let t=e.map((a)=>{let i="";if(a.rest)i+="...";if(i+=a.name,a.optional)i+="?";if(a.type)i+=`: ${a.type}`;if(a.defaultValue)i+=` = ${a.defaultValue}`;return i}).join(", "),o=r.text.replace(/\([^)]*\)/,`(${t})`);return{...r,parameters:e,text:o}})}function xi(n,r){return(e)=>{if(r&&!r(e))return;if(e.modifiers?.includes(n))return;let t=[...e.modifiers||[],n],o=e.text;if(!o.includes(n)){let a=["function","class","interface","type","enum","const","let","var"];for(let i of a){let s=o.indexOf(i);if(s>=0){o=`${o.slice(0,s)}${n} ${o.slice(s)}`;break}}}return{...e,modifiers:t,text:o}}}var Ci=we(["interface","type"],(n)=>{let r=n.text.replace(/(\n\s*)(\w+)(\??:\s)/g,"$1readonly $2$3");if(r===n.text)return;return{...n,text:r}}),Bo=we(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)\?:/g,"$1:");if(r===n.text)return;return{...n,text:r}}),Wo=we(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)(?<!\?):/g,"$1?:");if(r===n.text)return;return{...n,text:r}});function jo(n){let r=new RegExp(`@(${n.join("|")})\\b[^@]*`,"g");return(e)=>{if(!e.leadingComments?.length)return;let t=e.leadingComments.map((a)=>a.replace(r,"").replace(/\n\s*\*\s*\n/g,`
|
|
3
|
+
`));if(!t.some((a,i)=>a!==e.leadingComments[i]))return;return{...e,leadingComments:t}}}function _o(n,r){return(e)=>{if(r&&!r(e))return;if(!e.typeAnnotation)return;let t=`${n}<${e.typeAnnotation}>`,o=e.text.replace(e.typeAnnotation,t);return{...e,typeAnnotation:t,text:o}}}var Go=Ye({name:"readonly",version:"1.0.0",description:"Makes all interface properties readonly",transform:Ci}),Vo=Ye({name:"strip-private",version:"1.0.0",description:"Strips @internal, @private, and @hidden declarations",transform:wi((n)=>{if(!n.leadingComments)return!1;return n.leadingComments.some((r)=>/@(internal|private|hidden)\b/.test(r))})}),Uo=Ye({name:"declare",version:"1.0.0",description:"Adds declare keyword to all declarations",transform:xi("declare",(n)=>n.kind!=="import")});function zo(n){return Ye({name:`namespace-prefix-${n}`,version:"1.0.0",description:`Prefixes exported declarations with ${n}`,transform:bi(`${n}_`,(r)=>r.isExported&&r.kind!=="import")})}function f(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}
|
|
4
|
+
export{gi,hi,Tn,Po,yi,Do,we,Ro,Ye,Mo,bi,Oo,wi,Io,Lo,Fo,No,xi,Ci,Bo,Wo,jo,_o,Go,Vo,Uo,zo};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-z6mpxpxt.js";import{readFile as D}from"fs/promises";import{dirname as x,relative as g,resolve as C}from"path";async function Cr(s,i={}){let e=new Map,n=i.rootDir||process.cwd(),t=[];for(let o of s){if(i.ignore?.some((p)=>M(o,p)))continue;if(!i.includeNodeModules&&o.includes("node_modules"))continue;t.push(o)}let c=await Promise.all(t.map((o)=>b(o,n)));for(let o=0;o<t.length;o++){let p=c[o];if(p)e.set(t[o],p)}for(let[o,p]of e)for(let a of p.dependencies){let d=e.get(a);if(d)d.dependents.add(o)}return e}async function b(s,i){try{let e=await D(s,"utf-8"),n={path:s,exports:new Set,imports:new Map,dependencies:new Set,dependents:new Set};for(let t of r(e,s,!1)){if(t.isExported&&t.name)n.exports.add(t.isTypeOnly||t.kind==="type"||t.kind==="interface"?"type":t.name);if(!t.source)continue;let c=w(t.source,s,i);if(!c)continue;if(n.dependencies.add(c),t.kind==="import")for(let o of t.specifiers??[])n.imports.set(t.isTypeOnly||o.isType?`type ${o.alias??o.name}`:o.alias??o.name,c)}return n}catch{return null}}function w(s,i,e){if(!s.startsWith(".")&&!s.startsWith("/"))return null;let n=x(i),t=C(n,s);if(t.includes("node_modules"))return null;if(t.endsWith(".ts")||t.endsWith(".tsx"))return t.replace(/\.tsx?$/,".ts");return`${t}.ts`}function M(s,i){let e=i.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(e).test(s)}function vr(s,i={}){let e=[],n=new Set,t=new Set,c=[],o=new Map,p=i.maxDepth||100;function a(d,y){if(y>p)return;if(t.has(d)){let u=o.get(d)??c.indexOf(d),l=c.slice(u);l.push(d);let h=S(l,s),f=z(l,s);if(!i.typesOnly||f)e.push({chain:l,symbols:h,severity:f?"error":"warning",reason:f?"Type-level circular dependency can cause compilation issues":"Value-level circular dependency may cause runtime issues"});return}if(n.has(d))return;let m=s.get(d);if(!m)return;t.add(d),o.set(d,c.length),c.push(d);for(let u of m.dependencies)a(u,y+1);t.delete(d),c.pop(),o.delete(d),n.add(d)}for(let d of s.keys())if(!n.has(d))a(d,0);return N(e)}function S(s,i){let e=[];for(let n=0;n<s.length-1;n++){let t=i.get(s[n]),c=s[n+1];if(t){for(let[o,p]of t.imports)if(p===c)e.push(o)}}return[...new Set(e)]}function z(s,i){return s.some((e)=>e.endsWith(".d.ts")||i.get(e)?.exports.has("type")||[...i.get(e)?.imports.keys()||[]].some((n)=>n.startsWith("type ")||n==="type"))}function N(s){let i=new Set,e=[];for(let n of s){let t=v(n.chain),c=t.join(" -> ");if(!i.has(c))i.add(c),e.push({...n,chain:t})}return e}function v(s){if(s.length<=1)return s;let i=s.slice(0,-1),e=i;for(let n=1;n<i.length;n++){let t=[...i.slice(n),...i.slice(0,n)];if(t.join("")<e.join(""))e=t}return[...e,e[0]]}async function ds(s,i={}){let e=Date.now(),n=await Cr(s,i),t=vr(n,i);return{hasCircular:t.length>0,cycles:t,graph:n,filesAnalyzed:s,durationMs:Date.now()-e}}function ps(s,i){let e=[];if(!s.hasCircular)return e.push(`\u2713 No circular dependencies found (${s.filesAnalyzed.length} files analyzed in ${s.durationMs}ms)`),e.join(`
|
|
3
3
|
`);e.push(`\u2717 Found ${s.cycles.length} circular dependency chain(s)`),e.push("");for(let n of s.cycles){let t=n.severity==="error"?"\uD83D\uDD34":"\uD83D\uDFE1";e.push(`${t} ${n.severity.toUpperCase()}: Circular dependency`);let c=n.chain.map((o)=>i?g(i,o):o);if(e.push(` ${c.join(" \u2192 ")}`),n.symbols.length>0)e.push(` Symbols: ${n.symbols.join(", ")}`);e.push(` ${n.reason}`),e.push("")}return e.push(`Analyzed ${s.filesAnalyzed.length} files in ${s.durationMs}ms`),e.join(`
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function
|
|
6
|
-
export{
|
|
4
|
+
`)}function ms(s){let i=0,e={file:"",count:0},n={file:"",count:0},t=[];for(let[c,o]of s){let p=o.dependencies.size;if(i+=p,p>e.count)e={file:c,count:p};if(p===0&&o.dependents.size===0)t.push(c);if(o.dependents.size>n.count)n={file:c,count:o.dependents.size}}return{totalFiles:s.size,totalDependencies:i,avgDependencies:s.size>0?i/s.size:0,maxDependencies:e,isolatedFiles:t,mostDepended:n}}function gs(s,i){let e=new Set,n=[s];while(n.length>0){let t=n.shift(),c=i.get(t);if(c){for(let o of c.dependents)if(!e.has(o))e.add(o),n.push(o)}}return e}function hs(s,i){let e=new Set,n=[s];while(n.length>0){let t=n.shift(),c=i.get(t);if(c){for(let o of c.dependencies)if(!e.has(o))e.add(o),n.push(o)}}return e}function ys(s,i){let e=["digraph dependencies {"," rankdir=LR;"," node [shape=box];",""];for(let[n,t]of s){let c=i?g(i,n):n,o=n.replace(/[^a-z0-9]/gi,"_");e.push(` ${o} [label="${c}"];`);for(let p of t.dependencies){let a=p.replace(/[^a-z0-9]/gi,"_");e.push(` ${o} -> ${a};`)}}return e.push("}"),e.join(`
|
|
5
|
+
`)}function bs(s,i){let e=[];for(let[n,t]of s){let c=i?g(i,n):n;e.push({id:n,path:c,exports:[...t.exports],imports:Object.fromEntries(t.imports),dependencies:[...t.dependencies],dependents:[...t.dependents]})}return JSON.stringify({nodes:e},null,2)}
|
|
6
|
+
export{Cr,vr,ds,ps,ms,gs,hs,ys,bs};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class
|
|
4
|
-
`)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function
|
|
5
|
-
`),i=e.line-1,o=[];if(s)o.push(`${s}:${e.line}:${e.column}`);else o.push(`Line ${e.line}, Column ${e.column}`);o.push(`Error: ${t}`),o.push("");let
|
|
6
|
-
`)}function ze(n,e,t){let s={file:e,message:"Unknown error",code:
|
|
7
|
-
`),i=n.location.line-1;if(i>=0&&i<r.length){let o=Math.max(0,i-1),
|
|
8
|
-
`)}function
|
|
2
|
+
var ge={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class v extends Error{code;context;constructor(n,e="UNKNOWN_ERROR",t){super(n);if(this.name="DtsxError",this.code=e,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let n=`${this.name} [${this.code}]: ${this.message}`;if(this.context)n+=`
|
|
3
|
+
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class wn extends v{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class ri extends v{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class ii extends v{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class xn extends v{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Cn extends v{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class si extends v{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function fo(n){return n instanceof v}function po(n){return n instanceof wn}function mo(n){return n instanceof xn}function go(n){return n instanceof Cn}function ho(n,e="UNKNOWN_ERROR",t){if(n instanceof v)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new v(s,e);if(n instanceof Error)r.cause=n;return r}function yo(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
|
|
4
|
+
`)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function bo(n,e,t,s){let r=n.split(`
|
|
5
|
+
`),i=e.line-1,o=[];if(s)o.push(`${s}:${e.line}:${e.column}`);else o.push(`Line ${e.line}, Column ${e.column}`);o.push(`Error: ${t}`),o.push("");let E=Math.max(0,i-1),c=Math.min(r.length-1,i+1);for(let a=E;a<=c;a++){let R=(a+1).toString().padStart(4," "),u=a===i?">":" ";if(o.push(`${u} ${R} | ${r[a]}`),a===i){let l=" ".repeat(8+e.column-1);o.push(`${l}^`)}}return o.join(`
|
|
6
|
+
`)}function ze(n,e,t){let s={file:e,message:"Unknown error",code:ge.UNKNOWN_ERROR};if(n instanceof Error){s.message=n.message,s.stack=n.stack;let r=n.message.match(/\((\d+),(\d+)\)/);if(r)s.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(n.message.includes("Cannot find")||n.message.includes("not found"))s.code=ge.FILE_NOT_FOUND,s.suggestion="Check that the file path is correct and the file exists.";else if(n.message.includes("syntax")||n.message.includes("Unexpected token"))s.code=ge.SYNTAX_ERROR,s.suggestion="Check for syntax errors in your TypeScript code.";else if(n.message.includes("type")&&n.message.includes("cannot"))s.code=ge.TYPE_INFERENCE_ERROR,s.suggestion="Add explicit type annotations to help with type inference.";else if(n.message.includes("parse")||n.message.includes("Parse"))s.code=ge.PARSE_ERROR,s.suggestion="The file contains invalid TypeScript syntax."}else if(typeof n==="string")s.message=n;return s}function bt(n,e){let t=[],s=n.file;if(n.location)s+=`:${n.location.line}:${n.location.column}`;if(n.code)s+=` [${n.code}]`;if(t.push(s),t.push(` Error: ${n.message}`),e&&n.location){t.push("");let r=e.split(`
|
|
7
|
+
`),i=n.location.line-1;if(i>=0&&i<r.length){let o=Math.max(0,i-1),E=Math.min(r.length-1,i+1);for(let c=o;c<=E;c++){let a=(c+1).toString().padStart(4," "),R=c===i?">":" ";if(t.push(` ${R} ${a} | ${r[c]}`),c===i&&n.location.column>0){let u=" ".repeat(10+n.location.column-1);t.push(` ${u}^`)}}}}if(n.suggestion)t.push(""),t.push(` Suggestion: ${n.suggestion}`);return t.join(`
|
|
8
|
+
`)}function wo(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
|
|
9
9
|
`)}
|
|
10
|
-
export{
|
|
10
|
+
export{ge,v,wn,ri,ii,xn,Cn,si,fo,po,mo,go,ho,yo,bo,ze,bt,wo};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ee}from"./chunk-ayyb1jpe.js";function M(n,t){let e=n.length,i=t.length,o=Array.from({length:e+1},()=>Array(i+1).fill(0));for(let s=1;s<=e;s++)for(let r=1;r<=i;r++)if(n[s-1]===t[r-1])o[s][r]=o[s-1][r-1]+1;else o[s][r]=Math.max(o[s-1][r],o[s][r-1]);return o}function S(n,t,e,i,o){let s=[];while(i>0||o>0)if(i>0&&o>0&&t[i-1]===e[o-1])s.unshift({op:"equal",oldIdx:i-1,newIdx:o-1,line:t[i-1]}),i--,o--;else if(o>0&&(i===0||n[i][o-1]>=n[i-1][o]))s.unshift({op:"add",newIdx:o-1,line:e[o-1]}),o--;else if(i>0)s.unshift({op:"remove",oldIdx:i-1,line:t[i-1]}),i--;return s}function k(n,t){let e=n;if(t.ignoreWhitespace)e=e.replace(/\s+/g," ").trim();return e}function ft(n,t,e,i={}){let{context:o=3,ignoreWhitespace:s=!1,ignoreBlankLines:r=!1}=i,f=n.split(`
|
|
3
3
|
`),p=t.split(`
|
|
4
|
-
`);if(f[f.length-1]==="")f.pop();if(p[p.length-1]==="")p.pop();let d=f.map((l)=>k(l,{ignoreWhitespace:s})),a=p.map((l)=>k(l,{ignoreWhitespace:s})),c=d,g=a,w=f.map((l,x)=>x),m=p.map((l,x)=>x);if(r)c=[],g=[],w=[],m=[],d.forEach((l,x)=>{if(l.trim())c.push(l),w.push(x)}),a.forEach((l,x)=>{if(l.trim())g.push(l),m.push(x)});let F=M(c,g),b=S(F,c,g,c.length,g.length),B=b.every((l)=>l.op==="equal"),D=0,u=0,h=0;for(let l of b)if(l.op==="add")D++;else if(l.op==="remove")u++;else h++;let y=C(b,f,p,w,m,o);return{filePath:e,identical:B,hunks:y,stats:{additions:D,deletions:u,unchanged:h},oldContent:n,newContent:t}}function C(n,t,e,i,o,s){let r=[],f=[];if(n.forEach((a,c)=>{if(a.op!=="equal")f.push(c)}),f.length===0)return r;let p=[],d=[f[0]];for(let a=1;a<f.length;a++)if(f[a]-f[a-1]<=s*2+1)d.push(f[a]);else p.push(d),d=[f[a]];p.push(d);for(let a of p){let c=Math.max(0,a[0]-s),g=Math.min(n.length-1,a[a.length-1]+s),w=n.slice(c,g+1),m=[],F=1,b=1,B=0,D=0;for(let u=0;u<c;u++){let h=n[u];if(h.op==="equal"||h.op==="remove")F++;if(h.op==="equal"||h.op==="add")b++}for(let u of w)if(u.op==="equal")m.push(` ${u.line}`),B++,D++;else if(u.op==="remove")m.push(`-${u.line}`),B++;else if(u.op==="add")m.push(`+${u.line}`),D++;r.push({operation:"equal",lines:m,oldStart:F,oldCount:B,newStart:b,newCount:D})}return r}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
export{
|
|
4
|
+
`);if(f[f.length-1]==="")f.pop();if(p[p.length-1]==="")p.pop();let d=f.map((l)=>k(l,{ignoreWhitespace:s})),a=p.map((l)=>k(l,{ignoreWhitespace:s})),c=d,g=a,w=f.map((l,x)=>x),m=p.map((l,x)=>x);if(r)c=[],g=[],w=[],m=[],d.forEach((l,x)=>{if(l.trim())c.push(l),w.push(x)}),a.forEach((l,x)=>{if(l.trim())g.push(l),m.push(x)});let F=M(c,g),b=S(F,c,g,c.length,g.length),B=b.every((l)=>l.op==="equal"),D=0,u=0,h=0;for(let l of b)if(l.op==="add")D++;else if(l.op==="remove")u++;else h++;let y=C(b,f,p,w,m,o);return{filePath:e,identical:B,hunks:y,stats:{additions:D,deletions:u,unchanged:h},oldContent:n,newContent:t}}function C(n,t,e,i,o,s){let r=[],f=[];if(n.forEach((a,c)=>{if(a.op!=="equal")f.push(c)}),f.length===0)return r;let p=[],d=[f[0]];for(let a=1;a<f.length;a++)if(f[a]-f[a-1]<=s*2+1)d.push(f[a]);else p.push(d),d=[f[a]];p.push(d);for(let a of p){let c=Math.max(0,a[0]-s),g=Math.min(n.length-1,a[a.length-1]+s),w=n.slice(c,g+1),m=[],F=1,b=1,B=0,D=0;for(let u=0;u<c;u++){let h=n[u];if(h.op==="equal"||h.op==="remove")F++;if(h.op==="equal"||h.op==="add")b++}for(let u of w)if(u.op==="equal")m.push(` ${u.line}`),B++,D++;else if(u.op==="remove")m.push(`-${u.line}`),B++;else if(u.op==="add")m.push(`+${u.line}`),D++;r.push({operation:"equal",lines:m,oldStart:F,oldCount:B,newStart:b,newCount:D})}return r}function qi(n){if(n.identical)return"";let t=[];t.push(`--- a/${n.filePath}`),t.push(`+++ b/${n.filePath}`);for(let e of n.hunks)t.push(`@@ -${e.oldStart},${e.oldCount} +${e.newStart},${e.newCount} @@`),t.push(...e.lines);return t.join(`
|
|
5
|
+
`)}function fr(n){if(n.identical)return`\x1B[32m\u2713 ${n.filePath} (unchanged)\x1B[0m`;let t=[],e=`+${n.stats.additions} -${n.stats.deletions}`;t.push(`\x1B[1m${n.filePath}\x1B[0m \x1B[90m(${e})\x1B[0m`),t.push("");for(let i of n.hunks){t.push(`\x1B[36m@@ -${i.oldStart},${i.oldCount} +${i.newStart},${i.newCount} @@\x1B[0m`);for(let o of i.lines)if(o.startsWith("+"))t.push(`\x1B[32m${o}\x1B[0m`);else if(o.startsWith("-"))t.push(`\x1B[31m${o}\x1B[0m`);else t.push(`\x1B[90m${o}\x1B[0m`);t.push("")}return t.join(`
|
|
6
|
+
`)}function Ji(n){if(n.identical)return`${n.filePath}: unchanged`;return`${n.filePath}: +${n.stats.additions} -${n.stats.deletions} lines`}async function dr(n,t,e={}){let i="";try{let o=ee(n);if(await o.exists())i=await o.text();else if(!e.treatMissingAsEmpty)return ft("",t,n,e)}catch{if(!e.treatMissingAsEmpty)return ft("",t,n,e)}return ft(i,t,n,e)}async function Yi(n,t={}){let e=new Map;for(let[i,o]of n){let s=await dr(i,o,t);e.set(i,s)}return e}function pr(n){let t=0,e=0,i=0,o=0,s=0;for(let r of n.values())if(r.identical)e++;else if(t++,i+=r.stats.additions,o+=r.stats.deletions,!r.oldContent)s++;return{totalFiles:n.size,changedFiles:t,unchangedFiles:e,totalAdditions:i,totalDeletions:o,newFiles:s}}function mr(n){console.log(fr(n))}function Xi(n,t=!1){for(let i of n.values()){if(i.identical&&!t)continue;mr(i)}let e=pr(n);if(console.log(""),console.log(`\x1B[1mSummary:\x1B[0m ${e.totalFiles} files, ${e.changedFiles} changed, ${e.unchangedFiles} unchanged`),e.changedFiles>0)console.log(` \x1B[32m+${e.totalAdditions}\x1B[0m \x1B[31m-${e.totalDeletions}\x1B[0m lines`);if(e.newFiles>0)console.log(` ${e.newFiles} new files`)}
|
|
7
|
+
export{ft,qi,fr,Ji,dr,Yi,pr,mr,Xi};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t}from"./chunk-c7a07a26.js";import{Xn,Zn,Qn}from"./chunk-0m1wt3db.js";import{Oe,fe,Ie}from"./chunk-hvy1zvk6.js";import{ue}from"./chunk-a3apthex.js";var tt=20,et=!1,j=null;function ct(e){return Tt(e).replace(/\n[ \t]*(?=\n)/g,"")}function Tt(e){if(e.indexOf("/*")===-1)return e.trim();let r=[],c=0,s=0,l=e.length;while(s<l)if(e.charCodeAt(s)===47&&s+1<l&&e.charCodeAt(s+1)===42){if(s>c)r.push(e.substring(c,s));s+=2;while(s<l-1){if(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47){s+=2;break}s++}c=s}else s++;if(c<l)r.push(e.substring(c));return r.join("").trim()}function Ft(){et=!0,j=null}function Nt(){et=!1;let e=j;return j=null,e}function gt(e,i){if(i===2)return e===48||e===49;if(i===8)return e>=48&&e<=55;if(i===10)return e>=48&&e<=57;return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function G(e,i,r){let c=!1,s=!1;while(i.at<e.length){let l=e.charCodeAt(i.at);if(gt(l,r))c=!0,s=!1,i.at++;else if(l===95&&c&&!s&&i.at+1<e.length&>(e.charCodeAt(i.at+1),r))s=!0,i.at++;else break}return c&&!s}function kt(e,i){if(e.charCodeAt(i)!==48||i+1>=e.length)return 0;let r=e.charCodeAt(i+1)|32;return r===120?16:r===98?2:r===111?8:0}function z(e){if(e.length===0)return!1;let i={at:0};if(e.charCodeAt(0)===45)i.at++;if(i.at>=e.length)return!1;let r=kt(e,i.at);if(r)return i.at+=2,G(e,i,r)&&i.at===e.length;let c=G(e,i,10);if(e.charCodeAt(i.at)===46){i.at++;let l=G(e,i,10);if(!c&&!l)return!1}else if(!c)return!1;let s=e.charCodeAt(i.at);if(s===101||s===69){if(i.at++,e.charCodeAt(i.at)===43||e.charCodeAt(i.at)===45)i.at++;if(!G(e,i,10))return!1}return i.at===e.length}function ga(e){if(e.length<2||e.charCodeAt(e.length-1)!==110)return!1;let i=e.slice(0,-1),r={at:0};if(i.charCodeAt(0)===45)r.at++;if(r.at>=i.length)return!1;let c=kt(i,r.at);if(c)return r.at+=2,G(i,r,c)&&r.at===i.length;return G(i,r,10)&&r.at===i.length}function it(e){return e.includes("_")?e.replaceAll("_",""):e}function nt(e,i){let r=0,c=0;while((c=e.indexOf(i,c))!==-1)r++,c+=i.length;return r}function mt(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function Y(e){let i=e.trim();if(i.length<3||i.charCodeAt(0)!==60)return!1;if(i.startsWith("<>"))return i.endsWith("</>");let r=i.charCodeAt(1);if(!(r>=65&&r<=90||r>=97&&r<=122||r===36||r===95))return!1;let s=2;while(s<i.length&&mt(i.charCodeAt(s)))s++;let l=i.slice(1,s),f=i.charCodeAt(s);if(f>32&&f!==62&&f!==47)return!1;if(i.endsWith("/>"))return!0;let u=i.lastIndexOf("</");if(u===-1)return!1;let a=u+2;while(a<i.length&&mt(i.charCodeAt(a)))a++;return i.slice(u+2,a)===l&&i.charCodeAt(a)===62&&a===i.length-1}function Z(e){let i=e.length,r=!1;for(let f=1;f<i;f++)if(e.charCodeAt(f)<=32&&e.charCodeAt(f-1)<=32){r=!0;break}if(!r)for(let f=0;f<i;f++){let u=e.charCodeAt(f);if(u===10||u===13||u===9){r=!0;break}}if(!r)return e;let c=[],s=-1,l=!1;for(let f=0;f<i;f++)if(e.charCodeAt(f)<=32){if(!l){if(s>=0)c.push(e.substring(s,f));c.push(" "),l=!0,s=-1}}else{if(l||s<0)s=f;l=!1}if(s>=0)c.push(e.substring(s));return c.join("")}function n(e,i=!1,r=!1,c=0,s){if(!e||typeof e!=="string")return"unknown";if(c>=tt)return"unknown";let l=e.trim();if(Y(l))return"JSX.Element";if(l.startsWith("BigInt("))return"bigint";if(l.startsWith("Symbol.for("))return"symbol";if(l.includes(".raw`")||l.includes("String.raw`"))return"string";if(l.startsWith("`")&&l.endsWith("`")){if(!i||l.includes("${")||l.includes(`
|
|
3
|
+
`)||l.includes("\r"))return"string";return l}if(l.charCodeAt(0)===39||l.charCodeAt(0)===34){let u=Rt(l);if(u!==null){if(u==="string"||!i)return"string";return u}}if(z(l)){if(!i)return"number";return it(l)}if(l==="true"||l==="false"){if(!i)return"boolean";return l}if(l==="null")return"null";if(l==="undefined")return"undefined";if(l.startsWith("[")&&l.endsWith("]"))return De(l,i,c+1,s);if(l.startsWith("{")&&l.endsWith("}"))return st(l,i,c+1,s);if(l.startsWith("class ")||l.startsWith("class{"))return Yt(l);if(l.startsWith("new "))return Qt(l);if(l.endsWith("as const")){let u=l.slice(0,-8).trim();if(u.startsWith("[")&&u.endsWith("]")){let a=u.slice(1,-1).trim();if(!a)return"readonly []";let d=ce(a),C=[];for(let y=0;y<d.length;y++){let p=d[y].trim();if(p.startsWith("...")){let g=p.slice(3).trim();if(q(g))C.push(`...typeof ${g}`);else{let m=n(g,!0,!1,c+1,s);C.push(m.startsWith("readonly [")||m.endsWith("[]")?`...${m}`:"...unknown[]")}}else C.push(n(p,!0,!1,c+1,s))}return`readonly [${C.join(", ")}]`}return n(u,!0,r,c+1,s)}if(J(l)!==-1||l.startsWith("function")||l.startsWith("async"))return ot(l,r,c,i);if(l.startsWith("`")&&l.endsWith("`"))return Ht(l,i);if(l.startsWith("Promise."))return It(l,i,c,s);if(l.startsWith("await "))return"unknown";if(l.startsWith("typeof ")&&rt(l.slice(7)))return"string";if(l.startsWith("void ")&&rt(l.slice(5)))return"undefined";if(l.startsWith("delete ")&&rt(l.slice(7)))return"boolean";if(ga(l)){if(i)return it(l);return"bigint"}if(l.startsWith("Symbol(")||l==="Symbol.for")return"symbol";let f=Re(l);if(f!==null)return f;if(St(l))return"boolean";if(Vt(l))return"number";return"unknown"}function pt(e){let i=e.charCodeAt(0);if(i!==39&&i!==34)return!1;return K(e,0,i)===e.length}function Rt(e){if(pt(e))return e;let i=Dt(e);if(i.length<2)return null;let r=!1,c=!0,s="";for(let l of i){let f=l.trim();if(pt(f))r=!0,s+=Lt(f);else c=!1}if(c)return Kt(s);if(r)return"string";return null}function Dt(e){let i=[],r=0,c=0,s=0;while(s<e.length){let l=e.charCodeAt(s);if(l===39||l===34||l===96){s=K(e,s,l);continue}if(l===40||l===91||l===123)r++;else if(l===41||l===93||l===125)r--;else if(l===43&&r===0)i.push(e.slice(c,s)),c=s+1;s++}return i.push(e.slice(c)),i}function Lt(e){return e.slice(1,-1).replace(/\\(.)/g,(r,c)=>{if(c==="n")return`
|
|
4
|
+
`;if(c==="t")return"\t";if(c==="r")return"\r";if(c==="0")return"\x00";return c})}function Kt(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Vt(e){if(e==="")return!1;let i=!1,r=!1;for(let c=0;c<e.length;c++){let s=e.charCodeAt(c);if(s>=48&&s<=57){i=!0;continue}if(s===43||s===45||s===42||s===47||s===37){r=!0;continue}if(s===46||s===40||s===41||s<=32)continue;return!1}return i&&r}function St(e){let i=0;for(let r=0;r<e.length;r++){let c=e.charCodeAt(r);if(c===34||c===39||c===96){r=K(e,r,c)-1;continue}if(c===40||c===91||c===123){i++;continue}if(c===41||c===93||c===125){i--;continue}if(i!==0)continue;if(e.startsWith("===",r)||e.startsWith("!==",r)||e.startsWith("==",r)||e.startsWith("!=",r)||e.startsWith(">=",r)||e.startsWith("<=",r))return!0;if((c===62||c===60)&&e.charCodeAt(r-1)!==61&&e.charCodeAt(r+1)!==61)return!0}return!1}function Bt(e,i=!1,r=0,c){return n(e,i,!0,r,c)}function I(e,i=!1,r="",c,s){let l=lt(r,c),f=[],u=!1,a=0;while(a<e.length){let C=e.charCodeAt(a);if(C===34||C===39||C===96){a=K(e,a,C);continue}if(C===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(C===47&&e.charCodeAt(a+1)===42){let p=e.indexOf("*/",a+2);a=p===-1?e.length:p+2;continue}if(e.startsWith("function",a)&&H(e,a,8)||e.startsWith("class",a)&&H(e,a,5)){let p=Xt(e,a);if(p!==-1){a=U(e,p);continue}}if(C===61&&e.charCodeAt(a+1)===62){let p=Pt(e,a+2);if(e.charCodeAt(p)===123){a=U(e,p);continue}}if(e.startsWith("return",a)&&(a===0||!R(e.charCodeAt(a-1)))&&!R(e.charCodeAt(a+6))){a+=6;let p=!1;while(a<e.length&&e.charCodeAt(a)<=32){let W=e.charCodeAt(a);if(W===10||W===13)p=!0;a++}if(p||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){u=!0;continue}let g=a,m=0,A=0,h=0;while(a<e.length){let W=e.charCodeAt(a);if(W===34||W===39||W===96){a=K(e,a,W);continue}if(W===47&&e.charCodeAt(a+1)===47){if(m===0&&A===0&&h===0)break;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(W===47&&e.charCodeAt(a+1)===42){let x=e.indexOf("*/",a+2);a=x===-1?e.length:x+2;continue}if(W===40)m++;else if(W===41)m--;else if(W===91)A++;else if(W===93)A--;else if(W===123)h++;else if(W===125){if(h===0&&m===0&&A===0)break;h--}else if(W===59&&m===0&&A===0&&h===0)break;else if((W===10||W===13)&&m===0&&A===0&&h===0){let x=a+1;while(x<e.length&&e.charCodeAt(x)<=32)x++;if(e.startsWith("return",x)&&!R(e.charCodeAt(x+6)))break}a++}let w=e.slice(g,a).trim(),b=ct(F(w,l,c,s,g));if(!f.includes(b))f.push(b);continue}a++}if(u&&!f.includes("undefined"))f.push("undefined");let d=f.includes("unknown")?"unknown":f.length===0?"void":Ot(f);return i&&!d.startsWith("Promise<")?`Promise<${d}>`:d}function lt(e,i){let r=new Map,c=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,s=t(c),l=0,f=0,u=[];for(let a of s){let d=c.slice(a.start,a.end);if(d===","&&f===0)u.push(c.slice(l,a.start)),l=a.end;if(["(","[","{","<"].includes(d))f++;else if([")","]","}"].includes(d)||d===">"&&c[a.start-1]!=="=")f--}u.push(c.slice(l));for(let a of u){let d=t(a),C=-1,y=-1,p=0;for(let h of d){let w=a.slice(h.start,h.end);if(p===0&&w===":"&&C===-1)C=h.start;if(p===0&&w==="="&&a[h.end]!==">"){y=h.start;break}if(["(","[","{","<"].includes(w))p++;else if([")","]","}"].includes(w)||w===">"&&a[h.start-1]!=="=")p--}let g=a.slice(0,C!==-1?C:y!==-1?y:void 0).trim().replace(/^\.\.\./,"").replace(/\?$/,""),m=C===-1&&y!==-1&&!a.trim().startsWith("...")?fe(g,a.slice(y+1)):null;if(m){for(let h of m)r.set(h.alias,i?.(h.value)??n(h.value,!1));continue}if(!Q(g))continue;let A=C!==-1?a.slice(C+1,y!==-1?y:void 0).trim():"";if(!A&&y!==-1){let h=a.slice(y+1).trim();A=i?.(h)??n(h,!1)}if(A){if(y===-1&&a.slice(0,C).trim().endsWith("?"))A=`(${A}) | undefined`;r.set(g,A)}}return r}var Ct={string:{at:"string | undefined",charAt:"string",charCodeAt:"number",codePointAt:"number | undefined",concat:"string",endsWith:"boolean",includes:"boolean",indexOf:"number",lastIndexOf:"number",localeCompare:"number",normalize:"string",padEnd:"string",padStart:"string",repeat:"string",replace:"string",replaceAll:"string",search:"number",slice:"string",split:"string[]",startsWith:"boolean",substring:"string",toLocaleLowerCase:"string",toLocaleUpperCase:"string",toLowerCase:"string",toString:"string",toUpperCase:"string",trim:"string",trimEnd:"string",trimStart:"string",valueOf:"string"},number:{toExponential:"string",toFixed:"string",toLocaleString:"string",toPrecision:"string",toString:"string",valueOf:"number"},bigint:{toLocaleString:"string",toString:"string",valueOf:"bigint"},boolean:{toString:"string",valueOf:"boolean"}};function ha(e,i){let r=Object.hasOwn(Ct,e)?Ct[e]:void 0;return r&&Object.hasOwn(r,i)?r[i]:void 0}function L(e){return e.includes(`
|
|
5
|
+
`)?e.replaceAll(`
|
|
6
|
+
`,`
|
|
7
|
+
`):e}function qt(e,i){if(e=e.trim(),!e.startsWith("{")||!e.endsWith("}"))return;let r=e.slice(1,-1),c=t(r),s=0,l=0;for(let f=0;f<=c.length;f++){let u=c[f],a=u?r.slice(u.start,u.end):";";if(l===0&&(a===";"||a===",")){let d=r.slice(s,u?.start).trim(),C=d.indexOf(":");if(C!==-1&&d.slice(0,C).trim()===i)return d.slice(C+1).trim();s=u?.end??r.length}if(["(","[","{","<"].includes(a))l++;else if([")","]","}"].includes(a)||a===">"&&u&&r[u.start-1]!=="=")l--}return}function F(e,i,r,c,s=0,l=0){if(l>=tt)return"unknown";let f=e.trim();while(ht(f))f=f.slice(1,-1).trim();let u=r?.(f);if(u)return u;if(Y(f))return"JSX.Element";if(f.startsWith("await ")){let h=F(f.slice(6),i,r,c,s,l+1);return h.startsWith("Promise<")&&h.endsWith(">")?h.slice(8,-1):h}if(i.has(f))return i.get(f);let a=/^([\w$]+)\.([\w$]+)$/.exec(f);if(a){let h=i.get(a[1]),w=h&&qt(h,a[2]);if(w)return w}if(f.startsWith("!"))return"boolean";if(f.startsWith("fetch("))return"Promise<Response>";if(Jt(f))return n(f,!1);let d=zt(f);if(d){let h=F(d.whenTrue,i,r,c,s,l+1),w=F(d.whenFalse,i,r,c,s,l+1);return h===w?h:Ot([h,w])}let C=Gt(f);if(C&&c)return c(C,s);if(St(f))return"boolean";let y=0;for(let h=f.length-1;h>=0;h--){let w=f.charCodeAt(h);if(w===41||w===93||w===125)y++;else if(w===40||w===91||w===123)y--;else if(y===0&&(w===43||w===45||w===42||w===47||w===37)){let b=F(f.slice(0,h),i,r,c,s,l+1),W=F(f.slice(h+1),i,r,c,s,l+1);if(w===43&&(b==="string"||W==="string"))return"string";if(b==="number"&&W==="number")return"number";break}}let p=f.startsWith("{")&&f.endsWith("}")?st(f,!1,l+1,void 0,(h)=>F(h,i,r,c,s,l+1)):n(f,!1),g=t(p),m="",A=0;for(let h=0;h<g.length;h++){let w=g[h];if(w.kind!=="word"||p.slice(w.start,w.end)!=="typeof")continue;let b=g[h+1];if(!b||b.kind!=="word")continue;let W=i.get(p.slice(b.start,b.end)),x=W,P=!W,T=w.start,k=b.end,D=h,V=[];h++;while(g[h+1]&&p.slice(g[h+1].start,g[h+1].end)==="."&&g[h+2]?.kind==="word"){let B=g[h+2];if(V.push(p.slice(B.start,B.end)),!P)W=`(${W})["${p.slice(B.start,B.end)}"]`;k=B.end,h+=2}let S=D>=2&&p.slice(g[D-2].start,g[D-2].end)==="ReturnType"&&p.slice(g[D-1].start,g[D-1].end)==="<"&&g[h+1]&&p.slice(g[h+1].start,g[h+1].end)===">",E=x&&S&&V.length===1?ha(x.trim(),V[0]):void 0;if(E){T=g[D-2].start,k=g[++h].end;let B=T===0&&k===p.length;m+=p.slice(A,T)+(B||!E.includes("|")?E:`(${E})`),A=k;continue}if(P&&S)T=g[D-2].start,k=g[++h].end;m+=p.slice(A,T)+(W??"unknown"),A=k}return m+p.slice(A)}function Gt(e){let i=t(e),r=0,c=-1;for(let l=0;l<i.length;l++){let f=i[l],u=e.slice(f.start,f.end);if(f.kind!=="punctuation"&&f.kind!=="word")continue;if(["(","[","{"].includes(u))r++;else if([")","]","}"].includes(u))r--;else if(!r&&u==="as"&&l>0&&e.slice(i[l-1].start,i[l-1].end)!==".")c=l}if(c===-1||c+1===i.length)return;let s=e.slice(i[c].end).trim();if(s==="const")return;r=0;for(let l of i.slice(c+1)){if(l.kind!=="punctuation")continue;let f=e.slice(l.start,l.end);if(["(","[","{","<"].includes(f))r++;else if([")","]","}",">"].includes(f))r--;else if(!r&&["+","-","*","/","%","=","!",";"].includes(f))return}return s}function Ot(e){return e.map((i)=>e.length>1&&J(i)!==-1?`(${i})`:i).join(" | ")}function At(e){let i=0;while(i<e.length){let s=e.charCodeAt(i);if(s<=32)i++;else if(s===47&&e.charCodeAt(i+1)===47){i+=2;while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++}else if(s===47&&e.charCodeAt(i+1)===42){let l=e.indexOf("*/",i+2);i=l===-1?e.length:l+2}else break}let r=i,c=i;while(c<e.length){let s=e.charCodeAt(c);if(s===34||s===39||s===96){c=K(e,c,s),r=c;continue}if(s===92){c=Math.min(c+2,e.length),r=c;continue}if(s===47&&e.charCodeAt(c+1)===47){while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++;continue}if(s===47&&e.charCodeAt(c+1)===42){let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+2;continue}if(c++,s>32)r=c}return e.slice(i,r)}function rt(e){let i=0;for(let r=0;r<e.length;r++){let c=e[r];if(c==="'"||c==='"'||c==="`"){let s=r+1;while(s<e.length&&e[s]!==c){if(e[s]==="\\")s++;s++}r=s;continue}if(c==="("||c==="["||c==="{")i++;else if(c===")"||c==="]"||c==="}")i--;else if(i!==0)continue;else if(c==="?"){if(e[r+1]!==".")return!1}else if("=!<>&|+-*/%,:".includes(c))return!1;else if(c===" "||c==="\t"||c===`
|
|
8
|
+
`||c==="\r"){let s=e.slice(r).trimStart();if(s&&s[0]!=="."&&s[0]!=="?"&&s[0]!=="("&&s[0]!=="[")return!1}}return!0}function Jt(e){if(e.startsWith("function")&&H(e,0,8))return!0;let i=J(e);if(i===-1)return!1;let r=e.slice(0,i).trim();if(r.startsWith("async")&&H(r,0,5))r=r.slice(5).trim();if(r.startsWith("<")){let s=o(r,0,"<",">");if(s===-1)return!1;r=r.slice(s+1).trim()}if(r.startsWith("(")){let s=o(r,0,"(",")");if(s===-1)return!1;let l=r.slice(s+1).trim();if(l&&!l.startsWith(":"))return!1}let c=ut(r);return ht(c.params)||Q(c.params)}function ht(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let i=0;for(let r=0;r<e.length;r++){let c=e.charCodeAt(r);if(c===40)i++;else if(c===41&&--i===0)return r===e.length-1}return!1}function zt(e){let i=0,r=-1;for(let c=0;c<e.length;c++){let s=e.charCodeAt(c);if(s===34||s===39||s===96){c=K(e,c,s)-1;continue}if(s===47&&(e.charCodeAt(c+1)===47||e.charCodeAt(c+1)===42)){if(e.charCodeAt(c+1)===47)while(c+1<e.length&&e.charCodeAt(c+1)!==10&&e.charCodeAt(c+1)!==13)c++;else{let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+1}continue}if(s===40||s===91||s===123)i++;else if(s===41||s===93||s===125)i--;else if(s===63&&i===0&&e.charCodeAt(c+1)!==63)r=c;else if(s===58&&i===0&&r!==-1)return{whenTrue:At(e.slice(r+1,c)),whenFalse:At(e.slice(c+1))}}return null}function H(e,i,r){return(i===0||!R(e.charCodeAt(i-1)))&&!R(e.charCodeAt(i+r))}function Pt(e,i){let r=i;while(r<e.length){if(e.charCodeAt(r)<=32){r++;continue}if(e.startsWith("//",r)){while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;continue}if(e.startsWith("/*",r)){let c=e.indexOf("*/",r+2);r=c<0?e.length:c+2;continue}break}return r}function Xt(e,i){let r=0,c=0,s=0,l=!1,f=!1;for(let u=i;u<e.length;u++){if(u=Pt(e,u),u>=e.length)break;let a=e.charCodeAt(u);if(a===34||a===39||a===96){u=K(e,u,a)-1,f=!1;continue}if(R(a)||a>=128){let d=u;while(u+1<e.length&&(R(e.charCodeAt(u+1))||e.charCodeAt(u+1)>=128))u++;f=l&&["keyof","typeof","readonly","unique","new","abstract","infer","extends"].includes(e.slice(d,u+1));continue}if(a===61&&e.charCodeAt(u+1)===62){u++,f=l;continue}if(a===40)r++;else if(a===41)r--,f=!1;else if(a===91)c++;else if(a===93)c--,f=!1;else if(a===60&&r===0&&c===0)s++;else if(a===62&&s>0&&r===0&&c===0)s--,f=!1;else if(a===123)if(r||c||s||l&&f)u=U(e,u)-1,f=!1;else return u;else if(r===0&&c===0&&s===0){if(a===58)l=!0,f=!0;else if(l&&[124,38,63].includes(a))f=!0;else if(a===59)return-1}}return-1}function U(e,i){let r=1,c=i+1;while(c<e.length&&r>0){let s=e.charCodeAt(c);if(s===34||s===39||s===96){c=K(e,c,s);continue}if(s===47&&e.charCodeAt(c+1)===47){c+=2;while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++;continue}if(s===47&&e.charCodeAt(c+1)===42){let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+2;continue}if(s===123)r++;else if(s===125)r--;c++}return c}function K(e,i,r){let c=i+1;while(c<e.length){let s=e.charCodeAt(c);if(s===92){c+=2;continue}if(r===96&&s===36&&e.charCodeAt(c+1)===123){c=U(e,c+1);continue}if(c++,s===r)break}return c}function Ht(e,i){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!i||e.includes("${")||e.includes(`
|
|
9
|
+
`)||e.includes("\r"))return"string";return e}function Qt(e){let i=4;while(i<e.length&&e.charCodeAt(i)<=32)i++;let r=i,c=e.charCodeAt(i);if(c<65||c>90)return"unknown";while(i<e.length&&(R(e.charCodeAt(i))||e.charCodeAt(i)===46))i++;if(i===r)return"unknown";let s=e.slice(r,i);{let l=e.slice(i),f=l;if(l.startsWith("<")){let a=0,d=-1;for(let C=0;C<l.length;C++)if(l[C]==="<")a++;else if(l[C]===">"){if(a--,a===0){d=C;break}}if(d!==-1){let C=l.slice(0,d+1);f=l.slice(d+1);let y=f.indexOf("(");if(y!==-1){let p=0,g=-1;for(let m=y;m<f.length;m++)if(f[m]==="(")p++;else if(f[m]===")"){if(p--,p===0){g=m;break}}if(g!==-1){if(f.slice(g+1).trimStart().startsWith("."))return"unknown"}}return`${s}${C}`}}let u=f.indexOf("(");if(u!==-1){let a=0,d=-1;for(let C=u;C<f.length;C++)if(f[C]==="(")a++;else if(f[C]===")"){if(a--,a===0){d=C;break}}if(d!==-1){if(f.slice(d+1).trimStart().startsWith("."))return"unknown"}}switch(s){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return s}}return"unknown"}function Yt(e){return"{ new (...args: any[]): any }"}function It(e,i,r=0,c){if(e.startsWith("Promise.resolve(")){let l=e.indexOf(")",16);if(l!==-1){let f=e.slice(16,l).trim();if(f)return`Promise<${n(f,i,!1,r+1,c)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let s=e.indexOf("[",12),l=e.lastIndexOf("]");if(s!==-1&&l>s){let f=e.slice(s+1,l).trim(),u=ce(f),a=[];for(let d=0;d<u.length;d++){let C=u[d].trim();if(C.startsWith("Promise.resolve(")){let y=It(C,i,r+1,c),p=y.indexOf("<"),g=y.lastIndexOf(">");a.push(p!==-1&&g>p?y.slice(p+1,g):"unknown")}else a.push(n(C,i,!1,r+1,c))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function De(e,i,r=0,c){let s=e.slice(1,-1).trim();if(!s)return"never[]";if(r>=tt)return"unknown[]";let l=ce(s),f=!1;for(let g=0;g<l.length;g++){let m=l[g],A=m.length;while(A>0&&m.charCodeAt(A-1)<=32)A--;if(A>=8&&m.slice(A-8,A)==="as const"){f=!0;break}}if(f){let g=[];for(let m=0;m<l.length;m++){let A=l[m].trim();if(A.endsWith("as const")){let h=A.slice(0,-8).trim();if(h.startsWith("[")&&h.endsWith("]")){let w=h.slice(1,-1).trim(),b=ce(w),W=[];for(let x=0;x<b.length;x++)W.push(n(b[x].trim(),!0,!1,r+1,c));g.push(`readonly [${W.join(", ")}]`)}else g.push(n(h,!0,!1,r+1,c))}else if(A.startsWith("[")&&A.endsWith("]"))g.push(De(A,!0,r+1,c));else g.push(n(A,!0,!1,r+1,c))}return`readonly [
|
|
10
|
+
${g.join(` |
|
|
11
|
+
`)}
|
|
12
|
+
]`}let u=et&&!i,a=[],d=[];for(let g of l){let m=g.trim(),A=j;if(j=null,m.startsWith("...")){let h=m.slice(3).trim(),w=n(h,!1,!1,r+1,c);if(w.endsWith("[]"))a.push(w.slice(0,-2));else if(w.startsWith("readonly [")&&w.endsWith("]"))a.push(w.slice(10,-1));else if(q(h))a.push(`(typeof ${h})[number]`);else a.push("unknown")}else if(m.startsWith("[")&&m.endsWith("]"))a.push(De(m,i,r+1,c));else a.push(Bt(m,i,r+1,c));if(u)d.push(j);j=A}if(u)if(ft(e))j=Z(e);else{let g=[];for(let m=0;m<l.length;m++){let A=l[m].trim();if(A.endsWith("as const"))continue;if(v(A)||A==="null"||A==="undefined")g.push(A);else if(A.startsWith("[")&&ft(A))g.push(Z(A));else if(A.startsWith("{")){if(d[m])g.push(d[m])}else{let h=n(A,!1,!1,0,c);if(h!=="unknown")g.push(h)}}if(g.length>0)j=`[${g.join(", ")}]`}if(i)return`readonly [${a.join(", ")}]`;let C=new Set,y=[],p=!0;for(let g of a){if(!C.has(g))C.add(g),y.push(g);if(p){if(!(z(g)||g==="true"||g==="false"||g.charCodeAt(0)===34&&g.charCodeAt(g.length-1)===34||g.charCodeAt(0)===39&&g.charCodeAt(g.length-1)===39))p=!1}}if(p&&a.length<=10)return`readonly [${a.join(", ")}]`;if(y.length===1)return`${y[0]}[]`;return`(${y.join(" | ")})[]`}function ce(e){let i=[],r=0,c=!1,s=0,l=-1,f=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(c){if(a===92)u++;else if(a===s)c=!1;f=u+1;continue}if(a===47&&e.charCodeAt(u+1)===47){let d=e.indexOf(`
|
|
13
|
+
`,u+2);u=(d===-1?e.length:d)-1;continue}if(a===47&&e.charCodeAt(u+1)===42){let d=e.indexOf("*/",u+2);u=(d===-1?e.length:d+2)-1;continue}if(a===32||a===9||a===10||a===13)continue;if(a===44&&r===0){if(l!==-1)i.push(e.slice(l,f));l=-1;continue}if(a===34||a===39||a===96)c=!0,s=a;else if(a===91||a===123||a===40)r++;else if(a===93||a===125||a===41)r--;if(l===-1)l=u;f=u+1}if(l!==-1)i.push(e.slice(l,f));return i}function v(e){if(z(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function Et(e){return e==="number"||e==="string"||e==="boolean"}function Jn(e){let i=[],r=0;while(r<e.length){while(r<e.length&&e.charCodeAt(r)<=32)r++;if(e.startsWith("/*",r)){let c=e.indexOf("*/",r+2);if(c===-1)break;i.push(e.slice(r,c+2)),r=c+2}else if(e.startsWith("//",r)){let c=r;while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++;i.push(e.slice(r,c).trimEnd()),r=c}else break}return i}function Wt(e,i,r){let c=i.trim();if(!Et(r)||!v(c))return"";let s=(e??[]).map((f)=>f.trim()).filter((f)=>f.startsWith("/**")||f.startsWith("//")).join(`
|
|
14
|
+
`),l;if(s.includes("@defaultValue"))l=s;else{let f=`@defaultValue ${ue(c)}`;if(!s)l=`/** ${f} */`;else{let u=s.lastIndexOf("*/");if(u!==-1){let a=s.slice(0,u).trimEnd();if(a.startsWith("/** ")&&!a.includes(`
|
|
15
|
+
`))a=`/**
|
|
16
|
+
* ${a.slice(4)}`;l=`${a}
|
|
17
|
+
* ${f}
|
|
18
|
+
*/`}else l=`/**
|
|
19
|
+
* ${s.startsWith("// ")?s.slice(3):s.startsWith("//")?s.slice(2):s}
|
|
20
|
+
* ${f}
|
|
21
|
+
*/`}}return l.split(`
|
|
22
|
+
`).map((f)=>{let u=f.trim();if(!u)return"";return u.startsWith("*")?` ${u}`:` ${u}`}).join(`
|
|
23
|
+
`)+`
|
|
24
|
+
`}function ft(e){let i=!1,r=0,c=e.length;for(let s=0;s<c;s++){let l=e.charCodeAt(s);if(i){if(l===92){s++;continue}if(l===r)i=!1;continue}if(l===34||l===39||l===96){i=!0,r=l;continue}if(l===61&&s+1<c&&e.charCodeAt(s+1)===62)return!1;if(l===47&&(e.charCodeAt(s+1)===47||e.charCodeAt(s+1)===42))return!1;if(l>=97&&l<=122){let f=s;while(s<c&&(e.charCodeAt(s)>=97&&e.charCodeAt(s)<=122||e.charCodeAt(s)>=65&&e.charCodeAt(s)<=90||e.charCodeAt(s)>=48&&e.charCodeAt(s)<=57||e.charCodeAt(s)===95||e.charCodeAt(s)===36))s++;let u=e.slice(f,s);if(u==="new"||u==="async"||u==="await"||u==="function"||u==="yield"||u==="console"||u==="process")return!1;let a=s;while(a<c&&e.charCodeAt(a)<=32)a++;if(a<c&&e.charCodeAt(a)===40)return!1;s--}}return!0}function st(e,i,r=0,c,s){let l=e.slice(1,-1).trim();if(!l)return"{}";if(r>=tt)return"Record<string, unknown>";let f=vt(l),u=new Set(f.flatMap(([w])=>{let b=xt(at(w).key);return b?.kind==="get"?[b.name]:[]})),a=[],d=[],C=[],y=!1,p=et&&!i,g=[],m=0;for(let[w,b]of f){let{comments:W,key:x}=at(w),P=W?`${W}
|
|
25
|
+
`:"",T=xt(x);if(T&&Qn(T.name))continue;let k=x,D=!1;if(x==="..."){let O=b.trim(),N=q(O)?`typeof ${O}`:n(O,i,!1,r+1,c);if(N!=="unknown")d.push(N);if(p&&(q(O)||O.startsWith("{")))g.push(`...${Z(O)}`);continue}let V=j;j=null;let S,E=b.trim();if(E===x&&Q(E))S=(i?void 0:c?.mutableBindingTypes?.get(E))??`typeof ${E}`;else if(ne(E)){D=!0;let O=re(x);if(O){k=O.name;let N="";if(E.startsWith("async "))N="async ";if(E.charCodeAt(N.length)===42)N+="*";S=$t(O.name,N+O.typeParams+E.slice(N.length))}else S=$t(x,E)}else{if(S=s?.(b)??n(b,i,!1,r+1,c),S==="unknown"&&q(E))S=(i?void 0:c?.mutableBindingTypes?.get(E))??`typeof ${E}`;if(S.includes("=>")||S.includes("function")||S.includes("async"))S=yt(S)}let B=j;j=V;let Mt=k,M=b.trim(),X=Xn(k,c);if(!Zn(T?.name??k,c)&&!(T?.kind==="set"&&u.has(T.name)))C.push(T?ee(T.kind,S):S);if(X&&"index"in X)y=!0;else{if(X&&"name"in X)k=X.name;if(T){let O=te(T.kind,T.name,S);if(O){a.push(`${P}${L(O)}`);continue}}if(!i&&Et(S)&&v(M))a.push(`${P}/** @defaultValue ${ue(M)} */
|
|
26
|
+
${k}: ${L(S)}`);else a.push(`${P}${i?"readonly ":""}${k}: ${L(S)}`)}if(p){let O=Tt(Mt);if(M.endsWith("as const"));else if(v(M))g.push(`${O}: ${M}`);else if(M.startsWith("[")&&ft(M))g.push(`${O}: ${Z(M)}`);else if(M.startsWith("{")){if(B)g.push(`${O}: ${B}`)}else if(D)g.push(`${O}: ${ct(yt(S))}`),m++;else if(!M.startsWith("[")&&(M.includes("=>")||M.startsWith("function")||M.startsWith("async"))){let N=ot(M,!1,0,!0);g.push(`${O}: ${ct(N)}`),m++}}}if(p&&g.length>m){let w=r>0?(r-1)/2:0,b=`{ ${g.join(", ")} }`;if(b.length<=80)j=b;else{let W=" ".repeat((w+1)*2),x=" ".repeat(w*2);j=`{
|
|
27
|
+
${W}${g.join(`,
|
|
28
|
+
${W}`)}
|
|
29
|
+
${x}}`}}if(y&&d.length===0){let w=[...new Set(C)].map((b)=>b.includes("=>")||b.includes(" & ")?`(${b})`:b);a.unshift(`${i?"readonly ":""}[x: string]: ${L(w.join(" | "))}`)}let A=a.length>0?`{
|
|
30
|
+
${a.join(`;
|
|
31
|
+
`)}
|
|
32
|
+
}`:"{}";if(d.length===0)return A;let h=d[0];for(let w=1;w<d.length;w++)h=`Omit<${h}, keyof ${d[w]}> & ${d[w]}`;return a.length>0?`Omit<${h}, keyof ${A}> & ${A}`:h}function Q(e){if(!e)return!1;let i=e.charCodeAt(0);if(!(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127))return!1;for(let r=1;r<e.length;r++)if(!R(e.charCodeAt(r)))return!1;return!0}function q(e){let i=e.split(".");return i.length>0&&i.every(Q)}function Zt(e){let i=!1,r="";for(let c=0;c<e.length;c++){let s=e[c];if(i){if(s==="\\")c++;else if(s===r)i=!1;continue}if(s==='"'||s==="'"||s==="`"){i=!0,r=s;continue}if(s==="(")return c;if(s==="<"){let l=o(e,c,"<",">");if(l!==-1)c=l}}return-1}function Re(e){if(e.length<3||!e.endsWith(")"))return null;let i=Zt(e);if(i===-1||o(e,i,"(",")")!==e.length-1)return null;let r=e.slice(0,i).trim(),c=!1;if(r.endsWith("?."))c=!0,r=r.slice(0,-2).trim();let s=r,l=!1,f=r.indexOf("<");if(f!==-1){if(o(r,f,"<",">")!==r.length-1)return null;s=r.slice(0,f).trim(),l=!0}if(!q(s))return null;let u=e.slice(i+1,-1).trim(),a=J(u)!==-1||u.startsWith("function")||u.startsWith("async function"),d=q(u),C=!a&&u.endsWith(")")&&Re(u)!==null,y=s.indexOf(".");if(y!==-1){if(s.indexOf(".",y+1)!==-1)return null}else if(!l&&!c&&!a&&!d&&!C)return null;let p=`ReturnType<typeof ${r}>`;return c?`${p} | undefined`:p}function yt(e){let r=e.split(`
|
|
33
|
+
`).map((C)=>jt(C)).join(`
|
|
34
|
+
`),c=r.indexOf("async");if(c!==-1){let C=c>0?r.charCodeAt(c-1):32,y=c+5<r.length?r.charCodeAt(c+5):32;if(!R(C)&&!R(y))r=(r.slice(0,c)+r.slice(c+5)).trim()}let s=r.indexOf("(");if(s!==-1){let C=o(r,s,"(",")");if(C!==-1){let y=r.slice(s,C+1),p=le(y);r=r.slice(0,s)+p+r.slice(C+1)}}let l=r.length,f="",u=[],a=!1,d=!1;for(let C=0;C<l;C++){let y=r.charCodeAt(C);if(y===123||y===40)u.push(y);else if(y===125||y===41)u.pop();if(y<=32){if(a=!0,y===10||y===13)d=!0;continue}if(a&&f.length>0){let g=(u.length>0?u[u.length-1]:0)===123;if(d&&g){let m=f.charCodeAt(f.length-1),A=m===59||m===44||m===123||y===125,h=f.length>=2&&f.charCodeAt(f.length-1)===47&&f.charCodeAt(f.length-2)===42;if(!A&&!h)f+="; ";else f+=" "}else f+=" "}a=!1,d=!1,f+=r[C]}return f.trim()}function R(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function le(e){let i=e.trim(),r,c=!1;if(i.startsWith("(")&&i.endsWith(")"))r=i.slice(1,-1),c=!0;else r=i;let s=r.trim();if(!s)return c?"()":"";let l=!1;{let m=0;for(let A=0;A<s.length;A++){let h=s.charCodeAt(A);if(h===40||h===60||h===91||h===123)m++;else if(h===41||h===93||h===125||h===62&&s.charCodeAt(A-1)!==61)m--;else if(m===0&&h===61){let w=A>0?s.charCodeAt(A-1):0,b=A+1<s.length?s.charCodeAt(A+1):0;if(w!==61&&w!==33&&w!==60&&w!==62&&b!==61&&b!==62){l=!0;break}}}}if(!l)return i;let f=[],u=[],a=0,d=0,C=!1,y=0;for(let m=0;m<=s.length;m++){if(m===s.length){f.push(s.slice(a));break}let A=s.charCodeAt(m);if(C){if(A===92){m++;continue}if(A===y)C=!1;continue}if(A===47&&m+1<s.length){let h=s.charCodeAt(m+1);if(h===42){m+=2;while(m+1<s.length&&!(s.charCodeAt(m)===42&&s.charCodeAt(m+1)===47))m++;m++;continue}if(h===47){while(m<s.length&&s.charCodeAt(m)!==10)m++;continue}}if(A===39||A===34||A===96){C=!0,y=A;continue}if(A===40||A===60||A===91||A===123)d++;else if(A===41||A===93||A===125||A===62&&s.charCodeAt(m-1)!==61)d--;else if(A===44&&d===0){f.push(s.slice(a,m));let h=",",w=m+1;while(w<s.length&&s.charCodeAt(w)<=32)h+=s[w],w++;u.push(h),a=w}}let p=[];for(let m of f){let A=m.trim();if(!A){p.push(m);continue}if(A.startsWith("//"))continue;let h=jt(A),w=m.slice(0,m.length-m.trimStart().length);p.push(w+Ut(h))}let g=p[0]||"";for(let m=1;m<p.length;m++)g+=(u[m-1]||", ")+p[m];return Oe(c?`(${g})`:g)}function jt(e){let i=!1,r=0;for(let c=0;c<e.length-1;c++){let s=e.charCodeAt(c);if(i){if(s===92){c++;continue}if(s===r)i=!1;continue}if(s===39||s===34||s===96){i=!0,r=s;continue}if(s===47&&e.charCodeAt(c+1)===47)return e.slice(0,c).trimEnd()}return e}function Ut(e){if(e.startsWith("..."))return e;let i=-1,r=-1,c=0,s=!1,l=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(s){if(a===92){u++;continue}if(a===l)s=!1;continue}if(a===47&&u+1<e.length){let d=e.charCodeAt(u+1);if(d===42){u+=2;while(u+1<e.length&&!(e.charCodeAt(u)===42&&e.charCodeAt(u+1)===47))u++;u++;continue}if(d===47){while(u<e.length&&e.charCodeAt(u)!==10)u++;continue}}if(a===39||a===34||a===96){s=!0,l=a;continue}if(a===40||a===60||a===91||a===123)c++;else if(a===41||a===93||a===125||a===62&&e.charCodeAt(u-1)!==61)c--;else if(c===0){if(a===58&&i===-1)i=u;else if(a===61&&r===-1&&(u===0||e.charCodeAt(u-1)!==61)&&(u+1>=e.length||e.charCodeAt(u+1)!==61&&e.charCodeAt(u+1)!==62))r=u}}let f=r!==-1;if(i!==-1&&(r===-1||i<r)){let u=e.slice(0,i).trim(),a=r!==-1?e.slice(i+1,r).trim():e.slice(i+1).trim(),d=f&&!u.endsWith("?")?"?":"";return`${u}${d}: ${a}`}else if(r!==-1){let u=e.slice(0,r).trim(),a=fe(u,e.slice(r+1));if(a)return Ie(a,wt);let d=!u.endsWith("?")?"?":"";return`${u}${d}: ${wt(e.slice(r+1))}`}return e}function wt(e){let i=e.trim();if(i==="true"||i==="false")return"boolean";if(z(i))return"number";if(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))return"string";if(i.startsWith("["))return"unknown[]";if(i.startsWith("{"))return"Record<string, unknown>";return"unknown"}function _t(e){let i=0,r=e.length;while(i<r){while(i<r&&(e.charCodeAt(i)===32||e.charCodeAt(i)===9||e.charCodeAt(i)===10||e.charCodeAt(i)===13))i++;if(i+1<r&&e.charCodeAt(i)===47&&e.charCodeAt(i+1)===42){i+=2;while(i+1<r&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i+=2;continue}break}return i}function at(e){let i=[],r=0,c=e.length;while(r<c){while(r<c&&e.charCodeAt(r)<=32)r++;if(r+1>=c||e.charCodeAt(r)!==47||e.charCodeAt(r+1)!==42)break;let s=r;r+=2;while(r+1<c&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))r++;r=Math.min(r+2,c),i.push(e.slice(s,r).trim())}return{comments:i.join(`
|
|
35
|
+
`),key:e.slice(r).trim()}}function vt(e){let i=[],r="",c="",s=0,l=!1,f="",u=!0,a=!1,d=0,C=!1,y=!1,p=0,g=!1,m=!1;for(let A=0;A<e.length;A++){let h=e.charCodeAt(A),w=A>0?e.charCodeAt(A-1):0,b=A<e.length-1?e.charCodeAt(A+1):0;if(!l&&!a&&h===47&&b===47){r=r.replace(/[ \t]+$/,""),A+=2;while(A<e.length&&e.charCodeAt(A)!==10)A++;A--;continue}if(!l&&!a&&h===47&&b===42){a=!0,d=1,r+="/*",A++;continue}else if(a&&h===42&&b===47){if(d--,r+="*/",A++,d===0)a=!1;continue}else if(a&&h===47&&b===42){d++,r+="/*",A++;continue}let W=e[A];if(!l&&!a&&(h===34||h===39||h===96))l=!0,f=W,r+=W;else if(l&&W===f&&w!==92)l=!1,r+=W;else if(!l&&!a)if(h===40&&s===0&&u&&p===0){c=r.trim();let x=_t(c),P=x>0?c.slice(0,x):"",T=c.slice(x),k="";if(T.startsWith("async ")||T.startsWith("async\t")||T.startsWith(`async
|
|
36
|
+
`))T=T.slice(6).trimStart(),k="async ";if(T.startsWith("*"))T=T.slice(1).trimStart(),k+="*";c=P+T,r=k+W,u=!1,g=!0,m=!1,s=1}else if(h===123||h===91||h===40){if(s++,r+=W,m&&h===123)m=!1}else if(h===125||h===93||h===41){if(s--,r+=W,h===41&&s===0&&!u&&!g)C=!0;if(g){if(h===41&&s===0&&!m)m=!0;else if(h===125&&s===0)g=!1,m=!1}}else if(h===58&&s===0&&u&&p===0)c=r.trim(),r="",u=!1;else if(h===58&&s===0&&C)y=!0,r+=W;else if(h===60&&y)p++,r+=W;else if(h===60&&u&&s===0)p++,r+=W;else if(h===62&&p>0&&w!==61)p--,r+=W;else if(h===61&&b===62&&y&&p===0)y=!1,C=!1,r+=W;else if(h===44&&s===0&&p===0&&!m){if(c&&r.trim()){let x=r.trim();i.push([c,x])}else if(u&&r.trim())bt(i,r.trim());r="",c="",u=!0,C=!1,y=!1,p=0}else r+=W;else r+=W}if(c&&r.trim()){let A=r.trim();i.push([c,A])}else if(u&&r.trim())bt(i,r.trim());return i}function bt(e,i){let{comments:r,key:c}=at(i);if(Q(c))e.push([r?`${r}
|
|
37
|
+
${c}`:c,c]);else if(c.startsWith("...")&&c.length>3)e.push(["...",c.slice(3).trim()])}function xt(e){let i=e.trim();if(i.startsWith("get ")&&i.length>4){let r=i.slice(4).trim();if(r)return{kind:"get",name:r}}if(i.startsWith("set ")&&i.length>4){let r=i.slice(4).trim();if(r)return{kind:"set",name:r}}return null}function te(e,i,r){let c=r.trim();if(c.charCodeAt(0)!==40)return null;let s=o(c,0,"(",")");if(s===-1)return null;let l=c.slice(1,s).trim(),f=c.slice(s+1).trimStart();if(!f.startsWith("=>"))return null;let u=f.slice(2).trim();if(e==="get")return`get ${i}(): ${u||"unknown"}`;return`set ${i}(${l})`}function ee(e,i){let r=i.trim(),c=o(r,0,"(",")");if(!r.startsWith("(")||c===-1)return"unknown";if(e==="get"){let u=r.slice(c+1).trim();return u.startsWith("=>")?u.slice(2).trim():"unknown"}let s=r.slice(1,c).trim(),l=s.startsWith("{")?o(s,0,"{","}"):s.startsWith("[")?o(s,0,"[","]"):0,f=s.indexOf(":",Math.max(0,l));return f===-1?"unknown":s.slice(f+1).trim()}function ne(e){let i=e;if(i.startsWith("async ")||i.startsWith("async\t"))i=i.slice(5).trimStart();if(i.startsWith("*"))i=i.slice(1).trimStart();if(!i.startsWith("("))return!1;let r=0;for(let c=0;c<i.length;c++){let s=i.charCodeAt(c);if(s===40)r++;else if(s===41){if(r--,r===0){let l=i.slice(c+1).trimStart();if(l.startsWith("{"))return!0;if(l.startsWith(":")){let f=dt(l,1);if(f?.kind==="arrow")return!1;if(f?.kind==="body")return!0}return!1}}}return!1}function re(e){let i=e.trimEnd();if(!i.endsWith(">"))return null;let r=0,c=-1;for(let l=i.length-1;l>=0;l--){let f=i.charCodeAt(l);if(f===62){if(l>0&&i.charCodeAt(l-1)===61)continue;r++}else if(f===60){if(r--,r===0){c=l;break}}}if(c===-1)return null;let s=i.slice(0,c).trimEnd();if(!s)return null;return{name:s,typeParams:i.slice(c)}}function $t(e,i){let r=i.trimStart(),c=!1,s=!1;if(r.startsWith("async ")||r.startsWith("async\t"))c=!0,r=r.slice(5).trimStart();if(r.startsWith("*"))s=!0,r=r.slice(1).trimStart();let l="";if(r.charCodeAt(0)===60){let p=0,g=-1;for(let m=0;m<r.length;m++)if(r.charCodeAt(m)===60)p++;else if(r.charCodeAt(m)===62&&!(m>0&&r.charCodeAt(m-1)===61)){if(p--,p===0){g=m;break}}if(g!==-1)l=r.slice(0,g+1),r=r.slice(g+1).trimStart()}let f=r.indexOf("("),u=o(r,f,"(",")");if(f===-1||u===-1)return"() => unknown";let a=r.slice(f,u+1),d="unknown",C=r.slice(u+1).trimStart();if(C.charCodeAt(0)===58){let p=C.slice(1),g=dt(p,0);if(g)d=p.slice(0,g.index).trim();else d=p.trim()}if(d==="unknown"&&!s&&C.charCodeAt(0)===123){let p=o(C,0,"{","}");if(p!==-1){let g=I(C.slice(1,p),c,a);if(g!=="unknown"&&g!=="Promise<unknown>")d=c&&g.startsWith("Promise<")?g.slice(8,-1):g;else if(c)d="Promise<unknown>"}}if(d==="unknown"){if(c&&s)d="AsyncGenerator<unknown, void, unknown>";else if(s)d="Generator<unknown, void, unknown>";else if(c)d="Promise<void>"}else if(c&&!d.startsWith("Promise<")&&!d.startsWith("AsyncGenerator<"))d=`Promise<${d}>`;let y=le(a);return`${l}${y} => ${d}`}function dt(e,i){let r=0,c=0,s=0,l=0,f=!1,u=0;for(let a=i;a<e.length;a++){let d=e.charCodeAt(a);if(f){if(d===92)a++;else if(d===u)f=!1;continue}if(d===34||d===39||d===96){f=!0,u=d;continue}if(d===40)r++;else if(d===41&&r>0)r--;else if(d===91)c++;else if(d===93&&c>0)c--;else if(d===60)s++;else if(d===62&&s>0&&e.charCodeAt(a-1)!==61)s--;else if(d===125&&l>0)l--;else if(d===123){let C=r>0||c>0||s>0||l>0,y=e.slice(i,a).trimEnd(),p=y.charCodeAt(y.length-1),g=y.length===0||p===38||p===124||p===40||p===44||p===58||p===61||p===91;if(C||g)l++;else return{index:a,kind:"body"}}else if(d===61&&a+1<e.length&&e.charCodeAt(a+1)===62&&r===0&&c===0&&s===0&&l===0)return{index:a,kind:"arrow"}}return null}function o(e,i,r,c){let s=0;for(let l=i;l<e.length;l++)if(e[l]===r)s++;else if(e[l]===c){if(c===">"&&l>0&&e[l-1]==="=")continue;if(s--,s===0)return l}return-1}function J(e){let i=0,r=0,c=!1,s="";for(let l=0;l<e.length-1;l++){let f=e[l],u=e[l+1],a=l>0?e[l-1]:"";if(!c&&(f==='"'||f==="'"||f==="`"))c=!0,s=f;else if(c&&f===s&&a!=="\\")c=!1;if(!c){if(f==="<"){let d=o(e,l,"<",">");if(d!==-1){l=d;continue}}if(f==="(")i++;else if(f===")")i--;else if(f==="[")r++;else if(f==="]")r--;if(f==="="&&u===">"&&i===0&&r===0)return l}}return-1}function ot(e,i=!1,r=0,c=!0){let s=e.trim();if(s.length>200&&nt(s,"=>")>2&&nt(s,"<")>5&&!s.startsWith("function"))return i?"((...args: any[]) => any)":"(...args: any[]) => any";if(s.startsWith("async ")&&s.includes("=>")){let f=s.slice(5).trim(),u=J(f);if(u===-1)return i?"(() => Promise<unknown>)":"() => Promise<unknown>";let a=f.substring(0,u).trim(),d=f.substring(u+2).trim(),C=ut(a),{params:y,returnType:p}=C;if(y=le(y),y==="()"||y==="")y="()";else if(!y.startsWith("("))y=`(${y})`;let g=p;if(g);else if(d.startsWith("{"))g=I(d.slice(1,d.endsWith("}")?-1:void 0),!0,C.params);else g=F(d,lt(C.params));let m=`${y} => ${p||g.startsWith("Promise<")?g:`Promise<${g}>`}`;return i?`(${m})`:m}if(s.includes("=>")){let f="",u=s;if(s.startsWith("<")){let h=o(s,0,"<",">");if(h!==-1)f=s.substring(0,h+1),u=s.substring(h+1).trim()}let a=J(u);if(a===-1)return i?"(() => unknown)":"() => unknown";let d=u.substring(0,a).trim(),C=u.substring(a+2).trim(),y=ut(d),{params:p,returnType:g}=y;if(p=le(p),p==="()"||p==="")p="()";else if(!p.startsWith("("))p=`(${p})`;let m="unknown";if(g)m=g;else if(C.startsWith("{"))m=I(C.slice(1,C.endsWith("}")?-1:void 0),!1,y.params);else if(Y(C)||ht(C)&&Y(C.slice(1,-1).trim()))m="JSX.Element";else if(C.includes("=>")){let h=C.trimStart(),w=h.indexOf("("),b=w!==-1?o(h,w,"(",")"):-1,W=b!==-1?h.indexOf("=>",b):-1;if(w===0&&b!==-1&&W!==-1){let x=h.substring(w+1,b).trim(),P=le(x);if(f.includes("T")&&P.includes("T"))m=`(${P}) => T`;else m=`(${P}) => any`}else m="any"}else m=F(C,lt(y.params));let A=`${f}${p} => ${m}`;return i?`(${A})`:A}if(s.startsWith("function")){let f=8,u=s.length;while(f<u&&s.charCodeAt(f)<=32)f++;let a=!1;if(f<u&&s.charCodeAt(f)===42){a=!0,f++;while(f<u&&s.charCodeAt(f)<=32)f++}let d="";if(f<u&&s.charCodeAt(f)===60){let p=f,g=1;f++;while(f<u&&g>0){let m=s.charCodeAt(f);if(m===60)g++;else if(m===62&&s.charCodeAt(f-1)!==61)g--;f++}d=s.substring(p,f);while(f<u&&s.charCodeAt(f)<=32)f++}let C=s.indexOf("(",f);if(C!==-1){let p=1,g=C+1;while(g<u&&p>0){let W=s.charCodeAt(g);if(W===40)p++;else if(W===41)p--;g++}let m=s.substring(C+1,g-1).trim(),A=m?le(`(${m})`):"()";if(a){let W=s.substring(g).trim(),x=W.indexOf("Generator<");if(x!==-1){let T=x+10,k=W.indexOf(">",T);if(k!==-1){let D=W.substring(T,k),V=`${d}${A} => Generator<${D}>`;return i?`(${V})`:V}}let P=`${d}${A} => Generator<any, any, any>`;return i?`(${P})`:P}let h="unknown",w=s.substring(g).trimStart();if(w.charCodeAt(0)===58){let W=w.slice(1),x=dt(W,0),P=(x?W.slice(0,x.index):W).trim();if(P)h=P}let b=`${d}${A} => ${h}`;return i?`(${b})`:b}let y="(...args: any[]) => unknown";return i?`(${y})`:y}if(s.includes("=>")&&s.includes("(")&&s.includes(")")){if(s.length>100||nt(s,"=>")>2){let f="";if(s.charCodeAt(0)===60){let y=o(s,0,"<",">");if(y!==-1)f=s.substring(0,y+1)}let u=s.indexOf("("),a=u!==-1?o(s,u,"(",")"):-1,d=u!==-1&&a!==-1?s.substring(u,a+1):"(...args: any[])";d=le(d);let C=`${f}${d} => any`;return i?`(${C})`:C}return i?`(${s})`:s}let l="() => unknown";return i?`(${l})`:l}function ut(e){let i=e.trim();if(!i.startsWith("("))return{params:i,returnType:""};let r=o(i,0,"(",")");if(r===-1)return{params:i,returnType:""};let c=i.slice(r+1).trim();return{params:i.slice(0,r+1),returnType:c.startsWith(":")?c.slice(1).trim():""}}function Me(e){let i=e.trim();if(i==="any"||i==="object"||i==="unknown")return!0;if(i.startsWith("Record<")&&i.endsWith(">"))return!0;if(i.startsWith("Array<")&&i.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(i))return!0;return!1}function _(e){let i=-1,r=0;for(let s=0;s<e.length;s++){let l=e.charCodeAt(s);if(l===34||l===39||l===96){s=K(e,s,l)-1;continue}if(l===47&&e.charCodeAt(s+1)===47){while(s<e.length&&e.charCodeAt(s)!==10)s++;continue}if(l===47&&e.charCodeAt(s+1)===42){let f=e.indexOf("*/",s+2);s=f===-1?e.length:f+1;continue}if(l===47){let f=s-1;while(f>=0&&e.charCodeAt(f)<=32)f--;if(f<0||"([{:;,=!?&|+*-~>".includes(e[f])){let u=!1;for(s++;s<e.length;s++){let a=e.charCodeAt(s);if(a===92)s++;else if(a===91)u=!0;else if(a===93)u=!1;else if(a===47&&!u)break}continue}}if(l===40||l===91||l===123)r++;else if(l===41||l===93||l===125)r--;else if(r===0&&e.startsWith("satisfies",s)&&H(e,s,9)&&e[s-1]!==".")i=s}if(i===-1)return null;let c=e.slice(i+9).trim();if(c.endsWith(";"))c=c.slice(0,-1).trim();return c||null}function Fa(e){let i=e.trim(),r=i.match(/^\{\s*\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(r){let[,l,f,u,a]=r;return`{ [${l} in ${f}]${u?"?":""}: ${a} }`}let c=i.match(/^\{\s*readonly\s+\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(c){let[,l,f,u,a]=c;return`{ readonly [${l} in ${f}]${u?"?":""}: ${a} }`}let s=i.match(/^\{\s*(-?readonly\s+)?\[(\w+)\s+in\s+(.+?)\](-?\?)?\s*:\s*(.+)\s*\}$/);if(s){let[,l,f,u,a,d]=s;return`{ ${l?`${l.trim()} `:""}[${f} in ${u}]${a||""}: ${d} }`}return null}function Na(e){let i=e.trim(),r=i.indexOf(" extends ");if(r===-1)return null;let c=i.slice(r+9),s=ie(c);if(s===-1)return null;let l=se(c,s);if(l===-1)return null;let f=i.slice(0,r).trim(),u=c.slice(0,s).trim(),a=c.slice(s+1,l).trim(),d=c.slice(l+1).trim();return`${f} extends ${u} ? ${a} : ${d}`}function ie(e){let i=0,r=!1,c="";for(let s=0;s<e.length;s++){let l=e[s],f=s>0?e[s-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,c=l;else if(r&&l===c&&f!=="\\")r=!1;if(!r){if(l==="<"||l==="("||l==="["||l==="{")i++;if(l===">"||l===")"||l==="]"||l==="}")i--;if(l==="?"&&i===0)return s}}return-1}function se(e,i){let r=0,c=!1,s="";for(let l=i+1;l<e.length;l++){let f=e[l],u=l>0?e[l-1]:"";if(!c&&(f==='"'||f==="'"||f==="`"))c=!0,s=f;else if(c&&f===s&&u!=="\\")c=!1;if(!c){if(f==="<"||f==="("||f==="["||f==="{")r++;if(f===">"||f===")"||f==="]"||f==="}")r--;if(f==="?"&&r===0)r++;if(f===":"&&r===0)return l;if(f===":"&&r>0)r--}}return-1}function Ba(e){let i=e.trim();if(!i.startsWith("`")||!i.endsWith("`"))return null;let r=i.slice(1,-1);if(!r.includes("${"))return i;let c=[],s="",l=0;while(l<r.length)if(r[l]==="$"&&r[l+1]==="{"){if(s)c.push(`"${s}"`),s="";let f=1,u="";l+=2;while(l<r.length&&f>0){if(r[l]==="{")f++;if(r[l]==="}")f--;if(f>0)u+=r[l];l++}c.push(u.trim())}else s+=r[l],l++;if(s)c.push(`"${s}"`);return i}function Wa(e){let i=[],r=/infer\s+(\w+)/g,c;while((c=r.exec(e))!==null)i.push(c[1]);return i}function ja(e){let r=e.trim(),c=r.indexOf("[");if(c!==-1){if(r.indexOf(" in ",c)!==-1)return!0}let s=r.indexOf(" extends ");if(s!==-1){let f=r.indexOf(" ? ",s);if(f!==-1&&r.indexOf(" : ",f)!==-1)return!0}if(r.charCodeAt(0)===96&&r.charCodeAt(r.length-1)===96){if(r.indexOf("${")!==-1)return!0}let l=r.indexOf("infer ");if(l!==-1){if(l===0||!R(r.charCodeAt(l-1)))return!0}return!1}function _a(e,i=3){let r=e.trim(),c=0,s=0;for(let l of r){if(l==="<"||l==="("||l==="["||l==="{")c++,s=Math.max(s,c);if(l===">"||l===")"||l==="]"||l==="}")c--}if(s>i){let l=r.match(/^(\w+)</);if(l)return`${l[1]}<any>`;return"unknown"}return r}function Ga(e){let r=e.trim().match(/^(\w+)<(.+)>$/);if(!r)return null;let c=r[1],s=r[2],l=ya(s);if(["Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer"].includes(c))return{name:c,params:l};return null}function ya(e){let i=[],r="",c=0,s=!1,l="";for(let f=0;f<e.length;f++){let u=e[f],a=f>0?e[f-1]:"";if(!s&&(u==='"'||u==="'"||u==="`"))s=!0,l=u;else if(s&&u===l&&a!=="\\")s=!1;if(!s){if(u==="<"||u==="("||u==="["||u==="{")c++;if(u===">"||u===")"||u==="]"||u==="}")c--;if(u===","&&c===0){i.push(r.trim()),r="";continue}}r+=u}if(r.trim())i.push(r.trim());return i}function Va(e){let i=e.trim();if(i.startsWith("keyof "))return i;return null}function Ua(e){let i=e.trim();if(i.startsWith("typeof "))return i;return null}function za(e){let i=e.trim();if(i.length===0||i.charCodeAt(0)===91)return!1;if(i.charCodeAt(i.length-1)!==93)return!1;let r=i.indexOf("[");if(r<=0)return!1;for(let c=0;c<r;c++){let s=i.charCodeAt(c);if(!R(s)&&s!==46)return!1}return!0}
|
|
38
|
+
export{Ft,Nt,z,ga,it,n,Bt,I,ha,L,De,ce,Jn,Wt,st,Re,le,o,ot,Me,_,Fa,Na,Ba,Wa,ja,_a,Ga,ya,Va,Ua,za};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{readFile as M,writeFile as S}from"fs/promises";import{basename as x,dirname as d,relative as b,resolve as C}from"path";function f(e){return`${String.fromCharCode(47,47,35)} sourceMappingURL=${e}`}class
|
|
3
|
-
${f(n)}`}function
|
|
4
|
-
${n.toComment(r)}`}async function
|
|
2
|
+
import{readFile as M,writeFile as S}from"fs/promises";import{basename as x,dirname as d,relative as b,resolve as C}from"path";function f(e){return`${String.fromCharCode(47,47,35)} sourceMappingURL=${e}`}class rn{file;sourceRoot;sources=[];sourcesContent=[];names=[];mappings=[];sourceIndexMap=new Map;nameIndexMap=new Map;constructor(e){this.file=e.file,this.sourceRoot=e.sourceRoot}addSource(e,n){let r=this.sourceIndexMap.get(e);if(r===void 0)r=this.sources.length,this.sources.push(e),this.sourcesContent.push(n??null),this.sourceIndexMap.set(e,r);else if(n&&!this.sourcesContent[r])this.sourcesContent[r]=n;return r}addName(e){let n=this.nameIndexMap.get(e);if(n===void 0)n=this.names.length,this.names.push(e),this.nameIndexMap.set(e,n);return n}addMapping(e){let n=this.addSource(e.source),r;if(e.name)r=this.addName(e.name);this.mappings.push({generated:e.generated,original:e.original,sourceIndex:n,nameIndex:r})}generate(e=!1){this.mappings.sort((r,t)=>{if(r.generated.line!==t.generated.line)return r.generated.line-t.generated.line;return r.generated.column-t.generated.column});let n={version:3,file:this.file,sources:this.sources,names:this.names,mappings:this.encodeMappings()};if(this.sourceRoot)n.sourceRoot=this.sourceRoot;if(e)n.sourcesContent=this.sourcesContent;return n}encodeMappings(){let e=[],n=0,r=0,t=0,i=0,o=0,s=0,u=[];for(let a of this.mappings){while(n<a.generated.line)e.push(u.join(",")),u=[],n++,r=0;let l=[];if(l.push(a.generated.column-r),r=a.generated.column,l.push(a.sourceIndex-t),t=a.sourceIndex,l.push(a.original.line-i),i=a.original.line,l.push(a.original.column-o),o=a.original.column,a.nameIndex!==void 0)l.push(a.nameIndex-s),s=a.nameIndex;u.push(I(l))}return e.push(u.join(",")),e.join(";")}toString(e=!1){return JSON.stringify(this.generate(e))}toDataUrl(e=!1){let n=this.toString(e);return`data:application/json;charset=utf-8;base64,${Buffer.from(n).toString("base64")}`}toComment(e=!1){return f(this.toDataUrl(e))}}class mt{map;decodedMappings=null;constructor(e){this.map=typeof e==="string"?JSON.parse(e):e}originalPositionFor(e){let n=this.getMappings(),r=0,t=n.length-1,i=null;while(r<=t){let o=Math.floor((r+t)/2),s=n[o];if(s.generated.line===e.line)if(s.generated.column===e.column){i=s;break}else if(s.generated.column<e.column)i=s,r=o+1;else t=o-1;else if(s.generated.line<e.line)r=o+1;else t=o-1}if(!i)return{source:null,line:null,column:null,name:null};return{source:this.map.sources[i.sourceIndex]||null,line:i.original.line,column:i.original.column,name:i.nameIndex!==void 0?this.map.names[i.nameIndex]:null}}generatedPositionFor(e){let n=this.map.sources.indexOf(e.source);if(n===-1)return null;let r=this.getMappings();for(let t of r)if(t.sourceIndex===n&&t.original.line===e.line&&t.original.column<=e.column)return t.generated;return null}getMappings(){if(!this.decodedMappings)this.decodedMappings=v(this.map.mappings);return this.decodedMappings}sourceContentFor(e){let n=this.map.sources.indexOf(e);if(n===-1||!this.map.sourcesContent)return null;return this.map.sourcesContent[n]}}function I(e){return e.map(L).join("")}function L(e){let o="",s=e<0?-e<<1|1:e<<1;do{let u=s&31;if(s>>>=5,s>0)u|=32;o+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u]}while(s>0);return o}function v(e){let n=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,i=0,o=0,s=0,u=0,a=0,l=e.split(";");for(let g of l){if(i=0,g){let h=g.split(",");for(let p of h){if(!p)continue;let c=N(p,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");if(c.length>=1)i+=c[0];if(c.length>=4){o+=c[1],s+=c[2],u+=c[3];let m={generated:{line:t,column:i},original:{line:s,column:u},sourceIndex:o};if(c.length>=5)a+=c[4],m.nameIndex=a;n.push(m)}}}t++}return n}function N(e,n){let t=[],i=0,o=0;for(let s of e){let u=n.indexOf(s);if(u===-1)continue;let a=u&32;if(o+=(u&31)<<i,a)i+=5;else{let l=o&1;o>>=1,t.push(l?-o:o),o=0,i=0}}return t}function Ns(e){let n=new rn({file:x(e.generatedFile),sourceRoot:e.sourceRoot}),r=b(d(e.generatedFile),e.sourceFile);n.addSource(r,e.sourceContent);for(let t of e.mappings)n.addMapping({generated:{line:t.generatedLine,column:t.generatedColumn},original:{line:t.originalLine,column:t.originalColumn},source:r,name:t.name});return n}function Bs(e,n){return`${e}
|
|
3
|
+
${f(n)}`}function Ws(e,n,r=!1){return`${e}
|
|
4
|
+
${n.toComment(r)}`}async function js(e,n,r=!1){await S(e,n.toString(r))}async function _r(e){let n=await M(e,"utf-8");return new mt(n)}async function _s(e,n){let r=e.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if(r){let i=r[1],o=Buffer.from(i,"base64").toString("utf-8");return new mt(o)}let t=e.match(/\/\/# sourceMappingURL=(.+)$/);if(t){let i=C(d(n),t[1].trim());try{return await _r(i)}catch{return null}}return null}function Gs(e,n){let r=e,t=n,i=r.split(`
|
|
5
5
|
`),o=[],s=0,u=0;for(let a of t){while(s+i[u].length+1<=a.generatedStart&&u<i.length-1)s+=i[u].length+1,u++;let l=a.generatedStart-s;o.push({generatedLine:u,generatedColumn:Math.max(0,l),originalLine:a.originalLine,originalColumn:a.originalColumn,name:a.name})}return o}
|
|
6
|
-
export{
|
|
6
|
+
export{rn,mt,Ns,Bs,Ws,js,_r,_s,Gs};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
export{
|
|
2
|
+
var ui=[{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}],fi=[{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}],di=[{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}],pi=[{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 mi(e){switch(e){case"strict":return fi;case"readonly":return di;case"simplified":return pi;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 Sn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...ui);if(e.presets)for(let r of e.presets)this.rules.push(...mi(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 J(e={rules:[]}){return new Sn(e)}var ko=J({rules:[]}),To=J({rules:[],presets:["strict"]});function $t(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var Ao={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{ui,fi,di,pi,mi,Sn,J,ko,To,$t,Ao};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{r}from"./chunk-z6mpxpxt.js";import{l}from"./chunk-yzdh207n.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 yr(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 is(e,o={}){let i=performance.now(),{maxConcurrency:t=4,rootDir:n=process.cwd(),config:s={},onProgress:c,onError:a}=o,g=await yr(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 ss(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 br(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 wr(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 os(e){let o=wr(e),i=br(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{yr,is,ss,br,wr,os};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class
|
|
3
|
-
`)}function
|
|
4
|
-
export{
|
|
2
|
+
import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class ai{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(t={}){this.config={enabled:t.enabled??!0,cacheDir:t.cacheDir??b,format:t.format??"json",maxAge:t.maxAge??86400000,force:t.force??!1,validateCache:t.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await y(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let t=o(this.config.cacheDir,d);try{let e=await l(t,"utf-8");if(this.manifest=JSON.parse(e),this.manifest.version!==c){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let t=o(this.config.cacheDir,d);this.manifest.updatedAt=Date.now(),await v(t,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(t,e){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let s=this.manifest.entries[t];if(!s)return this.stats.misses++,null;if(s.configHash!==e)return this.stats.misses++,null;if(Date.now()-s.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null;if(this.config.validateCache)try{let a=(await m(t)).mtimeMs;if(a!==s.mtime){let i=await l(t,"utf-8");if(this.hashContent(i)!==s.hash)return this.stats.misses++,null;s.mtime=a,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null}if(s.dependencies.length>0){if((await Promise.all(s.dependencies.map(async(a)=>{let i=this.manifest.entries[a];if(!i)return!0;try{return(await m(a)).mtimeMs===i.mtime}catch{return!1}}))).some((a)=>!a))return this.stats.misses++,null}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),s}async set(t,e,s,r,a,i){if(!this.config.enabled||!this.manifest)return;let n=Date.now();try{n=(await m(t)).mtimeMs}catch{}let h={filePath:t,hash:this.hashContent(e),mtime:n,declarations:s,dtsContent:r,dependencies:a,cachedAt:Date.now(),configHash:i};if(!(t in this.manifest.entries))this.stats.totalEntries++;this.manifest.entries[t]=h,this.dirty=!0}invalidate(t){if(!this.manifest)return;delete this.manifest.entries[t],this.dirty=!0;for(let[e,s]of Object.entries(this.manifest.entries))if(s.dependencies.includes(t))delete this.manifest.entries[e]}async clear(){this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(t){return String(p(t))}updateHitRatio(){let t=this.stats.hits+this.stats.misses;this.stats.hitRatio=t>0?this.stats.hits/t:0}static hashConfig(t){let e={outdir:t.outdir,clean:t.clean,tsconfigPath:t.tsconfigPath};return g("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}}function xo(t,e){let s=[],r=[],a=[];return{async needsRebuild(i){return await t.get(i,e)===null},async getCachedDeclarations(i){let n=await t.get(i,e);if(n)return r.push(i),n.declarations;return null},async getCachedDts(i){let n=await t.get(i,e);if(n)return n.dtsContent;return null},async cacheResult(i,n,h,u,f=[]){await t.set(i,n,h,u,f,e),s.push(i)},skip(i){a.push(i)},getResult(){return{rebuilt:s,cached:r,skipped:a,stats:t.getStats()}},async save(){await t.save()}}}async function Co(t,e=604800000){let s=t.getStats();if(s.totalEntries>1000)return await t.clear(),s.totalEntries;return 0}function vo(t){let e=[];return e.push("Incremental Build Results:"),e.push(` Rebuilt: ${t.rebuilt.length} files`),e.push(` From cache: ${t.cached.length} files`),e.push(` Skipped: ${t.skipped.length} files`),e.push(""),e.push("Cache Statistics:"),e.push(` Total entries: ${t.stats.totalEntries}`),e.push(` Hit ratio: ${(t.stats.hitRatio*100).toFixed(1)}%`),e.push(` Time saved: ~${t.stats.timeSavedMs}ms`),e.join(`
|
|
3
|
+
`)}function So(t,e){let s=[],r=/import\s+(?:type\s+)?(?:.+(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])from\s+)?['"]([^'"]+)['"]/g,a;while((a=r.exec(t))!==null){let i=a[1];if(i.startsWith(".")){let n=o(C(e),i);s.push(n),s.push(`${n}.ts`),s.push(`${n}.tsx`),s.push(o(n,"index.ts")),s.push(o(n,"index.tsx"))}}return s}
|
|
4
|
+
export{ai,xo,Co,vo,So};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{R,M}from"./chunk-2ngfncfx.js";import{P,D}from"./chunk-hqph3vnd.js";import{nr}from"./chunk-c7a07a26.js";import{p}from"./chunk-v6fwy63g.js";import{T,O}from"./chunk-3mcz22q8.js";var y=100,h=0,s=new Map;function Te(n,a,c=!0,i=!1,l){if(R(a))n=M(n);else if(P(a))n=D(n);let f=p(n),m=`${a}:${c?1:0}:${i?1:0}:${JSON.stringify([...l??[]].sort())}`,r=s.get(m);if(r&&r.contentHash===f)return r.lastAccess=++h,r.declarations;let g=i?T(n,a,c):O(n,a,c,l);if(s.set(m,{declarations:g,contentHash:f,lastAccess:++h}),s.size>y){let S=Math.max(1,Math.ceil(s.size*0.1)),e=[];for(let[t,o]of s)e.push([t,o.lastAccess]);e.sort((t,o)=>t[1]-o[1]);for(let t=0;t<S&&t<e.length;t++)s.delete(e[t][0])}return g}function Rn(){s.clear(),nr()}
|
|
3
|
+
export{Te,Rn};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var r=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,E=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,f=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function
|
|
2
|
+
var r=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,E=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,f=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function bn(t){let l=[],a=0;for(let e=0;e<=t.length;e++)if(e===t.length||t[e]===`
|
|
3
3
|
`){let n=a,i=e;while(n<i&&(t[n]===" "||t[n]==="\t"||t[n]==="\r"))n++;while(i>n&&(t[i-1]===" "||t[i-1]==="\t"||t[i-1]==="\r"))i--;let s=t.slice(n,i);if(a=e+1,s.startsWith("///")){if(s.indexOf("<")===-1)continue;if(r.test(s)||E.test(s)||f.test(s))l.push(s)}else if(s===""||s.startsWith("//"))continue;else break}return l}
|
|
4
|
-
export{
|
|
4
|
+
export{bn};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ke}from"./chunk-bkbsg2bv.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 Q(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(ke(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 Q(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{Q};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,d}from"./chunk-c7a07a26.js";import{j}from"./chunk-7j4cgkb4.js";import{It}from"./chunk-3mcz22q8.js";import{b}from"./chunk-jfygtm4r.js";import{Z}from"./chunk-7z8pykqp.js";import{relative as W}from"path";function Q(n){let y=t(n),c=(l)=>y[l]?n.slice(y[l].start,y[l].end):"",i=c(0)==="export"?1:0;if(c(i++)!=="declare")return;let f;if(c(i)==="module"&&y[i+1]?.kind==="quoted"){if(f=d(c(i+1)),f===void 0)return;i+=2}else if(c(i++)!=="global")return;if(c(i)!=="{")return;let h=y[i].end,S=1;for(i++;i<y.length;i++)if(c(i)==="{")S++;else if(c(i)==="}"&&--S===0)return{specifier:f,body:n.slice(h,y[i].start),start:h,end:y[i].start};return}var ne=/^[A-Z_$][\w$]*$/i;function Eo(n){let y=[],c=[],i=0,f=0,h=[],S=!1,l=0,E=n.length,R=(a)=>{let w=n.slice(i,a).trim();if(i=a,!w)return;if(se(w)){c.push(w);return}y.push({text:w,comments:c}),c=[]};while(l<E){let a=n[l];if(S){if(a==="\\"){l+=2;continue}if(a==="`"){S=!1,l++;continue}if(a==="$"&&n[l+1]==="{"){h.push(f),f++,S=!1,l+=2;continue}l++;continue}if(a==="/"&&n[l+1]==="*"){let w=n.indexOf("*/",l+2);l=w===-1?E:w+2;continue}if(a==="/"&&n[l+1]==="/"){let w=n.indexOf(`
|
|
3
|
+
`,l);l=w===-1?E:w;continue}if(a==="'"||a==='"'){l++;while(l<E&&n[l]!==a&&n[l]!==`
|
|
4
|
+
`){if(n[l]==="\\")l++;l++}l++;continue}if(a==="`"){S=!0,l++;continue}if(a==="("||a==="["||a==="{"){f++,l++;continue}if(a===")"||a==="]"||a==="}"){if(f--,h.length>0&&a==="}"&&f===h[h.length-1])h.pop(),S=!0;l++;continue}if(f===0&&a===";"){R(l+1),l++;continue}if(f===0&&a===`
|
|
5
|
+
`){let w=n[l+1];if(w!==void 0&&/[\w$@/]/.test(w))R(l+1);l++;continue}l++}return R(E),y}function se(n){let y=0;while(y<n.length){while(y<n.length&&/\s/.test(n[y]))y++;if(y>=n.length)return!0;if(n.startsWith("//",y)){let c=n.indexOf(`
|
|
6
|
+
`,y);y=c===-1?n.length:c;continue}if(n.startsWith("/*",y)){let c=n.indexOf("*/",y+2);if(c===-1)return!0;y=c+2;continue}return!1}return!0}function Y(n){let y=[];for(let c of n.split(",")){let i=c.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!i)continue;let f=i.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;y.push({local:f[1],exported:f[2]??f[1]})}return y}var ie=/^(?:export\s+)?(default\s+)?(?:declare\s+)?(abstract\s+)?(class|interface|type|function\s*\*?|enum|const\s+enum|namespace|module|const|let|var|async\s+function)\b\s*([\w$]+)?/;function oe(n,y){let c=n.replace(/^export\s+/,""),i=/^default\s+/.test(c);if(c=c.replace(/^default\s+/,""),i)c=c.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(f,h)=>`${h.trimEnd()} ${y}`);if(/^(?:interface|type)\b/.test(c)||/^declare\b/.test(c))return c;return`declare ${c}`}function F(n,y,c=!1){let i={file:n,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],augmentations:[],directives:[]},f=c?It(y,n).map((h)=>({text:h.text,comments:[...h.leadingComments??[]]})):Eo(y);for(let h of f){h.comments=h.comments.filter((w)=>{if(/^\/\/\/\s*</.test(w))return i.directives.push(...w.split(`
|
|
7
|
+
`).map((v)=>v.trim()).filter((v)=>v.startsWith("///"))),!1;return!0});let S=h.text.replace(/;\s*$/,"").trim(),l=S.startsWith("import")?b(S):null;if(l&&!l.isImportEquals){let w=l.source;if(l.defaultName)i.imports.set(l.defaultName,{specifier:w,imported:"default"});if(l.namespaceName)i.imports.set(l.namespaceName,{specifier:w,imported:"*"});for(let v of l.namedItems)i.imports.set(v.name,{specifier:w,imported:/^['"]/.test(v.originalName)?d(v.originalName):v.originalName});continue}if(/^import\s+['"]/.test(S)){i.verbatim.push(h);continue}let E=S.match(/^export\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s+(['"])([^'"]+)\2/);if(E){i.namespaceReExports.push({specifier:E[3],exported:E[1]});continue}if(E=S.match(/^export\s+(?:type\s+)?\*\s+from\s+(['"])([^'"]+)\1/),E){i.starReExports.push(E[2]);continue}if(E=S.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}\s+from\s+(['"])([^'"]+)\2/),E){for(let w of Y(E[1]))i.namedReExports.push({specifier:E[3],imported:w.local,exported:w.exported});continue}if(E=S.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}$/),E){for(let w of Y(E[1]))i.localExports.set(w.exported,w.local);continue}if(E=S.match(/^export\s+default\s+([\w$]+)$/),E&&ne.test(E[1])){i.localExports.set("default",E[1]);continue}let R=Q(S);if(R?.specifier!==void 0&&j(y)){i.augmentations.push({statement:h,specifier:R.specifier,body:R.body});continue}if(/^export\s+as\s+namespace\b/.test(S)||R){i.verbatim.push(h);continue}let a=S.match(ie);if(a){let w=!!a[1],v=a[4]??(w?"_default":null);if(v){if(i.declared.add(v),/^export\s/.test(S))i.localExports.set(w?"default":v,v);i.declarations.push({statement:h,name:v,emit:oe(h.text,v)});continue}}i.declarations.push({statement:h,name:null,emit:h.text})}return i}function qe(n,y){if(y.size===0)return n;let c=t(n),i=new Map(c.filter((m)=>m.kind==="literal").map((m)=>[m.start,m.end])),f=(m)=>c[m]?n.slice(c[m].start,c[m].end):"",h=new Map,S=[];for(let m=0;m<c.length;m++){let x=f(m);if(["(","[","{","<"].includes(x))S.push(m);else if([")","]","}",">"].includes(x)&&!(x===">"&&f(m-1)==="=")){let k=S.at(-1);if(k!==void 0&&["()","[]","{}","<>"].includes(f(k)+x))S.pop(),h.set(k,m)}}let l=(m)=>{for(let x=m;x<c.length;x++){if([";",",",")","]","}"].includes(f(x))||f(x)===">"&&f(x-1)!=="=")return x;let k=h.get(x);if(k!==void 0)x=k}return c.length},E=new Set;for(let m=0;m<c.length;m++){let x=h.get(m);if(f(m)!=="<"||x===void 0)continue;let k=["class","interface","type"].includes(f(m-2));if(!k&&f(x+1)!=="(")continue;let N=new Set;for(let u=m+1;u<x;u++){if(u===m+1||f(u-1)===","){while(["const","in","out"].includes(f(u)))u++;if(c[u]?.kind==="word")N.add(f(u))}let D=h.get(u);if(D!==void 0)u=D}let I=l(x+1);if(k&&f(m-2)!=="type")for(let u=x+1;u<c.length;u++){if(f(u)==="{"){I=h.get(u)??I;break}let D=h.get(u);if(D!==void 0)u=D}for(let u=m+1;u<I;u++){let D=f(m-2)==="class"&&u>x&&f(u-1)==="extends";if(N.has(f(u))&&f(u-1)!=="typeof"&&!D)E.add(c[u].start)}}for(let m=0;m<c.length;m++){if(!["namespace","module"].includes(f(m))||c[m+1]?.kind!=="word"||f(m+2)!=="{")continue;let x=h.get(m+2);if(x===void 0)continue;let k=It(n.slice(c[m+2].end,c[x].start),"bundle-namespace.ts"),N=new Set(k.filter((u)=>["class","interface","type","enum","module","namespace"].includes(u.kind)).map((u)=>u.name)),I=new Set(k.filter((u)=>["class","variable","function","enum","module","namespace"].includes(u.kind)).map((u)=>u.name));for(let u=m+3;u<x;u++)if((f(u-1)==="typeof"?I:N).has(f(u)))E.add(c[u].start)}let R="",a=0,w=n.length,v=`
|
|
8
|
+
`;while(a<w){let m=i.get(a);if(m!==void 0){R+=n.slice(a,m),a=m,v="`";continue}let x=n[a];if(x==="/"&&n[a+1]==="*"){let k=n.indexOf("*/",a+2),N=k===-1?w:k+2;R+=n.slice(a,N),a=N;continue}if(x==="/"&&n[a+1]==="/"){let k=n.indexOf(`
|
|
9
|
+
`,a),N=k===-1?w:k;R+=n.slice(a,N),a=N;continue}if(x==="'"||x==='"'){let k=a+1;while(k<w&&n[k]!==x&&n[k]!==`
|
|
10
|
+
`){if(n[k]==="\\")k++;k++}R+=n.slice(a,k+1),a=k+1,v=x;continue}if(/[A-Z_$]/i.test(x)){let k=a+1;while(k<w&&/[\w$]/.test(n[k]))k++;let N=n.slice(a,k),I=y.get(N);if(I!==void 0&&v!=="."&&!E.has(a)){let u=k;while(u<w&&(n[u]===" "||n[u]==="\t"))u++;let D=(n[u]===":"||n[u]==="?"&&n[u+1]===":")&&/[{;,(\n]/.test(v);R+=D?N:I}else R+=N;v="a",a=k;continue}if(R+=x,x===`
|
|
11
|
+
`||!/\s/.test(x))v=x;a++}return R}function vn(n,y,c,i){let f=[],h=new Map,S=[n,...y.filter((e)=>e!==n)];for(let e of S){let s=c.get(e);if(s===void 0){f.push(`No declarations were generated for ${W(i.cwd,e)}; it is left out of the bundle`);continue}h.set(e,F(e,s))}let l=(e,s)=>{if(!e.startsWith(".")&&!e.startsWith("/"))return null;let o=Z(e,s).resolved;return o&&h.has(o)?o:null},E=(e)=>e.startsWith(".")||e.startsWith("/"),R=new Set,a=(e)=>{let s=e;for(let o=1;R.has(s);o++)s=`${e}_${o}`;return R.add(s),s},w=new Map;for(let[e,s]of h){let o=new Map;for(let g of s.declared)o.set(g,a(g));w.set(e,o)}let v=new Map,m=(e,s,o)=>{let g=`${e}\x00${s}`,r=v.get(g);if(!r)r=a(o),v.set(g,r);return r},x=new Map,k=new Map,N=new Set,I=new Map,u=!0,D=(e,s,o)=>{let g=l(s,e.file);if(g){if(o==="*")return{kind:"namespace",file:g};let r=A(g).get(o);if(!r&&!u)f.push(`${W(i.cwd,e.file)}: '${o}' is not exported by '${s}'`);return r??null}if(E(s))return f.push(`${W(i.cwd,e.file)}: '${s}' is not part of the bundle`),null;return o==="*"?{kind:"external-namespace",source:s}:{kind:"external",source:s,imported:o}},ee=(e,s)=>{if(e.declared.has(s))return{kind:"local",name:w.get(e.file).get(s)};let o=e.imports.get(s);if(o)return D(e,o.specifier,o.imported);return f.push(`${W(i.cwd,e.file)}: cannot resolve exported name '${s}'`),null};function A(e){let s=x.get(e);if(s)return s;let o=new Map,g=h.get(e);if(!g||N.has(e))return o;N.add(e);let r=new Set;for(let[p,M]of g.localExports){let B=ee(g,M);if(B)o.set(p,B)}for(let p of g.namedReExports){let M=D(g,p.specifier,p.imported);if(M)o.set(p.exported,M)}for(let p of g.namespaceReExports){let M=D(g,p.specifier,"*");if(M)o.set(p.exported,M)}for(let p of g.starReExports){let M=l(p,e);if(M){for(let[B,C]of A(M))if(B!=="default"&&!o.has(B))o.set(B,C);for(let B of k.get(M)??[])r.add(B)}else if(E(p))f.push(`${W(i.cwd,e)}: '${p}' is not part of the bundle`);else r.add(p)}for(let[p,M]of I.get(e)??[])o.set(p,M);return N.delete(e),x.set(e,o),k.set(e,r),o}for(let[e,s]of h)for(let o of s.augmentations){let g=l(o.specifier,e);if(!g)continue;for(let r of F(e,o.body,!0).declared){if(A(g).has(r))continue;let p=I.get(g);if(!p)p=new Map,I.set(g,p);p.set(r,{kind:"local",name:a(r)}),x.clear()}}u=!1,x.clear(),k.clear();let U=new Map,H=[],T=(e,s)=>{switch(e.kind){case"local":return e.name;case"external":return m(e.source,e.imported,e.imported==="default"?s:e.imported);case"external-namespace":return m(e.source,"*",s);case"namespace":return te(e.file,s)}};function te(e,s){let o=U.get(e);if(o)return o;let g=a(s);U.set(e,g);let r=[];for(let[p,M]of A(e)){if(p==="default")continue;let B=T(M,p);r.push(B===p?p:`${B} as ${p}`)}if(k.get(e)?.size)f.push(`${W(i.cwd,e)}: 'export * from' an external module cannot be expressed inside namespace '${g}'`);return H.push(`declare namespace ${g} {
|
|
12
|
+
export { ${r.join(", ")} };
|
|
13
|
+
}`),g}let V=[],O=[],G=new Set;for(let[e,s]of h){for(let r of s.directives)G.add(r);let o=new Map;for(let[r,p]of w.get(e))if(r!==p)o.set(r,p);for(let[r,p]of s.imports){if(s.declared.has(r))continue;let M=D(s,p.specifier,p.imported);if(!M)continue;let B=T(M,r);if(B!==r)o.set(r,B)}let g=[];for(let r of s.declarations){if(i.keepComments)g.push(...r.statement.comments);let p=qe(r.emit,o);if(!/[;}]$/.test(p))p+=";";g.push(p)}for(let r of s.verbatim){if(i.keepComments)O.push(...r.comments);let p=Q(r.text);if(p){let M=new Map(o);for(let B of F(e,p.body,!0).declared)M.delete(B);O.push(r.text.slice(0,p.start)+qe(p.body,M)+r.text.slice(p.end))}else{let M=t(r.text),B=M[1]?.kind==="quoted"?d(r.text.slice(M[1].start,M[1].end)):void 0;if(B===void 0||!l(B,e))O.push(qe(r.text,o))}}for(let r of s.augmentations){let p=l(r.specifier,e),M=F(e,r.body,!0),B=new Map(o);if(!p){for(let J of M.declared)B.delete(J);let C=Q(r.statement.text);if(i.keepComments)O.push(...r.statement.comments);O.push(r.statement.text.slice(0,C.start)+qe(C.body,B)+r.statement.text.slice(C.end));continue}for(let[C,J]of A(p))B.set(C,T(J,C));if(i.keepComments)g.push(...r.statement.comments);for(let C of M.declarations){if(!C.name||!A(p).has(C.name))throw Error(`Cannot link augmentation '${r.specifier}' member '${C.name??C.emit}'`);if(i.keepComments)g.push(...C.statement.comments);g.push(qe(C.emit,B))}}if(g.length>0)V.push(`// From: ${W(i.cwd,e)}
|
|
14
|
+
${g.join(`
|
|
15
|
+
`)}`)}let X=A(n),K=[],q=[];for(let[e,s]of X){if(s.kind==="external"){q.push(`export { ${s.imported===e?e:`${s.imported} as ${e}`} } from '${s.source}';`);continue}if(s.kind==="external-namespace"){q.push(`export * as ${e} from '${s.source}';`);continue}let o=T(s,e==="default"?"_default":e);K.push(o===e?e:`${o} as ${e}`)}for(let e of k.get(n)??[])q.push(`export * from '${e}';`);let P=new Map;for(let[e,s]of v){let[o,g]=e.split("\x00"),r=P.get(o)??{named:[],defaults:[],namespaces:[]};if(P.set(o,r),g==="*")r.namespaces.push(s);else if(g==="default")r.defaults.push(s);else r.named.push(g===s?s:`${g} as ${s}`)}let _=[];for(let[e,s]of[...P].sort(([o],[g])=>o.localeCompare(g))){for(let o of s.defaults)_.push(`import ${o} from '${e}';`);for(let o of s.namespaces)_.push(`import * as ${o} from '${e}';`);if(s.named.length>0)_.push(`import { ${s.named.join(", ")} } from '${e}';`)}let L=[];if(G.size>0)L.push([...G].join(`
|
|
16
|
+
`));if(L.push(`/**
|
|
17
|
+
* Bundled TypeScript declarations
|
|
18
|
+
* Generated from ${h.size} source files
|
|
19
|
+
*/`),_.length>0)L.push(_.join(`
|
|
20
|
+
`));if(L.push(...V),H.length>0)L.push(H.join(`
|
|
21
|
+
`));if(O.length>0)L.push(O.join(`
|
|
22
|
+
`));let z=[];if(K.length>0)z.push(`export { ${K.join(", ")} };`);if(z.push(...q),z.length===0)z.push("export {};");return L.push(z.join(`
|
|
23
|
+
`)),{content:`${L.join(`
|
|
24
|
+
|
|
25
|
+
`)}
|
|
26
|
+
`,files:[...h.keys()],exportCount:X.size,warnings:f}}
|
|
27
|
+
export{Eo,qe,vn};
|
|
@@ -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-z6mpxpxt.js";import{be}from"./chunk-vae5wxar.js";import{readFileSync as u}from"fs";import{readFile as p}from"fs/promises";import{resolve as g}from"path";function m(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"").replace(/,\s*([}\]])/g,"$1")}function Ss(t,e){try{return{...JSON.parse(m(u(t,"utf8"))).compilerOptions,...e}}catch(s){throw Error(`Error reading tsconfig.json: ${s instanceof Error?s.message:String(s)}`)}}function f(t,e){let s=e.declarationsOnly?t.filter((o)=>o.endsWith(".d.ts")):t;if(e.include?.length){let o=e.include.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>o.some((i)=>i.test(n)))}if(e.exclude?.length){let o=e.exclude.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>!o.some((i)=>i.test(n)))}return s}async function dt(t,e={}){let s=performance.now(),o=f(t,e),n=[];for(let a of o)try{let c=await p(a,"utf8");for(let l of be(c))n.push({file:a,line:l.line,column:l.column,message:l.message,code:Number(l.code.slice(4)),severity:"error",category:"Error"})}catch(c){n.push({file:a,line:0,column:0,message:c instanceof Error?c.message:String(c),code:1000,severity:"error",category:"Error"})}let i=e.maxErrors?n.slice(0,e.maxErrors):n;return{success:i.length===0,diagnostics:i,errorCount:i.length,warningCount:0,infoCount:0,filesChecked:o,durationMs:performance.now()-s}}function Tr(t,e={}){return dt(t,{...e,declarationsOnly:!0})}async function $s(t){let e=new Map;for(let s of t){let o=await p(s,"utf8").catch(()=>""),n=[];for(let i of r(o,s,!1,!0))if(i.isExported&&i.kind==="function"&&!i.returnType)n.push({line:1,column:1,message:"Exported function requires an explicit return type",declarationName:i.name,missingAnnotation:"return"});e.set(s,{compatible:n.length===0,issues:n})}return e}function d(t,e,s){let o=t.split(`
|
|
3
|
+
`);if(e<1||e>o.length||s<1||s>o[e-1].length+1)return null;let n=s-1;for(let i=0;i<e-1;i++)n+=o[i].length+1;return n}function Ar(t,e,s){try{let o=u(t,"utf8"),n=d(o,e,s);if(n===null)return null;let i=r(o,t,!1).find((a)=>n>=(a.start??0)&&n<=(a.end??o.length));return i?.typeAnnotation??i?.returnType??i?.text??null}catch{return null}}function Es(t,e,s){let o=Ar(t,e,s);return o?{type:o}:null}function ks(t){if(t.success)return`\u2713 Type check passed (${t.filesChecked.length} files checked in ${t.durationMs}ms)`;return["\u2717 Type check failed",` ${t.errorCount} error(s), ${t.warningCount} warning(s)`,...t.diagnostics.map((e)=>`\u2717 ${e.file}:${e.line}:${e.column}
|
|
4
4
|
${e.message}`)].join(`
|
|
5
|
-
`)}function
|
|
6
|
-
export{
|
|
5
|
+
`)}function Ts(t){return dt(t.entrypoints.map((e)=>g(t.cwd,e)),{tsconfigPath:t.tsconfigPath,rootDir:t.root})}async function As(t,e){let o=(await Promise.all([dt(t),Tr(e)])).flatMap((n)=>n.diagnostics).map((n)=>({sourceName:n.file,sourceType:n.message,dtsType:"<invalid>"}));return{valid:o.length===0,mismatches:o}}
|
|
6
|
+
export{Ss,dt,Tr,$s,Ar,Es,ks,Ts,As};
|
|
@@ -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
|
|
3
|
-
export{
|
|
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 Ge(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 Gr(t,r={}){return t.map((e)=>Ge(e,r))}function an(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 Vr(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 Ur(t){try{return(await d(t)).isSymbolicLink()}catch{return!1}}async function zr(t,r={}){let e=r.followSymlinks??N.followSymlinks;if(await Ur(t)){if(!e)throw new C(`Symbolic links not allowed: "${t}"`,"SYMLINK_NOT_ALLOWED",t);let i=await f(t);return Ge(i,r)}return t}async function gt(t,r={}){let e=Ge(t,r);if(an(e,r))throw new C(`Path matches blocked pattern: "${t}"`,"BLOCKED_PATTERN",t);let i=await zr(e,r),n=await Vr(i,r);return{path:i,size:n}}async function cn(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 gt(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 ht(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 Hr(t,r={}){let e=r.timeout??N.timeout;return async(i)=>{let{path:n}=await gt(i,r);return ht(t(n),e,`Processing ${i}`)}}function Xs(t,r={}){let e=r.timeout??N.timeout;return async(i)=>{let{paths:n}=await cn(i,r);return ht(t(n),e,`Processing ${i.length} files`)}}function Zs(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 Qs(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 eo(t={}){let r={...N,...t};return{validatePath:(e)=>Ge(e,r),validatePaths:(e)=>Gr(e,r),validateFile:(e)=>gt(e,r),validateBatch:(e)=>cn(e,r),withTimeout:(e,i)=>ht(e,r.timeout,i),secureProcessor:(e)=>Hr(e,r),isBlocked:(e)=>an(e,r),getConfig:()=>r}}
|
|
3
|
+
export{N,C,Ge,Gr,an,Vr,Ur,zr,gt,cn,ht,Hr,Xs,Zs,Qs,eo};
|