@dtsx/dtsx 0.11.39 → 0.11.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +1 -1
- package/dist/{chunk-31kbs9mj.js → chunk-00m9cbar.js} +3 -3
- package/dist/{chunk-2dstvjpv.js → chunk-01jwgm2m.js} +1 -1
- package/dist/{chunk-jswvvjkr.js → chunk-01zsk2q8.js} +3 -3
- package/dist/{chunk-zn2gvwve.js → chunk-059gzhxc.js} +3 -3
- package/dist/{chunk-tm2j0feh.js → chunk-06jp6gah.js} +2 -2
- package/dist/{chunk-3jjrn16z.js → chunk-13tjnp25.js} +3 -3
- package/dist/{chunk-ka8mbyjb.js → chunk-1vc3eend.js} +2 -2
- package/dist/{chunk-aak9xzy7.js → chunk-2ck79rny.js} +2 -2
- package/dist/{chunk-t6ds7drh.js → chunk-3f3byyqp.js} +2 -2
- package/dist/{chunk-8dvxjzhy.js → chunk-3r9dptyy.js} +2 -2
- package/dist/{chunk-vbzchjvq.js → chunk-5mbfgcvp.js} +1 -1
- package/dist/{chunk-p4hf9bwj.js → chunk-6vz1grv8.js} +3 -3
- package/dist/{chunk-bc7ahgxz.js → chunk-6yn2edca.js} +2 -2
- package/dist/{chunk-8zvjkzsv.js → chunk-7387m006.js} +2 -2
- package/dist/{chunk-kccc6p2t.js → chunk-73qsp464.js} +1 -1
- package/dist/{chunk-0c03j9eq.js → chunk-7g0hjhqy.js} +1 -1
- package/dist/chunk-7khy25x0.js +3 -0
- package/dist/{chunk-ayyb1jpe.js → chunk-85d82vn3.js} +2 -2
- package/dist/chunk-8g4wk8mm.js +38 -0
- package/dist/{chunk-zk55g2cb.js → chunk-8qvphjgv.js} +1 -1
- package/dist/{chunk-hvy1zvk6.js → chunk-8wk7nw3c.js} +1 -1
- package/dist/{chunk-vgmnxnjf.js → chunk-9pharkp0.js} +11 -11
- package/dist/{chunk-jfygtm4r.js → chunk-a2dn9j88.js} +1 -1
- package/dist/{chunk-phwfth21.js → chunk-asqkc0bw.js} +2 -2
- package/dist/{chunk-nd0sbh5r.js → chunk-btwfkzt5.js} +3 -3
- package/dist/{chunk-996gqrz6.js → chunk-df8p90w4.js} +2 -2
- package/dist/{chunk-js4m0y2m.js → chunk-dpanh3p5.js} +1 -1
- package/dist/{chunk-3mcz22q8.js → chunk-epjq1edf.js} +4 -4
- package/dist/{chunk-0m1wt3db.js → chunk-fv3x086v.js} +2 -2
- package/dist/chunk-g0dxj89b.js +7 -0
- package/dist/{chunk-6epjc5rj.js → chunk-geqv8t08.js} +1 -1
- package/dist/{chunk-a3vfqhnp.js → chunk-gn3zapr9.js} +1 -1
- package/dist/{chunk-w26wgqh8.js → chunk-grqy03qp.js} +1 -1
- package/dist/{chunk-qrwst9bb.js → chunk-j0p7bwj6.js} +2 -2
- package/dist/{chunk-nqgfrehj.js → chunk-jfsj0sd2.js} +1 -1
- package/dist/{chunk-45fpbdw3.js → chunk-jvaqq9fq.js} +1 -1
- package/dist/{chunk-cyw59tgm.js → chunk-k0mqnrc1.js} +1 -1
- package/dist/{chunk-3dweac93.js → chunk-k4pkkkmh.js} +1 -1
- package/dist/{chunk-zbe06f63.js → chunk-pq1n1xqh.js} +1 -1
- package/dist/{chunk-g3zt5h6d.js → chunk-q11f576t.js} +2 -2
- package/dist/{chunk-y4wykrya.js → chunk-q4ph9qa2.js} +3 -3
- package/dist/{chunk-7ynrmx5b.js → chunk-qnwcsmsg.js} +4 -4
- package/dist/{chunk-hgscwj1y.js → chunk-qqjbaqm6.js} +2 -2
- package/dist/{chunk-sgcne5bb.js → chunk-qzb5pswc.js} +2 -2
- package/dist/{chunk-y3x7p6jf.js → chunk-rajfxka5.js} +1 -1
- package/dist/{chunk-jyq39qjt.js → chunk-sp0k32m0.js} +2 -2
- package/dist/{chunk-fay5vymp.js → chunk-twrcd0q6.js} +2 -2
- package/dist/{chunk-ee109s3r.js → chunk-v55m1ae1.js} +6 -6
- package/dist/{chunk-axj2w6hp.js → chunk-ves9h7g2.js} +1 -1
- package/dist/{chunk-kv0bpgyw.js → chunk-vgdsxnc2.js} +1 -1
- package/dist/chunk-w3zqfm8a.js +3 -0
- package/dist/{chunk-jhpfmjnx.js → chunk-w8ws29dq.js} +1 -1
- package/dist/{chunk-yde8rmfm.js → chunk-wma315wm.js} +8 -8
- package/dist/{chunk-z6mpxpxt.js → chunk-xmj05115.js} +1 -1
- package/dist/{chunk-ybzz1jg7.js → chunk-xzw0p4nq.js} +2 -2
- package/dist/{chunk-dpcvehxp.js → chunk-yf6v2p6x.js} +1 -1
- package/dist/{chunk-ex03kbwr.js → chunk-ywv56grs.js} +1 -1
- package/dist/{chunk-yzdh207n.js → chunk-yyqay3jp.js} +4 -4
- package/dist/{chunk-7j4cgkb4.js → chunk-zf96k060.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/declaration-project.js +1 -1
- package/dist/src/declaration-publication.js +1 -1
- package/dist/src/declaration-references.js +1 -1
- package/dist/src/diff.js +1 -1
- package/dist/src/docs.js +1 -1
- package/dist/src/enum-declarations.js +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/extractor/extract.js +1 -1
- package/dist/src/extractor/scanner.js +1 -1
- package/dist/src/extractor.js +1 -1
- package/dist/src/formatter.js +1 -1
- package/dist/src/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/lsp.js +1 -1
- package/dist/src/memory.js +1 -1
- package/dist/src/module-graph.js +1 -1
- package/dist/src/module-references.js +1 -1
- package/dist/src/native-checker.js +1 -1
- package/dist/src/native-extractor.js +1 -1
- package/dist/src/native-generation.js +1 -1
- package/dist/src/native-project.js +1 -1
- package/dist/src/optimizer.js +1 -1
- package/dist/src/parallel-processor.js +1 -1
- package/dist/src/parameters.js +1 -1
- package/dist/src/parser.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsdown.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/dist/src/plugins.js +1 -1
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/declarations.js +1 -1
- package/dist/src/processor/import-usage.js +1 -1
- package/dist/src/processor/imports.js +1 -1
- package/dist/src/processor/index.js +1 -1
- package/dist/src/processor/type-inference.js +1 -1
- package/dist/src/processor.js +1 -1
- package/dist/src/profiling.js +1 -1
- package/dist/src/return-type-scope.js +1 -1
- package/dist/src/source-cache.js +1 -1
- package/dist/src/sourcemap.js +1 -1
- package/dist/src/transformers.js +1 -1
- package/dist/src/tsconfig.js +1 -1
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/watcher.js +1 -1
- package/dist/src/worker-thread.js +1 -1
- package/dist/src/workspace.js +1 -1
- package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
- package/native/darwin-x64/libzig-dtsx.dylib +0 -0
- package/native/freebsd-x64/libzig-dtsx.so +0 -0
- package/native/linux-arm64/libzig-dtsx.so +0 -0
- package/native/linux-x64/libzig-dtsx.so +0 -0
- package/native/windows-x64/zig-dtsx.dll +0 -0
- package/package.json +1 -1
- package/dist/chunk-7z8pykqp.js +0 -3
- package/dist/chunk-c7a07a26.js +0 -7
- package/dist/chunk-qq5x44y9.js +0 -38
- package/dist/chunk-vf8jmdsp.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{c,i,Ne,de}from"./chunk-8kj9pkw5.js";import{t,d,Fe,m}from"./chunk-
|
|
2
|
+
import{c,i,Ne,de}from"./chunk-8kj9pkw5.js";import{t,d,Fe,m}from"./chunk-g0dxj89b.js";import{Le}from"./chunk-ywv56grs.js";import{tr}from"./chunk-73qsp464.js";import{Yn}from"./chunk-fv3x086v.js";import{_,qn}from"./chunk-zf96k060.js";import{Bn}from"./chunk-7g0hjhqy.js";import{Oe,fe,Ie}from"./chunk-8wk7nw3c.js";import{z,it,n,I,L,Jn,Wt,Re,j}from"./chunk-8g4wk8mm.js";import{Nn}from"./chunk-w8ws29dq.js";import{h}from"./chunk-qnwcsmsg.js";import{jn}from"./chunk-df8p90w4.js";function Ei(S,Z,H,G,te=""){let ne=new Map,f={start:0,end:S.length,header:0,name:"",children:[],results:new Map},K=t(S),me=[],g=[],ce=[],P=new Map;for(let e=0;e<K.length;e++){let le=K[e];if(le.kind!=="punctuation")continue;let he=S.slice(le.start,le.end);if(he==="(")ce.push(e);else if(he===")"){let ue=ce.pop();if(ue!==void 0)P.set(e,ue)}else if(he==="{")g.push(e);else if(he==="}"){let ue=g.pop();if(ue===void 0)continue;let se=K[ue].start,Y=ue-1,ee=Y>=0?S.slice(K[Y].start,K[Y].end):"";if(ee===")"){let V=P.get(Y);if(V!==void 0&&V>0&&["if","for","while","switch","catch","with"].includes(S.slice(K[V-1].start,K[V-1].end)))se=K[V-1].start}else if(["else","try","finally","do"].includes(ee))se=K[Y].start;me.push({open:K[ue].start,close:le.start,header:se})}}let ae=0,Q=(e,le=new Set)=>{let he=new Set(le),ue=t(S.slice(e.start,e.end)),se=0;for(let re=0;re+1<ue.length;re++){let qe=S.slice(e.start+ue[re].start,e.start+ue[re].end);if(qe==="{")se++;else if(qe==="}")se--;else if(!se&&["type","interface"].includes(qe))he.add(S.slice(e.start+ue[re+1].start,e.start+ue[re+1].end))}let Y="",ee=e.start,V=[...e.results].map(([re,qe])=>({type:re,name:qe}));for(let re of e.children.sort((qe,Ge)=>qe.header-Ge.header)){let qe=Q(re,he);Y+=S.slice(ee,re.header)+`
|
|
3
3
|
declare namespace ${re.name} {
|
|
4
4
|
${qe.text}
|
|
5
5
|
}
|
|
@@ -9,7 +9,7 @@ ${V.map((re)=>`export type ${re.name} = ${re.type};`).join(`
|
|
|
9
9
|
`)}`;let ze=O(Y,Z,!1);for(let re of V)he.add(re.name);let ie=te?Bt(te).map((re,qe)=>[re,`${xe}_capture_${qe}`]):[],x=ze.map((re)=>te&&["type","interface"].includes(re.kind)?vn(re,te,ie,he):(re.kind==="variable"?h(re,!1):re.text).replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
|
|
10
10
|
`);return{declarations:ze,text:x,exports:V}},xe;return{resolve(e,le){xe??=H();let he=f;for(let se of me.filter((Y)=>Y.open<le&&le<Y.close).sort((Y,ee)=>Y.open-ee.open)){let Y=he.children.find((ee)=>ee.start===se.open+1);if(!Y)Y={start:se.open+1,end:se.close,header:se.header,name:`${xe}_scope_${ae++}`,children:[],results:new Map},he.children.push(Y);he=Y}let ue=he.results.get(e);if(!ue)ue=`${xe}_result_${ne.size}`,he.results.set(e,ue),ne.set(ue,e);return`${xe}.${ue}`},finish(e){if(!xe)return e;let le=Q(f),he=le.declarations,ue=new Set(ne.keys());if(he.every((Y)=>ue.has(Y.name))){let Y=new Map(ne),ee=t(e),V="",ze=0;for(let ie=0;ie+2<ee.length;ie++){if(e.slice(ee[ie].start,ee[ie].end)!==xe||e.slice(ee[ie+1].start,ee[ie+1].end)!==".")continue;let x=Y.get(e.slice(ee[ie+2].start,ee[ie+2].end));if(!x)continue;V+=e.slice(ze,ee[ie].start)+`(${x})`,ze=ee[ie+2].end,ie+=2}return V+e.slice(ze)}if(te){let Y=Bt(te).join(", "),ee=t(e),V="",ze=0;for(let ie=0;ie+2<ee.length;ie++){if(e.slice(ee[ie].start,ee[ie].end)!==xe||e.slice(ee[ie+1].start,ee[ie+1].end)!=="."||!ue.has(e.slice(ee[ie+2].start,ee[ie+2].end)))continue;V+=`${e.slice(ze,ee[ie+2].end)}<${Y}>`,ze=ee[ie+2].end,ie+=2}e=V+e.slice(ze)}let se=le.text;return G({kind:"module",name:xe,text:`declare namespace ${xe} {
|
|
11
11
|
${se}
|
|
12
|
-
}`,moduleForm:"namespace",isExported:!1}),e}}}function Bt(S){let Z=t(S),H=[],G=0,te=0,ne=!1;for(let f of Z){let K=S.slice(f.start,f.end);if(K==="<"){if(G++,G===1)ne=!0}else if(K===">"&&S[f.start-1]!=="=")G--;else if(["(","[","{"].includes(K))te++;else if([")","]","}"].includes(K))te--;else if(K===","&&G===1&&!te)ne=!0;else if(ne&&f.kind==="word"&&!["const","in","out"].includes(K))H.push(K),ne=!1}return H}function vn(S,Z,H,G){let te=new Set(Bt(S.generics||"")),ne=(Q,xe,e)=>{let le=t(Q),he="",ue=0;for(let se=0;se<le.length;se++){let Y=le[se],ee=Q.slice(Y.start,Y.end),V=le[se+1]&&Q.slice(le[se+1].start,le[se+1].end),ze=le[se+2]&&Q.slice(le[se+2].start,le[se+2].end),ie=le[se-1]&&Q.slice(le[se-1].start,le[se-1].end);if(Y.kind!=="word"||V===":"||V==="?"&&ze===":")continue;let x=!e.has(ee)&&ie!=="."&&H.find(([re])=>re===ee)?.[1];if(x)he+=Q.slice(ue,Y.start)+x,ue=Y.end;else if(xe&&G.has(ee)&&!e.has(ee)){let re=H.map(([,qe])=>qe).join(", ");he+=`${Q.slice(ue,Y.end)}<${re}${V==="<"?", ":">"}`,ue=V==="<"?le[++se].end:Y.end}}return he+Q.slice(ue)},f=t(S.text),K=f.findIndex((Q)=>["type","interface"].includes(S.text.slice(Q.start,Q.end))),me=f[K+1],g=S.generics||"",ce=g?S.text.indexOf(g,me.end)+g.length:me.end,P=ne(Sn(Z),!1,new Set),ae=g?`, ${ne(g.slice(1,-1),!0,te)}`:"";return`${S.text.slice(0,me.end)}<${P}${ae}>${ne(S.text.slice(ce),!0,te)}`.replace(/^export\s+/,"").replace(/^declare\s+/,"")}function Sn(S){let Z=S.slice(1,-1),H=t(Z),G=0,te=0,ne=!1,f="";for(let K=0;K<H.length;K++){let me=H[K],g=Z.slice(me.start,me.end);if(["(","[","{","<"].includes(g))G++;else if([")","]","}"].includes(g)||g===">"&&Z[me.start-1]!=="=")G--;else if(!G&&g==="const")f+=Z.slice(te,me.start),te=me.end;else if(!G&&g==="="&&Z.slice(H[K+1]?.start,H[K+1]?.end)!==">")f+=Z.slice(te,me.start),ne=!0;else if(!G&&g===","&&ne)te=me.start,ne=!1}return f+(ne?"":Z.slice(te))}var He=32,je=9,be=10,ve=13,F=47,we=42,pe=39,Ae=34,Ee=96,Qe=92,W=123,U=125,X=40,ge=41,Se=91,_e=93,ke=60,Ce=62,J=59,Ze=58,$e=61,Je=44,Ye=46,$t=63,on=35,Dn=64,Tn=36;function We(S){return S===He||S===je||S===be||S===ve}function In(S){let Z=!0;for(let H=0;H<S.length;H++){let G=S.charCodeAt(H);if(G===Ye){if(Z)return!1;Z=!0}else if(Z){if(!c(G))return!1;Z=!1}else if(!i(G))return!1}return S.length>0&&!Z}function pt(S,Z,H){let G=Z+1;while(G<S.length){let te=S.charCodeAt(G);if(te===Qe){G+=2;continue}if(G++,te===H)break}return G}function
|
|
12
|
+
}`,moduleForm:"namespace",isExported:!1}),e}}}function Bt(S){let Z=t(S),H=[],G=0,te=0,ne=!1;for(let f of Z){let K=S.slice(f.start,f.end);if(K==="<"){if(G++,G===1)ne=!0}else if(K===">"&&S[f.start-1]!=="=")G--;else if(["(","[","{"].includes(K))te++;else if([")","]","}"].includes(K))te--;else if(K===","&&G===1&&!te)ne=!0;else if(ne&&f.kind==="word"&&!["const","in","out"].includes(K))H.push(K),ne=!1}return H}function vn(S,Z,H,G){let te=new Set(Bt(S.generics||"")),ne=(Q,xe,e)=>{let le=t(Q),he="",ue=0;for(let se=0;se<le.length;se++){let Y=le[se],ee=Q.slice(Y.start,Y.end),V=le[se+1]&&Q.slice(le[se+1].start,le[se+1].end),ze=le[se+2]&&Q.slice(le[se+2].start,le[se+2].end),ie=le[se-1]&&Q.slice(le[se-1].start,le[se-1].end);if(Y.kind!=="word"||V===":"||V==="?"&&ze===":")continue;let x=!e.has(ee)&&ie!=="."&&H.find(([re])=>re===ee)?.[1];if(x)he+=Q.slice(ue,Y.start)+x,ue=Y.end;else if(xe&&G.has(ee)&&!e.has(ee)){let re=H.map(([,qe])=>qe).join(", ");he+=`${Q.slice(ue,Y.end)}<${re}${V==="<"?", ":">"}`,ue=V==="<"?le[++se].end:Y.end}}return he+Q.slice(ue)},f=t(S.text),K=f.findIndex((Q)=>["type","interface"].includes(S.text.slice(Q.start,Q.end))),me=f[K+1],g=S.generics||"",ce=g?S.text.indexOf(g,me.end)+g.length:me.end,P=ne(Sn(Z),!1,new Set),ae=g?`, ${ne(g.slice(1,-1),!0,te)}`:"";return`${S.text.slice(0,me.end)}<${P}${ae}>${ne(S.text.slice(ce),!0,te)}`.replace(/^export\s+/,"").replace(/^declare\s+/,"")}function Sn(S){let Z=S.slice(1,-1),H=t(Z),G=0,te=0,ne=!1,f="";for(let K=0;K<H.length;K++){let me=H[K],g=Z.slice(me.start,me.end);if(["(","[","{","<"].includes(g))G++;else if([")","]","}"].includes(g)||g===">"&&Z[me.start-1]!=="=")G--;else if(!G&&g==="const")f+=Z.slice(te,me.start),te=me.end;else if(!G&&g==="="&&Z.slice(H[K+1]?.start,H[K+1]?.end)!==">")f+=Z.slice(te,me.start),ne=!0;else if(!G&&g===","&&ne)te=me.start,ne=!1}return f+(ne?"":Z.slice(te))}var He=32,je=9,be=10,ve=13,F=47,we=42,pe=39,Ae=34,Ee=96,Qe=92,W=123,U=125,X=40,ge=41,Se=91,_e=93,ke=60,Ce=62,J=59,Ze=58,$e=61,Je=44,Ye=46,$t=63,on=35,Dn=64,Tn=36;function We(S){return S===He||S===je||S===be||S===ve}function In(S){let Z=!0;for(let H=0;H<S.length;H++){let G=S.charCodeAt(H);if(G===Ye){if(Z)return!1;Z=!0}else if(Z){if(!c(G))return!1;Z=!1}else if(!i(G))return!1}return S.length>0&&!Z}function pt(S,Z,H){let G=Z+1;while(G<S.length){let te=S.charCodeAt(G);if(te===Qe){G+=2;continue}if(G++,te===H)break}return G}function _n(S){if(S==="any"||S==="object"||S==="unknown")return!0;if(S.startsWith("Record<")||S.startsWith("Array<"))return!0;return S.charCodeAt(0)===W&&S.includes("[")&&S.includes("]:")}var Ht=["public","protected","private","readonly","override"];function Ra(S,Z,H=!0,G=!1){return G?T(S,Z,H):O(S,Z,H)}function T(S,Z,H=!0){return Nt(S,Z,H,!0)}function O(S,Z,H=!0,G){return Nt(S,Z,H,!1,!1,G)}function It(S,Z,H=!0){return Nt(S,Z,H,!0,!0)}function Nt(S,Z,H,G,te=!1,ne){let f=S,K=H,me=G,g=f.length,ce=_(f),P=[],ae=new Map,Q=new Map,xe=new Set,e=0,le=0,he=[];function ue(s){let o=/^this\.([\w$]+)$/.exec(s);if(o){let C=he.at(-1);return C?.fields.get(`${C.isStatic?"static:":""}${o[1]}`)}let r=/^([\w$]+)\s*\(/.exec(s);if(!r||!s.endsWith(")"))return;let a=t(s),l=0;for(let C=1;C<a.length;C++){let A=s.slice(a[C].start,a[C].end);if(A==="(")l++;else if(A===")"&&--l===0&&C!==a.length-1)return}let u=[...P,...ae.values()].filter((C)=>C.kind==="function"&&C.name===r[1]);if(u.length!==1||u[0].generics||Le(f,r[1])!==1)return;return u[0].returnType}function se(s){let o=s.trim(),r=ue(o);if(r)return r;if(!o.startsWith("class"))return;let a=t(o);if(a[0]?.kind!=="word"||o.slice(a[0].start,a[0].end)!=="class")return;let l;do l=`__dtsx_class_${le++}`;while(f.includes(l));let u=a[1],C=u?o.slice(u.start,u.end):"",A=u?.kind==="word"&&!["extends","implements"].includes(C),b=A?C:`${l}_value`,p=A?`export ${o}`:`export class ${b} ${o.slice(5)}`,k=O(p,Z,K),D=k.find((y)=>y.kind==="class");if(!D)throw Error("Cannot extract the class expression declaration");if(t(p.slice(D.end??p.length)).some((y)=>p.slice((D.end??0)+y.start,(D.end??0)+y.end)!==";"))return;let M=k.map((y)=>y.text.replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
|
|
13
13
|
`);return ae.set(l,{kind:"module",name:l,text:`declare namespace ${l} {
|
|
14
14
|
${M}
|
|
15
15
|
}`,moduleForm:"namespace",isExported:!1,start:e,end:e}),`typeof ${l}.${b}`}function Y(s,o){let r=/^this\.([\w$]+)$/.exec(s);if(r)return he.at(-1)?.fields.get(`${o?"static:":""}${r[1]}`);return se(s)}function ee(s){let o=Q.get(s.name);if(o)o.push(s);else Q.set(s.name,[s]);ae.set(s.name,s)}if(e<g&&f.charCodeAt(e)===65279)e++;function V(s,o){if(s<o){let r=f.charCodeAt(s),a=f.charCodeAt(o-1);if(r!==He&&r!==je&&r!==be&&r!==ve&&a!==He&&a!==je&&a!==be&&a!==ve)return f.slice(s,o)}while(s<o&&We(f.charCodeAt(s)))s++;while(o>s&&We(f.charCodeAt(o-1)))o--;return f.slice(s,o)}let ze=/[\r\n]/g;function ie(s){return ze.lastIndex=s,ze.exec(f)?.index??g}function x(){if(e>=g)return;let s=f.charCodeAt(e);if(s!==He&&s!==je&&s!==be&&s!==ve&&s!==F)return;while(e<g){let o=f.charCodeAt(e);if(o===He||o===je||o===be||o===ve){e++;continue}if(o===F&&e+1<g){let r=f.charCodeAt(e+1);if(r===F){e=ie(e+2);continue}if(r===we){let a=f.indexOf("*/",e+2);e=a===-1?g:a+2;continue}}break}}function re(s){if(s.indexOf("//")===-1&&s.indexOf("/*")===-1)return s;let o=0,r=0;while(r<s.length){let a=s.charCodeAt(r);if(a===pe||a===Ae||a===Ee){r=pt(s,r,a),o=r;continue}if(a===Qe){r+=2,o=Math.min(r,s.length);continue}if(a===F&&s.charCodeAt(r+1)===F){while(r<s.length&&s.charCodeAt(r)!==be&&s.charCodeAt(r)!==ve)r++;continue}if(a===F&&s.charCodeAt(r+1)===we){let l=s.indexOf("*/",r+2);r=l===-1?s.length:l+2;continue}if(r++,a>32)o=r}return o<s.length?s.slice(0,o).trimEnd():s}function qe(s){let o=s.length,r=0,a=o;for(let l=0;l<o;l++){let u=s.charCodeAt(l);if(r){if(u===Qe){l++;continue}if(u===r)r=0;continue}if(u===pe||u===Ae||u===Ee){r=u;continue}if(u===F&&l+1<o){let C=s.charCodeAt(l+1);if(C===F){a=l;while(a>0&&(s.charCodeAt(a-1)===He||s.charCodeAt(a-1)===je))a--;return s.slice(0,a)}if(C===we){let A=s.indexOf("*/",l+2);if(A!==-1){s=`${s.slice(0,l)} ${s.slice(A+2)}`,l--;continue}}}}a=o;while(a>0&&(s.charCodeAt(a-1)===He||s.charCodeAt(a-1)===je||s.charCodeAt(a-1)===ve))a--;return a<o?s.slice(0,a):s}function Ge(s){e++;let o=s===pe?"'":'"';while(e<g){let r=f.indexOf(o,e);if(r===-1){e=g;return}let a=0,l=r-1;while(l>=0&&f.charCodeAt(l)===Qe)a++,l--;if(a%2===0){e=r+1;return}e=r+1}}function lt(){e++;let s=[];while(e<g){let o=f.charCodeAt(e);if(s.length===0){if(o===Qe){e+=2;continue}if(o===Ee){e++;return}if(o===Tn&&e+1<g&&f.charCodeAt(e+1)===W){e+=2,s.push(0);continue}e++;continue}if(o===pe||o===Ae){Ge(o);continue}if(o===Ee){lt();continue}if(o===F&&e+1<g){let r=f.charCodeAt(e+1);if(r===F){e=ie(e+2);continue}if(r===we){let a=f.indexOf("*/",e+2);e=a===-1?g:a+2;continue}if(jt()){qt();continue}e++;continue}if(o===W){s[s.length-1]++,e++;continue}if(o===U){let r=s[s.length-1];if(r===0){s.pop(),e++;continue}s[s.length-1]=r-1,e++;continue}e++}}let xt=!1;function Be(){xt=!1;let s=f.charCodeAt(e);if(s===pe||s===Ae)return Ge(s),!0;if(s===Ee)return lt(),!0;if(s===F&&e+1<g){let o=f.charCodeAt(e+1);if(o===F)return e=ie(e+2),!0;if(o===we){let r=f.indexOf("*/",e+2);return xt=ie(e+2)<(r===-1?g:r),e=r===-1?g:r+2,!0}if(jt())return qt(),!0}return!1}function jt(){return Ne(f,e)}function qt(){e=de(f,e)}function Te(){let s=e;while(e<g&&i(f.charCodeAt(e)))e++;return f.slice(s,e)}function w(s){if(e+s.length>g)return!1;for(let o=0;o<s.length;o++)if(f.charCodeAt(e+o)!==s.charCodeAt(o))return!1;if(e+s.length<g&&i(f.charCodeAt(e+s.length)))return!1;return!0}function mt(s){let o=e+s;while(o<g){let r=f.charCodeAt(o);if(r===He||r===je||r===be||r===ve){o++;continue}return r!==Ye&&r!==$e}return!1}function yt(){if(!xt)return!1;let s=e;x();let o=e>=g||vt()||f.charCodeAt(e)===U;return e=s,o}function vt(){if(e>=g)return!1;switch(f.charCodeAt(e)){case 101:return w("export")||w("enum");case 105:return w("import")||w("interface");case 102:return w("function");case 99:return w("class")||w("const");case 116:return w("type");case 108:return w("let");case 118:return w("var");case 100:return w("declare")||w("default");case 109:return w("module");case 110:return w("namespace");case 97:return w("abstract")||w("async");default:return!1}}function st(){let s=f.charCodeAt(e);if(s!==be&&s!==ve)return!1;let o=e;if(e++,s===ve&&e<g&&f.charCodeAt(e)===be)e++;while(e<g){let a=f.charCodeAt(e);if(a===He||a===je||a===ve||a===be){e++;continue}if(a===F&&e+1<g){let l=f.charCodeAt(e+1);if(l===F){e=ie(e+2);continue}if(l===we){let u=f.indexOf("*/",e+2);e=u===-1?g:u+2;continue}}break}let r=e>=g||vt()||f.charCodeAt(e)===U;return e=o,r}function zt(s){let o=s-1;while(o>=0){let b=f.charCodeAt(o);if(b===He||b===je||b===ve||b===be){o--;continue}break}if(o<0)return!0;let r=f[o];if("+-*/%=<>&|^!~?:,.([{".includes(r))return!0;let a=o;while(a>0&&f.charCodeAt(a-1)!==be)a--;let l=f.slice(a,o+1),u=l.lastIndexOf("<");if(u!==-1&&/^<[A-Za-z]/.test(l.slice(u))&&!l.slice(u).includes(">"))return!0;let C=o;while(C>=0&&/[a-z]/i.test(f[C]))C--;let A=f.slice(C+1,o+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(A)}function ln(){let s=f.charCodeAt(e);if(s!==be&&s!==ve)return!1;if(zt(e))return!1;let o=e;e++;while(e<g){let u=f.charCodeAt(e);if(u===He||u===je||u===ve||u===be){e++;continue}if(u===F&&e+1<g){let C=f.charCodeAt(e+1);if(C===F){e=ie(e+2);continue}if(C===we){let A=f.indexOf("*/",e+2);e=A===-1?g:A+2;continue}}break}let r=e<g?f[e]:"",a=f.slice(e,e+2),l=r==="."||r==="?"||r===":"||r===")"||r==="]"||r==="}"||r===","||r==="+"||r==="-"||r==="*"||r==="/"||r==="%"||r==="<"||r===">"||r==="="||r==="&"||r==="|"||r==="^"||r==="`"||a==="=>"||w("as")||w("satisfies")||w("instanceof")||w("in");return e=o,!l}function Ft(){let s=f.charCodeAt(e);if(s!==be&&s!==ve)return!1;if(zt(e))return!1;let o=e;e++;while(e<g){let l=f.charCodeAt(e);if(l===He||l===je||l===ve||l===be){e++;continue}if(l===F&&e+1<g){let u=f.charCodeAt(e+1);if(u===F){e=ie(e+2);continue}if(u===we){let C=f.indexOf("*/",e+2);e=C===-1?g:C+2;continue}}break}let r=e<g?f[e]:"",a=r==="|"||r==="&"||r==="["||r==="."||r==="?"||r===":"||r===">"||r===")"||r===","||w("extends");return e=o,!a}function ft(){let s=f.charCodeAt(e);if(s!==be&&s!==ve)return!1;let o=e;if(e++,s===ve&&e<g&&f.charCodeAt(e)===be)e++;while(e<g){let a=f.charCodeAt(e);if(a===He||a===je||a===ve||a===be){e++;continue}if(a===F&&e+1<g&&f.charCodeAt(e+1)===F){e=ie(e+2);continue}break}if(e>=g)return e=o,!0;let r=f.charCodeAt(e);if(r===124||r===38||r===Ye||r===$t||r===Ze)return e=o,!1;if(w("extends")||w("keyof")||w("typeof")||w("infer")||w("is")||w("as")||w("in"))return e=o,!1;return e=o,!0}let fn=/[{}'"`\/]/g,dn=/[()'"`\/]/g,un=/[[\]'"`\/]/g,hn=/[<>'"`\/]/g;function Pe(s,o){let r=1;e++;let a=s===W?fn:s===X?dn:s===Se?un:hn;a.lastIndex=e;let l;while((l=a.exec(f))!==null){let u=l.index,C=f.charCodeAt(u);if(C===pe||C===Ae){e=u,Ge(C),a.lastIndex=e;continue}if(C===Ee){e=u,lt(),a.lastIndex=e;continue}if(C===F){if(e=u,Be()){a.lastIndex=e;continue}a.lastIndex=u+1;continue}if(C===s)r++;else if(C===o){if(o===Ce&&u>0&&f.charCodeAt(u-1)===$e){a.lastIndex=u+1;continue}if(r--,r===0)return e=u+1,e}a.lastIndex=u+1}return e=g,e}function Ue(){return e>0&&f.charCodeAt(e-1)===$e}function St(){return e+1<g&&f.charCodeAt(e+1)===Ce}let Ke=/[<{};'"`\/\n\r()[\]]/g;function Me(s=!1){let o=0,r=0,a=0,l=0,u=f.charCodeAt(e)===W;Ke.lastIndex=e;let C;while((C=Ke.exec(f))!==null){let A=C.index,b=f.charCodeAt(A);if(b===pe||b===Ae){e=A,Ge(b),Ke.lastIndex=e;continue}if(b===Ee){e=A,lt(),Ke.lastIndex=e;continue}if(b===F){if(A>0&&f.charCodeAt(A-1)===ke){Ke.lastIndex=A+1;continue}if(e=A,Be()){if(o===0&&r===0&&a===0&&l===0&&yt())return;Ke.lastIndex=e;continue}Ke.lastIndex=A+1;continue}if(b===ke){let p=Jt(A);if(p!==null)l=Math.max(0,l+p);Ke.lastIndex=A+1;continue}if(b===X){r++,Ke.lastIndex=A+1;continue}if(b===ge){r--,Ke.lastIndex=A+1;continue}if(b===Se){a++,Ke.lastIndex=A+1;continue}if(b===_e){a--,Ke.lastIndex=A+1;continue}if(b===W){o++,Ke.lastIndex=A+1;continue}if(b===U){let p=o>0;if(!p&&s&&r===0&&a===0&&l===0){e=A;return}if(p)o--;if((!p||u)&&o===0&&r===0&&a===0&&l===0){e=A+1;return}if(p&&o===0&&r===0&&a===0&&l===0){e=A+1;let k=e;x();let D=vt();if(e=k,D)return}Ke.lastIndex=A+1;continue}if(b===J&&o===0&&r===0&&a===0&&l===0){e=A+1;return}if((b===be||b===ve)&&o===0&&r===0&&a===0&&l===0){if(e=A,st())return}Ke.lastIndex=A+1}e=g}function pn(){e++;while(e<g&&(f.charCodeAt(e)===He||f.charCodeAt(e)===je))e++;let s=f.indexOf(`
|
|
@@ -27,11 +27,11 @@ ${M}
|
|
|
27
27
|
`).map((q)=>{let N=q.trim();if(!N)return"";if(N==="{"||N==="}"||N==="["||N==="]"||N.startsWith("}")||N.startsWith("]"))return N;return` ${N}`}).join(`
|
|
28
28
|
`)}let E=p.endsWith("?")||D;if(p.endsWith("?"))p=p.slice(0,-1).trim();let M=E&&!r?"?":"";if(r)return`...${p}: ${k}`;return`${p}${M}: ${k}`}function dt(s){let o=s.trim(),r=ue(o);if(r)return r;if(o==="true"||o==="false")return"boolean";if(z(o))return"number";if(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))return"string";if(o.startsWith("["))return"unknown[]";if(o.startsWith("{"))return"Record<string, unknown>";return Re(o)??"unknown"}function Tt(s){let o=s.trim();if(o.endsWith("as const"))o=o.slice(0,-8).trim();if(o==="true"||o==="false")return o;if(z(o))return it(o);let r=Cn(o);if(r!==null)return r;return Re(o)??"unknown"}function Cn(s){if(s==="")return null;if(s.charCodeAt(0)===pe||s.charCodeAt(0)===Ae){if(pt(s,0,s.charCodeAt(0))===s.length)return s}let o=An(s,"+");if(o.length>1){let r=!1,a=!0,l=[];for(let u of o){let C=u.trim(),A=C.charCodeAt(0);if((A===pe||A===Ae)&&pt(C,0,A)===C.length)r=!0,l.push(bn(C));else a=!1}if(a)return kn(l.join(""));if(r)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(s)&&/\d/.test(s)&&/[+*/%\-\s]/.test(s))return"number";return null}function An(s,o){let r=[],a=0,l="",u=0;while(u<s.length){let C=s.charCodeAt(u);if(C===pe||C===Ae||C===Ee){let A=pt(s,u,C);l+=s.slice(u,A),u=A;continue}if(C===F&&(s.charCodeAt(u+1)===F||s.charCodeAt(u+1)===42)){if(s.charCodeAt(u+1)===F){let p=s.indexOf(`
|
|
29
29
|
`,u+2),k=p===-1?s.length:p;l+=s.slice(u,k),u=k;continue}let A=s.indexOf("*/",u+2),b=A===-1?s.length:A+2;l+=s.slice(u,b),u=b;continue}if(C===X||C===Se||C===W)a++;else if(C===ge||C===_e||C===U)a--;if(s[u]===o&&a===0){r.push(l),l="",u++;continue}l+=s[u],u++}return r.push(l),r}function bn(s){return s.slice(1,-1).replace(/\\(.)/g,(r,a)=>{if(a==="n")return`
|
|
30
|
-
`;if(a==="t")return"\t";if(a==="r")return"\r";if(a==="0")return"\x00";return a})}function kn(s){return`'${s.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function At(s){if(s.endsWith("as const"))return null;let o=0,r=-1;for(let l=0;l<s.length;l++){let u=s.charCodeAt(l);if(u===pe||u===Ae||u===Ee)l=pt(s,l,u)-1;else if(u===123||u===91||u===40)o++;else if(u===125||u===93||u===41)o--;else if(o===0&&u===32&&l+4<=s.length&&s.substring(l,l+4)===" as ")r=l}if(r===-1)return null;return s.slice(r+4).trim()||null}function ut(){if(x(),e<g&&f.charCodeAt(e)===Ze){let a=function(){let l=V(s,r),u=(C)=>{let A=l.length-C.length;return A>=0&&l.endsWith(C)&&(A===0||!i(l.charCodeAt(A-1)))};return l.length===0||l.endsWith("=>")||l.endsWith("|")||l.endsWith("&")||u("is")||u("extends")};e++,x();let s=e,o=0,r=s;while(e<g){let l=e;if(Be()){if(f.charCodeAt(l)!==F)r=e;continue}let u=f.charCodeAt(e);if(u===X||u===Se||u===ke)o++;else if(u===ge||u===_e||u===Ce&&!Ue())o--;else if(u===W)if(o>0)o++;else if(a())o++;else break;else if(u===U){if(o===0)break;o--}else if(o===0&&u===J)break;if(o===0&&ft()&&!a())break;if(!We(u))r=e+1;e++}return V(s,e)}return""}function tt(s,o,r,a){e+=8,x();let l=e<g&&f.charCodeAt(e)===we;if(l)e++,x();let u=Te();if(!u&&!a)return null;x();let C=Xe();x();let A=et();x();let b=ut(),p=b.length>0;if(!b)if(r&&l)b="AsyncGenerator<unknown, void, unknown>";else if(l)b="Generator<unknown, void, unknown>";else if(r)b="Promise<void>";else b="void";x();let k=!1;if(e<g&&f.charCodeAt(e)===W){k=!0;let N=e+1;if(Pe(W,U),!p&&!l){let B=f.slice(N,e-1),R=Ei(B,Z,()=>{let ye;do ye=`__dtsx_return_${le++}`;while(f.includes(ye));return ye},(ye)=>ae.set(ye.name,{...ye,start:e,end:e}),C);b=R.finish(I(B,r,A,se,R.resolve))}}else if(e<g&&f.charCodeAt(e)===J)e++;let D=ot(A),y=`${o?a?"export default function ":"export declare function ":"declare function "}${u||(a?"":"default")}${C}${D}: ${b};`,v=Ve(s),q={kind:"function",name:u||"default",text:y,isExported:o,isDefault:a,isAsync:r,isGenerator:l,returnType:b,generics:C||void 0,leadingComments:v,start:s,end:e};if(k)xe.add(q);return q}let _t,wn=0;function Zt(){_t??=new Set(t(f).filter((s)=>s.kind==="word").map((s)=>f.slice(s.start,s.end)));for(;;){let s=`__dtsx_binding_${wn++}`;if(_t.has(s))continue;return _t.add(s),s}}function rt(s,o,r){e+=o.length,x();let a=[];do{if(x(),e>=g)break;let l=f.charCodeAt(e),u,C=e;if(l===W||l===Se)Pe(l,l===W?U:_e),u=f.slice(C,e);let A=u?Zt():Te();if(!A)return Me(),a;x();let b,p,k,D=!1;if(e<g&&f.charCodeAt(e)===Ze){e++,x();let N=e,B=0;while(e<g){if(Be()){if(B===0&&yt())break;continue}let R=f.charCodeAt(e);if(R===X||R===W||R===Se||R===ke)B++;else if(R===ge||R===U||R===_e||R===Ce&&!Ue())B--;else if(B===0&&(R===J||R===Je))break;else if(B===0&&R===$e&&!St())break;if(B===0&&(st()||Ft()))break;e++}b=V(N,e)}if(e<g&&f.charCodeAt(e)===$e)if(me&&b&&(!K||!
|
|
30
|
+
`;if(a==="t")return"\t";if(a==="r")return"\r";if(a==="0")return"\x00";return a})}function kn(s){return`'${s.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function At(s){if(s.endsWith("as const"))return null;let o=0,r=-1;for(let l=0;l<s.length;l++){let u=s.charCodeAt(l);if(u===pe||u===Ae||u===Ee)l=pt(s,l,u)-1;else if(u===123||u===91||u===40)o++;else if(u===125||u===93||u===41)o--;else if(o===0&&u===32&&l+4<=s.length&&s.substring(l,l+4)===" as ")r=l}if(r===-1)return null;return s.slice(r+4).trim()||null}function ut(){if(x(),e<g&&f.charCodeAt(e)===Ze){let a=function(){let l=V(s,r),u=(C)=>{let A=l.length-C.length;return A>=0&&l.endsWith(C)&&(A===0||!i(l.charCodeAt(A-1)))};return l.length===0||l.endsWith("=>")||l.endsWith("|")||l.endsWith("&")||u("is")||u("extends")};e++,x();let s=e,o=0,r=s;while(e<g){let l=e;if(Be()){if(f.charCodeAt(l)!==F)r=e;continue}let u=f.charCodeAt(e);if(u===X||u===Se||u===ke)o++;else if(u===ge||u===_e||u===Ce&&!Ue())o--;else if(u===W)if(o>0)o++;else if(a())o++;else break;else if(u===U){if(o===0)break;o--}else if(o===0&&u===J)break;if(o===0&&ft()&&!a())break;if(!We(u))r=e+1;e++}return V(s,e)}return""}function tt(s,o,r,a){e+=8,x();let l=e<g&&f.charCodeAt(e)===we;if(l)e++,x();let u=Te();if(!u&&!a)return null;x();let C=Xe();x();let A=et();x();let b=ut(),p=b.length>0;if(!b)if(r&&l)b="AsyncGenerator<unknown, void, unknown>";else if(l)b="Generator<unknown, void, unknown>";else if(r)b="Promise<void>";else b="void";x();let k=!1;if(e<g&&f.charCodeAt(e)===W){k=!0;let N=e+1;if(Pe(W,U),!p&&!l){let B=f.slice(N,e-1),R=Ei(B,Z,()=>{let ye;do ye=`__dtsx_return_${le++}`;while(f.includes(ye));return ye},(ye)=>ae.set(ye.name,{...ye,start:e,end:e}),C);b=R.finish(I(B,r,A,se,R.resolve))}}else if(e<g&&f.charCodeAt(e)===J)e++;let D=ot(A),y=`${o?a?"export default function ":"export declare function ":"declare function "}${u||(a?"":"default")}${C}${D}: ${b};`,v=Ve(s),q={kind:"function",name:u||"default",text:y,isExported:o,isDefault:a,isAsync:r,isGenerator:l,returnType:b,generics:C||void 0,leadingComments:v,start:s,end:e};if(k)xe.add(q);return q}let _t,wn=0;function Zt(){_t??=new Set(t(f).filter((s)=>s.kind==="word").map((s)=>f.slice(s.start,s.end)));for(;;){let s=`__dtsx_binding_${wn++}`;if(_t.has(s))continue;return _t.add(s),s}}function rt(s,o,r){e+=o.length,x();let a=[];do{if(x(),e>=g)break;let l=f.charCodeAt(e),u,C=e;if(l===W||l===Se)Pe(l,l===W?U:_e),u=f.slice(C,e);let A=u?Zt():Te();if(!A)return Me(),a;x();let b,p,k,D=!1;if(e<g&&f.charCodeAt(e)===Ze){e++,x();let N=e,B=0;while(e<g){if(Be()){if(B===0&&yt())break;continue}let R=f.charCodeAt(e);if(R===X||R===W||R===Se||R===ke)B++;else if(R===ge||R===U||R===_e||R===Ce&&!Ue())B--;else if(B===0&&(R===J||R===Je))break;else if(B===0&&R===$e&&!St())break;if(B===0&&(st()||Ft()))break;e++}b=V(N,e)}if(e<g&&f.charCodeAt(e)===$e)if(me&&b&&(!K||!_n(b)))pn();else{e++,x();let N=e;k=N;let B=0,R=0,ye=0,oe=!0;for(;;){e=N,B=0,R=0,ye=0;while(e<g){if(Be()){if(B===0&&R===0&&ye===0&&yt())break;continue}let De=f.charCodeAt(e);if(De===X||De===W||De===Se)B++;else if(De===ge||De===U||De===_e)B--;else if(De===ke&&B===0){let ht=Jt(e);if(ht!==null)ye=Math.max(0,ye+ht);else if(oe&&(e+1>=g||f.charCodeAt(e+1)!==$e))R++}else if(De===Ce&&B===0&&ye===0&&!Ue()){if(R>0&&(e+1>=g||f.charCodeAt(e+1)!==$e))R--}else if(B===0&&R===0&&ye===0&&(De===J||De===Je))break;if(B===0&&R===0&&ye===0&&(st()||ln()))break;e++}if(R>0&&oe){oe=!1;continue}break}if(p=re(V(N,e)),p.endsWith(" as const")||p==="const"){if(D=!0,!b){let De=p.endsWith(" as const")?p.slice(0,-9).trim():p,ht=Tt(De);b=ht!=="unknown"?ht:void 0}}else if(!b){let De=j(p)??At(p)??se(p);if(De)b=De}}let E=a.length===0?Ve(s):void 0,M=u?"const":o,y=u?!1:r,v=`${y?"export ":""}declare ${M} ${A}: ${b||"unknown"};`,q={kind:"variable",name:A,text:v,isExported:y,typeAnnotation:b,value:p,initializerStart:k,modifiers:D?[M,"const assertion"]:[M],leadingComments:u?void 0:E,start:s,end:e};if(u)a.push(...tr({pattern:u,patternOffset:C,root:q,kind:o,exported:r,comments:E,allocateName:Zt}));else a.push(q);if(f.charCodeAt(e)===Je){e++;continue}if(f.charCodeAt(e)===J)e++;break}while(e<g);return a}function Jt(s){if(f.charCodeAt(s)!==ke||s+1>=g)return null;let o=f.charCodeAt(s+1);if(o===Ce)return 1;if(o===F)return-1;if(!c(o))return null;let r=s+2;while(r<g){let p=f.charCodeAt(r);if(!i(p)&&p!==Ye&&p!==58&&p!==45)break;r++}let a=f.slice(s+1,r),l=f.charCodeAt(r);if(l>32&&l!==Ce&&l!==F)return null;let u=0,C=0,A=r;for(;A<g;A++){let p=f.charCodeAt(A);if(C!==0){if(p===Qe)A++;else if(p===C)C=0;continue}if(p===pe||p===Ae||p===Ee)C=p;else if(p===W)u++;else if(p===U&&u>0)u--;else if(p===Ce&&u===0)break}if(A>=g)return null;let b=A-1;while(b>s&&f.charCodeAt(b)<=32)b--;if(f.charCodeAt(b)===F)return 0;return f.indexOf(`</${a}`,A+1)===-1?null:1}function Ot(s,o){e+=9,x();let r=Te();x();let a=Xe();x();let l="";if(w("extends")){e+=7,x();let p=e,k=0;while(e<g){if(Be())continue;let D=f.charCodeAt(e);if(D===ke)k++;else if(D===Ce&&!Ue())k--;else if(D===W&&k===0)break;e++}l=V(p,e)}x();let u=e<g&&f.charCodeAt(e)===W?Dt():"{}",C=Vt(u),A=`${o?"export ":""}declare interface ${r}${a}${l?` extends ${l}`:""} ${C}`,b=Ve(s);return{kind:"interface",name:r,text:A,isExported:o,extends:l||void 0,generics:a||void 0,leadingComments:b,start:s,end:e}}function Et(s,o){e+=4,x();let r=Te();x();let a=Xe();if(x(),e<g&&f.charCodeAt(e)===$e)e++;x();let l=e,u=0;while(e<g){if(Be())continue;let p=f.charCodeAt(e);if(p===X||p===W||p===Se||p===ke)u++;else if(p===ge||p===U||p===_e||p===Ce&&!Ue())u--;else if(u===0&&p===J)break;if(u===0&&(st()||Ft()))break;e++}let C=V(l,e);if(e<g&&f.charCodeAt(e)===J)e++;let A=`${o?"export ":""}type ${r}${a} = ${C}`,b=Ve(s);return{kind:"type",name:r,text:A,isExported:o,generics:a||void 0,leadingComments:b,start:s,end:e}}function ct(s,o,r){e+=4,x();let a=Te();x();let l=e;if(e<g&&f.charCodeAt(e)===W)Pe(W,U);let u=V(s,e),C=Ve(s);return{kind:"enum",name:a,text:u,isExported:o,modifiers:r?["const"]:void 0,leadingComments:C,start:s,end:e}}function nt(s,o,r,a=!1){e+=5,x();let l=Te()||"AnonymousClass";x();let u=Xe();x();let C="";if(w("extends")){e+=7,x();let E=e,M=0;while(e<g){if(Be())continue;let y=f.charCodeAt(e);if(y===ke)M++;else if(y===Ce&&!Ue())M--;else if(M===0&&(y===W||w("implements")))break;e++}C=V(E,e)}let A;if(w("implements")){e+=10,x();let E=e,M=0;while(e<g){if(Be())continue;let v=f.charCodeAt(e);if(v===ke)M++;else if(v===Ce&&!Ue())M--;else if(M===0&&v===W)break;e++}let y=V(E,e);if(y)A=y.split(",").map((v)=>v.trim())}x();let b=Pt(),k=`${o?a?"export default ":"export declare ":"declare "}${r?"abstract ":""}class ${l}${u}${C?` extends ${C}`:""}${A&&A.length>0?` implements ${A.join(", ")}`:""} ${b}`,D=Ve(s);return{kind:"class",name:l,text:k,isExported:o,isDefault:a,extends:C||void 0,implements:A,generics:u||void 0,modifiers:r?["abstract"]:void 0,leadingComments:D,start:s,end:e}}let Rt;function Pt(){if(e>=g||f.charCodeAt(e)!==W)return"{}";e++;let s={fields:new Map,pending:[],isStatic:!1};he.push(s);let o=[],r=new Set;while(e<g){if(x(),e>=g)break;if(f.charCodeAt(e)===U){e++;break}if(f.charCodeAt(e)===J){e++;continue}if(Rt=Ve(e),w("static")&&kt("static")===W){e+=6,x(),Pe(W,U);continue}let a=!1,l=!1,u=!1,C=!1,A=!1,b=!1,p=!1,k=!1,D=!0;while(D){x();let N=e,B=Te();if(e=N,B){let R=kt(B);if(R===X||R===ke||R===$t||R===33||R===Ze||R===$e||R===J||R===U)break}if(w("private")){a=!0,e+=7;continue}if(w("protected")){l=!0,e+=9;continue}if(w("public")){e+=6;continue}if(w("static")){u=!0,e+=6;continue}if(w("abstract")){C=!0,e+=8;continue}if(w("readonly")){A=!0,e+=8;continue}if(w("override")){b=!0,e+=8;continue}if(w("accessor")){p=!0,e+=8;continue}if(w("async")){k=!0,e+=5;continue}if(w("declare")){e+=7;continue}break}if(x(),e>=g||f.charCodeAt(e)===U)break;let E=e;if(s.isStatic=u,(w("get")||w("set"))&&Mt(kt(f.slice(e,e+3))))e+=3,x();if(f.charCodeAt(e)===we)e++,x();let M=bt();e=E;let y=M.startsWith("#");if(y)a=!0;if(a&&M&&M!=="constructor"){let N=y?u?" static #private_static;":" #private;":` private ${u?"static ":""}${M};`,R=M[0]==="'"||M[0]==='"'?d(M)??M:M,ye=y?`${u?"static":"instance"}#`:`${u?"static:":"instance:"}${R}`;if(!r.has(ye))r.add(ye),o.push(N)}let v=a?[]:o,q=" ";if(l)q+="protected ";if(u)q+="static ";if(C)q+="abstract ";if(A)q+="readonly ";if(w("constructor")){e+=11,x();let N=et();if(x(),xn(N,o),e<g&&f.charCodeAt(e)===W)Pe(W,U);else if(e<g&&f.charCodeAt(e)===J)e++;let B=ot(N);o.push(a?" private constructor();":` ${l?"protected ":""}constructor${B};`)}else if(w("get"))if(e+=3,x(),e<g&&Mt(f.charCodeAt(e))){let N=bt();if(N.startsWith("#")){if(x(),e<g&&f.charCodeAt(e)===X)et();if(x(),ut(),x(),e<g&&f.charCodeAt(e)===W)Pe(W,U);else if(e<g&&f.charCodeAt(e)===J)e++;continue}x(),et(),x();let B=ut(),R;if(x(),e<g&&f.charCodeAt(e)===W){let oe=e+1;if(Pe(W,U),!B&&!me)R=f.slice(oe,e-1),B=I(R,!1,"()",(De)=>Y(De,u))}else if(e<g&&f.charCodeAt(e)===J)e++;let ye=v.length;if(v.push(`${q}get ${N}(): ${R?L(B):B||"unknown"};`),R)s.pending.push(()=>{let oe=I(R,!1,"()",(De)=>Y(De,u));v[ye]=`${q}get ${N}(): ${L(oe)};`})}else Yt("get",q,u,A,k,v);else if(w("set"))if(e+=3,x(),e<g&&Mt(f.charCodeAt(e))){let N=bt();if(N.startsWith("#")){if(x(),e<g&&f.charCodeAt(e)===X)et();if(x(),e<g&&f.charCodeAt(e)===W)Pe(W,U);else if(e<g&&f.charCodeAt(e)===J)e++;continue}x();let B=et();if(x(),e<g&&f.charCodeAt(e)===W)Pe(W,U);else if(e<g&&f.charCodeAt(e)===J)e++;let R=ot(B);v.push(`${q}set ${N}${R};`)}else Yt("set",q,u,A,k,v);else{let N=f.charCodeAt(e)===we;if(N)e++,x();let B=bt();if(!B){Xt();continue}en(B,q,u,A,N,C,k,v)}}for(let a of s.pending)a();return he.pop(),`{
|
|
31
31
|
${o.join(`
|
|
32
32
|
`)}
|
|
33
33
|
}`}function Mt(s){return c(s)||s===Se||s===on||s===pe||s===Ae}function bt(){if(e>=g)return"";let s=f.charCodeAt(e);if(s===Se){let o=e;return Pe(Se,_e),f.slice(o,e)}if(s===on)return e++,`#${Te()}`;if(s===pe||s===Ae){let o=e;return Ge(s),f.slice(o,e)}return Te()}function kt(s){let o=e;e+=s.length,x();let r=e<g?f.charCodeAt(e):0;return e=o,r}function Xt(){let s=0;while(e<g){if(Be())continue;let o=f.charCodeAt(e);if(o===W||o===X)s++;else if(o===U||o===ge){if(s===0)return;s--}else if(o===J&&s===0){e++;return}if(s===0&&ft())return;e++}}function Yt(s,o,r,a,l,u){en(s,o,r,a,!1,!1,l,u)}function en(s,o,r,a,l,u,C,A){let b=Rt;if(Rt=void 0,x(),e>=g)return;let p=f.charCodeAt(e),k=!1;if(p===$t)k=!0,e++,x();if(e<g&&f.charCodeAt(e)===33)e++,x();let D=e<g?f.charCodeAt(e):0;if(D===X||D===ke){let E=D===ke?Xe():"";x();let M=et();x();let y=ut(),v,q=y.length>0;if(!y)if(C&&l)y="AsyncGenerator<unknown, void, unknown>";else if(l)y="Generator<unknown, void, unknown>";else if(C)y="Promise<void>";else y="void";if(x(),e<g&&f.charCodeAt(e)===W){let ye=e+1;if(Pe(W,U),!q&&!l)v=f.slice(ye,e-1),y=I(v,C,M,(oe)=>Y(oe,r))}else if(e<g&&f.charCodeAt(e)===J)e++;let N=ot(M),B=k?"?":"",R=A.length;if(A.push(`${o}${s}${B}${E}${N}: ${v?L(y):y};`),v)he.at(-1)?.pending.push(()=>{let ye=I(v,C,M,(oe)=>Y(oe,r));A[R]=`${o}${s}${B}${E}${N}: ${L(ye)};`})}else if(D===Ze||D===$e||D===J||D===U||D===be||D===ve){let E="";if(D===Ze){e++,x();let N=e,B=0;while(e<g){if(Be())continue;let R=f.charCodeAt(e);if(R===X||R===W||R===Se||R===ke)B++;else if(R===ge||R===U||R===_e||R===Ce&&!Ue()){if(B===0)break;B--}else if(B===0&&(R===J||R===Je))break;else if(B===0&&R===$e&&!St())break;if(B===0&&ft())break;e++}E=V(N,e)}let M="";if(e<g&&f.charCodeAt(e)===$e)if(me&&E){e++;let N=0;while(e<g){if(Be())continue;let B=f.charCodeAt(e);if(B===X||B===W||B===Se)N++;else if(B===ge||B===U||B===_e){if(N===0&&B===U)break;N--}else if(N===0&&B===J)break;if(N===0&&ft())break;e++}}else{e++,x();let N=e,B=0;while(e<g){if(Be())continue;let R=f.charCodeAt(e);if(R===X||R===W||R===Se)B++;else if(R===ge||R===U||R===_e){if(B===0&&R===U)break;B--}else if(B===0&&R===J)break;if(B===0&&ft())break;e++}M=V(N,e)}if(e<g&&f.charCodeAt(e)===J)e++;let y=E.length>0;if(!E)if(M){let N=At(M);if(N)E=N;else E=M.endsWith("as const")||r&&a?Tt(M):dt(M)}else E="unknown";let v=k?"?":"";he.at(-1)?.fields.set(`${r?"static:":""}${s}`,k?`(${E}) | undefined`:E);let q=K&&!y&&M?Wt(b,M,E):"";A.push(`${q}${o}${s}${v}: ${E};`)}else Xt()}function $n(s){let o=0;for(let r=0;r<s.length;r++){let a=s.charCodeAt(r);if(a===X||a===W||a===Se||a===ke)o++;else if(a===ge||a===U||a===_e||a===Ce&&s.charCodeAt(r-1)!==$e)o--;else if(a===$e&&o===0&&s.charCodeAt(r+1)!==Ce&&s.charCodeAt(r+1)!==$e)return!0}return!1}function xn(s,o){let r=s.slice(1,-1).trim();if(!r)return;let a=[],l=0,u=0,C=!1,A=0,b=[];for(let p=0;p<=r.length;p++){if(p===r.length){b.push(r.slice(l)),a.push(Ct(r.slice(l).trim()));break}let k=r.charCodeAt(p);if(C){if(k===Qe){p++;continue}if(k===A)C=!1;continue}if(k===F&&p+1<r.length){let D=r.charCodeAt(p+1);if(D===we){p+=2;while(p+1<r.length&&!(r.charCodeAt(p)===we&&r.charCodeAt(p+1)===F))p++;p++;continue}if(D===F){while(p<r.length&&r.charCodeAt(p)!==10)p++;continue}}if(k===pe||k===Ae||k===Ee){C=!0,A=k;continue}if(k===X||k===W||k===Se||k===ke)u++;else if(k===ge||k===U||k===_e||k===Ce&&!(p>0&&r.charCodeAt(p-1)===$e))u--;else if(k===Je&&u===0)b.push(r.slice(l,p)),a.push(Ct(r.slice(l,p).trim())),l=p+1}for(let[p,k]of a.entries()){let D=k.startsWith("public ")||k.startsWith("public\t"),E=k.startsWith("protected ")||k.startsWith("protected\t"),M=k.startsWith("private ")||k.startsWith("private\t"),y=k.includes("readonly ");if(!D&&!E&&!M&&!y)continue;let v=k,q=[];if(M){let oe=7;while(oe<v.length&&We(v.charCodeAt(oe)))oe++;v=v.slice(oe),q.push("private")}if(D){let oe=6;while(oe<v.length&&We(v.charCodeAt(oe)))oe++;v=v.slice(oe),q.push("public")}if(E){let oe=9;while(oe<v.length&&We(v.charCodeAt(oe)))oe++;v=v.slice(oe),q.push("protected")}if(y){let oe=v.indexOf("readonly ");if(oe!==-1){let De=oe+8;while(De<v.length&&We(v.charCodeAt(De)))De++;v=v.slice(0,oe)+v.slice(De)}q.push("readonly")}let N=q.length>0?`${q.join(" ")} `:"",B=Qt(v),R=v.search(/[?:=]/);if(R!==-1&&v.charCodeAt(R)!==63&&$n(v))B=B.replace(/^([\w$]+)\?:/,"$1:");let ye="";if(K&&!M&&R!==-1&&v.charCodeAt(R)===$e){let oe=v.slice(R+1);ye=Wt(Jn(b[p]),oe,dt(oe))}o.push(M?` private ${B.split(/[?:]/,1)[0]};`:`${ye} ${N}${B};`)}}function Lt(s=" "){if(e>=g||f.charCodeAt(e)!==W)return"{}";e++;let o=[];while(e<g){if(x(),e>=g)break;if(f.charCodeAt(e)===U){e++;break}if(f.charCodeAt(e)===J){e++;continue}let r=!1;if(w("export"))r=!0,e+=6,x();if(w("declare"))e+=7,x();let a=r?"export ":"";if(w("function")||w("async")&&yn("async","function")){let l=!1;if(w("async"))l=!0,e+=5,x();if(e+=8,x(),e<g&&f.charCodeAt(e)===we)e++,x();let C=Te();x();let A=Xe();x();let b=et();x();let p=ut();if(!p)p=l?"Promise<void>":"void";if(x(),e<g&&f.charCodeAt(e)===W)Pe(W,U);else if(e<g&&f.charCodeAt(e)===J)e++;let k=ot(b);o.push(`${s}${a}function ${C}${A}${k}: ${p};`)}else if(w("const")||w("let")||w("var")){let l=w("const")?"const":w("let")?"let":"var";e+=l.length,x();let u=Te();if(!u){Me(!0);continue}x();let C="";if(e<g&&f.charCodeAt(e)===Ze){e++,x();let b=e,p=0;while(e<g){if(Be())continue;let k=f.charCodeAt(e);if(k===X||k===W||k===Se||k===ke)p++;else if(k===U&&p===0)break;else if(k===ge||k===U||k===_e||k===Ce&&!Ue())p--;else if(p===0&&(k===J||k===Je))break;else if(p===0&&k===$e&&!St())break;if(p===0&&st())break;e++}C=V(b,e)}let A="";if(e<g&&f.charCodeAt(e)===$e){e++,x();let b=e,p=0;while(e<g){if(Be())continue;let k=f.charCodeAt(e);if(k===X||k===W||k===Se||k===ke)p++;else if(k===U&&p===0)break;else if(k===ge||k===U||k===_e||k===Ce&&!Ue())p--;else if(p===0&&(k===J||k===Je))break;if(p===0&&st())break;e++}A=V(b,e)}if(e<g&&f.charCodeAt(e)===J)e++;if(!C&&A){let b=At(A);if(b)C=b;else if(l==="const")C=Tt(A);else C=dt(A)}if(!C)C="unknown";o.push(`${s}${a}${l} ${u}: ${C};`)}else if(w("interface")){e+=9,x();let l=Te();x();let u=Xe();x();let C="";if(w("extends")){e+=7,x();let b=e,p=0;while(e<g){if(Be())continue;let k=f.charCodeAt(e);if(k===ke)p++;else if(k===Ce&&!Ue())p--;else if(k===W&&p===0)break;e++}C=V(b,e)}let A=Vt(Dt());o.push(`${s}${a}interface ${l}${u}${C?` extends ${C}`:""} ${A}`)}else if(w("type")){e+=4,x();let l=Te();x();let u=Xe();if(x(),e<g&&f.charCodeAt(e)===$e){e++,x();let C=e,A=0;while(e<g){if(Be())continue;let p=f.charCodeAt(e);if(p===X||p===W||p===Se||p===ke)A++;else if(p===U&&A===0)break;else if(p===ge||p===U||p===_e||p===Ce&&!Ue())A--;else if(A===0&&p===J)break;if(A===0&&st())break;e++}let b=V(C,e);if(e<g&&f.charCodeAt(e)===J)e++;o.push(`${s}${a}type ${l}${u} = ${b}`)}}else if(w("class")){e+=5,x();let l=Te();x();let u=Xe();x();let C=e,A=0;while(e<g){if(Be())continue;let D=f.charCodeAt(e);if(D===ke)A++;else if(D===Ce&&!Ue())A--;else if(D===W&&A===0)break;e++}let b=V(C,e),p=b?` ${b}`:"",k=Pt();o.push(`${s}${a}class ${l}${u}${p} ${k}`)}else if(w("enum")){e+=4,x();let l=Te();x();let u=Dt();o.push(`${s}${a}enum ${l} ${u}`)}else if(w("namespace")||w("module")){let l=w("namespace")?"namespace":"module";e+=l.length,x();let u=Te();x();let C=Lt(s);o.push(`${s}${a}${l} ${u} ${C}`)}else if(w("abstract"))if(e+=8,x(),w("class")){e+=5,x();let l=Te();x();let u=Xe();x();let C=e,A=0;while(e<g){if(Be())continue;let D=f.charCodeAt(e);if(D===ke)A++;else if(D===Ce&&!Ue())A--;else if(D===W&&A===0)break;e++}let b=V(C,e),p=b?` ${b}`:"",k=Pt();o.push(`${s}${a}abstract class ${l}${u}${p} ${k}`)}else Me(!0);else if(r&&w("default")){e+=7,x();let l=e;Me(!0);let u=V(l,e);if(u.charCodeAt(u.length-1)===J)u=u.slice(0,-1);if(u)o.push(`${s}export default ${u};`)}else if(!r&&(f.charCodeAt(e)===pe||f.charCodeAt(e)===Ae||f.charCodeAt(e)===Ee))Me(!0);else Me(!0)}if(o.length===0)return"{}";return`{
|
|
34
34
|
${o.join(`
|
|
35
35
|
`)}
|
|
36
|
-
}`}function yn(s,o){let r=e+s.length;while(r<g&&We(f.charCodeAt(r)))r++;for(let a=0;a<o.length;a++)if(r+a>=g||f.charCodeAt(r+a)!==o.charCodeAt(a))return!1;return r+o.length>=g||!i(f.charCodeAt(r+o.length))}function at(s,o,r){e+=r.length,x();let a="",l=f.charCodeAt(e);if(l===pe||l===Ae){let p=e;Ge(l),a=f.slice(p,e)}else{a=Te();while(e<g&&f.charCodeAt(e)===Ye)e++,a+=`.${Te()}`}x();let u=e<g&&f.charCodeAt(e)===W?Lt():"{}",C=`${o?"export ":""}declare ${r} ${a} ${u}`,A=Ve(s),b=a.startsWith("'")||a.startsWith('"');return{kind:"module",name:a,text:C,isExported:o,moduleForm:b?"quoted":r==="namespace"?"namespace":"identifier",source:b?a.slice(1,-1):void 0,leadingComments:A,start:s,end:e}}function tn(s,o){Me();let r=V(o,e);if(r.charCodeAt(r.length-1)===J)r=r.slice(0,-1).trimEnd();if(!r)return;let a=c(r.charCodeAt(0));for(let k=1;a&&k<r.length;k++)a=i(r.charCodeAt(k));let l=Ve(s);if(a){P.push({kind:"export",name:"default",text:`export default ${r};`,isExported:!0,isTypeOnly:!1,leadingComments:l,start:s,end:e});return}let u="__dtsx_default_export__",C=1;while(f.includes(u))u=`__dtsx_default_export_${C++}__`;let b=At(r)||se(r)||n(r,!1),p=b==="unknown"&&In(r)?`typeof ${r}`:b;P.push({kind:"variable",name:u,text:`declare const ${u}: ${p};`,isExported:!1,typeAnnotation:p,modifiers:["const"],start:s,end:e}),P.push({kind:"export",name:"default",text:`export default ${u};`,isExported:!0,isTypeOnly:!1,leadingComments:l,start:s,end:e})}function nn(){if(f.charCodeAt(e)===W)return Pe(W,U),!0;let s=w("if"),o=w("do"),r=w("try"),a=w("for");if(!s&&!o&&!r&&!a&&!w("while")&&!w("switch")&&!w("with"))return!1;if(Te(),x(),a&&w("await"))e+=5,x();if(!o&&!r&&f.charCodeAt(e)===X)Pe(X,ge);if(wt(),x(),s&&w("else"))e+=4,wt();else if(o&&w("while")){if(e+=5,x(),f.charCodeAt(e)===X)Pe(X,ge);if(x(),f.charCodeAt(e)===J)e++}else if(r){if(w("catch")){if(e+=5,x(),f.charCodeAt(e)===X)Pe(X,ge);wt(),x()}if(w("finally"))e+=7,wt()}return!0}function wt(){if(x(),!nn())Me()}while(e<g){if(x(),e>=g)break;if(nn())continue;let s=e,o=f.charCodeAt(e);if(o===105&&w("import"))P.push(mn(s));else if(o===101&&w("export")){e+=6,x();let r=f.charCodeAt(e);if(r===100&&w("default")){e+=7,x();let a=e,l=f.charCodeAt(e);if(l===102&&w("function")){let u=tt(s,!0,!1,!0);if(u)P.push(u)}else if(l===97&&w("async")&&kt("async")!==J)if(e+=5,x(),w("function")){let u=tt(s,!0,!0,!0);if(u)P.push(u)}else tn(s,a);else if(l===99&&w("class")){let u=nt(s,!0,!1,!0);P.push(u)}else if(l===97&&w("abstract")){if(e+=8,x(),w("class")){let u=nt(s,!0,!0,!0);P.push(u)}}else tn(s,a)}else if(r===116&&w("type")){let a=e;if(e+=4,x(),e<g&&f.charCodeAt(e)===W){Gt();let l=V(s,e),u=Ve(s);P.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:!0,source:gt(l),leadingComments:u,start:s,end:e})}else if(e<g&&f.charCodeAt(e)===we){Kt();let l=V(s,e);P.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:!0,source:gt(l),start:s,end:e})}else{e=a;let l=Et(s,!0);P.push(l)}}else if(r===105&&w("interface")){let a=Ot(s,!0);P.push(a)}else if(r===102&&w("function")){let a=tt(s,!0,!1,!1);if(a)P.push(a)}else if(r===97&&w("async"))if(e+=5,x(),w("function")){let a=tt(s,!0,!0,!1);if(a)P.push(a)}else Me();else if(r===99)if(w("class")){let a=nt(s,!0,!1);P.push(a)}else if(w("const")){let a=e;if(e+=5,x(),w("enum")){e=a+5,x();let l=ct(s,!0,!0);P.push(l)}else{e=a;let l=rt(s,"const",!0);for(let u=0;u<l.length;u++)P.push(l[u])}}else Me();else if(r===97&&w("abstract")){if(e+=8,x(),w("class")){let a=nt(s,!0,!0);P.push(a)}}else if(r===108&&w("let")){let a=rt(s,"let",!0);for(let l=0;l<a.length;l++)P.push(a[l])}else if(r===118&&w("var")){let a=rt(s,"var",!0);for(let l=0;l<a.length;l++)P.push(a[l])}else if(r===101&&w("enum")){let a=ct(s,!0,!1);P.push(a)}else if(r===100&&w("declare"))e+=7,x(),rn(s,!0);else if(r===110&&w("namespace")&&mt(9)){let a=at(s,!0,"namespace");P.push(a)}else if(r===109&&w("module")&&mt(6)){let a=at(s,!0,"module");P.push(a)}else if(r===W){Gt();let a=V(s,e),l=a.includes("export type"),u=Ve(s);P.push({kind:"export",name:"",text:a,isExported:!0,isTypeOnly:l,source:gt(a),leadingComments:u,start:s,end:e})}else if(r===we){Kt();let a=V(s,e),l=Ve(s);P.push({kind:"export",name:"",text:a,isExported:!0,isTypeOnly:!1,source:gt(a),leadingComments:l,start:s,end:e})}else{Me();let a=V(s,e);if(a)P.push({kind:"export",name:"",text:a,isExported:!0,start:s,end:e})}}else if(o===100&&w("declare"))e+=7,x(),rn(s,!1);else if(o===105&&w("interface")){let r=Ot(s,!1);ae.set(r.name,r)}else if(o===116&&w("type")){let r=Et(s,!1);ae.set(r.name,r),P.push(r)}else if(o===102&&w("function")){let r=tt(s,!1,!1,!1);if(r)ee(r);else Me()}else if(o===97)if(w("async")){let r=e;if(e+=5,x(),w("function")){let a=tt(s,!1,!0,!1);if(a)ee(a);else e=r,Me()}else e=r,Me()}else if(w("abstract"))if(e+=8,x(),w("class")){let r=nt(s,!1,!1);ae.set(r.name,r),P.push(r)}else Me();else e++,Me();else if(o===99)if(w("class")){let r=nt(s,!1,!1);ae.set(r.name,r),P.push(r)}else if(w("const")){let r=e;if(e+=5,x(),w("enum")){e=r+5,x();let a=ct(s,!1,!0);ae.set(a.name,a),P.push(a)}else{e=r;let a=rt(s,"const",!1);for(let l=0;l<a.length;l++)ae.set(a[l].name,a[l])}}else e++,Me();else if(o===101&&w("enum")){let r=ct(s,!1,!1);ae.set(r.name,r),P.push(r)}else if(o===108&&w("let")||o===118&&w("var")){let r=w("let")?"let":"var",a=rt(s,r,!1);for(let l=0;l<a.length;l++)ae.set(a[l].name,a[l])}else if(o===109&&w("module")&&mt(6)){let r=at(s,!1,"module");P.push(r)}else if(o===110&&w("namespace")&&mt(9)){let r=at(s,!1,"namespace");P.push(r)}else{let r=f.charCodeAt(e);if(r===J)e++;else if(r===pe||r===Ae){if(Ge(r),e<g&&f.charCodeAt(e)===J)e++}else if(r===Ee){if(lt(),e<g&&f.charCodeAt(e)===J)e++}else if(r===Dn){if(e++,Te(),x(),e<g&&f.charCodeAt(e)===Ye)e++,Te(),x();if(e<g&&f.charCodeAt(e)===X)Pe(X,ge)}else e++,Me()}}if(xe.size>0){sn(P);for(let s of Q.values())sn(s)}if(Nn(f,P,ae,Q),Bn(P,ae),Yn(P,ae),!me)
|
|
36
|
+
}`}function yn(s,o){let r=e+s.length;while(r<g&&We(f.charCodeAt(r)))r++;for(let a=0;a<o.length;a++)if(r+a>=g||f.charCodeAt(r+a)!==o.charCodeAt(a))return!1;return r+o.length>=g||!i(f.charCodeAt(r+o.length))}function at(s,o,r){e+=r.length,x();let a="",l=f.charCodeAt(e);if(l===pe||l===Ae){let p=e;Ge(l),a=f.slice(p,e)}else{a=Te();while(e<g&&f.charCodeAt(e)===Ye)e++,a+=`.${Te()}`}x();let u=e<g&&f.charCodeAt(e)===W?Lt():"{}",C=`${o?"export ":""}declare ${r} ${a} ${u}`,A=Ve(s),b=a.startsWith("'")||a.startsWith('"');return{kind:"module",name:a,text:C,isExported:o,moduleForm:b?"quoted":r==="namespace"?"namespace":"identifier",source:b?a.slice(1,-1):void 0,leadingComments:A,start:s,end:e}}function tn(s,o){Me();let r=V(o,e);if(r.charCodeAt(r.length-1)===J)r=r.slice(0,-1).trimEnd();if(!r)return;let a=c(r.charCodeAt(0));for(let k=1;a&&k<r.length;k++)a=i(r.charCodeAt(k));let l=Ve(s);if(a){P.push({kind:"export",name:"default",text:`export default ${r};`,isExported:!0,isTypeOnly:!1,leadingComments:l,start:s,end:e});return}let u="__dtsx_default_export__",C=1;while(f.includes(u))u=`__dtsx_default_export_${C++}__`;let b=At(r)||se(r)||n(r,!1),p=b==="unknown"&&In(r)?`typeof ${r}`:b;P.push({kind:"variable",name:u,text:`declare const ${u}: ${p};`,isExported:!1,typeAnnotation:p,modifiers:["const"],start:s,end:e}),P.push({kind:"export",name:"default",text:`export default ${u};`,isExported:!0,isTypeOnly:!1,leadingComments:l,start:s,end:e})}function nn(){if(f.charCodeAt(e)===W)return Pe(W,U),!0;let s=w("if"),o=w("do"),r=w("try"),a=w("for");if(!s&&!o&&!r&&!a&&!w("while")&&!w("switch")&&!w("with"))return!1;if(Te(),x(),a&&w("await"))e+=5,x();if(!o&&!r&&f.charCodeAt(e)===X)Pe(X,ge);if(wt(),x(),s&&w("else"))e+=4,wt();else if(o&&w("while")){if(e+=5,x(),f.charCodeAt(e)===X)Pe(X,ge);if(x(),f.charCodeAt(e)===J)e++}else if(r){if(w("catch")){if(e+=5,x(),f.charCodeAt(e)===X)Pe(X,ge);wt(),x()}if(w("finally"))e+=7,wt()}return!0}function wt(){if(x(),!nn())Me()}while(e<g){if(x(),e>=g)break;if(nn())continue;let s=e,o=f.charCodeAt(e);if(o===105&&w("import"))P.push(mn(s));else if(o===101&&w("export")){e+=6,x();let r=f.charCodeAt(e);if(r===100&&w("default")){e+=7,x();let a=e,l=f.charCodeAt(e);if(l===102&&w("function")){let u=tt(s,!0,!1,!0);if(u)P.push(u)}else if(l===97&&w("async")&&kt("async")!==J)if(e+=5,x(),w("function")){let u=tt(s,!0,!0,!0);if(u)P.push(u)}else tn(s,a);else if(l===99&&w("class")){let u=nt(s,!0,!1,!0);P.push(u)}else if(l===97&&w("abstract")){if(e+=8,x(),w("class")){let u=nt(s,!0,!0,!0);P.push(u)}}else tn(s,a)}else if(r===116&&w("type")){let a=e;if(e+=4,x(),e<g&&f.charCodeAt(e)===W){Gt();let l=V(s,e),u=Ve(s);P.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:!0,source:gt(l),leadingComments:u,start:s,end:e})}else if(e<g&&f.charCodeAt(e)===we){Kt();let l=V(s,e);P.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:!0,source:gt(l),start:s,end:e})}else{e=a;let l=Et(s,!0);P.push(l)}}else if(r===105&&w("interface")){let a=Ot(s,!0);P.push(a)}else if(r===102&&w("function")){let a=tt(s,!0,!1,!1);if(a)P.push(a)}else if(r===97&&w("async"))if(e+=5,x(),w("function")){let a=tt(s,!0,!0,!1);if(a)P.push(a)}else Me();else if(r===99)if(w("class")){let a=nt(s,!0,!1);P.push(a)}else if(w("const")){let a=e;if(e+=5,x(),w("enum")){e=a+5,x();let l=ct(s,!0,!0);P.push(l)}else{e=a;let l=rt(s,"const",!0);for(let u=0;u<l.length;u++)P.push(l[u])}}else Me();else if(r===97&&w("abstract")){if(e+=8,x(),w("class")){let a=nt(s,!0,!0);P.push(a)}}else if(r===108&&w("let")){let a=rt(s,"let",!0);for(let l=0;l<a.length;l++)P.push(a[l])}else if(r===118&&w("var")){let a=rt(s,"var",!0);for(let l=0;l<a.length;l++)P.push(a[l])}else if(r===101&&w("enum")){let a=ct(s,!0,!1);P.push(a)}else if(r===100&&w("declare"))e+=7,x(),rn(s,!0);else if(r===110&&w("namespace")&&mt(9)){let a=at(s,!0,"namespace");P.push(a)}else if(r===109&&w("module")&&mt(6)){let a=at(s,!0,"module");P.push(a)}else if(r===W){Gt();let a=V(s,e),l=a.includes("export type"),u=Ve(s);P.push({kind:"export",name:"",text:a,isExported:!0,isTypeOnly:l,source:gt(a),leadingComments:u,start:s,end:e})}else if(r===we){Kt();let a=V(s,e),l=Ve(s);P.push({kind:"export",name:"",text:a,isExported:!0,isTypeOnly:!1,source:gt(a),leadingComments:l,start:s,end:e})}else{Me();let a=V(s,e);if(a)P.push({kind:"export",name:"",text:a,isExported:!0,start:s,end:e})}}else if(o===100&&w("declare"))e+=7,x(),rn(s,!1);else if(o===105&&w("interface")){let r=Ot(s,!1);ae.set(r.name,r)}else if(o===116&&w("type")){let r=Et(s,!1);ae.set(r.name,r),P.push(r)}else if(o===102&&w("function")){let r=tt(s,!1,!1,!1);if(r)ee(r);else Me()}else if(o===97)if(w("async")){let r=e;if(e+=5,x(),w("function")){let a=tt(s,!1,!0,!1);if(a)ee(a);else e=r,Me()}else e=r,Me()}else if(w("abstract"))if(e+=8,x(),w("class")){let r=nt(s,!1,!1);ae.set(r.name,r),P.push(r)}else Me();else e++,Me();else if(o===99)if(w("class")){let r=nt(s,!1,!1);ae.set(r.name,r),P.push(r)}else if(w("const")){let r=e;if(e+=5,x(),w("enum")){e=r+5,x();let a=ct(s,!1,!0);ae.set(a.name,a),P.push(a)}else{e=r;let a=rt(s,"const",!1);for(let l=0;l<a.length;l++)ae.set(a[l].name,a[l])}}else e++,Me();else if(o===101&&w("enum")){let r=ct(s,!1,!1);ae.set(r.name,r),P.push(r)}else if(o===108&&w("let")||o===118&&w("var")){let r=w("let")?"let":"var",a=rt(s,r,!1);for(let l=0;l<a.length;l++)ae.set(a[l].name,a[l])}else if(o===109&&w("module")&&mt(6)){let r=at(s,!1,"module");P.push(r)}else if(o===110&&w("namespace")&&mt(9)){let r=at(s,!1,"namespace");P.push(r)}else{let r=f.charCodeAt(e);if(r===J)e++;else if(r===pe||r===Ae){if(Ge(r),e<g&&f.charCodeAt(e)===J)e++}else if(r===Ee){if(lt(),e<g&&f.charCodeAt(e)===J)e++}else if(r===Dn){if(e++,Te(),x(),e<g&&f.charCodeAt(e)===Ye)e++,Te(),x();if(e<g&&f.charCodeAt(e)===X)Pe(X,ge)}else e++,Me()}}if(xe.size>0){sn(P);for(let s of Q.values())sn(s)}if(Nn(f,P,ae,Q),Bn(P,ae),Yn(P,ae),!me)jn(f,P,ae,ne);if(te){let s=new Set(P);for(let o of[...ae.values(),...[...Q.values()].flat()])if(!s.has(o))P.push(o),s.add(o);return P.sort((o,r)=>(o.start??0)-(r.start??0))}if(ae.size>0)On(P,ae,Q);return P;function sn(s){let o=new Map;for(let a of s)if(a.kind==="function")o.set(a.name,(o.get(a.name)||0)+1);let r=new Set;for(let[a,l]of o)if(l>1)r.add(a);if(r.size>0){let a=new Set;for(let l of r)for(let u=s.length-1;u>=0;u--)if(s[u].kind==="function"&&s[u].name===l&&xe.has(s[u])){a.add(u);break}if(a.size>0){let l=[...a].sort((u,C)=>C-u);for(let u of l)s.splice(u,1)}}}function rn(s,o){if(w("function")){let r=tt(s,o,!1,!1);if(r)P.push(r)}else if(w("async")){if(e+=5,x(),w("function")){let r=tt(s,o,!0,!1);if(r)P.push(r)}}else if(w("class")){let r=nt(s,o,!1);P.push(r)}else if(w("abstract")){if(e+=8,x(),w("class")){let r=nt(s,o,!0);P.push(r)}}else if(w("interface")){let r=Ot(s,o);P.push(r)}else if(w("type")){let r=Et(s,o);P.push(r)}else if(w("enum")){let r=ct(s,o,!1);P.push(r)}else if(w("const")){let r=e;if(e+=5,x(),w("enum")){e=r+5,x();let a=ct(s,o,!0);P.push(a)}else{e=r;let a=rt(s,"const",o);for(let l=0;l<a.length;l++)if(o||!ce)P.push(a[l]);else ae.set(a[l].name,a[l])}}else if(w("let")||w("var")){let r=w("let")?"let":"var",a=rt(s,r,o);for(let l=0;l<a.length;l++)if(o||!ce)P.push(a[l]);else ae.set(a[l].name,a[l])}else if(w("module")){let r=at(s,o,"module");P.push(r)}else if(w("namespace")){let r=at(s,o,"namespace");P.push(r)}else if(w("global")){e+=6,x();let a=`declare global ${e<g&&f.charCodeAt(e)===W?Lt():"{}"}`,l=Ve(s);P.push({kind:"module",name:"global",text:a,isExported:!1,moduleForm:"global",leadingComments:l,start:s,end:e})}else Me()}}class an{names;lengths=new Uint8Array(65);firstUnits=new Uint8Array(65536);size;constructor(S){this.names=S;for(let Z of S.keys()){if(!Z)continue;this.lengths[Math.min(Z.length,64)]=1,this.firstUnits[Z.charCodeAt(0)]=1}this.size=S.size}scan(S,Z){if(this.size===0)return!1;let H=!1,G=0,te=S.length;while(G<te){let ne=S.charCodeAt(G);if(ne>=65&&ne<=90||ne>=97&&ne<=122||ne===95||ne===36||ne>127){let f=G;G++;while(G<te){let K=S.charCodeAt(G);if(K>=65&&K<=90||K>=97&&K<=122||K>=48&&K<=57||K===95||K===36||K>127)G++;else break}if(this.firstUnits[ne]===1&&this.lengths[Math.min(G-f,64)]===1){let K=S.substring(f,G),me=this.names.get(K);if(me!==void 0){if(Z.add(K),me.kind==="function"||me.kind==="variable")H=!0}}}else G++}return H}}function cn(S,Z){let H=0;while(H<S.length){let G=S.charCodeAt(H);if(G===pe||G===Ae||G===Ee){let ce=G;H++;while(H<S.length)if(S.charCodeAt(H)===Qe)H+=2;else if(S.charCodeAt(H++)===ce)break;continue}if(G===F&&S.charCodeAt(H+1)===F){H+=2;while(H<S.length&&S.charCodeAt(H)!==be&&S.charCodeAt(H)!==ve)H++;continue}if(G===F&&S.charCodeAt(H+1)===we){let ce=S.indexOf("*/",H+2);H=ce===-1?S.length:ce+2;continue}if(!c(G)){H++;continue}let te=H++;while(H<S.length&&i(S.charCodeAt(H)))H++;let ne=te-1,f=H;while(ne>=0&&We(S.charCodeAt(ne)))ne--;while(f<S.length&&We(S.charCodeAt(f)))f++;let K=ne>=0?S.charCodeAt(ne):0,me=f<S.length?S.charCodeAt(f):0,g=te>=3&&S.slice(te-3,te)==="...";if(me===Ze||K===Ye&&!g)continue;if(me===X&&(K===W||K===Je))continue;Z.add(S.slice(te,H))}}function On(S,Z,H){let G=new Set,te=new Set;for(let ce of S)te.add(ce.name);let ne=new an(Z),f=new Set,K=new Set,me=(ce)=>{if(ne.scan(ce.text,f))qn(ce,K)},g=new Set;for(let ce=0;ce<S.length;ce++){let P=S[ce];if(P.kind!=="import"){if(me(P),typeof P.value==="string")cn(P.value,g)}}for(;;){let ce=[];for(let[Q,xe]of Z){if(G.has(Q))continue;if((xe.kind==="function"||xe.kind==="variable"?K:f).has(Q)||xe.kind!=="function"&&g.has(Q)){if(!te.has(Q)){let le=xe.kind==="function"?H.get(Q):void 0;if(le)for(let he of le)ce.push(he);else ce.push(xe);te.add(Q)}G.add(Q)}}if(ce.length===0)break;ce.sort((Q,xe)=>(Q.start??1/0)-(xe.start??1/0));let P=[],ae=0;for(let Q=0;Q<S.length;Q++){let xe=S[Q].start??1/0;while(ae<ce.length&&(ce[ae].start??1/0)<=xe)P.push(ce[ae++]);P.push(S[Q])}while(ae<ce.length)P.push(ce[ae++]);S.length=0;for(let Q=0;Q<P.length;Q++)S.push(P[Q]);for(let Q of ce)if(Q.kind!=="import"){if(me(Q),typeof Q.value==="string")cn(Q.value,g)}}}
|
|
37
37
|
export{Ei,Ra,T,O,It};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,d,
|
|
3
|
-
export{
|
|
2
|
+
import{t,d,w}from"./chunk-g0dxj89b.js";var C={kind:"symbol"},K=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:[\d_]+(?:\.[\d_]*)?|\.[\d_]+)(?:[eE][+-]?[\d_]+)?)/,v={"|":1,"^":2,"&":3,"<<":4,">>":4,">>>":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},M=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"];function x(l,c,o=0){if(o>=64)return;let n=l.trim(),r=t(n);if(!r.length)return;if(r[0].start!==0||r[r.length-1].end!==n.length)return x(n.slice(r[0].start,r[r.length-1].end),c,o+1);if(r.length===1&&r[0].kind==="quoted")return d(n);if(r.length===1&&r[0].kind==="word"){let e=c.get(n);return typeof e==="object"?void 0:e}if(K.exec(n)?.[0].length===n.length){let e=Number(n.replaceAll("_",""));return Number.isFinite(e)?e:void 0}let i=0,a;for(let e=0;e<r.length;e++){let s=r[e],u=n.slice(s.start,s.end);if(s.kind!=="punctuation")continue;if(["(","[","{"].includes(u)){i++;continue}if([")","]","}"].includes(u)){i--;continue}let m=K.exec(n.slice(s.start));if(m){while(r[e+1]?.start<s.start+m[0].length)e++;continue}if(i)continue;let f=M.find((S)=>n.startsWith(S,s.start));if(!f)continue;let p=r[e-1],h=p?n.slice(p.start,p.end):"";if(!(!p||p.kind==="punctuation"&&![")","]"].includes(h)&&!/\d/.test(h))&&(!a||v[f]<a.priority||v[f]===a.priority&&f!=="**"))a={start:s.start,operator:f,priority:v[f]};while(r[e+1]?.start<s.start+f.length)e++}if(a){let e=x(n.slice(0,a.start),c,o+1),s=x(n.slice(a.start+a.operator.length),c,o+1);if(e===void 0||s===void 0)return;if(a.operator==="+"&&(typeof e==="string"||typeof s==="string"))return String(e)+String(s);if(typeof e!=="number"||typeof s!=="number")return;let u;switch(a.operator){case"+":u=e+s;break;case"-":u=e-s;break;case"*":u=e*s;break;case"/":u=e/s;break;case"%":u=e%s;break;case"**":u=e**s;break;case"<<":u=e<<s;break;case">>":u=e>>s;break;case">>>":u=e>>>s;break;case"|":u=e|s;break;case"^":u=e^s;break;case"&":u=e&s;break;default:return}return Number.isFinite(u)?u:void 0}if(n.startsWith("(")&&n.endsWith(")")){let e=0;if(r.every((u,m)=>{let f=n.slice(u.start,u.end);if(f==="(")e++;if(f===")")e--;return e!==0||m===r.length-1}))return x(n.slice(1,-1),c,o+1)}if(["+","-","~"].includes(n[0])){let e=x(n.slice(1),c,o+1);if(typeof e!=="number")return;return n[0]==="-"?-e:n[0]==="~"?~e:e}if(!n.startsWith("`")||!n.endsWith("`"))return;let y="",b=1;for(let e=1;e<n.length-1;e++){if(n[e]==="\\"){e++;continue}if(n[e]!=="$"||n[e+1]!=="{")continue;let s=d(`\`${n.slice(b,e)}\``);if(s===void 0)return;y+=s;let u=0,m=r.find((p)=>{if(p.start<e+2||p.kind!=="punctuation")return!1;let h=n.slice(p.start,p.end);if(h==="{")u++;if(h!=="}")return!1;if(u===0)return!0;return u--,!1});if(!m)return;let f=x(n.slice(e+2,m.start),c,o+1);if(f===void 0)return;y+=String(f),e=m.start,b=e+1}let g=d(`\`${n.slice(b,-1)}\``);return g===void 0?void 0:y+g}function Yn(l,c){let o=[...new Set([...l,...c.values()])];if(!o.some((i)=>i.kind==="variable"&&typeof i.value==="string"&&/[\[{]/.test(i.value)))return;o.sort((i,a)=>(i.start??0)-(a.start??0));let n=new Map,r=new Map,k=o.some((i)=>i.name==="Symbol");for(let i of o){if(i.kind!=="variable"||typeof i.value!=="string")continue;if(i.value.includes("{")||i.value.includes("[")){let g=new Map(n);g.mutableBindingTypes=new Map(r),i.computedKeyConstants=g}let a=t(i.value),y=a.length===1&&a[0].kind==="word"?n.get(i.value.slice(a[0].start,a[0].end)):void 0;if(i.typeAnnotation==="unique symbol"||i.typeAnnotation==="symbol"||typeof y==="object"||!k&&a[0]?.kind==="word"&&i.value.slice(a[0].start,a[0].end)==="Symbol"&&["(","."].includes(i.value.slice(a[1]?.start,a[1]?.end))){n.set(i.name,C);continue}if(i.modifiers?.[0]!=="const"||i.typeAnnotation||i.modifiers.includes("const assertion"))continue;let b=x(i.value,n);if(b!==void 0){if(n.set(i.name,b),!(a.length===1&&a[0].kind==="word")||r.has(i.value.trim()))r.set(i.name,typeof b)}else if(i.value.trim()==="true"||i.value.trim()==="false")r.set(i.name,"boolean");else if(a.length===1&&a[0].kind==="word"){let g=r.get(i.value.trim());if(g)r.set(i.name,g)}}}function Xn(l,c){if(!l.trimStart().startsWith("[")||!l.includes("`"))return;let o=t(l);if(l[o[0]?.start]!=="["||l[o[1]?.start]!=="`"||l[o.at(-1)?.start??-1]!=="]")return;let n=l.slice(o[0].end,o.at(-1).start).trim(),r=x(n,c??new Map);return typeof r==="string"?{name:w(r,"'")}:{index:!0}}function Zn(l,c){if(!c||!l.trimStart().startsWith("["))return!1;let o=t(l);return o.length===3&&l[o[0].start]==="["&&o[1].kind==="word"&&l[o[2].start]==="]"&&typeof c.get(l.slice(o[1].start,o[1].end))==="object"}function Qn(l){if(!l.trimStart().startsWith("[")||!l.includes("`"))return!1;let c=t(l);return l[c[1]?.start]==="`"&&c.some((o)=>o.kind==="punctuation"&&l[o.start]==="{")}
|
|
3
|
+
export{x,Yn,Xn,Zn,Qn};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{c,i,Ne,de}from"./chunk-8kj9pkw5.js";function t(s){let r=[],a=s.length,e=0;function n(){let l=e++;while(e<a){let u=s.charCodeAt(e);if(u===92)e+=2;else if(u===96){r.push({start:l,end:++e,kind:"literal"});return}else if(u===36&&s.charCodeAt(e+1)===123)r.push({start:l,end:e+1,kind:"literal"}),r.push({start:e+1,end:e+2,kind:"punctuation"}),e+=2,h(!0),l=e;else e++}r.push({start:l,end:e,kind:"literal"})}function h(l=!1){let u=0;while(e<a){let b=e,p=s.charCodeAt(e);if(p===32||p>=9&&p<=13||p>127&&/\s/.test(s[e])){e++;continue}if(p===47){let S=s.charCodeAt(e+1);if(S===47){let g=s.indexOf(`
|
|
3
|
+
`,e+2);e=g===-1?a:g+1;continue}if(S===42){let g=s.indexOf("*/",e+2);e=g===-1?a:g+2;continue}if(Ne(s,e)){e=de(s,e),r.push({start:b,end:e,kind:"literal"});continue}}else if(p===96){n();continue}else if(p===34||p===39){e++;let S=!1;while(e<a){let g=s.charCodeAt(e++);if(g===92)e++;else if(g===p){S=!0;break}}r.push({start:b,end:Math.min(e,a),kind:S?"quoted":"literal"});continue}else if(c(p)){while(i(s.charCodeAt(++e)));r.push({start:b,end:e,kind:"word"});continue}if(r.push({start:b,end:++e,kind:"punctuation"}),l){if(p===123)u++;else if(p===125){if(u===0)return;u--}}}}return h(),r}var C,M=[];function F(s){if(s!==C)M=t(s),C=s;return M}function nr(){C=void 0,M=[]}function d(s){let r="",a=s.length-1;for(let e=1;e<a;e++){if(s[e]!=="\\"){r+=s[e];continue}let n=s[++e];if(e>=a)return;switch(n){case`
|
|
4
|
+
`:break;case"\r":if(s[e+1]===`
|
|
5
|
+
`)e++;break;case"n":r+=`
|
|
6
|
+
`;break;case"r":r+="\r";break;case"t":r+="\t";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;case"0":if(/\d/.test(s[e+1]??""))return;r+="\x00";break;case"x":case"u":{let h=n==="u"&&s[e+1]==="{",l=e+(h?2:1),u=h?s.indexOf("}",l):l+(n==="x"?2:4),b=s.slice(l,u);if(u<l||u>a||!/^[\da-f]+$/i.test(b)||h&&b.length>6)return;let p=Number.parseInt(b,16);if(p>1114111)return;r+=String.fromCodePoint(p),e=h?u:u-1;break}default:if(/\d/.test(n))return;r+=n}}return r}function w(s,r){let a=r;for(let e of s){let n=e.charCodeAt(0);if(e===r||e==="\\")a+=`\\${e}`;else if(n<32||n===8232||n===8233||e.length===1&&n>=55296&&n<=57343)a+=`\\u${n.toString(16).padStart(4,"0")}`;else a+=e}return a+r}function Fe(s){let r=t(s),a=(u)=>r[u]?s.slice(r[u].start,r[u].end):"";if(a(0)!=="import")return;let e=a(1)==="type"&&a(2)!=="=",n=e?2:1;if(r[n]?.kind!=="word"||a(n+1)!=="="||a(n+2)!=="require"||a(n+3)!=="("||r[n+4]?.kind!=="quoted"||a(n+5)!==")")return;let h=n+6;if(r.length!==h&&!(r.length===h+1&&a(h)===";"))return;let l=d(a(n+4));if(l===void 0)return;return{name:a(n),source:l,isTypeOnly:e,end:r[r.length-1].end}}function m(s){let r=t(s),a=[],e=new Set,n=(o)=>o>=0&&o<r.length?s.slice(r[o].start,r[o].end):"",h=(o)=>r[o]?.kind==="quoted",l=(o)=>r[o]?.kind==="word",u=[],b=!1,p=0;if(s.includes("declare")&&s.includes("module"))for(let o=0;o<r.length;o++){let k=n(o);if(p===0&&l(o)&&n(o-1)!=="."&&n(o-1)!=="#"){if(k==="export"||k==="import"&&n(o+1)!=="("&&n(o+1)!==".")b=!0;if(k==="declare"&&n(o+1)==="module"&&h(o+2)&&n(o+3)==="{")u.push(o+2)}if(k==="{"||k==="("||k==="[")p++;else if(k==="}"||k===")"||k==="]")p--}function S(o,k=!1){if(n(o)==="*"){if(n(o+1)==="as")return l(o+2)||k&&h(o+2)?o+3:-1;return k?o+1:-1}if(n(o)!=="{")return-1;let f=1;for(let x=o+1;x<r.length;x++)if(n(x)==="{")f++;else if(n(x)==="}"&&--f===0)return x+1;else if(r[x].kind==="literal"||n(x)===";")return-1;return-1}function g(o,k,f,x){let y=r[o];if(!y||y.kind!=="quoted"||e.has(y.start))return;let T=d(s.slice(y.start,y.end));if(T===void 0)return;e.add(y.start),a.push({specifier:T,kind:k,isTypeOnly:f,category:x,start:y.start,end:y.end})}for(let o=0;o<r.length;o++){if(!l(o)||n(o-1)==="."||n(o-1)==="#")continue;let k=n(o),f=o+1;if(k==="export"){let x=n(f)==="type";if(x)f++;let y=n(f)==="*"?n(f+1)==="as"?"export-star-as":"export-star":"export-named",T=S(f,!0);if(T>=0&&n(T)==="from")g(T+1,y,x,"export")}else if(k==="import"){if(h(f)){g(f,"import",!1,"static-import");continue}if(n(f)==="("){if(n(f+2)===")"||n(f+2)===",")g(f+1,"import",!1,"import-type");continue}let x=n(f)==="type"&&n(f+1)!=="from"&&n(f+1)!=="="&&n(f+1)!==",";if(x)f++;if(l(f)){if(f++,n(f)==="="){if(n(f+1)==="require"&&n(f+2)==="("&&n(f+4)===")")g(f+3,"import",x,"static-import");continue}if(n(f)===",")f=S(f+1)}else f=S(f);if(f>=0&&n(f)==="from")g(f+1,"import",x,"static-import")}}if(b&&u.length){for(let o of u)g(o,"import",!0,"augmentation");a.sort((o,k)=>o.start-k.start)}return a}
|
|
7
|
+
export{t,F,nr,d,w,Fe,m};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-xmj05115.js";import{existsSync as g,readFileSync as h,writeFileSync as b}from"fs";function d(t){let e=[],s=/\b([A-Z][a-zA-Z0-9]*)\b/g,o;while((o=s.exec(t))!==null){let i=o[1];if(!D(i))e.push(i)}return[...new Set(e)]}function D(t){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(t)}function x(t){if(t.kind!=="type")return!1;let e=t.typeAnnotation||"";if(t.generics)return!1;if(e.includes("{")||e.includes("(")||e.includes("<"))return!1;return/^[\w\s|&]+$/.test(e)}function v(t){if(t.kind!=="interface")return!1;if(!t.members||t.members.length===0){if(!t.extends)return!0}return!1}function I(t,e){let s={...t,members:[...t.members||[],...e.members||[]],leadingComments:[...t.leadingComments||[],...e.leadingComments||[]]};if(t.extends&&e.extends){let o=t.extends.split(",").map((n)=>n.trim()),i=e.extends.split(",").map((n)=>n.trim());s.extends=[...new Set([...o,...i])].join(", ")}else s.extends=t.extends||e.extends;return s}function A(t){let e={import:0,interface:1,type:2,class:3,enum:4,function:5,variable:6,export:7};return[...t].sort((s,o)=>{let i=e[s.kind]??99,n=e[o.kind]??99;if(i!==n)return i-n;return s.name.localeCompare(o.name)})}function T(t){let e=[],s=[];for(let i=0;i<t.length;i++){let n=t[i];if(n.kind==="import")e.push(n);else s.push(n)}return[...[...e].sort((i,n)=>{let a=i.source||"",c=n.source||"",p=a.startsWith("node:")||a==="bun",m=c.startsWith("node:")||c==="bun";if(p&&!m)return-1;if(!p&&m)return 1;let l=!a.startsWith("."),u=!c.startsWith(".");if(l&&!u)return-1;if(!l&&u)return 1;return a.localeCompare(c)}),...s]}function S(t){let e=new Set;for(let i of t){if(i.kind==="import")continue;let n=i.text||"",a=i.typeAnnotation||"",c=i.returnType||"",p=i.extends||"",m=i.implements?.join(" ")||"",l=`${n} ${a} ${c} ${p} ${m}`;for(let u of d(l))e.add(u);if(i.members)for(let u of i.members){let f=`${u.typeAnnotation||""} ${u.returnType||""}`;for(let y of d(f))e.add(y)}if(i.parameters){for(let u of i.parameters)if(u.type)for(let f of d(u.type))e.add(f)}}let s=0;return{declarations:t.map((i)=>{if(i.kind!=="import"||!i.specifiers)return i;let n=i.specifiers.filter((a)=>{let c=a.alias||a.name;return e.has(c)});if(n.length===0){if(!i.isSideEffect)return s++,null}if(n.length<(i.specifiers?.length||0))return s+=(i.specifiers?.length||0)-n.length,{...i,specifiers:n};return i}).filter((i)=>i!==null),removed:s}}function k(t){let e=new Map,s=0;for(let o of t){if(o.kind==="import"){let n=`import:${o.source}`;if(e.has(n)){let a=e.get(n),c=[...a.specifiers||[],...o.specifiers||[]],p=Array.from(new Map(c.map((m)=>[m.alias||m.name,m])).values());e.set(n,{...a,specifiers:p}),s++}else e.set(n,o);continue}let i=`${o.kind}:${o.name}`;if(e.has(i))s++;else e.set(i,o)}return{declarations:Array.from(e.values()),removed:s}}function z(t){let e=new Map,s=[];for(let n of t)if(n.kind==="interface"){let a=n.name;if(!e.has(a))e.set(a,[]);e.get(a).push(n)}else s.push(n);let o=0,i=[];for(let[n,a]of e)if(a.length>1){let c=a[0];for(let p=1;p<a.length;p++)c=I(c,a[p]),o++;i.push(c)}else i.push(a[0]);return{declarations:[...s,...i],merged:o}}function w(t){let e=new Map,s=new Set;for(let n of t)if(x(n))e.set(n.name,n.typeAnnotation||""),s.add(n.name);if(e.size===0)return{declarations:t,inlined:0};function o(n){let a=n;for(let[c,p]of e){let m=new RegExp(`\\b${c}\\b`,"g");a=a.replace(m,p)}return a}return{declarations:t.filter((n)=>n.kind!=="type"||!s.has(n.name)).map((n)=>{if(n.typeAnnotation)n={...n,typeAnnotation:o(n.typeAnnotation)};if(n.returnType)n={...n,returnType:o(n.returnType)};if(n.extends)n={...n,extends:o(n.extends)};return n}),inlined:e.size}}function R(t){let e=t.length,s=t.filter((o)=>!v(o));return{declarations:s,removed:e-s.length}}function or(t,e={}){let s=[...t],o={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(e.removeUnusedImports){let{declarations:i,removed:n}=S(s);s=i,o.removedImports=n}if(e.deduplicateDeclarations){let{declarations:i,removed:n}=k(s);s=i,o.removedDeclarations+=n}if(e.mergeInterfaces){let{declarations:i,merged:n}=z(s);s=i,o.mergedInterfaces=n}if(e.removeEmptyInterfaces){let{declarations:i,removed:n}=R(s);s=i,o.removedDeclarations+=n}if(e.inlineSimpleTypes){let{declarations:i,inlined:n}=w(s);s=i,o.inlinedTypes=n}if(e.sortImports)s=T(s);if(e.sortDeclarations)s=A(s);return{declarations:s,result:o}}async function Pi(t,e={}){if(!g(t))throw Error(`File not found: ${t}`);let s=h(t,"utf-8"),o=Buffer.byteLength(s,"utf-8"),i=r(s,t,!e.removeComments),{declarations:n,result:a}=or(i,e),c=C(n,e);if(e.minify)c=ar(c);let p=Buffer.byteLength(c,"utf-8");return a.originalSize=o,a.optimizedSize=p,a.savings=o-p,a.savingsPercent=Math.round(a.savings/o*100),b(t,c),a}function C(t,e){let s=[];for(let o of t){if(!e.removeComments&&o.leadingComments)for(let i of o.leadingComments)s.push(i);if(o.text)s.push(o.text);else s.push(E(o));s.push("")}return s.join(`
|
|
3
3
|
`)}function E(t){let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"import":if(t.isTypeOnly)e.push("import type");else e.push("import");if(t.specifiers&&t.specifiers.length>0){let s=t.specifiers.map((o)=>{let i=o.isType?"type ":"";return o.alias?`${i}${o.name} as ${o.alias}`:`${i}${o.name}`}).join(", ");e.push(`{ ${s} }`)}e.push("from"),e.push(`'${t.source}'`);break;case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${B(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let s of t.members)e.push(` ${s.name}${s.typeAnnotation?`: ${s.typeAnnotation}`:""}`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements?.length)e.push(`implements ${t.implements.join(", ")}`);e.push("{ }");break;case"enum":e.push("declare enum"),e.push(t.name),e.push("{ }");break;default:return t.text||""}return e.join(" ")}function B(t){if(!t)return"";return t.map((e)=>{let s="";if(e.rest)s+="...";if(s+=e.name,e.optional)s+="?";if(e.type)s+=`: ${e.type}`;return s}).join(", ")}function ar(t){return t.replace(/(?<!\/\*\*)\/\/[^\n]*/g,"").replace(/^\s*[\r\n]/gm,"").replace(/ {2,}/g," ").replace(/\s*([{}[\]();,:])\s*/g,"$1").replace(/(\w)(\{)/g,"$1 $2").replace(/(\})([a-z])/gi,"$1 $2").replace(/(export|import|type|interface|class|function|const|let|var|extends|implements|declare)\s*/g,"$1 ").trim()}
|
|
4
4
|
export{or,Pi,ar};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{e,A}from"./chunk-btc6zbyj.js";import{ke}from"./chunk-bkbsg2bv.js";import{s}from"./chunk-
|
|
2
|
+
import{e,A}from"./chunk-btc6zbyj.js";import{ke}from"./chunk-bkbsg2bv.js";import{s}from"./chunk-wma315wm.js";import{existsSync as u,readFileSync as w}from"fs";import{dirname as W,join as d,resolve as v}from"path";async function Kr(i){let c=[],n=new Set;async function t(a,f){let o=v(a);if(n.has(o))return;if(n.add(o),!u(o)){e.warn(`tsconfig not found: ${o}`);return}try{let p=w(o,"utf-8"),r=JSON.parse(ke(p)),l=W(o),g=P(l,f),m=[];if(r.references)for(let y of r.references){let h=v(l,y.path),C=u(d(h,"tsconfig.json"))?d(h,"tsconfig.json"):h;await t(C,g);let G=P(W(C),g);m.push(G)}let j="./src";if(r.compilerOptions?.rootDir)j=r.compilerOptions.rootDir;else if(r.include&&r.include.length>0){if(r.include[0].startsWith("src/"))j="./src"}let k="./dist";if(r.compilerOptions?.outDir)k=r.compilerOptions.outDir;else if(r.compilerOptions?.declarationDir)k=r.compilerOptions.declarationDir;c.push({name:g,root:l,tsconfigPath:o,references:m,config:{root:j,outdir:k}})}catch(p){let r=p instanceof Error?p.message:String(p);e.warn(`Failed to parse ${o}: ${r}`)}}return await t(i),c}function P(i,c){let n=d(i,"package.json");if(u(n))try{let a=w(n,"utf-8"),f=JSON.parse(a);if(f.name)return f.name}catch{}let t=i.split("/").pop()||"unknown";return c?`${c}/${t}`:t}function qr(i){let c=new Map(i.map((o)=>[o.name,o])),n=[],t=new Set,a=new Set;function f(o){if(t.has(o))return;if(a.has(o)){e.warn(`Circular dependency detected involving: ${o}`);return}a.add(o);let p=c.get(o);if(p){for(let r of p.references)f(r);n.push(p)}a.delete(o),t.add(o)}for(let o of i)f(o.name);return n}async function ln(i){let c=Date.now(),n=qr(i.projects);e.info(`Generating declarations for ${n.length} projects...`);let t=[],a=!0;for(let r of n){e.info(`
|
|
3
3
|
[${r.name}] Generating...`);try{let l={...i.sharedConfig,...r.config,cwd:r.root,tsconfigPath:r.tsconfigPath},g=await s(l),m=g.filesFailed===0;if(!m)a=!1;t.push({name:r.name,stats:g,success:m}),e.info(`[${r.name}] Generated ${g.filesGenerated} files`)}catch(l){a=!1;let g=l instanceof Error?l.message:String(l);t.push({name:r.name,stats:{generationMode:r.config?.isolatedDeclarations||i.sharedConfig?.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:g}),e.error(`[${r.name}] Failed: ${g}`)}}let f=Date.now()-c,o=t.filter((r)=>r.success).length,p=t.length-o;if(e.info(`
|
|
4
4
|
--- Workspace Generation Summary ---`),e.info(`Projects processed: ${t.length}`),e.info(`Successful: ${o}`),p>0)e.info(`Failed: ${p}`);return e.info(`Total duration: ${f}ms`),e.info(`------------------------------------
|
|
5
5
|
`),{success:a,projects:t,durationMs:f}}async function to(i,c){if(c?.logLevel)A(c.logLevel);let n=d(i,"tsconfig.json");if(!u(n))throw Error(`Root tsconfig.json not found at: ${n}`);e.info("Discovering workspace projects...");let t=await Kr(n);if(t.length===0)return e.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return e.info(`Found ${t.length} projects`),ln({root:i,projects:t,sharedConfig:c})}async function Jr(i){let c=d(i,"package.json");if(!u(c))return[];try{let n=w(c,"utf-8"),t=JSON.parse(n),a=[];if(Array.isArray(t.workspaces))a=t.workspaces;else if(t.workspaces?.packages)a=t.workspaces.packages;return a}catch{return[]}}async function Yr(i,c){let{Glob:n}=await Promise.resolve(globalThis.Bun),t=[];for(let a of c){let f=new n(a);for await(let o of f.scan({cwd:i,absolute:!0,onlyFiles:!1})){let p=d(o,"package.json");if(u(p))t.push(o)}}return t}async function no(i,c){if(c?.logLevel)A(c.logLevel);let n=await Jr(i);if(n.length===0)return e.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};e.info(`Found workspace patterns: ${n.join(", ")}`);let t=await Yr(i,n);if(t.length===0)return e.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};e.info(`Found ${t.length} workspace packages`);let a=t.map((f)=>{let o=d(f,"tsconfig.json");return{name:P(f),root:f,tsconfigPath:u(o)?o:"",references:[]}});return ln({root:i,projects:a,sharedConfig:c})}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-xmj05115.js";import{be}from"./chunk-vae5wxar.js";import{readFileSync as u}from"fs";import{readFile as p}from"fs/promises";import{resolve as g}from"path";function m(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"").replace(/,\s*([}\]])/g,"$1")}function Ss(t,e){try{return{...JSON.parse(m(u(t,"utf8"))).compilerOptions,...e}}catch(s){throw Error(`Error reading tsconfig.json: ${s instanceof Error?s.message:String(s)}`)}}function f(t,e){let s=e.declarationsOnly?t.filter((o)=>o.endsWith(".d.ts")):t;if(e.include?.length){let o=e.include.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>o.some((i)=>i.test(n)))}if(e.exclude?.length){let o=e.exclude.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>!o.some((i)=>i.test(n)))}return s}async function dt(t,e={}){let s=performance.now(),o=f(t,e),n=[];for(let a of o)try{let c=await p(a,"utf8");for(let l of be(c))n.push({file:a,line:l.line,column:l.column,message:l.message,code:Number(l.code.slice(4)),severity:"error",category:"Error"})}catch(c){n.push({file:a,line:0,column:0,message:c instanceof Error?c.message:String(c),code:1000,severity:"error",category:"Error"})}let i=e.maxErrors?n.slice(0,e.maxErrors):n;return{success:i.length===0,diagnostics:i,errorCount:i.length,warningCount:0,infoCount:0,filesChecked:o,durationMs:performance.now()-s}}function Tr(t,e={}){return dt(t,{...e,declarationsOnly:!0})}async function $s(t){let e=new Map;for(let s of t){let o=await p(s,"utf8").catch(()=>""),n=[];for(let i of r(o,s,!1,!0))if(i.isExported&&i.kind==="function"&&!i.returnType)n.push({line:1,column:1,message:"Exported function requires an explicit return type",declarationName:i.name,missingAnnotation:"return"});e.set(s,{compatible:n.length===0,issues:n})}return e}function d(t,e,s){let o=t.split(`
|
|
3
3
|
`);if(e<1||e>o.length||s<1||s>o[e-1].length+1)return null;let n=s-1;for(let i=0;i<e-1;i++)n+=o[i].length+1;return n}function Ar(t,e,s){try{let o=u(t,"utf8"),n=d(o,e,s);if(n===null)return null;let i=r(o,t,!1).find((a)=>n>=(a.start??0)&&n<=(a.end??o.length));return i?.typeAnnotation??i?.returnType??i?.text??null}catch{return null}}function Es(t,e,s){let o=Ar(t,e,s);return o?{type:o}:null}function ks(t){if(t.success)return`\u2713 Type check passed (${t.filesChecked.length} files checked in ${t.durationMs}ms)`;return["\u2717 Type check failed",` ${t.errorCount} error(s), ${t.warningCount} warning(s)`,...t.diagnostics.map((e)=>`\u2717 ${e.file}:${e.line}:${e.column}
|
|
4
4
|
${e.message}`)].join(`
|
|
5
5
|
`)}function Ts(t){return dt(t.entrypoints.map((e)=>g(t.cwd,e)),{tsconfigPath:t.tsconfigPath,rootDir:t.root})}async function As(t,e){let o=(await Promise.all([dt(t),Tr(e)])).flatMap((n)=>n.diagnostics).map((n)=>({sourceName:n.file,sourceType:n.message,dtsType:"<invalid>"}));return{valid:o.length===0,mismatches:o}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{readFile as M,writeFile as S}from"fs/promises";import{basename as x,dirname as d,relative as b,resolve as C}from"path";function f(e){return`${String.fromCharCode(47,47,35)} sourceMappingURL=${e}`}class rn{file;sourceRoot;sources=[];sourcesContent=[];names=[];mappings=[];sourceIndexMap=new Map;nameIndexMap=new Map;constructor(e){this.file=e.file,this.sourceRoot=e.sourceRoot}addSource(e,n){let r=this.sourceIndexMap.get(e);if(r===void 0)r=this.sources.length,this.sources.push(e),this.sourcesContent.push(n??null),this.sourceIndexMap.set(e,r);else if(n&&!this.sourcesContent[r])this.sourcesContent[r]=n;return r}addName(e){let n=this.nameIndexMap.get(e);if(n===void 0)n=this.names.length,this.names.push(e),this.nameIndexMap.set(e,n);return n}addMapping(e){let n=this.addSource(e.source),r;if(e.name)r=this.addName(e.name);this.mappings.push({generated:e.generated,original:e.original,sourceIndex:n,nameIndex:r})}generate(e=!1){this.mappings.sort((r,t)=>{if(r.generated.line!==t.generated.line)return r.generated.line-t.generated.line;return r.generated.column-t.generated.column});let n={version:3,file:this.file,sources:this.sources,names:this.names,mappings:this.encodeMappings()};if(this.sourceRoot)n.sourceRoot=this.sourceRoot;if(e)n.sourcesContent=this.sourcesContent;return n}encodeMappings(){let e=[],n=0,r=0,t=0,i=0,o=0,s=0,u=[];for(let a of this.mappings){while(n<a.generated.line)e.push(u.join(",")),u=[],n++,r=0;let l=[];if(l.push(a.generated.column-r),r=a.generated.column,l.push(a.sourceIndex-t),t=a.sourceIndex,l.push(a.original.line-i),i=a.original.line,l.push(a.original.column-o),o=a.original.column,a.nameIndex!==void 0)l.push(a.nameIndex-s),s=a.nameIndex;u.push(I(l))}return e.push(u.join(",")),e.join(";")}toString(e=!1){return JSON.stringify(this.generate(e))}toDataUrl(e=!1){let n=this.toString(e);return`data:application/json;charset=utf-8;base64,${Buffer.from(n).toString("base64")}`}toComment(e=!1){return f(this.toDataUrl(e))}}class mt{map;decodedMappings=null;constructor(e){this.map=typeof e==="string"?JSON.parse(e):e}originalPositionFor(e){let n=this.getMappings(),r=0,t=n.length-1,i=null;while(r<=t){let o=Math.floor((r+t)/2),s=n[o];if(s.generated.line===e.line)if(s.generated.column===e.column){i=s;break}else if(s.generated.column<e.column)i=s,r=o+1;else t=o-1;else if(s.generated.line<e.line)r=o+1;else t=o-1}if(!i)return{source:null,line:null,column:null,name:null};return{source:this.map.sources[i.sourceIndex]||null,line:i.original.line,column:i.original.column,name:i.nameIndex!==void 0?this.map.names[i.nameIndex]:null}}generatedPositionFor(e){let n=this.map.sources.indexOf(e.source);if(n===-1)return null;let r=this.getMappings();for(let t of r)if(t.sourceIndex===n&&t.original.line===e.line&&t.original.column<=e.column)return t.generated;return null}getMappings(){if(!this.decodedMappings)this.decodedMappings=v(this.map.mappings);return this.decodedMappings}sourceContentFor(e){let n=this.map.sources.indexOf(e);if(n===-1||!this.map.sourcesContent)return null;return this.map.sourcesContent[n]}}function I(e){return e.map(L).join("")}function L(e){let o="",s=e<0?-e<<1|1:e<<1;do{let u=s&31;if(s>>>=5,s>0)u|=32;o+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u]}while(s>0);return o}function v(e){let n=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,i=0,o=0,s=0,u=0,a=0,l=e.split(";");for(let g of l){if(i=0,g){let h=g.split(",");for(let p of h){if(!p)continue;let c=N(p,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");if(c.length>=1)i+=c[0];if(c.length>=4){o+=c[1],s+=c[2],u+=c[3];let m={generated:{line:t,column:i},original:{line:s,column:u},sourceIndex:o};if(c.length>=5)a+=c[4],m.nameIndex=a;n.push(m)}}}t++}return n}function N(e,n){let t=[],i=0,o=0;for(let s of e){let u=n.indexOf(s);if(u===-1)continue;let a=u&32;if(o+=(u&31)<<i,a)i+=5;else{let l=o&1;o>>=1,t.push(l?-o:o),o=0,i=0}}return t}function Ns(e){let n=new rn({file:x(e.generatedFile),sourceRoot:e.sourceRoot}),r=b(d(e.generatedFile),e.sourceFile);n.addSource(r,e.sourceContent);for(let t of e.mappings)n.addMapping({generated:{line:t.generatedLine,column:t.generatedColumn},original:{line:t.originalLine,column:t.originalColumn},source:r,name:t.name});return n}function Bs(e,n){return`${e}
|
|
3
3
|
${f(n)}`}function Ws(e,n,r=!1){return`${e}
|
|
4
|
-
${n.toComment(r)}`}async function
|
|
4
|
+
${n.toComment(r)}`}async function _s(e,n,r=!1){await S(e,n.toString(r))}async function jr(e){let n=await M(e,"utf-8");return new mt(n)}async function js(e,n){let r=e.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if(r){let i=r[1],o=Buffer.from(i,"base64").toString("utf-8");return new mt(o)}let t=e.match(/\/\/# sourceMappingURL=(.+)$/);if(t){let i=C(d(n),t[1].trim());try{return await jr(i)}catch{return null}}return null}function Gs(e,n){let r=e,t=n,i=r.split(`
|
|
5
5
|
`),o=[],s=0,u=0;for(let a of t){while(s+i[u].length+1<=a.generatedStart&&u<i.length-1)s+=i[u].length+1,u++;let l=a.generatedStart-s;o.push({generatedLine:u,generatedColumn:Math.max(0,l),originalLine:a.originalLine,originalColumn:a.originalColumn,name:a.name})}return o}
|
|
6
|
-
export{rn,mt,Ns,Bs,Ws,
|
|
6
|
+
export{rn,mt,Ns,Bs,Ws,_s,jr,js,Gs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-xmj05115.js";import{readFile as D}from"fs/promises";import{dirname as x,relative as g,resolve as C}from"path";async function Cr(s,i={}){let e=new Map,n=i.rootDir||process.cwd(),t=[];for(let o of s){if(i.ignore?.some((p)=>M(o,p)))continue;if(!i.includeNodeModules&&o.includes("node_modules"))continue;t.push(o)}let c=await Promise.all(t.map((o)=>b(o,n)));for(let o=0;o<t.length;o++){let p=c[o];if(p)e.set(t[o],p)}for(let[o,p]of e)for(let a of p.dependencies){let d=e.get(a);if(d)d.dependents.add(o)}return e}async function b(s,i){try{let e=await D(s,"utf-8"),n={path:s,exports:new Set,imports:new Map,dependencies:new Set,dependents:new Set};for(let t of r(e,s,!1)){if(t.isExported&&t.name)n.exports.add(t.isTypeOnly||t.kind==="type"||t.kind==="interface"?"type":t.name);if(!t.source)continue;let c=w(t.source,s,i);if(!c)continue;if(n.dependencies.add(c),t.kind==="import")for(let o of t.specifiers??[])n.imports.set(t.isTypeOnly||o.isType?`type ${o.alias??o.name}`:o.alias??o.name,c)}return n}catch{return null}}function w(s,i,e){if(!s.startsWith(".")&&!s.startsWith("/"))return null;let n=x(i),t=C(n,s);if(t.includes("node_modules"))return null;if(t.endsWith(".ts")||t.endsWith(".tsx"))return t.replace(/\.tsx?$/,".ts");return`${t}.ts`}function M(s,i){let e=i.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(e).test(s)}function vr(s,i={}){let e=[],n=new Set,t=new Set,c=[],o=new Map,p=i.maxDepth||100;function a(d,y){if(y>p)return;if(t.has(d)){let u=o.get(d)??c.indexOf(d),l=c.slice(u);l.push(d);let h=S(l,s),f=z(l,s);if(!i.typesOnly||f)e.push({chain:l,symbols:h,severity:f?"error":"warning",reason:f?"Type-level circular dependency can cause compilation issues":"Value-level circular dependency may cause runtime issues"});return}if(n.has(d))return;let m=s.get(d);if(!m)return;t.add(d),o.set(d,c.length),c.push(d);for(let u of m.dependencies)a(u,y+1);t.delete(d),c.pop(),o.delete(d),n.add(d)}for(let d of s.keys())if(!n.has(d))a(d,0);return N(e)}function S(s,i){let e=[];for(let n=0;n<s.length-1;n++){let t=i.get(s[n]),c=s[n+1];if(t){for(let[o,p]of t.imports)if(p===c)e.push(o)}}return[...new Set(e)]}function z(s,i){return s.some((e)=>e.endsWith(".d.ts")||i.get(e)?.exports.has("type")||[...i.get(e)?.imports.keys()||[]].some((n)=>n.startsWith("type ")||n==="type"))}function N(s){let i=new Set,e=[];for(let n of s){let t=v(n.chain),c=t.join(" -> ");if(!i.has(c))i.add(c),e.push({...n,chain:t})}return e}function v(s){if(s.length<=1)return s;let i=s.slice(0,-1),e=i;for(let n=1;n<i.length;n++){let t=[...i.slice(n),...i.slice(0,n)];if(t.join("")<e.join(""))e=t}return[...e,e[0]]}async function ds(s,i={}){let e=Date.now(),n=await Cr(s,i),t=vr(n,i);return{hasCircular:t.length>0,cycles:t,graph:n,filesAnalyzed:s,durationMs:Date.now()-e}}function ps(s,i){let e=[];if(!s.hasCircular)return e.push(`\u2713 No circular dependencies found (${s.filesAnalyzed.length} files analyzed in ${s.durationMs}ms)`),e.join(`
|
|
3
3
|
`);e.push(`\u2717 Found ${s.cycles.length} circular dependency chain(s)`),e.push("");for(let n of s.cycles){let t=n.severity==="error"?"\uD83D\uDD34":"\uD83D\uDFE1";e.push(`${t} ${n.severity.toUpperCase()}: Circular dependency`);let c=n.chain.map((o)=>i?g(i,o):o);if(e.push(` ${c.join(" \u2192 ")}`),n.symbols.length>0)e.push(` Symbols: ${n.symbols.join(", ")}`);e.push(` ${n.reason}`),e.push("")}return e.push(`Analyzed ${s.filesAnalyzed.length} files in ${s.durationMs}ms`),e.join(`
|
|
4
4
|
`)}function ms(s){let i=0,e={file:"",count:0},n={file:"",count:0},t=[];for(let[c,o]of s){let p=o.dependencies.size;if(i+=p,p>e.count)e={file:c,count:p};if(p===0&&o.dependents.size===0)t.push(c);if(o.dependents.size>n.count)n={file:c,count:o.dependents.size}}return{totalFiles:s.size,totalDependencies:i,avgDependencies:s.size>0?i/s.size:0,maxDependencies:e,isolatedFiles:t,mostDepended:n}}function gs(s,i){let e=new Set,n=[s];while(n.length>0){let t=n.shift(),c=i.get(t);if(c){for(let o of c.dependents)if(!e.has(o))e.add(o),n.push(o)}}return e}function hs(s,i){let e=new Set,n=[s];while(n.length>0){let t=n.shift(),c=i.get(t);if(c){for(let o of c.dependencies)if(!e.has(o))e.add(o),n.push(o)}}return e}function ys(s,i){let e=["digraph dependencies {"," rankdir=LR;"," node [shape=box];",""];for(let[n,t]of s){let c=i?g(i,n):n,o=n.replace(/[^a-z0-9]/gi,"_");e.push(` ${o} [label="${c}"];`);for(let p of t.dependencies){let a=p.replace(/[^a-z0-9]/gi,"_");e.push(` ${o} -> ${a};`)}}return e.push("}"),e.join(`
|
|
5
5
|
`)}function bs(s,i){let e=[];for(let[n,t]of s){let c=i?g(i,n):n;e.push({id:n,path:c,exports:[...t.exports],imports:Object.fromEntries(t.imports),dependencies:[...t.dependencies],dependents:[...t.dependents]})}return JSON.stringify({nodes:e},null,2)}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{E}from"./chunk-60wrxcjt.js";import{
|
|
2
|
+
import{E}from"./chunk-60wrxcjt.js";import{J}from"./chunk-13tjnp25.js";import{q,he}from"./chunk-2ck79rny.js";import{An}from"./chunk-rajfxka5.js";import{spawn as N}from"child_process";var x=new Set(["cwd","root","outdir","entrypoints","include","exclude","autoIncludeReExports","outputStructure","tsconfigPath","moduleSpecifierMode","keepComments","isolatedDeclarations","clean","lineEnding"]);function y(l,f,d,n,u){let s=u.signal;s?.throwIfAborted();let c=u.timeoutMs??30000;if(!Number.isSafeInteger(c)||c<=0||c>2147483647)throw RangeError("Native project timeoutMs must be an integer between 1 and 2147483647");return new Promise((g,r)=>{let o=N(l,f,{cwd:n,stdio:["pipe","pipe","pipe"],windowsHide:!0}),i=[],a=[],e,h,v=!1,p=(t)=>{e??=t,o.kill()},m=()=>p(s?.reason instanceof Error?s.reason:Error("Native declaration project aborted",{cause:s?.reason})),j=setTimeout(()=>p(Error(`Native declaration project exceeded ${c}ms`)),c),b=(t,w)=>{if(v)return;if(v=!0,clearTimeout(j),s?.removeEventListener("abort",m),t)r(t);else g(w)};if(o.once("error",(t)=>b(t)),o.stdout.on("data",(t)=>i.push(Buffer.from(t))),o.stderr.on("data",(t)=>a.push(Buffer.from(t))),o.stdout.once("error",p),o.stderr.once("error",p),o.stdin.once("error",(t)=>{h??=t}),o.once("close",(t,w)=>{if(t!==0&&!e)e=Error(`Native declaration project failed (${w??t}): ${Buffer.concat(a).toString("utf8")}`);b(e??h,Buffer.concat(i).toString("utf8"))}),s?.addEventListener("abort",m,{once:!0}),s?.aborted)m();o.stdin.end(Buffer.from(d,"utf8"))})}async function Di(l,f={},d={}){if(!l||l.includes("\x00"))throw Error("A native zig-dtsx executable is required");for(let i of Object.keys(f))if(!x.has(i))throw Error(`Native declaration project does not support option: ${i}`);d.signal?.throwIfAborted();let n={...E,...f};if(await q(n),n.isolatedDeclarations===void 0)n.isolatedDeclarations=await J(n);let u=await An(n),s=["--batch"];if(!n.keepComments)s.push("--no-comments");if(n.isolatedDeclarations)s.push("--isolated-declarations");let c=JSON.stringify({protocol:"zig-dtsx-project",version:1,files:u.files.map((i)=>({source:i.source,context:i.context}))}),g=await y(l,s,c,n.cwd,d),r;try{r=JSON.parse(g)}catch(i){throw Error("Native executable did not return a valid zig-dtsx project protocol response",{cause:i})}if(!r||typeof r!=="object"||!("protocol"in r)||r.protocol!=="zig-dtsx-project"||!("version"in r)||r.version!==1||!("files"in r)||!Array.isArray(r.files)||r.files.length!==u.files.length)throw Error("Native executable returned an unsupported or incomplete project response");let o=new Map;for(let[i,a]of u.files.entries()){let e=r.files[i];if(!e||typeof e!=="object"||!("sourceFile"in e)||e.sourceFile!==a.sourceFile||!("outputFile"in e)||e.outputFile!==a.outputFile||!("sourceHash"in e)||e.sourceHash!==a.context.sourceHash||!("content"in e)||typeof e.content!=="string")throw Error(`Native executable returned a mismatched project result for ${a.sourceFile}`);o.set(a.outputFile,{content:e.content,lineEnding:n.lineEnding})}return d.signal?.throwIfAborted(),await he(n,o),Object.freeze({filesGenerated:o.size,outputFiles:Object.freeze([...o.keys()])})}
|
|
3
3
|
export{Di};
|
|
@@ -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.41",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/*"}},k="./dist/index.js",l="./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","@dtsx/bun":"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:k,types:l,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,k as module,e as name,f as overrides,r as private,o as repository,h as scripts,i as type,l as types,n as version,y as workspaces};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
2
|
+
import{s}from"./chunk-wma315wm.js";function me(a={}){let{onStart:d=!1,onEnd:l=!0,onGenerated:u,onError:i,...n}=a,e=async()=>{try{let r=await s(n);u?.(r)}catch(r){let t=r instanceof Error?r:Error(String(r));if(i?.(t),!i)console.error("[dtsx] Generation failed:",t.message)}};return{name:"dtsx",setup(r){let t=r.initialOptions;if(!n.entrypoints&&t.entryPoints)if(Array.isArray(t.entryPoints))n.entrypoints=t.entryPoints;else n.entrypoints=Object.values(t.entryPoints);if(!n.outdir){if(t.outdir)n.outdir=t.outdir;else if(t.outfile){let o=t.outfile.lastIndexOf("/");if(o!==-1)n.outdir=t.outfile.substring(0,o)}}if(d)r.onStart(async()=>{await e()});if(l)r.onEnd(async(o)=>{if(o.errors.length===0)await e()})}}}var Aa=me,sr=me,Pa=me;
|
|
3
3
|
export{me,Aa,sr,Pa};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Le}from"./chunk-
|
|
2
|
+
import{Le}from"./chunk-ywv56grs.js";import{T}from"./chunk-epjq1edf.js";import{b}from"./chunk-a2dn9j88.js";function kn(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=Je(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 Je(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&&Le(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
|
|
3
3
|
export{kn,Je};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
3
|
-
export{Be,
|
|
2
|
+
import{s}from"./chunk-wma315wm.js";function Be(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 wa=Be,Ca=Be;
|
|
3
|
+
export{Be,wa,Ca};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Se}from"./chunk-
|
|
2
|
+
import{Se}from"./chunk-01jwgm2m.js";import{e}from"./chunk-btc6zbyj.js";import{Ee,U}from"./chunk-7khy25x0.js";import{existsSync as x}from"fs";import{basename as D,dirname as M,extname as R,isAbsolute as v,relative as p,resolve as m}from"path";var{Glob:j}=globalThis.Bun;async function Ce(r,o){let s=await F(r);C(r,s);let n=s.slice(),a=await(o?o():Ee(r)),t=null;if(r.autoIncludeReExports!==!1&&n.length>0){t=await U(n,{includeImports:!0,resolveSpecifier:a});let l=m(r.cwd,r.root),u=r.exclude||[],f=[];for(let c of t.reachable){if(n.includes(c))continue;if(!b(c))continue;if(c.endsWith(".d.ts"))continue;if(c.includes("node_modules"))continue;let E=r.outputStructure==="flat"&&s.some((O)=>a.isPackageLocal?.(O,c));if(!S(c,l)&&!E){e.warn(`Skipping auto-included source outside root: ${p(r.cwd,c)}`);continue}if(Z(c,u,l))continue;f.push(c)}if(f.length>0)n=[...n,...f],e.debug(`Auto-included ${f.length} file(s) reached via relative re-exports`)}let i=N(n,r),d=t??await U(n,{includeImports:!0,resolveSpecifier:a}),g=await Se([...d.sources.keys()],a,r.isolatedDeclarations??!1,d.sources),h=new Set(n);for(let[l,u]of g){if(!h.has(l))continue;for(let f of u){let c=a(f,l).resolved;if(c&&!h.has(c))throw Error(`Module augmentation import ${JSON.stringify(f)} from ${l} requires a source not emitted by this package build: ${c}`)}}let y=[...g].map(([l,u])=>[l,[...u].sort()]).sort(([l],[u])=>l.localeCompare(u));return Object.freeze({entryFiles:Object.freeze(s),files:Object.freeze(n),outputBySource:i,resolver:a,reachability:t,augmentationImports:g,getResolutionFingerprint:()=>JSON.stringify({resolution:a.cacheKey?.(n),augmentations:y})})}var P=50,w=new Map;function k(r){let o=w.get(r);if(!o){if(o=new j(r),w.set(r,o),w.size>P){let s=w.keys().next().value;if(s!==void 0)w.delete(s)}}return o}function Z(r,o,s){if(!o||o.length===0)return!1;let n=p(s,r);for(let a of o){let t=k(a);if(t.match(n)||t.match(r))return!0}return!1}var G=/[*?[\]{}!]/;function C(r,o){let s=m(r.cwd,r.root),n=` root: ${s}
|
|
3
3
|
entrypoints: ${r.entrypoints.map((t)=>JSON.stringify(t)).join(", ")||"(none)"}
|
|
4
4
|
`+(r.exclude?.length?` exclude: ${r.exclude.map((t)=>JSON.stringify(t)).join(", ")}
|
|
5
5
|
`:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(o.length===0){if(r.entrypoints.filter((i)=>v(i)&&x(i)&&!S(i,s)).length===r.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
|
|
6
6
|
${n}`)}let a=r.entrypoints.filter((t)=>{if(G.test(t))return!1;return!x(v(t)?t:m(s,t))});if(a.length>0)throw Error(`Entrypoint${a.length>1?"s":""} not found: ${a.map((t)=>JSON.stringify(t)).join(", ")}
|
|
7
|
-
${n}`)}async function F(r){let o=[],s=m(r.cwd,r.root),n=r.exclude||[],a=[...r.entrypoints,...r.include??[]];for(let t of a)if(v(t)&&b(t)){if(!t.includes("node_modules")){if(!S(t,s)&&r.outputStructure!=="flat")e.warn(`Skipping entrypoint outside root: ${p(r.cwd,t)}`);else if(!
|
|
8
|
-
export{Ce,
|
|
7
|
+
${n}`)}async function F(r){let o=[],s=m(r.cwd,r.root),n=r.exclude||[],a=[...r.entrypoints,...r.include??[]];for(let t of a)if(v(t)&&b(t)){if(!t.includes("node_modules")){if(!S(t,s)&&r.outputStructure!=="flat")e.warn(`Skipping entrypoint outside root: ${p(r.cwd,t)}`);else if(!Z(t,n,s))o.push(t)}}else{let i=new j(t);for await(let d of i.scan({cwd:s,absolute:!0,onlyFiles:!0}))if(b(d)&&!d.includes("node_modules")){if(!Z(d,n,s))o.push(d)}}return[...new Set(o.map((t)=>m(t)))].sort()}function S(r,o){let s=p(o,r);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!v(s)}function N(r,o){let s=new Map,n=new Map;for(let a of r){let t=V(a,o),i=s.get(t);if(i&&i!==a)throw Error(`Output path collision: ${p(o.cwd,i)} and ${p(o.cwd,a)} both emit ${p(o.cwd,t)}`);s.set(t,a),n.set(a,t)}return n}function b(r){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(r)&&!/\.d\.(?:ts|mts|cts)$/.test(r)}function V(r,o){let s=m(o.cwd,o.root),n=p(s,r),a=/\.d\.(?:ts|mts|cts)$/.test(n)?n:n.replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(t)=>{if(t===".mts"||t===".mjs")return".d.mts";if(t===".cts"||t===".cjs")return".d.cts";return".d.ts"});if(o.outputStructure==="mirror")return m(o.cwd,o.outdir,a);else{let t=D(a);return m(o.cwd,o.outdir,t)}}function Yo(r,o,s=""){let n=p(M(r),o).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),s)n+=s;if(!n.startsWith("."))n=`./${n}`;return n}function ve(r,o,s,n){let a=V(r,o);return(t)=>{let i=s(t,r);if(!i.isRelative||!i.resolved)return{kind:"unchanged",reason:i.isRelative?"unresolved":"external",specifier:t,emittedSpecifier:t};if(/\.d\.(?:ts|mts|cts)$/.test(i.resolved)){if(o.moduleSpecifierMode!=="node")return{kind:"unchanged",reason:"preserved-declaration",specifier:t,emittedSpecifier:t};if(n&&!n.has(i.resolved))throw Error(`Local declaration ${JSON.stringify(t)} from ${r} targets an authored declaration not emitted by this package build: ${i.resolved}. Declaration-only dependencies must be delivered with the package before this importer can be emitted.`)}if(i.isAlias&&n&&!n.has(i.resolved))throw Error(`Local alias ${JSON.stringify(t)} from ${r} targets a declaration excluded from this package build: ${i.resolved}`);if(n&&!n.has(i.resolved)&&Z(i.resolved,o.exclude??[],m(o.cwd,o.root)))throw Error(`Local reference ${JSON.stringify(t)} from ${r} targets a source excluded from this package build: ${i.resolved}`);let d=i.isAlias?i.suffix??"":t.match(/[?#].*$/)?.[0]??"",g=d?t.slice(0,-d.length):t,h=R(g),y=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(h)?h:"";if(!y&&o.moduleSpecifierMode==="node"){let u=R(i.resolved);y=u===".mts"||u===".mjs"?".mjs":u===".cts"||u===".cjs"?".cjs":".js"}let l=V(i.resolved,o);return{kind:"local",specifier:t,resolvedSource:i.resolved,declarationOutput:l,emittedSpecifier:Yo(a,l,y)+d}}}
|
|
8
|
+
export{Ce,Z,S,V,Yo,ve};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{f,ue}from"./chunk-a3apthex.js";import{Ft,Nt,n,Me,
|
|
2
|
+
import{f,ue}from"./chunk-a3apthex.js";import{Ft,Nt,n,Me,j}from"./chunk-8g4wk8mm.js";function g(t){if(t.includes(`
|
|
3
3
|
`))return`/**
|
|
4
4
|
* ${t}
|
|
5
5
|
*/
|
|
6
6
|
`;return`/** ${t} */
|
|
7
|
-
`}function D(t){let o=t.indexOf("{");if(o===-1)return-1;let s=t.indexOf("<");if(s===-1||s>o)return o;let e=0,r=!1,a="";for(let i=0;i<t.length;i++){let l=t[i],u=i>0?t[i-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,a=l;else if(r&&l===a&&u!=="\\")r=!1;if(!r){if(l==="<")e++;else if(l===">")e--;else if(l==="{"&&e===0)return i}}return-1}function
|
|
7
|
+
`}function D(t){let o=t.indexOf("{");if(o===-1)return-1;let s=t.indexOf("<");if(s===-1||s>o)return o;let e=0,r=!1,a="";for(let i=0;i<t.length;i++){let l=t[i],u=i>0?t[i-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,a=l;else if(r&&l===a&&u!=="\\")r=!1;if(!r){if(l==="<")e++;else if(l===">")e--;else if(l==="{"&&e===0)return i}}return-1}function re(t,o=!0){return f(t.leadingComments,o)+t.text}function h(t,o=!0){if(t.inferenceError)throw Object.assign(Error(`Cannot infer alias '${t.name}': unsupported source value flow`),{code:t.inferenceError});let s=f(t.leadingComments,o);if(!t.typeAnnotation&&t.inferredType)return s+t.text;if(t.typeAnnotation&&!t.value)return s+t.text;let e="";if(t.isExported)e+="export ";e+="declare ";let r=t.modifiers?.[0]||"const";e+=`${r} `,e+=t.name;let{typeAnnotation:a,value:i}=t,l=!a&&i?j(i):null;if(l)a=l;else if(!a&&i&&i.trim().endsWith("as const"))a=n(i,!0,!1,0,t.computedKeyConstants);else if(!a&&i&&r==="const"){let c=i.trim(),m=c.startsWith("{")||c.startsWith("[");if(m)Ft();a=n(i,!m,!1,0,t.computedKeyConstants)}else if(!a&&i)a=n(i,r==="const",!1,0,t.computedKeyConstants);if(!a)a="unknown";let u="";if(o&&i&&!t.typeAnnotation&&!i.trim().endsWith("as const")){let c=i.trim();if(r!=="const"){if((a==="string"||a==="number"||a==="boolean")&&c.length>0)u=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let m=Nt();if(m)if(m.includes(`
|
|
8
8
|
`))u=`@defaultValue
|
|
9
9
|
* \`\`\`ts
|
|
10
10
|
${m.split(`
|
|
@@ -25,5 +25,5 @@ ${x.split(`
|
|
|
25
25
|
* ${c.replace(/^\/\/\s*/,"")}
|
|
26
26
|
* ${u}
|
|
27
27
|
*/
|
|
28
|
-
${e}`}if(u)return`${g(u)}${e}`;return s+e}function
|
|
29
|
-
export{
|
|
28
|
+
${e}`}if(u)return`${g(u)}${e}`;return s+e}function ie(t,o=!0){let s=f(t.leadingComments,o),e=t.text;if(e.startsWith("export declare interface")||e.startsWith("declare interface"))return s+e;let r="";if(t.isExported)r+="export ";if(r+="declare interface ",r+=t.name,t.generics)r+=t.generics;if(t.extends)r+=` extends ${t.extends}`;let a=D(t.text);if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}function se(t,o=!0){let s=f(t.leadingComments,o);if(t.text.includes("{")&&t.text.includes("}")&&t.text.includes("from"))return s+t.text;let e="";if(t.isExported)e+="export ";if(!t.isExported&&!t.text.includes(" from "))e+="declare ";let r=t.text.indexOf("type ");if(r!==-1){let i=t.text.slice(r),l=i.length;while(l>0&&(i.charCodeAt(l-1)===59||i.charCodeAt(l-1)===32||i.charCodeAt(l-1)===10||i.charCodeAt(l-1)===13))l--;if(l<i.length)i=i.slice(0,l);e+=i}else{if(e+=`type ${t.name}`,t.generics)e+=t.generics;e+=" = any"}let a=e.trimEnd();if(!a.endsWith(";")&&!a.endsWith("}"))e+=";";return s+e}function oe(t,o=!0){return f(t.leadingComments,o)+t.text}function ae(t,o=!0){let s=f(t.leadingComments,o),e="";if(t.isExported)e+="export ";if(e+="declare ",t.modifiers?.includes("const"))e+="const ";e+="enum ",e+=t.name;let r=t.text.indexOf("{");if(r!==-1)e+=` ${t.text.slice(r)}`;else e+=" {}";return s+e}function Wn(t){let o=t.text.trim(),s=o.length;while(s>0&&o.charCodeAt(s-1)===59)s--;if(s<o.length)o=o.slice(0,s);return o+=";",o}function _n(t,o=!0){return f(t.leadingComments,o)+t.text.trim()}function ce(t,o=!0){let s=f(t.leadingComments,o);if(t.text.startsWith("declare global"))return s+t.text;if(t.source||(t.name.startsWith('"')||t.name.startsWith("'")||t.name.startsWith("`"))){let i="declare module ";i+=t.name;let l=t.text.indexOf("{");if(l!==-1)i+=` ${t.text.slice(l)}`;else i+=" {}";return s+i}let r="";if(t.isExported)r+="export ";if(!t.modifiers?.includes("declare"))r+="declare ";r+="namespace ",r+=t.name;let a=t.text.indexOf("{");if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}
|
|
29
|
+
export{re,h,ie,se,oe,ae,Wn,_n,ce};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{watch as z}from"fs";import{readdir as O,stat as U}from"fs/promises";import{join as S,relative as E}from"path";function Ti(e,i){let{root:s,include:u=["**/*.ts","**/*.tsx","**/*.vue","**/*.stx"],exclude:v=["**/node_modules/**","**/*.d.ts","**/dist/**"],debounce:f=100,initialBuild:a=!0,clearScreen:D=!1,onChange:T,onBuildStart:w,onBuildComplete:B,onError:W}=e,P=[],g=new Set,h=!1,d=new Map,c=null,y=!1;function A(o){let r=E(s,o);for(let n of v)if(p(r,n))return!1;for(let n of u)if(p(r,n))return!0;return!1}function p(o,r){let n=r.replace(/\./g,"\\.").replace(/\*\*/g,"{{DOUBLESTAR}}").replace(/\*/g,"[^/]*").replace(/\{\{DOUBLESTAR\}\}/g,".*").replace(/\?/g,".");return new RegExp(`^${n}$`).test(o.replace(/\\/g,"/"))}async function F(){if(y||d.size===0)return;y=!0;let o=Array.from(d.values());d.clear();try{for(let t of o)await T?.(t);if(D)console.clear();await w?.();let r=o.filter((t)=>t.type!=="unlink").map((t)=>t.path),n=await i(r.length>0?r:void 0);await B?.(n)}catch(r){await W?.(r)}finally{if(y=!1,d.size>0)C()}}function C(){if(c)clearTimeout(c);c=setTimeout(()=>{c=null,F()},f)}function k(o,r,n){if(!r||!h)return;let t=S(n,r);if(!A(t))return;let l={type:o==="rename"?"add":"change",path:t,relativePath:E(s,t)};U(t).then(()=>{g.add(t)}).catch(()=>{l.type="unlink",g.delete(t)}).finally(()=>{d.set(t,l),C()})}async function b(o){let r=[o];try{let n=await O(o,{withFileTypes:!0});for(let t of n)if(t.isDirectory()){let l=S(o,t.name),x=E(s,l),R=!1;for(let m of v)if(p(x,m)||p(`${x}/`,m)){R=!0;break}if(!R){let m=await b(l);r.push(...m)}}}catch{}return r}async function G(){if(h)return;h=!0;let o=await b(s);for(let r of o)try{let n=z(r,{persistent:!0},(t,l)=>{k(t,l,r)});n.on("error",(t)=>{W?.(t)}),P.push(n)}catch(n){await W?.(n)}if(a){await w?.();let r=await i();await B?.(r)}}function L(){if(h=!1,c)clearTimeout(c),c=null;for(let o of P)o.close();P.length=0,g.clear(),d.clear()}async function j(){await w?.();let o=await i();return await B?.(o),o}return{start:G,stop:L,rebuild:j,isWatching:()=>h,getWatchedFiles:()=>Array.from(g)}}async function ba(e,i){let s=async(v)=>{let f=Date.now();try{let a=await i(e);return{success:a.errors.length===0,duration:Date.now()-f,filesProcessed:a.filesProcessed,errors:a.errors}}catch(a){return{success:!1,duration:Date.now()-f,filesProcessed:0,errors:[a.message]}}},u=Ti({root:e.root||e.cwd||process.cwd(),include:e.include,exclude:e.exclude,debounce:e.debounce,initialBuild:e.initialBuild,clearScreen:e.clearScreen,onChange:e.onChange,onBuildStart:e.onBuildStart,onBuildComplete:e.onBuildComplete,onError:e.onError},s);return await u.start(),u}function Ai(e){let i=e.success?"\u2713":"\u2717",s=`${e.duration}ms`;if(e.success)return`${i} Built ${e.filesProcessed} file(s) in ${s}`;else return`${i} Build failed in ${s}
|
|
3
3
|
${e.errors.map((u)=>` - ${u}`).join(`
|
|
4
|
-
`)}`}function
|
|
4
|
+
`)}`}function xa(){return{onChange:(e)=>{let i=e.type==="add"?"+":e.type==="unlink"?"-":"~";console.log(`[${i}] ${e.relativePath}`)},onBuildStart:()=>{console.log(`
|
|
5
5
|
Rebuilding...`)},onBuildComplete:(e)=>{console.log(Ai(e))},onError:(e)=>{console.error(`Error: ${e.message}`)}}}
|
|
6
|
-
export{Ti,ba,Ai,
|
|
6
|
+
export{Ti,ba,Ai,xa};
|