@dtsx/dtsx 0.11.37 → 0.11.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +3 -3
- package/dist/{chunk-wrnz0e76.js → chunk-082w7zvy.js} +3 -3
- package/dist/{chunk-psrgw9f8.js → chunk-0k0fhq13.js} +7 -7
- package/dist/{chunk-69dbf6de.js → chunk-0rmbc5zp.js} +2 -2
- package/dist/{chunk-nn9tpxx3.js → chunk-0yg5mcrf.js} +2 -2
- package/dist/chunk-0zfzhn19.js +31 -0
- package/dist/chunk-189nn4fc.js +3 -0
- package/dist/{chunk-cen2t56g.js → chunk-1qtghb2x.js} +2 -2
- package/dist/{chunk-r4zkf9ag.js → chunk-2436cnmb.js} +2 -2
- package/dist/{chunk-py7pj8aj.js → chunk-2qd3axyx.js} +4 -4
- package/dist/{chunk-n2nyd0ck.js → chunk-32qexm3w.js} +2 -2
- package/dist/{chunk-1pz7zxhc.js → chunk-3fbt79hx.js} +2 -2
- package/dist/{chunk-gpq2kggq.js → chunk-3t57mzvf.js} +2 -2
- package/dist/{chunk-2kwjbk55.js → chunk-42j9cfte.js} +2 -2
- package/dist/{chunk-vtskg4r2.js → chunk-4fygcxtb.js} +2 -2
- package/dist/{chunk-437g8zz6.js → chunk-50h54rax.js} +3 -3
- package/dist/{chunk-aw48mk3t.js → chunk-6yvk3q1e.js} +2 -2
- package/dist/chunk-73dzve1s.js +3 -0
- package/dist/chunk-7tremqhs.js +14 -0
- package/dist/{chunk-mt9219xc.js → chunk-83qnrx0m.js} +5 -5
- package/dist/{chunk-ckq8g1ck.js → chunk-88gwzbew.js} +3 -3
- package/dist/{chunk-90aptjh6.js → chunk-8d3sdkv4.js} +19 -19
- package/dist/{chunk-srg5qhch.js → chunk-8tzd98q8.js} +4 -4
- package/dist/{chunk-fy97syc2.js → chunk-96atbsd3.js} +2 -2
- package/dist/{chunk-h7k9wamx.js → chunk-9gts9ymh.js} +2 -2
- package/dist/{chunk-sq34kkhy.js → chunk-9menejdz.js} +2 -2
- package/dist/{chunk-1h6ycqza.js → chunk-a7nvyxpg.js} +4 -4
- package/dist/{chunk-j6pfxvy8.js → chunk-ag1b6d30.js} +2 -2
- package/dist/{chunk-0ke9xh7t.js → chunk-bnry23ve.js} +3 -3
- package/dist/{chunk-wzcwctba.js → chunk-bxc2herz.js} +3 -3
- package/dist/{chunk-pzedkn7z.js → chunk-cpmqa8kd.js} +2 -2
- package/dist/{chunk-rdzfdjkb.js → chunk-cv29b4zb.js} +3 -3
- package/dist/{chunk-xr1h3tv2.js → chunk-cyr45de1.js} +2 -2
- package/dist/{chunk-m1khpcqb.js → chunk-d0bazr3p.js} +1 -1
- package/dist/{chunk-vae5wxar.js → chunk-danfamyx.js} +2 -2
- package/dist/{chunk-853ftm92.js → chunk-davy89dj.js} +5 -5
- package/dist/{chunk-n6nw7sn2.js → chunk-e29rp5xj.js} +5 -5
- package/dist/{chunk-p7w9ydhe.js → chunk-eba562w8.js} +2 -2
- package/dist/{chunk-v44crx69.js → chunk-ebjafajx.js} +11 -11
- package/dist/{chunk-g9d5r6a8.js → chunk-ft2zk7jx.js} +2 -2
- package/dist/chunk-g2120ysy.js +3 -0
- package/dist/chunk-ghfd34r7.js +3 -0
- package/dist/{chunk-sjneg7p7.js → chunk-gspsxc9d.js} +8 -8
- package/dist/{chunk-n3p7wedp.js → chunk-h3n6256r.js} +2 -2
- package/dist/{chunk-4f2mwn7p.js → chunk-hnqm1zb3.js} +4 -4
- package/dist/{chunk-gs7wfk8b.js → chunk-htgy94y3.js} +1 -1
- package/dist/{chunk-knrtwppp.js → chunk-hv8bx8xx.js} +6 -6
- package/dist/chunk-hzn9kmq7.js +3 -0
- package/dist/{chunk-nchp0pqa.js → chunk-ja7bp731.js} +2 -2
- package/dist/chunk-jcckwgb9.js +3 -0
- package/dist/{chunk-s0mvstt0.js → chunk-kfk554fj.js} +2 -2
- package/dist/{chunk-1e10w914.js → chunk-kkshxyex.js} +3 -3
- package/dist/{chunk-bdxq6500.js → chunk-kpbz61yy.js} +3 -3
- package/dist/{chunk-w9av39jy.js → chunk-mkakbjvs.js} +2 -2
- package/dist/{chunk-xsf941gw.js → chunk-mwyjxjqa.js} +2 -2
- package/dist/{chunk-n37yj3xv.js → chunk-p023fhce.js} +3 -3
- package/dist/chunk-p9vfxn8g.js +3 -0
- package/dist/{chunk-q0hn0ymb.js → chunk-pjqzkgzk.js} +4 -4
- package/dist/chunk-qzjzw9p2.js +3 -0
- package/dist/{chunk-acyj1dev.js → chunk-rbx6q1r0.js} +2 -2
- package/dist/{chunk-fgbdm1y6.js → chunk-rkstz4w1.js} +4 -4
- package/dist/{chunk-gsv5yc32.js → chunk-rz060wxt.js} +4 -4
- package/dist/{chunk-z4mvkazp.js → chunk-sd8bywh9.js} +11 -11
- package/dist/{chunk-dv5hhg1a.js → chunk-sv8h007a.js} +2 -2
- package/dist/{chunk-1bpv3tck.js → chunk-t4va49p3.js} +4 -4
- package/dist/{chunk-bqabznps.js → chunk-tka2m4af.js} +2 -2
- package/dist/{chunk-7610h2tf.js → chunk-v93389xm.js} +1 -1
- package/dist/{chunk-wnk9yjw2.js → chunk-vf3ybe5r.js} +2 -2
- package/dist/{chunk-ezbp8tss.js → chunk-vkahj2ab.js} +8 -8
- package/dist/chunk-wnqg6hem.js +27 -0
- package/dist/chunk-xa6rsd4b.js +29 -0
- package/dist/{chunk-gsb3ty07.js → chunk-xfjfhe9d.js} +2 -2
- package/dist/{chunk-5n0tfrpc.js → chunk-xwpn40p0.js} +3 -3
- package/dist/chunk-y1g6v96c.js +10 -0
- package/dist/{chunk-r4s18nn5.js → chunk-y5k0szq6.js} +2 -2
- package/dist/{chunk-km8t8gqg.js → chunk-yay68832.js} +2 -2
- package/dist/{chunk-strqhcqs.js → chunk-yrv6z221.js} +2 -2
- package/dist/chunk-yx1jy7fx.js +37 -0
- package/dist/{chunk-ggbahdr2.js → chunk-zgcdx773.js} +3 -3
- package/dist/{chunk-60ssvwc8.js → chunk-zk3w5sqv.js} +2 -2
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.js +1 -1
- package/dist/src/branded-types.js +1 -1
- package/dist/src/bundle-linker.js +1 -1
- package/dist/src/bundler.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/call-signatures.js +1 -1
- package/dist/src/circular.js +1 -1
- package/dist/src/compat.js +1 -1
- package/dist/src/computed-keys.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/dangling-refs.js +1 -1
- package/dist/src/declaration-project.js +1 -1
- package/dist/src/declaration-publication.js +1 -1
- package/dist/src/declaration-references.js +1 -1
- package/dist/src/diff.js +1 -1
- package/dist/src/docs.js +1 -1
- package/dist/src/enum-declarations.js +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/extractor/directives.js +1 -1
- package/dist/src/extractor/extract.js +1 -1
- package/dist/src/extractor/scanner.js +1 -1
- package/dist/src/extractor.js +1 -1
- package/dist/src/formats.js +1 -1
- package/dist/src/formatter.js +1 -1
- package/dist/src/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/global-types.js +1 -1
- package/dist/src/import-sorter.js +1 -1
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/json-config.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/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.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.js +1 -1
- package/dist/src/processor.js +1 -1
- package/dist/src/profiling.js +1 -1
- package/dist/src/return-type-scope.js +1 -1
- package/dist/src/security.js +1 -1
- package/dist/src/source-cache.js +1 -1
- package/dist/src/sourcemap.js +1 -1
- package/dist/src/stx.js +1 -1
- package/dist/src/syntax-validator.js +1 -1
- package/dist/src/tracking.js +1 -1
- package/dist/src/transformers.js +1 -1
- package/dist/src/tree-shaker.js +1 -1
- package/dist/src/tsconfig.js +1 -1
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/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/package.json +1 -1
- package/dist/chunk-0azm93j9.js +0 -31
- package/dist/chunk-25vyhfzh.js +0 -3
- package/dist/chunk-79nv7twc.js +0 -14
- package/dist/chunk-cs4gwz1k.js +0 -27
- package/dist/chunk-d43bpfk6.js +0 -3
- package/dist/chunk-dfye109x.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,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-zq93f8ca.js";import{t,F}from"./chunk-1j6092xz.js";import{Qe,Dt}from"./chunk-ag1b6d30.js";import{y}from"./chunk-vf3ybe5r.js";import{n}from"./chunk-8d3sdkv4.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 Fn(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=Qe(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=Qe(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||!Dt(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||!Dt(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=Qe(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{Fn};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{u}from"./chunk-73dzve1s.js";import{m}from"./chunk-1j6092xz.js";import{y}from"./chunk-vf3ybe5r.js";import{r}from"./chunk-jcckwgb9.js";import{xe}from"./chunk-4fygcxtb.js";function Uo(c){if(!c.includes("declare")||!c.includes("module"))return[];return m(c).filter((d)=>d.category==="augmentation").map((d)=>d.specifier)}function E(c,d){let p=new Set([c]);for(let v of p)for(let h of d(v))p.add(h);return p}async function we(c,d,p=!1,v){let h=new Map,x=new Map;for(let e of c){let g=v?.get(e)??await u(e);h.set(e,g);let s=Uo(g);if(s.length)x.set(e,s)}let M=new Map;if(x.size===0)return M;let l=new Map,b=(e,g)=>{let s=d(e,g);if(s.resolved)return s.resolved;if(!s.isRelative&&!s.isAlias)return`external:${e}`;return};for(let[e,g]of h){let s=r(g,e,!1,p),a=xe(s),f={edges:[],declarations:new Set,augmentations:new Set},w=(n,i,t)=>{let o=b(n.specifier,e);if(!o)return;if(h.has(o))f.edges.push({specifier:n.specifier,target:o,import:i});if(t)f.declarations.add(o)};for(let n of s){if(n.kind!=="import")continue;let i=n.isSideEffect||y(n.text).some((t)=>a.usedItems.has(t));for(let t of m(n.text))w(t,!0,!!i)}for(let n of m(a.referenceText))w(n,!1,!0);for(let n of x.get(e)??[]){let i=b(n,e);if(i)f.augmentations.add(i),f.declarations.add(i)}l.set(e,f)}let R=!0;while(R){R=!1;for(let[e,g]of l){let s=E(e,(a)=>l.get(a)?.declarations??[]);for(let[a,f]of l){if(s.has(a)||!f.augmentations.size||![...f.augmentations].some((t)=>s.has(t)))continue;let w=[e],n=new Map,i=new Set([e]);for(let t of w){if(t===a)break;for(let o of l.get(t).edges){if(i.has(o.target))continue;i.add(o.target),n.set(o.target,{from:t,edge:o}),w.push(o.target)}}if(!n.has(a))continue;for(let t=a;t!==e;){let{from:o,edge:I}=n.get(t),A=l.get(o);if(I.import){let S=M.get(o);if(!S)S=new Set,M.set(o,S);S.add(I.specifier)}if(!A.declarations.has(t))A.declarations.add(t),R=!0;t=o}}}}return M}
|
|
3
|
+
export{Uo,we};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Re}from"./chunk-1qtghb2x.js";import{T}from"./chunk-yx1jy7fx.js";import{b}from"./chunk-vf3ybe5r.js";function xn(i,r){let n=new Set;for(let e of T(i,"imports.ts",!1)){if(e.kind!=="import")continue;let t=b(e.text),a=t&&r.get(t.source);if(!t||t.isTypeOnly||!a)continue;let s=ze(a);for(let o of t.namedItems)if(!o.isTypeOnly&&s.some((m)=>m.name===o.originalName))n.add(o.name);if(t.defaultName&&s.some((o)=>o.isDefault))n.add(t.defaultName)}return n}function ze(i){let r=T(i,"dependency.ts",!1).filter((n)=>n.kind==="function");return r.filter((n)=>n.isExported&&!n.generics&&r.filter((e)=>e.name===n.name).length===1&&Re(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
|
|
3
|
+
export{xn,ze};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function p(r,t){let e=r.trim();if(e==="string")return{type:"string"};if(e==="number")return{type:"number"};if(e==="boolean")return{type:"boolean"};if(e==="null")return{type:"null"};if(e==="undefined")return{type:"null"};if(e==="any"||e==="unknown")return{};if(e==="never")return{not:{}};if(e==="void")return{type:"null"};if(e==="bigint")return{type:"integer"};if(e==="symbol")return{type:"string",description:"Symbol type"};if(e==="object")return{type:"object"};if(e.startsWith("'")||e.startsWith('"'))return{const:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{const:Number.parseFloat(e)};if(e==="true")return{const:!0};if(e==="false")return{const:!1};let n=e.match(/^(.+)\[\]$/)||e.match(/^Array<(.+)>$/i);if(n)return{type:"array",items:p(n[1],t)};let i=e.match(/^\[(.+)\]$/);if(i){let f=l(i[1],",").map((d)=>p(d.trim(),t));return{type:"array",items:f,minItems:f.length,maxItems:f.length}}if(e.includes("|")){let f=l(e,"|");if(f.length>1){let d=f.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined");if(f.some((a)=>a.trim()==="null"||a.trim()==="undefined")&&d.length===1){let a=p(d[0],t);if(a.type&&typeof a.type==="string")return{...a,type:[a.type,"null"]};return{oneOf:[a,{type:"null"}]}}return{oneOf:f.map((a)=>p(a.trim(),t))}}}if(e.includes("&")){let f=l(e,"&");if(f.length>1)return{allOf:f.map((d)=>p(d.trim(),t))}}let s=e.match(/^Record<(.+),\s*(.+)>$/i);if(s)return{type:"object",additionalProperties:p(s[2],t)};let o=e.match(/^Promise<(.+)>$/i);if(o)return p(o[1],t);let u=e.match(/^Partial<(.+)>$/i);if(u)return{...p(u[1],t),required:[]};let h=e.match(/^Required<(.+)>$/i);if(h)return p(h[1],t);let c=e.match(/^Readonly<(.+)>$/i);if(c)return p(c[1],t);let y=e.match(/^Pick<(.+),\s*(.+)>$/i);if(y)return p(y[1],t);let b=e.match(/^Omit<(.+),\s*(.+)>$/i);if(b)return p(b[1],t);if(e==="Date")return{type:"string",format:"date-time"};if(/^[A-Z]\w*$/.test(e))return{$ref:`#/$defs/${e}`};return{type:"object"}}function
|
|
2
|
+
function p(r,t){let e=r.trim();if(e==="string")return{type:"string"};if(e==="number")return{type:"number"};if(e==="boolean")return{type:"boolean"};if(e==="null")return{type:"null"};if(e==="undefined")return{type:"null"};if(e==="any"||e==="unknown")return{};if(e==="never")return{not:{}};if(e==="void")return{type:"null"};if(e==="bigint")return{type:"integer"};if(e==="symbol")return{type:"string",description:"Symbol type"};if(e==="object")return{type:"object"};if(e.startsWith("'")||e.startsWith('"'))return{const:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{const:Number.parseFloat(e)};if(e==="true")return{const:!0};if(e==="false")return{const:!1};let n=e.match(/^(.+)\[\]$/)||e.match(/^Array<(.+)>$/i);if(n)return{type:"array",items:p(n[1],t)};let i=e.match(/^\[(.+)\]$/);if(i){let f=l(i[1],",").map((d)=>p(d.trim(),t));return{type:"array",items:f,minItems:f.length,maxItems:f.length}}if(e.includes("|")){let f=l(e,"|");if(f.length>1){let d=f.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined");if(f.some((a)=>a.trim()==="null"||a.trim()==="undefined")&&d.length===1){let a=p(d[0],t);if(a.type&&typeof a.type==="string")return{...a,type:[a.type,"null"]};return{oneOf:[a,{type:"null"}]}}return{oneOf:f.map((a)=>p(a.trim(),t))}}}if(e.includes("&")){let f=l(e,"&");if(f.length>1)return{allOf:f.map((d)=>p(d.trim(),t))}}let s=e.match(/^Record<(.+),\s*(.+)>$/i);if(s)return{type:"object",additionalProperties:p(s[2],t)};let o=e.match(/^Promise<(.+)>$/i);if(o)return p(o[1],t);let u=e.match(/^Partial<(.+)>$/i);if(u)return{...p(u[1],t),required:[]};let h=e.match(/^Required<(.+)>$/i);if(h)return p(h[1],t);let c=e.match(/^Readonly<(.+)>$/i);if(c)return p(c[1],t);let y=e.match(/^Pick<(.+),\s*(.+)>$/i);if(y)return p(y[1],t);let b=e.match(/^Omit<(.+),\s*(.+)>$/i);if(b)return p(b[1],t);if(e==="Date")return{type:"string",format:"date-time"};if(/^[A-Z]\w*$/.test(e))return{$ref:`#/$defs/${e}`};return{type:"object"}}function $r(r,t={}){let e=t.indent??2,n=t.jsonSchemaDraft??"2020-12",i={"2020-12":"https://json-schema.org/draft/2020-12/schema","2019-09":"https://json-schema.org/draft/2019-09/schema","draft-07":"http://json-schema.org/draft-07/schema#"}[n],s=new Map,o={$schema:t.includeSchema!==!1?i:void 0,$defs:{}};for(let u of r)if(u.kind==="interface"||u.kind==="type"){let h=N(u,s,t);if(o.$defs)o.$defs[u.name]=h}if(o.$defs&&Object.keys(o.$defs).length===1){let[u,h]=Object.entries(o.$defs)[0];return JSON.stringify({$schema:o.$schema,title:u,...h},null,e)}return JSON.stringify(o,null,e)}function N(r,t,e){let n={type:"object"};if(e.includeDescriptions&&r.leadingComments?.length){let i=v(r.leadingComments);if(i)n.description=i}if(r.members&&r.members.length>0){n.properties={},n.required=[];for(let i of r.members)if(i.name&&i.typeAnnotation){let s=p(i.typeAnnotation,t);if(e.includeDescriptions&&i.leadingComments?.length){let u=v(i.leadingComments);if(u)s.description=u}if(n.properties[i.name]=s,!(i.modifiers?.includes("?")||i.text?.includes("?:")||e.allOptional))n.required.push(i.name)}if(n.required.length===0)delete n.required}else if(r.typeAnnotation)return p(r.typeAnnotation,t);return n}function Er(r,t={}){let e=["import { z } from 'zod'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=x(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = z.infer<typeof ${i}>`),e.push("")}return e.join(`
|
|
3
3
|
`)}function x(r,t){if(r.members&&r.members.length>0)return`z.object({
|
|
4
4
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=m(n.typeAnnotation);if(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional)i=`${i}.optional()`;if(t.includeDescriptions&&n.leadingComments?.length){let o=v(n.leadingComments);if(o)i=`${i}.describe(${JSON.stringify(o)})`}return` ${n.name}: ${i}`}).join(`,
|
|
5
5
|
`)}
|
|
6
|
-
})`;if(r.typeAnnotation)return m(r.typeAnnotation);return"z.unknown()"}function m(r){let t=r.trim();if(t==="string")return"z.string()";if(t==="number")return"z.number()";if(t==="boolean")return"z.boolean()";if(t==="null")return"z.null()";if(t==="undefined")return"z.undefined()";if(t==="any")return"z.any()";if(t==="unknown")return"z.unknown()";if(t==="never")return"z.never()";if(t==="void")return"z.void()";if(t==="bigint")return"z.bigint()";if(t==="symbol")return"z.symbol()";if(t==="Date")return"z.date()";if(t.startsWith("'")||t.startsWith('"'))return`z.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`z.literal(${t})`;if(t==="true"||t==="false")return`z.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`z.array(${m(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`z.tuple([${l(n[1],",").map((b)=>m(b.trim())).join(", ")}])`;if(t.includes("|")){let y=l(t,"|");if(y.length>1){let b=y.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined"),f=y.some((a)=>a.trim()==="null"),d=y.some((a)=>a.trim()==="undefined");if((f||d)&&b.length===1){let a=m(b[0]);if(f)a=`${a}.nullable()`;if(d)a=`${a}.optional()`;return a}return`z.union([${y.map((a)=>m(a.trim())).join(", ")}])`}}if(t.includes("&")){let y=l(t,"&");if(y.length>1)return y.map((f)=>m(f.trim())).reduce((f,d)=>`${f}.and(${d})`)}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`z.record(${m(i[1])}, ${m(i[2])})`;let s=t.match(/^Promise<(.+)>$/i);if(s)return`z.promise(${m(s[1])})`;let o=t.match(/^Map<(.+),\s*(.+)>$/i);if(o)return`z.map(${m(o[1])}, ${m(o[2])})`;let u=t.match(/^Set<(.+)>$/i);if(u)return`z.set(${m(u[1])})`;let h=t.match(/^Partial<(.+)>$/i);if(h)return`${m(h[1])}.partial()`;let c=t.match(/^Required<(.+)>$/i);if(c)return`${m(c[1])}.required()`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"z.unknown()"}function
|
|
6
|
+
})`;if(r.typeAnnotation)return m(r.typeAnnotation);return"z.unknown()"}function m(r){let t=r.trim();if(t==="string")return"z.string()";if(t==="number")return"z.number()";if(t==="boolean")return"z.boolean()";if(t==="null")return"z.null()";if(t==="undefined")return"z.undefined()";if(t==="any")return"z.any()";if(t==="unknown")return"z.unknown()";if(t==="never")return"z.never()";if(t==="void")return"z.void()";if(t==="bigint")return"z.bigint()";if(t==="symbol")return"z.symbol()";if(t==="Date")return"z.date()";if(t.startsWith("'")||t.startsWith('"'))return`z.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`z.literal(${t})`;if(t==="true"||t==="false")return`z.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`z.array(${m(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`z.tuple([${l(n[1],",").map((b)=>m(b.trim())).join(", ")}])`;if(t.includes("|")){let y=l(t,"|");if(y.length>1){let b=y.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined"),f=y.some((a)=>a.trim()==="null"),d=y.some((a)=>a.trim()==="undefined");if((f||d)&&b.length===1){let a=m(b[0]);if(f)a=`${a}.nullable()`;if(d)a=`${a}.optional()`;return a}return`z.union([${y.map((a)=>m(a.trim())).join(", ")}])`}}if(t.includes("&")){let y=l(t,"&");if(y.length>1)return y.map((f)=>m(f.trim())).reduce((f,d)=>`${f}.and(${d})`)}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`z.record(${m(i[1])}, ${m(i[2])})`;let s=t.match(/^Promise<(.+)>$/i);if(s)return`z.promise(${m(s[1])})`;let o=t.match(/^Map<(.+),\s*(.+)>$/i);if(o)return`z.map(${m(o[1])}, ${m(o[2])})`;let u=t.match(/^Set<(.+)>$/i);if(u)return`z.set(${m(u[1])})`;let h=t.match(/^Partial<(.+)>$/i);if(h)return`${m(h[1])}.partial()`;let c=t.match(/^Required<(.+)>$/i);if(c)return`${m(c[1])}.required()`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"z.unknown()"}function kr(r,t={}){let e=["import * as v from 'valibot'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=j(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = v.InferOutput<typeof ${i}>`),e.push("")}return e.join(`
|
|
7
7
|
`)}function j(r,t){if(r.members&&r.members.length>0)return`v.object({
|
|
8
8
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=g(n.typeAnnotation);if(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional)i=`v.optional(${i})`;return` ${n.name}: ${i}`}).join(`,
|
|
9
9
|
`)}
|
|
10
|
-
})`;if(r.typeAnnotation)return g(r.typeAnnotation);return"v.unknown()"}function g(r){let t=r.trim();if(t==="string")return"v.string()";if(t==="number")return"v.number()";if(t==="boolean")return"v.boolean()";if(t==="null")return"v.null_()";if(t==="undefined")return"v.undefined_()";if(t==="any")return"v.any()";if(t==="unknown")return"v.unknown()";if(t==="never")return"v.never()";if(t==="void")return"v.void_()";if(t==="bigint")return"v.bigint()";if(t==="symbol")return"v.symbol()";if(t==="Date")return"v.date()";if(t.startsWith("'")||t.startsWith('"'))return`v.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`v.literal(${t})`;if(t==="true"||t==="false")return`v.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`v.array(${g(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`v.tuple([${l(n[1],",").map((o)=>g(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1){let o=s.filter((c)=>c.trim()!=="null"&&c.trim()!=="undefined"),u=s.some((c)=>c.trim()==="null"),h=s.some((c)=>c.trim()==="undefined");if((u||h)&&o.length===1){let c=g(o[0]);if(u)c=`v.nullable(${c})`;if(h)c=`v.optional(${c})`;return c}return`v.union([${s.map((c)=>g(c.trim())).join(", ")}])`}}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`v.intersect([${s.map((o)=>g(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`v.record(${g(i[1])}, ${g(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"v.unknown()"}function
|
|
10
|
+
})`;if(r.typeAnnotation)return g(r.typeAnnotation);return"v.unknown()"}function g(r){let t=r.trim();if(t==="string")return"v.string()";if(t==="number")return"v.number()";if(t==="boolean")return"v.boolean()";if(t==="null")return"v.null_()";if(t==="undefined")return"v.undefined_()";if(t==="any")return"v.any()";if(t==="unknown")return"v.unknown()";if(t==="never")return"v.never()";if(t==="void")return"v.void_()";if(t==="bigint")return"v.bigint()";if(t==="symbol")return"v.symbol()";if(t==="Date")return"v.date()";if(t.startsWith("'")||t.startsWith('"'))return`v.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`v.literal(${t})`;if(t==="true"||t==="false")return`v.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`v.array(${g(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`v.tuple([${l(n[1],",").map((o)=>g(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1){let o=s.filter((c)=>c.trim()!=="null"&&c.trim()!=="undefined"),u=s.some((c)=>c.trim()==="null"),h=s.some((c)=>c.trim()==="undefined");if((u||h)&&o.length===1){let c=g(o[0]);if(u)c=`v.nullable(${c})`;if(h)c=`v.optional(${c})`;return c}return`v.union([${s.map((c)=>g(c.trim())).join(", ")}])`}}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`v.intersect([${s.map((o)=>g(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`v.record(${g(i[1])}, ${g(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"v.unknown()"}function Tr(r,t={}){let e=["import * as t from 'io-ts'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Codec`,s=A(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = t.TypeOf<typeof ${i}>`),e.push("")}return e.join(`
|
|
11
11
|
`)}function A(r,t){if(r.members&&r.members.length>0){let e=[],n=[];for(let i of r.members){if(!i.name||!i.typeAnnotation)continue;let s=O(i.typeAnnotation),o=i.modifiers?.includes("?")||i.text?.includes("?:")||t.allOptional,u=` ${i.name}: ${s}`;if(o)n.push(u);else e.push(u)}if(n.length>0)return`t.intersection([
|
|
12
12
|
t.type({
|
|
13
13
|
${e.join(`,
|
|
@@ -20,15 +20,15 @@ ${n.join(`,
|
|
|
20
20
|
])`;return`t.type({
|
|
21
21
|
${e.join(`,
|
|
22
22
|
`)}
|
|
23
|
-
})`}if(r.typeAnnotation)return O(r.typeAnnotation);return"t.unknown"}function O(r){let t=r.trim();if(t==="string")return"t.string";if(t==="number")return"t.number";if(t==="boolean")return"t.boolean";if(t==="null")return"t.null";if(t==="undefined")return"t.undefined";if(t==="any")return"t.unknown";if(t==="unknown")return"t.unknown";if(t==="never")return"t.never";if(t==="void")return"t.void";if(t.startsWith("'")||t.startsWith('"'))return`t.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`t.literal(${t})`;if(t==="true"||t==="false")return`t.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`t.array(${O(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`t.tuple([${l(n[1],",").map((o)=>O(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1)return`t.union([${s.map((o)=>O(o.trim())).join(", ")}])`}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`t.intersection([${s.map((o)=>O(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`t.record(${O(i[1])}, ${O(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Codec`;return"t.unknown"}function
|
|
23
|
+
})`}if(r.typeAnnotation)return O(r.typeAnnotation);return"t.unknown"}function O(r){let t=r.trim();if(t==="string")return"t.string";if(t==="number")return"t.number";if(t==="boolean")return"t.boolean";if(t==="null")return"t.null";if(t==="undefined")return"t.undefined";if(t==="any")return"t.unknown";if(t==="unknown")return"t.unknown";if(t==="never")return"t.never";if(t==="void")return"t.void";if(t.startsWith("'")||t.startsWith('"'))return`t.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`t.literal(${t})`;if(t==="true"||t==="false")return`t.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`t.array(${O(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`t.tuple([${l(n[1],",").map((o)=>O(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1)return`t.union([${s.map((o)=>O(o.trim())).join(", ")}])`}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`t.intersection([${s.map((o)=>O(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`t.record(${O(i[1])}, ${O(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Codec`;return"t.unknown"}function Ar(r,t={}){let e=["import * as yup from 'yup'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=z(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = yup.InferType<typeof ${i}>`),e.push("")}return e.join(`
|
|
24
24
|
`)}function z(r,t){if(r.members&&r.members.length>0)return`yup.object({
|
|
25
25
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=T(n.typeAnnotation);if(!(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional))i=`${i}.required()`;return` ${n.name}: ${i}`}).join(`,
|
|
26
26
|
`)}
|
|
27
|
-
})`;if(r.typeAnnotation)return T(r.typeAnnotation);return"yup.mixed()"}function T(r){let t=r.trim();if(t==="string")return"yup.string()";if(t==="number")return"yup.number()";if(t==="boolean")return"yup.boolean()";if(t==="Date")return"yup.date()";if(t==="any"||t==="unknown")return"yup.mixed()";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`yup.array().of(${T(e[1])})`;if(t.includes("|")){let n=l(t,"|");if(n.length>1){let i=n.filter((o)=>o.trim()!=="null"&&o.trim()!=="undefined");if(n.some((o)=>o.trim()==="null"||o.trim()==="undefined")&&i.length===1)return`${T(i[0])}.nullable()`}}if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"yup.mixed()"}function
|
|
27
|
+
})`;if(r.typeAnnotation)return T(r.typeAnnotation);return"yup.mixed()"}function T(r){let t=r.trim();if(t==="string")return"yup.string()";if(t==="number")return"yup.number()";if(t==="boolean")return"yup.boolean()";if(t==="Date")return"yup.date()";if(t==="any"||t==="unknown")return"yup.mixed()";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`yup.array().of(${T(e[1])})`;if(t.includes("|")){let n=l(t,"|");if(n.length>1){let i=n.filter((o)=>o.trim()!=="null"&&o.trim()!=="undefined");if(n.some((o)=>o.trim()==="null"||o.trim()==="undefined")&&i.length===1)return`${T(i[0])}.nullable()`}}if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"yup.mixed()"}function Pr(r,t={}){let e=["import { type } from 'arktype'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||n.name,s=w(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name}Type = typeof ${i}.infer`),e.push("")}return e.join(`
|
|
28
28
|
`)}function w(r,t){if(r.members&&r.members.length>0)return`type({
|
|
29
29
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=S(n.typeAnnotation);return` ${n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional?`'${n.name}?'`:`${n.name}`}: ${i}`}).join(`,
|
|
30
30
|
`)}
|
|
31
|
-
})`;if(r.typeAnnotation)return`type(${S(r.typeAnnotation)})`;return"type('unknown')"}function S(r){let t=r.trim();if(t==="string")return"'string'";if(t==="number")return"'number'";if(t==="boolean")return"'boolean'";if(t==="null")return"'null'";if(t==="undefined")return"'undefined'";if(t==="bigint")return"'bigint'";if(t==="symbol")return"'symbol'";if(t==="Date")return"'Date'";if(t==="any"||t==="unknown")return"'unknown'";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`${S(e[1])}.array()`;if(t.includes("|")){let n=l(t,"|");if(n.length>1)return`'${n.map((i)=>i.trim()).join(" | ")}'`}if(t.startsWith("'")||t.startsWith('"'))return`'${t}'`;return`'${t}'`}function l(r,t){let e=[],n="",i=0;for(let s=0;s<r.length;s++){let o=r[s];if(o==="<"||o==="("||o==="["||o==="{")i++,n+=o;else if(o===">"||o===")"||o==="]"||o==="}")i--,n+=o;else if(i===0&&r.slice(s,s+t.length)===t)e.push(n.trim()),n="",s+=t.length-1;else n+=o}if(n.trim())e.push(n.trim());return e}function v(r){for(let t of r){let e=t.replace(/^\/\*\*|\*\/$/g,"").replace(/^\s*\*\s?/gm,"").replace(/@\w.*/g,"").trim();if(e)return e}return null}function
|
|
31
|
+
})`;if(r.typeAnnotation)return`type(${S(r.typeAnnotation)})`;return"type('unknown')"}function S(r){let t=r.trim();if(t==="string")return"'string'";if(t==="number")return"'number'";if(t==="boolean")return"'boolean'";if(t==="null")return"'null'";if(t==="undefined")return"'undefined'";if(t==="bigint")return"'bigint'";if(t==="symbol")return"'symbol'";if(t==="Date")return"'Date'";if(t==="any"||t==="unknown")return"'unknown'";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`${S(e[1])}.array()`;if(t.includes("|")){let n=l(t,"|");if(n.length>1)return`'${n.map((i)=>i.trim()).join(" | ")}'`}if(t.startsWith("'")||t.startsWith('"'))return`'${t}'`;return`'${t}'`}function l(r,t){let e=[],n="",i=0;for(let s=0;s<r.length;s++){let o=r[s];if(o==="<"||o==="("||o==="["||o==="{")i++,n+=o;else if(o===">"||o===")"||o==="]"||o==="}")i--,n+=o;else if(i===0&&r.slice(s,s+t.length)===t)e.push(n.trim()),n="",s+=t.length-1;else n+=o}if(n.trim())e.push(n.trim());return e}function v(r){for(let t of r){let e=t.replace(/^\/\*\*|\*\/$/g,"").replace(/^\s*\*\s?/gm,"").replace(/@\w.*/g,"").trim();if(e)return e}return null}function ks(r,t){switch(t.format){case"json-schema":return $r(r,t);case"zod":return Er(r,t);case"valibot":return kr(r,t);case"io-ts":return Tr(r,t);case"yup":return Ar(r,t);case"arktype":return Pr(r,t);case"dts":default:return r.map((e)=>e.text).join(`
|
|
32
32
|
|
|
33
|
-
`)}}function
|
|
34
|
-
export{
|
|
33
|
+
`)}}function Ts(r){switch(r){case"json-schema":return".schema.json";case"zod":case"valibot":case"io-ts":case"yup":case"arktype":return".schema.ts";case"dts":default:return".d.ts"}}
|
|
34
|
+
export{$r,Er,kr,Tr,Ar,Pr,ks,Ts};
|
|
@@ -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 L={rootDir:process.cwd(),maxFileSize:10485760,maxTotalSize:104857600,timeout:30000,followSymlinks:!1,maxFiles:1e4,blockedPatterns:["**/.git/**","**/node_modules/**","**/.env*","**/secrets/**","**/*.key","**/*.pem"]};class C extends Error{code;path;constructor(t,r,e){super(t);this.code=r;this.path=e;this.name="SecurityError"}}function
|
|
3
|
-
export{L,C,
|
|
2
|
+
import{lstat as d,realpath as f,stat as T}from"fs/promises";import{isAbsolute as l,normalize as g,relative as p,resolve as u}from"path";var L={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 Be(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 Fr(t,r={}){return t.map((e)=>Be(e,r))}function en(t,r={}){let e=r.blockedPatterns||L.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 Lr(t,r={}){let e=r.maxFileSize??L.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 Nr(t){try{return(await d(t)).isSymbolicLink()}catch{return!1}}async function Br(t,r={}){let e=r.followSymlinks??L.followSymlinks;if(await Nr(t)){if(!e)throw new C(`Symbolic links not allowed: "${t}"`,"SYMLINK_NOT_ALLOWED",t);let i=await f(t);return Be(i,r)}return t}async function ut(t,r={}){let e=Be(t,r);if(en(e,r))throw new C(`Path matches blocked pattern: "${t}"`,"BLOCKED_PATTERN",t);let i=await Br(e,r),n=await Lr(i,r);return{path:i,size:n}}async function tn(t,r={}){let e=r.maxFiles??L.maxFiles,i=r.maxTotalSize??L.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 ut(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 ft(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 Wr(t,r={}){let e=r.timeout??L.timeout;return async(i)=>{let{path:n}=await ut(i,r);return ft(t(n),e,`Processing ${i}`)}}function Us(t,r={}){let e=r.timeout??L.timeout;return async(i)=>{let{paths:n}=await tn(i,r);return ft(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 Hs(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 Ks(t={}){let r={...L,...t};return{validatePath:(e)=>Be(e,r),validatePaths:(e)=>Fr(e,r),validateFile:(e)=>ut(e,r),validateBatch:(e)=>tn(e,r),withTimeout:(e,i)=>ft(e,r.timeout,i),secureProcessor:(e)=>Wr(e,r),isBlocked:(e)=>en(e,r),getConfig:()=>r}}
|
|
3
|
+
export{L,C,Be,Fr,en,Lr,Nr,Br,ut,tn,ft,Wr,Us,zs,Hs,Ks};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
3
|
-
`);if(r!==-1)i=n.slice(r+1),s=!0;else i="",s=!0}}return i.trim()}function
|
|
4
|
-
`),r=[],t=n.length-1,u=!1,a=[];while(t>=0){let l=n[t].trim();if(l.endsWith("*/")&&!u)u=!0,a.unshift(l);else if(l.startsWith("/*")&&u)a.unshift(l),r.unshift(...a),a=[],u=!1;else if(u)a.unshift(l);else if(l.startsWith("//"))r.unshift(l);else if(l.startsWith("*")&&(t>0&&n[t-1].trim().startsWith("/*")))r.unshift(l);else if(l===""&&r.length>0);else if(l!=="")break;t--}return r}function
|
|
5
|
-
export{
|
|
2
|
+
function Ls(e,i){return e.getText?.()??i.slice(e.pos??0,e.end??i.length)}function Ns(e){return e.getFullText?.().match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g)??[]}function Zt(e){let i=e,s=!0;while(s){s=!1;let n=i.trimStart();if(n.startsWith("/*")){let r=n.indexOf("*/",2);if(r!==-1){i=n.slice(r+2),s=!0;continue}}if(n.startsWith("//")){let r=n.indexOf(`
|
|
3
|
+
`);if(r!==-1)i=n.slice(r+1),s=!0;else i="",s=!0}}return i.trim()}function Bs(e,i){let n=e.substring(0,i).split(`
|
|
4
|
+
`),r=[],t=n.length-1,u=!1,a=[];while(t>=0){let l=n[t].trim();if(l.endsWith("*/")&&!u)u=!0,a.unshift(l);else if(l.startsWith("/*")&&u)a.unshift(l),r.unshift(...a),a=[],u=!1;else if(u)a.unshift(l);else if(l.startsWith("//"))r.unshift(l);else if(l.startsWith("*")&&(t>0&&n[t-1].trim().startsWith("/*")))r.unshift(l);else if(l===""&&r.length>0);else if(l!=="")break;t--}return r}function Ws(e){let i=!1,s="",n=!1;for(let r=0;r<e.length;r++){let t=e[r];if(!n&&!i&&(t==='"'||t==="'"||t==="`"))i=!0,s=t;else if(!n&&i&&t===s)i=!1;else if(t==="\\"&&!n){n=!0;continue}else if(!i&&t==="/"&&r<e.length-1){if(e[r+1]==="/")return e.substring(r)}n=!1}return null}function Qt(e,i,s){let n=0,r=!1,t="",u=!1;if(!e.startsWith(i))return null;for(let a=0;a<e.length;a++){let l=e[a];if(!u&&(l==='"'||l==="'"||l==="`")){if(!r)r=!0,t=l;else if(l===t)r=!1}if(l==="\\"&&!u){u=!0;continue}if(u=!1,!r){if(e.substring(a,a+i.length)===i)n++;else if(e.substring(a,a+s.length)===s){if(n--,n===0)return{content:e.substring(0,a+s.length),rest:e.substring(a+s.length)}}}}return null}function js(e){let i=Zt(e).trim(),s=i.match(/^(export\s+)?(async\s+)?function\s*(\*?)([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=[];if(s[1])n.push("export");if(s[2])n.push("async");if(s[3])n.push("generator");let r=s[4],t=i.substring(s[0].length).trim(),u="";if(t.startsWith("<")){let o=Qt(t,"<",">");if(o)u=o.content,t=o.rest.trim()}let a="";if(t.startsWith("(")){let o=Qt(t,"(",")");if(o)a=o.content.slice(1,-1).trim(),t=o.rest.trim()}let l="void";if(t.startsWith(":")){let o=t.match(/^:\s*([^{;]+)/);if(o)l=o[1].trim()}return{name:r,generics:u,parameters:a,returnType:l,modifiers:n}}function _s(e){return/^\s*export\s+/.test(e)}function Gs(e){return/^\s*export\s+type\s+/.test(e)}function Vs(e){let i=Zt(e).trim(),s=i.match(/^(export\s+)?(const|let|var)\s+([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=s[2],r=s[3],t=i.substring(s[0].length).trim(),u;if(t.startsWith(":")){let l=t.indexOf("=");if(l!==-1)u=t.substring(1,l).trim(),t=t.substring(l).trim();else u=t.substring(1).replace(/;?\s*$/,"").trim(),t=""}let a;if(t.startsWith("="))a=t.substring(1).replace(/;?\s*$/,"").trim();return{kind:n,name:r,typeAnnotation:u,value:a}}
|
|
5
|
+
export{Ls,Ns,Zt,Bs,Ws,Qt,js,_s,Gs,Vs};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var e="@dtsx/dtsx",i="module",n="0.11.
|
|
2
|
+
var e="@dtsx/dtsx",i="module",n="0.11.38",r=!0,c="A modern, fast .d.ts generation tool, powered by Bun.",u="Chris Breuer <chris@stacksjs.org>",a="MIT",b="https://github.com/stacksjs/dtsx#readme",o={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},p={url:"https://github.com/stacksjs/dtsx/issues"},d=["dts","generation","isolated declarations","development","bun","stacks","typescript","javascript"],m={".":{import:"./dist/index.js"},"./*":{import:"./dist/*"}},l="./dist/index.js",k="./dist/index.d.ts",x={dtsx:"./dist/cli.js"},g=["dist"],h={benchmark:"bun benchmark/index.ts","benchmark:prepare":"cd packages/zig-dtsx && zig build -Doptimize=ReleaseFast && cd ../.. && bun build benchmark/oxc-emit.ts --compile --splitting --bytecode --minify --format=esm --outfile benchmark/oxc-emit","benchmark:publish":"bun benchmark/index.ts --json benchmark/results.json --runs 3 && bun benchmark/render.ts","benchmark:tsdown":"bun benchmark/tsdown.ts",build:"bun --filter './packages/dtsx' build",test:"find packages -name '*.test.ts' -print | xargs bun test","test:public-sdk":"bun scripts/verify-public-sdk.ts","test:standalone":"bun scripts/verify-standalone.ts","typecheck:public-sdk":"bun x tsc --project tsconfig.public-sdk.json",lint:"bun x --bun pickier .","lint:fix":"bun x --bun pickier . --fix",format:"bun x --bun pickier . --format","format:fix":"bun x --bun pickier . --format --write",changelog:"bun x @stacksjs/logsmith --verbose","changelog:generate":"bun x @stacksjs/logsmith --output CHANGELOG.md",release:"bun x --bun @stacksjs/bumpx prompt --recursive","release:patch":"bun x --bun @stacksjs/bumpx patch --recursive --commit --tag --push --yes","release:minor":"bun x --bun @stacksjs/bumpx minor --recursive --commit --tag --push --yes",typecheck:"bun x tsc --noEmit","dev:docs":"bun --bun bunpress dev docs","build:docs":"bun --bun bunpress build docs","preview:docs":"bun --bun bunpress preview docs"},j={"@stacksjs/bumpx":"^0.2.32","@stacksjs/bunpress":"^0.2.31","@stacksjs/clapp":"^0.2.16",pickier:"^0.1.88","@stacksjs/gitlint":"^0.1.8","@stacksjs/logsmith":"^0.2.14","@types/bun":"^1.4.4","buddy-bot":"^0.10.5","bun-git-hooks":"^0.3.3","bun-plugin-dtsx":"workspace:*",mitata:"^1.0.34","oxc-transform":"^0.157.0","oxc-parser":"^0.157.0",tsdown:"^0.23.7",typescript:"^7.0.2"},y=["packages/*"],f={typescript:"^7.0.2"},v={name:e,type:i,version:n,private:r,description:c,author:u,license:a,homepage:b,repository:o,bugs:p,keywords:d,exports:m,module:l,types:k,bin:x,files:g,scripts:h,devDependencies:j,workspaces:y,overrides:f,"git-hooks":{"pre-commit":{"staged-lint":{"*.{js,ts,json,yaml,yml,md}":"bun x --bun pickier lint --fix"}},"commit-msg":"bun x gitlint --edit .git/COMMIT_EDITMSG"}};export{u as author,x as bin,p as bugs,v as default,c as description,j as devDependencies,m as exports,g as files,b as homepage,d as keywords,a as license,l as module,e as name,f as overrides,r as private,o as repository,h as scripts,i as type,k as types,n as version,y as workspaces};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-jcckwgb9.js";import{e}from"./chunk-yay68832.js";import{existsSync as j,mkdirSync as S,readFileSync as E,writeFileSync as f}from"fs";import{basename as h,join as g}from"path";function Ht(t){let n={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!t||t.length===0)return n;for(let s of t){let o=s.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
|
|
3
3
|
`).map((p)=>p.replace(/^\s*\*\s?/,"")).join(`
|
|
4
|
-
`).trim(),i=o.search(/@\w+/);if(i===-1){n.description=o;continue}else if(i>0)n.description=o.slice(0,i).trim(),o=o.slice(i);let a=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,c;while((c=a.exec(o))!==null){let[,p,u,d]=c,m=d.trim();switch(p){case"param":{let l=m.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(l)n.params.push({name:l[2],type:u,description:l[3].trim(),optional:!!l[1]});break}case"returns":case"return":n.returns={type:u,description:m};break;case"example":n.examples.push(m);break;case"deprecated":n.deprecated=m||"Deprecated";break;case"since":n.since=m;break;case"see":n.see.push(m);break;case"throws":case"throw":n.throws.push({type:u,description:m});break;case"category":n.category=m;break;default:if(!n.tags[p])n.tags[p]=[];n.tags[p].push(m)}}}return n}function w(t,n){let s=
|
|
5
|
-
`)}function k(t,n){let s=[];if(s.push(`### ${t.name}`),s.push(""),t.jsdoc.deprecated)s.push(`> **Deprecated:** ${t.jsdoc.deprecated}`),s.push("");if(s.push("```typescript"),s.push(t.signature),s.push("```"),s.push(""),t.jsdoc.description)s.push(t.jsdoc.description),s.push("");if(t.jsdoc.params.length>0){s.push("**Parameters:**"),s.push(""),s.push("| Name | Type | Description |"),s.push("|------|------|-------------|");for(let o of t.jsdoc.params){let i=o.optional?" (optional)":"",a=o.type||"any";s.push(`| \`${o.name}\`${i} | \`${a}\` | ${o.description} |`)}s.push("")}if(t.jsdoc.returns){s.push("**Returns:**"),s.push("");let o=t.jsdoc.returns.type?`\`${t.jsdoc.returns.type}\``:"";s.push(`${o} ${t.jsdoc.returns.description}`),s.push("")}if(t.jsdoc.throws.length>0){s.push("**Throws:**"),s.push("");for(let o of t.jsdoc.throws){let i=o.type?`\`${o.type}\``:"";s.push(`- ${i} ${o.description}`)}s.push("")}if(t.jsdoc.examples.length>0){s.push("**Examples:**"),s.push("");for(let o of t.jsdoc.examples)s.push("```typescript"),s.push(o),s.push("```"),s.push("")}if(t.jsdoc.see.length>0){s.push("**See also:**"),s.push("");for(let o of t.jsdoc.see)s.push(`- ${o}`);s.push("")}if(t.jsdoc.since)s.push(`*Since: ${t.jsdoc.since}*`),s.push("");if(n.includeSourceLinks&&t.sourceFile){let o=t.sourceFile;if(n.sourceBaseUrl)s.push(`[Source](${n.sourceBaseUrl}/${o})`);else s.push(`*Source: ${o}*`);s.push("")}if(t.members&&t.members.length>0){s.push("**Members:**"),s.push("");for(let o of t.members)if(s.push(`#### ${o.name}`),s.push(""),s.push("```typescript"),s.push(o.signature),s.push("```"),s.push(""),o.jsdoc.description)s.push(o.jsdoc.description),s.push("")}return s.push("---"),s.push(""),s}function
|
|
4
|
+
`).trim(),i=o.search(/@\w+/);if(i===-1){n.description=o;continue}else if(i>0)n.description=o.slice(0,i).trim(),o=o.slice(i);let a=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,c;while((c=a.exec(o))!==null){let[,p,u,d]=c,m=d.trim();switch(p){case"param":{let l=m.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(l)n.params.push({name:l[2],type:u,description:l[3].trim(),optional:!!l[1]});break}case"returns":case"return":n.returns={type:u,description:m};break;case"example":n.examples.push(m);break;case"deprecated":n.deprecated=m||"Deprecated";break;case"since":n.since=m;break;case"see":n.see.push(m);break;case"throws":case"throw":n.throws.push({type:u,description:m});break;case"category":n.category=m;break;default:if(!n.tags[p])n.tags[p]=[];n.tags[p].push(m)}}}return n}function w(t,n){let s=Ht(t.leadingComments),o="";switch(t.kind){case"function":o=M(t);break;case"variable":o=C(t);break;case"interface":o=P(t);break;case"type":o=v(t);break;case"class":o=T(t);break;case"enum":o=F(t);break;default:o=t.text||t.name}let i={name:t.name,kind:t.kind,signature:o,jsdoc:s,isExported:t.isExported,isDefault:t.isDefault,sourceFile:n};if(t.members&&t.members.length>0)i.members=t.members.map((a)=>w(a,n));return i}function M(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("function"),n.push(t.name),t.generics)n.push(t.generics);if(t.parameters){let s=t.parameters.map((o)=>{let i="";if(o.rest)i+="...";if(i+=o.name,o.optional)i+="?";if(o.type)i+=`: ${o.type}`;return i}).join(", ");n.push(`(${s})`)}else n.push("()");if(t.returnType)n.push(`: ${t.returnType}`);return n.join(" ").replace(/\s+/g," ")}function C(t){let n=[];if(t.isExported)n.push("export");if(n.push("const"),n.push(t.name),t.typeAnnotation)n.push(`: ${t.typeAnnotation}`);return n.join(" ")}function P(t){let n=[];if(t.isExported)n.push("export");if(n.push("interface"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);return n.join(" ")}function v(t){let n=[];if(t.isExported)n.push("export");if(n.push("type"),n.push(t.name),t.generics)n.push(t.generics);if(n.push("="),t.typeAnnotation)n.push(t.typeAnnotation);return n.join(" ")}function T(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("class"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)n.push(`implements ${t.implements.join(", ")}`);return n.join(" ")}function F(t){let n=[];if(t.isExported)n.push("export");return n.push("enum"),n.push(t.name),n.join(" ")}async function Kt(t,n={}){let s=[],o=new Map;for(let i of t){if(!j(i)){e.warn(`File not found: ${i}`);continue}let a=E(i,"utf-8"),c=r(a,i,!0);for(let p of c){if(p.kind==="import")continue;if(!n.includePrivate&&p.name.startsWith("_"))continue;if(!n.includeInternal&&p.leadingComments?.some((d)=>d.includes("@internal")))continue;let u=w(p,i);if(s.push(u),n.groupByCategory&&u.jsdoc.category){let d=u.jsdoc.category;if(!o.has(d))o.set(d,[]);o.get(d).push(u)}}}return{title:n.title||"API Documentation",description:n.description,entries:s,categories:o,generatedAt:new Date}}function Ne(t,n={}){let s=[];if(s.push(`# ${t.title}`),s.push(""),t.description)s.push(t.description),s.push("");if(s.push(`> Generated on ${t.generatedAt.toISOString()}`),s.push(""),s.push("## Table of Contents"),s.push(""),n.groupByCategory&&t.categories.size>0)for(let o of t.categories.keys())s.push(`- [${o}](#${D(o)})`);else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0)s.push(`- [${b(i)}](#${D(b(i))})`)}if(s.push(""),n.groupByCategory&&t.categories.size>0)for(let[o,i]of t.categories){s.push(`## ${o}`),s.push("");for(let a of i)s.push(...k(a,n))}else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0){s.push(`## ${b(i)}`),s.push("");for(let c of a)s.push(...k(c,n))}}return s.join(`
|
|
5
|
+
`)}function k(t,n){let s=[];if(s.push(`### ${t.name}`),s.push(""),t.jsdoc.deprecated)s.push(`> **Deprecated:** ${t.jsdoc.deprecated}`),s.push("");if(s.push("```typescript"),s.push(t.signature),s.push("```"),s.push(""),t.jsdoc.description)s.push(t.jsdoc.description),s.push("");if(t.jsdoc.params.length>0){s.push("**Parameters:**"),s.push(""),s.push("| Name | Type | Description |"),s.push("|------|------|-------------|");for(let o of t.jsdoc.params){let i=o.optional?" (optional)":"",a=o.type||"any";s.push(`| \`${o.name}\`${i} | \`${a}\` | ${o.description} |`)}s.push("")}if(t.jsdoc.returns){s.push("**Returns:**"),s.push("");let o=t.jsdoc.returns.type?`\`${t.jsdoc.returns.type}\``:"";s.push(`${o} ${t.jsdoc.returns.description}`),s.push("")}if(t.jsdoc.throws.length>0){s.push("**Throws:**"),s.push("");for(let o of t.jsdoc.throws){let i=o.type?`\`${o.type}\``:"";s.push(`- ${i} ${o.description}`)}s.push("")}if(t.jsdoc.examples.length>0){s.push("**Examples:**"),s.push("");for(let o of t.jsdoc.examples)s.push("```typescript"),s.push(o),s.push("```"),s.push("")}if(t.jsdoc.see.length>0){s.push("**See also:**"),s.push("");for(let o of t.jsdoc.see)s.push(`- ${o}`);s.push("")}if(t.jsdoc.since)s.push(`*Since: ${t.jsdoc.since}*`),s.push("");if(n.includeSourceLinks&&t.sourceFile){let o=t.sourceFile;if(n.sourceBaseUrl)s.push(`[Source](${n.sourceBaseUrl}/${o})`);else s.push(`*Source: ${o}*`);s.push("")}if(t.members&&t.members.length>0){s.push("**Members:**"),s.push("");for(let o of t.members)if(s.push(`#### ${o.name}`),s.push(""),s.push("```typescript"),s.push(o.signature),s.push("```"),s.push(""),o.jsdoc.description)s.push(o.jsdoc.description),s.push("")}return s.push("---"),s.push(""),s}function qt(t,n={}){let s=Ne(t,n);return`<!DOCTYPE html>
|
|
6
6
|
<html lang="en">
|
|
7
7
|
<head>
|
|
8
8
|
<meta charset="UTF-8">
|
|
@@ -97,6 +97,6 @@ import{r}from"./chunk-qnf4byak.js";import{e}from"./chunk-km8t8gqg.js";import{exi
|
|
|
97
97
|
document.getElementById('content').innerHTML = marked.parse(markdown);
|
|
98
98
|
</script>
|
|
99
99
|
</body>
|
|
100
|
-
</html>`}function
|
|
101
|
-
`)),e.info(`Generated: ${g(n.outdir,"README.md")}`)}else{let o=
|
|
102
|
-
export{
|
|
100
|
+
</html>`}function Jt(t,n={}){let s={title:t.title,description:t.description,generatedAt:t.generatedAt.toISOString(),version:"1.0.0",entries:t.entries.map((o)=>({name:o.name,kind:o.kind,signature:o.signature,description:o.jsdoc.description,isExported:o.isExported,isDefault:o.isDefault,deprecated:o.jsdoc.deprecated,since:o.jsdoc.since,category:o.jsdoc.category,params:o.jsdoc.params,returns:o.jsdoc.returns,examples:o.jsdoc.examples,throws:o.jsdoc.throws,see:o.jsdoc.see,tags:o.jsdoc.tags,sourceFile:o.sourceFile,sourceLine:o.sourceLine,members:o.members?.map((i)=>({name:i.name,kind:i.kind,signature:i.signature,description:i.jsdoc.description,deprecated:i.jsdoc.deprecated,params:i.jsdoc.params,returns:i.jsdoc.returns}))})),categories:n.groupByCategory?Object.fromEntries(Array.from(t.categories.entries()).map(([o,i])=>[o,i.map((a)=>a.name)])):void 0};return JSON.stringify(s,null,2)}function Sr(t){let n={id:0,name:t.title,kind:1,kindString:"Project",flags:{},children:t.entries.map((s,o)=>({id:o+1,name:s.name,kind:y(s.kind),kindString:s.kind,flags:{isExported:s.isExported,isDefault:s.isDefault},comment:s.jsdoc.description?{summary:[{kind:"text",text:s.jsdoc.description}],blockTags:s.jsdoc.deprecated?[{tag:"@deprecated",content:[{kind:"text",text:s.jsdoc.deprecated}]}]:void 0}:void 0,sources:s.sourceFile?[{fileName:s.sourceFile,line:s.sourceLine||1,character:0}]:void 0,signatures:s.kind==="function"?[{id:o+1000,name:s.name,kind:4096,kindString:"Call signature",parameters:s.jsdoc.params.map((i,a)=>({id:o+2000+a,name:i.name,kind:32768,kindString:"Parameter",flags:{isOptional:i.optional},type:i.type?{type:"intrinsic",name:i.type}:void 0,comment:i.description?{summary:[{kind:"text",text:i.description}]}:void 0})),type:s.jsdoc.returns?.type?{type:"intrinsic",name:s.jsdoc.returns.type}:void 0}]:void 0,children:s.members?.map((i,a)=>({id:o+3000+a,name:i.name,kind:y(i.kind),kindString:i.kind,comment:i.jsdoc.description?{summary:[{kind:"text",text:i.jsdoc.description}]}:void 0}))}))};return JSON.stringify(n,null,2)}async function $s(t,n){e.info("Extracting documentation...");let s=await Kt(t,n);if(e.info(`Found ${s.entries.length} documented entries`),!j(n.outdir))S(n.outdir,{recursive:!0});if(n.format==="markdown")if(n.splitByModule){let o=I(s.entries);for(let[a,c]of o){let p={title:h(a,".ts"),description:`Documentation for ${a}`,entries:c,categories:new Map,generatedAt:s.generatedAt},u=Ne(p,n),d=g(n.outdir,`${h(a,".ts")}.md`);f(d,u),e.info(`Generated: ${d}`)}let i=[`# ${s.title}`,"",s.description||"","","## Modules",""];for(let[a]of o){let c=h(a,".ts");i.push(`- [${c}](./${c}.md)`)}f(g(n.outdir,"README.md"),i.join(`
|
|
101
|
+
`)),e.info(`Generated: ${g(n.outdir,"README.md")}`)}else{let o=Ne(s,n),i=g(n.outdir,"API.md");f(i,o),e.info(`Generated: ${i}`)}else if(n.format==="json"){let o=Jt(s,n),i=g(n.outdir,"api.json");f(i,o),e.info(`Generated: ${i}`);let a=Sr(s),c=g(n.outdir,"typedoc.json");f(c,a),e.info(`Generated: ${c}`)}else{let o=qt(s,n),i=g(n.outdir,"index.html");f(i,o),e.info(`Generated: ${i}`)}}function D(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function b(t){return{function:"Functions",variable:"Variables",interface:"Interfaces",type:"Type Aliases",class:"Classes",enum:"Enums",export:"Exports",module:"Modules"}[t]||t}function x(t){let n=new Map,s=["function","class","interface","type","enum","variable"];for(let o of s)n.set(o,[]);for(let o of t){let i=o.kind;if(!n.has(i))n.set(i,[]);n.get(i).push(o)}return n}function A(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function I(t){let n=new Map;for(let s of t){let o=s.sourceFile||"unknown";if(!n.has(o))n.set(o,[]);n.get(o).push(s)}return n}function y(t){return{function:64,variable:32,interface:256,type:4194304,class:128,enum:8,property:1024,method:2048,module:2,namespace:4}[t]||0}function Es(t={}){return{extract:(n)=>Kt(n,t),generateMarkdown:(n)=>Ne(n,t),generateHTML:(n)=>qt(n,t),generateJSON:(n)=>Jt(n,t),parseJSDoc:Ht}}
|
|
102
|
+
export{Ht,Kt,Ne,qt,Jt,Sr,$s,Es};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{R,M}from"./chunk-sd8bywh9.js";import{P,D}from"./chunk-83qnrx0m.js";import{p}from"./chunk-v6fwy63g.js";import{T,O}from"./chunk-yx1jy7fx.js";import{Se}from"./chunk-189nn4fc.js";import{l}from"./chunk-y1g6v96c.js";import{pe}from"./chunk-mkakbjvs.js";function je(t,n,s,r,i){if(r.length!==1||r[0]!=="bun")return null;let o=R(n)?M(t):P(n)?D(t):t;return pe(o,{keepComments:s,isolatedDeclarations:i})}var S=100,h=0,c=new Map;function dt(t,n="stdin.ts",s=!0,r=["bun"],i=!1){let o=p(t),a=JSON.stringify([n,s,i,r]),g=c.get(a);if(g&&g.contentHash===o)return g.lastAccess=++h,g.result;let b=je(t,n,s,r,i)??y(t,n,s,r,i);if(c.set(a,{result:b,contentHash:o,lastAccess:++h}),c.size>S){let x=Math.max(1,Math.ceil(c.size*0.1)),u=[];for(let[e,f]of c)u.push([e,f.lastAccess]);u.sort((e,f)=>e[1]-f[1]);for(let e=0;e<x&&e<u.length;e++)c.delete(u[e][0])}return b}function Kr(t,n="stdin.ts",s=!0,r=["bun"]){return dt(t,n,s,r,!0)}function qr(t,n="stdin.ts",s=!0,r=["bun"]){return dt(t,n,s,r,!1)}function y(t,n,s,r,i){let o=Se(t,n,s,i);return l(o,{filePath:n,sourceCode:t,declarations:o},s,r)}function Jr(){c.clear()}function Ca(t,n="stdin.ts",s=!0,r=["bun"],i=!1){return je(t,n,s,r,i)??fn(t,n,s,r,i)}function fn(t,n="stdin.ts",s=!0,r=["bun"],i=!1){if(R(n))t=M(t);else if(P(n))t=D(t);let o=i?T(t,n,s):O(t,n,s);return l(o,{filePath:n,sourceCode:t,declarations:o},s,r)}
|
|
3
|
+
export{je,dt,Kr,qr,Jr,Ca,fn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
3
|
-
export{Fe,
|
|
2
|
+
import{s}from"./chunk-0zfzhn19.js";import w from"process";import{dirname as x,relative as y,resolve as B,sep as l}from"path";function Fe(p={}){let{preBuild:c=!1,postBuild:r=!0,onGenerated:n,onError:o,failOnError:E=!0,...e}=p,v=async(i)=>{try{let t=await s(i);n?.(t)}catch(t){let d=t instanceof Error?t:Error(String(t));if(o?.(d),!o)console.error("[dtsx] Generation failed:",d.message);if(E)throw d}};return{name:"dtsx",async setup(i){if(!c&&!r)return;let t=e.cwd||w.cwd(),u=(i.config.entrypoints||[]).map((a)=>B(t,a)),g=e.root||i.config.root||(u.length>0?y(t,G(u))||".":"./src"),f=B(t,g),m=e.entrypoints||u.filter((a)=>a===f||a.startsWith(`${f}${l}`)).map((a)=>y(f,a));await v({...e,cwd:t,root:g,entrypoints:m.length>0?m:["index.ts"],outdir:e.outdir||i.config.outdir||"./dist",moduleSpecifierMode:e.moduleSpecifierMode??(i.config.target==="node"?"node":"preserve")})}}}function G(p){let c=p.map((n)=>x(n).split(l)),r=c[0];for(let n of c.slice(1)){let o=0;while(o<r.length&&o<n.length&&r[o]===n[o])o++;r=r.slice(0,o)}return r.join(l)||l}var pa=Fe,ma=Fe;
|
|
3
|
+
export{Fe,pa,ma};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{B}from"./chunk-pga5m4wm.js";import{Se,En}from"./chunk-189nn4fc.js";import{Q,Tn}from"./chunk-3fbt79hx.js";function hi(){Tn(),En()}function r(e,t,c=!0,n=!1,o){return Se(e,t,c,n,o)}async function $n(e,t,c=!0,n={}){return await Q(t,e,n),r(e,t,c)}async function yi(e,t={}){let c=B(t.concurrency,4),n=new Map;for(let o=0;o<e.length;o+=c){let s=e.slice(o,o+c),i=await Promise.all(s.map(async(a)=>({path:a.filePath,declarations:await $n(a.sourceCode,a.filePath,a.keepComments,t)})));for(let a of i)n.set(a.path,a.declarations)}return n}
|
|
3
|
+
export{hi,r,$n,yi};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{S}from"./chunk-davy89dj.js";import{_}from"./chunk-7tremqhs.js";import{chmod as j,lstat as P,mkdir as y,readdir as q,realpath as L,rename as D,rm as R,rmdir as W,stat as A,writeFile as B}from"fs/promises";import{basename as J,dirname as m,isAbsolute as M,parse as U,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await L(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),J(e))}}async function z(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!S(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===U(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(S(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function X(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function x(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await x(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function G(a,e,n){for(let r of(await q(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await G(s,e,n);else if(X(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function de(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await z(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!S(t,n)||S(t,r)||!X(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],T=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!S(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(S(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await x(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await G(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await B(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await _(v,i.content,i.lineEnding),!a.clean&&u.existing)await j(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),T.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await x(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of T.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await W(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
|
|
3
|
+
export{z,de};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
2
|
+
function Bi(m,b={}){let{mergeInterfaces:c=!0,mergeNamespaces:e=!0,mergeTypes:n=!1,mergeEnums:l=!0,deduplicateIdentical:g=!0,conflictStrategy:d="last",preserveAllComments:h=!0}=b,u=[],r=0,f=new Map,o=[];for(let i of m){let a=`${i.kind}:${i.name}`,s=f.get(a);if(!s)s=[],f.set(a,s),o.push(a);s.push(i)}let t=[];for(let i of o){let a=f.get(i),s=a[0];if(a.length===1){t.push(s);continue}if(!(s.kind==="interface"&&c||s.kind==="module"&&e||s.kind==="type"&&n||s.kind==="enum"&&l)){t.push(...a);continue}let p=a;if(g)p=y(a);if(p.length===1){t.push(p[0]);continue}let x;switch(s.kind){case"interface":x=k(p,d,h);break;case"module":x=w(p,d,h);break;case"enum":x=M(p,d,h);break;case"type":x=A(p,d,h);break;default:x=p[0]}t.push(x),r+=p.length-1,u.push({name:s.name,kind:s.kind,sourceCount:p.length,memberCount:x.members?.length||0})}return{declarations:t,mergedCount:r,merges:u}}function y(m){let b=new Map;for(let c of m){let e=D(c.text);if(!b.has(e))b.set(e,c);else{let n=b.get(e);if((c.leadingComments?.length||0)>(n.leadingComments?.length||0))b.set(e,c)}}return Array.from(b.values())}function D(m){return m.replace(/\s+/g," ").replace(/;\s*/g,";").trim()}function k(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let a of m){if(c&&a.leadingComments&&g){for(let s of a.leadingComments)if(!g.has(s))g.add(s),l.push(s)}if(a.members)for(let s of a.members)if(!n.get(s.name))n.set(s.name,s);else switch(b){case"first":break;case"last":n.set(s.name,s);break;case"error":throw Error(`Conflicting member '${s.name}' in interface '${e.name}'`)}}let d=Array.from(n.values()),h=d.map((a)=>` ${a.text}`).join(`
|
|
3
3
|
`),u=e.generics||"",r=e.extends||"",f=new Set;for(let a of m)if(a.extends){let s=a.extends.split(",");for(let C of s){let p=C.trim();if(p)f.add(p)}}if(f.size>0)r=`extends ${Array.from(f).join(", ")}`;let o=e.isExported?"export ":"",t=e.modifiers?.includes("declare")?"declare ":"",i=`${o}${t}interface ${e.name}${u} ${r} {
|
|
4
4
|
${h}
|
|
5
5
|
}`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:i.replace(/\s+\{/," {").replace(/\{\s*\n\s*\n/,`{
|
|
@@ -9,10 +9,10 @@ ${h}
|
|
|
9
9
|
}`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:f}}function M(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let t of m){if(c&&t.leadingComments&&g){for(let i of t.leadingComments)if(!g.has(i))g.add(i),l.push(i)}if(t.members)for(let i of t.members)if(!n.get(i.name))n.set(i.name,i);else switch(b){case"first":break;case"last":n.set(i.name,i);break;case"error":throw Error(`Conflicting member '${i.name}' in enum '${e.name}'`)}}let d=Array.from(n.values()),h=d.map((t)=>` ${t.name}${t.value!==void 0?` = ${t.value}`:""}`).join(`,
|
|
10
10
|
`),u=e.isExported?"export ":"",r=e.modifiers?.includes("declare")?"declare ":"",f=e.modifiers?.includes("const")?"const ":"",o=`${u}${r}${f}enum ${e.name} {
|
|
11
11
|
${h}
|
|
12
|
-
}`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:o}}function A(m,b,c){let e=m[0],n=[],l=c?new Set:null,g=[],d=new Set;for(let o of m){if(c&&o.leadingComments&&l){for(let t of o.leadingComments)if(!l.has(t))l.add(t),n.push(t)}if(o.typeAnnotation&&!d.has(o.typeAnnotation))d.add(o.typeAnnotation),g.push(o.typeAnnotation)}if(g.length<=1)return{...e,leadingComments:n.length>0?n:e.leadingComments};let h=g.join(" | "),u=e.isExported?"export ":"",r=e.generics||"",f=`${u}type ${e.name}${r} = ${h}`;return{...e,typeAnnotation:h,leadingComments:n.length>0?n:e.leadingComments,text:f}}function
|
|
12
|
+
}`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:o}}function A(m,b,c){let e=m[0],n=[],l=c?new Set:null,g=[],d=new Set;for(let o of m){if(c&&o.leadingComments&&l){for(let t of o.leadingComments)if(!l.has(t))l.add(t),n.push(t)}if(o.typeAnnotation&&!d.has(o.typeAnnotation))d.add(o.typeAnnotation),g.push(o.typeAnnotation)}if(g.length<=1)return{...e,leadingComments:n.length>0?n:e.leadingComments};let h=g.join(" | "),u=e.isExported?"export ":"",r=e.generics||"",f=`${u}type ${e.name}${r} = ${h}`;return{...e,typeAnnotation:h,leadingComments:n.length>0?n:e.leadingComments,text:f}}function Wi(m,b={}){let c=m.split(`
|
|
13
13
|
`),e=new Map,n=null,l=0;for(let u=0;u<c.length;u++){let r=c[u],f=r.match(/^(export\s+)?(declare\s+)?interface\s+(\w+)/);if(f&&!n){n={name:f[3],start:u,lines:[r]},l=(r.match(/\{/g)||[]).length-(r.match(/\}/g)||[]).length;continue}if(n){if(n.lines.push(r),l+=(r.match(/\{/g)||[]).length-(r.match(/\}/g)||[]).length,l<=0){let o=e.get(n.name)||[];o.push({start:n.start,end:u,content:n.lines}),e.set(n.name,o),n=null,l=0}}}let g=Array.from(e.entries()).filter(([,u])=>u.length>1);if(g.length===0)return m;let d=[...c],h=new Set;for(let[u,r]of g){if(r.length<=1)continue;let[f,...o]=r,t=[],i=new Set;for(let C of r)for(let p of C.content){let x=p.trim();if(x.startsWith("interface")||x.startsWith("export")||x==="{"||x==="}")continue;if(x&&!i.has(x))i.add(x),t.push(p)}for(let C of o)for(let p=C.start;p<=C.end;p++)h.add(p);let a=f.content[0],s=[a.endsWith("{")?a:`${a} {`,...t,"}"];for(let C=f.start;C<=f.end;C++)h.add(C);d[f.start]=s.join(`
|
|
14
14
|
`)}return d.filter((u,r)=>!h.has(r)||d[r].includes("interface")).join(`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
17
|
`)}
|
|
18
|
-
export{
|
|
18
|
+
export{Bi,Wi};
|
|
@@ -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{q}from"./chunk-bxc2herz.js";function ci(n,r,e,t={}){return{kind:n,name:r,text:e,isExported:t.isExported??!1,...t}}function li(n){if(typeof structuredClone==="function")return structuredClone(n);return JSON.parse(JSON.stringify(n))}function Cn(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)Cn(t.members,r,t);r.leave?.(t,e)}}function vo(n,r){let e=[];return Cn(n,{enter:(t)=>{if(r(t))e.push(t)}}),e}async function ui(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 So(...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 ge(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 $o(n,r){return async(e,t)=>{if(n(e))return r(e,t);return}}function He(n){let r={createDeclaration:ci,cloneDeclaration:li,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 q({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)=>ui(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 Eo(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 fi(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 ko(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 di(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 To(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 Ao(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 Po(n){return ge("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 Do(n){return ge(["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 pi(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 mi=ge(["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}}),Ro=ge(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)\?:/g,"$1:");if(r===n.text)return;return{...n,text:r}}),Mo=ge(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)(?<!\?):/g,"$1?:");if(r===n.text)return;return{...n,text:r}});function Oo(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 Io(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 Fo=He({name:"readonly",version:"1.0.0",description:"Makes all interface properties readonly",transform:mi}),Lo=He({name:"strip-private",version:"1.0.0",description:"Strips @internal, @private, and @hidden declarations",transform:di((n)=>{if(!n.leadingComments)return!1;return n.leadingComments.some((r)=>/@(internal|private|hidden)\b/.test(r))})}),No=He({name:"declare",version:"1.0.0",description:"Adds declare keyword to all declarations",transform:pi("declare",(n)=>n.kind!=="import")});function Bo(n){return He({name:`namespace-prefix-${n}`,version:"1.0.0",description:`Prefixes exported declarations with ${n}`,transform:fi(`${n}_`,(r)=>r.isExported&&r.kind!=="import")})}function f(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}
|
|
4
|
+
export{ci,li,Cn,vo,ui,So,ge,$o,He,Eo,fi,ko,di,To,Ao,Po,Do,pi,mi,Ro,Mo,Oo,Io,Fo,Lo,No,Bo};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{existsSync as L}from"fs";import{arch as N,platform as w}from"os";import{fileURLToPath as I}from"url";var b;function _(){return`${w()==="win32"?"windows":w()}-${N()}`}function z(r){let t=[],e=process.env.DTSX_NATIVE_LIBRARY;if(e)t.push(e);for(let n of[`../native/${_()}/${r}`,`../../native/${_()}/${r}`,`../../zig-dtsx/zig-out/lib/${r}`,`../../zig-dtsx/zig-out/bin/${r}`])try{t.push(I(new URL(n,import.meta.url)))}catch{}return t}function E(){if(process.env.DTSX_ENGINE==="typescript"||typeof globalThis.Bun>"u")return null;let r;try{r=import.meta.require("bun:ffi")}catch{return null}let{dlopen:t,FFIType:e,ptr:n,suffix:u,toArrayBuffer:s}=r,d=u==="dll"?`zig-dtsx.${u}`:`libzig-dtsx.${u}`;for(let c of z(d)){if(!L(c))continue;try{let f=t(c,{process_source_checked_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.ptr],returns:e.ptr},process_source_with_context_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.u64,e.ptr,e.ptr],returns:e.ptr},free_result:{args:[e.ptr,e.u64],returns:e.void}}),{symbols:l}=f,g=new TextDecoder;return{checked:(o,i,p,m,y,h)=>l.process_source_checked_v1(n(o),i,p,m,n(y),n(h)),contextual:(o,i,p,m,y,h,S,U)=>l.process_source_with_context_v1(n(o),i,p,m,n(y),h,n(S),n(U)),read:(o,i)=>{if(!o)return"";let p=i?g.decode(s(o,0,i)):"";return l.free_result(o,i),p}}}catch{continue}}return null}function k(){if(b===void 0)b=E();return b}function
|
|
3
|
-
export{
|
|
2
|
+
import{existsSync as L}from"fs";import{arch as N,platform as w}from"os";import{fileURLToPath as I}from"url";var b;function _(){return`${w()==="win32"?"windows":w()}-${N()}`}function z(r){let t=[],e=process.env.DTSX_NATIVE_LIBRARY;if(e)t.push(e);for(let n of[`../native/${_()}/${r}`,`../../native/${_()}/${r}`,`../../zig-dtsx/zig-out/lib/${r}`,`../../zig-dtsx/zig-out/bin/${r}`])try{t.push(I(new URL(n,import.meta.url)))}catch{}return t}function E(){if(process.env.DTSX_ENGINE==="typescript"||typeof globalThis.Bun>"u")return null;let r;try{r=import.meta.require("bun:ffi")}catch{return null}let{dlopen:t,FFIType:e,ptr:n,suffix:u,toArrayBuffer:s}=r,d=u==="dll"?`zig-dtsx.${u}`:`libzig-dtsx.${u}`;for(let c of z(d)){if(!L(c))continue;try{let f=t(c,{process_source_checked_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.ptr],returns:e.ptr},process_source_with_context_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.u64,e.ptr,e.ptr],returns:e.ptr},free_result:{args:[e.ptr,e.u64],returns:e.void}}),{symbols:l}=f,g=new TextDecoder;return{checked:(o,i,p,m,y,h)=>l.process_source_checked_v1(n(o),i,p,m,n(y),n(h)),contextual:(o,i,p,m,y,h,S,U)=>l.process_source_with_context_v1(n(o),i,p,m,n(y),h,n(S),n(U)),read:(o,i)=>{if(!o)return"";let p=i?g.decode(s(o,0,i)):"";return l.free_result(o,i),p}}}catch{continue}}return null}function k(){if(b===void 0)b=E();return b}function ti(){return k()!==null}var A=new TextEncoder,a=new Uint8Array(65536),x=new BigUint64Array(1),v=new Uint32Array(1);function pe(r,t){let e=k();if(!e)return null;if(r.length*3>a.length)a=new Uint8Array(r.length*3);let{written:n}=A.encodeInto(r,a),u=(t.inferenceSources?.size??0)>0||(t.augmentationImports?.size??0)>0,s;if(u){let c=t.sourceFile??"source.ts",f=A.encode(JSON.stringify({version:1,moduleSpecifierMode:"preserve",sourceFile:c,outputFile:c.replace(/\.[cm]?tsx?$/,".d.ts"),sourceHash:new Bun.CryptoHasher("sha256").update(a.subarray(0,n)).digest("hex"),rewrites:[],augmentationImports:[...t.augmentationImports??[]],inferenceSources:[...t.inferenceSources??[]].map(([l,g])=>({specifier:l,source:g}))}));s=e.contextual(a,n,t.keepComments,t.isolatedDeclarations,f,f.length,x,v)}else s=e.checked(a,n,t.keepComments,t.isolatedDeclarations,x,v);let d=Number(x[0]);if(v[0]!==0)return e.read(s,d),null;return e.read(s,d)}
|
|
3
|
+
export{ti,pe};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
3
|
-
export{Ie,da
|
|
2
|
+
import{s}from"./chunk-0zfzhn19.js";function Ie(d={}){let{buildStart:l=!0,buildEnd:u=!1,writeBundle:c=!1,modes:t,onGenerated:f,onError:o,...p}=d,i="production",r=async()=>{try{let e=await s(p);f?.(e)}catch(e){let a=e instanceof Error?e:Error(String(e));if(o?.(a),!o)console.error("[dtsx] Generation failed:",a.message)}},n=()=>{if(!t||t.length===0)return!0;return t.includes(i)};return{name:"dtsx",apply(e){return i=e.mode,!0},async buildStart(){if(l&&n())await r()},async buildEnd(){if(u&&n())await r()},async writeBundle(){if(c&&n())await r()}}}var fa=Ie,da=Ie;
|
|
3
|
+
export{Ie,fa,da};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{wn}from"./chunk-6yvk3q1e.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 bn(e){let o=f(e),c=f(e,{strings:!1}),n=new Set([...m(o),...d(c),...p(o),...wn,...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{bn};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{u}from"./chunk-73dzve1s.js";import{e}from"./chunk-yay68832.js";import{x,m}from"./chunk-1j6092xz.js";import{X}from"./chunk-qzjzw9p2.js";import{existsSync as T,readFileSync as N,realpathSync as w,statSync as q}from"fs";import{builtinModules as F}from"module";import{dirname as I,extname as z,isAbsolute as A,join as J,relative as U,resolve as O}from"path";var B=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],G={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};function j(t){try{return q(t).isFile()}catch{return!1}}function Y(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=z(c),d=G[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 C(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 K(t,i){if(Object.hasOwn(t,i))return t[i]!==null;let s=Object.keys(t).filter((l)=>l.includes("*")&&C(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 K(l,s)}function W(t,i){let s=U(t,i);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!A(s)}async function Ce(t){let i=await X(O(t.cwd,t.tsconfigPath||"tsconfig.json")),s=Object.entries(i?.paths??{});if(s.length===0){let r=(o,n)=>Y(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 Y(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)||K(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])=>C(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("*"),L=E===-1?"":r.slice(E,r.length-(R.length-E-1));for(let h of b){let S=O(l,h.replace("*",L)),M=d(S);if(M&&D(M,r)&&!M.private&&M.directory!==n?.directory)return{resolved:null,isRelative:!1};let P=Y(S,o);if(!P.resolved)continue;let y=w(P.resolved),_=t.outputStructure==="flat"||T(a)&&W(w(a),y);if(!n||!W(n.directory,y)||!_||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,U(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 Sn(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 V(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??Y)(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{Y,Ce,k,Sn,V};
|