@dtsx/dtsx 0.11.50 → 0.11.51
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-ef428m5g.js → chunk-19626hwq.js} +1 -1
- package/dist/{chunk-j4t8d6p0.js → chunk-1jmwmc2a.js} +1 -1
- package/dist/{chunk-vrvzmysf.js → chunk-2q641ekp.js} +1 -1
- package/dist/{chunk-xawz3n8s.js → chunk-3e6q952c.js} +1 -1
- package/dist/{chunk-9xep96k0.js → chunk-3z75j224.js} +1 -1
- package/dist/{chunk-txf9rw55.js → chunk-4nrrjn7g.js} +1 -1
- package/dist/{chunk-vvy85nm6.js → chunk-4sasxrdr.js} +1 -1
- package/dist/{chunk-zrmg0q1q.js → chunk-4xvx77zs.js} +1 -1
- package/dist/{chunk-bvtzfznj.js → chunk-5mh2gqd4.js} +1 -1
- package/dist/{chunk-tgfj7kre.js → chunk-5ym0xgg0.js} +1 -1
- package/dist/{chunk-5zzvxzey.js → chunk-6e5dyfx2.js} +1 -1
- package/dist/{chunk-6exq13f9.js → chunk-6ekgn7sc.js} +1 -1
- package/dist/{chunk-25vpx6mq.js → chunk-7ryea8wn.js} +1 -1
- package/dist/{chunk-aj2n4x1b.js → chunk-7xgwvv94.js} +1 -1
- package/dist/{chunk-yapz0de1.js → chunk-9b0jah2a.js} +1 -1
- package/dist/{chunk-s6tmjqsc.js → chunk-9wxhpnya.js} +1 -1
- package/dist/{chunk-c6bfdmfy.js → chunk-a04yhmwb.js} +1 -1
- package/dist/{chunk-2t2xwzj5.js → chunk-anr9ncep.js} +1 -1
- package/dist/{chunk-skydb7vs.js → chunk-b7g1pyea.js} +1 -1
- package/dist/{chunk-bkwzva5v.js → chunk-bj3r4j0a.js} +1 -1
- package/dist/{chunk-nh71w1ta.js → chunk-bkrftw1s.js} +1 -1
- package/dist/chunk-cgqg1br8.js +5 -0
- package/dist/{chunk-gcgtyjyj.js → chunk-cq5zpg9c.js} +1 -1
- package/dist/{chunk-fp40v5jx.js → chunk-cx4rq49z.js} +1 -1
- package/dist/{chunk-w9jg9761.js → chunk-cyzr3xat.js} +1 -1
- package/dist/{chunk-p4dpq81g.js → chunk-czgjmefa.js} +1 -1
- package/dist/{chunk-n833rcmj.js → chunk-dc0059dr.js} +1 -1
- package/dist/{chunk-a5tvswq1.js → chunk-dq0nmept.js} +1 -1
- package/dist/{chunk-4p9dw996.js → chunk-e4f5kxrh.js} +1 -1
- package/dist/{chunk-0rk4cvt6.js → chunk-fjkswqq2.js} +1 -1
- package/dist/{chunk-h12vphnz.js → chunk-jkeqyj50.js} +1 -1
- package/dist/{chunk-258337ef.js → chunk-kf4sza0n.js} +1 -1
- package/dist/{chunk-ka9qyjzn.js → chunk-m8w98p7p.js} +1 -1
- package/dist/{chunk-qx0pxmvs.js → chunk-m9b6cqn7.js} +1 -1
- package/dist/{chunk-1mg4cxd3.js → chunk-n0tw6p7g.js} +1 -1
- package/dist/{chunk-5rrxzd1e.js → chunk-p99myphf.js} +1 -1
- package/dist/{chunk-31rb15pe.js → chunk-r9gdz351.js} +1 -1
- package/dist/{chunk-zrfwvjq8.js → chunk-sbmdk35p.js} +1 -1
- package/dist/{chunk-beg5vxdm.js → chunk-t4cdpfrr.js} +1 -1
- package/dist/{chunk-ntps0jm2.js → chunk-tpjz15nc.js} +1 -1
- package/dist/{chunk-xcfbw2r7.js → chunk-vekg5zy6.js} +1 -1
- package/dist/{chunk-av03sjse.js → chunk-x67zh0tr.js} +1 -1
- package/dist/{chunk-fvr0rwgt.js → chunk-xph91r7p.js} +1 -1
- package/dist/{chunk-r4dq05mh.js → chunk-zbrj37wa.js} +1 -1
- package/dist/{chunk-h3r142dy.js → chunk-zpvcnc7c.js} +1 -1
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.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/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/docs.js +1 -1
- package/dist/src/enum-declarations.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/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/initializer-type-spans.js +1 -1
- package/dist/src/lexical.js +1 -1
- package/dist/src/lsp.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/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/return-type-scope.js +1 -1
- package/dist/src/value-inference.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-gyfbehkf.js +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{e,M}from"./chunk-3mp0jaa7.js";import{Ie}from"./chunk-g9emajpc.js";import{s}from"./chunk-
|
|
2
|
+
import{e,M}from"./chunk-3mp0jaa7.js";import{Ie}from"./chunk-g9emajpc.js";import{s}from"./chunk-4xvx77zs.js";import{existsSync as u,readFileSync as w}from"fs";import{dirname as W,join as d,resolve as v}from"path";async function ei(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(Ie(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 ti(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 yn(i){let c=Date.now(),n=ti(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 lo(i,c){if(c?.logLevel)M(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 ei(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`),yn({root:i,projects:t,sharedConfig:c})}async function ni(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 ri(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 uo(i,c){if(c?.logLevel)M(c.logLevel);let n=await ni(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 ri(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 yn({root:i,projects:a,sharedConfig:c})}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
2
|
+
import{s}from"./chunk-4xvx77zs.js";import w from"process";import{dirname as x,relative as y,resolve as B,sep as l}from"path";function qe(p={}){let{preBuild:c=!1,postBuild:r=!0,onGenerated:n,onError:o,failOnError:E=!0,...e}=p,v=async(i)=>{try{let t=await s(i);n?.(t)}catch(t){let d=t instanceof Error?t:Error(String(t));if(o?.(d),!o)console.error("[dtsx] Generation failed:",d.message);if(E)throw d}};return{name:"dtsx",async setup(i){if(!c&&!r)return;let t=e.cwd||w.cwd(),u=(i.config.entrypoints||[]).map((a)=>B(t,a)),g=e.root||i.config.root||(u.length>0?y(t,G(u))||".":"./src"),f=B(t,g),m=e.entrypoints||u.filter((a)=>a===f||a.startsWith(`${f}${l}`)).map((a)=>y(f,a));await v({...e,cwd:t,root:g,entrypoints:m.length>0?m:["index.ts"],outdir:e.outdir||i.config.outdir||"./dist",moduleSpecifierMode:e.moduleSpecifierMode??(i.config.target==="node"?"node":"preserve")})}}}function G(p){let c=p.map((n)=>x(n).split(l)),r=c[0];for(let n of c.slice(1)){let o=0;while(o<r.length&&o<n.length&&r[o]===n[o])o++;r=r.slice(0,o)}return r.join(l)||l}var Ma=qe,Oa=qe;
|
|
3
3
|
export{qe,Ma,Oa};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,d,E}from"./chunk-
|
|
2
|
+
import{t,d,E}from"./chunk-6ekgn7sc.js";import{S}from"./chunk-r9gdz351.js";function D(n){return typeof n==="string"?E(n,"'"):String(n)}function va(n,y,m=new Map){let o=t(n),e=new Map(m),i=new Map,f=[],c=1,p=0,q=0;for(let r=1;r<o.length;r++){let w=o[r],K=n.slice(w.start,w.end);if(w.kind==="punctuation"&&p===0&&(K===","||K==="}")){let l=o.slice(c,r),a=l[0];if(a){let u=a.kind==="quoted"?d(n.slice(a.start,a.end)):n.slice(a.start,a.end),v=l.findIndex((g)=>g.kind==="punctuation"&&n[g.start]==="="),s=q;if(v>=0){let g=l.slice(v+1),B="",C=l[v].end;for(let x=0;x+2<g.length;x++){let[h,A,M]=g.slice(x,x+3);if(h.kind!=="word"||M.kind!=="word"||n.slice(A.start,A.end)!==".")continue;let b=e.get(`${n.slice(h.start,h.end)}.${n.slice(M.start,M.end)}`);if(b===void 0||typeof b==="object")continue;B+=n.slice(C,h.start)+D(b),C=M.end,x+=2}B+=n.slice(C,l.at(-1).end),s=S(B,e),f.push({start:l[v].start,end:l.at(-1).end,text:s===void 0?"":`= ${D(s)}`})}else if(s!==void 0)f.push({start:a.end,end:a.end,text:` = ${D(s)}`});if(q=typeof s==="number"?s+1:void 0,u!==void 0){if(e.delete(u),e.delete(`${y}.${u}`),s!==void 0)i.set(u,s),e.set(u,s),e.set(`${y}.${u}`,s)}}c=r+1}else if(w.kind==="punctuation"){if("([{".includes(K))p++;else if(")]}".includes(K))p--}}let k=n;for(let r of f.reverse())k=k.slice(0,r.start)+r.text+k.slice(r.end);return{body:k,members:i}}function Hn(n,y){let m=[...new Set([...n,...y.values()])];if(!m.some((e)=>e.kind==="enum"))return;m.sort((e,i)=>(e.start??0)-(i.start??0));let o=new Map;for(let e of m)if(e.kind==="enum"){let i=e.text.indexOf("{");if(i<0)continue;if(t(e.text.slice(0,i)).some((c)=>e.text.slice(c.start,c.end)==="declare"))continue;let f=va(e.text.slice(i),e.name,o);e.text=e.text.slice(0,i)+f.body;for(let[c,p]of f.members)o.set(`${e.name}.${c}`,p)}else if(e.kind==="variable"&&e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion")&&typeof e.value==="string"){let i=S(e.value,o);if(i!==void 0)o.set(e.name,i)}}
|
|
3
3
|
export{va,Hn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m}from"./chunk-
|
|
2
|
+
import{m}from"./chunk-6ekgn7sc.js";import{y,ee}from"./chunk-vk5r6pgx.js";function H(b){let f=m(b),e=0,v,I,w,z=[new Map,new Map],n=(t=e)=>f[t]?b.slice(f[t].start,f[t].end):"",d=(t=e)=>f[t]?.kind==="word",g=(t,u)=>/[\r\n]/.test(b.slice(t,u));function r(t){if(n()!==t)return!1;return e++,!0}function k(t){let u=e;for(let a of t)if(!r(a)||e>u+1&&f[e-2].end!==f[e-1].start)return e=u,!1;return!0}function h(t){let u=e;if(t())return!0;return e=u,!1}function o(){if(!d())return!1;return e++,!0}function T(){let t=e,u=e;while(u<f.length&&(u===t||f[u-1].end===f[u].start)){let i=n(u),l=(i==="+"||i==="-")&&/[eE]$/.test(n(u-1));if(!d(u)&&!/^[0-9.]$/.test(i)&&!l)break;u++}if(u===t)return!1;let a=b.slice(f[t].start,f[u-1].end);if(!y(a)&&!ee(a))return!1;return e=u,!0}function A(){if(!["(","[","{"].includes(n()))return!1;if(!v){v=new Map;let u=[];for(let a=0;a<f.length;a++){let i=n(a);if(["(","[","{"].includes(i))u.push(a);else if([")","]","}"].includes(i)){let l=u.pop();if(l!==void 0&&["()","[]","{}"].includes(n(l)+i))v.set(l,a+1);else u.length=0}}}let t=v.get(e);if(t===void 0)return!1;return e=t,!0}function D(){return o()||(n()==="{"||n()==="[")&&A()}function N(){if(!r("("))return!1;if(r(")"))return!0;do{if(k("..."),!D())return!1;if(r("?"),r(":")&&!s())return!1;if(n()===")")break}while(r(",")&&n()!==")");return r(")")}function x(){if(!r("<"))return!1;if(n()===">")return!1;do{if(n()==="const")e++;while((n()==="in"||n()==="out")&&d(e+1)&&n(e+1)!=="extends")e++;if(!o())return!1;if(r("extends")&&!s(!1))return!1;if(r("=")&&!s())return!1;if(n()===">")break}while(r(",")&&n()!==">");return r(">")}function O(){if(!r("<")||n()===">")return!1;do{if(!s())return!1;if(n()===">")break}while(r(",")&&n()!==">");return r(">")}function F(){if(r("abstract"),r("new"),n()==="<"&&!x())return!1;return N()&&k("=>")&&q()}function G(){if(f[e]?.kind!=="literal"||b.charCodeAt(f[e].start)!==96)return!1;for(;;){let t=f[e++];if(!t)return!1;if(b.charCodeAt(t.end-1)===96)return!0;if(b.charCodeAt(t.end-1)!==36||!r("{")||!s()||!r("}"))return!1;if(f[e]?.kind!=="literal")return!1}}function J(){if(!r("["))return!1;if(r("]"))return!0;do{k("...");let t=e;if(d()||f[e]?.kind==="quoted"){if(e++,r("?"),!r(":"))e=t}if(!s())return!1;if(r("?"),n()==="]")break}while(r(",")&&n()!=="]");return r("]")}function q(){if(r("asserts")){if(!o())return!1;return!r("is")||s()}if(d()&&n(e+1)==="is")return e+=2,s();return s()}function S(){if(n()==="<"&&!x())return!1;if(!N())return!1;return!r(":")||q()}function K(){if(!r("["))return!1;if(d()&&(n(e+1)==="in"||n(e+1)===":")){e++;let t=r("in");if(!t&&!r(":"))return!1;if(!s())return!1;if(t&&r("as")&&!s())return!1}else{if(!o()&&!T()){if(f[e]?.kind!=="quoted")return!1;e++}while(r("."))if(!o())return!1}return r("]")}function B(){if(n()==="[")return K();if(o()||T())return!0;if(f[e]?.kind!=="quoted")return!1;return e++,!0}function Q(){if(n()!=="get"&&n()!=="set")return;let t=e++;e=B()&&n()==="("?t+1:t}function L(){if(!r("{"))return!1;while(!r("}")){if(e>=f.length)return!1;let t=e;if((n()==="+"||n()==="-")&&n(e+1)==="readonly")e++;if(n()==="readonly"&&n(e+1)!==":"&&n(e+1)!=="?"&&n(e+1)!=="("&&n(e+1)!==";"&&n(e+1)!=="}")e++;if(n()==="new"&&(n(e+1)==="("||n(e+1)==="<"))e++;if(n()==="("||n()==="<"){if(!S())return!1}else{if(Q(),!B())return!1;if(n()==="+"||n()==="-"){if(e++,!r("?"))return!1}else r("?");if(r(":")){if(!s())return!1}else if(n()==="("||n()==="<"){if(!S())return!1}}if(e===t)return!1;if(r(";")||r(","))continue;if(n()!=="}"&&!g(f[e-1].end,f[e]?.start??b.length))return!1}return!0}function P(){if(h(F))return!0;if(r("("))return s()&&r(")");if(n()==="{")return L();if(n()==="[")return J();if(h(G))return!0;if(f[e]?.kind==="quoted")return e++,!0;if(r("-"))return T();if(h(T))return!0;if(r("typeof")){if(n()==="import")return P();if(!o())return!1;while(r("."))if(!o())return!1;if(n()==="<"&&!O())return!1;return!0}if(r("import")){if(!r("(")||!s())return!1;if(r(",")&&!L())return!1;return r(")")}if(["export","function","class","const","let","var","return","throw","default","new","abstract"].includes(n()))return!1;return o()}function E(){if(n()==="keyof"||n()==="readonly"||n()==="unique")return e++,E();if(r("infer")){if(!o())return!1;if(r("extends")&&!s(!1))return!1;return!0}if(!P())return!1;for(;;)if(r(".")){if(!o())return!1}else if(n()==="<"){if(g(f[e-1].end,f[e].start))return!0;if(!O())return!1}else if(n()==="["){if(g(f[e-1].end,f[e].start))return!0;if(e++,!r("]")&&!(s()&&r("]")))return!1}else return!0}function R(){if(r("&"),!E())return!1;while(r("&"))if(!E())return!1;return!0}function s(t=!0){let u=e,a=z[t?1:0],i=a.get(u);if(i!==void 0){if(i<0)return!1;return e=i,!0}let l=U(t);if(a.set(u,l?e:-1),!l)e=u;return l}function U(t){if(r("|"),!R())return!1;while(r("|"))if(!R())return!1;if(t&&n()==="extends"&&!g(f[e-1].end,f[e].start))return e++,s(!1)&&r("?")&&s()&&r(":")&&s();return!0}function V(){if(n()!=="("||!A())return!1;if(r(":")&&!q())return!1;return k("=>")}function W(){r("async");let t=r("function");if(t){if(r("*"),d())e++}if(n()==="<"&&!x())return!1;if(n()!=="("||!A())return!1;if(r(":")&&!q())return!1;return t?n()==="{":k("=>")}function X(){let t=n();if(t==="<"||t===">"||t==="+"||t==="-")return!1;if(t==="("||f[e]?.kind==="literal"&&b.charCodeAt(f[e].start)===96)return!0;if(!f[e]||g(f[e-1].end,f[e].start))return!0;if(["*","/","%","=","&","|","^","?",":",",",";",")","]","}","in","instanceof","as","satisfies"].includes(t))return!0;if(t==="!")return n(e+1)==="="&&f[e].end===f[e+1]?.start;return!d()&&f[e]?.kind!=="quoted"&&f[e]?.kind!=="literal"&&!["{","[","~","#","@"].includes(t)&&!/^[0-9]$/.test(t)}return(t,u,a)=>{let i=0,l=f.length;while(i<l){let p=i+l>>>1;if(f[p].start<t)i=p+1;else l=p}if(f[i]?.start!==t||n(i)!=="<")return;if(I!==u){I=u,w=void 0;let p=0,M=i;while(p<M){let C=p+M>>>1;if(f[C].start<u)p=C+1;else M=C}if(e=p,W())w=f[e-1].end}if(w!==void 0&&t<w)return{end:w,completeOperand:!1,parameters:!0};e=i;let c=n(i-1),j=t===u||["=","+","-","*","/","%","&","|","^","!","~","?",":","<",">","void","typeof","await","yield","delete"].includes(c);if((c==="function"||c==="class"||c==="*"&&n(i-2)==="function"||d(i-1)&&(n(i-2)==="function"||n(i-2)==="class"||n(i-2)==="*"&&n(i-3)==="function"))&&h(x))return{end:f[e-1].end,completeOperand:!1,parameters:!0};if(e=i,(j||c==="async")&&h(x)){let p=f[e-1].end;if(h(V))return{end:p,completeOperand:!1,parameters:!0}}e=i;let Y=c==="."&&n(i-2)==="?"&&f[i-2].end===f[i-1].start;if((f[i-1]?.end??-1)>=u&&(Y||d(i-1)||c===")"||c==="]"||c==="!"||c===">"&&f[i-1].end===a)&&h(O)&&X())return{end:f[e-1].end,completeOperand:!0};if(e=i,j&&r("<")&&s()&&r(">"))return{end:f[e-1].end,completeOperand:!1};return}}
|
|
3
3
|
export{H};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V,er,tr}from"./chunk-
|
|
2
|
+
import{V,er,tr}from"./chunk-sbmdk35p.js";import{kn}from"./chunk-xm63aee8.js";import{f}from"./chunk-587w6ktw.js";import{fe,x,de,pe,me,ge,he}from"./chunk-bkrftw1s.js";import{Fe,v}from"./chunk-zpvcnc7c.js";import{Me}from"./chunk-t4cdpfrr.js";function L(y,D){throw Error(D||`Unexpected value: ${y}`)}var j=null,q=[],z=[];function l(y,D,d=!0,b=["bun"]){let o="",m=D.sourceCode;if(m){let e=0;while(e<m.length&&(m.charCodeAt(e)===32||m.charCodeAt(e)===9||m.charCodeAt(e)===10||m.charCodeAt(e)===13))e++;if(e<m.length-2&&m.charCodeAt(e)===47&&m.charCodeAt(e+1)===47&&m.charCodeAt(e+2)===47){let i=kn(m);if(i.length>0)for(let r=0;r<i.length;r++){if(o)o+=`
|
|
3
3
|
`;o+=i[r]}}}let E=[],N=[],M=[],P=[],U=[],W=[],_=[],w=[],C=[];for(let e of y){let i=e.kind;switch(i){case"import":E.push(e);break;case"function":N.push(e);break;case"variable":M.push(e);break;case"interface":P.push(e);break;case"type":U.push(e);break;case"class":W.push(e);break;case"enum":_.push(e);break;case"module":w.push(e);break;case"export":C.push(e);break;case"namespace":w.push(e);break;case"unknown":break;default:L(i,`Unhandled declaration kind: ${i}`)}}let T=[],S=[],A=[],F=new Set;for(let e of C){let i=f(e.leadingComments,d);if(e.text.startsWith("export default")){let r=e.text.endsWith(";")?e.text:`${e.text};`;A.push(i+r)}else{let r=e.text.trim();if(!r.endsWith(";"))r+=";";let a=i+r;if(!F.has(a))if(F.add(a),a.includes("export type"))T.push(a);else S.push(a)}}let u=[];if(E.length>0){let{usedItems:e}=Me(y);for(let r of E){if(r.isSideEffect){let t=r.text.trim(),p=t.endsWith(";")?t:`${t};`;u.push(p);continue}let a=v(r.text);if(!a)continue;let{defaultName:s,namedItems:n,isTypeOnly:h,namespaceName:c}=a,g=s?e.has(s):!1,G=c?e.has(c):!1;if(a.isImportEquals){if(g){let t=r.text.trim();u.push(t.endsWith(";")?t:`${t};`)}else if(D.augmentationImports?.has(a.source)){let t=Fe(r.text);if(!t)throw Error("Cannot locate an augmentation import module literal");u.push(`import ${t};`)}continue}let k="",I=0;for(let t=0;t<n.length;t++){let p=n[t];if(e.has(p.name)){if(I>0)k+=", ";if(!h&&p.isTypeOnly)k+="type ";k+=p.originalName===p.name?p.name:`${p.originalName} as ${p.name}`,I++}}if(g||G||I>0){let t=h?"import type ":"import ";if(G&&c){if(g&&s)t+=`${s}, `;t+=`* as ${c}`}else if(g&&s)t+=I>0?`${s}, { ${k} }`:s;else if(I>0)t+=`{ ${k} }`;let p=Fe(r.text);if(!p)throw Error("Cannot locate a grammatical module literal in the import declaration");t+=` from ${p};`,u.push(t)}else if(D.augmentationImports?.has(a.source)){let t=Fe(r.text);if(!t)throw Error("Cannot locate an augmentation import module literal");u.push(`import ${t};`)}}let i=b.length;if(u.length>1){if(j!==b)j=b,q=b.map((n)=>`from '${n}`),z=b.map((n)=>`from "${n}`);let r=q,a=z,s=new Map;for(let n of u){let h=i;for(let c=0;c<b.length;c++)if(n.includes(r[c])||n.includes(a[c])){h=c;break}s.set(n,h)}u.sort((n,h)=>{let c=s.get(n),g=s.get(h);return c!==g?c-g:n.localeCompare(h)})}}for(let e=0;e<u.length;e++){if(o)o+=`
|
|
4
4
|
`;o+=u[e]}for(let e=0;e<T.length;e++){if(o)o+=`
|
|
5
5
|
`;o+=T[e]}let K=[N,M,P,U,W,_,w];for(let e=0;e<K.length;e++){let i=K[e];for(let r=0;r<i.length;r++){let a=i[r],s="",n=a.kind;switch(n){case"function":s=fe(a,d);break;case"variable":s=x(a,d);break;case"interface":s=de(a,d);break;case"type":s=pe(a,d);break;case"class":s=me(a,d);break;case"enum":s=ge(a,d);break;case"module":case"namespace":s=he(a,d);break;case"import":case"export":case"unknown":break;default:L(n,`Unhandled declaration kind in processor: ${n}`)}if(s){if(o)o+=`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-a04yhmwb.js";import{ke}from"./chunk-hgg4aqvf.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 Rs(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 wt(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 ke(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 Ir(t,e={}){return wt(t,{...e,declarationsOnly:!0})}async function Ms(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 Lr(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 Os(t,e,s){let o=Lr(t,e,s);return o?{type:o}:null}function Is(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 Ls(t){return wt(t.entrypoints.map((e)=>g(t.cwd,e)),{tsconfigPath:t.tsconfigPath,rootDir:t.root})}async function Ns(t,e){let o=(await Promise.all([wt(t),Ir(e)])).flatMap((n)=>n.diagnostics).map((n)=>({sourceName:n.file,sourceType:n.message,dtsType:"<invalid>"}));return{valid:o.length===0,mismatches:o}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Re}from"./chunk-
|
|
2
|
+
import{Re}from"./chunk-9b0jah2a.js";import{e}from"./chunk-3mp0jaa7.js";import{Oe,Z}from"./chunk-4sasxrdr.js";import{existsSync as x}from"fs";import{basename as O,dirname as D,extname as S,isAbsolute as v,relative as p,resolve as m}from"path";var{Glob:R}=globalThis.Bun;async function De(r,o){let s=await C(r);G(r,s);let n=s.slice(),a=await(o?o():Oe(r)),t=null;if(r.autoIncludeReExports!==!1&&n.length>0){t=await Z(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 j=r.outputStructure==="flat"&&s.some((E)=>a.isPackageLocal?.(E,c));if(!A(c,l)&&!j){e.warn(`Skipping auto-included source outside root: ${p(r.cwd,c)}`);continue}if(oe(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=F(n,r),d=t??await Z(n,{includeImports:!0,resolveSpecifier:a}),g=await Re([...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 M=50,w=new Map;function P(r){let o=w.get(r);if(!o){if(o=new R(r),w.set(r,o),w.size>M){let s=w.keys().next().value;if(s!==void 0)w.delete(s)}}return o}function oe(r,o,s){if(!o||o.length===0)return!1;let n=p(s,r);for(let a of o){let t=P(a);if(t.match(n)||t.match(r))return!0}return!1}var k=/[*?[\]{}!]/;function G(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)&&!A(i,s)).length===r.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a,i,h,g,xe,Ue}from"./chunk-
|
|
2
|
+
import{a,i,h,g,xe,Ue}from"./chunk-cgqg1br8.js";import{t,m,d,ze,b}from"./chunk-6ekgn7sc.js";import{cr}from"./chunk-cyzr3xat.js";import{Ve}from"./chunk-2q641ekp.js";import{ir}from"./chunk-r9gdz351.js";import{V,nr}from"./chunk-sbmdk35p.js";import{Hn}from"./chunk-e4f5kxrh.js";import{y,K}from"./chunk-vk5r6pgx.js";import{H}from"./chunk-fjkswqq2.js";import{_e,we,je}from"./chunk-n0tw6p7g.js";import{n,B,W,Ht,rr,Kt,z,U}from"./chunk-4nrrjn7g.js";import{Un}from"./chunk-3z75j224.js";import{x}from"./chunk-bkrftw1s.js";import{Jn}from"./chunk-zbrj37wa.js";function Oi(E,ie,Q,Y,ue=""){let le=new Map,f={start:0,end:E.length,header:0,name:"",children:[],results:new Map},ee=t(E),ge=[],S=[],Ze=[],Ye=new Map;for(let J=0;J<ee.length;J++){let he=ee[J];if(he.kind!=="punctuation")continue;let Ce=E.slice(he.start,he.end);if(Ce==="(")Ze.push(J);else if(Ce===")"){let e=Ze.pop();if(e!==void 0)Ye.set(J,e)}else if(Ce==="{")S.push(J);else if(Ce==="}"){let e=S.pop();if(e===void 0)continue;let Z=ee[e].start,se=e-1,P=se>=0?E.slice(ee[se].start,ee[se].end):"";if(P===")"){let ce=Ye.get(se);if(ce!==void 0&&ce>0&&["if","for","while","switch","catch","with"].includes(E.slice(ee[ce-1].start,ee[ce-1].end)))Z=ee[ce-1].start}else if(["else","try","finally","do"].includes(P))Z=ee[se].start;ge.push({open:ee[e].start,close:he.start,header:Z})}}let q=0,me=(J,he=new Set)=>{let Ce=new Set(he),e=t(E.slice(J.start,J.end)),Z=0;for(let de=0;de+1<e.length;de++){let Qe=E.slice(J.start+e[de].start,J.start+e[de].end);if(Qe==="{")Z++;else if(Qe==="}")Z--;else if(!Z&&["type","interface"].includes(Qe))Ce.add(E.slice(J.start+e[de+1].start,J.start+e[de+1].end))}let se="",P=J.start,ce=[...J.results].map(([de,Qe])=>({type:de,name:Qe}));for(let de of J.children.sort((Qe,ot)=>Qe.header-ot.header)){let Qe=me(de,Ce);se+=E.slice(P,de.header)+`
|
|
3
3
|
declare namespace ${de.name} {
|
|
4
4
|
${Qe.text}
|
|
5
5
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t}from"./chunk-
|
|
2
|
+
import{t}from"./chunk-6ekgn7sc.js";function C(n,o){if(o.kind!=="punctuation")return 0;let r=n.slice(o.start,o.end);if("([{<".includes(r))return 1;if(")]}".includes(r)||r===">"&&n[o.start-1]!=="=")return-1;return 0}function _e(n){if(!n.includes("?"))return n;let o=n.trim(),r=o.startsWith("(")&&o.endsWith(")"),u=n.indexOf(o)+(r?1:0),s=r?o.slice(1,-1):o,a=[[]],h=0;for(let i of t(s)){if(i.kind==="punctuation"&&s[i.start]===","&&h===0)a.push([]);else a[a.length-1].push(i);h+=C(s,i)}let m=a.map((i)=>{let l=0,d=-1;for(let[D,A]of i.entries()){if(l===0&&A.kind==="punctuation"&&s[A.start]===":"){d=D;break}l+=C(s,A)}let f=d>0&&s[i[d-1].start]==="?"?i[d-1]:void 0,y=i[0]?s.slice(i[0].start,i[0].end):"",q=i[0]&&s.startsWith("...",i[0].start);return{tokens:i,colon:d,question:f,required:i.length>0&&!f&&!q&&y!=="this"}}),c=-1;for(let[i,l]of m.entries())if(l.required)c=i;let e=[];for(let[i,l]of m.entries()){if(i>=c||!l.question||l.colon<0)continue;let d=l.tokens[l.colon+1],f=l.tokens.at(-1);if(!d||!f)continue;e.push({start:u+l.question.start,end:u+l.question.end,text:""},{start:u+d.start,end:u+d.start,text:"("},{start:u+f.end,end:u+f.end,text:") | undefined"})}if(!e.length)return n;let g=[],p=0;for(let i of e)g.push(n.slice(p,i.start),i.text),p=i.end;return g.push(n.slice(p)),g.join("")}function x(n){return n>=65&&n<=90||n>=97&&n<=122||n===95||n===36}function k(n,o){if(o>=n.length||!x(n.charCodeAt(o)))return o;let r=o+1;while(r<n.length&&(x(n.charCodeAt(r))||n.charCodeAt(r)>=48&&n.charCodeAt(r)<=57))r++;return r}function b(n,o){let r=o;while(r<n.length&&n.charCodeAt(r)<=32)r++;return r}function we(n,o){if(o.trim()!=="{}")return null;let r=n.trim();if(r.length<2||r[0]!=="{"||r[r.length-1]!=="}")return null;let u=r.slice(1,-1),s=[],a=0,h=0;for(let c=0;c<u.length;c++){let e=u.charCodeAt(c);if(e===34||e===39||e===96){c++;while(c<u.length&&u.charCodeAt(c)!==e){if(u.charCodeAt(c)===92)c++;c++}if(c>=u.length)return null;continue}if(e===47&&(u.charCodeAt(c+1)===47||u.charCodeAt(c+1)===42))return null;if(e===40||e===91||e===123)a++;else if(e===41||e===93||e===125){if(--a<0)return null}else if(e===44&&a===0)s.push(u.slice(h,c)),h=c+1}if(a!==0)return null;if(u.slice(h).trim()||s.length===0)s.push(u.slice(h));let m=[];for(let c of s){let e=c.trim(),g=k(e,0);if(g===0)return null;let p=e.slice(0,g),i=p,l=b(e,g);if(e.charCodeAt(l)===58){let f=b(e,l+1),y=k(e,f);if(y===f)return null;i=e.slice(f,y),l=b(e,y)}if(e.charCodeAt(l)!==61||e.charCodeAt(l+1)===61||e.charCodeAt(l+1)===62)return null;let d=e.slice(l+1).trim();if(!d)return null;m.push({key:p,alias:i,value:d})}return m}function je(n,o){let r=n.map((s)=>s.key===s.alias?s.key:`${s.key}: ${s.alias}`).join(", "),u=n.map((s)=>{let a=o(s.value),h=a==="unknown"||a==="any"?a:`${a.includes("=>")?`(${a})`:a} | undefined`;return`${s.key}?: ${h}`}).join("; ");return`{ ${r} }?: { ${u} }`}
|
|
3
3
|
export{_e,we,je};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
2
|
+
import{s}from"./chunk-4xvx77zs.js";function Ce(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=Ce,fr=Ce,Da=Ce;
|
|
3
3
|
export{Ce,Aa,fr,Da};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,d,E}from"./chunk-
|
|
2
|
+
import{t,d,E}from"./chunk-6ekgn7sc.js";var K={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},C=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"];function S(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 S(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=C.find((w)=>n.startsWith(w,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=S(n.slice(0,a.start),c,o+1),s=S(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 S(n.slice(1,-1),c,o+1)}if(["+","-","~"].includes(n[0])){let e=S(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=S(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 ir(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,x=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"||!x&&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,K);continue}if(i.modifiers?.[0]!=="const"||i.typeAnnotation||i.modifiers.includes("const assertion"))continue;let b=S(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 sr(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=S(n,c??new Map);return typeof r==="string"?{name:E(r,"'")}:{index:!0}}function or(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 ar(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
3
|
export{S,ir,sr,or,ar};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,m}from"./chunk-
|
|
2
|
+
import{t,m}from"./chunk-6ekgn7sc.js";import{Ge}from"./chunk-cyzr3xat.js";function ft(l){let u=t(l);if(u.length!==1||u[0].kind!=="word")return;let f=l.slice(u[0].start,u[0].end);return["true","false","null","undefined","this","super"].includes(f)?void 0:f}function Gt(l){let u=t(l);if(u.length===0)return!0;let f=u[u.length-1],g=l.slice(f.start,f.end);if(f.kind==="word"&&(g==="is"||g==="extends"))return!0;if(g==="|"||g==="&")return!0;let o=u[u.length-2];return g===">"&&o!==void 0&&l.slice(o.start,o.end)==="="}function V(l){return C(l,m(l))}function er(l){for(let u=1024;u<l.length;u*=8){let f=l.slice(0,u),g=I(f,t(f),u);if(g!==void 0)return g}return C(l,t(l))}function C(l,u){return I(l,u,1/0)??!1}function I(l,u,f){let g=0;for(let o=0;o<u.length;o++){let e=u[o];if(e.end>=f)return;if(e.kind==="punctuation"){let a=l.charCodeAt(e.start);if(a===123||a===40||a===91)g++;else if(a===125||a===41||a===93)g--;continue}if(g!==0||e.kind!=="word"||e.end-e.start!==6)continue;let b=l.slice(e.start,e.end);if(b==="export")return!0;if(b==="import"){let a=u[o+1];if(a===void 0?f!==1/0:a.end>=f)return;let w=a?l.slice(a.start,a.end):"";if(w!=="("&&w!==".")return!0}}return f===1/0?!1:void 0}function tr(l){if(l.isExported)return!1;if(["function","variable","interface","type","class","enum","namespace"].includes(l.kind))return!0;return l.kind==="module"&&(l.moduleForm==="namespace"||l.moduleForm==="identifier")}function nr(l,u,f){let g=l.text,o=t(g),e=(s)=>o[s]?g.slice(o[s].start,o[s].end):"",b=(s)=>o[s]?.kind==="word",a=new Map,w=new Map,y=[];for(let s=0;s<o.length;s++){let n=e(s);if(n==="("||n==="["||n==="{"||n==="<")y.push(s);else if(n===")"||n==="]"||n==="}"||n===">"&&e(s-1)!=="="){let i=y.at(-1);if(i!==void 0&&(e(i)==="("&&n===")"||e(i)==="["&&n==="]"||e(i)==="{"&&n==="}"||e(i)==="<"&&n===">")){if(y.pop(),a.set(i,s),e(i)==="<")w.set(s,i)}}}let O=(s)=>{let n=s;while(["readonly","public","private","protected","static","abstract","override","declare","accessor","get","set","async"].includes(e(n))&&(b(n+1)||o[n+1]?.kind==="quoted"||e(n+1)==="["||/^[0-9]/.test(e(n+1))))n++;if(e(n)==="(")return e((a.get(n)??o.length)+1)===":";if(e(n)==="<")return e((a.get(n)??o.length)+1)==="(";let i=n+1;if(e(n)==="[")i=(a.get(n)??o.length)+1;else if(g.charCodeAt(o[n]?.start??g.length)>=48&&g.charCodeAt(o[n]?.start??g.length)<=57)while(i<o.length&&o[i-1].end===o[i].start&&/^[\da-fxob_e.+-]+$/i.test(e(i)))i++;else if(!b(n)&&o[n]?.kind!=="quoted"&&o[n]?.kind!=="literal")return!1;if(e(i)==="?")i++;if(e(i)==="<")i=(a.get(i)??o.length)+1;return e(i)===":"||e(i)==="("},D=[],A=[];for(let s=0;s<o.length;s++){if(e(s)!=="(")continue;let n=a.get(s);if(n===void 0||!(e(n+1)===":"||e(n+1)==="="&&e(n+2)===">"))continue;let i=new Set,h=s+1;while(h<n){let p=h;while(p<n&&e(p)!==","){let x=a.get(p);if(x!==void 0)p=x+1;else p++}let r=h;while(r<p&&e(r)!==":"&&e(r)!=="="){let x=a.get(r);if(x!==void 0)r=x+1;else r++}let c=h;while([".","public","private","protected","readonly","override"].includes(e(c)))c++;if(e(c)==="{"||e(c)==="[")for(let x of Ge(g.slice(o[c].start,o[r-1].end)))i.add(x);else if(b(c))i.add(e(c));h=p+1}let d=n+(e(n+1)===":"?2:3);while(d<o.length){if(d>n+2&&g.slice(o[d-1].end,o[d].start).includes(`
|
|
3
3
|
`)&&!["|","&","?","extends","keyof","typeof","readonly","new","infer","is"].includes(e(d-1))&&O(d))break;if([";",",",")","]","}"].includes(e(d))||e(d)===">"&&e(d-1)!=="=")break;let p=a.get(d);if(p!==void 0)d=p+1;else d++}D.push({start:s,end:d,names:i});let k=w.get(s-1);if(f&&k!==void 0){let p=new Set,r=k+1;while(r<s-1){while(["const","in","out"].includes(e(r)))r++;if(b(r))p.add(e(r));while(r<s-1&&e(r)!==",")r=(a.get(r)??r)+1;r++}A.push({start:k,end:d,names:p})}}let v=f?new Set:void 0,S=(s)=>{if(!b(s))return;v?.add(o[s].start);let n=e(s);if(!D.some((i)=>s>=i.start&&s<i.end&&i.names.has(n)))u.add(n)},T=(s,n)=>{for(let i=s;i<n;i++){if(e(i)==="<"&&a.has(i)){i=a.get(i);continue}if(!b(i)||e(i-1)==="."||e(i+1)===":")continue;if(["true","false","null","undefined","new","this","super","as","satisfies","typeof","void","keyof"].includes(e(i)))continue;S(i)}};for(let s=0;s<o.length;s++){if(e(s)==="typeof")S(s+1);if(e(s)==="export"){let n=s+1;if(e(n)==="default"){if(!["function","class","abstract"].includes(e(n+1))){if(T(n+1,o.length),b(n+1)&&f?.candidates.has(e(n+1))&&(e(n+2)===";"||n+2===o.length))f.references.add(e(n+1))}continue}let i=e(n)==="type";if(i)n++;if(e(n)==="{"){let h=a.get(n);if(h===void 0||e(h+1)==="from")continue;for(let d=n+1;d<h;){let k=e(d)==="type"&&b(d+1)&&e(d+1)!=="as";if(k)d++;let p=f?.candidates.has(e(d));if(p)f.references.add(e(d));if(!p||!i&&!k)S(d);else v?.add(o[d].start);while(d<h&&e(d)!==",")d++;d++}}}if(e(s)==="["){let n=a.get(s);if(n!==void 0&&[":","?","("].includes(e(n+1))&&e(s+2)!==":"&&e(s+2)!=="in")T(s+1,n)}}if(l.kind==="class"){let s=-1;for(let n=0;n<o.length&&e(n)!=="{";n++)if(e(n)==="<"&&a.has(n))n=a.get(n);else if(e(n)==="extends"){s=n;break}if(s!==-1){let n=s+1;while(n<o.length&&e(n)!=="{"&&e(n)!=="implements"){let i=a.get(n);if(i!==void 0)n=i+1;else n++}T(s+1,n)}}if(f){let s=new Set,n=t(l.generics??""),i=0,h=!1;for(let r of n){let c=(l.generics??"").slice(r.start,r.end);if(["<","(","[","{"].includes(c)){if(i++,c==="<"&&i===1)h=!0}else if([">",")","]","}"].includes(c)&&!(c===">"&&(l.generics??"").slice(r.start-1,r.start)==="="))i--;else if(c===","&&i===1)h=!0;else if(h&&i===1&&r.kind==="word"&&!["const","in","out"].includes(c))s.add(c),h=!1}let d=A.flatMap((r)=>[...r.names].flatMap((c)=>[{index:r.start,name:c,delta:1},{index:r.end,name:c,delta:-1}])).sort((r,c)=>r.index-c.index),k=new Map,p=0;for(let r=0;r<o.length;r++){while(p<d.length&&d[p].index<=r){let M=d[p++];k.set(M.name,(k.get(M.name)??0)+M.delta)}if(!b(r)||v?.has(o[r].start)||!f.candidates.has(e(r))||s.has(e(r))||(k.get(e(r))??0)>0)continue;let c=e(r-1),x=e(r+1);if(c==="."||c==="as"&&l.kind==="export"||["const","let","var","function","class","interface","type","enum","namespace","module"].includes(c))continue;if(x===":"&&c!=="?"||x==="?"&&[":","("].includes(e(r+2))||x==="("||x==="<"&&e((a.get(r+1)??o.length)+1)==="(")continue;f.references.add(e(r))}}}
|
|
4
4
|
export{ft,Gt,V,er,tr,nr};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a,i}from"./chunk-
|
|
2
|
+
import{a,i}from"./chunk-cgqg1br8.js";import{x}from"./chunk-bkrftw1s.js";import{C}from"./chunk-zpvcnc7c.js";function Me(f){let r=new Set,n=[];for(let t of f)if(t.kind==="import")for(let o of C(t.text))r.add(o);else if(t.kind!=="unknown"){if(n.push(t.text),t.kind==="variable"){if(t.typeAnnotation)n.push(t.typeAnnotation);else if(t.value)n.push(x(t,!1))}}let e=n.join(`
|
|
3
3
|
`),s=new Set;for(let t=0;t<e.length;){if(!a(e.charCodeAt(t))){t++;continue}let o=t++;while(t<e.length&&i(e.charCodeAt(t)))t++;let c=e.slice(o,t);if(r.has(c))s.add(c)}return{usedItems:s,referenceText:e}}
|
|
4
4
|
export{Me};
|
|
@@ -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.51",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{A}from"./chunk-
|
|
2
|
+
import{A}from"./chunk-m8w98p7p.js";import{Y}from"./chunk-b6xcyrnx.js";import{chmod as G,lstat as P,mkdir as y,readdir as j,realpath as q,rename as D,rm as N,rmdir as L,stat as R,writeFile as W}from"fs/promises";import{basename as _,dirname as m,isAbsolute as M,parse as B,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await q(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),_(e))}}async function ne(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!A(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===B(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(A(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function S(a,e){try{if(!(await R(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await S(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await R(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await j(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function $e(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await ne(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!A(t,n)||A(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],x=[],T=[],b=!1,E,d,I=!1;async function h(o,c){let t=await g(m(o));if(!A(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(A(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function C(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await N(r,{recursive:!0})}try{await S(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await W(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await Y(v,i.content,i.lineEnding),!a.clean&&u.existing)await G(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),x.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await S(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),T.push({path:t.path,identity:t.stagedIdentity})}I=!0;try{await C()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(I)throw o;let c=[];for(let i of T.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await N(i.path)}catch(u){c.push(u)}for(let i of x.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await C()}catch(i){t.push(i)}for(let i of p.toReversed())try{await L(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
|
|
3
3
|
export{ne,$e};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{D}from"./chunk-m7jndt3v.js";import{re}from"./chunk-b6xcyrnx.js";import{ne,$e}from"./chunk-
|
|
2
|
+
import{D}from"./chunk-m7jndt3v.js";import{re}from"./chunk-b6xcyrnx.js";import{ne,$e}from"./chunk-vekg5zy6.js";import{Nn}from"./chunk-5ym0xgg0.js";import{spawn as j}from"child_process";var N=new Set(["cwd","root","outdir","entrypoints","include","exclude","autoIncludeReExports","outputStructure","tsconfigPath","moduleSpecifierMode","keepComments","isolatedDeclarations","clean","lineEnding"]);function x(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=j(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})),b=setTimeout(()=>p(Error(`Native declaration project exceeded ${c}ms`)),c),E=(t,w)=>{if(v)return;if(v=!0,clearTimeout(b),s?.removeEventListener("abort",m),t)r(t);else g(w)};if(o.once("error",(t)=>E(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")}`);E(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 Vi(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(!N.has(i))throw Error(`Native declaration project does not support option: ${i}`);d.signal?.throwIfAborted();let n={...D,...f};if(await ne(n),n.isolatedDeclarations===void 0)n.isolatedDeclarations=await re(n);let u=await Nn(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 x(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 $e(n,o),Object.freeze({filesGenerated:o.size,outputFiles:Object.freeze([...o.keys()])})}
|
|
3
3
|
export{Vi};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-a04yhmwb.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 mr(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 Gi(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}=mr(i,e),c=C(n,e);if(e.minify)c=gr(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 gr(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{mr,Gi,gr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a,i}from"./chunk-gyfbehkf.js";import{t,m}from"./chunk-6exq13f9.js";import{ft,Gt}from"./chunk-zrfwvjq8.js";import{C}from"./chunk-h3r142dy.js";import{n,z}from"./chunk-txf9rw55.js";function F(g,w){let D=(B)=>t(B).map((y)=>B.slice(y.start,y.end)).join("");return D(g)===D(w)}function fe(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let w=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(w)?w:void 0}function de(g,w){if(F(g,w))return g;let D=fe(w);if(!D)return;let B=t(g),y=0,v=0,E=[];for(let S of B){let k=g.slice(S.start,S.end);if(k==="("||k==="["||k==="{"||k==="<")y++;else if(k===")"||k==="]"||k==="}"||k===">")y--;else if(k==="|"&&y===0)E.push(g.slice(v,S.start).trim()),v=S.end}E.push(g.slice(v).trim());let W=E.find((S)=>F(S,w));if(W)return W;if(E.includes(D))return D==="boolean"&&(w==="true"||w==="false")?w:D;return}function Jn(g,w,D,B=new Set){let y=new Map,v=[],E=new Set;for(let e of[...w,...D.values()]){if(E.has(e))continue;if(E.add(e),v.push(e),e.kind==="import")for(let o of C(e.text))y.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))y.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")y.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}v.sort((e,o)=>(e.start??0)-(o.start??0));let W=new Set(v.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of B)W.add(e);let S=new Map,k=(e)=>{if(e=e.trimStart(),S.has(e))return S.get(e);if(S.set(e,void 0),!a(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!W.has(e.slice(0,o)))return;let r=t(e);if(r[0]?.kind!=="word"||!r[1]||e.slice(r[1].start,r[1].end)!=="(")return;let d=1;for(let s=2;s<r.length;s++){let l=e.slice(r[s].start,r[s].end);if(l==="(")d++;else if(l===")"&&--d===0){let c=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return S.set(e,c),c}}return},_=new Set(v.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>k(e.value)).filter((e)=>e!==void 0)).size?m(g):void 0,L=new Map;if(_){let e=0;for(let o=0;o<_.length;o++){let r=g.slice(_[o].start,_[o].end);if(e===0&&r==="function"){let d=_[o+1],s=d&&g.slice(d.start,d.end)==="*"?_[o+2]:d;if(s?.kind==="word"){let l=g.slice(s.start,s.end);L.set(l,(L.get(l)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let I=new Map;for(let e of v)if(e.kind==="function"&&!e.generics&&L.get(e.name)===1)I.set(e.name,e);for(let e of B){let o=v.find((r)=>r.kind==="import"&&C(r.text).includes(e));if(o)I.set(e,o)}let j="__dtsx_call_result";while(g.includes(j))j+="_";let X=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${j} ? ${j} : never`,G=new Map,N=!1;for(let e of v){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=z(e.value);if(o&&n(e.value,!1)===o)e.inferredType=o,e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${o};`;let r=k(e.value);if(r&&I.has(r))G.set(e,X(r)),y.get(e.name).active=!0,y.get(r).active=!0,N=!0;if(e.modifiers?.[0]!=="const")continue;let d=ft(e.value);if(!d||d===e.name||!y.has(d))continue;y.get(d).active=!0,y.get(e.name).active=!0,N=!0}if(!N)return;let u=_??m(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",b=new Map,O=new Map,J=new Set,P=new Set,Q=new Set,Y=new Map,x=[];for(let e=0;e<u.length;e++){let o=f(e),r=x.at(-1);if(r!==void 0)O.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))J.add(e);if(["(","[","{"].includes(o))x.push(e);else if([")","]","}"].includes(o)){let d=x.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))x.pop(),b.set(d,e)}}let Z=new Map;for(let e=0;e<u.length;){if(u[e].kind!=="punctuation"){e++;continue}let r=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>g.startsWith(s,u[e].start))??f(e);Z.set(e,r);let d=u[e].start+r.length;do e++;while(e<u.length&&u[e].start<d)}for(let e=0;e<u.length;e++){let o=te(e);if(o!==void 0)P.add(o)}for(let e of P)ce(e);let h=0;function ee(e){let o=ft(e);if(o){let l=y.get(o);return{type:l?.flow,unresolved:l?.unresolved??!1}}let r=k(e),d=r?I.get(r):void 0;if(d)return{type:d.returnType&&fe(d.returnType)?d.returnType:X(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function T(e){return Z.get(e)??""}function U(e){if(u[e]?.kind!=="word"||Q.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=y.get(f(e));if(!o?.active)return;let r=T(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(r))return{binding:o,operator:r};if(["++","--"].includes(r)&&!/[\r\n]/.test(g.slice(u[e].end,u[e+1].start)))return{binding:o,operator:r};if(e>=2&&["++","--"].includes(T(e-2))){let d=u[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(f(e-3)));if(!d||!s||/[\r\n;]/.test(g.slice(d.end,u[e-2].start)))return{binding:o,operator:T(e-2)}}return}function ne(e){let o=U(e);return o?.operator==="="?o.binding:void 0}function te(e){if(u[e]?.kind!=="word"||f(e)!=="class"||f(e-1)==="."||["(",":","="].includes(f(e+1)))return;let o=e+1,r=0;while(o<u.length){let d=f(o);if(d==="{"&&r===0)return o;if(d==="class"){let s=te(o);if(s!==void 0){o=(b.get(s)??s)+1;continue}}if(d==="function"){let s=oe(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&T(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(b.get(o)??o)+1}return}function ie(e,o,r){let d=e,s=!1,l=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(l.includes(f(d))&&!["(","<","?","!",":","=",";","}"].includes(f(d+1))){if(f(d)==="static")s=!0;d++}if(f(d)==="*")d++;if(r&&f(d)==="#")d++;if(f(d)==="["){let p=b.get(d);return p===void 0?void 0:{next:p+1,isStatic:s}}if(u[d]?.kind==="word"||u[d]?.kind==="quoted")return{next:d+1,isStatic:s};let c=d+1;while(c<o&&u[c-1].end===u[c].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(c)))c++;if(d<o&&n(g.slice(u[d].start,u[c-1].end),!1)==="number")return{next:c,isStatic:s};return}function V(e,o,r){let d=ie(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let l=1;s++;while(s<o&&l>0){if(f(s)==="<")l++;else if(f(s)===">"&&T(s-1)!=="=>")l--;s=(b.get(s)??s)+1}if(l!==0)return}return s}function re(e,o,r){return V(e,o,r)===o}function ae(e,o){let r=0,d=-1;for(let s=e;s<o;s=(b.get(s)??s)+1)if(f(s)==="<"&&(r>0||s>e&&(u[s-1].kind==="word"||[")","]"].includes(f(s-1))))){if(r===0)d=s;r++}else if(f(s)===">"&&T(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function le(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=V(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function q(e,o,r=!1){let d=b.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&T(s)==="=")return s;if(s>e&&O.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let l=f(s-1),p=!(l===">"&&ae(e,s)&&le(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(l),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!M)return s}s=(b.get(s)??s)+1}return d}function K(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&b.has(r)){r=b.get(r);continue}if(u[r].kind==="word")Q.add(r)}}function ce(e){let o=b.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(b.get(r+1)??r+1)+1;continue}let d=ie(r,o,!0);if(!d){r++;continue}let s=V(r,o,!0);if(s===void 0){r++;continue}if(K(r,s),f(s)==="("){let c=b.get(s),p=c===void 0?void 0:se(c,o);if(p!==void 0){r=(b.get(p)??p)+1;continue}}let l=s;if(f(l)===":")l=q(l+1,e,!0);if(T(l)==="="){K(r,l+1);let c=l+1,p=q(c,e);if(!d.isStatic&&p>c)Y.set(c,p);r=p}else{let c=q(s,e);K(r,c),r=Math.max(r+1,c)}}}function ue(e){let o=O.get(e);if(o===void 0)return!1;let r=P.has(o);if(!r&&!J.has(o))return!1;if(re(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=O.get(d),l=O.get(d)===o&&(f(d)===","||r&&f(d)===";"),c=r&&f(d)==="}"&&s!==void 0&&O.get(s)===o,p=r&&O.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((l||c||p)&&re(d+1,e,r))return!0}return!1}function se(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Gt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(b.get(r)??r)+1}return}function oe(e,o){let r=-1;if(f(e)==="("){let s=b.get(e);if(s!==void 0&&ue(e))r=se(s,o)??-1;else if(s!==void 0&&T(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let l=s+2;while(l<o&&f(l)!==";"){if(T(l)==="=>"){r=l+2;break}l=(b.get(l)??l)+1}}}else if(u[e]?.kind==="word"&&T(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(b.get(s)??s)+1;let l=b.get(s);if(l===void 0)return;r=l+1;let c=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(c===void 0||!Gt(g.slice(u[c].start,u[r].start))))break;r=(b.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(b.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(b.get(d)??d)+1;return{start:e,end:d}}function H(e,o,r=!0){for(let d=e;d<o;d++){let s=Y.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let l=r?oe(d,o):void 0;if(l){let p=l.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")H(l.start,l.end,!1);d=l.end-1;continue}let c=U(d);if(c)c.binding.flow=void 0,c.binding.unresolved=!0}}function ge(e){let o=!1;while(h<u.length&&u[h].start<e){let r=f(h);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let c=b.get(h)??h+1;while(c<u.length&&u[c].start>=e)c--;if(H(h+1,c),h=c+1,r==="{")o=!1;continue}let d=ne(h);if(d){let l=h+2,c=l,p=[];while(c<u.length&&u[c].start<e){let A=f(c);if(p.length===0&&(A===";"||c>l&&/[\r\n]/.test(g.slice(u[c-1].end,u[c].start))&&(ne(c)||["if","for","while","switch","try","do","return","throw"].includes(A))))break;if(A==="("||A==="{"||A==="[")p.push(A==="("?")":A==="{"?"}":"]");else if(A===p.at(-1))p.pop();c++}let M=c>l?g.slice(u[l].start,u[c-1].end):"";H(l,c);let R=ee(M);d.flow=!o&&R.type?d.declared?de(d.declared,R.type):R.type:void 0,d.unresolved=o||R.unresolved||!d.flow,h=c;continue}let s=U(h);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;h++}}for(let e of v){ge(e.start??0);let o=h;while(h<u.length&&u[h].start<(e.end??0))h++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<h&&u[M].start<e.initializerStart)M++;H(M,h)}let r=y.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=ee(d),l=ft(d),c=l?y.get(l):void 0,p=G.get(e);if(p)e.inferredType=p;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&l&&l!==e.name&&c){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=c.declared&&F(c.declared,s.type)?`typeof ${l}`:s.type}if(e.inferredType)e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${e.inferredType};`;if(e.typeAnnotation)r.flow=s.type?de(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)r.declared=e.inferredType,r.flow=e.inferredType;else{let M=e.modifiers?.[0]==="const",R=d.trim().startsWith("{")||d.trim().startsWith("["),A=n(d,M&&!R);r.declared=A==="unknown"?void 0:A,r.flow=r.declared}r.unresolved=s.unresolved}}
|
|
2
|
+
import{a,i}from"./chunk-cgqg1br8.js";import{t,m}from"./chunk-6ekgn7sc.js";import{ft,Gt}from"./chunk-sbmdk35p.js";import{C}from"./chunk-zpvcnc7c.js";import{n,z}from"./chunk-4nrrjn7g.js";function F(g,w){let D=(B)=>t(B).map((y)=>B.slice(y.start,y.end)).join("");return D(g)===D(w)}function fe(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let w=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(w)?w:void 0}function de(g,w){if(F(g,w))return g;let D=fe(w);if(!D)return;let B=t(g),y=0,v=0,E=[];for(let S of B){let k=g.slice(S.start,S.end);if(k==="("||k==="["||k==="{"||k==="<")y++;else if(k===")"||k==="]"||k==="}"||k===">")y--;else if(k==="|"&&y===0)E.push(g.slice(v,S.start).trim()),v=S.end}E.push(g.slice(v).trim());let W=E.find((S)=>F(S,w));if(W)return W;if(E.includes(D))return D==="boolean"&&(w==="true"||w==="false")?w:D;return}function Jn(g,w,D,B=new Set){let y=new Map,v=[],E=new Set;for(let e of[...w,...D.values()]){if(E.has(e))continue;if(E.add(e),v.push(e),e.kind==="import")for(let o of C(e.text))y.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))y.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")y.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}v.sort((e,o)=>(e.start??0)-(o.start??0));let W=new Set(v.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of B)W.add(e);let S=new Map,k=(e)=>{if(e=e.trimStart(),S.has(e))return S.get(e);if(S.set(e,void 0),!a(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!W.has(e.slice(0,o)))return;let r=t(e);if(r[0]?.kind!=="word"||!r[1]||e.slice(r[1].start,r[1].end)!=="(")return;let d=1;for(let s=2;s<r.length;s++){let l=e.slice(r[s].start,r[s].end);if(l==="(")d++;else if(l===")"&&--d===0){let c=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return S.set(e,c),c}}return},_=new Set(v.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>k(e.value)).filter((e)=>e!==void 0)).size?m(g):void 0,L=new Map;if(_){let e=0;for(let o=0;o<_.length;o++){let r=g.slice(_[o].start,_[o].end);if(e===0&&r==="function"){let d=_[o+1],s=d&&g.slice(d.start,d.end)==="*"?_[o+2]:d;if(s?.kind==="word"){let l=g.slice(s.start,s.end);L.set(l,(L.get(l)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let I=new Map;for(let e of v)if(e.kind==="function"&&!e.generics&&L.get(e.name)===1)I.set(e.name,e);for(let e of B){let o=v.find((r)=>r.kind==="import"&&C(r.text).includes(e));if(o)I.set(e,o)}let j="__dtsx_call_result";while(g.includes(j))j+="_";let X=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${j} ? ${j} : never`,G=new Map,N=!1;for(let e of v){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=z(e.value);if(o&&n(e.value,!1)===o)e.inferredType=o,e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${o};`;let r=k(e.value);if(r&&I.has(r))G.set(e,X(r)),y.get(e.name).active=!0,y.get(r).active=!0,N=!0;if(e.modifiers?.[0]!=="const")continue;let d=ft(e.value);if(!d||d===e.name||!y.has(d))continue;y.get(d).active=!0,y.get(e.name).active=!0,N=!0}if(!N)return;let u=_??m(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",b=new Map,O=new Map,J=new Set,P=new Set,Q=new Set,Y=new Map,x=[];for(let e=0;e<u.length;e++){let o=f(e),r=x.at(-1);if(r!==void 0)O.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))J.add(e);if(["(","[","{"].includes(o))x.push(e);else if([")","]","}"].includes(o)){let d=x.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))x.pop(),b.set(d,e)}}let Z=new Map;for(let e=0;e<u.length;){if(u[e].kind!=="punctuation"){e++;continue}let r=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>g.startsWith(s,u[e].start))??f(e);Z.set(e,r);let d=u[e].start+r.length;do e++;while(e<u.length&&u[e].start<d)}for(let e=0;e<u.length;e++){let o=te(e);if(o!==void 0)P.add(o)}for(let e of P)ce(e);let h=0;function ee(e){let o=ft(e);if(o){let l=y.get(o);return{type:l?.flow,unresolved:l?.unresolved??!1}}let r=k(e),d=r?I.get(r):void 0;if(d)return{type:d.returnType&&fe(d.returnType)?d.returnType:X(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function T(e){return Z.get(e)??""}function U(e){if(u[e]?.kind!=="word"||Q.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=y.get(f(e));if(!o?.active)return;let r=T(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(r))return{binding:o,operator:r};if(["++","--"].includes(r)&&!/[\r\n]/.test(g.slice(u[e].end,u[e+1].start)))return{binding:o,operator:r};if(e>=2&&["++","--"].includes(T(e-2))){let d=u[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(f(e-3)));if(!d||!s||/[\r\n;]/.test(g.slice(d.end,u[e-2].start)))return{binding:o,operator:T(e-2)}}return}function ne(e){let o=U(e);return o?.operator==="="?o.binding:void 0}function te(e){if(u[e]?.kind!=="word"||f(e)!=="class"||f(e-1)==="."||["(",":","="].includes(f(e+1)))return;let o=e+1,r=0;while(o<u.length){let d=f(o);if(d==="{"&&r===0)return o;if(d==="class"){let s=te(o);if(s!==void 0){o=(b.get(s)??s)+1;continue}}if(d==="function"){let s=oe(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&T(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(b.get(o)??o)+1}return}function ie(e,o,r){let d=e,s=!1,l=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(l.includes(f(d))&&!["(","<","?","!",":","=",";","}"].includes(f(d+1))){if(f(d)==="static")s=!0;d++}if(f(d)==="*")d++;if(r&&f(d)==="#")d++;if(f(d)==="["){let p=b.get(d);return p===void 0?void 0:{next:p+1,isStatic:s}}if(u[d]?.kind==="word"||u[d]?.kind==="quoted")return{next:d+1,isStatic:s};let c=d+1;while(c<o&&u[c-1].end===u[c].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(c)))c++;if(d<o&&n(g.slice(u[d].start,u[c-1].end),!1)==="number")return{next:c,isStatic:s};return}function V(e,o,r){let d=ie(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let l=1;s++;while(s<o&&l>0){if(f(s)==="<")l++;else if(f(s)===">"&&T(s-1)!=="=>")l--;s=(b.get(s)??s)+1}if(l!==0)return}return s}function re(e,o,r){return V(e,o,r)===o}function ae(e,o){let r=0,d=-1;for(let s=e;s<o;s=(b.get(s)??s)+1)if(f(s)==="<"&&(r>0||s>e&&(u[s-1].kind==="word"||[")","]"].includes(f(s-1))))){if(r===0)d=s;r++}else if(f(s)===">"&&T(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function le(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=V(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function q(e,o,r=!1){let d=b.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&T(s)==="=")return s;if(s>e&&O.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let l=f(s-1),p=!(l===">"&&ae(e,s)&&le(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(l),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!M)return s}s=(b.get(s)??s)+1}return d}function K(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&b.has(r)){r=b.get(r);continue}if(u[r].kind==="word")Q.add(r)}}function ce(e){let o=b.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(b.get(r+1)??r+1)+1;continue}let d=ie(r,o,!0);if(!d){r++;continue}let s=V(r,o,!0);if(s===void 0){r++;continue}if(K(r,s),f(s)==="("){let c=b.get(s),p=c===void 0?void 0:se(c,o);if(p!==void 0){r=(b.get(p)??p)+1;continue}}let l=s;if(f(l)===":")l=q(l+1,e,!0);if(T(l)==="="){K(r,l+1);let c=l+1,p=q(c,e);if(!d.isStatic&&p>c)Y.set(c,p);r=p}else{let c=q(s,e);K(r,c),r=Math.max(r+1,c)}}}function ue(e){let o=O.get(e);if(o===void 0)return!1;let r=P.has(o);if(!r&&!J.has(o))return!1;if(re(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=O.get(d),l=O.get(d)===o&&(f(d)===","||r&&f(d)===";"),c=r&&f(d)==="}"&&s!==void 0&&O.get(s)===o,p=r&&O.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((l||c||p)&&re(d+1,e,r))return!0}return!1}function se(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Gt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(b.get(r)??r)+1}return}function oe(e,o){let r=-1;if(f(e)==="("){let s=b.get(e);if(s!==void 0&&ue(e))r=se(s,o)??-1;else if(s!==void 0&&T(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let l=s+2;while(l<o&&f(l)!==";"){if(T(l)==="=>"){r=l+2;break}l=(b.get(l)??l)+1}}}else if(u[e]?.kind==="word"&&T(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(b.get(s)??s)+1;let l=b.get(s);if(l===void 0)return;r=l+1;let c=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(c===void 0||!Gt(g.slice(u[c].start,u[r].start))))break;r=(b.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(b.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(b.get(d)??d)+1;return{start:e,end:d}}function H(e,o,r=!0){for(let d=e;d<o;d++){let s=Y.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let l=r?oe(d,o):void 0;if(l){let p=l.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")H(l.start,l.end,!1);d=l.end-1;continue}let c=U(d);if(c)c.binding.flow=void 0,c.binding.unresolved=!0}}function ge(e){let o=!1;while(h<u.length&&u[h].start<e){let r=f(h);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let c=b.get(h)??h+1;while(c<u.length&&u[c].start>=e)c--;if(H(h+1,c),h=c+1,r==="{")o=!1;continue}let d=ne(h);if(d){let l=h+2,c=l,p=[];while(c<u.length&&u[c].start<e){let A=f(c);if(p.length===0&&(A===";"||c>l&&/[\r\n]/.test(g.slice(u[c-1].end,u[c].start))&&(ne(c)||["if","for","while","switch","try","do","return","throw"].includes(A))))break;if(A==="("||A==="{"||A==="[")p.push(A==="("?")":A==="{"?"}":"]");else if(A===p.at(-1))p.pop();c++}let M=c>l?g.slice(u[l].start,u[c-1].end):"";H(l,c);let R=ee(M);d.flow=!o&&R.type?d.declared?de(d.declared,R.type):R.type:void 0,d.unresolved=o||R.unresolved||!d.flow,h=c;continue}let s=U(h);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;h++}}for(let e of v){ge(e.start??0);let o=h;while(h<u.length&&u[h].start<(e.end??0))h++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<h&&u[M].start<e.initializerStart)M++;H(M,h)}let r=y.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=ee(d),l=ft(d),c=l?y.get(l):void 0,p=G.get(e);if(p)e.inferredType=p;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&l&&l!==e.name&&c){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=c.declared&&F(c.declared,s.type)?`typeof ${l}`:s.type}if(e.inferredType)e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${e.inferredType};`;if(e.typeAnnotation)r.flow=s.type?de(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)r.declared=e.inferredType,r.flow=e.inferredType;else{let M=e.modifiers?.[0]==="const",R=d.trim().startsWith("{")||d.trim().startsWith("["),A=n(d,M&&!R);r.declared=A==="unknown"?void 0:A,r.flow=r.declared}r.unresolved=s.unresolved}}
|
|
3
3
|
export{Jn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,E,ze,b}from"./chunk-
|
|
2
|
+
import{t,E,ze,b}from"./chunk-6ekgn7sc.js";import{Xn,Zn}from"./chunk-013mp499.js";function q(n){return b(n).find((e)=>e.category==="static-import")}function S(n){return t(n).map((e)=>n.slice(e.start,e.end)).join(" ")}function W(n){let e=q(n);return e?n.lastIndexOf(" from ",e.start):-1}function Fe(n){let e=q(n);return e?E(e.specifier,"'"):void 0}function Yn(n){let e=v(n);if(!e)return null;return{defaultName:e.defaultName??e.namespaceName,namedItems:e.namedItems.map((r)=>`${!e.isTypeOnly&&r.isTypeOnly?"type ":""}${r.originalName===r.name?r.name:`${r.originalName} as ${r.name}`}`),source:e.source,isTypeOnly:e.isTypeOnly,isNamespace:e.isNamespace,namespaceName:e.namespaceName,isImportEquals:e.isImportEquals}}function C(n){let e=Xn(n);if(e)return e;let r=v(n),u=r?[r.defaultName,r.namespaceName,...r.namedItems.map((a)=>a.name)].filter((a)=>a!==null):[];return Zn(n,u),u}function w(n){let e=[],r=0;for(let a of t(n)){if(a.kind!=="punctuation"||n.slice(a.start,a.end)!==",")continue;let s=n.slice(r,a.start).trim();if(s)e.push(s);r=a.end}let u=n.slice(r).trim();if(u)e.push(u);return e}function v(n){n=S(n);let e=ze(n);if(e)return{defaultName:e.name,namedItems:[],source:e.source,isTypeOnly:e.isTypeOnly,isNamespace:!1,namespaceName:null,isImportEquals:!0};let r=W(n);if(r===-1)return null;let u=q(n);if(!u)return null;let a=u.specifier,s=n.slice(0,r).trim(),p=u.isTypeOnly;if(s.startsWith("import "))s=s.slice(7).trim();if(p&&s.startsWith("type "))s=s.slice(5).trim();let f=null,o=[],i=!1,m=null,c=s.includes("{")?-1:s.indexOf("* as ");if(c!==-1)return i=!0,m=s.slice(c+5).trim(),f=s.slice(0,c).trim().replace(/,$/,"").trim()||null,{defaultName:f,namedItems:[],source:a,isTypeOnly:p,isNamespace:i,namespaceName:m};let l=s.indexOf("{"),d=s.lastIndexOf("}");if(l!==-1&&d!==-1){let g=s.slice(0,l).trim();if(g.endsWith(","))f=g.slice(0,-1).trim()||null;let I=s.slice(l+1,d),D=w(I);for(let h of D){let T=Ii(h),y=T?h.slice(5).trim():h,N=y.lastIndexOf(" as "),O,x;if(N!==-1)x=y.slice(0,N).trim(),O=y.slice(N+4).trim();else O=y,x=y;o.push({name:O,originalName:x,isTypeOnly:p||T,isDefault:!1})}}else f=s.trim()||null;return{defaultName:f,namedItems:o,source:a,isTypeOnly:p,isNamespace:i,namespaceName:m}}function Wa(n){let e=n.trim();if(e.startsWith("export default "))return{namedItems:[],source:null,isTypeOnly:!1,isNamespace:!1,isDefault:!0};let r=e.startsWith("export type ");if(e.startsWith("export "))e=e.slice(7).trim();if(r&&e.startsWith("type "))e=e.slice(5).trim();if(e.startsWith("* from ")||e.startsWith("* as ")){let m=e.indexOf(" from "),c=null;if(m!==-1){let l=e.slice(m+6).trim(),d=l[0];if(d==='"'||d==="'"){let g=l.indexOf(d,1);if(g!==-1)c=l.slice(1,g)}}return{namedItems:[],source:c,isTypeOnly:r,isNamespace:!0,isDefault:!1}}let u=e.indexOf("{"),a=e.lastIndexOf("}");if(u===-1||a===-1)return null;let s=null,p=e.indexOf(" from ",a);if(p!==-1){let m=e.slice(p+6).trim(),c=m[0];if(c==='"'||c==="'"){let l=m.indexOf(c,1);if(l!==-1)s=m.slice(1,l)}}let f=[],o=e.slice(u+1,a),i=[];{let m=0;for(let c=0;c<=o.length;c++)if(c===o.length||o.charCodeAt(c)===44){let l=m,d=c;while(l<d&&o.charCodeAt(l)<=32)l++;while(d>l&&o.charCodeAt(d-1)<=32)d--;if(l<d)i.push(o.slice(l,d));m=c+1}}for(let m of i){let c=Ii(m),l=c?m.slice(5).trim():m,d=l.lastIndexOf(" as "),g,I;if(d!==-1)I=l.slice(0,d).trim(),g=l.slice(d+4).trim();else g=l,I=l;f.push({name:g,originalName:I,isTypeOnly:r||c,isDefault:!1})}return{namedItems:f,source:s,isTypeOnly:r,isNamespace:!1,isDefault:!1}}function Ii(n){let e=t(n),r=e[0];if(!r||r.kind!=="word"||n.slice(r.start,r.end)!=="type"||e.length<2)return!1;return!(e.length===3&&n.slice(e[1].start,e[1].end)==="as")}function _a(n){let e=v(n);if(!e||e.isTypeOnly||e.isImportEquals)return n;if(e.namedItems.every((r)=>r.isTypeOnly))return n.replace(/^import\s+/,"import type ");return n}function ja(n){let e=new Map,r=[];for(let a of n){let s=v(a);if(!s)continue;if(s.isImportEquals||s.isNamespace){r.push(a);continue}let p=Fe(a);if(!p)throw Error("Cannot locate a grammatical module literal in the import declaration");let f=e.get(s.source)||{types:[],values:[],defaultName:null,sourceLiteral:p};if(s.defaultName)f.defaultName=s.defaultName;for(let o of s.namedItems)if(o.isTypeOnly)f.types.push(o);else f.values.push(o);e.set(s.source,f)}let u=r;for(let{types:a,values:s,defaultName:p,sourceLiteral:f}of e.values())if(a.length===0&&s.length===0&&p)u.push(`import ${p} from ${f};`);else if(a.length>0&&s.length===0&&!p){let o=a.map((i)=>i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`);u.push(`import type { ${o.join(", ")} } from ${f};`)}else if(s.length>0&&a.length===0&&!p){let o=s.map((i)=>i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`);u.push(`import { ${o.join(", ")} } from ${f};`)}else{let o=[];for(let i of a){let m=i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`;o.push(`type ${m}`)}for(let i of s){let m=i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`;o.push(m)}if(p)u.push(`import ${p}, { ${o.join(", ")} } from ${f};`);else u.push(`import { ${o.join(", ")} } from ${f};`)}return u}
|
|
3
3
|
export{Fe,Yn,C,v,Wa,Ii,_a,ja};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{sa,Re}from"../chunk-
|
|
2
|
+
import{sa,Re}from"../chunk-9b0jah2a.js";import"../chunk-t4cdpfrr.js";import"../chunk-02yqpwv0.js";import"../chunk-a04yhmwb.js";import"../chunk-cq5zpg9c.js";import"../chunk-kcfc6zg6.js";import"../chunk-8gksa73c.js";import"../chunk-937czex4.js";import"../chunk-srfpcjtn.js";import"../chunk-v6fwy63g.js";import"../chunk-m9b6cqn7.js";import"../chunk-3z75j224.js";import"../chunk-e4f5kxrh.js";import"../chunk-bkrftw1s.js";import"../chunk-zbrj37wa.js";import"../chunk-zpvcnc7c.js";import"../chunk-013mp499.js";import"../chunk-sbmdk35p.js";import"../chunk-4nrrjn7g.js";import"../chunk-587w6ktw.js";import"../chunk-r9gdz351.js";import"../chunk-fjkswqq2.js";import"../chunk-vk5r6pgx.js";import"../chunk-n0tw6p7g.js";import"../chunk-cyzr3xat.js";import"../chunk-2q641ekp.js";import"../chunk-6ekgn7sc.js";import"../chunk-cgqg1br8.js";export{Re as planAugmentationImports,sa as scanModuleAugmentations};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ge,cr}from"../chunk-
|
|
2
|
+
import{Ge,cr}from"../chunk-cyzr3xat.js";import"../chunk-6ekgn7sc.js";import"../chunk-cgqg1br8.js";export{Ge as bindingPatternNames,cr as projectBindingPattern};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Oo,nt,Pn}from"../chunk-
|
|
2
|
+
import{Oo,nt,Pn}from"../chunk-czgjmefa.js";import"../chunk-4sasxrdr.js";import"../chunk-x6ddycvm.js";import"../chunk-g9emajpc.js";import"../chunk-02yqpwv0.js";import"../chunk-3mp0jaa7.js";import"../chunk-m9b6cqn7.js";import"../chunk-3z75j224.js";import"../chunk-e4f5kxrh.js";import"../chunk-bkrftw1s.js";import"../chunk-zbrj37wa.js";import"../chunk-zpvcnc7c.js";import"../chunk-013mp499.js";import"../chunk-sbmdk35p.js";import"../chunk-4nrrjn7g.js";import"../chunk-587w6ktw.js";import"../chunk-r9gdz351.js";import"../chunk-fjkswqq2.js";import"../chunk-vk5r6pgx.js";import"../chunk-n0tw6p7g.js";import"../chunk-cyzr3xat.js";import"../chunk-2q641ekp.js";import"../chunk-6ekgn7sc.js";import"../chunk-cgqg1br8.js";export{Pn as linkBundle,nt as renameIdentifiers,Oo as splitTopLevelStatements};
|
package/dist/src/bundler.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ys,tn,Tr,bs,ws}from"../chunk-
|
|
2
|
+
import{ys,tn,Tr,bs,ws}from"../chunk-bj3r4j0a.js";import"../chunk-a04yhmwb.js";import"../chunk-cq5zpg9c.js";import"../chunk-kcfc6zg6.js";import"../chunk-8gksa73c.js";import"../chunk-937czex4.js";import"../chunk-srfpcjtn.js";import"../chunk-v6fwy63g.js";import"../chunk-m9b6cqn7.js";import"../chunk-3z75j224.js";import"../chunk-e4f5kxrh.js";import"../chunk-bkrftw1s.js";import"../chunk-zbrj37wa.js";import"../chunk-zpvcnc7c.js";import"../chunk-013mp499.js";import"../chunk-sbmdk35p.js";import"../chunk-4nrrjn7g.js";import"../chunk-587w6ktw.js";import"../chunk-r9gdz351.js";import"../chunk-fjkswqq2.js";import"../chunk-vk5r6pgx.js";import"../chunk-n0tw6p7g.js";import"../chunk-cyzr3xat.js";import"../chunk-2q641ekp.js";import"../chunk-6ekgn7sc.js";import"../chunk-cgqg1br8.js";export{Tr as bundleAndWrite,ys as bundleDeclarations,tn as bundleDtsFiles,bs as createBundler,ws as resolveEntryFiles};
|
package/dist/src/cache.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{pi,et,kt}from"../chunk-
|
|
2
|
+
import{pi,et,kt}from"../chunk-1jmwmc2a.js";import"../chunk-v6fwy63g.js";export{et as BuildCache,pi as clearBuildCache,kt as ensureGitignore};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ve}from"../chunk-
|
|
2
|
+
import{Ve}from"../chunk-2q641ekp.js";import"../chunk-6ekgn7sc.js";import"../chunk-cgqg1br8.js";export{Ve as functionCount};
|
package/dist/src/circular.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ar,Dr,xs,Cs,vs,Ss,$s,Es,ks}from"../chunk-
|
|
2
|
+
import{Ar,Dr,xs,Cs,vs,Ss,$s,Es,ks}from"../chunk-6e5dyfx2.js";import"../chunk-a04yhmwb.js";import"../chunk-cq5zpg9c.js";import"../chunk-kcfc6zg6.js";import"../chunk-8gksa73c.js";import"../chunk-937czex4.js";import"../chunk-srfpcjtn.js";import"../chunk-v6fwy63g.js";import"../chunk-m9b6cqn7.js";import"../chunk-3z75j224.js";import"../chunk-e4f5kxrh.js";import"../chunk-bkrftw1s.js";import"../chunk-zbrj37wa.js";import"../chunk-zpvcnc7c.js";import"../chunk-013mp499.js";import"../chunk-sbmdk35p.js";import"../chunk-4nrrjn7g.js";import"../chunk-587w6ktw.js";import"../chunk-r9gdz351.js";import"../chunk-fjkswqq2.js";import"../chunk-vk5r6pgx.js";import"../chunk-n0tw6p7g.js";import"../chunk-cyzr3xat.js";import"../chunk-2q641ekp.js";import"../chunk-6ekgn7sc.js";import"../chunk-cgqg1br8.js";export{xs as analyzeCircularDependencies,Ar as buildDependencyGraph,Dr as detectCircularDependencies,Es as exportGraphAsDot,ks as exportGraphAsJson,$s as findAllDependencies,Ss as findAllDependents,Cs as formatCircularAnalysis,vs as getGraphSummary};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S,ir,sr,or,ar}from"../chunk-
|
|
2
|
+
import{S,ir,sr,or,ar}from"../chunk-r9gdz351.js";import"../chunk-6ekgn7sc.js";import"../chunk-cgqg1br8.js";export{ir as attachComputedKeyConstants,S as evaluateKeyConstant,ar as hasTemplateSubstitution,or as isSymbolKey,sr as resolveTemplateKey};
|