@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{r}from"./chunk-
|
|
3
|
-
`)}function E(t){let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"import":if(t.isTypeOnly)e.push("import type");else e.push("import");if(t.specifiers&&t.specifiers.length>0){let s=t.specifiers.map((o)=>{let i=o.isType?"type ":"";return o.alias?`${i}${o.name} as ${o.alias}`:`${i}${o.name}`}).join(", ");e.push(`{ ${s} }`)}e.push("from"),e.push(`'${t.source}'`);break;case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${B(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let s of t.members)e.push(` ${s.name}${s.typeAnnotation?`: ${s.typeAnnotation}`:""}`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements?.length)e.push(`implements ${t.implements.join(", ")}`);e.push("{ }");break;case"enum":e.push("declare enum"),e.push(t.name),e.push("{ }");break;default:return t.text||""}return e.join(" ")}function B(t){if(!t)return"";return t.map((e)=>{let s="";if(e.rest)s+="...";if(s+=e.name,e.optional)s+="?";if(e.type)s+=`: ${e.type}`;return s}).join(", ")}function
|
|
4
|
-
export{
|
|
2
|
+
import{r}from"./chunk-z6mpxpxt.js";import{existsSync as g,readFileSync as h,writeFileSync as b}from"fs";function d(t){let e=[],s=/\b([A-Z][a-zA-Z0-9]*)\b/g,o;while((o=s.exec(t))!==null){let i=o[1];if(!D(i))e.push(i)}return[...new Set(e)]}function D(t){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(t)}function x(t){if(t.kind!=="type")return!1;let e=t.typeAnnotation||"";if(t.generics)return!1;if(e.includes("{")||e.includes("(")||e.includes("<"))return!1;return/^[\w\s|&]+$/.test(e)}function v(t){if(t.kind!=="interface")return!1;if(!t.members||t.members.length===0){if(!t.extends)return!0}return!1}function I(t,e){let s={...t,members:[...t.members||[],...e.members||[]],leadingComments:[...t.leadingComments||[],...e.leadingComments||[]]};if(t.extends&&e.extends){let o=t.extends.split(",").map((n)=>n.trim()),i=e.extends.split(",").map((n)=>n.trim());s.extends=[...new Set([...o,...i])].join(", ")}else s.extends=t.extends||e.extends;return s}function A(t){let e={import:0,interface:1,type:2,class:3,enum:4,function:5,variable:6,export:7};return[...t].sort((s,o)=>{let i=e[s.kind]??99,n=e[o.kind]??99;if(i!==n)return i-n;return s.name.localeCompare(o.name)})}function T(t){let e=[],s=[];for(let i=0;i<t.length;i++){let n=t[i];if(n.kind==="import")e.push(n);else s.push(n)}return[...[...e].sort((i,n)=>{let a=i.source||"",c=n.source||"",p=a.startsWith("node:")||a==="bun",m=c.startsWith("node:")||c==="bun";if(p&&!m)return-1;if(!p&&m)return 1;let l=!a.startsWith("."),u=!c.startsWith(".");if(l&&!u)return-1;if(!l&&u)return 1;return a.localeCompare(c)}),...s]}function S(t){let e=new Set;for(let i of t){if(i.kind==="import")continue;let n=i.text||"",a=i.typeAnnotation||"",c=i.returnType||"",p=i.extends||"",m=i.implements?.join(" ")||"",l=`${n} ${a} ${c} ${p} ${m}`;for(let u of d(l))e.add(u);if(i.members)for(let u of i.members){let f=`${u.typeAnnotation||""} ${u.returnType||""}`;for(let y of d(f))e.add(y)}if(i.parameters){for(let u of i.parameters)if(u.type)for(let f of d(u.type))e.add(f)}}let s=0;return{declarations:t.map((i)=>{if(i.kind!=="import"||!i.specifiers)return i;let n=i.specifiers.filter((a)=>{let c=a.alias||a.name;return e.has(c)});if(n.length===0){if(!i.isSideEffect)return s++,null}if(n.length<(i.specifiers?.length||0))return s+=(i.specifiers?.length||0)-n.length,{...i,specifiers:n};return i}).filter((i)=>i!==null),removed:s}}function k(t){let e=new Map,s=0;for(let o of t){if(o.kind==="import"){let n=`import:${o.source}`;if(e.has(n)){let a=e.get(n),c=[...a.specifiers||[],...o.specifiers||[]],p=Array.from(new Map(c.map((m)=>[m.alias||m.name,m])).values());e.set(n,{...a,specifiers:p}),s++}else e.set(n,o);continue}let i=`${o.kind}:${o.name}`;if(e.has(i))s++;else e.set(i,o)}return{declarations:Array.from(e.values()),removed:s}}function z(t){let e=new Map,s=[];for(let n of t)if(n.kind==="interface"){let a=n.name;if(!e.has(a))e.set(a,[]);e.get(a).push(n)}else s.push(n);let o=0,i=[];for(let[n,a]of e)if(a.length>1){let c=a[0];for(let p=1;p<a.length;p++)c=I(c,a[p]),o++;i.push(c)}else i.push(a[0]);return{declarations:[...s,...i],merged:o}}function w(t){let e=new Map,s=new Set;for(let n of t)if(x(n))e.set(n.name,n.typeAnnotation||""),s.add(n.name);if(e.size===0)return{declarations:t,inlined:0};function o(n){let a=n;for(let[c,p]of e){let m=new RegExp(`\\b${c}\\b`,"g");a=a.replace(m,p)}return a}return{declarations:t.filter((n)=>n.kind!=="type"||!s.has(n.name)).map((n)=>{if(n.typeAnnotation)n={...n,typeAnnotation:o(n.typeAnnotation)};if(n.returnType)n={...n,returnType:o(n.returnType)};if(n.extends)n={...n,extends:o(n.extends)};return n}),inlined:e.size}}function R(t){let e=t.length,s=t.filter((o)=>!v(o));return{declarations:s,removed:e-s.length}}function or(t,e={}){let s=[...t],o={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(e.removeUnusedImports){let{declarations:i,removed:n}=S(s);s=i,o.removedImports=n}if(e.deduplicateDeclarations){let{declarations:i,removed:n}=k(s);s=i,o.removedDeclarations+=n}if(e.mergeInterfaces){let{declarations:i,merged:n}=z(s);s=i,o.mergedInterfaces=n}if(e.removeEmptyInterfaces){let{declarations:i,removed:n}=R(s);s=i,o.removedDeclarations+=n}if(e.inlineSimpleTypes){let{declarations:i,inlined:n}=w(s);s=i,o.inlinedTypes=n}if(e.sortImports)s=T(s);if(e.sortDeclarations)s=A(s);return{declarations:s,result:o}}async function Pi(t,e={}){if(!g(t))throw Error(`File not found: ${t}`);let s=h(t,"utf-8"),o=Buffer.byteLength(s,"utf-8"),i=r(s,t,!e.removeComments),{declarations:n,result:a}=or(i,e),c=C(n,e);if(e.minify)c=ar(c);let p=Buffer.byteLength(c,"utf-8");return a.originalSize=o,a.optimizedSize=p,a.savings=o-p,a.savingsPercent=Math.round(a.savings/o*100),b(t,c),a}function C(t,e){let s=[];for(let o of t){if(!e.removeComments&&o.leadingComments)for(let i of o.leadingComments)s.push(i);if(o.text)s.push(o.text);else s.push(E(o));s.push("")}return s.join(`
|
|
3
|
+
`)}function E(t){let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"import":if(t.isTypeOnly)e.push("import type");else e.push("import");if(t.specifiers&&t.specifiers.length>0){let s=t.specifiers.map((o)=>{let i=o.isType?"type ":"";return o.alias?`${i}${o.name} as ${o.alias}`:`${i}${o.name}`}).join(", ");e.push(`{ ${s} }`)}e.push("from"),e.push(`'${t.source}'`);break;case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${B(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let s of t.members)e.push(` ${s.name}${s.typeAnnotation?`: ${s.typeAnnotation}`:""}`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements?.length)e.push(`implements ${t.implements.join(", ")}`);e.push("{ }");break;case"enum":e.push("declare enum"),e.push(t.name),e.push("{ }");break;default:return t.text||""}return e.join(" ")}function B(t){if(!t)return"";return t.map((e)=>{let s="";if(e.rest)s+="...";if(s+=e.name,e.optional)s+="?";if(e.type)s+=`: ${e.type}`;return s}).join(", ")}function ar(t){return t.replace(/(?<!\/\*\*)\/\/[^\n]*/g,"").replace(/^\s*[\r\n]/gm,"").replace(/ {2,}/g," ").replace(/\s*([{}[\]();,:])\s*/g,"$1").replace(/(\w)(\{)/g,"$1 $2").replace(/(\})([a-z])/gi,"$1 $2").replace(/(export|import|type|interface|class|function|const|let|var|extends|implements|declare)\s*/g,"$1 ").trim()}
|
|
4
|
+
export{or,Pi,ar};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{En}from"./chunk-9gp0e3kn.js";var g=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"]);function f(e,o={strings:!0}){let c="",n=0;while(n<e.length){let t=e.slice(n,n+2);if(t==="//"){let s=e.indexOf(`
|
|
3
3
|
`,n),a=s===-1?e.length:s;c+=" ".repeat(a-n),n=a;continue}if(t==="/*"){let s=e.indexOf("*/",n+2),a=s===-1?e.length:s+2;for(let r=n;r<a;r++)c+=e[r]===`
|
|
4
4
|
`?`
|
|
5
5
|
`:" ";n=a;continue}let i=e[n];if(o.strings&&(i==='"'||i==="'"||i==="`")){let s=i;c+=" ",n++;while(n<e.length){if(e[n]==="\\"){c+=" ",n+=2;continue}if(e[n]===s){c+=" ",n++;break}c+=e[n]===`
|
|
6
6
|
`?`
|
|
7
|
-
`:" ",n++}continue}c+=i,n++}return c}function m(e){let o=new Set,c=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let n of c)for(let t of e.matchAll(n))o.add(t[1]);return o}function d(e){let o=new Set;for(let c of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=c[1],t=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(t)o.add(t[1]);let i=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of i.split(",")){let r=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(r))o.add(r)}let s=/\{([\s\S]*?)\}/.exec(n);if(s)for(let a of s[1].split(",")){let r=a.trim().replace(/^type\s+/,"");if(!r)continue;let l=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(r);o.add(l?l[1]:r.split(/\s+/)[0])}}for(let c of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))o.add(c[1]);return o}function p(e){let o=new Set,c=(t)=>{for(let i of t.split(",")){let s=i.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))o.add(s)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let t of e.matchAll(n))c(t[1]);for(let t of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))c(t[1]);for(let t of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))o.add(t[1]);for(let t of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))o.add(t[1]);return o}function h(e){let o=new Map,c=(t)=>{let i=1;for(let s=0;s<t&&s<e.length;s++)if(e.charCodeAt(s)===10)i++;return i},n=(t,i,s)=>{for(let a of t.matchAll(/\b([A-Z][\w$]*)\b/g)){let r=a[1];if(o.has(r))continue;let l=t.slice(a.index+r.length);if(/^\s*\??:/.test(l))continue;o.set(r,{line:c(i),context:s.trim().slice(0,120)})}};for(let t of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(t[1],t.index+t[0].indexOf("="),t[0]);for(let t of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/<([^<>()]*)>/g))n(t[1],t.index,t[0]);return o}function
|
|
8
|
-
export{
|
|
7
|
+
`:" ",n++}continue}c+=i,n++}return c}function m(e){let o=new Set,c=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let n of c)for(let t of e.matchAll(n))o.add(t[1]);return o}function d(e){let o=new Set;for(let c of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=c[1],t=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(t)o.add(t[1]);let i=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of i.split(",")){let r=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(r))o.add(r)}let s=/\{([\s\S]*?)\}/.exec(n);if(s)for(let a of s[1].split(",")){let r=a.trim().replace(/^type\s+/,"");if(!r)continue;let l=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(r);o.add(l?l[1]:r.split(/\s+/)[0])}}for(let c of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))o.add(c[1]);return o}function p(e){let o=new Set,c=(t)=>{for(let i of t.split(",")){let s=i.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))o.add(s)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let t of e.matchAll(n))c(t[1]);for(let t of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))c(t[1]);for(let t of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))o.add(t[1]);for(let t of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))o.add(t[1]);return o}function h(e){let o=new Map,c=(t)=>{let i=1;for(let s=0;s<t&&s<e.length;s++)if(e.charCodeAt(s)===10)i++;return i},n=(t,i,s)=>{for(let a of t.matchAll(/\b([A-Z][\w$]*)\b/g)){let r=a[1];if(o.has(r))continue;let l=t.slice(a.index+r.length);if(/^\s*\??:/.test(l))continue;o.set(r,{line:c(i),context:s.trim().slice(0,120)})}};for(let t of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(t[1],t.index+t[0].indexOf("="),t[0]);for(let t of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/<([^<>()]*)>/g))n(t[1],t.index,t[0]);return o}function $n(e){let o=f(e),c=f(e,{strings:!1}),n=new Set([...m(o),...d(c),...p(o),...En,...g]),t=[];for(let[i,s]of h(o)){if(n.has(i))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${i}\\b`).test(o))continue;t.push({name:i,line:s.line,context:s.context})}return t.sort((i,s)=>i.line-s.line||i.name.localeCompare(s.name))}
|
|
8
|
+
export{$n};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,F}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{t,F}from"./chunk-c7a07a26.js";import{er}from"./chunk-kccc6p2t.js";function rt(o){let f=t(o);if(f.length!==1||f[0].kind!=="word")return;let l=o.slice(f[0].start,f[0].end);return["true","false","null","undefined","this","super"].includes(l)?void 0:l}function Lt(o){let f=t(o);if(f.length===0)return!0;let l=f[f.length-1],s=o.slice(l.start,l.end);if(l.kind==="word"&&(s==="is"||s==="extends"))return!0;if(s==="|"||s==="&")return!0;let n=f[f.length-2];return s===">"&&n!==void 0&&o.slice(n.start,n.end)==="="}function j(o){return w(o,F(o))}function Hn(o){for(let f=1024;f<o.length;f*=8){let l=o.slice(0,f),s=v(l,t(l),f);if(s!==void 0)return s}return w(o,t(o))}function w(o,f){return v(o,f,1/0)??!1}function v(o,f,l){let s=0;for(let n=0;n<f.length;n++){let a=f[n];if(a.end>=l)return;if(a.kind==="punctuation"){let d=o.charCodeAt(a.start);if(d===123||d===40||d===91)s++;else if(d===125||d===41||d===93)s--;continue}if(s!==0||a.kind!=="word"||a.end-a.start!==6)continue;let c=o.slice(a.start,a.end);if(c==="export")return!0;if(c==="import"){let d=f[n+1];if(d===void 0?l!==1/0:d.end>=l)return;let x=d?o.slice(d.start,d.end):"";if(x!=="("&&x!==".")return!0}}return l===1/0?!1:void 0}function Kn(o){if(o.isExported)return!1;if(["function","variable","interface","type","class","enum","namespace"].includes(o.kind))return!0;return o.kind==="module"&&(o.moduleForm==="namespace"||o.moduleForm==="identifier")}function qn(o,f){let l=o.text,s=t(l),n=(i)=>s[i]?l.slice(s[i].start,s[i].end):"",a=(i)=>s[i]?.kind==="word",c=new Map,d=[];for(let i=0;i<s.length;i++){let e=n(i);if(e==="("||e==="["||e==="{"||e==="<")d.push(i);else if(e===")"||e==="]"||e==="}"||e===">"&&n(i-1)!=="="){let r=d.at(-1);if(r!==void 0&&(n(r)==="("&&e===")"||n(r)==="["&&e==="]"||n(r)==="{"&&e==="}"||n(r)==="<"&&e===">"))d.pop(),c.set(r,i)}}let x=[];for(let i=0;i<s.length;i++){if(n(i)!=="(")continue;let e=c.get(i);if(e===void 0||!(n(e+1)===":"||n(e+1)==="="&&n(e+2)===">"))continue;let r=new Set,u=i+1;while(u<e){let m=u;while(m<e&&n(m)!==","){let b=c.get(m);if(b!==void 0)m=b+1;else m++}let g=u;while(g<m&&n(g)!==":"&&n(g)!=="="){let b=c.get(g);if(b!==void 0)g=b+1;else g++}let h=u;while([".","public","private","protected","readonly","override"].includes(n(h)))h++;if(n(h)==="{"||n(h)==="[")for(let b of er(l.slice(s[h].start,s[g-1].end)))r.add(b);else if(a(h))r.add(n(h));u=m+1}let p=e+(n(e+1)===":"?2:3);while(p<s.length){if([";",",",")","]","}"].includes(n(p))||n(p)===">"&&n(p-1)!=="=")break;let m=c.get(p);if(m!==void 0)p=m+1;else p++}x.push({start:i,end:p,names:r})}let y=(i)=>{if(!a(i))return;let e=n(i);if(!x.some((r)=>i>=r.start&&i<r.end&&r.names.has(e)))f.add(e)},k=(i,e)=>{for(let r=i;r<e;r++){if(n(r)==="<"&&c.has(r)){r=c.get(r);continue}if(!a(r)||n(r-1)==="."||n(r+1)===":")continue;if(["true","false","null","undefined","new","this","super","as","satisfies","typeof","void","keyof"].includes(n(r)))continue;y(r)}};for(let i=0;i<s.length;i++){if(n(i)==="typeof")y(i+1);if(n(i)==="export"){let e=i+1;if(n(e)==="default"){if(!["function","class","abstract"].includes(n(e+1)))k(e+1,s.length);continue}if(n(e)==="type")e++;if(n(e)==="{"){let r=c.get(e);if(r===void 0||n(r+1)==="from")continue;for(let u=e+1;u<r;){if(n(u)==="type"&&a(u+1)&&n(u+1)!=="as")u++;y(u);while(u<r&&n(u)!==",")u++;u++}}}if(n(i)==="["){let e=c.get(i);if(e!==void 0&&[":","?","("].includes(n(e+1))&&n(i+2)!==":"&&n(i+2)!=="in")k(i+1,e)}}if(o.kind==="class"){let i=-1;for(let e=0;e<s.length&&n(e)!=="{";e++)if(n(e)==="<"&&c.has(e))e=c.get(e);else if(n(e)==="extends"){i=e;break}if(i!==-1){let e=i+1;while(e<s.length&&n(e)!=="{"&&n(e)!=="implements"){let r=c.get(e);if(r!==void 0)e=r+1;else e++}k(i+1,e)}}}
|
|
3
|
+
export{rt,Lt,j,Hn,Kn,qn};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{f,ue}from"./chunk-a3apthex.js";import{Ft,Nt,n,Me,_}from"./chunk-qq5x44y9.js";function g(t){if(t.includes(`
|
|
3
|
+
`))return`/**
|
|
4
|
+
* ${t}
|
|
5
|
+
*/
|
|
6
|
+
`;return`/** ${t} */
|
|
7
|
+
`}function D(t){let o=t.indexOf("{");if(o===-1)return-1;let s=t.indexOf("<");if(s===-1||s>o)return o;let e=0,r=!1,a="";for(let i=0;i<t.length;i++){let l=t[i],u=i>0?t[i-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,a=l;else if(r&&l===a&&u!=="\\")r=!1;if(!r){if(l==="<")e++;else if(l===">")e--;else if(l==="{"&&e===0)return i}}return-1}function ne(t,o=!0){return f(t.leadingComments,o)+t.text}function h(t,o=!0){if(t.inferenceError)throw Object.assign(Error(`Cannot infer alias '${t.name}': unsupported source value flow`),{code:t.inferenceError});let s=f(t.leadingComments,o);if(!t.typeAnnotation&&t.inferredType)return s+t.text;if(t.typeAnnotation&&!t.value)return s+t.text;let e="";if(t.isExported)e+="export ";e+="declare ";let r=t.modifiers?.[0]||"const";e+=`${r} `,e+=t.name;let{typeAnnotation:a,value:i}=t,l=!a&&i?_(i):null;if(l)a=l;else if(!a&&i&&i.trim().endsWith("as const"))a=n(i,!0,!1,0,t.computedKeyConstants);else if(!a&&i&&r==="const"){let c=i.trim(),m=c.startsWith("{")||c.startsWith("[");if(m)Ft();a=n(i,!m,!1,0,t.computedKeyConstants)}else if(!a&&i)a=n(i,r==="const",!1,0,t.computedKeyConstants);if(!a)a="unknown";let u="";if(o&&i&&!t.typeAnnotation&&!i.trim().endsWith("as const")){let c=i.trim();if(r!=="const"){if((a==="string"||a==="number"||a==="boolean")&&c.length>0)u=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let m=Nt();if(m)if(m.includes(`
|
|
8
|
+
`))u=`@defaultValue
|
|
9
|
+
* \`\`\`ts
|
|
10
|
+
${m.split(`
|
|
11
|
+
`).map((p)=>` * ${p}`).join(`
|
|
12
|
+
`)}
|
|
13
|
+
* \`\`\``;else u=`@defaultValue \`${m}\``}}else if(o&&i&&t.typeAnnotation&&Me(t.typeAnnotation)){Ft();let c=i.trim(),m=c.endsWith("as const")?c.slice(0,-8).trim():c;n(m,!1,!1,0,t.computedKeyConstants);let x=Nt();if(x)if(x.includes(`
|
|
14
|
+
`))u=`@defaultValue
|
|
15
|
+
* \`\`\`ts
|
|
16
|
+
${x.split(`
|
|
17
|
+
`).map((d)=>` * ${d}`).join(`
|
|
18
|
+
`)}
|
|
19
|
+
* \`\`\``;else u=`@defaultValue \`${x}\``}if(u=ue(u),e+=`: ${a};`,u&&s&&s.includes("@defaultValue"))u="";if(u&&s){let c=s.trimEnd(),m=c.lastIndexOf("*/");if(m!==-1){let p=c.slice(0,m).trimEnd();if(p.startsWith("/** ")&&!p.includes(`
|
|
20
|
+
`))p=`/**
|
|
21
|
+
* ${p.slice(4)}`;return`${p}
|
|
22
|
+
* ${u}
|
|
23
|
+
*/
|
|
24
|
+
`+e}return`/**
|
|
25
|
+
* ${c.replace(/^\/\/\s*/,"")}
|
|
26
|
+
* ${u}
|
|
27
|
+
*/
|
|
28
|
+
${e}`}if(u)return`${g(u)}${e}`;return s+e}function re(t,o=!0){let s=f(t.leadingComments,o),e=t.text;if(e.startsWith("export declare interface")||e.startsWith("declare interface"))return s+e;let r="";if(t.isExported)r+="export ";if(r+="declare interface ",r+=t.name,t.generics)r+=t.generics;if(t.extends)r+=` extends ${t.extends}`;let a=D(t.text);if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}function ie(t,o=!0){let s=f(t.leadingComments,o);if(t.text.includes("{")&&t.text.includes("}")&&t.text.includes("from"))return s+t.text;let e="";if(t.isExported)e+="export ";if(!t.isExported&&!t.text.includes(" from "))e+="declare ";let r=t.text.indexOf("type ");if(r!==-1){let i=t.text.slice(r),l=i.length;while(l>0&&(i.charCodeAt(l-1)===59||i.charCodeAt(l-1)===32||i.charCodeAt(l-1)===10||i.charCodeAt(l-1)===13))l--;if(l<i.length)i=i.slice(0,l);e+=i}else{if(e+=`type ${t.name}`,t.generics)e+=t.generics;e+=" = any"}let a=e.trimEnd();if(!a.endsWith(";")&&!a.endsWith("}"))e+=";";return s+e}function se(t,o=!0){return f(t.leadingComments,o)+t.text}function oe(t,o=!0){let s=f(t.leadingComments,o),e="";if(t.isExported)e+="export ";if(e+="declare ",t.modifiers?.includes("const"))e+="const ";e+="enum ",e+=t.name;let r=t.text.indexOf("{");if(r!==-1)e+=` ${t.text.slice(r)}`;else e+=" {}";return s+e}function Wn(t){let o=t.text.trim(),s=o.length;while(s>0&&o.charCodeAt(s-1)===59)s--;if(s<o.length)o=o.slice(0,s);return o+=";",o}function jn(t,o=!0){return f(t.leadingComments,o)+t.text.trim()}function ae(t,o=!0){let s=f(t.leadingComments,o);if(t.text.startsWith("declare global"))return s+t.text;if(t.source||(t.name.startsWith('"')||t.name.startsWith("'")||t.name.startsWith("`"))){let i="declare module ";i+=t.name;let l=t.text.indexOf("{");if(l!==-1)i+=` ${t.text.slice(l)}`;else i+=" {}";return s+i}let r="";if(t.isExported)r+="export ";if(!t.modifiers?.includes("declare"))r+="declare ";r+="namespace ",r+=t.name;let a=t.text.indexOf("{");if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}
|
|
29
|
+
export{ne,h,re,ie,se,oe,Wn,jn,ae};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{u}from"./chunk-ayyb1jpe.js";import{e}from"./chunk-btc6zbyj.js";import{x,m}from"./chunk-c7a07a26.js";import{Q}from"./chunk-vf8jmdsp.js";import{existsSync as T,readFileSync as N,realpathSync as w,statSync as X}from"fs";import{builtinModules as F}from"module";import{dirname as I,extname as V,isAbsolute as A,join as J,relative as C,resolve as O}from"path";var B=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],z={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};function j(t){try{return X(t).isFile()}catch{return!1}}function Z(t,i){let s=t.replace(/[?#].*$/,"");if(!(s.startsWith("./")||s.startsWith("../")||s==="."||s==="..")&&!A(s))return{resolved:null,isRelative:!1};let a=I(i),c=O(a,s);if(j(c))return{resolved:c,isRelative:!0};let p=V(c),d=z[p];if(d){let f=c.slice(0,-p.length);for(let r of d){let o=f+r;if(j(o))return{resolved:o,isRelative:!0}}}for(let f of B){let r=c+f;if(j(r))return{resolved:r,isRelative:!0}}if(T(c))for(let f of B){let r=J(c,`index${f}`);if(j(r))return{resolved:r,isRelative:!0}}return{resolved:null,isRelative:!0}}function K(t,i){let s=t.indexOf("*");return s===-1?i===t:i.startsWith(t.slice(0,s))&&i.endsWith(t.slice(s+1))&&i.length>=t.length-1}function L(t,i){if(Object.hasOwn(t,i))return t[i]!==null;let s=Object.keys(t).filter((l)=>l.includes("*")&&K(l,i)).sort((l,a)=>a.indexOf("*")-l.indexOf("*")||a.length-l.length)[0];return s!==void 0&&t[s]!==null}function D(t,i){if(!t.name||i!==t.name&&!i.startsWith(`${t.name}/`))return!1;if(t.exports===void 0)return!0;let s=i===t.name?".":`.${i.slice(t.name.length)}`;if(typeof t.exports==="string"||Array.isArray(t.exports))return s===".";if(!t.exports||typeof t.exports!=="object")return!1;let l=t.exports;if(!Object.keys(l).some((c)=>c.startsWith(".")))return s===".";return L(l,s)}function W(t,i){let s=C(t,i);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!A(s)}async function Ee(t){let i=await Q(O(t.cwd,t.tsconfigPath||"tsconfig.json")),s=Object.entries(i?.paths??{});if(s.length===0){let r=(o,n)=>Z(o,n);return r.cacheKey=(o)=>JSON.stringify(o.map((n)=>({file:n,references:k(N(n,"utf8"),{includeImports:!0}).map((g)=>({specifier:g.specifier,resolution:r(g.specifier,n)}))}))),r}let l=i?.baseUrl??i?.pathsBasePath??t.cwd,a=O(t.cwd,t.root),c=new Map,p=new Set([...F,"bun"]),d=(r)=>{let o=I(r),n=[];while(!0){if(c.has(o)){let R=c.get(o);for(let b of n)c.set(b,R);return R}n.push(o);let g=J(o,"package.json");if(T(g)){let b={...JSON.parse(N(g,"utf8")),directory:w(o)};for(let E of n)c.set(E,b);return b}let v=I(o);if(v===o)return;o=v}},f=(r,o)=>{if(r.startsWith(".")||A(r))return Z(r,o);if(r.startsWith("node:")||r.startsWith("bun:")||p.has(r))return{resolved:null,isRelative:!1};let n=d(o),g=r.startsWith("@")?/^@[^/]+\/[^/]+/.exec(r)?.[0]:r.split("/")[0];if(n&&(D(n,r)||L(n.imports??{},r)||g&&[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies].some((h)=>Object.hasOwn(h??{},g))))return{resolved:null,isRelative:!1};let v=s.filter(([h])=>K(h,r)).sort(([h],[S])=>{if(!h.includes("*"))return-1;if(!S.includes("*"))return 1;return S.indexOf("*")-h.indexOf("*")})[0];if(!v)return{resolved:null,isRelative:!1};let[R,b]=v,E=R.indexOf("*"),_=E===-1?"":r.slice(E,r.length-(R.length-E-1));for(let h of b){let S=O(l,h.replace("*",_)),M=d(S);if(M&&D(M,r)&&!M.private&&M.directory!==n?.directory)return{resolved:null,isRelative:!1};let P=Z(S,o);if(!P.resolved)continue;let y=w(P.resolved),q=t.outputStructure==="flat"||T(a)&&W(w(a),y);if(!n||!W(n.directory,y)||!q||d(y)?.directory!==n.directory||/\.d\.(?:ts|mts|cts)$/.test(y))throw Error(`Local alias ${JSON.stringify(r)} from ${o} resolves outside its emitted package source: ${y}`);return e.debug(`Resolved local declaration alias ${r} from ${o} to ${y}`),{resolved:t.outputStructure==="flat"?P.resolved:O(a,C(w(a),y)),isRelative:!0,isAlias:!0,suffix:S.match(/[?#].*$/)?.[0]??""}}throw Error(`Cannot resolve local alias ${JSON.stringify(r)} from ${o} using ${t.tsconfigPath||"tsconfig.json"} (${JSON.stringify(R)})`)};return f.isPackageLocal=(r,o)=>{let n=d(r);return!!n&&d(o)?.directory===n.directory&&W(n.directory,w(o))},f.cacheKey=(r)=>{let o=r.map((g)=>({file:g,references:k(N(g,"utf8"),{includeImports:!0}).map((v)=>({specifier:v.specifier,resolution:f(v.specifier,g)}))})),n=[...new Set(c.values())].filter((g)=>g!==void 0).sort((g,v)=>g.directory.localeCompare(v.directory));return JSON.stringify({root:a,compilerOptions:i,packages:n,edges:o})},f}function k(t,i={}){let s=m(t);return(i.includeImports?["export","static-import","import-type","augmentation"]:["export"]).flatMap((a)=>s.filter((c)=>c.category===a).map(({specifier:c,kind:p,isTypeOnly:d})=>({specifier:c,kind:p,isTypeOnly:d})))}function Pn(t,i){let s=[];for(let a of m(t)){let c=i(a.specifier);if(c!==a.specifier)s.push({start:a.start,end:a.end,value:x(c,t[a.start])})}let l=t;for(let a of s.reverse())l=l.slice(0,a.start)+a.value+l.slice(a.end);return l}async function U(t,i={}){let s=new Set,l=new Map,a=[],c=new Map,p=[];for(let d of t){let f=O(d);if(!s.has(f))s.add(f),p.push(f)}while(p.length>0){let d=p.shift(),f;try{f=await u(d)}catch{continue}c.set(d,f);let r=k(f,i);l.set(d,r);for(let o of r){let n=(i.resolveSpecifier??Z)(o.specifier,d);if(!n.isRelative)continue;if(n.resolved){if(!s.has(n.resolved))s.add(n.resolved),p.push(n.resolved)}else a.push({from:d,specifier:o.specifier,isTypeOnly:o.isTypeOnly})}}return{reachable:s,reExports:l,unresolved:a,sources:c}}
|
|
3
|
+
export{Z,Ee,k,Pn,U};
|
|
@@ -14,5 +14,5 @@ var d=null,m=null;async function P(){if(d!==null)return d;try{return m=await imp
|
|
|
14
14
|
`),s=[],a=[],i=!1,u=0;for(let o=0;o<n.length;o++){let t=n[o],p=t.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(p){i=!0,u=o;let c=p[1];s.push({line:t,source:p[2],isType:c.startsWith("import type ")||c.startsWith("import type\t")})}else if(i&&t.trim()==="")continue;else{if(i)i=!1;a.push(t)}}if(s.length===0)return r;if(e.sort)s.sort((o,t)=>{if(o.isType!==t.isType)return o.isType?1:-1;return M(o.source,t.source)});let l;if(e.group){let o=[],t=[],p=[],c=[],b=[];for(let f=0;f<s.length;f++){let g=s[f],h=g.source;if(h.charCodeAt(0)===46)b.push(g);else if(h.startsWith("node:"))o.push(g);else if(h.charCodeAt(0)===64)c.push(g);else if(h.includes("/"))p.push(g);else t.push(g)}l=[...o.map((f)=>f.line),...o.length>0&&t.length>0?[""]:[],...t.map((f)=>f.line),...(o.length>0||t.length>0)&&p.length>0?[""]:[],...p.map((f)=>f.line),...c.length>0&&(o.length>0||t.length>0||p.length>0)?[""]:[],...c.map((f)=>f.line),...b.length>0?[""]:[],...b.map((f)=>f.line)]}else l=s.map((o)=>o.line);return[...l,"",...a].join(`
|
|
15
15
|
`)}function M(r,e){let n=r.startsWith("node:"),s=e.startsWith("node:");if(n!==s)return n?-1:1;let a=r.startsWith("."),i=e.startsWith(".");if(a!==i)return a?1:-1;return r.localeCompare(e)}function W(r,e,n){let s=r.split(`
|
|
16
16
|
`),a=[];for(let i of s){if(i.length<=e){a.push(i);continue}if(i.trimStart().startsWith("import ")){a.push(i);continue}let u=i.match(/^(\s*)/)?.[1]||"",l=u+n,o=O(i,u,l);if(o){a.push(...o);continue}if(i.includes("{")&&i.includes("}")){let t=v(i,e,u,l);a.push(...t);continue}if(i.includes(" | ")){let t=R(i,e,u,l);a.push(...t);continue}a.push(i)}return a.join(`
|
|
17
|
-
`)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(r,e,n){let s=r.match(F);if(!s)return null;let[,a,i,u,l]=s,o=u.split(",").map((c)=>c.trim()).filter(Boolean);if(o.length<=1)return[r];let t=`${e}${a}${i??""} {`,p=l?`${e}} ${l};`:`${e}};`;return[t,...o.map((c)=>`${n}${c},`),p]}function v(r,e,n,s){let a=r.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!a)return[r];let[,,i,u,l,o]=a,t=l.split(/;\s*|,\s*/).filter((c)=>c.trim());if(t.length<=1)return[r];return[`${n}${i}${u}`,...t.map((c)=>`${s}${c.trim()};`),`${n}${o.trim()}`]}function R(r,e,n,s){let a=r.match(/^(\s*)(.*?=\s*)(.+)$/);if(!a)return[r];let[,,i,u]=a,l=u.split(/\s*\|\s*/).filter((t)=>t.trim());if(l.length<=2)return[r];return[`${n}${i}`,...l.map((t,p)=>`${s}${p>0?"| ":" "}${t.trim()}`)]}async function
|
|
18
|
-
export{
|
|
17
|
+
`)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(r,e,n){let s=r.match(F);if(!s)return null;let[,a,i,u,l]=s,o=u.split(",").map((c)=>c.trim()).filter(Boolean);if(o.length<=1)return[r];let t=`${e}${a}${i??""} {`,p=l?`${e}} ${l};`:`${e}};`;return[t,...o.map((c)=>`${n}${c},`),p]}function v(r,e,n,s){let a=r.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!a)return[r];let[,,i,u,l,o]=a,t=l.split(/;\s*|,\s*/).filter((c)=>c.trim());if(t.length<=1)return[r];return[`${n}${i}${u}`,...t.map((c)=>`${s}${c.trim()};`),`${n}${o.trim()}`]}function R(r,e,n,s){let a=r.match(/^(\s*)(.*?=\s*)(.+)$/);if(!a)return[r];let[,,i,u]=a,l=u.split(/\s*\|\s*/).filter((t)=>t.trim());if(l.length<=2)return[r];return[`${n}${i}`,...l.map((t,p)=>`${s}${p>0?"| ":" "}${t.trim()}`)]}async function H(r,e={},n){let s=[];if(e.usePrettier!==!1){if(await P())try{let l={...await y(e.prettierConfigPath,n),...e.prettierOptions,parser:"typescript"};return{content:await w(r,l),usedPrettier:!0}}catch(u){s.push(`Prettier formatting failed: ${u}. Using built-in formatter.`)}else if(e.usePrettier===!0)s.push("Prettier requested but not available. Using built-in formatter.")}return{content:C(r,e.builtIn),usedPrettier:!1,warnings:s.length>0?s:void 0}}async function Xr(r,e={}){let n=new Map;for(let[s,a]of r){let i=await H(a,e,s);n.set(s,i)}return n}function so(r={}){return{format:(e,n)=>H(e,r,n),formatMany:(e)=>Xr(e,r)}}async function oo(r){return(await H(r,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}
|
|
18
|
+
export{H,Xr,so,oo};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{e}from"./chunk-
|
|
2
|
+
import{e}from"./chunk-btc6zbyj.js";import{existsSync as h}from"fs";import{cpus as u}from"os";import{resolve as l}from"path";import{fileURLToPath as k}from"url";import{Worker as c}from"worker_threads";var __dirname="/home/runner/work/dtsx/dtsx/packages/dtsx/src",a;function f(){if(a!==void 0)return a;a=null;for(let t of["./worker-thread.js","./worker-thread.ts","./src/worker-thread.js","./src/worker-thread.ts"]){let r=new URL(t,import.meta.url);try{if(h(k(r))){a=r;break}}catch{}}return a}class Vt{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(t={}){let r=t.maxWorkers??Math.max(1,u().length-1);this.config={maxWorkers:r,taskTimeout:t.taskTimeout??30000,recycleAfter:t.recycleAfter??100,idleTimeout:t.idleTimeout??1e4,initialWorkers:t.initialWorkers??Math.min(2,r)}}async init(){let t=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let r=0;r<t;r++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let t=`
|
|
3
3
|
const { parentPort } = require('worker_threads');
|
|
4
4
|
const bun = typeof Bun !== 'undefined' ? Bun : null;
|
|
5
5
|
const fs = bun ? null : require('node:fs');
|
|
@@ -173,5 +173,5 @@ catch (error) {
|
|
|
173
173
|
const result = await processTask(task);
|
|
174
174
|
parentPort.postMessage(result);
|
|
175
175
|
});
|
|
176
|
-
`,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function
|
|
177
|
-
export{
|
|
176
|
+
`,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function hr(t={}){return new Vt(t)}async function ts(t,r={},o={}){let s=hr(o);await s.init();try{return await s.processFiles(t,r)}finally{await s.shutdown()}}function ns(t,r){let o=[];for(let s=0;s<t.length;s+=r)o.push(t.slice(s,s+r));return o}function rs(t,r=u().length){if(t<=r)return 1;let s=r*3;return Math.max(1,Math.ceil(t/s))}
|
|
177
|
+
export{Vt,hr,ts,ns,rs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function c(t){return t>=65&&t<=90||t>=97&&t<=122||t===95||t===36||t>127}function i(t){return c(t)||t>=48&&t<=57}function L(t,_){let n=_;for(;;){while(n>=0&&(t.charCodeAt(n)===32||t.charCodeAt(n)===9||t.charCodeAt(n)===10||t.charCodeAt(n)===13))n--;if(n<0)return-1;if(t.charCodeAt(n)===47&&n>0&&t.charCodeAt(n-1)===42){let C=t.lastIndexOf("/*",n-2);if(C===-1)return-1;n=C-1;continue}let r=t.lastIndexOf(`
|
|
3
3
|
`,n)+1,o=E(t,r,n);if(o!==-1){n=o-1;continue}return n}}function E(t,_,n){let r=0;for(let o=_;o<=n;o++){let C=t.charCodeAt(o);if(r){if(C===92){o++;continue}if(C===r)r=0;continue}if(C===39||C===34||C===96){r=C;continue}if(C===47&&o+1<=n&&t.charCodeAt(o+1)===47)return o}return-1}function u(t){return t===61||t===40||t===91||t===33||t===38||t===124||t===63||t===58||t===44||t===59||t===123||t===125||t===94||t===126||t===43||t===45||t===42||t===37||t===60||t===62}function R(t){return t==="return"||t==="typeof"||t==="void"||t==="delete"||t==="throw"||t==="new"||t==="in"||t==="of"||t==="case"||t==="instanceof"||t==="yield"||t==="await"||t==="else"||t==="do"}function b(t,_){let n=[],r=[],o=0,C=!1,l="",s="",S=!0,e=0,f=(H,A=!1)=>{s=l,l=H,S=A};while(e<=_){let H=t.charCodeAt(e);if(C){if(H===92){e+=2;continue}if(H===96)C=!1,f("literal");else if(H===36&&t.charCodeAt(e+1)===123)r.push(o++),C=!1,f("{",!0),e++;e++;continue}if(H===32||H===9||H===10||H===13){e++;continue}if(H===47&&t.charCodeAt(e+1)===47){let A=t.indexOf(`
|
|
4
|
-
`,e+2);e=A===-1?t.length:A+1;continue}if(H===47&&t.charCodeAt(e+1)===42){let A=t.indexOf("*/",e+2);e=A===-1?t.length:A+2;continue}if(H===39||H===34){let A=H;e++;while(e<t.length){let a=t.charCodeAt(e++);if(a===92)e++;else if(a===A)break}f("literal");continue}if(H===96){C=!0,e++;continue}if(c(H)||H===35&&c(t.charCodeAt(e+1))){let A=e++;while(i(t.charCodeAt(e)))e++;let a=t.slice(A,e);f(a,l!=="."&&R(a));continue}if(H===40){let A=s!=="."&&(l==="if"||l==="while"||l==="for"||l==="with"||l==="switch"||l==="catch"||l==="await"&&s==="for");n.push(A),f("(",!0)}else if(H===41){let A=n.pop()??!1;if(e===_)return A;f(")",A)}else if(H===47&&S){e=
|
|
5
|
-
export{c,i,
|
|
4
|
+
`,e+2);e=A===-1?t.length:A+1;continue}if(H===47&&t.charCodeAt(e+1)===42){let A=t.indexOf("*/",e+2);e=A===-1?t.length:A+2;continue}if(H===39||H===34){let A=H;e++;while(e<t.length){let a=t.charCodeAt(e++);if(a===92)e++;else if(a===A)break}f("literal");continue}if(H===96){C=!0,e++;continue}if(c(H)||H===35&&c(t.charCodeAt(e+1))){let A=e++;while(i(t.charCodeAt(e)))e++;let a=t.slice(A,e);f(a,l!=="."&&R(a));continue}if(H===40){let A=s!=="."&&(l==="if"||l==="while"||l==="for"||l==="with"||l==="switch"||l==="catch"||l==="await"&&s==="for");n.push(A),f("(",!0)}else if(H===41){let A=n.pop()??!1;if(e===_)return A;f(")",A)}else if(H===47&&S){e=de(t,e),f("literal");continue}else{if(H===123)o++;else if(H===125){if(o--,r.at(-1)===o)r.pop(),C=!0}f(t[e],H===47||u(H))}e++}return!1}function Ne(t,_){let n=L(t,_-1);if(n<0)return!0;let r=t.charCodeAt(n);if(r===41)return b(t,n);if(u(r))return!0;if(i(r)){let o=n;while(o>=0&&i(t.charCodeAt(o)))o--;let C=t.charCodeAt(L(t,o));if(C===46||C===35)return!1;return R(t.slice(o+1,n+1))}return!1}function de(t,_){let n=_,r=t.length;n++;let o=!1;while(n<r){let C=t.charCodeAt(n);if(C===92){n+=2;continue}if(o){if(C===93)o=!1;n++;continue}if(C===91){o=!0,n++;continue}if(C===47){n++;break}if(C===10||C===13)break;n++}while(n<r&&i(t.charCodeAt(n)))n++;return n}
|
|
5
|
+
export{c,i,Ne,de};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{W}from"./chunk-k5wz43yh.js";import{p}from"./chunk-v6fwy63g.js";var f=100,c=new Map,a=new Map,u=new Map,g=0;function d(e,n,t){let r={fileName:e,text:n};c.delete(e),c.set(e,{file:r,hash:t});while(c.size>f){let s=c.keys().next().value;if(s===void 0)break;c.delete(s)}return r}function b(e,n,t){return u.set(e,(u.get(e)??0)+1),d(e,n,t)}function Ot(e,n,t=p(n)){let r=c.get(e);if(r?.hash===t)return c.delete(e),c.set(e,r),r.file;return b(e,n,t)}async function te(e,n,t={}){let r=p(n);if(c.get(e)?.hash===r)return Ot(e,n,r);let o=`${e}\x00${String(r)}`,i=a.get(o);if(i)return i;let h=(u.get(e)??0)+1;u.set(e,h);let m=g,l;return l=Promise.resolve().then(async()=>{try{if(n.length>=(t.asyncThreshold??1e5))await new Promise((y)=>setTimeout(y,Math.max(0,t.yieldInterval??0)));if(m===g&&u.get(e)===h)return d(e,n,r);return{fileName:e,text:n}}finally{if(a.get(o)===l)a.delete(o)}}),a.set(o,l),l}async function Mn(e,n={}){let t=new Map,r=W(n.concurrency,4);for(let s=0;s<e.length;s+=r){let o=await Promise.all(e.slice(s,s+r).map(async(i)=>({path:i.filePath,file:await te(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function On(){g++,c.clear(),a.clear(),u.clear()}function In(){return c.size}function Ln(){return a.size}function Fn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
|
|
3
|
+
export{Ot,te,Mn,On,In,Ln,Fn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{c,i}from"./chunk-zq93f8ca.js";import{t,F}from"./chunk-1j6092xz.js";import{et,Mt}from"./chunk-j6pfxvy8.js";import{h}from"./chunk-wnk9yjw2.js";import{n}from"./chunk-90aptjh6.js";function q(g,w){let C=(D)=>t(D).map((b)=>D.slice(b.start,b.end)).join("");return C(g)===C(w)}function de(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let w=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(w)?w:void 0}function oe(g,w){if(q(g,w))return g;let C=de(w);if(!C)return;let D=t(g),b=0,v=0,B=[];for(let S of D){let k=g.slice(S.start,S.end);if(k==="("||k==="["||k==="{"||k==="<")b++;else if(k===")"||k==="]"||k==="}"||k===">")b--;else if(k==="|"&&b===0)B.push(g.slice(v,S.start).trim()),v=S.end}B.push(g.slice(v).trim());let O=B.find((S)=>q(S,w));if(O)return O;if(B.includes(C))return C==="boolean"&&(w==="true"||w==="false")?w:C;return}function In(g,w,C,D=new Set){let b=new Map,v=[],B=new Set;for(let e of[...w,...C.values()]){if(B.has(e))continue;if(B.add(e),v.push(e),e.kind==="import")for(let o of h(e.text))b.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))b.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")b.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}v.sort((e,o)=>(e.start??0)-(o.start??0));let O=new Set(v.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of D)O.add(e);let S=new Map,k=(e)=>{if(e=e.trimStart(),S.has(e))return S.get(e);if(S.set(e,void 0),!c(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!O.has(e.slice(0,o)))return;let r=t(e);if(r[0]?.kind!=="word"||!r[1]||e.slice(r[1].start,r[1].end)!=="(")return;let d=1;for(let s=2;s<r.length;s++){let a=e.slice(r[s].start,r[s].end);if(a==="(")d++;else if(a===")"&&--d===0){let l=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return S.set(e,l),l}}return},E=new Set(v.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>k(e.value)).filter((e)=>e!==void 0)).size?F(g):void 0,x=new Map;if(E){let e=0;for(let o=0;o<E.length;o++){let r=g.slice(E[o].start,E[o].end);if(e===0&&r==="function"){let d=E[o+1],s=d&&g.slice(d.start,d.end)==="*"?E[o+2]:d;if(s?.kind==="word"){let a=g.slice(s.start,s.end);x.set(a,(x.get(a)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let R=new Map;for(let e of v)if(e.kind==="function"&&!e.generics&&x.get(e.name)===1)R.set(e.name,e);for(let e of D){let o=v.find((r)=>r.kind==="import"&&h(r.text).includes(e));if(o)R.set(e,o)}let W="__dtsx_call_result";while(g.includes(W))W+="_";let K=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${W} ? ${W} : never`,X=new Map,H=!1;for(let e of v){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=k(e.value);if(o&&R.has(o))X.set(e,K(o)),b.get(e.name).active=!0,b.get(o).active=!0,H=!0;if(e.modifiers?.[0]!=="const")continue;let r=et(e.value);if(!r||r===e.name||!b.has(r))continue;b.get(r).active=!0,b.get(e.name).active=!0,H=!0}if(!H)return;let u=E??F(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",m=new Map,_=new Map,G=new Set,L=new Set,J=new Set,Q=new Map,I=[];for(let e=0;e<u.length;e++){let o=f(e),r=I.at(-1);if(r!==void 0)_.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))G.add(e);if(["(","[","{"].includes(o))I.push(e);else if([")","]","}"].includes(o)){let d=I.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))I.pop(),m.set(d,e)}}let Y=new Map;for(let e=0;e<u.length;){if(u[e].kind!=="punctuation"){e++;continue}let r=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>g.startsWith(s,u[e].start))??f(e);Y.set(e,r);let d=u[e].start+r.length;do e++;while(e<u.length&&u[e].start<d)}for(let e=0;e<u.length;e++){let o=ne(e);if(o!==void 0)L.add(o)}for(let e of L)le(e);let y=0;function Z(e){let o=et(e);if(o){let a=b.get(o);return{type:a?.flow,unresolved:a?.unresolved??!1}}let r=k(e),d=r?R.get(r):void 0;if(d)return{type:d.returnType&&de(d.returnType)?d.returnType:K(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function T(e){return Y.get(e)??""}function N(e){if(u[e]?.kind!=="word"||J.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=b.get(f(e));if(!o?.active)return;let r=T(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(r))return{binding:o,operator:r};if(["++","--"].includes(r)&&!/[\r\n]/.test(g.slice(u[e].end,u[e+1].start)))return{binding:o,operator:r};if(e>=2&&["++","--"].includes(T(e-2))){let d=u[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(f(e-3)));if(!d||!s||/[\r\n;]/.test(g.slice(d.end,u[e-2].start)))return{binding:o,operator:T(e-2)}}return}function ee(e){let o=N(e);return o?.operator==="="?o.binding:void 0}function ne(e){if(u[e]?.kind!=="word"||f(e)!=="class"||f(e-1)==="."||["(",":","="].includes(f(e+1)))return;let o=e+1,r=0;while(o<u.length){let d=f(o);if(d==="{"&&r===0)return o;if(d==="class"){let s=ne(o);if(s!==void 0){o=(m.get(s)??s)+1;continue}}if(d==="function"){let s=se(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&T(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(m.get(o)??o)+1}return}function te(e,o,r){let d=e,s=!1,a=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(a.includes(f(d))&&!["(","<","?","!",":","=",";","}"].includes(f(d+1))){if(f(d)==="static")s=!0;d++}if(f(d)==="*")d++;if(r&&f(d)==="#")d++;if(f(d)==="["){let p=m.get(d);return p===void 0?void 0:{next:p+1,isStatic:s}}if(u[d]?.kind==="word"||u[d]?.kind==="quoted")return{next:d+1,isStatic:s};let l=d+1;while(l<o&&u[l-1].end===u[l].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(l)))l++;if(d<o&&n(g.slice(u[d].start,u[l-1].end),!1)==="number")return{next:l,isStatic:s};return}function P(e,o,r){let d=te(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let a=1;s++;while(s<o&&a>0){if(f(s)==="<")a++;else if(f(s)===">"&&T(s-1)!=="=>")a--;s=(m.get(s)??s)+1}if(a!==0)return}return s}function ie(e,o,r){return P(e,o,r)===o}function fe(e,o){let r=0,d=-1;for(let s=e;s<o;s=(m.get(s)??s)+1)if(f(s)==="<"&&(r>0||s>e&&(u[s-1].kind==="word"||[")","]"].includes(f(s-1))))){if(r===0)d=s;r++}else if(f(s)===">"&&T(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function ae(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=P(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function U(e,o,r=!1){let d=m.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&T(s)==="=")return s;if(s>e&&_.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let a=f(s-1),p=!(a===">"&&fe(e,s)&&ae(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(a),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!M)return s}s=(m.get(s)??s)+1}return d}function V(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&m.has(r)){r=m.get(r);continue}if(u[r].kind==="word")J.add(r)}}function le(e){let o=m.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(m.get(r+1)??r+1)+1;continue}let d=te(r,o,!0);if(!d){r++;continue}let s=P(r,o,!0);if(s===void 0){r++;continue}if(V(r,s),f(s)==="("){let l=m.get(s),p=l===void 0?void 0:re(l,o);if(p!==void 0){r=(m.get(p)??p)+1;continue}}let a=s;if(f(a)===":")a=U(a+1,e,!0);if(T(a)==="="){V(r,a+1);let l=a+1,p=U(l,e);if(!d.isStatic&&p>l)Q.set(l,p);r=p}else{let l=U(s,e);V(r,l),r=Math.max(r+1,l)}}}function ce(e){let o=_.get(e);if(o===void 0)return!1;let r=L.has(o);if(!r&&!G.has(o))return!1;if(ie(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=_.get(d),a=_.get(d)===o&&(f(d)===","||r&&f(d)===";"),l=r&&f(d)==="}"&&s!==void 0&&_.get(s)===o,p=r&&_.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((a||l||p)&&ie(d+1,e,r))return!0}return!1}function re(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Mt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(m.get(r)??r)+1}return}function se(e,o){let r=-1;if(f(e)==="("){let s=m.get(e);if(s!==void 0&&ce(e))r=re(s,o)??-1;else if(s!==void 0&&T(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let a=s+2;while(a<o&&f(a)!==";"){if(T(a)==="=>"){r=a+2;break}a=(m.get(a)??a)+1}}}else if(u[e]?.kind==="word"&&T(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(m.get(s)??s)+1;let a=m.get(s);if(a===void 0)return;r=a+1;let l=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(l===void 0||!Mt(g.slice(u[l].start,u[r].start))))break;r=(m.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(m.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(m.get(d)??d)+1;return{start:e,end:d}}function j(e,o,r=!0){for(let d=e;d<o;d++){let s=Q.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let a=r?se(d,o):void 0;if(a){let p=a.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")j(a.start,a.end,!1);d=a.end-1;continue}let l=N(d);if(l)l.binding.flow=void 0,l.binding.unresolved=!0}}function ue(e){let o=!1;while(y<u.length&&u[y].start<e){let r=f(y);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let l=m.get(y)??y+1;while(l<u.length&&u[l].start>=e)l--;if(j(y+1,l),y=l+1,r==="{")o=!1;continue}let d=ee(y);if(d){let a=y+2,l=a,p=[];while(l<u.length&&u[l].start<e){let A=f(l);if(p.length===0&&(A===";"||l>a&&/[\r\n]/.test(g.slice(u[l-1].end,u[l].start))&&(ee(l)||["if","for","while","switch","try","do","return","throw"].includes(A))))break;if(A==="("||A==="{"||A==="[")p.push(A==="("?")":A==="{"?"}":"]");else if(A===p.at(-1))p.pop();l++}let M=l>a?g.slice(u[a].start,u[l-1].end):"";j(a,l);let z=Z(M);d.flow=!o&&z.type?d.declared?oe(d.declared,z.type):z.type:void 0,d.unresolved=o||z.unresolved||!d.flow,y=l;continue}let s=N(y);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;y++}}for(let e of v){ue(e.start??0);let o=y;while(y<u.length&&u[y].start<(e.end??0))y++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<y&&u[M].start<e.initializerStart)M++;j(M,y)}let r=b.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=Z(d),a=et(d),l=a?b.get(a):void 0,p=X.get(e);if(p)e.inferredType=p,e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${p};`;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&a&&a!==e.name&&l){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=l.declared&&q(l.declared,s.type)?`typeof ${a}`:s.type,e.text=`${e.isExported?"export ":""}declare const ${e.name}: ${e.inferredType};`}if(e.typeAnnotation)r.flow=s.type?oe(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)r.declared=e.inferredType,r.flow=e.inferredType;else{let M=e.modifiers?.[0]==="const",z=d.trim().startsWith("{")||d.trim().startsWith("["),A=n(d,M&&!z);r.declared=A==="unknown"?void 0:A,r.flow=r.declared}r.unresolved=s.unresolved}}
|
|
3
|
-
export{
|
|
2
|
+
import{c,i}from"./chunk-8kj9pkw5.js";import{t,F}from"./chunk-c7a07a26.js";import{rt,Lt}from"./chunk-7j4cgkb4.js";import{y}from"./chunk-jfygtm4r.js";import{n}from"./chunk-qq5x44y9.js";function q(g,w){let C=(D)=>t(D).map((b)=>D.slice(b.start,b.end)).join("");return C(g)===C(w)}function de(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let w=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(w)?w:void 0}function oe(g,w){if(q(g,w))return g;let C=de(w);if(!C)return;let D=t(g),b=0,v=0,B=[];for(let S of D){let k=g.slice(S.start,S.end);if(k==="("||k==="["||k==="{"||k==="<")b++;else if(k===")"||k==="]"||k==="}"||k===">")b--;else if(k==="|"&&b===0)B.push(g.slice(v,S.start).trim()),v=S.end}B.push(g.slice(v).trim());let O=B.find((S)=>q(S,w));if(O)return O;if(B.includes(C))return C==="boolean"&&(w==="true"||w==="false")?w:C;return}function _n(g,w,C,D=new Set){let b=new Map,v=[],B=new Set;for(let e of[...w,...C.values()]){if(B.has(e))continue;if(B.add(e),v.push(e),e.kind==="import")for(let o of y(e.text))b.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))b.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")b.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}v.sort((e,o)=>(e.start??0)-(o.start??0));let O=new Set(v.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of D)O.add(e);let S=new Map,k=(e)=>{if(e=e.trimStart(),S.has(e))return S.get(e);if(S.set(e,void 0),!c(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!O.has(e.slice(0,o)))return;let r=t(e);if(r[0]?.kind!=="word"||!r[1]||e.slice(r[1].start,r[1].end)!=="(")return;let d=1;for(let s=2;s<r.length;s++){let a=e.slice(r[s].start,r[s].end);if(a==="(")d++;else if(a===")"&&--d===0){let l=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return S.set(e,l),l}}return},E=new Set(v.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>k(e.value)).filter((e)=>e!==void 0)).size?F(g):void 0,x=new Map;if(E){let e=0;for(let o=0;o<E.length;o++){let r=g.slice(E[o].start,E[o].end);if(e===0&&r==="function"){let d=E[o+1],s=d&&g.slice(d.start,d.end)==="*"?E[o+2]:d;if(s?.kind==="word"){let a=g.slice(s.start,s.end);x.set(a,(x.get(a)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let R=new Map;for(let e of v)if(e.kind==="function"&&!e.generics&&x.get(e.name)===1)R.set(e.name,e);for(let e of D){let o=v.find((r)=>r.kind==="import"&&y(r.text).includes(e));if(o)R.set(e,o)}let W="__dtsx_call_result";while(g.includes(W))W+="_";let K=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${W} ? ${W} : never`,X=new Map,H=!1;for(let e of v){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=k(e.value);if(o&&R.has(o))X.set(e,K(o)),b.get(e.name).active=!0,b.get(o).active=!0,H=!0;if(e.modifiers?.[0]!=="const")continue;let r=rt(e.value);if(!r||r===e.name||!b.has(r))continue;b.get(r).active=!0,b.get(e.name).active=!0,H=!0}if(!H)return;let u=E??F(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",m=new Map,_=new Map,G=new Set,L=new Set,J=new Set,Q=new Map,I=[];for(let e=0;e<u.length;e++){let o=f(e),r=I.at(-1);if(r!==void 0)_.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))G.add(e);if(["(","[","{"].includes(o))I.push(e);else if([")","]","}"].includes(o)){let d=I.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))I.pop(),m.set(d,e)}}let Y=new Map;for(let e=0;e<u.length;){if(u[e].kind!=="punctuation"){e++;continue}let r=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>g.startsWith(s,u[e].start))??f(e);Y.set(e,r);let d=u[e].start+r.length;do e++;while(e<u.length&&u[e].start<d)}for(let e=0;e<u.length;e++){let o=ne(e);if(o!==void 0)L.add(o)}for(let e of L)le(e);let h=0;function Z(e){let o=rt(e);if(o){let a=b.get(o);return{type:a?.flow,unresolved:a?.unresolved??!1}}let r=k(e),d=r?R.get(r):void 0;if(d)return{type:d.returnType&&de(d.returnType)?d.returnType:K(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function T(e){return Y.get(e)??""}function N(e){if(u[e]?.kind!=="word"||J.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=b.get(f(e));if(!o?.active)return;let r=T(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(r))return{binding:o,operator:r};if(["++","--"].includes(r)&&!/[\r\n]/.test(g.slice(u[e].end,u[e+1].start)))return{binding:o,operator:r};if(e>=2&&["++","--"].includes(T(e-2))){let d=u[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(f(e-3)));if(!d||!s||/[\r\n;]/.test(g.slice(d.end,u[e-2].start)))return{binding:o,operator:T(e-2)}}return}function ee(e){let o=N(e);return o?.operator==="="?o.binding:void 0}function ne(e){if(u[e]?.kind!=="word"||f(e)!=="class"||f(e-1)==="."||["(",":","="].includes(f(e+1)))return;let o=e+1,r=0;while(o<u.length){let d=f(o);if(d==="{"&&r===0)return o;if(d==="class"){let s=ne(o);if(s!==void 0){o=(m.get(s)??s)+1;continue}}if(d==="function"){let s=se(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&T(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(m.get(o)??o)+1}return}function te(e,o,r){let d=e,s=!1,a=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(a.includes(f(d))&&!["(","<","?","!",":","=",";","}"].includes(f(d+1))){if(f(d)==="static")s=!0;d++}if(f(d)==="*")d++;if(r&&f(d)==="#")d++;if(f(d)==="["){let p=m.get(d);return p===void 0?void 0:{next:p+1,isStatic:s}}if(u[d]?.kind==="word"||u[d]?.kind==="quoted")return{next:d+1,isStatic:s};let l=d+1;while(l<o&&u[l-1].end===u[l].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(l)))l++;if(d<o&&n(g.slice(u[d].start,u[l-1].end),!1)==="number")return{next:l,isStatic:s};return}function P(e,o,r){let d=te(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let a=1;s++;while(s<o&&a>0){if(f(s)==="<")a++;else if(f(s)===">"&&T(s-1)!=="=>")a--;s=(m.get(s)??s)+1}if(a!==0)return}return s}function ie(e,o,r){return P(e,o,r)===o}function fe(e,o){let r=0,d=-1;for(let s=e;s<o;s=(m.get(s)??s)+1)if(f(s)==="<"&&(r>0||s>e&&(u[s-1].kind==="word"||[")","]"].includes(f(s-1))))){if(r===0)d=s;r++}else if(f(s)===">"&&T(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function ae(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=P(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function U(e,o,r=!1){let d=m.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&T(s)==="=")return s;if(s>e&&_.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let a=f(s-1),p=!(a===">"&&fe(e,s)&&ae(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(a),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!M)return s}s=(m.get(s)??s)+1}return d}function V(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&m.has(r)){r=m.get(r);continue}if(u[r].kind==="word")J.add(r)}}function le(e){let o=m.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(m.get(r+1)??r+1)+1;continue}let d=te(r,o,!0);if(!d){r++;continue}let s=P(r,o,!0);if(s===void 0){r++;continue}if(V(r,s),f(s)==="("){let l=m.get(s),p=l===void 0?void 0:re(l,o);if(p!==void 0){r=(m.get(p)??p)+1;continue}}let a=s;if(f(a)===":")a=U(a+1,e,!0);if(T(a)==="="){V(r,a+1);let l=a+1,p=U(l,e);if(!d.isStatic&&p>l)Q.set(l,p);r=p}else{let l=U(s,e);V(r,l),r=Math.max(r+1,l)}}}function ce(e){let o=_.get(e);if(o===void 0)return!1;let r=L.has(o);if(!r&&!G.has(o))return!1;if(ie(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=_.get(d),a=_.get(d)===o&&(f(d)===","||r&&f(d)===";"),l=r&&f(d)==="}"&&s!==void 0&&_.get(s)===o,p=r&&_.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((a||l||p)&&ie(d+1,e,r))return!0}return!1}function re(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Lt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(m.get(r)??r)+1}return}function se(e,o){let r=-1;if(f(e)==="("){let s=m.get(e);if(s!==void 0&&ce(e))r=re(s,o)??-1;else if(s!==void 0&&T(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let a=s+2;while(a<o&&f(a)!==";"){if(T(a)==="=>"){r=a+2;break}a=(m.get(a)??a)+1}}}else if(u[e]?.kind==="word"&&T(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(m.get(s)??s)+1;let a=m.get(s);if(a===void 0)return;r=a+1;let l=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(l===void 0||!Lt(g.slice(u[l].start,u[r].start))))break;r=(m.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(m.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(m.get(d)??d)+1;return{start:e,end:d}}function j(e,o,r=!0){for(let d=e;d<o;d++){let s=Q.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let a=r?se(d,o):void 0;if(a){let p=a.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")j(a.start,a.end,!1);d=a.end-1;continue}let l=N(d);if(l)l.binding.flow=void 0,l.binding.unresolved=!0}}function ue(e){let o=!1;while(h<u.length&&u[h].start<e){let r=f(h);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let l=m.get(h)??h+1;while(l<u.length&&u[l].start>=e)l--;if(j(h+1,l),h=l+1,r==="{")o=!1;continue}let d=ee(h);if(d){let a=h+2,l=a,p=[];while(l<u.length&&u[l].start<e){let A=f(l);if(p.length===0&&(A===";"||l>a&&/[\r\n]/.test(g.slice(u[l-1].end,u[l].start))&&(ee(l)||["if","for","while","switch","try","do","return","throw"].includes(A))))break;if(A==="("||A==="{"||A==="[")p.push(A==="("?")":A==="{"?"}":"]");else if(A===p.at(-1))p.pop();l++}let M=l>a?g.slice(u[a].start,u[l-1].end):"";j(a,l);let z=Z(M);d.flow=!o&&z.type?d.declared?oe(d.declared,z.type):z.type:void 0,d.unresolved=o||z.unresolved||!d.flow,h=l;continue}let s=N(h);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;h++}}for(let e of v){ue(e.start??0);let o=h;while(h<u.length&&u[h].start<(e.end??0))h++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<h&&u[M].start<e.initializerStart)M++;j(M,h)}let r=b.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=Z(d),a=rt(d),l=a?b.get(a):void 0,p=X.get(e);if(p)e.inferredType=p,e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${p};`;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&a&&a!==e.name&&l){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=l.declared&&q(l.declared,s.type)?`typeof ${a}`:s.type,e.text=`${e.isExported?"export ":""}declare const ${e.name}: ${e.inferredType};`}if(e.typeAnnotation)r.flow=s.type?oe(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)r.declared=e.inferredType,r.flow=e.inferredType;else{let M=e.modifiers?.[0]==="const",z=d.trim().startsWith("{")||d.trim().startsWith("["),A=n(d,M&&!z);r.declared=A==="unknown"?void 0:A,r.flow=r.declared}r.unresolved=s.unresolved}}
|
|
3
|
+
export{_n};
|