@dtsx/dtsx 0.11.57 → 0.12.0
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-s9937pks.js → chunk-07c41ffx.js} +7 -7
- package/dist/{chunk-qhbdh4gy.js → chunk-0mj07j66.js} +3 -3
- package/dist/chunk-0zwa1tag.js +31 -0
- package/dist/chunk-16rpzfwq.js +10 -0
- package/dist/chunk-253e6nb4.js +3 -0
- package/dist/chunk-27hrxxsh.js +9 -0
- package/dist/{chunk-1b003vaa.js → chunk-27rxm6hh.js} +6 -6
- package/dist/chunk-30ffarqm.js +4 -0
- package/dist/{chunk-kqyqbrcv.js → chunk-37jcvx0v.js} +3 -3
- package/dist/chunk-44a6zpxs.js +3 -0
- package/dist/{chunk-xvp60m78.js → chunk-4ce9a877.js} +2 -2
- package/dist/{chunk-587w6ktw.js → chunk-4th0w19y.js} +3 -3
- package/dist/{chunk-mew3f4wh.js → chunk-50r5qs7t.js} +2 -2
- package/dist/chunk-5fgakmq9.js +3 -0
- package/dist/chunk-5tcpge5e.js +56 -0
- package/dist/{chunk-wmzg12wb.js → chunk-5vk2x8ee.js} +2 -2
- package/dist/{chunk-ered54kd.js → chunk-7116bytq.js} +8 -8
- package/dist/{chunk-hqytpz18.js → chunk-78ft65vf.js} +2 -2
- package/dist/{chunk-p023fhce.js → chunk-795w1bb2.js} +3 -3
- package/dist/chunk-7vjbc4z7.js +6 -0
- package/dist/chunk-85r70e8z.js +3 -0
- package/dist/chunk-8t9qp0mq.js +5 -0
- package/dist/chunk-9axwjcna.js +21 -0
- package/dist/{chunk-s3mxfatw.js → chunk-9wgk5qp1.js} +2 -2
- package/dist/{chunk-b1wmavr8.js → chunk-am4b9zt0.js} +3 -3
- package/dist/chunk-b5wcbnb8.js +9 -0
- package/dist/{chunk-ss3na6s0.js → chunk-bd048mjd.js} +2 -2
- package/dist/chunk-be7f8t6b.js +3 -0
- package/dist/chunk-bwb12r8r.js +3 -0
- package/dist/chunk-cb5dj4qy.js +3 -0
- package/dist/chunk-chj3hn6f.js +3 -0
- package/dist/chunk-cnb2rfmv.js +21 -0
- package/dist/{chunk-jb43rwce.js → chunk-cs6538bw.js} +2 -2
- package/dist/chunk-d99qykzn.js +6 -0
- package/dist/{chunk-31t6c3q1.js → chunk-e12f4mpd.js} +21 -21
- package/dist/chunk-e21ap86b.js +3 -0
- package/dist/{chunk-vs6ay4t3.js → chunk-ezhvnzja.js} +2 -2
- package/dist/chunk-fnd5bvfd.js +3 -0
- package/dist/chunk-fwqdc8fd.js +3 -0
- package/dist/{chunk-yd8rwwzf.js → chunk-gkfchhnr.js} +2 -2
- package/dist/chunk-h9gwg4kt.js +9 -0
- package/dist/chunk-hd2bq1j5.js +6 -0
- package/dist/{chunk-14zb70ca.js → chunk-hpdmtzhk.js} +3 -3
- package/dist/{chunk-v6fwy63g.js → chunk-j2bapmng.js} +2 -2
- package/dist/{chunk-aa3k6rcj.js → chunk-j41nnny5.js} +2 -2
- package/dist/{chunk-c094c8jt.js → chunk-j60x598n.js} +3 -3
- package/dist/{chunk-8z4tvwyd.js → chunk-javyer70.js} +2 -2
- package/dist/chunk-ke1h5m7f.js +5 -0
- package/dist/chunk-kp395d2p.js +44 -0
- package/dist/{chunk-naweq349.js → chunk-mzw42cv7.js} +2 -2
- package/dist/chunk-n2fm08w5.js +2 -0
- package/dist/chunk-n73yp5s4.js +6 -0
- package/dist/{chunk-zf6qpv30.js → chunk-ne7q6jf2.js} +2 -2
- package/dist/{chunk-srbye4cm.js → chunk-ngb87w7x.js} +7 -7
- package/dist/{chunk-6yvk3q1e.js → chunk-nnayqrp5.js} +2 -2
- package/dist/chunk-p15wwraa.js +3 -0
- package/dist/{chunk-q8dtn1qf.js → chunk-pb7p64tn.js} +2 -2
- package/dist/chunk-peg2exva.js +3 -0
- package/dist/chunk-pjrnfmwm.js +3 -0
- package/dist/{chunk-fnncnk59.js → chunk-pkmjprad.js} +4 -4
- package/dist/{chunk-k2axmtyh.js → chunk-pq6j9bkd.js} +5 -5
- package/dist/chunk-r1t34d75.js +3 -0
- package/dist/chunk-r48h4anw.js +3 -0
- package/dist/chunk-r6bagvr6.js +18 -0
- package/dist/chunk-rnm8937h.js +3 -0
- package/dist/chunk-rv597vq5.js +3 -0
- package/dist/chunk-s7d3d1wx.js +3 -0
- package/dist/{chunk-hnjv8zsq.js → chunk-sqhmhd08.js} +2 -2
- package/dist/{chunk-6bsft59m.js → chunk-t5x9cy8y.js} +5 -5
- package/dist/chunk-t9w6e58q.js +22 -0
- package/dist/chunk-v0gpmwh9.js +8 -0
- package/dist/{chunk-8j311f4n.js → chunk-ves5kf6r.js} +4 -4
- package/dist/{chunk-4rchw3mn.js → chunk-veys7ggd.js} +4 -4
- package/dist/chunk-vjmwxye4.js +3 -0
- package/dist/chunk-war78wdt.js +22 -0
- package/dist/chunk-wfkkp4tx.js +29 -0
- package/dist/{chunk-qg691xj0.js → chunk-x4pxkg7c.js} +4 -4
- package/dist/chunk-xrtfb38p.js +14 -0
- package/dist/chunk-xz57d151.js +3 -0
- package/dist/chunk-y7bcjjqd.js +3 -0
- package/dist/{chunk-5af6meh8.js → chunk-yfgm2ccr.js} +2 -2
- package/dist/{chunk-ysgfcqvf.js → chunk-yje9ebc0.js} +4 -4
- package/dist/chunk-yjkhep5n.js +3 -0
- package/dist/{chunk-ppybvpk4.js → chunk-ykxeeekb.js} +3 -3
- package/dist/{chunk-5egg62em.js → chunk-ypbjr2b6.js} +3 -3
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.js +1 -1
- package/dist/src/branded-types.js +1 -1
- package/dist/src/bundle-linker.d.ts +4 -2
- 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.d.ts +2 -0
- package/dist/src/call-signatures.js +1 -1
- package/dist/src/circular.js +1 -1
- package/dist/src/compat.js +1 -1
- package/dist/src/computed-keys.js +1 -1
- package/dist/src/concurrency.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/dangling-refs.js +1 -1
- package/dist/src/declaration-project.d.ts +4 -2
- package/dist/src/declaration-project.js +1 -1
- package/dist/src/declaration-publication.d.ts +1 -1
- package/dist/src/declaration-publication.js +1 -1
- package/dist/src/declaration-references.js +1 -1
- package/dist/src/diff.js +1 -1
- package/dist/src/docs.js +1 -1
- package/dist/src/enum-declarations.js +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/extractor/directives.js +1 -1
- package/dist/src/extractor/extract.js +1 -1
- package/dist/src/extractor/hash.js +1 -1
- package/dist/src/extractor/scanner.d.ts +2 -0
- package/dist/src/extractor/scanner.js +1 -1
- package/dist/src/extractor.js +1 -1
- package/dist/src/formats.js +1 -1
- package/dist/src/formatter.js +1 -1
- package/dist/src/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/global-types.js +1 -1
- package/dist/src/import-sorter.d.ts +6 -6
- package/dist/src/import-sorter.js +1 -1
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.d.ts +5 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/initializer-type-spans.js +1 -1
- package/dist/src/json-config.js +1 -1
- package/dist/src/lexical.d.ts +3 -0
- package/dist/src/lexical.js +1 -1
- package/dist/src/logger.js +1 -1
- package/dist/src/lsp.js +1 -1
- package/dist/src/memory.js +1 -1
- package/dist/src/merger.js +1 -1
- package/dist/src/module-graph.d.ts +9 -3
- package/dist/src/module-graph.js +1 -1
- package/dist/src/module-references.d.ts +2 -0
- package/dist/src/module-references.js +1 -1
- package/dist/src/native-checker.js +1 -1
- package/dist/src/native-engine.d.ts +24 -0
- package/dist/src/native-engine.js +1 -1
- package/dist/src/native-extractor.js +1 -1
- package/dist/src/native-generation.js +1 -1
- package/dist/src/native-project.js +1 -1
- package/dist/src/numeric-literals.js +1 -1
- package/dist/src/optimizer.js +1 -1
- package/dist/src/output-normalizer.d.ts +5 -5
- package/dist/src/output-normalizer.js +1 -1
- package/dist/src/parallel-processor.js +1 -1
- package/dist/src/parameters.js +1 -1
- package/dist/src/parser.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsdown.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/dist/src/plugins.d.ts +2 -0
- package/dist/src/plugins.js +1 -1
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/cache.js +1 -1
- package/dist/src/processor/comments.js +1 -1
- package/dist/src/processor/declarations.js +1 -1
- package/dist/src/processor/import-usage.js +1 -1
- package/dist/src/processor/imports.d.ts +3 -1
- package/dist/src/processor/imports.js +1 -1
- package/dist/src/processor/index.js +1 -1
- package/dist/src/processor/type-inference.d.ts +27 -7
- package/dist/src/processor/type-inference.js +1 -1
- package/dist/src/processor.js +1 -1
- package/dist/src/profiling.js +1 -1
- package/dist/src/return-type-scope.js +1 -1
- package/dist/src/security.js +1 -1
- package/dist/src/source-cache.js +1 -1
- package/dist/src/sourcemap.js +1 -1
- package/dist/src/stx.js +1 -1
- package/dist/src/syntax-validator.js +1 -1
- package/dist/src/tracking.js +1 -1
- package/dist/src/transformers.js +1 -1
- package/dist/src/tree-shaker.js +1 -1
- package/dist/src/tsconfig.js +1 -1
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/vue.js +1 -1
- package/dist/src/watcher.js +1 -1
- package/dist/src/worker-thread.js +1 -1
- package/dist/src/worker.js +1 -1
- package/dist/src/workspace.js +1 -1
- package/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-3phg2e1n.js +0 -3
- package/dist/chunk-4tk9w4ms.js +0 -2
- package/dist/chunk-59q0p96t.js +0 -3
- package/dist/chunk-5ncggctz.js +0 -3
- package/dist/chunk-5t69y2qj.js +0 -18
- package/dist/chunk-5zcampnz.js +0 -3
- package/dist/chunk-6m4fpfzj.js +0 -31
- package/dist/chunk-6mg1pbfj.js +0 -19
- package/dist/chunk-6rxhkcx0.js +0 -3
- package/dist/chunk-6vhzmpy0.js +0 -8
- package/dist/chunk-7061vwkq.js +0 -4
- package/dist/chunk-72txgcxc.js +0 -3
- package/dist/chunk-93jzvstf.js +0 -3
- package/dist/chunk-9hz32qxh.js +0 -3
- package/dist/chunk-a018gbxq.js +0 -6
- package/dist/chunk-abe0mchv.js +0 -6
- package/dist/chunk-ctpxwa1v.js +0 -3
- package/dist/chunk-dc6thsdb.js +0 -3
- package/dist/chunk-f27fd50q.js +0 -3
- package/dist/chunk-fcx6r0m1.js +0 -22
- package/dist/chunk-fpbcgcwd.js +0 -6
- package/dist/chunk-fxx9zbtq.js +0 -3
- package/dist/chunk-g2s10ehd.js +0 -8
- package/dist/chunk-gzjccs8y.js +0 -27
- package/dist/chunk-h3m1vfa2.js +0 -5
- package/dist/chunk-jhjj15ey.js +0 -38
- package/dist/chunk-mzpbqdd2.js +0 -10
- package/dist/chunk-n8044s0h.js +0 -3
- package/dist/chunk-qhsgmwcm.js +0 -3
- package/dist/chunk-qxkvzznc.js +0 -3
- package/dist/chunk-r7qq9579.js +0 -7
- package/dist/chunk-rb602c8k.js +0 -21
- package/dist/chunk-rcmdt2gs.js +0 -3
- package/dist/chunk-rzjj16rb.js +0 -9
- package/dist/chunk-s28gyv8z.js +0 -3
- package/dist/chunk-s5rja20d.js +0 -3
- package/dist/chunk-szxyqpfq.js +0 -3
- package/dist/chunk-try1hmvs.js +0 -3
- package/dist/chunk-vdt9x6h8.js +0 -29
- package/dist/chunk-vej5fnnp.js +0 -3
- package/dist/chunk-w482p1x8.js +0 -14
- package/dist/chunk-y18th8yp.js +0 -3
- package/dist/chunk-ynpxjf6d.js +0 -4
- package/dist/chunk-ywzc3ym6.js +0 -40
- package/dist/chunk-z03w2v8h.js +0 -3
- package/dist/chunk-zddtg858.js +0 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{s}from"./chunk-vjmwxye4.js";import{h}from"./chunk-16rpzfwq.js";import{existsSync as v}from"fs";import{readFile as D}from"fs/promises";import{dirname as N,join as k,resolve as S}from"path";async function Si(e,o=process.cwd()){let i=new Map;for(let t of e){let n=S(o,t),r=await F(n,o);i.set(n,{path:n,dependencies:r,dependents:new Set,state:"pending"})}for(let[t,n]of i)for(let r of n.dependencies){let c=i.get(r);if(c)c.dependents.add(t)}return i}async function F(e,o){let i=new Set;try{let t=await D(e,"utf-8"),n=N(e);for(let r of s(t,e,!1)){let c=r.source;if(!c||!c.startsWith(".")&&!c.startsWith("/"))continue;let a=z(c,n,o);if(a)i.add(a)}}catch{}return i}function z(e,o,i){let t=S(o,e);if(/\.(?:ts|tsx|mts|cts)$/.test(e))return t.includes("node_modules")?null:t;let n=[".ts",".tsx",".mts",".cts"];for(let c of n){let a=`${t}${c}`;if(v(a))return a}for(let c of n){let a=k(t,`index${c}`);if(v(a))return a}let r=`${t}.ts`;return r.includes("node_modules")?null:r}function G(e){let o=[];for(let[i,t]of e){if(t.state!=="pending")continue;let n=!0;for(let r of t.dependencies){let c=e.get(r);if(c&&c.state!=="completed"){n=!1;break}}if(n)o.push(i)}return o}async function I(e,o={}){let i=await D(e,"utf-8"),t=o.keepComments??!0,n=s(i,e,t,o.isolatedDeclarations??!1);return h(n,{filePath:e,sourceCode:i,declarations:n},t,o.importOrder)}async function oo(e,o={}){let i=performance.now(),{maxConcurrency:t=4,rootDir:n=process.cwd(),config:r={},onProgress:c,onError:a}=o,p=await Si(e,n),x=new Map,m=new Map,w=[],P=0,g=0,u=0,b=p.size;while(u<b){let y=G(p);if(y.length===0){let l=[...p.values()].filter((d)=>d.state==="pending");if(l.length>0)for(let d of l)d.state="failed",d.error=Error("Circular dependency detected or dependency failed"),m.set(d.path,d.error),u++;break}let C=y.slice(0,t-g);for(let l of C){let d=p.get(l);d.state="processing",g++}P=Math.max(P,g);let E=C.map(async(l)=>{let d=p.get(l),M=performance.now();try{let f=await I(l,r);d.state="completed",d.result=f,d.duration=performance.now()-M,x.set(l,f),w.push(l)}catch(f){if(d.state="failed",d.error=f instanceof Error?f:Error(String(f)),d.duration=performance.now()-M,m.set(l,d.error),a&&!a(l,d.error))throw Error("Processing aborted by error handler")}finally{g--,u++,c?.(u,b,l)}});await Promise.all(E)}return{success:x,failed:m,totalTimeMs:performance.now()-i,maxConcurrent:P,processingOrder:w}}function ao(e){let o=[],i=new Set,t=new Set;function n(r){if(i.has(r))return;if(t.has(r))return;t.add(r);let c=e.get(r);if(c){for(let a of c.dependencies)if(e.has(a))n(a)}t.delete(r),i.add(r),o.push(r)}for(let r of e.keys())n(r);return o}function $i(e){let o=[];for(let[i,t]of e){let n=!1;for(let r of t.dependencies)if(e.has(r)){n=!0;break}if(!n)o.push(i)}return o}function ki(e){let o=[],i=new Set;while(i.size<e.size){let t=[];for(let[n,r]of e){if(i.has(n))continue;let c=!0;for(let a of r.dependencies)if(e.has(a)&&!i.has(a)){c=!1;break}if(c)t.push(n)}if(t.length===0){for(let n of e.keys())if(!i.has(n))t.push(n)}for(let n of t)i.add(n);o.push(t)}return o}function co(e){let o=ki(e),i=$i(e),t=Math.max(...o.map((r)=>r.length)),n=e.size/o.length;return{totalFiles:e.size,independentFiles:i.length,maxParallelism:t,levels:o.length,estimatedSpeedup:n}}
|
|
3
|
+
export{Si,oo,ao,$i,ki,co};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{p}from"./chunk-44a6zpxs.js";import{C}from"./chunk-b5wcbnb8.js";import{w}from"./chunk-cb5dj4qy.js";import{s}from"./chunk-vjmwxye4.js";import{Fe}from"./chunk-8t9qp0mq.js";function Ho(g){if(!g.includes("declare")||!g.includes("module"))return[];return C(g).filter((l)=>l.category==="augmentation").map((l)=>l.specifier)}function R(g,l){let m=new Set([g]);for(let S of m)for(let M of l(S))m.add(M);return m}async function Le(g,l,m=!1,S){let M=new Map,v=new Map;for(let t of g){let a=S?.get(t)??await p(t);M.set(t,a);let n=Ho(a);if(n.length)v.set(t,n)}let h=new Map;if(v.size===0)return h;let u=new Map,x=(t,a)=>{let n=l(t,a);if(n.resolved)return n.resolved;if(!n.isRelative&&!n.isAlias)return`external:${t}`;return};for(let[t,a]of M){let n=s(a,t,!1,m),c=Fe(n),d={edges:[],declarations:new Set,augmentations:new Set},o=(e,i,r)=>{let f=x(e.specifier,t);if(!f)return;if(M.has(f))d.edges.push({specifier:e.specifier,target:f,import:i});if(r)d.declarations.add(f)};for(let e of n){if(e.kind!=="import")continue;let i=e.isSideEffect||w(e.text).some((r)=>c.usedItems.has(r));for(let r of C(e.text))o(r,!0,!!i)}for(let e of C(c.referenceText))o(e,!1,!0);for(let e of v.get(t)??[]){let i=x(e,t);if(i)d.augmentations.add(i),d.declarations.add(i)}u.set(t,d)}let y=!0;while(y){y=!1;for(let[t]of u){let a=R(t,(c)=>u.get(c)?.declarations??[]),n;for(let[c,d]of u){if(a.has(c)||!d.augmentations.size||![...d.augmentations].some((o)=>a.has(o)))continue;if(!n){n=new Map;let o=[t],e=new Set([t]);for(let i of o)for(let r of u.get(i).edges){if(e.has(r.target))continue;e.add(r.target),n.set(r.target,{from:i,edge:r}),o.push(r.target)}}if(!n.has(c))continue;for(let o=c;o!==t;){let{from:e,edge:i}=n.get(o),r=u.get(e);if(i.import){let f=h.get(e);if(!f)f=new Set,h.set(e,f);f.add(i.specifier)}if(!r.declarations.has(o))r.declarations.add(o),y=!0;o=e}}}}return h}
|
|
3
|
+
export{Ho,Le};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var b=null,m=null;async function P(){if(b!==null)return b;try{return m=await import("prettier"),b=!0,!0}catch{return b=!1,!1}}async function y(t,n){if(!m)return null;try{if(n&&m.resolveConfig){let s=await m.resolveConfig(n);if(s)return s}if(t&&m.resolveConfig){let s=await m.resolveConfig(t);if(s)return s}return null}catch{return null}}async function w(t,n){if(!m)throw Error("Prettier is not available");let s={...n,parser:n.parser||"typescript"};return m.format(t,s)}function C(t,n={}){let{indentSize:s=2,useTabs:e=!1,maxLineWidth:i=100,trailingNewline:a=!0,normalizeWhitespace:u=!0,sortImports:o=!0,groupImports:l=!0}=n,r=t,c=e?"\t":" ".repeat(s);if(r.indexOf(`\r
|
|
3
|
+
`)!==-1)r=r.replace(/\r\n/g,`
|
|
4
|
+
`);if(u){if(/[ \t]\n/.test(r)||/[ \t]$/.test(r))r=r.replace(/[ \t]+$/gm,"");if(r.indexOf(`
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
`)!==-1)r=r.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`);r=I(r,c)}if(o||l)r=x(r,{sort:o,group:l});if(i>0)r=W(r,i,c);if(a&&!r.endsWith(`
|
|
10
|
+
`))r+=`
|
|
11
|
+
`;return r}function I(t,n){let s=t.split(`
|
|
12
|
+
`),e=[];for(let i of s){let a=i.match(/^(\s*)(.*)$/);if(!a){e.push(i);continue}let[,u,o]=a;if(!o){e.push("");continue}let l=u.replace(/\t/g," ").length,r=Math.floor(l/2);e.push(n.repeat(r)+o)}return e.join(`
|
|
13
|
+
`)}function x(t,n){let s=t.split(`
|
|
14
|
+
`),e=[],i=[],a=!1,u=0;for(let l=0;l<s.length;l++){let r=s[l],c=r.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(c){a=!0,u=l;let f=c[1];e.push({line:r,source:c[2],isType:f.startsWith("import type ")||f.startsWith("import type\t")})}else if(a&&r.trim()==="")continue;else{if(a)a=!1;i.push(r)}}if(e.length===0)return t;if(n.sort)e.sort((l,r)=>{if(l.isType!==r.isType)return l.isType?1:-1;return M(l.source,r.source)});let o;if(n.group){let l=[],r=[],c=[],f=[],h=[];for(let p=0;p<e.length;p++){let g=e[p],d=g.source;if(d.charCodeAt(0)===46)h.push(g);else if(d.startsWith("node:"))l.push(g);else if(d.charCodeAt(0)===64)f.push(g);else if(d.includes("/"))c.push(g);else r.push(g)}o=[...l.map((p)=>p.line),...l.length>0&&r.length>0?[""]:[],...r.map((p)=>p.line),...(l.length>0||r.length>0)&&c.length>0?[""]:[],...c.map((p)=>p.line),...f.length>0&&(l.length>0||r.length>0||c.length>0)?[""]:[],...f.map((p)=>p.line),...h.length>0?[""]:[],...h.map((p)=>p.line)]}else o=e.map((l)=>l.line);return[...o,"",...i].join(`
|
|
15
|
+
`)}function M(t,n){let s=t.startsWith("node:"),e=n.startsWith("node:");if(s!==e)return s?-1:1;let i=t.startsWith("."),a=n.startsWith(".");if(i!==a)return i?1:-1;return t.localeCompare(n)}function W(t,n,s){let e=t.split(`
|
|
16
|
+
`),i=[];for(let a of e){if(a.length<=n){i.push(a);continue}if(a.trimStart().startsWith("import ")){i.push(a);continue}let u=a.match(/^(\s*)/)?.[1]||"",o=u+s,l=O(a,u,o);if(l){i.push(...l);continue}if(a.includes("{")&&a.includes("}")){let r=k(a,n,u,o);i.push(...r);continue}if(a.includes(" | ")){let r=S(a,n,u,o);i.push(...r);continue}i.push(a)}return i.join(`
|
|
17
|
+
`)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(t,n,s){let e=t.match(F);if(!e)return null;let[,i,a,u,o]=e,l=u.split(",").map((f)=>f.trim()).filter(Boolean);if(l.length<=1)return[t];let r=`${n}${i}${a??""} {`,c=o?`${n}} ${o};`:`${n}};`;return[r,...l.map((f)=>`${s}${f},`),c]}function v(t,n){let s=[],e=0,i=0;for(let u=0;u<t.length;u++){let o=t[u];if(o==="'"||o==='"'||o==="`"){u++;while(u<t.length){if(t[u]==="\\"){u+=2;continue}if(t[u]===o)break;u++}continue}if(o==="("||o==="["||o==="{"||o==="<"){e++;continue}if(o===")"||o==="]"||o==="}"||o===">"&&t[u-1]!=="="){if(e>0)e--;continue}if(e===0&&(o===","||!n&&o===";")){let l=t.slice(i,u).trim();if(l)s.push(l);i=u+1}}let a=t.slice(i).trim();if(a)s.push(a);return s}function R(t){let n=-1,s=0;for(let e=0;e<t.length;e++){let i=t[e];if(i==="'"||i==='"'||i==="`"){e++;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===i)break;e++}continue}if(i==="{"){if(n===-1)n=e;s++}else if(i==="}"){if(s===0)return null;if(s--,s===0&&n!==-1)return{open:n,close:e}}}return null}function k(t,n,s,e){let i=R(t);if(!i)return[t];let a=t.slice(0,i.open).trimStart(),u=t.slice(i.open+1,i.close),o=t.slice(i.close),l=/\benum\s+/.test(a),r=v(u,l);if(r.length<=1)return[t];let c=l?",":";";return[`${s}${a}{`,...r.map((h)=>`${e}${h}${c}`),`${s}${o.trim()}`]}function S(t,n,s,e){let i=t.match(/^(\s*)(.*?=\s*)(.+)$/);if(!i)return[t];let[,,a,u]=i,o=u.split(/\s*\|\s*/).filter((r)=>r.trim());if(o.length<=2)return[t];return[`${s}${a}`,...o.map((r,c)=>`${e}${c>0?"| ":" "}${r.trim()}`)]}async function le(t,n={},s){let e=[];if(n.usePrettier!==!1){if(await P())try{let o={...await y(n.prettierConfigPath,s),...n.prettierOptions,parser:"typescript"};return{content:await w(t,o),usedPrettier:!0}}catch(u){e.push(`Prettier formatting failed: ${u}. Using built-in formatter.`)}else if(n.usePrettier===!0)e.push("Prettier requested but not available. Using built-in formatter.")}return{content:C(t,n.builtIn),usedPrettier:!1,warnings:e.length>0?e:void 0}}async function yi(t,n={}){let s=new Map;for(let[e,i]of t){let a=await le(i,n,e);s.set(e,a)}return s}function io(t={}){return{format:(n,s)=>le(n,t,s),formatMany:(n)=>yi(n,t)}}async function so(t){return(await le(t,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}
|
|
18
|
+
export{le,yi,io,so};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Y}from"./chunk-50r5qs7t.js";import{g}from"./chunk-j2bapmng.js";var p=100,c=new Map,a=new Map,u=new Map,h=0;function m(e,n,t){let r={fileName:e,text:n};c.delete(e),c.set(e,{file:r,hash:t});while(c.size>p){let s=c.keys().next().value;if(s===void 0)break;c.delete(s)}return r}function b(e,n,t){return u.set(e,(u.get(e)??0)+1),m(e,n,t)}function jt(e,n,t=g(n)){let r=c.get(e);if(r?.hash===t)return c.delete(e),c.set(e,r),r.file;return b(e,n,t)}async function pe(e,n,t={}){let r=g(n);if(c.get(e)?.hash===r)return jt(e,n,r);let o=`${e}\x00${String(r)}`,i=a.get(o);if(i)return i;let d=(u.get(e)??0)+1;u.set(e,d);let y=h,l;return l=Promise.resolve().then(async()=>{try{if(n.length>=(t.asyncThreshold??1e5))await new Promise((f)=>setTimeout(f,Math.max(0,t.yieldInterval??0)));if(y===h&&u.get(e)===d)return m(e,n,r);return{fileName:e,text:n}}finally{if(a.get(o)===l)a.delete(o)}}),a.set(o,l),l}async function Fn(e,n={}){let t=new Map,r=Y(n.concurrency,4);for(let s=0;s<e.length;s+=r){let o=await Promise.all(e.slice(s,s+r).map(async(i)=>({path:i.filePath,file:await pe(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function Bn(){h++,c.clear(),a.clear(),u.clear()}function _n(){return c.size}function jn(){return a.size}function Gn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
|
|
3
|
+
export{jt,pe,Fn,Bn,_n,jn,Gn};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ge}from"./chunk-4ce9a877.js";import{readFileSync as m,statSync as w}from"fs";import{readFile as y}from"fs/promises";import{createRequire as v}from"module";import{dirname as g,isAbsolute as b,join as u,resolve as p}from"path";function l(t){let o=[t];if(!t.endsWith(".json"))o.push(`${t}.json`);o.push(u(t,"tsconfig.json"));for(let a of o)try{if(w(a).isFile())return a}catch{}return null}function E(t,o){if(b(t)||t.startsWith("."))return l(p(g(o),t));let a=v(o),n=t.startsWith("@")?/^@[^/]+\/[^/]+/.exec(t)?.[0]:t.split("/")[0];if(n)for(let d of a.resolve.paths(n)??[]){let e=l(u(d,n,"package.json"));if(!e)continue;let i=JSON.parse(m(e,"utf8"));if(t===n){if(i.tsconfig!==void 0){if(typeof i.tsconfig!=="string")throw Error(`Invalid tsconfig field in ${e}`);let r=l(p(g(e),i.tsconfig));if(!r)throw Error(`Cannot resolve tsconfig ${JSON.stringify(i.tsconfig)} from ${e}`);return r}let s=l(u(g(e),"tsconfig.json"));if(s)return s}break}for(let d of[`${t}/tsconfig.json`,t])try{let e=a.resolve(d),i=e.endsWith(".json")?l(e):null;if(i)return i}catch{}return null}async function G(t,o={},a=new Set){let n=l(t);if(!n)return;if(a.has(n)){if(o.allowCircular)return;throw Error(`Circular tsconfig extends: ${n}`)}let d=new Set(a).add(n),e=JSON.parse(Ge(await y(n,"utf8"))),i=typeof e.extends==="string"?[e.extends]:e.extends??[];if(!Array.isArray(i)||i.some((f)=>typeof f!=="string"))throw Error(`Invalid tsconfig extends in ${n}`);let s={};for(let f of i){let c=E(f,n);if(!c)throw Error(`Cannot resolve tsconfig extends ${JSON.stringify(f)} from ${n}`);s={...s,...await G(c,o,d)}}let r=e.compilerOptions??{};if(r.isolatedDeclarations!==void 0)s.isolatedDeclarations=r.isolatedDeclarations;if(r.baseUrl!==void 0){if(typeof r.baseUrl!=="string")throw Error(`Invalid baseUrl in ${n}`);s.baseUrl=p(g(n),r.baseUrl)}if(r.paths!==void 0){if(!r.paths||typeof r.paths!=="object"||Array.isArray(r.paths))throw Error(`Invalid paths in ${n}`);for(let[f,c]of Object.entries(r.paths))if(f.split("*").length>2||!Array.isArray(c)||c.length===0||c.some((h)=>typeof h!=="string"||h.split("*").length>2))throw Error(`Invalid path mapping ${JSON.stringify(f)} in ${n}`);s.paths=r.paths,s.pathsBasePath=g(n)}return s}
|
|
3
|
+
export{G};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import O from"process";import{existsSync as z}from"fs";import{arch as R,platform as C}from"os";import{fileURLToPath as M}from"url";function te(n,t="engine"){if(n===void 0||n===null||n==="")return;if(n==="native"||n==="typescript")return n;throw Error(`Invalid ${t} ${JSON.stringify(n)}: expected "native" or "typescript"`)}var I,F=!1,W;function Ci(n){I=te(n)}function k(n){if(n==="native"||n==="typescript")return n;if(n!==void 0)return te(n)??"native";if(I!==void 0)return I;if(!F)W=te(O.env.DTSX_ENGINE,"DTSX_ENGINE"),F=!0;return W??"native"}var D;function j(){return`${C()==="win32"?"windows":C()}-${R()}`}function X(n){let t=[],e=O.env.DTSX_NATIVE_LIBRARY;if(e)t.push(e);for(let r of[`../native/${j()}/${n}`,`../../native/${j()}/${n}`,`../../zig-dtsx/zig-out/lib/${n}`,`../../zig-dtsx/zig-out/bin/${n}`])try{t.push(M(new URL(r,import.meta.url)))}catch{}return t}function G(){if(typeof globalThis.Bun>"u")return null;let n;try{n=import.meta.require("bun:ffi")}catch{return null}let{dlopen:t,FFIType:e,ptr:r,suffix:d,toArrayBuffer:f}=n,h=d==="dll"?`zig-dtsx.${d}`:`libzig-dtsx.${d}`;for(let u of X(h)){if(!z(u))continue;try{let g=t(u,{process_source_checked_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.ptr],returns:e.ptr},process_source_with_context_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.u64,e.ptr,e.ptr],returns:e.ptr},free_result:{args:[e.ptr,e.u64],returns:e.void}}),{symbols:o}=g,l=null;try{let y=t(u,{process_source_checked_v2:{args:[e.ptr,e.u64,e.bool,e.bool,e.i8,e.ptr,e.ptr],returns:e.ptr}}).symbols.process_source_checked_v2;l=(x,U,A,_,E,L,T)=>y(r(x),U,A,_,E,r(L),r(T))}catch{}let b=null;try{b=t(u,{process_source_into_v2:{args:[e.ptr,e.u64,e.bool,e.bool,e.i8,e.ptr,e.u64,e.ptr,e.ptr],returns:e.ptr}}).symbols.process_source_into_v2}catch{}let B=null,c=null;try{let i=t(u,{process_batch_checked_v2:{args:[e.ptr,e.ptr,e.u32,e.bool,e.bool,e.ptr,e.ptr,e.ptr,e.u32,e.ptr],returns:e.void},free_batch_results:{args:[e.ptr,e.ptr,e.u32],returns:e.void}});B=i.symbols.process_batch_checked_v2,c=i.symbols.free_batch_results}catch{}let a=new TextDecoder;return{checked:(i,y,x,U,A,_)=>o.process_source_checked_v1(r(i),y,x,U,r(A),r(_)),checkedV2:l,intoV2:b,batchV2:B,freeBatch:c,ptrOf:(i)=>r(i),contextual:(i,y,x,U,A,_,E,L)=>o.process_source_with_context_v1(r(i),y,x,U,r(A),_,r(E),r(L)),read:(i,y)=>{if(!i)return"";let x=y?a.decode(f(i,0,y)):"";return o.free_result(i,y),x},decode:(i)=>a.decode(i),decodePointer:(i,y)=>y?a.decode(f(i,0,y)):""}}catch{continue}}return null}function S(){if(D===void 0)D=G();return D}function vi(n){return k(n)==="native"&&S()!==null}var w=new TextEncoder,s=Buffer.allocUnsafe(1048576),p=Buffer.allocUnsafe(262144),N=Buffer.allocUnsafe(64),m=new BigUint64Array(N.buffer,N.byteOffset,1),v=new Uint32Array(N.buffer,N.byteOffset+8,1),H=typeof p.utf8Slice==="function",V=typeof s.utf8Write==="function";function P(n,t){return H?n.utf8Slice(0,t):n.toString("utf8",0,t)}function Tn(n,t,e,r,d){if(d==="typescript"||d!=="native"&&k(d)==="typescript")return null;let f=S();if(!f)return null;if(n.length===0)return"";let h=n.length*3;if(h>s.length)s=Buffer.allocUnsafe(h);let u=V?s.utf8Write(n,0):w.encodeInto(n,s).written;if(f.intoV2){let g=r===void 0?-1:r.endsWith(".tsx")||r.endsWith(".jsx")?1:0,o=f.intoV2(s,u,t,e,g,p,p.length,m,v),l=Number(m[0]);if(v[0]!==0){if(o)f.read(o,l);return null}if(o){let b=f.read(o,l);if(l>p.length)p=Buffer.allocUnsafe(l*2);return b}return l?P(p,l):""}return At(n,{keepComments:t,isolatedDeclarations:e,sourceFile:r,engine:d})}function At(n,t){if(t.engine==="typescript"||t.engine!=="native"&&k(t.engine)==="typescript")return null;let e=S();if(!e)return null;if(n.length*3>s.length)s=Buffer.allocUnsafe(n.length*3);let r=V?s.utf8Write(n,0):w.encodeInto(n,s).written,d=(t.inferenceSources?.size??0)>0||(t.augmentationImports?.size??0)>0;if(!d&&e.intoV2){let u=t.sourceFile===void 0?-1:t.sourceFile.endsWith(".tsx")||t.sourceFile.endsWith(".jsx")?1:0,g=e.intoV2(s,r,t.keepComments,t.isolatedDeclarations,u,p,p.length,m,v),o=Number(m[0]);if(v[0]!==0){if(g)e.read(g,o);return null}if(g){let l=e.read(g,o);if(o>p.length)p=Buffer.allocUnsafe(o*2);return l}return o?P(p,o):""}let f;if(d||t.sourceFile!==void 0&&!e.checkedV2){let u=t.sourceFile??"source.ts",g=w.encode(JSON.stringify({version:1,moduleSpecifierMode:"preserve",sourceFile:u,outputFile:u.replace(/\.(?:[cm]?[jt]sx?|vue|stx)$/,".d.ts"),sourceHash:new Bun.CryptoHasher("sha256").update(s.subarray(0,r)).digest("hex"),rewrites:[],augmentationImports:[...t.augmentationImports??[]],inferenceSources:[...t.inferenceSources??[]].map(([o,l])=>({specifier:o,source:l}))}));f=e.contextual(s,r,t.keepComments,t.isolatedDeclarations,g,g.length,m,v)}else if(e.checkedV2){let u=t.sourceFile===void 0?-1:t.sourceFile.endsWith(".tsx")||t.sourceFile.endsWith(".jsx")?1:0;f=e.checkedV2(s,r,t.keepComments,t.isolatedDeclarations,u,m,v)}else f=e.checked(s,r,t.keepComments,t.isolatedDeclarations,m,v);let h=Number(m[0]);if(v[0]!==0)return e.read(f,h),null;return e.read(f,h)}function Pn(n,t){if(n.length===0)return[];if(t.engine==="typescript"||t.engine!=="native"&&k(t.engine)==="typescript")return null;let e=S();if(!e||!e.batchV2||!e.freeBatch)return null;let r=n.length,d=1;for(let c=0;c<r;c++){let a=n[c].source;if(a.length>0)d+=a.length*3}if(d>s.length)s=Buffer.allocUnsafe(d);let f=BigInt(e.ptrOf(s)),h=new BigUint64Array(r),u=new BigUint64Array(r),g=new Int8Array(r),o=0;for(let c=0;c<r;c++){let a=n[c];if(h[c]=f+BigInt(o),g[c]=a.sourceFile===void 0?-1:a.sourceFile.endsWith(".tsx")||a.sourceFile.endsWith(".jsx")?1:0,a.source.length===0)u[c]=0n;else{let i=V?s.utf8Write(a.source,o):w.encodeInto(a.source,s.subarray(o)).written;u[c]=BigInt(i),o+=i}}let l=new BigUint64Array(r),b=new BigUint64Array(r),B=new Uint32Array(r);e.batchV2(h,u,r,t.keepComments,t.isolatedDeclarations,g,l,b,t.threadCount??0,B);try{let c=Array(r);for(let a=0;a<r;a++){if(B[a]!==0){c[a]=null;continue}let i=Number(b[a]);c[a]=i===0?"":e.decodePointer(Number(l[a]),i)}return c}finally{e.freeBatch(l,b,r)}}
|
|
3
|
+
export{te,Ci,k,vi,Tn,At,Pn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{l}from"./chunk-0zwa1tag.js";import{mkdtemp as y,readFile as v,realpath as a,rm as x}from"fs/promises";import{tmpdir as b}from"os";import{join as p,resolve as i}from"path";function wt(r={}){if(Reflect.get(r,"declarationMap"))throw Error("dtsx: bundled declaration maps are not supported");let u=new Map,c=(t,n)=>`${i(t)}\x00${n}`;return{name:"dtsx",tsdownConfig:()=>({dts:!1}),tsdownConfigResolved(t){u.set(c(i(t.cwd??process.cwd(),t.outDir??"dist"),t.format),t)},async generateBundle(t,n){let s=u.get(c(t.dir??"dist",t.format??"es"));if(!s)throw Error("dtsx: expected a resolved tsdown build before generating declarations");let f=await a(i(r.cwd??s.cwd??process.cwd())),m=await a(i(f,r.root??s.root)),d=await y(p(b(),"dtsx-tsdown-"));try{for(let e of Object.values(n)){if(e.type!=="chunk"||!e.isEntry||!e.facadeModuleId)continue;let w=await a(e.facadeModuleId),g=e.fileName.endsWith(".cjs")?".d.cts":e.fileName.endsWith(".mjs")?".d.mts":".d.ts",o=e.fileName.replace(/\.(?:c|m)?js$/,g);if(o===e.fileName)throw Error(`dtsx: unsupported tsdown JavaScript output ${e.fileName}`);if((await l({...r,cwd:f,root:m,entrypoints:[w],outdir:d,bundle:!0,bundleOutput:o,clean:!1,dryRun:!1,outputStructure:"mirror",declarationMap:!1,moduleSpecifierMode:r.moduleSpecifierMode??"node"})).filesFailed)throw Error(`dtsx: declaration generation failed for ${e.facadeModuleId}`);this.emitFile({type:"asset",fileName:o,source:await v(p(d,o),"utf8")})}}finally{await x(d,{recursive:!0,force:!0})}}}}var za=wt;
|
|
3
|
+
export{wt,za};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ge}from"./chunk-44a6zpxs.js";function M(n,t){let e=n.length,i=t.length,o=Array.from({length:e+1},()=>Array(i+1).fill(0));for(let s=1;s<=e;s++)for(let r=1;r<=i;r++)if(n[s-1]===t[r-1])o[s][r]=o[s-1][r-1]+1;else o[s][r]=Math.max(o[s-1][r],o[s][r-1]);return o}function S(n,t,e,i,o){let s=[];while(i>0||o>0)if(i>0&&o>0&&t[i-1]===e[o-1])s.unshift({op:"equal",oldIdx:i-1,newIdx:o-1,line:t[i-1]}),i--,o--;else if(o>0&&(i===0||n[i][o-1]>=n[i-1][o]))s.unshift({op:"add",newIdx:o-1,line:e[o-1]}),o--;else if(i>0)s.unshift({op:"remove",oldIdx:i-1,line:t[i-1]}),i--;return s}function k(n,t){let e=n;if(t.ignoreWhitespace)e=e.replace(/\s+/g," ").trim();return e}function Ot(n,t,e,i={}){let{context:o=3,ignoreWhitespace:s=!1,ignoreBlankLines:r=!1}=i,f=n.split(`
|
|
3
3
|
`),p=t.split(`
|
|
4
|
-
`);if(f[f.length-1]==="")f.pop();if(p[p.length-1]==="")p.pop();let d=f.map((l)=>k(l,{ignoreWhitespace:s})),a=p.map((l)=>k(l,{ignoreWhitespace:s})),c=d,g=a,w=f.map((l,x)=>x),m=p.map((l,x)=>x);if(r)c=[],g=[],w=[],m=[],d.forEach((l,x)=>{if(l.trim())c.push(l),w.push(x)}),a.forEach((l,x)=>{if(l.trim())g.push(l),m.push(x)});let F=M(c,g),b=S(F,c,g,c.length,g.length),B=b.every((l)=>l.op==="equal"),D=0,u=0,h=0;for(let l of b)if(l.op==="add")D++;else if(l.op==="remove")u++;else h++;let y=C(b,f,p,w,m,o);return{filePath:e,identical:B,hunks:y,stats:{additions:D,deletions:u,unchanged:h},oldContent:n,newContent:t}}function C(n,t,e,i,o,s){let r=[],f=[];if(n.forEach((a,c)=>{if(a.op!=="equal")f.push(c)}),f.length===0)return r;let p=[],d=[f[0]];for(let a=1;a<f.length;a++)if(f[a]-f[a-1]<=s*2+1)d.push(f[a]);else p.push(d),d=[f[a]];p.push(d);for(let a of p){let c=Math.max(0,a[0]-s),g=Math.min(n.length-1,a[a.length-1]+s),w=n.slice(c,g+1),m=[],F=1,b=1,B=0,D=0;for(let u=0;u<c;u++){let h=n[u];if(h.op==="equal"||h.op==="remove")F++;if(h.op==="equal"||h.op==="add")b++}for(let u of w)if(u.op==="equal")m.push(` ${u.line}`),B++,D++;else if(u.op==="remove")m.push(`-${u.line}`),B++;else if(u.op==="add")m.push(`+${u.line}`),D++;r.push({operation:"equal",lines:m,oldStart:F,oldCount:B,newStart:b,newCount:D})}return r}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
export{
|
|
4
|
+
`);if(f[f.length-1]==="")f.pop();if(p[p.length-1]==="")p.pop();let d=f.map((l)=>k(l,{ignoreWhitespace:s})),a=p.map((l)=>k(l,{ignoreWhitespace:s})),c=d,g=a,w=f.map((l,x)=>x),m=p.map((l,x)=>x);if(r)c=[],g=[],w=[],m=[],d.forEach((l,x)=>{if(l.trim())c.push(l),w.push(x)}),a.forEach((l,x)=>{if(l.trim())g.push(l),m.push(x)});let F=M(c,g),b=S(F,c,g,c.length,g.length),B=b.every((l)=>l.op==="equal"),D=0,u=0,h=0;for(let l of b)if(l.op==="add")D++;else if(l.op==="remove")u++;else h++;let y=C(b,f,p,w,m,o);return{filePath:e,identical:B,hunks:y,stats:{additions:D,deletions:u,unchanged:h},oldContent:n,newContent:t}}function C(n,t,e,i,o,s){let r=[],f=[];if(n.forEach((a,c)=>{if(a.op!=="equal")f.push(c)}),f.length===0)return r;let p=[],d=[f[0]];for(let a=1;a<f.length;a++)if(f[a]-f[a-1]<=s*2+1)d.push(f[a]);else p.push(d),d=[f[a]];p.push(d);for(let a of p){let c=Math.max(0,a[0]-s),g=Math.min(n.length-1,a[a.length-1]+s),w=n.slice(c,g+1),m=[],F=1,b=1,B=0,D=0;for(let u=0;u<c;u++){let h=n[u];if(h.op==="equal"||h.op==="remove")F++;if(h.op==="equal"||h.op==="add")b++}for(let u of w)if(u.op==="equal")m.push(` ${u.line}`),B++,D++;else if(u.op==="remove")m.push(`-${u.line}`),B++;else if(u.op==="add")m.push(`+${u.line}`),D++;r.push({operation:"equal",lines:m,oldStart:F,oldCount:B,newStart:b,newCount:D})}return r}function mo(n){if(n.identical)return"";let t=[];t.push(`--- a/${n.filePath}`),t.push(`+++ b/${n.filePath}`);for(let e of n.hunks)t.push(`@@ -${e.oldStart},${e.oldCount} +${e.newStart},${e.newCount} @@`),t.push(...e.lines);return t.join(`
|
|
5
|
+
`)}function Ti(n){if(n.identical)return`\x1B[32m\u2713 ${n.filePath} (unchanged)\x1B[0m`;let t=[],e=`+${n.stats.additions} -${n.stats.deletions}`;t.push(`\x1B[1m${n.filePath}\x1B[0m \x1B[90m(${e})\x1B[0m`),t.push("");for(let i of n.hunks){t.push(`\x1B[36m@@ -${i.oldStart},${i.oldCount} +${i.newStart},${i.newCount} @@\x1B[0m`);for(let o of i.lines)if(o.startsWith("+"))t.push(`\x1B[32m${o}\x1B[0m`);else if(o.startsWith("-"))t.push(`\x1B[31m${o}\x1B[0m`);else t.push(`\x1B[90m${o}\x1B[0m`);t.push("")}return t.join(`
|
|
6
|
+
`)}function ho(n){if(n.identical)return`${n.filePath}: unchanged`;return`${n.filePath}: +${n.stats.additions} -${n.stats.deletions} lines`}async function Pi(n,t,e={}){let i="";try{let o=ge(n);if(await o.exists())i=await o.text();else if(!e.treatMissingAsEmpty)return Ot("",t,n,e)}catch{if(!e.treatMissingAsEmpty)return Ot("",t,n,e)}return Ot(i,t,n,e)}async function go(n,t={}){let e=new Map;for(let[i,o]of n){let s=await Pi(i,o,t);e.set(i,s)}return e}function Di(n){let t=0,e=0,i=0,o=0,s=0;for(let r of n.values())if(r.identical)e++;else if(t++,i+=r.stats.additions,o+=r.stats.deletions,!r.oldContent)s++;return{totalFiles:n.size,changedFiles:t,unchangedFiles:e,totalAdditions:i,totalDeletions:o,newFiles:s}}function Ri(n){console.log(Ti(n))}function yo(n,t=!1){for(let i of n.values()){if(i.identical&&!t)continue;Ri(i)}let e=Di(n);if(console.log(""),console.log(`\x1B[1mSummary:\x1B[0m ${e.totalFiles} files, ${e.changedFiles} changed, ${e.unchangedFiles} unchanged`),e.changedFiles>0)console.log(` \x1B[32m+${e.totalAdditions}\x1B[0m \x1B[31m-${e.totalDeletions}\x1B[0m lines`);if(e.newFiles>0)console.log(` ${e.newFiles} new files`)}
|
|
7
|
+
export{Ot,mo,Ti,ho,Pi,go,Di,Ri,yo};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{n,m,x}from"./chunk-b5wcbnb8.js";import{Q}from"./chunk-30ffarqm.js";import{T}from"./chunk-cb5dj4qy.js";import{Kt}from"./chunk-5tcpge5e.js";import{me}from"./chunk-chj3hn6f.js";import{dirname as we,extname as Ce,join as Ae,relative as ee,resolve as ke}from"path";function de(e){if(!e.startsWith("declare")&&!(e.startsWith("export")&&e.includes("declare")))return;if(!e.includes("module")&&!e.includes("global"))return;let c=n(e),t=(s)=>c[s]?e.slice(c[s].start,c[s].end):"",i=t(0)==="export"?1:0;if(t(i++)!=="declare")return;let d;if(t(i)==="module"&&c[i+1]?.kind==="quoted"){if(d=m(t(i+1)),d===void 0)return;i+=2}else if(t(i++)!=="global")return;if(t(i)!=="{")return;let O=c[i].end,A=1;for(i++;i<c.length;i++)if(t(i)==="{")A++;else if(t(i)==="}"&&--A===0)return{specifier:d,body:e.slice(O,c[i].start),start:O,end:c[i].start};return}function $e(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36||e===64||e===47}function ae(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function V(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36}function xe(e){return e===32||e===9||e===10||e===13||e===12||e===11||e===65279}function Oa(e){let c=[],t=[],i=0,d=0,O=[],A=!1,s=0,w=e.length,v=(l)=>{let b=e.slice(i,l).trim();if(i=l,!b)return;if(Me(b)){t.push(b);return}c.push({text:b,comments:t}),t=[]};while(s<w){let l=e.charCodeAt(s);if(A){if(l===92){s+=2;continue}if(l===96){A=!1,s++;continue}if(l===36&&e.charCodeAt(s+1)===123){O.push(d),d++,A=!1,s+=2;continue}s++;continue}if(l===47){let b=e.charCodeAt(s+1);if(b===42){let g=e.indexOf("*/",s+2);s=g===-1?w:g+2;continue}if(b===47){let g=e.indexOf(`
|
|
3
|
+
`,s);s=g===-1?w:g;continue}}if(l===39||l===34){s++;while(s<w){let b=e.charCodeAt(s);if(b===l||b===10)break;if(b===92)s++;s++}s++;continue}if(l===96){A=!0,s++;continue}if(l===40||l===91||l===123){d++,s++;continue}if(l===41||l===93||l===125){if(d--,O.length>0&&l===125&&d===O[O.length-1])O.pop(),A=!0;s++;continue}if(d===0&&l===59){v(s+1),s++;continue}if(d===0&&l===10){if(s+1<w&&$e(e.charCodeAt(s+1))&&!Ee(e,s))v(s+1);s++;continue}s++}return v(w),c}var Oe=new Set(["extends","keyof","typeof","infer","readonly","is","asserts","unique","in","new"]);function Ee(e,c){let t=c-1;while(t>=0&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9||e.charCodeAt(t)===13))t--;if(t<0)return!1;let i=e.charCodeAt(t);if(i===124||i===38||i===63||i===58||i===61||i===44||i===46||i===43||i===45||i===60)return!0;if(i===62&&t>0&&e.charCodeAt(t-1)===61)return!0;if(V(i)){let d=t;while(d>0&&V(e.charCodeAt(d-1)))d--;if(Oe.has(e.slice(d,t+1)))return!0}return!1}function ue(e){if(e.length===0)return!1;for(let c=0;c<e.length;c++)if(!V(e.charCodeAt(c)))return!1;return!0}function re(e){if(ue(e))return e;if(e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")))return e;return x(e,'"')}function Me(e){let c=0;while(c<e.length){while(c<e.length&&xe(e.charCodeAt(c)))c++;if(c>=e.length)return!0;if(e.startsWith("//",c)){let t=e.indexOf(`
|
|
4
|
+
`,c);c=t===-1?e.length:t;continue}if(e.startsWith("/*",c)){let t=e.indexOf("*/",c+2);if(t===-1)return!0;c=t+2;continue}return!1}return!0}var Te=/^([\w$]+|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")(?:\s+as\s+([\w$]+|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))?$/;function Se(e){if(e.length===0||!ae(e.charCodeAt(0)))return!1;for(let c=1;c<e.length;c++)if(!V(e.charCodeAt(c)))return!1;return!0}function ye(e,c=!1){let t=[],i=e.includes("/*");for(let d of e.split(",")){let O=(i?d.replace(/\/\*[\s\S]*?\*\//g,""):d).trim();if(!O)continue;let A=c;if(O.startsWith("type")&&O.length>4&&O.charCodeAt(4)<=32){let w=O.slice(4).trimStart();if(!(w.startsWith("as")&&w.length>2&&w.charCodeAt(2)<=32)&&w.length>0)A=!0,O=w}if(Se(O)){t.push({local:O,exported:O,isTypeOnly:A});continue}let s=Te.exec(O);if(!s)continue;t.push({local:s[1],exported:s[2]??s[1],isTypeOnly:A})}return t}function ve(e){let c=e.length,t=0,i=()=>{while(t<c&&e.charCodeAt(t)<=32)t++},d=(b)=>{let g=b.length;if(t+g>c||!e.startsWith(b,t))return!1;if(t+g<c&&V(e.charCodeAt(t+g)))return!1;return t+=g,!0},O=!1;if(d("export")){if(t>=c||e.charCodeAt(t)>32)return null;O=!0,i()}let A=!1;if(d("default")){if(t>=c||e.charCodeAt(t)>32)return null;A=!0,i()}if(d("declare")){if(t>=c||e.charCodeAt(t)>32)return null;i()}if(d("abstract")){if(t>=c||e.charCodeAt(t)>32)return null;i()}let s=!1,w=t<c?e.charCodeAt(t):0;if(w===99){if(d("const")){let b=t;if(i(),!d("enum"))t=b;s=!0}else if(d("class"))s=!0}else if(w===105&&d("interface"))s=!0;else if(w===116&&d("type"))s=!0;else if(w===102&&d("function")){if(i(),t<c&&e.charCodeAt(t)===42)t++;s=!0}else if(w===97&&d("async")){if(i(),d("function")){if(i(),t<c&&e.charCodeAt(t)===42)t++;s=!0}}else if(w===101&&d("enum"))s=!0;else if(w===110&&d("namespace"))s=!0;else if(w===109&&d("module"))s=!0;else if(w===108&&d("let"))s=!0;else if(w===118&&d("var"))s=!0;if(!s)return null;i();let v=t;while(t<c&&V(e.charCodeAt(t)))t++;let l=t>v?e.slice(v,t):null;return{isExported:O,isDefault:A,name:l??(A?"_default":null)}}function We(e,c){let t=e;if(t.startsWith("export")&&t.length>6&&t.charCodeAt(6)<=32){let d=7;while(d<t.length&&t.charCodeAt(d)<=32)d++;t=t.slice(d)}if(t.startsWith("default")&&t.length>7&&t.charCodeAt(7)<=32){let d=8;while(d<t.length&&t.charCodeAt(d)<=32)d++;t=t.slice(d),t=t.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(O,A)=>`${A.trimEnd()} ${c}`)}if(t.startsWith("declare")&&(t.length===7||!V(t.charCodeAt(7)))||t.startsWith("interface")&&(t.length===9||!V(t.charCodeAt(9)))||t.startsWith("type")&&(t.length===4||!V(t.charCodeAt(4))))return t;return`declare ${t}`}function oe(e,c,t=!1){let i={file:e,declarations:[],declared:new Set,imports:new Map,localExports:new Map,localExportTypeOnly:new Set,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],augmentations:[],directives:[]},d=t?Kt(c,e).map((A)=>({text:A.text,comments:[...A.leadingComments??[]]})):Oa(c),O;for(let A of d){if(A.comments.length>0)A.comments=A.comments.filter((l)=>{if(l.startsWith("///")&&/^\/\/\/\s*</.test(l))return i.directives.push(...l.split(`
|
|
5
|
+
`).map((b)=>b.trim()).filter((b)=>b.startsWith("///"))),!1;return!0});let s=A.text.trim();if(s.endsWith(";"))s=s.slice(0,-1).trimEnd();if(s.startsWith("import")){let l=T(s);if(l&&!l.isImportEquals){let g=l.source;if(l.defaultName)i.imports.set(l.defaultName,{specifier:g,imported:"default",isTypeOnly:l.isTypeOnly});if(l.namespaceName)i.imports.set(l.namespaceName,{specifier:g,imported:"*",isTypeOnly:l.isTypeOnly});for(let B of l.namedItems)i.imports.set(B.name,{specifier:g,imported:/^['"]/.test(B.originalName)?m(B.originalName):B.originalName,isTypeOnly:l.isTypeOnly||B.isTypeOnly});continue}if(/^import\s+['"]/.test(s)){i.verbatim.push(A);continue}let b=/^import\s+([\w$]+)\s*=\s*(?!require\s*\()/.exec(s);if(b){let g=b[1];i.declared.add(g),i.declarations.push({statement:A,name:g,emit:A.text});continue}}if(s.startsWith("export")&&s.length>6&&s.charCodeAt(6)<=32){let l=7;while(l<s.length&&s.charCodeAt(l)<=32)l++;let b=s.charCodeAt(l);if(b===42||b===123||b===116||b===100||b===105)if(b===105){let g=/^export\s+import\s+([\w$]+)\s*=\s*(?!require\s*\()/.exec(s);if(g){let B=g[1];i.declared.add(B),i.localExports.set(B,B),i.declarations.push({statement:A,name:B,emit:A.text.replace(/^export\s+/,"")});continue}}else if(b===100){let g=s.match(/^export\s+default\s+([\w$]+)$/);if(g&&ae(g[1].charCodeAt(0))){i.localExports.set("default",g[1]);continue}}else{let g=l,B=!1;if(b===116&&s.startsWith("type",g)&&g+4<s.length&&s.charCodeAt(g+4)<=32){let R=g+5;while(R<s.length&&s.charCodeAt(R)<=32)R++;let _=s.charCodeAt(R);if(_===42||_===123)B=!0,g=R}let P=s.charCodeAt(g);if(P===123){let R=s.indexOf("}",g+1);if(R!==-1){let _=s.slice(g+1,R),L=R+1;while(L<s.length&&s.charCodeAt(L)<=32)L++;if(L===s.length){for(let h of ye(_,B))if(i.localExports.set(h.exported,h.local),h.isTypeOnly)i.localExportTypeOnly.add(h.exported);continue}if(s.startsWith("from",L)&&L+4<s.length&&s.charCodeAt(L+4)<=32){let h=L+5;while(h<s.length&&s.charCodeAt(h)<=32)h++;let I=s.charCodeAt(h);if(I===39||I===34){let M=s.indexOf(I===39?"'":'"',h+1);if(M!==-1){let D=s.slice(h+1,M);for(let z of ye(_,B))i.namedReExports.push({specifier:D,imported:z.local,exported:z.exported,isTypeOnly:z.isTypeOnly});continue}}}}}else if(P===42){let R=s.match(/^export\s+(type\s+)?\*\s+as\s+([\w$]+|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")\s+from\s+(['"])([^'"]+)\3/);if(R){i.namespaceReExports.push({specifier:R[4],exported:R[2],isTypeOnly:Boolean(R[1])});continue}if(R=s.match(/^export\s+(type\s+)?\*\s+from\s+(['"])([^'"]+)\2/),R){i.starReExports.push({specifier:R[3],isTypeOnly:Boolean(R[1])});continue}}}}let w=de(s);if(w?.specifier!==void 0&&(O??=Q(c))){i.augmentations.push({statement:A,specifier:w.specifier,body:w.body});continue}if(/^export\s+as\s+namespace\b/.test(s)||w){i.verbatim.push(A);continue}let v=ve(s);if(v&&v.name){let l=v.name;if(i.declared.add(l),v.isExported)i.localExports.set(v.isDefault?"default":l,l);i.declarations.push({statement:A,name:l,emit:We(A.text,l)});continue}i.declarations.push({statement:A,name:null,emit:A.text})}return i}var Ie=new Set(["readonly","static","public","protected","private","abstract","override","accessor","get","set","async","declare"]),be=new WeakMap;function Be(e,c){if(c.size<=16){for(let w of c.keys())if(e.includes(w))return!0;return!1}let t=be.get(c);if(!t){let w=new Uint8Array(128),v=!1,l=Number.POSITIVE_INFINITY,b=0;for(let g of c.keys()){if(g.length===0)continue;let B=g.charCodeAt(0);if(B<128)w[B]=1;else v=!0;if(!v){for(let P=1;P<g.length;P++)if(g.charCodeAt(P)>=128){v=!0;break}}if(g.length<l)l=g.length;if(g.length>b)b=g.length}t={firstAscii:w,hasNonAscii:v,minLen:l,maxLen:b},be.set(c,t)}let{firstAscii:i,hasNonAscii:d,minLen:O,maxLen:A}=t;if(d)return!0;let s=e.length;if(s<O)return!1;for(let w=0;w<s;){let v=e.charCodeAt(w);if(!ae(v)){w++;continue}let l=w++;while(w<s&&V(e.charCodeAt(w)))w++;let b=w-l;if(b>=O&&b<=A&&i[v]===1){if(c.has(e.slice(l,w)))return!0}}return!1}function pt(e,c){if(c.size===0||!Be(e,c))return e;let t=e.includes("<"),i=e.includes("namespace")||e.includes("module"),d=e.includes("`"),O,A;if(t||i||d){let h=n(e),I=h.length;if(d){for(let M=0;M<I;M++)if(h[M].kind==="literal")O??=new Map,O.set(h[M].start,h[M].end)}if(t||i){let M=Array(I);for(let y=0;y<I;y++)M[y]=e.slice(h[y].start,h[y].end);let D=(y)=>y>=0&&y<I?M[y]:"",z=new Int32Array(I).fill(-1),K=[];for(let y=0;y<I;y++){let E=M[y];if(E.length===1){if(E==="("||E==="["||E==="{"||E==="<")K.push(y);else if((E===")"||E==="]"||E==="}"||E===">")&&!(E===">"&&D(y-1)==="=")){let N=K.length>0?K[K.length-1]:-1;if(N!==-1){let F=M[N];if(F==="("&&E===")"||F==="["&&E==="]"||F==="{"&&E==="}"||F==="<"&&E===">")K.pop(),z[N]=y}}}}let te=(y)=>{for(let E=y;E<I;E++){let N=M[E];if(N===";"||N===","||N===")"||N==="]"||N==="}"||N===">"&&D(E-1)!=="=")return E;let F=z[E];if(F!==-1)E=F}return I};if(t)for(let y=0;y<I;y++){if(M[y]!=="<")continue;let E=z[y];if(E===-1)continue;let N=D(y-2),F=N==="class"||N==="interface"||N==="type";if(!F&&D(E+1)!=="(")continue;let U=new Set;for(let u=y+1;u<E;u++){if(u===y+1||D(u-1)===","){while(u<E&&(M[u]==="const"||M[u]==="in"||M[u]==="out"))u++;if(u<E&&h[u].kind==="word"&&c.has(M[u]))U.add(M[u])}let q=z[u];if(q!==-1)u=q}if(U.size===0)continue;let G=te(E+1);if(F&&N!=="type")for(let u=E+1;u<I;u++){if(M[u]==="{"){let H=z[u];if(H!==-1)G=H;break}let q=z[u];if(q!==-1)u=q}for(let u=y+1;u<G;u++){let q=N==="class"&&u>E&&D(u-1)==="extends";if(U.has(M[u])&&D(u-1)!=="typeof"&&!q)A??=new Set,A.add(h[u].start)}}if(i)for(let y=0;y<I;y++){let E=M[y];if(E!=="namespace"&&E!=="module"||h[y+1]?.kind!=="word"||D(y+2)!=="{")continue;let N=z[y+2];if(N===-1)continue;let F=Kt(e.slice(h[y+2].end,h[N].start),"bundle-namespace.ts"),U=new Set,G=new Set;for(let u of F){if(!c.has(u.name))continue;if(u.kind==="class"||u.kind==="interface"||u.kind==="type"||u.kind==="enum"||u.kind==="module"||u.kind==="namespace")U.add(u.name);if(u.kind==="class"||u.kind==="variable"||u.kind==="function"||u.kind==="enum"||u.kind==="module"||u.kind==="namespace")G.add(u.name)}if(U.size===0&&G.size===0)continue;for(let u=y+3;u<N;u++)if((D(u-1)==="typeof"?G:U).has(M[u]))A??=new Set,A.add(h[u].start)}}}let s="",w=0,v=0,l=e.length,b=10,g=59,B=!0,P=!1,R=!1,_=[],L=[];while(v<l){if(O!==void 0){let I=O.get(v);if(I!==void 0){v=I,b=96,g=96,B=!1,P=!1;continue}}let h=e.charCodeAt(v);if(h===47){let I=e.charCodeAt(v+1);if(I===42){let M=e.indexOf("*/",v+2);v=M===-1?l:M+2;continue}if(I===47){let M=e.indexOf(`
|
|
6
|
+
`,v);v=M===-1?l:M;continue}}if(h===39||h===34){let I=v+1;while(I<l){let M=e.charCodeAt(I);if(M===h||M===10)break;if(M===92)I++;I++}v=I+1,b=h,g=h,B=!1,P=!1;continue}if(ae(h)){let I=v+1;while(I<l&&V(e.charCodeAt(I)))I++;let M=e.slice(v,I),D=c.get(M),z=_.length>0?_[_.length-1]:0,K=L.length>0&&L[L.length-1],te=B&&Ie.has(M);if(M==="enum")R=!0;if(D!==void 0&&b!==46&&!A?.has(v)){let y=I;while(y<l&&(e.charCodeAt(y)===32||e.charCodeAt(y)===9))y++;let E=e.charCodeAt(y),N=B&&K,F=B&&(E===58||E===63&&e.charCodeAt(y+1)===58),U=E===105&&y+1<l&&e.charCodeAt(y+1)===115&&(y+2===l||!V(e.charCodeAt(y+2))),G=P||(b===58||b===62)&&U,u=!1;if(B&&z===123&&!K){if(E===40||E===63&&e.charCodeAt(y+1)===40)u=!0;else if(E===60||E===63&&e.charCodeAt(y+1)===60){let q=1,H=E===60?y+1:y+2;while(H<l&&q>0){let X=e.charCodeAt(H);if(X===60)q++;else if(X===62&&e.charCodeAt(H-1)!==61)q--;H++}while(H<l&&(e.charCodeAt(H)===32||e.charCodeAt(H)===9))H++;if(q===0&&e.charCodeAt(H)===40)u=!0}}if(!N&&!F&&!u&&!G)s+=e.slice(w,v)+D,w=I}P=(b===58||b===62)&&M==="asserts",b=97,g=97,B=te,v=I;continue}if(h===123||h===40||h===91){if(_.push(h),L.push(h===123&&R),h===123)R=!1;b=h,g=h,B=h===123||h===40,P=!1}else if(h===125||h===41||h===93){if(_.length>0)_.pop();if(L.length>0)L.pop();b=h,g=h,B=h===125,P=!1}else if(h===10){if(b=10,g===123||g===59||g===44||g===40||g===125)B=!0}else if(!xe(h))b=h,g=h,B=h===59||h===44,P=!1;v++}return w===0?e:s+e.slice(w)}function sr(e,c,t,i){let d=[],O=new Map,A=[e,...c.filter((r)=>r!==e)];for(let r of A){let o=t.get(r);if(o===void 0){d.push(`No declarations were generated for ${ee(i.cwd,r)}; it is left out of the bundle`);continue}O.set(r,oe(r,o))}let s=new Map,w=new Map,v=i.cwd.endsWith("/")||i.cwd.endsWith("\\")?i.cwd:`${i.cwd}/`,l=(r)=>r.startsWith(v)?r.slice(v.length):ee(i.cwd,r),b=[".ts",".tsx",".mts",".cts",".d.ts",".d.mts",".d.cts"],g={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]},B=(r,o)=>{if(!r.startsWith(".")&&!r.startsWith("/"))return null;let a=`${o}\x00${r}`,k=s.get(a);if(k!==void 0)return k;let S=r.includes("?")||r.includes("#")?r.replace(/[?#].*$/,""):r,p=w.get(o);if(p===void 0)p=we(o),w.set(o,p);let f=S.startsWith("./")&&S.indexOf("/",2)===-1&&S!=="./."&&S!=="./.."?`${p}/${S.slice(2)}`:ke(p,S),C=null;if(O.has(f))C=f;else{let W=Ce(f),j=g[W];if(j){let Y=f.slice(0,-W.length);for(let Z of j){let ge=Y+Z;if(O.has(ge)){C=ge;break}}}if(!C)for(let Y of b){let Z=f+Y;if(O.has(Z)){C=Z;break}}if(!C)for(let Y of b){let Z=Ae(f,`index${Y}`);if(O.has(Z)){C=Z;break}}}if(!C){let W=(i.resolver?i.resolver(r,o):me(r,o)).resolved;C=W&&O.has(W)?W:null}return s.set(a,C),C},P=(r)=>r.startsWith(".")||r.startsWith("/"),R=new Set,_=(r)=>{let o=r;for(let a=1;R.has(o);a++)o=`${r}_${a}`;return R.add(o),o},L=new Map;for(let[r,o]of O){let a=new Map;for(let k of o.declared)a.set(k,_(k));L.set(r,a)}let h=new Map,I=(r,o,a,k=!1)=>{let S=`${r}\x00${o}`,p=h.get(S);if(!p){let f=ue(a)?a:"_ext";p={local:_(f),isTypeOnly:k},h.set(S,p)}else if(!k)p.isTypeOnly=!1;return p.local},M=new Map,D=new Map,z=new Set,K=new Map,te=!0,y=(r,o,a,k=!1)=>{let S=B(o,r.file);if(S){if(a==="*")return{kind:"namespace",file:S};let p=N(S).get(a);if(!p&&!te)d.push(`${ee(i.cwd,r.file)}: '${a}' is not exported by '${o}'`);return p??null}if(P(o))return d.push(`${ee(i.cwd,r.file)}: '${o}' is not part of the bundle`),null;return a==="*"?{kind:"external-namespace",source:o,isTypeOnly:k}:{kind:"external",source:o,imported:a,isTypeOnly:k}},E=(r,o)=>{if(r.declared.has(o))return{kind:"local",name:L.get(r.file).get(o)};let a=r.imports.get(o);if(a)return y(r,a.specifier,a.imported,a.isTypeOnly);return d.push(`${ee(i.cwd,r.file)}: cannot resolve exported name '${o}'`),null};function N(r){let o=M.get(r);if(o)return o;let a=new Map,k=O.get(r);if(!k||z.has(r))return a;z.add(r);let S=new Map,p=(f,C)=>{if(S.get(f)===void 0)S.set(f,C);else if(!C)S.set(f,!1)};for(let[f,C]of k.localExports){let W=E(k,C);if(!W)continue;if(k.localExportTypeOnly.has(f)&&(W.kind==="external"||W.kind==="external-namespace"))a.set(f,{...W,isTypeOnly:!0});else a.set(f,W)}for(let f of k.namedReExports){let C=y(k,f.specifier,f.imported,f.isTypeOnly);if(C)a.set(f.exported,C)}for(let f of k.namespaceReExports){let C=y(k,f.specifier,"*",f.isTypeOnly);if(C)a.set(f.exported,C)}for(let f of k.starReExports){let C=B(f.specifier,r);if(C){for(let[W,j]of N(C))if(W!=="default"&&!a.has(W))a.set(W,j);for(let[W,j]of D.get(C)??[])p(W,f.isTypeOnly||j)}else if(P(f.specifier))d.push(`${ee(i.cwd,r)}: '${f.specifier}' is not part of the bundle`);else p(f.specifier,f.isTypeOnly)}for(let[f,C]of K.get(r)??[])a.set(f,C);return z.delete(r),M.set(r,a),D.set(r,S),a}let F=new Map;for(let[r,o]of O)for(let a of o.augmentations){let k=B(a.specifier,r);if(!k)continue;let S=oe(r,a.body,!0);F.set(a,S);let p=N(k),f=!1;for(let C of S.declared){if(p.has(C))continue;let W=K.get(k);if(!W)W=new Map,K.set(k,W);if(!W.has(C))W.set(C,{kind:"local",name:_(C)}),f=!0}if(f)M.clear()}te=!1,M.clear(),D.clear();let U=new Map,G=[],u=(r,o)=>{switch(r.kind){case"local":return r.name;case"external":return I(r.source,r.imported,r.imported==="default"?o:r.imported,Boolean(r.isTypeOnly));case"external-namespace":return I(r.source,"*",o,Boolean(r.isTypeOnly));case"namespace":return q(r.file,o)}};function q(r,o){let a=U.get(r);if(a)return a;let k=ue(o)?o:"_ns",S=_(k);U.set(r,S);let p=[];for(let[f,C]of N(r)){let W=u(C,f==="default"?"_default":f),j=re(f);p.push(W===j?j:`${W} as ${j}`)}if(D.get(r)?.size)d.push(`${ee(i.cwd,r)}: 'export * from' an external module cannot be expressed inside namespace '${S}'`);return G.push(`declare namespace ${S} {
|
|
7
|
+
export { ${p.join(", ")} };
|
|
8
|
+
}`),S}let H=[],X=[],le=new Set,pe=new Map;for(let[r,o]of O){for(let p of o.directives)le.add(p);let a=null;for(let[p,f]of L.get(r))if(p!==f){if(!a)a=new Map;a.set(p,f)}if(o.declarations.length>0||o.verbatim.length>0||o.augmentations.length>0)for(let[p,f]of o.imports){if(o.declared.has(p))continue;let C=y(o,f.specifier,f.imported,f.isTypeOnly);if(!C)continue;let W=u(C,p);if(W!==p){if(!a)a=new Map;a.set(p,W)}}let S=[];for(let p of o.declarations){if(i.keepComments&&p.statement.comments.length>0)S.push(...p.statement.comments);let f=a?pt(p.emit,a):p.emit,C=f.charCodeAt(f.length-1);if(C!==59&&C!==125)f+=";";S.push(f)}for(let p of o.verbatim){if(i.keepComments)X.push(...p.comments);let f=de(p.text);if(f){let C=a?new Map(a):pe;if(a)for(let W of oe(r,f.body,!0).declared)C.delete(W);X.push(p.text.slice(0,f.start)+(C.size>0?pt(f.body,C):f.body)+p.text.slice(f.end))}else{let C=n(p.text),W=C[1]?.kind==="quoted"?m(p.text.slice(C[1].start,C[1].end)):void 0;if(W===void 0||!B(W,r))X.push(a?pt(p.text,a):p.text)}}for(let p of o.augmentations){let f=B(p.specifier,r),C=F.get(p)??oe(r,p.body,!0),W=new Map(a??pe);if(!f){for(let Y of C.declared)W.delete(Y);let j=de(p.statement.text);if(i.keepComments)X.push(...p.statement.comments);X.push(p.statement.text.slice(0,j.start)+pt(j.body,W)+p.statement.text.slice(j.end));continue}for(let[j,Y]of N(f))W.set(j,u(Y,j));if(i.keepComments)S.push(...p.statement.comments);for(let j of C.declarations){if(!j.name||!N(f).has(j.name))throw Error(`Cannot link augmentation '${p.specifier}' member '${j.name??j.emit}'`);if(i.keepComments)S.push(...j.statement.comments);S.push(pt(j.emit,W))}}if(S.length>0)H.push(`// From: ${l(r)}
|
|
9
|
+
${S.join(`
|
|
10
|
+
`)}`)}let he=N(e),ce=[],ie=[];for(let[r,o]of he){let a=re(r);if(o.kind==="external"){let S=o.isTypeOnly?"export type":"export",p=re(o.imported);ie.push(`${S} { ${o.imported===r?a:`${p} as ${a}`} } from '${o.source}';`);continue}if(o.kind==="external-namespace"){let S=o.isTypeOnly?"export type":"export";ie.push(`${S} * as ${a} from '${o.source}';`);continue}let k=u(o,r==="default"?"_default":r);ce.push(k===a?a:`${k} as ${a}`)}for(let[r,o]of D.get(e)??[])ie.push(`${o?"export type":"export"} * from '${r}';`);let fe=new Map;for(let[r,o]of h){let[a,k]=r.split("\x00"),S=fe.get(a)??{named:[],defaults:[],namespaces:[]};if(fe.set(a,S),k==="*")S.namespaces.push(o);else if(k==="default")S.defaults.push(o);else{let p=re(k);S.named.push({text:k===o.local&&p===o.local?o.local:`${p} as ${o.local}`,isTypeOnly:o.isTypeOnly})}}let ne=[];for(let[r,o]of[...fe].sort(([a],[k])=>a.localeCompare(k))){for(let a of o.defaults)ne.push(`${a.isTypeOnly?"import type":"import"} ${a.local} from '${r}';`);for(let a of o.namespaces)ne.push(`${a.isTypeOnly?"import type":"import"} * as ${a.local} from '${r}';`);if(o.named.length>0)if(o.named.every((k)=>k.isTypeOnly))ne.push(`import type { ${o.named.map((k)=>k.text).join(", ")} } from '${r}';`);else ne.push(`import { ${o.named.map((k)=>k.isTypeOnly?`type ${k.text}`:k.text).join(", ")} } from '${r}';`)}let J=[];if(le.size>0)J.push([...le].join(`
|
|
11
|
+
`));if(J.push(`/**
|
|
12
|
+
* Bundled TypeScript declarations
|
|
13
|
+
* Generated from ${O.size} source files
|
|
14
|
+
*/`),ne.length>0)J.push(ne.join(`
|
|
15
|
+
`));if(J.push(...H),G.length>0)J.push(G.join(`
|
|
16
|
+
`));if(X.length>0)J.push(X.join(`
|
|
17
|
+
`));let se=[];if(ce.length>0)se.push(`export { ${ce.join(", ")} };`);if(se.push(...ie),se.length===0)se.push("export {};");return J.push(se.join(`
|
|
18
|
+
`)),{content:`${J.join(`
|
|
19
|
+
|
|
20
|
+
`)}
|
|
21
|
+
`,files:[...O.keys()],exportCount:he.size,warnings:d}}
|
|
22
|
+
export{Oa,pt,sr};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Le}from"./chunk-r48h4anw.js";import{e}from"./chunk-bd048mjd.js";import{he,re}from"./chunk-chj3hn6f.js";import{existsSync as D,statSync as F}from"fs";import{basename as C,dirname as M,extname as O,isAbsolute as b,relative as y,resolve as g}from"path";var{Glob:P}=globalThis.Bun;async function Ne(t,n){let o=await _(t);W(t,o);let r=o.slice(),a=await(n?n():he(t)),s=null;if(t.autoIncludeReExports!==!1&&r.length>0){s=await re(r,{includeImports:!0,resolveSpecifier:a});let f=g(t.cwd,t.root),h=t.exclude||[],w=new Set(r),m=[];for(let d of s.reachable){if(w.has(d))continue;if(!j(d))continue;if(d.endsWith(".d.ts"))continue;if(d.includes("node_modules"))continue;let x=t.outputStructure==="flat"&&o.some((v)=>a.isPackageLocal?.(v,d));if(!R(d,f)&&!x){e.warn(`Skipping auto-included source outside root: ${y(t.cwd,d)}`);continue}if(ne(d,h,f))continue;m.push(d)}if(m.length>0)r=[...r,...m],e.debug(`Auto-included ${m.length} file(s) reached via relative re-exports`)}let i=J(r,t),l=s??await re(r,{includeImports:!0,resolveSpecifier:a}),c=await Le([...l.sources.keys()],a,t.isolatedDeclarations??!1,l.sources),p=new Set(r);for(let[f,h]of c){if(!p.has(f))continue;for(let w of h){let m=a(w,f).resolved;if(m&&!p.has(m))throw Error(`Module augmentation import ${JSON.stringify(w)} from ${f} requires a source not emitted by this package build: ${m}`)}}let u=[...c].map(([f,h])=>[f,[...h].sort()]).sort(([f],[h])=>f.localeCompare(h));return Object.freeze({entryFiles:Object.freeze(o),files:Object.freeze(r),outputBySource:i,resolver:a,reachability:s,sources:l.sources,reExports:l.reExports,augmentationImports:c,getResolutionFingerprint:()=>JSON.stringify({resolution:a.cacheKey?.(r,l.sources,l.reExports),augmentations:u})})}var A=50,S=new Map;function N(t){let n=S.get(t);if(!n){if(n=new P(t),S.set(t,n),S.size>A){let o=S.keys().next().value;if(o!==void 0)S.delete(o)}}return n}function ne(t,n,o){if(!n||n.length===0)return!1;let r=y(o,t);for(let a of n){let s=N(a);if(s.match(r)||s.match(t))return!0}return!1}var k=/[*?[\]{}!]/;function W(t,n){let o=g(t.cwd,t.root),r=` root: ${o}
|
|
3
|
+
entrypoints: ${t.entrypoints.map((i)=>JSON.stringify(i)).join(", ")||"(none)"}
|
|
4
|
+
`+(t.exclude?.length?` exclude: ${t.exclude.map((i)=>JSON.stringify(i)).join(", ")}
|
|
5
|
+
`:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(n.length===0){if(t.entrypoints.filter((l)=>b(l)&&D(l)&&!R(l,o)).length===t.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
|
|
6
|
+
${r}`)}let a=new Set(n),s=t.entrypoints.filter((i)=>{if(k.test(i))return!1;let l=b(i)?i:g(o,i);if(a.has(l))return!1;return!D(l)});if(s.length>0)throw Error(`Entrypoint${s.length>1?"s":""} not found: ${s.map((i)=>JSON.stringify(i)).join(", ")}
|
|
7
|
+
${r}`)}async function _(t){let n=[],o=g(t.cwd,t.root),r=t.exclude||[],a=[...t.entrypoints,...t.include??[]];for(let s of a)if(b(s)&&j(s)){if(!s.includes("node_modules")){if(!R(s,o)&&t.outputStructure!=="flat")e.warn(`Skipping entrypoint outside root: ${y(t.cwd,s)}`);else if(!ne(s,r,o))n.push(s)}}else if(!b(s)&&!k.test(s)){let i=g(o,s);if(R(i,o)&&j(i)&&!i.includes("node_modules")){let l=!1;try{l=F(i).isFile()}catch{}if(l&&!ne(i,r,o))n.push(i)}}else{let i=new P(s);for await(let l of i.scan({cwd:o,absolute:!0,onlyFiles:!0}))if(j(l)&&!l.includes("node_modules")){if(!ne(l,r,o))n.push(l)}}return[...new Set(n.map((s)=>g(s)))].sort()}function R(t,n){let o=y(n,t);return o!==".."&&!o.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!b(o)}function J(t,n){let o=new Map,r=new Map;for(let a of t){let s=q(a,n),i=o.get(s);if(i&&i!==a)throw Error(`Output path collision: ${y(n.cwd,i)} and ${y(n.cwd,a)} both emit ${y(n.cwd,s)}`);o.set(s,a),r.set(a,s)}return r}function j(t){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(t)&&!/\.d\.(?:ts|mts|cts)$/.test(t)}function q(t,n){let o=g(n.cwd,n.root),r=y(o,t),a=/\.d\.(?:ts|mts|cts)$/.test(r)?r:r.replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(s)=>{if(s===".mts"||s===".mjs")return".d.mts";if(s===".cts"||s===".cjs")return".d.cts";return".d.ts"});if(n.outputStructure==="mirror")return g(n.cwd,n.outdir,a);else{let s=C(a);return g(n.cwd,n.outdir,s)}}function nc(t,n,o=""){return G(M(t),n,o)}function G(t,n,o=""){let r=y(t,n);if(r.includes("\\"))r=r.replace(/\\/g,"/");if(r.endsWith(".d.ts"))r=r.slice(0,-5);else if(r.endsWith(".d.mts")||r.endsWith(".d.cts"))r=r.slice(0,-6);if(o)r+=o;if(!r.startsWith("."))r=`./${r}`;return r}function We(t,n,o,r,a){let s=g(n.cwd,n.root),i=a?.get(t)??q(t,n),l=M(i);return(c)=>{let p=o(c,t);if(!p.isRelative||!p.resolved)return{kind:"unchanged",reason:p.isRelative?"unresolved":"external",specifier:c,emittedSpecifier:c};let u=p.resolved;if(u.endsWith(".d.ts")||u.endsWith(".d.mts")||u.endsWith(".d.cts")){if(n.moduleSpecifierMode!=="node")return{kind:"unchanged",reason:"preserved-declaration",specifier:c,emittedSpecifier:c};if(r&&!r.has(u))throw Error(`Local declaration ${JSON.stringify(c)} from ${t} targets an authored declaration not emitted by this package build: ${u}. Declaration-only dependencies must be delivered with the package before this importer can be emitted.`)}if(p.isAlias&&r&&!r.has(u))throw Error(`Local alias ${JSON.stringify(c)} from ${t} targets a declaration excluded from this package build: ${u}`);if(r&&!r.has(u)&&ne(u,n.exclude??[],s))throw Error(`Local reference ${JSON.stringify(c)} from ${t} targets a source excluded from this package build: ${u}`);let h=!p.isAlias&&(c.includes("?")||c.includes("#")),w=p.isAlias?p.suffix??"":h?c.match(/[?#].*$/)?.[0]??"":"",m=w?c.slice(0,-w.length):c,d=O(m),x=d===".js"||d===".jsx"||d===".mjs"||d===".cjs"?d:"";if(!x&&n.moduleSpecifierMode==="node"){let E=O(u);x=E===".mts"||E===".mjs"?".mjs":E===".cts"||E===".cjs"?".cjs":".js"}let v=a?.get(u)??q(u,n);return{kind:"local",specifier:c,resolvedSource:u,declarationOutput:v,emittedSpecifier:G(l,v,x)+w}}}
|
|
8
|
+
export{Ne,ne,R,q,nc,We};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{readFile as M,writeFile as S}from"fs/promises";import{basename as x,dirname as d,relative as b,resolve as C}from"path";function f(e){return`${String.fromCharCode(47,47,35)} sourceMappingURL=${e}`}class
|
|
3
|
-
${f(n)}`}function
|
|
4
|
-
${n.toComment(r)}`}async function
|
|
2
|
+
import{readFile as M,writeFile as S}from"fs/promises";import{basename as x,dirname as d,relative as b,resolve as C}from"path";function f(e){return`${String.fromCharCode(47,47,35)} sourceMappingURL=${e}`}class ir{file;sourceRoot;sources=[];sourcesContent=[];names=[];mappings=[];sourceIndexMap=new Map;nameIndexMap=new Map;constructor(e){this.file=e.file,this.sourceRoot=e.sourceRoot}addSource(e,n){let r=this.sourceIndexMap.get(e);if(r===void 0)r=this.sources.length,this.sources.push(e),this.sourcesContent.push(n??null),this.sourceIndexMap.set(e,r);else if(n&&!this.sourcesContent[r])this.sourcesContent[r]=n;return r}addName(e){let n=this.nameIndexMap.get(e);if(n===void 0)n=this.names.length,this.names.push(e),this.nameIndexMap.set(e,n);return n}addMapping(e){let n=this.addSource(e.source),r;if(e.name)r=this.addName(e.name);this.mappings.push({generated:e.generated,original:e.original,sourceIndex:n,nameIndex:r})}generate(e=!1){this.mappings.sort((r,t)=>{if(r.generated.line!==t.generated.line)return r.generated.line-t.generated.line;return r.generated.column-t.generated.column});let n={version:3,file:this.file,sources:this.sources,names:this.names,mappings:this.encodeMappings()};if(this.sourceRoot)n.sourceRoot=this.sourceRoot;if(e)n.sourcesContent=this.sourcesContent;return n}encodeMappings(){let e=[],n=0,r=0,t=0,i=0,o=0,s=0,u=[];for(let a of this.mappings){while(n<a.generated.line)e.push(u.join(",")),u=[],n++,r=0;let l=[];if(l.push(a.generated.column-r),r=a.generated.column,l.push(a.sourceIndex-t),t=a.sourceIndex,l.push(a.original.line-i),i=a.original.line,l.push(a.original.column-o),o=a.original.column,a.nameIndex!==void 0)l.push(a.nameIndex-s),s=a.nameIndex;u.push(I(l))}return e.push(u.join(",")),e.join(";")}toString(e=!1){return JSON.stringify(this.generate(e))}toDataUrl(e=!1){let n=this.toString(e);return`data:application/json;charset=utf-8;base64,${Buffer.from(n).toString("base64")}`}toComment(e=!1){return f(this.toDataUrl(e))}}class zt{map;decodedMappings=null;constructor(e){this.map=typeof e==="string"?JSON.parse(e):e}originalPositionFor(e){let n=this.getMappings(),r=0,t=n.length-1,i=null;while(r<=t){let o=Math.floor((r+t)/2),s=n[o];if(s.generated.line===e.line)if(s.generated.column===e.column){i=s;break}else if(s.generated.column<e.column)i=s,r=o+1;else t=o-1;else if(s.generated.line<e.line)r=o+1;else t=o-1}if(!i)return{source:null,line:null,column:null,name:null};return{source:this.map.sources[i.sourceIndex]||null,line:i.original.line,column:i.original.column,name:i.nameIndex!==void 0?this.map.names[i.nameIndex]:null}}generatedPositionFor(e){let n=this.map.sources.indexOf(e.source);if(n===-1)return null;let r=this.getMappings();for(let t of r)if(t.sourceIndex===n&&t.original.line===e.line&&t.original.column<=e.column)return t.generated;return null}getMappings(){if(!this.decodedMappings)this.decodedMappings=v(this.map.mappings);return this.decodedMappings}sourceContentFor(e){let n=this.map.sources.indexOf(e);if(n===-1||!this.map.sourcesContent)return null;return this.map.sourcesContent[n]}}function I(e){return e.map(L).join("")}function L(e){let o="",s=e<0?-e<<1|1:e<<1;do{let u=s&31;if(s>>>=5,s>0)u|=32;o+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u]}while(s>0);return o}function v(e){let n=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,i=0,o=0,s=0,u=0,a=0,l=e.split(";");for(let g of l){if(i=0,g){let h=g.split(",");for(let p of h){if(!p)continue;let c=N(p,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");if(c.length>=1)i+=c[0];if(c.length>=4){o+=c[1],s+=c[2],u+=c[3];let m={generated:{line:t,column:i},original:{line:s,column:u},sourceIndex:o};if(c.length>=5)a+=c[4],m.nameIndex=a;n.push(m)}}}t++}return n}function N(e,n){let t=[],i=0,o=0;for(let s of e){let u=n.indexOf(s);if(u===-1)continue;let a=u&32;if(o+=(u&31)<<i,a)i+=5;else{let l=o&1;o>>=1,t.push(l?-o:o),o=0,i=0}}return t}function $a(e){let n=new ir({file:x(e.generatedFile),sourceRoot:e.sourceRoot}),r=b(d(e.generatedFile),e.sourceFile);n.addSource(r,e.sourceContent);for(let t of e.mappings)n.addMapping({generated:{line:t.generatedLine,column:t.generatedColumn},original:{line:t.originalLine,column:t.originalColumn},source:r,name:t.name});return n}function ka(e,n){return`${e}
|
|
3
|
+
${f(n)}`}function Ea(e,n,r=!1){return`${e}
|
|
4
|
+
${n.toComment(r)}`}async function Aa(e,n,r=!1){await S(e,n.toString(r))}async function Zi(e){let n=await M(e,"utf-8");return new zt(n)}async function Ta(e,n){let r=e.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if(r){let i=r[1],o=Buffer.from(i,"base64").toString("utf-8");return new zt(o)}let t=e.match(/\/\/# sourceMappingURL=(.+)$/);if(t){let i=C(d(n),t[1].trim());try{return await Zi(i)}catch{return null}}return null}function Pa(e,n){let r=e,t=n,i=r.split(`
|
|
5
5
|
`),o=[],s=0,u=0;for(let a of t){while(s+i[u].length+1<=a.generatedStart&&u<i.length-1)s+=i[u].length+1,u++;let l=a.generatedStart-s;o.push({generatedLine:u,generatedColumn:Math.max(0,l),originalLine:a.originalLine,originalColumn:a.originalColumn,name:a.name})}return o}
|
|
6
|
-
export{
|
|
6
|
+
export{ir,zt,$a,ka,Ea,Aa,Zi,Ta,Pa};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{watch as z}from"fs";import{readdir as O,stat as U}from"fs/promises";import{join as S,relative as E}from"path";function
|
|
2
|
+
import{watch as z}from"fs";import{readdir as O,stat as U}from"fs/promises";import{join as S,relative as E}from"path";function si(e,i){let{root:s,include:u=["**/*.ts","**/*.tsx","**/*.vue","**/*.stx"],exclude:v=["**/node_modules/**","**/*.d.ts","**/dist/**"],debounce:f=100,initialBuild:a=!0,clearScreen:D=!1,onChange:T,onBuildStart:w,onBuildComplete:B,onError:W}=e,P=[],g=new Set,h=!1,d=new Map,c=null,y=!1;function A(o){let r=E(s,o);for(let n of v)if(p(r,n))return!1;for(let n of u)if(p(r,n))return!0;return!1}function p(o,r){let n=r.replace(/\./g,"\\.").replace(/\*\*/g,"{{DOUBLESTAR}}").replace(/\*/g,"[^/]*").replace(/\{\{DOUBLESTAR\}\}/g,".*").replace(/\?/g,".");return new RegExp(`^${n}$`).test(o.replace(/\\/g,"/"))}async function F(){if(y||d.size===0)return;y=!0;let o=Array.from(d.values());d.clear();try{for(let t of o)await T?.(t);if(D)console.clear();await w?.();let r=o.filter((t)=>t.type!=="unlink").map((t)=>t.path),n=await i(r.length>0?r:void 0);await B?.(n)}catch(r){await W?.(r)}finally{if(y=!1,d.size>0)C()}}function C(){if(c)clearTimeout(c);c=setTimeout(()=>{c=null,F()},f)}function k(o,r,n){if(!r||!h)return;let t=S(n,r);if(!A(t))return;let l={type:o==="rename"?"add":"change",path:t,relativePath:E(s,t)};U(t).then(()=>{g.add(t)}).catch(()=>{l.type="unlink",g.delete(t)}).finally(()=>{d.set(t,l),C()})}async function b(o){let r=[o];try{let n=await O(o,{withFileTypes:!0});for(let t of n)if(t.isDirectory()){let l=S(o,t.name),x=E(s,l),R=!1;for(let m of v)if(p(x,m)||p(`${x}/`,m)){R=!0;break}if(!R){let m=await b(l);r.push(...m)}}}catch{}return r}async function G(){if(h)return;h=!0;let o=await b(s);for(let r of o)try{let n=z(r,{persistent:!0},(t,l)=>{k(t,l,r)});n.on("error",(t)=>{W?.(t)}),P.push(n)}catch(n){await W?.(n)}if(a){await w?.();let r=await i();await B?.(r)}}function L(){if(h=!1,c)clearTimeout(c),c=null;for(let o of P)o.close();P.length=0,g.clear(),d.clear()}async function j(){await w?.();let o=await i();return await B?.(o),o}return{start:G,stop:L,rebuild:j,isWatching:()=>h,getWatchedFiles:()=>Array.from(g)}}async function Js(e,i){let s=async(v)=>{let f=Date.now();try{let a=await i(e);return{success:a.errors.length===0,duration:Date.now()-f,filesProcessed:a.filesProcessed,errors:a.errors}}catch(a){return{success:!1,duration:Date.now()-f,filesProcessed:0,errors:[a.message]}}},u=si({root:e.root||e.cwd||process.cwd(),include:e.include,exclude:e.exclude,debounce:e.debounce,initialBuild:e.initialBuild,clearScreen:e.clearScreen,onChange:e.onChange,onBuildStart:e.onBuildStart,onBuildComplete:e.onBuildComplete,onError:e.onError},s);return await u.start(),u}function oi(e){let i=e.success?"\u2713":"\u2717",s=`${e.duration}ms`;if(e.success)return`${i} Built ${e.filesProcessed} file(s) in ${s}`;else return`${i} Build failed in ${s}
|
|
3
3
|
${e.errors.map((u)=>` - ${u}`).join(`
|
|
4
|
-
`)}`}function
|
|
5
|
-
Rebuilding...`)},onBuildComplete:(e)=>{console.log(
|
|
6
|
-
export{
|
|
4
|
+
`)}`}function Ys(){return{onChange:(e)=>{let i=e.type==="add"?"+":e.type==="unlink"?"-":"~";console.log(`[${i}] ${e.relativePath}`)},onBuildStart:()=>{console.log(`
|
|
5
|
+
Rebuilding...`)},onBuildComplete:(e)=>{console.log(oi(e))},onError:(e)=>{console.error(`Error: ${e.message}`)}}}
|
|
6
|
+
export{si,Js,oi,Ys};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Y}from"./chunk-50r5qs7t.js";import{Be,Ln}from"./chunk-fwqdc8fd.js";import{pe,Bn}from"./chunk-rnm8937h.js";function Ii(){Bn(),Ln()}function s(e,r,a=!0,c=!1,n){return Be(e,r,a,c,n)}async function Wn(e,r,a=!0,c={}){return await pe(r,e,c),s(e,r,a)}async function Ni(e,r={}){let a=Y(r.concurrency,4),c=new Map;for(let n=0;n<e.length;n+=a){let o=e.slice(n,n+a),i=await Promise.all(o.map(async(t)=>({path:t.filePath,declarations:await Wn(t.sourceCode,t.filePath,t.keepComments,r)})));for(let t of i)c.set(t.path,t.declarations)}return c}
|
|
3
|
+
export{Ii,s,Wn,Ni};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{s}from"./chunk-vjmwxye4.js";import{h}from"./chunk-16rpzfwq.js";import{existsSync as P,readFileSync as b,unwatchFile as w}from"fs";var ti;((i)=>{i[i.Error=1]="Error";i[i.Warning=2]="Warning";i[i.Information=3]="Information";i[i.Hint=4]="Hint"})(ti||={});var ni;((o)=>{o[o.File=1]="File";o[o.Module=2]="Module";o[o.Namespace=3]="Namespace";o[o.Package=4]="Package";o[o.Class=5]="Class";o[o.Method=6]="Method";o[o.Property=7]="Property";o[o.Field=8]="Field";o[o.Constructor=9]="Constructor";o[o.Enum=10]="Enum";o[o.Interface=11]="Interface";o[o.Function=12]="Function";o[o.Variable=13]="Variable";o[o.Constant=14]="Constant";o[o.String=15]="String";o[o.Number=16]="Number";o[o.Boolean=17]="Boolean";o[o.Array=18]="Array";o[o.Object=19]="Object";o[o.Key=20]="Key";o[o.Null=21]="Null";o[o.EnumMember=22]="EnumMember";o[o.Struct=23]="Struct";o[o.Event=24]="Event";o[o.Operator=25]="Operator";o[o.TypeParameter=26]="TypeParameter"})(ni||={});var ri;((c)=>{c[c.Text=1]="Text";c[c.Method=2]="Method";c[c.Function=3]="Function";c[c.Constructor=4]="Constructor";c[c.Field=5]="Field";c[c.Variable=6]="Variable";c[c.Class=7]="Class";c[c.Interface=8]="Interface";c[c.Module=9]="Module";c[c.Property=10]="Property";c[c.Unit=11]="Unit";c[c.Value=12]="Value";c[c.Enum=13]="Enum";c[c.Keyword=14]="Keyword";c[c.Snippet=15]="Snippet";c[c.Color=16]="Color";c[c.File=17]="File";c[c.Reference=18]="Reference";c[c.Folder=19]="Folder";c[c.EnumMember=20]="EnumMember";c[c.Constant=21]="Constant";c[c.Struct=22]="Struct";c[c.Event=23]="Event";c[c.Operator=24]="Operator";c[c.TypeParameter=25]="TypeParameter"})(ri||={});var ii;((n)=>{n[n.Text=1]="Text";n[n.Read=2]="Read";n[n.Write=3]="Write"})(ii||={});class xn{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(t){return this.rootUri=t.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(t){let{uri:e,text:r,version:n}=t.textDocument;this.updateDocument(e,r,n)}didChange(t){let{uri:e,version:r}=t.textDocument,n=t.contentChanges[0]?.text||"";this.updateDocument(e,n,r)}didClose(t){let e=t.textDocument.uri;if(this.documents.delete(e),this.watchers.get(e))w(this.uriToPath(e)),this.watchers.delete(e)}updateDocument(t,e,r){let n=this.uriToPath(t),i=s(e,n,!0);this.documents.set(t,{content:e,version:r,declarations:i})}getDiagnostics(t){let e=this.documents.get(t);if(!e)return[];let r=[];for(let n of e.declarations){if(n.isExported&&n.kind==="variable"&&!n.typeAnnotation)r.push({range:this.getDeclarationRange(n,e.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${n.name}' should have an explicit type annotation for better declaration generation`});if(n.typeAnnotation==="any"||n.returnType==="any")r.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(n.kind==="function"&&n.isExported&&!n.returnType)r.push({range:this.getDeclarationRange(n,e.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${n.name}' should have an explicit return type for better declaration generation`})}return r}hover(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:r,character:n}=t.position,a=e.content.split(`
|
|
3
|
+
`)[r]||"",u=a.slice(0,n).match(/[\w$]+$/),l=a.slice(n).match(/^[\w$]+/);if(!u&&!l)return null;let d=(u?.[0]||"")+(l?.[0]||""),g=e.declarations.find((x)=>x.name===d);if(!g)return null;let m=`\`\`\`typescript
|
|
4
|
+
${this.buildSignature(g)}
|
|
5
|
+
\`\`\``;if(g.leadingComments&&g.leadingComments.length>0){let v=g.leadingComments.join(`
|
|
6
|
+
`).match(/\*\s*([^@*][^*]*)/);if(v)m+=`
|
|
7
|
+
|
|
8
|
+
${v[1].trim()}`}return{contents:{kind:"markdown",value:m}}}completion(t){let e=this.documents.get(t.textDocument.uri);if(!e)return[];let r=[];for(let n of e.declarations){if(!n.isExported)continue;let i=6;switch(n.kind){case"function":i=3;break;case"class":i=7;break;case"interface":i=8;break;case"type":i=8;break;case"enum":i=13;break}r.push({label:n.name,kind:i,detail:this.buildSignature(n)})}return r}definition(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:r,character:n}=t.position,a=e.content.split(`
|
|
9
|
+
`)[r]||"",u=a.slice(0,n).match(/[\w$]+$/),l=a.slice(n).match(/^[\w$]+/);if(!u&&!l)return null;let d=(u?.[0]||"")+(l?.[0]||""),g=e.declarations.find((p)=>p.name===d);if(!g)return null;return{uri:t.textDocument.uri,range:this.getDeclarationRange(g,e.content)}}references(t){let e=[],r=this.getWordAtPosition(t.textDocument.uri,t.position);if(!r)return e;for(let[n,i]of this.documents){let a=i.content.split(`
|
|
10
|
+
`);for(let u=0;u<a.length;u++){let l=a[u],d=0;while(d<l.length){let g=l.indexOf(r,d);if(g===-1)break;let p=g>0?l[g-1]:" ",m=g+r.length<l.length?l[g+r.length]:" ";if(!/[\w$]/.test(p)&&!/[\w$]/.test(m))e.push({uri:n,range:{start:{line:u,character:g},end:{line:u,character:g+r.length}}});d=g+1}}}return e}prepareRename(t){let e=this.getWordAtPosition(t.textDocument.uri,t.position);if(!e)return null;let r=this.documents.get(t.textDocument.uri);if(!r)return null;let n=r.declarations.find((a)=>a.name===e);if(!n)return null;return{range:this.getDeclarationRange(n,r.content),placeholder:e}}rename(t){if(!this.getWordAtPosition(t.textDocument.uri,t.position))return null;let r=this.references({textDocument:t.textDocument,position:t.position,context:{includeDeclaration:!0}});if(r.length===0)return null;let n={};for(let i of r){if(!n[i.uri])n[i.uri]=[];n[i.uri].push({range:i.range,newText:t.newName})}return{changes:n}}documentSymbols(t){let e=this.documents.get(t.textDocument.uri);if(!e)return[];let r=[];for(let n of e.declarations){let i=this.getDeclarationRange(n,e.content),a=this.declarationKindToSymbolKind(n.kind),u={name:n.name,detail:this.buildSignature(n),kind:a,range:i,selectionRange:i};if(n.members&&n.members.length>0)u.children=n.members.map((l)=>({name:l.name,kind:this.declarationKindToSymbolKind(l.kind),range:this.getDeclarationRange(l,e.content),selectionRange:this.getDeclarationRange(l,e.content)}));r.push(u)}return r}workspaceSymbols(t){let e=[],r=t.query.toLowerCase();for(let[n,i]of this.documents)for(let a of i.declarations){if(!a.isExported)continue;if(r&&!a.name.toLowerCase().includes(r))continue;e.push({name:a.name,kind:this.declarationKindToSymbolKind(a.kind),location:{uri:n,range:this.getDeclarationRange(a,i.content)}})}return e}codeActions(t){let e=[];if(!this.documents.get(t.textDocument.uri))return e;for(let i of t.context.diagnostics){if(i.code==="missing-type"){let a=this.getWordAtRange(t.textDocument.uri,i.range);if(a)e.push({title:`Add type annotation to '${a}'`,kind:"quickfix",diagnostics:[i],edit:{changes:{[t.textDocument.uri]:[{range:{start:i.range.end,end:i.range.end},newText:": unknown"}]}}})}if(i.code==="any-type")e.push({title:"Replace 'any' with 'unknown'",kind:"quickfix",diagnostics:[i],isPreferred:!0,edit:{changes:{[t.textDocument.uri]:[{range:i.range,newText:"unknown"}]}}});if(i.code==="missing-return-type"){let a=this.getWordAtRange(t.textDocument.uri,i.range);if(a)e.push({title:`Add return type to '${a}'`,kind:"quickfix",diagnostics:[i]})}}let n=this.getDeclarationAtPosition(t.textDocument.uri,t.range.start);if(n){if(n.kind==="function")e.push({title:"Extract function signature to type",kind:"refactor.extract"});if(n.kind==="interface"||n.kind==="type")e.push({title:"Generate runtime validator",kind:"source"})}return e}signatureHelp(t){let e=this.documents.get(t.textDocument.uri);if(!e)return null;let{line:r,character:n}=t.position,a=e.content.split(`
|
|
11
|
+
`)[r]||"",u=0,l=-1,d=0;for(let f=n-1;f>=0;f--){let D=a[f];if(D===")")u++;else if(D==="("){if(u===0){l=f;break}u--}else if(D===","&&u===0)d++}if(l===-1)return null;let p=a.slice(0,l).trimEnd().match(/[\w$]+$/);if(!p)return null;let m=p[0],x=e.declarations.find((f)=>f.name===m&&f.kind==="function");if(!x||!x.parameters)return null;let v=x.parameters.map((f)=>{let D="";if(f.rest)D+="...";if(D+=f.name,f.optional)D+="?";if(f.type)D+=`: ${f.type}`;return D});return{signatures:[{label:`${m}(${v.join(", ")}): ${x.returnType||"void"}`,parameters:x.parameters.map((f)=>({label:f.name,documentation:f.type?`Type: ${f.type}`:void 0}))}],activeSignature:0,activeParameter:Math.min(d,x.parameters.length-1)}}documentHighlight(t){let e=[],r=this.getWordAtPosition(t.textDocument.uri,t.position);if(!r)return e;let n=this.documents.get(t.textDocument.uri);if(!n)return e;let i=n.content.split(`
|
|
12
|
+
`);for(let a=0;a<i.length;a++){let u=i[a],l=0;while(l<u.length){let d=u.indexOf(r,l);if(d===-1)break;let g=d>0?u[d-1]:" ",p=d+r.length<u.length?u[d+r.length]:" ";if(!/[\w$]/.test(g)&&!/[\w$]/.test(p)){let m=/^\s*[=:]/.test(u.slice(d+r.length))||/^(const|let|var|function|class|interface|type|enum)\s+$/.test(u.slice(0,d));e.push({range:{start:{line:a,character:d},end:{line:a,character:d+r.length}},kind:m?3:2})}l=d+1}}return e}async formatting(t){let e=this.documents.get(t.textDocument.uri);if(!e)return[];let r=this.generateDts(t.textDocument.uri);if(!r)return[];let n=e.content.split(`
|
|
13
|
+
`);return[{range:{start:{line:0,character:0},end:{line:n.length-1,character:n[n.length-1].length}},newText:r}]}getWordAtPosition(t,e){let r=this.documents.get(t);if(!r)return null;let i=r.content.split(`
|
|
14
|
+
`)[e.line]||"",a=i.slice(0,e.character).match(/[\w$]+$/),u=i.slice(e.character).match(/^[\w$]+/);if(!a&&!u)return null;return(a?.[0]||"")+(u?.[0]||"")}getWordAtRange(t,e){let r=this.documents.get(t);if(!r)return null;let n=r.content.split(`
|
|
15
|
+
`);if(e.start.line===e.end.line)return n[e.start.line]?.slice(e.start.character,e.end.character)||null;return null}getDeclarationAtPosition(t,e){let r=this.documents.get(t);if(!r)return null;for(let n of r.declarations){let i=this.getDeclarationRange(n,r.content);if(this.positionInRange(e,i))return n}return null}positionInRange(t,e){if(t.line<e.start.line||t.line>e.end.line)return!1;if(t.line===e.start.line&&t.character<e.start.character)return!1;if(t.line===e.end.line&&t.character>e.end.character)return!1;return!0}declarationKindToSymbolKind(t){switch(t){case"function":return 12;case"class":return 5;case"interface":return 11;case"type":return 11;case"enum":return 10;case"variable":return 13;case"const":return 14;case"property":return 7;case"method":return 6;case"module":return 2;case"namespace":return 3;default:return 13}}generateDts(t){let e=this.documents.get(t);if(!e)return null;let r={filePath:this.uriToPath(t),sourceCode:e.content,declarations:e.declarations};return h(e.declarations,r,!0,this.config.importOrder)}buildSignature(t){switch(t.kind){case"function":{let e=t.parameters?.map((i)=>{let a="";if(i.rest)a+="...";if(a+=i.name,i.optional)a+="?";if(i.type)a+=`: ${i.type}`;return a}).join(", ")||"",r=t.generics||"",n=t.returnType?`: ${t.returnType}`:"";return`function ${t.name}${r}(${e})${n}`}case"variable":return`const ${t.name}: ${t.typeAnnotation||"unknown"}`;case"interface":return`interface ${t.name}${t.generics||""}${t.extends?` extends ${t.extends}`:""}`;case"type":return`type ${t.name}${t.generics||""} = ${t.typeAnnotation||"unknown"}`;case"class":return`class ${t.name}${t.generics||""}${t.extends?` extends ${t.extends}`:""}`;case"enum":return`enum ${t.name}`;default:return t.name}}getDeclarationRange(t,e){if(t.start!==void 0&&t.end!==void 0)return{start:this.offsetToPosition(t.start,e),end:this.offsetToPosition(t.end,e)};let r=e.split(`
|
|
16
|
+
`);for(let n=0;n<r.length;n++){let i=r[n].indexOf(t.name);if(i!==-1)return{start:{line:n,character:i},end:{line:n,character:i+t.name.length}}}return{start:{line:0,character:0},end:{line:0,character:0}}}offsetToPosition(t,e){let r=0,n=0;for(let i=0;i<t&&i<e.length;i++)if(e[i]===`
|
|
17
|
+
`)r++,n=0;else n++;return{line:r,character:n}}uriToPath(t){if(t.startsWith("file://"))return decodeURIComponent(t.slice(7));return t}pathToUri(t){return`file://${encodeURIComponent(t).replace(/%2F/g,"/")}`}handleMessage(t){if(t.method==="initialize")return{jsonrpc:"2.0",id:t.id,result:this.initialize(t.params)};if(t.method==="initialized")return null;if(t.method==="shutdown")return{jsonrpc:"2.0",id:t.id,result:null};if(t.method==="exit")process.exit(0);let e=t.params;if(t.method==="textDocument/didOpen")return this.didOpen(e),null;if(t.method==="textDocument/didChange")return this.didChange(e),null;if(t.method==="textDocument/didClose")return this.didClose(e),null;if(t.method==="textDocument/hover")return{jsonrpc:"2.0",id:t.id,result:this.hover(e)};if(t.method==="textDocument/completion")return{jsonrpc:"2.0",id:t.id,result:this.completion(e)};if(t.method==="textDocument/definition")return{jsonrpc:"2.0",id:t.id,result:this.definition(e)};if(t.method==="textDocument/references")return{jsonrpc:"2.0",id:t.id,result:this.references(e)};if(t.method==="textDocument/prepareRename")return{jsonrpc:"2.0",id:t.id,result:this.prepareRename(e)};if(t.method==="textDocument/rename")return{jsonrpc:"2.0",id:t.id,result:this.rename(e)};if(t.method==="textDocument/documentSymbol")return{jsonrpc:"2.0",id:t.id,result:this.documentSymbols(e)};if(t.method==="workspace/symbol")return{jsonrpc:"2.0",id:t.id,result:this.workspaceSymbols(e)};if(t.method==="textDocument/codeAction")return{jsonrpc:"2.0",id:t.id,result:this.codeActions(e)};if(t.method==="textDocument/signatureHelp")return{jsonrpc:"2.0",id:t.id,result:this.signatureHelp(e)};if(t.method==="textDocument/documentHighlight")return{jsonrpc:"2.0",id:t.id,result:this.documentHighlight(e)};if(t.method==="textDocument/formatting")return{jsonrpc:"2.0",id:t.id,result:this.formatting(e)};if(t.method==="textDocument/diagnostic"){let r=e?.textDocument?.uri;return{jsonrpc:"2.0",id:t.id,result:{kind:"full",items:r?this.getDiagnostics(r):[]}}}if(t.id!==void 0)return{jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`Method not found: ${t.method}`}};return null}}function zs(){let t=new xn,e="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(r)=>{e+=r;while(!0){let n=e.indexOf(`\r
|
|
18
|
+
\r
|
|
19
|
+
`);if(n===-1)break;let a=e.slice(0,n).match(/Content-Length:\s*(\d+)/i);if(!a){e=e.slice(n+4);continue}let u=Number.parseInt(a[1],10),l=n+4,d=l+u;if(e.length<d)break;let g=e.slice(l,d);e=e.slice(d);try{let p=JSON.parse(g),m=t.handleMessage(p);if(m){let x=JSON.stringify(m),v=Buffer.byteLength(x,"utf8");process.stdout.write(`Content-Length: ${v}\r
|
|
20
|
+
\r
|
|
21
|
+
${x}`)}}catch(p){console.error("Error parsing LSP message:",p)}}})}function Hs(t,e){return(r)=>{if(!P(r))return;let n=b(r,"utf-8"),i=`file://${r}`;t.didOpen({textDocument:{uri:i,languageId:"typescript",version:1,text:n}});let a=t.getDiagnostics(i);e(i,a)}}
|
|
22
|
+
export{ti,ni,ri,ii,xn,zs,Hs};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{y,Ee}from"./chunk-4th0w19y.js";import{Xt,Qt,r,ke,P}from"./chunk-kp395d2p.js";function g(t){if(t.includes(`
|
|
3
|
+
`))return`/**
|
|
4
|
+
* ${t}
|
|
5
|
+
*/
|
|
6
|
+
`;return`/** ${t} */
|
|
7
|
+
`}function h(t){let o=t.indexOf("{");if(o===-1)return-1;let s=t.indexOf("<");if(s===-1||s>o)return o;let e=0,i=!1,a="";for(let n=0;n<t.length;n++){let f=t[n],m=n>0?t[n-1]:"";if(!i&&(f==='"'||f==="'"||f==="`"))i=!0,a=f;else if(i&&f===a&&m!=="\\")i=!1;if(!i){if(f==="<")e++;else if(f===">")e--;else if(f==="{"&&e===0)return n}}return-1}function ye(t,o=!0){return y(t.leadingComments,o)+t.text}function A(t,o=!0){if(t.inferenceError)throw Object.assign(Error(`Cannot infer alias '${t.name}': unsupported source value flow`),{code:t.inferenceError});let s=y(t.leadingComments,o);if(!t.typeAnnotation&&t.inferredType)return s+t.text;if(t.typeAnnotation&&t.text&&(!t.value||!o||!ke(t.typeAnnotation))&&(t.isExported?t.text.startsWith("export declare "):t.text.startsWith("declare ")))return s+t.text;let e="";if(t.isExported)e+="export ";e+="declare ";let i=t.modifiers?.[0]||"const";e+=`${i} `,e+=t.name;let{typeAnnotation:a,value:n}=t,f=!a&&n?P(n):null;if(f)a=f;else if(!a&&n&&n.trim().endsWith("as const"))a=r(n,!0,!1,0,t.computedKeyConstants);else if(!a&&n&&i==="const"){let u=n.trim(),l=u.startsWith("{")||u.startsWith("[");if(l)Xt();a=r(n,!l,!1,0,t.computedKeyConstants)}else if(!a&&n)a=r(n,i==="const",!1,0,t.computedKeyConstants);if(!a)a="unknown";let m="";if(o&&n&&!t.typeAnnotation&&!n.trim().endsWith("as const")){let u=n.trim();if(i!=="const"){if((a==="string"||a==="number"||a==="boolean")&&u.length>0)m=`@defaultValue ${u}`}else if(u.startsWith("{")||u.startsWith("[")){let l=Qt();if(l)if(l.includes(`
|
|
8
|
+
`))m=`@defaultValue
|
|
9
|
+
* \`\`\`ts
|
|
10
|
+
${l.split(`
|
|
11
|
+
`).map((c)=>` * ${c}`).join(`
|
|
12
|
+
`)}
|
|
13
|
+
* \`\`\``;else m=`@defaultValue \`${l}\``}}else if(o&&n&&t.typeAnnotation&&ke(t.typeAnnotation)){Xt();let u=n.trim(),l=u.endsWith("as const")?u.slice(0,-8).trim():u;r(l,!1,!1,0,t.computedKeyConstants);let p=Qt();if(p)if(p.includes(`
|
|
14
|
+
`))m=`@defaultValue
|
|
15
|
+
* \`\`\`ts
|
|
16
|
+
${p.split(`
|
|
17
|
+
`).map((x)=>` * ${x}`).join(`
|
|
18
|
+
`)}
|
|
19
|
+
* \`\`\``;else m=`@defaultValue \`${p}\``}if(m=Ee(m),e+=`: ${a};`,m&&s&&s.includes("@defaultValue"))m="";if(m&&s){let u=s.trimEnd(),l=u.lastIndexOf("*/");if(l!==-1){let c=u.slice(0,l).trimEnd();if(c.startsWith("/** ")&&!c.includes(`
|
|
20
|
+
`))c=`/**
|
|
21
|
+
* ${c.slice(4)}`;return`${c}
|
|
22
|
+
* ${m}
|
|
23
|
+
*/
|
|
24
|
+
`+e}return`/**
|
|
25
|
+
* ${u.replace(/^\/\/\s*/,"")}
|
|
26
|
+
* ${m}
|
|
27
|
+
*/
|
|
28
|
+
${e}`}if(m)return`${g(m)}${e}`;return s+e}function be(t,o=!0){let s=y(t.leadingComments,o),e=t.text;if(e.startsWith("export declare interface")||e.startsWith("declare interface")||e.startsWith("export default interface"))return s+e;let i="";if(t.isExported)i+="export ";if(i+="declare interface ",i+=t.name,t.generics)i+=t.generics;if(t.extends)i+=` extends ${t.extends}`;let a=h(t.text);if(a!==-1)i+=` ${t.text.slice(a)}`;else i+=" {}";return s+i}function we(t,o=!0){let s=y(t.leadingComments,o);if(t.text.startsWith("import "))return s+t.text;if(t.text.startsWith("export type {")&&t.text.includes(" from "))return s+t.text;let e="";if(t.isExported)e+="export ";if(!t.isExported)e+="declare ";let i=t.text.indexOf("type ");if(i!==-1){let n=t.text.slice(i),f=n.length;while(f>0&&(n.charCodeAt(f-1)===59||n.charCodeAt(f-1)===32||n.charCodeAt(f-1)===10||n.charCodeAt(f-1)===13))f--;if(f<n.length)n=n.slice(0,f);e+=n}else{if(e+=`type ${t.name}`,t.generics)e+=t.generics;e+=" = any"}let a=e.trimEnd();if(!a.endsWith(";")&&!a.endsWith("}"))e+=";";return s+e}function xe(t,o=!0){return y(t.leadingComments,o)+t.text}function Ce(t,o=!0){let s=y(t.leadingComments,o),e="";if(t.isExported)e+="export ";if(e+="declare ",t.modifiers?.includes("const"))e+="const ";e+="enum ",e+=t.name;let i=t.text.indexOf("{");if(i!==-1)e+=` ${t.text.slice(i)}`;else e+=" {}";return s+e}function lr(t){let o=t.text.trim(),s=o.length;while(s>0&&o.charCodeAt(s-1)===59)s--;if(s<o.length)o=o.slice(0,s);return o+=";",o}function ur(t,o=!0){return y(t.leadingComments,o)+t.text.trim()}function ve(t,o=!0){let s=y(t.leadingComments,o);if(t.text.startsWith("declare global"))return s+t.text;if(t.source||(t.name.startsWith('"')||t.name.startsWith("'")||t.name.startsWith("`"))){let n="declare module ";n+=t.name;let f=t.text.indexOf(t.name),m=f!==-1?f+t.name.length:0,u=t.text.indexOf("{",m);if(u!==-1)n+=` ${t.text.slice(u)}`;else n+=";";return s+n}let i="";if(t.isExported)i+="export ";if(!t.modifiers?.includes("declare"))i+="declare ";i+="namespace ",i+=t.name;let a=t.text.indexOf("{");if(a!==-1)i+=` ${t.text.slice(a)}`;else i+=" {}";return s+i}
|
|
29
|
+
export{ye,A,be,we,xe,Ce,lr,ur,ve};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
3
|
-
`);if(r!==-1)i=n.slice(r+1),s=!0;else i="",s=!0}}return i.trim()}function
|
|
4
|
-
`),r=[],t=n.length-1,u=!1,a=[];while(t>=0){let l=n[t].trim();if(l.endsWith("*/")&&!u)u=!0,a.unshift(l);else if(l.startsWith("/*")&&u)a.unshift(l),r.unshift(...a),a=[],u=!1;else if(u)a.unshift(l);else if(l.startsWith("//"))r.unshift(l);else if(l.startsWith("*")&&(t>0&&n[t-1].trim().startsWith("/*")))r.unshift(l);else if(l===""&&r.length>0);else if(l!=="")break;t--}return r}function
|
|
5
|
-
export{
|
|
2
|
+
function Jo(e,i){return e.getText?.()??i.slice(e.pos??0,e.end??i.length)}function Yo(e){return e.getFullText?.().match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g)??[]}function Vn(e){let i=e,s=!0;while(s){s=!1;let n=i.trimStart();if(n.startsWith("/*")){let r=n.indexOf("*/",2);if(r!==-1){i=n.slice(r+2),s=!0;continue}}if(n.startsWith("//")){let r=n.indexOf(`
|
|
3
|
+
`);if(r!==-1)i=n.slice(r+1),s=!0;else i="",s=!0}}return i.trim()}function Xo(e,i){let n=e.substring(0,i).split(`
|
|
4
|
+
`),r=[],t=n.length-1,u=!1,a=[];while(t>=0){let l=n[t].trim();if(l.endsWith("*/")&&!u)u=!0,a.unshift(l);else if(l.startsWith("/*")&&u)a.unshift(l),r.unshift(...a),a=[],u=!1;else if(u)a.unshift(l);else if(l.startsWith("//"))r.unshift(l);else if(l.startsWith("*")&&(t>0&&n[t-1].trim().startsWith("/*")))r.unshift(l);else if(l===""&&r.length>0);else if(l!=="")break;t--}return r}function Qo(e){let i=!1,s="",n=!1;for(let r=0;r<e.length;r++){let t=e[r];if(!n&&!i&&(t==='"'||t==="'"||t==="`"))i=!0,s=t;else if(!n&&i&&t===s)i=!1;else if(t==="\\"&&!n){n=!0;continue}else if(!i&&t==="/"&&r<e.length-1){if(e[r+1]==="/")return e.substring(r)}n=!1}return null}function Un(e,i,s){let n=0,r=!1,t="",u=!1;if(!e.startsWith(i))return null;for(let a=0;a<e.length;a++){let l=e[a];if(!u&&(l==='"'||l==="'"||l==="`")){if(!r)r=!0,t=l;else if(l===t)r=!1}if(l==="\\"&&!u){u=!0;continue}if(u=!1,!r){if(e.substring(a,a+i.length)===i)n++;else if(e.substring(a,a+s.length)===s){if(n--,n===0)return{content:e.substring(0,a+s.length),rest:e.substring(a+s.length)}}}}return null}function Zo(e){let i=Vn(e).trim(),s=i.match(/^(export\s+)?(async\s+)?function\s*(\*?)([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=[];if(s[1])n.push("export");if(s[2])n.push("async");if(s[3])n.push("generator");let r=s[4],t=i.substring(s[0].length).trim(),u="";if(t.startsWith("<")){let o=Un(t,"<",">");if(o)u=o.content,t=o.rest.trim()}let a="";if(t.startsWith("(")){let o=Un(t,"(",")");if(o)a=o.content.slice(1,-1).trim(),t=o.rest.trim()}let l="void";if(t.startsWith(":")){let o=t.match(/^:\s*([^{;]+)/);if(o)l=o[1].trim()}return{name:r,generics:u,parameters:a,returnType:l,modifiers:n}}function ea(e){return/^\s*export\s+/.test(e)}function ta(e){return/^\s*export\s+type\s+/.test(e)}function na(e){let i=Vn(e).trim(),s=i.match(/^(export\s+)?(const|let|var)\s+([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=s[2],r=s[3],t=i.substring(s[0].length).trim(),u;if(t.startsWith(":")){let l=t.indexOf("=");if(l!==-1)u=t.substring(1,l).trim(),t=t.substring(l).trim();else u=t.substring(1).replace(/;?\s*$/,"").trim(),t=""}let a;if(t.startsWith("="))a=t.substring(1).replace(/;?\s*$/,"").trim();return{kind:n,name:r,typeAnnotation:u,value:a}}
|
|
5
|
+
export{Jo,Yo,Vn,Xo,Qo,Un,Zo,ea,ta,na};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{mt}from"./chunk-44a6zpxs.js";import{M}from"./chunk-e12f4mpd.js";import{Mn}from"./chunk-795w1bb2.js";import{Ie}from"./chunk-yfgm2ccr.js";import{G}from"./chunk-rv597vq5.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function it(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function po(r,n){throw Error(n||`Unexpected value: ${r}`)}async function K(r,n,i="lf"){let t=n.includes("\r")?n.replace(/\r\n/g,`
|
|
3
|
+
`):n;if(!t.endsWith(`
|
|
4
|
+
`))t+=`
|
|
5
|
+
`;if(i==="crlf")t=t.replace(/\n/g,`\r
|
|
6
|
+
`);if(await mt(r,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${r}`)}async function Ai(r){let n=r??M.root,i=await v(n,{withFileTypes:!0});return(await Promise.all(i.map((o)=>{let c=C(n,o.name);return o.isDirectory()?Ai(c):c}))).flat(1/0).filter((o)=>{if(typeof o!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(o)&&!/\.d\.(?:ts|mts|cts)$/.test(o)})}async function fe(r){try{let n=r?.cwd||y.cwd();return(await G(D(n,r?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function Tt(r,n){let i={isValid:!0,errors:[]};for(let t of Ie(r))i.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of Mn(r))i.errors.push({line:t.line,column:1,message:`'${t.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${t.context}`,code:"dangling-type-reference"});return i.isValid=i.errors.length===0,i}function Pt(r,n,i){if(r===n)return"";let t=r.split(`
|
|
7
|
+
`),o=n.split(`
|
|
8
|
+
`),c=new Map,a=new Map;for(let e=0;e<t.length;e++)c.set(t[e],(c.get(t[e])??0)+1);for(let e=0;e<o.length;e++)a.set(o[e],(a.get(o[e])??0)+1);let g=[],u=[];for(let[e,s]of c){let m=s-(a.get(e)??0);for(let l=0;l<m;l++)g.push(e)}for(let[e,s]of a){let m=s-(c.get(e)??0);for(let l=0;l<m;l++)u.push(e)}if(g.length===0&&u.length===0)return"";let p=[`--- ${i}`,`+++ ${i}`];for(let e=0;e<g.length;e++)p.push(`- ${g[e]}`);for(let e=0;e<u.length;e++)p.push(`+ ${u[e]}`);return p.join(`
|
|
9
|
+
`)}function Dt(r,n,i,t){let o=r.split(`
|
|
10
|
+
`),c=[];function a(s){let l="",f=s<0?-s<<1|1:s<<1;do{let d=f&31;if(f>>>=5,f>0)d|=32;l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d]}while(f>0);return l}let g=0,u=0,p=0,e=t.split(`
|
|
11
|
+
`).length;for(let s=0;s<o.length;s++){if(o[s].trim()===""){c.push("");continue}g=0;let l=Math.min(s,e-1),f=[],d=0-g,h=0,w=l-u,x=0-p;f.push(a(d)+a(h)+a(w)+a(x)),g=0,u=l,p=0,c.push(f.join(","))}return{version:3,file:n,sourceRoot:"",sources:[i],sourcesContent:[t],mappings:c.join(";")}}function Rt(r,n){return`${r}
|
|
12
|
+
${it()}${n}
|
|
13
|
+
`}
|
|
14
|
+
export{it,po,K,Ai,fe,Tt,Pt,Dt,Rt};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{n,m,x}from"./chunk-b5wcbnb8.js";var w={kind:"symbol"},C=/^(?: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},W=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"];function S(d,u,a=0){if(a>=64)return;let i=d.trim(),o=n(i);if(!o.length)return;if(o[0].start!==0||o[o.length-1].end!==i.length)return S(i.slice(o[0].start,o[o.length-1].end),u,a+1);if(o.length===1&&o[0].kind==="quoted")return m(i);if(o.length===1&&o[0].kind==="word"){let t=u.get(i);return typeof t==="object"?void 0:t}if(C.exec(i)?.[0].length===i.length){let t=Number(i.replaceAll("_",""));return Number.isFinite(t)?t:void 0}let e=0,s;for(let t=0;t<o.length;t++){let c=o[t],r=i.slice(c.start,c.end);if(c.kind!=="punctuation")continue;if(["(","[","{"].includes(r)){e++;continue}if([")","]","}"].includes(r)){e--;continue}let l=C.exec(i.slice(c.start));if(l){while(o[t+1]?.start<c.start+l[0].length)t++;continue}if(e)continue;let b=W.find((K)=>i.startsWith(K,c.start));if(!b)continue;let y=o[t-1],k=y?i.slice(y.start,y.end):"";if(!(!y||y.kind==="punctuation"&&![")","]"].includes(k)&&!/\d/.test(k))&&(!s||v[b]<s.priority||v[b]===s.priority&&b!=="**"))s={start:c.start,operator:b,priority:v[b]};while(o[t+1]?.start<c.start+b.length)t++}if(s){let t=S(i.slice(0,s.start),u,a+1),c=S(i.slice(s.start+s.operator.length),u,a+1);if(t===void 0||c===void 0)return;if(s.operator==="+"&&(typeof t==="string"||typeof c==="string"))return String(t)+String(c);if(typeof t!=="number"||typeof c!=="number")return;let r;switch(s.operator){case"+":r=t+c;break;case"-":r=t-c;break;case"*":r=t*c;break;case"/":r=t/c;break;case"%":r=t%c;break;case"**":r=t**c;break;case"<<":r=t<<c;break;case">>":r=t>>c;break;case">>>":r=t>>>c;break;case"|":r=t|c;break;case"^":r=t^c;break;case"&":r=t&c;break;default:return}return Number.isFinite(r)?r:void 0}if(i.startsWith("(")&&i.endsWith(")")){let t=0;if(o.every((r,l)=>{let b=i.slice(r.start,r.end);if(b==="(")t++;if(b===")")t--;return t!==0||l===o.length-1}))return S(i.slice(1,-1),u,a+1)}if(["+","-","~"].includes(i[0])){let t=S(i.slice(1),u,a+1);if(typeof t!=="number")return;return i[0]==="-"?-t:i[0]==="~"?~t:t}if(!i.startsWith("`")||!i.endsWith("`"))return;let p="",h=1;for(let t=1;t<i.length-1;t++){if(i[t]==="\\"){t++;continue}if(i[t]!=="$"||i[t+1]!=="{")continue;let c=m(`\`${i.slice(h,t)}\``);if(c===void 0)return;p+=c;let r=0,l=o.find((y)=>{if(y.start<t+2||y.kind!=="punctuation")return!1;let k=i.slice(y.start,y.end);if(k==="{")r++;if(k!=="}")return!1;if(r===0)return!0;return r--,!1});if(!l)return;let b=S(i.slice(t+2,l.start),u,a+1);if(b===void 0)return;p+=String(b),t=l.start,h=t+1}let g=m(`\`${i.slice(h,-1)}\``);return g===void 0?void 0:p+g}function $r(d,u){let a=[...new Set([...d,...u.values()])];if(!a.some((e)=>e.kind==="variable"&&typeof e.value==="string"&&/[\[{]/.test(e.value)))return;a.sort((e,s)=>(e.start??0)-(s.start??0));let i=new Map,o=new Map,f=a.some((e)=>e.name==="Symbol");for(let e of a){if(e.kind!=="variable"||typeof e.value!=="string")continue;if(e.value.includes("{")||e.value.includes("[")){let r=new Map(i);r.mutableBindingTypes=new Map(o),e.computedKeyConstants=r}let s=e.value.trim();if(s.length===0)continue;if(e.typeAnnotation==="unique symbol"||e.typeAnnotation==="symbol"){i.set(e.name,w);continue}let p=s.charCodeAt(0);if(p===123||p===91)continue;if(s==="true"||s==="false"){if(e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion"))o.set(e.name,"boolean");continue}if(!f&&s.startsWith("Symbol")&&s.length>6&&(s.charCodeAt(6)===40||s.charCodeAt(6)===46)){i.set(e.name,w);continue}if(s.startsWith("function")||s.startsWith("async ")||s.startsWith("class ")||s.startsWith("new "))continue;let h=p>=65&&p<=90||p>=97&&p<=122||p===95||p===36;if(h)for(let r=1;r<s.length;r++){let l=s.charCodeAt(r);if(!(l>=65&&l<=90||l>=97&&l<=122||l>=48&&l<=57||l===95||l===36)){h=!1;break}}if(h){let r=i.get(s);if(typeof r==="object"){i.set(e.name,w);continue}if(e.modifiers?.[0]!=="const"||e.typeAnnotation||e.modifiers.includes("const assertion"))continue;if(r!==void 0){if(i.set(e.name,r),o.has(s))o.set(e.name,typeof r)}else{let l=o.get(s);if(l)o.set(e.name,l)}continue}let g=n(e.value);if(typeof(g.length===1&&g[0].kind==="word"?i.get(e.value.slice(g[0].start,g[0].end)):void 0)==="object"||!f&&g[0]?.kind==="word"&&e.value.slice(g[0].start,g[0].end)==="Symbol"&&["(","."].includes(e.value.slice(g[1]?.start,g[1]?.end))){i.set(e.name,w);continue}if(e.modifiers?.[0]!=="const"||e.typeAnnotation||e.modifiers.includes("const assertion"))continue;let c=S(e.value,i);if(c!==void 0){if(i.set(e.name,c),!(g.length===1&&g[0].kind==="word")||o.has(s))o.set(e.name,typeof c)}else if(g.length===1&&g[0].kind==="word"){let r=o.get(s);if(r)o.set(e.name,r)}}}function A(d){let u=d.trim();while(u.length>=2&&u.charCodeAt(0)===40&&u.charCodeAt(u.length-1)===41){let f=0,e=!0;for(let s=0;s<u.length-1;s++){let p=u.charCodeAt(s);if(p===40)f++;else if(p===41){if(f--,f===0){e=!1;break}}}if(!e)break;u=u.slice(1,-1).trim()}if(!u)return!0;let a=n(u);if(!a.length)return!0;if(a.length===1&&a[0].kind==="quoted"&&a[0].start===0&&a[0].end===u.length)return!0;let i=u[0]==="-"||u[0]==="+"?u.slice(1).trimStart():u,o=C.exec(i);if(o&&o[0].length===i.length)return!0;if(a.length%2===1){let f=!0;for(let e=0;e<a.length;e++)if(e%2===0){if(a[e].kind!=="word"){f=!1;break}}else if(u.slice(a[e].start,a[e].end)!=="."){f=!1;break}if(f)return!0}return!1}function kr(d,u){let a=d.trim();if(!a.startsWith("[")||!a.endsWith("]"))return;let i=a.slice(1,-1).trim();if(!i)return;if(i.startsWith("`")){let f=n(d);if(d[f[0]?.start]!=="["||d[f[1]?.start]!=="`"||d[f.at(-1)?.start??-1]!=="]")return;let e=d.slice(f[0].end,f.at(-1).start).trim(),s=S(e,u??new Map);return typeof s==="string"?{name:x(s,"'")}:{index:!0}}if(A(i))return;let o=S(i,u??new Map);if(typeof o==="string")return{name:x(o,"'")};if(typeof o==="number")return{name:String(o)};return{index:!0}}function Er(d,u){if(!u||!d.trimStart().startsWith("["))return!1;let a=n(d);return a.length===3&&d[a[0].start]==="["&&a[1].kind==="word"&&d[a[2].start]==="]"&&typeof u.get(d.slice(a[1].start,a[1].end))==="object"}function Ar(d){if(!d.trimStart().startsWith("[")||!d.includes("`"))return!1;let u=n(d);return d[u[1]?.start]==="`"&&u.some((a)=>a.kind==="punctuation"&&d[a.start]==="{")}
|
|
3
|
+
export{S,$r,kr,Er,Ar};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{J}from"./chunk-e12f4mpd.js";import{F}from"./chunk-chj3hn6f.js";import{Ne,We}from"./chunk-v0gpmwh9.js";import{createHash as N}from"crypto";import{readFile as d}from"fs/promises";import{resolve as m}from"path";async function Nn(g){let e={...J,...g},n=e.moduleSpecifierMode??"preserve";if(n!=="node"&&n!=="preserve")throw Error("moduleSpecifierMode must be preserve or node");if(e.plugins?.length)throw Error("Native project planning does not support generation plugins");let o=await Ne(e),l=[];for(let r of o.files){let s=await d(r),a=s.toString("utf8");if(!Buffer.from(a,"utf8").equals(s))throw Error(`Native declaration source must be valid UTF-8: ${r}`);let u=o.outputBySource.get(r),v=We(r,e,o.resolver),i=[],S=o.reExports.get(r)??F(a,{includeImports:!0}),h=new Set(S.map((t)=>t.specifier));for(let t of h){let p=v(t);if(p.kind!=="local")continue;let{resolvedSource:w,declarationOutput:y,emittedSpecifier:x}=p;i.push({specifier:t,resolvedSource:w,declarationOutput:y,emittedSpecifier:x})}let c={version:1,moduleSpecifierMode:n,sourceFile:r,outputFile:u,sourceHash:N("sha256").update(s).digest("hex"),rewrites:i};if(!e.isolatedDeclarations&&i.length)c.inferenceSources=await Promise.all(i.map(async(t)=>({specifier:t.specifier,source:o.sources.get(t.resolvedSource)??await d(t.resolvedSource,"utf8")})));let f=o.augmentationImports.get(r);if(f?.size)c.augmentationImports=[...f];l.push(Object.freeze({sourceFile:r,outputFile:u,source:a,context:c}))}return Object.freeze({version:1,rootPath:m(e.cwd,e.root),outdirPath:m(e.cwd,e.outdir),files:Object.freeze(l)})}
|
|
3
|
+
export{Nn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function d(n,c){let o=1,l=1;for(let i=0;i<c;i++)if(n.charCodeAt(i)===10)o++,l=1;else l++;return{line:o,column:l}}function
|
|
3
|
-
export{
|
|
2
|
+
function d(n,c){let o=1,l=1;for(let i=0;i<c;i++)if(n.charCodeAt(i)===10)o++,l=1;else l++;return{line:o,column:l}}function Ie(n){let c=[],o=[],l=[],i={")":"(","]":"[","}":"{"},r=0,m=0,f=-1;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e),s=n.charCodeAt(e+1);if(f!==-1){if(t===42&&s===47)o.push({start:f,end:e+2}),f=-1,e++;continue}if(r){if(t===92)e++;else if(t===r)o.push({start:m,end:e+1}),r=0;continue}if(t===47&&s===42){f=e,e++;continue}if(t===47&&s===47){let u=e;while(e<n.length&&n.charCodeAt(e)!==10)e++;o.push({start:u,end:e});continue}if(t===39||t===34||t===96){r=t,m=e;continue}let a=n[e];if(a==="("||a==="["||a==="{")l.push({char:a,offset:e});else if(i[a]){let u=l.pop();if(!u||u.char!==i[a])c.push({...d(n,e),message:`Unexpected closing delimiter ${a}`,code:"DTSX1004"})}}if(r)c.push({...d(n,m),message:"Unterminated string literal",code:"DTSX1002"});if(f!==-1)c.push({...d(n,f),message:"Unterminated block comment",code:"DTSX1003"});for(let e of l)c.push({...d(n,e.offset),message:`Unclosed delimiter ${e.char}`,code:"DTSX1001"});let p=[[/\b(?:interface|class|enum)\s*(?=[{=])/g,"Declaration name expected"],[/\bfunction\s*(?=\()/g,"Function name expected"],[/\(\s*:/g,"Parameter name expected"]];for(let[e,t]of p)for(let s of n.matchAll(e)){if(o.some((a)=>s.index>=a.start&&s.index<a.end))continue;c.push({...d(n,s.index),message:t,code:"DTSX1005"})}for(let e of n.matchAll(/\btype\s*(?=[{=])/g)){if(o.some((s)=>e.index>=s.start&&e.index<s.end))continue;let t=n.slice(0,e.index).trimEnd();if(t.endsWith("import")||t.endsWith("export"))continue;c.push({...d(n,e.index),message:"Declaration name expected",code:"DTSX1005"})}return c.push(...g(n,o)),c.sort((e,t)=>e.line-t.line||e.column-t.column)}var h=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,x=new RegExp(`^(?:type\\s+)?${h}(?:\\s+as\\s+${h})?$`,"u");function g(n,c){let o=[],l=(i)=>c.some((r)=>i>=r.start&&i<r.end);for(let i of n.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let r=i.index;if(l(r))continue;let m=r+i[0].length-1,f=-1;for(let t=m+1;t<n.length;t++){if(l(t))continue;let s=n[t];if(s==="{"){f=-2;break}if(s==="}"){f=t;break}}if(f<0)continue;let p=n.slice(m+1,f);if(!p.trim())continue;let e=m+1;for(let t of p.split(",")){let s=t.trim();if(s){let a=e+t.indexOf(s);if(s.includes(";"))o.push({...d(n,a),message:`Unexpected ';' in ${i[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!x.test(s))o.push({...d(n,a),message:`Invalid ${i[1]} specifier '${s}'`,code:"DTSX1006"})}e+=t.length+1}}return o}
|
|
3
|
+
export{Ie};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
2
|
+
function Ct(e,r={}){let{entryPoints:n,keepExported:s=!0,keep:t=[],remove:l=[],shakableKinds:c=["type","interface"],debug:m=!1}=r,p=m?console.log.bind(console,"[tree-shake]"):()=>{},x=new Map;for(let a of e)x.set(a.name,a);let i=vt(e);p("Dependency graph:",Object.fromEntries(Array.from(i.entries()).map(([a,d])=>[a,Array.from(d)])));let o=new Set;if(n&&n.length>0){for(let a of n)if(x.has(a))o.add(a)}else{let a=new Set(c);for(let d of e){if(s&&d.isExported){o.add(d.name);continue}if(k(d.name,t)){o.add(d.name);continue}if(!a.has(d.kind))o.add(d.name)}}if(n&&n.length>0&&t.length>0){for(let a of e)if(k(a.name,t))o.add(a.name)}p("Entry points:",Array.from(o));let f=T(o,i);p("Reachable:",Array.from(f));let u=new Set,g=[];for(let a of e){let d=a.name;if(f.has(d)){u.add(d);continue}if(k(d,l)){g.push(d);continue}if(!c.includes(a.kind)){u.add(d);continue}g.push(d)}p("Keeping:",Array.from(u)),p("Removing:",g);let b=e.filter((a)=>u.has(a.name)),y={totalBefore:e.length,totalAfter:b.length,removedCount:g.length,reductionPercent:e.length>0?Math.round(g.length/e.length*100):0};return{declarations:b,removed:g,dependencyGraph:i,stats:y}}function vt(e){let r=new Map,n=new Set;for(let s=0;s<e.length;s++)n.add(e[s].name);for(let s of e){let t=new Set,l=St(s);for(let c of l)if(n.has(c)&&c!==s.name)t.add(c);r.set(s.name,t)}return r}function St(e){let r=new Set;if(e.typeAnnotation)h(e.typeAnnotation,r);if(e.extends)h(e.extends,r);if(e.text)R(e.text,r);if(e.members)for(let n of e.members){let s=St(n);for(let t of s)r.add(t)}if(e.parameters){for(let n of e.parameters)if(n.type)h(n.type,r)}if(e.returnType)h(e.returnType,r);return r}var E=new Set(["string","number","boolean","object","any","unknown","never","void","null","undefined","symbol","bigint","true","false","Array","Object","String","Number","Boolean","Function","Symbol","Promise","Map","Set","WeakMap","WeakSet","Record","Partial","Required","Readonly","Pick","Omit","Exclude","Extract","NonNullable","Parameters","ReturnType","InstanceType","ConstructorParameters","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","keyof","typeof","infer","extends","readonly","const","new"]),S=/\b([A-Z]\w*)\b/g,D=/\btypeof\s+([$A-Z_a-z][$\w]*)/g;function h(e,r){S.lastIndex=0;let n;while((n=S.exec(e))!==null){let s=n[1];if(!E.has(s))r.add(s)}D.lastIndex=0;while((n=D.exec(e))!==null)r.add(n[1])}function R(e,r){h(e,r)}function T(e,r){let n=new Set,s=Array.from(e);while(s.length>0){let t=s.pop();if(n.has(t))continue;n.add(t);let l=r.get(t);if(l){for(let c of l)if(!n.has(c))s.push(c)}}return n}function k(e,r){for(let n of r)if(typeof n==="string"){if(n.includes("*")){if(new RegExp(`^${n.replace(/\*/g,".*").replace(/\?/g,".")}$`).test(e))return!0}else if(e===n)return!0}else if(n.test(e))return!0;return!1}function Ur(e,r={}){let n=e.split(`
|
|
3
3
|
`),s=[],t=null;for(let i=0;i<n.length;i++){let o=n[i],f=o.trim();if(!t&&(f===""||f.startsWith("//")))continue;if(!t){let u=f.match(/^(export\s+)?(declare\s+)?(interface|type|enum|class|function|const|let|var)\s+(\w+)/);if(u){let[,g,,b,y]=u;if(t={name:y,kind:b,isExported:!!g,start:i,lines:[o],braceCount:0},t.braceCount+=(o.match(/\{/g)||[]).length,t.braceCount-=(o.match(/\}/g)||[]).length,t.braceCount===0&&(f.endsWith(";")||!f.includes("{")))s.push({name:t.name,kind:t.kind,isExported:t.isExported,start:t.start,end:i,text:t.lines.join(`
|
|
4
4
|
`)}),t=null;continue}}if(t){if(t.lines.push(o),t.braceCount+=(o.match(/\{/g)||[]).length,t.braceCount-=(o.match(/\}/g)||[]).length,t.braceCount<=0&&(f.endsWith("}")||f.endsWith(";")))s.push({name:t.name,kind:t.kind,isExported:t.isExported,start:t.start,end:i,text:t.lines.join(`
|
|
5
|
-
`)}),t=null}}if(s.length===0)return{content:e,removed:[]};let l=s.map((i)=>({name:i.name,kind:i.kind,isExported:i.isExported,text:i.text})),c=
|
|
5
|
+
`)}),t=null}}if(s.length===0)return{content:e,removed:[]};let l=s.map((i)=>({name:i.name,kind:i.kind,isExported:i.isExported,text:i.text})),c=Ct(l,r),m=new Set(c.declarations.map((i)=>i.name)),p=new Set;for(let i of s)if(!m.has(i.name))for(let o=i.start;o<=i.end;o++)p.add(o);return{content:n.filter((i,o)=>!p.has(o)).join(`
|
|
6
6
|
`).replace(/\n{3,}/g,`
|
|
7
7
|
|
|
8
|
-
`),removed:c.removed}}function
|
|
9
|
-
export{
|
|
8
|
+
`),removed:c.removed}}function zr(e,r={}){return Ct(e,{...r,debug:!1}).removed}function Hr(e,r){let n=vt(r),s=n.get(e)||new Set,t=T(new Set([e]),n);t.delete(e);let l=[];for(let[c,m]of n)if(c!==e&&m.has(e))l.push(c);return{directDependencies:Array.from(s),transitiveDependencies:Array.from(t),dependents:l}}function Os(e={}){return{shake:(r)=>Ct(r,e),shakeContent:(r)=>Ur(r,e),findUnused:(r)=>zr(r,e),analyzeDependencies:(r,n)=>Hr(r,n),buildGraph:vt,extractRefs:St}}
|
|
9
|
+
export{Ct,vt,St,Ur,zr,Hr,Os};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{N,j}from"./chunk-9axwjcna.js";import{I,_}from"./chunk-pq6j9bkd.js";import{g}from"./chunk-j2bapmng.js";import{V,U}from"./chunk-5tcpge5e.js";import{Be}from"./chunk-fwqdc8fd.js";import{k,Tn}from"./chunk-s7d3d1wx.js";import{h}from"./chunk-16rpzfwq.js";function rt(t,n,s,r,i,e){if(r.length!==1||r[0]!=="bun")return null;if(e==="typescript"||e!=="native"&&k(e)==="typescript")return null;let c=t;if(n!==void 0&&!n.endsWith(".ts")&&!n.endsWith(".mts")&&!n.endsWith(".cts")&&!n.endsWith(".tsx")){if(N(n))c=j(t);else if(I(n))c=_(t)}return Tn(c,s,i,n,e)}var E=100,p=0,a=new Map;function Et(t,n,s=!0,r=["bun"],i=!1,e){let c=k(e),S=r.length===1&&r[0]==="bun"?"b":`j${JSON.stringify(r)}`,x=`${n===void 0?"u":`s${n.length}:${n}`}\x00${s?1:0}${i?1:0}${c[0]}\x00${S}`,o=a.size>0?a.get(x):void 0;if(o){if(o.sourceRef===t)return o.lastAccess=++p,o.result;if(o.sourceLen===t.length){let f=g(t);if(o.contentHash===void 0)o.contentHash=g(o.sourceRef);if(o.contentHash===f)return o.sourceRef=t,o.lastAccess=++p,o.result}}let y=rt(t,n,s,r,i,c)??R(t,n,s,r,i);if(a.set(x,{result:y,sourceRef:t,sourceLen:t.length,lastAccess:++p}),a.size>E){let f=Math.max(1,Math.ceil(a.size*0.1)),l=[];for(let[u,b]of a)l.push([u,b.lastAccess]);l.sort((u,b)=>u[1]-b[1]);for(let u=0;u<f&&u<l.length;u++)a.delete(l[u][0])}return y}function bi(t,n,s=!0,r=["bun"]){return Et(t,n,s,r,!0)}function wi(t,n,s=!0,r=["bun"]){return Et(t,n,s,r,!1)}function R(t,n,s,r,i){let e=Be(t,n,s,i);return h(e,{filePath:n??"stdin.ts",sourceCode:t,declarations:e},s,r)}function xi(){a.clear()}function tc(t,n,s=!0,r=["bun"],i=!1,e){return rt(t,n,s,r,i,e)??An(t,n,s,r,i)}function An(t,n,s=!0,r=["bun"],i=!1){if(N(n??""))t=j(t);else if(I(n??""))t=_(t);let e=i?V(t,n,s):U(t,n,s);return h(e,{filePath:n??"stdin.ts",sourceCode:t,declarations:e},s,r)}
|
|
3
|
+
export{rt,Et,bi,wi,xi,tc,An};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
class
|
|
3
|
-
`)}}function
|
|
4
|
-
export{
|
|
2
|
+
class Cn{config;types=new Map;imports=new Map;relationships=[];usageMap=new Map;constructor(e={}){this.config={types:!1,relationships:!1,usage:!1,imports:!1,importUsage:!1,importRelationships:!1,...e}}trackType(e,s){if(!this.config.types)return;if(["interface","type","class","enum"].includes(e.kind)){if(this.types.get(e.name))return;let i={name:e.name,kind:e.kind,file:s,usedBy:new Set,references:new Set,extendsFrom:e.extends?[e.extends]:void 0,implementsFrom:e.implements};if(this.types.set(e.name,i),this.config.relationships){if(e.extends)this.relationships.push({from:e.name,to:e.extends,kind:"extends",file:s});if(e.implements)for(let n of e.implements)this.relationships.push({from:e.name,to:n,kind:"implements",file:s})}}}trackTypeUsage(e,s,t){if(!this.config.usage)return;let i=this.types.get(e);if(i)i.usedBy.add(s);let n=this.usageMap.get(e)||new Set;if(n.add(`${t}:${s}`),this.usageMap.set(e,n),this.config.relationships)this.relationships.push({from:s,to:e,kind:"uses",file:t})}trackImport(e,s,t,i){if(!this.config.imports)return;let n={source:e,specifiers:s,isTypeOnly:t,file:i,usedSpecifiers:new Set,unusedSpecifiers:new Set(s)},r=this.imports.get(i)||[];r.push(n),this.imports.set(i,r)}trackImportUsage(e,s){if(!this.config.importUsage)return;let t=this.imports.get(s);if(!t)return;for(let i of t)if(i.specifiers.includes(e))i.usedSpecifiers.add(e),i.unusedSpecifiers.delete(e)}trackTypeReference(e,s){if(!this.config.types)return;let t=this.types.get(e);if(t)t.references.add(s)}getResults(){let e=[],s=[];for(let[n,r]of this.types)if(r.usedBy.size===0&&r.references.size===0)e.push(n);for(let n of this.imports.values())for(let r of n)if(r.unusedSpecifiers.size===r.specifiers.length)s.push(r);let t=this.detectCircularReferences(),i={totalTypes:this.types.size,usedTypes:this.types.size-e.length,unusedTypes:e.length,totalImports:Array.from(this.imports.values()).flat().length,usedImports:Array.from(this.imports.values()).flat().filter((n)=>n.usedSpecifiers.size>0).length,unusedImports:s.length,totalRelationships:this.relationships.length,circularDependencies:t.length};return{types:this.types,imports:this.imports,relationships:this.relationships,unusedTypes:e,unusedImports:s,circularReferences:t,statistics:i}}detectCircularReferences(){let e=[],s=new Set,t=[],i=(n)=>{if(t.includes(n)){let o=t.indexOf(n);e.push(t.slice(o));return}if(s.has(n))return;s.add(n),t.push(n);let r=this.relationships.filter((o)=>o.from===n&&(o.kind==="extends"||o.kind==="implements"||o.kind==="references")).map((o)=>o.to);for(let o of r)i(o);t.pop()};for(let n of this.types.keys())i(n);return e}clear(){this.types.clear(),this.imports.clear(),this.relationships=[],this.usageMap.clear()}formatResults(){let e=this.getResults(),s=["=== Tracking Results ===",""];if(s.push("Statistics:"),s.push(` Total types: ${e.statistics.totalTypes}`),s.push(` Used types: ${e.statistics.usedTypes}`),s.push(` Unused types: ${e.statistics.unusedTypes}`),s.push(` Total imports: ${e.statistics.totalImports}`),s.push(` Used imports: ${e.statistics.usedImports}`),s.push(` Unused imports: ${e.statistics.unusedImports}`),s.push(` Type relationships: ${e.statistics.totalRelationships}`),s.push(` Circular dependencies: ${e.statistics.circularDependencies}`),s.push(""),e.unusedTypes.length>0){s.push("Unused types:");for(let t of e.unusedTypes){let i=e.types.get(t);s.push(` - ${t} (${i?.kind}) in ${i?.file}`)}s.push("")}if(e.unusedImports.length>0){s.push("Unused imports:");for(let t of e.unusedImports)s.push(` - ${t.source} in ${t.file}`),s.push(` Specifiers: ${Array.from(t.unusedSpecifiers).join(", ")}`);s.push("")}if(e.circularReferences.length>0){s.push("Circular references:");for(let t of e.circularReferences)s.push(` - ${t.join(" -> ")} -> ${t[0]}`);s.push("")}return s.join(`
|
|
3
|
+
`)}}function vn(e){return new Cn(e)}function Sn(e,s,t){for(let i of e){if(t.trackType(i,s),i.typeAnnotation){let n=p(i.typeAnnotation);for(let r of n)t.trackTypeUsage(r,i.name,s)}if(i.extends)t.trackTypeUsage(i.extends,i.name,s);if(i.implements)for(let n of i.implements)t.trackTypeUsage(n,i.name,s);if(i.kind==="import"&&i.source&&i.specifiers)t.trackImport(i.source,i.specifiers.map((n)=>n.name),i.isTypeOnly||!1,s)}}function p(e){let s=[],t=new Set(["string","number","boolean","any","unknown","void","never","null","undefined","object","symbol","bigint","true","false","readonly","keyof","typeof","infer","extends","in","out"]),i=/\b([A-Z]\w*)\b/g,n;while((n=i.exec(e))!==null){let r=n[1];if(!t.has(r.toLowerCase())&&!s.includes(r))s.push(r)}return s}function Ks(e,s){let t=vn({imports:!0,importUsage:!0,importRelationships:!0,...s});for(let[i,n]of e)Sn(n,i,t);return t.getResults()}function qs(e,s){let t=vn({types:!0,relationships:!0,usage:!0,...s});for(let[i,n]of e)Sn(n,i,t);return t.getResults()}
|
|
4
|
+
export{Cn,vn,Sn,Ks,qs};
|