@dtsx/dtsx 0.11.56 → 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-62428w6e.js → chunk-07c41ffx.js} +7 -7
- package/dist/{chunk-j7rpp55s.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-tgaear7n.js → chunk-27rxm6hh.js} +6 -6
- package/dist/chunk-30ffarqm.js +4 -0
- package/dist/{chunk-kkshxyex.js → chunk-37jcvx0v.js} +3 -3
- package/dist/chunk-44a6zpxs.js +3 -0
- package/dist/{chunk-g9emajpc.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-h6ddkhyq.js → chunk-5vk2x8ee.js} +2 -2
- package/dist/{chunk-k8tnz2qd.js → chunk-7116bytq.js} +8 -8
- package/dist/{chunk-6j6dvj8a.js → chunk-78ft65vf.js} +2 -2
- package/dist/{chunk-v22xpr7j.js → chunk-795w1bb2.js} +2 -2
- 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-qt9gjs57.js → chunk-9wgk5qp1.js} +2 -2
- package/dist/{chunk-hbmnkmzb.js → chunk-am4b9zt0.js} +3 -3
- package/dist/chunk-b5wcbnb8.js +9 -0
- package/dist/{chunk-8vvryt8p.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-vk5r6pgx.js → chunk-cs6538bw.js} +2 -2
- package/dist/chunk-d99qykzn.js +6 -0
- package/dist/{chunk-2qbj76ap.js → chunk-e12f4mpd.js} +8 -8
- package/dist/chunk-e21ap86b.js +3 -0
- package/dist/{chunk-f5jc2v3k.js → chunk-ezhvnzja.js} +2 -2
- package/dist/chunk-fnd5bvfd.js +3 -0
- package/dist/chunk-fwqdc8fd.js +3 -0
- package/dist/{chunk-6r01zgys.js → chunk-gkfchhnr.js} +2 -2
- package/dist/chunk-h9gwg4kt.js +9 -0
- package/dist/chunk-hd2bq1j5.js +6 -0
- package/dist/{chunk-g25sbqbw.js → chunk-hpdmtzhk.js} +3 -3
- package/dist/{chunk-v6fwy63g.js → chunk-j2bapmng.js} +2 -2
- package/dist/{chunk-pnfjhm01.js → chunk-j41nnny5.js} +2 -2
- package/dist/{chunk-btcj8fgc.js → chunk-j60x598n.js} +3 -3
- package/dist/{chunk-gwa4hmfa.js → chunk-javyer70.js} +2 -2
- package/dist/chunk-ke1h5m7f.js +5 -0
- package/dist/chunk-kp395d2p.js +44 -0
- package/dist/{chunk-4rsk49xj.js → chunk-mzw42cv7.js} +2 -2
- package/dist/chunk-n2fm08w5.js +2 -0
- package/dist/chunk-n73yp5s4.js +6 -0
- package/dist/{chunk-6ekemc3h.js → chunk-ne7q6jf2.js} +2 -2
- package/dist/{chunk-5bdwrsqt.js → chunk-ngb87w7x.js} +7 -7
- package/dist/chunk-p15wwraa.js +3 -0
- package/dist/{chunk-1mzxq1rg.js → chunk-pb7p64tn.js} +2 -2
- package/dist/chunk-peg2exva.js +3 -0
- package/dist/chunk-pjrnfmwm.js +3 -0
- package/dist/{chunk-mph001z4.js → chunk-pkmjprad.js} +4 -4
- package/dist/{chunk-fpa2ea8k.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-b6994asf.js → chunk-sqhmhd08.js} +2 -2
- package/dist/{chunk-8r7rmcz7.js → chunk-t5x9cy8y.js} +5 -5
- package/dist/chunk-t9w6e58q.js +22 -0
- package/dist/chunk-v0gpmwh9.js +8 -0
- package/dist/{chunk-heqx5083.js → chunk-ves5kf6r.js} +4 -4
- package/dist/{chunk-6c8nk9rm.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-mqv5m22t.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-hgg4aqvf.js → chunk-yfgm2ccr.js} +2 -2
- package/dist/{chunk-nmht3krt.js → chunk-yje9ebc0.js} +4 -4
- package/dist/chunk-yjkhep5n.js +3 -0
- package/dist/{chunk-7dmn623d.js → chunk-ykxeeekb.js} +3 -3
- package/dist/{chunk-9bj73ygx.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/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-0a1xppye.js +0 -3
- package/dist/chunk-0d5nemtn.js +0 -3
- package/dist/chunk-1t77gtcx.js +0 -3
- package/dist/chunk-20jq5v1p.js +0 -14
- package/dist/chunk-38r6thfe.js +0 -3
- package/dist/chunk-4cr1q0yf.js +0 -4
- package/dist/chunk-555w3kcr.js +0 -8
- package/dist/chunk-5tn8854w.js +0 -31
- package/dist/chunk-5yx2x4v4.js +0 -3
- package/dist/chunk-6b6rt0yh.js +0 -3
- package/dist/chunk-7pw9ayve.js +0 -9
- package/dist/chunk-7rdazac9.js +0 -40
- package/dist/chunk-81jrzxr6.js +0 -10
- package/dist/chunk-9h17ws4c.js +0 -2
- package/dist/chunk-9mdgtq38.js +0 -3
- package/dist/chunk-9wwsqemm.js +0 -3
- package/dist/chunk-bt2n0b75.js +0 -4
- package/dist/chunk-c726s7aj.js +0 -6
- package/dist/chunk-cfjd81h8.js +0 -3
- package/dist/chunk-cgqg1br8.js +0 -5
- package/dist/chunk-daasy0pw.js +0 -3
- package/dist/chunk-dak0dhnx.js +0 -3
- package/dist/chunk-djbck65n.js +0 -3
- package/dist/chunk-ekf33t9z.js +0 -6
- package/dist/chunk-eskywkxz.js +0 -22
- package/dist/chunk-ewgs91y1.js +0 -3
- package/dist/chunk-h28vzayq.js +0 -3
- package/dist/chunk-h7ebvy8j.js +0 -3
- package/dist/chunk-hj7gs32r.js +0 -3
- package/dist/chunk-hkcqbex1.js +0 -3
- package/dist/chunk-msa98cgm.js +0 -19
- package/dist/chunk-mzxxgnp8.js +0 -3
- package/dist/chunk-njknd1pt.js +0 -6
- package/dist/chunk-qbk49jz5.js +0 -21
- package/dist/chunk-qhkxctek.js +0 -3
- package/dist/chunk-r46rw8gr.js +0 -29
- package/dist/chunk-rzcnab8j.js +0 -3
- package/dist/chunk-sjbm1trn.js +0 -3
- package/dist/chunk-spdw3tc0.js +0 -18
- package/dist/chunk-srm0ddsk.js +0 -27
- package/dist/chunk-t5nmnzy6.js +0 -7
- package/dist/chunk-tw99ftp1.js +0 -3
- package/dist/chunk-vt5hr8vs.js +0 -3
- package/dist/chunk-wq5r1ms9.js +0 -38
- package/dist/chunk-x6ddycvm.js +0 -3
- package/dist/chunk-yxcyqezk.js +0 -8
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{s}from"./chunk-vjmwxye4.js";import{readFile as D}from"fs/promises";import{dirname as x,relative as g,resolve as C}from"path";async function Zr(r,i={}){let e=new Map,n=i.rootDir||process.cwd(),t=[];for(let o of r){if(i.ignore?.some((p)=>M(o,p)))continue;if(!i.includeNodeModules&&o.includes("node_modules"))continue;t.push(o)}let c=await Promise.all(t.map((o)=>b(o,n)));for(let o=0;o<t.length;o++){let p=c[o];if(p)e.set(t[o],p)}for(let[o,p]of e)for(let a of p.dependencies){let d=e.get(a);if(d)d.dependents.add(o)}return e}async function b(r,i){try{let e=await D(r,"utf-8"),n={path:r,exports:new Set,imports:new Map,dependencies:new Set,dependents:new Set};for(let t of s(e,r,!1)){if(t.isExported&&t.name)n.exports.add(t.isTypeOnly||t.kind==="type"||t.kind==="interface"?"type":t.name);if(!t.source)continue;let c=w(t.source,r,i);if(!c)continue;if(n.dependencies.add(c),t.kind==="import")for(let o of t.specifiers??[])n.imports.set(t.isTypeOnly||o.isType?`type ${o.alias??o.name}`:o.alias??o.name,c)}return n}catch{return null}}function w(r,i,e){if(!r.startsWith(".")&&!r.startsWith("/"))return null;let n=x(i),t=C(n,r);if(t.includes("node_modules"))return null;if(t.endsWith(".ts")||t.endsWith(".tsx"))return t.replace(/\.tsx?$/,".ts");return`${t}.ts`}function M(r,i){let e=i.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(e).test(r)}function ei(r,i={}){let e=[],n=new Set,t=new Set,c=[],o=new Map,p=i.maxDepth||100;function a(d,y){if(y>p)return;if(t.has(d)){let u=o.get(d)??c.indexOf(d),l=c.slice(u);l.push(d);let h=S(l,r),f=z(l,r);if(!i.typesOnly||f)e.push({chain:l,symbols:h,severity:f?"error":"warning",reason:f?"Type-level circular dependency can cause compilation issues":"Value-level circular dependency may cause runtime issues"});return}if(n.has(d))return;let m=r.get(d);if(!m)return;t.add(d),o.set(d,c.length),c.push(d);for(let u of m.dependencies)a(u,y+1);t.delete(d),c.pop(),o.delete(d),n.add(d)}for(let d of r.keys())if(!n.has(d))a(d,0);return N(e)}function S(r,i){let e=[];for(let n=0;n<r.length-1;n++){let t=i.get(r[n]),c=r[n+1];if(t){for(let[o,p]of t.imports)if(p===c)e.push(o)}}return[...new Set(e)]}function z(r,i){return r.some((e)=>e.endsWith(".d.ts")||i.get(e)?.exports.has("type")||[...i.get(e)?.imports.keys()||[]].some((n)=>n.startsWith("type ")||n==="type"))}function N(r){let i=new Set,e=[];for(let n of r){let t=v(n.chain),c=t.join(" -> ");if(!i.has(c))i.add(c),e.push({...n,chain:t})}return e}function v(r){if(r.length<=1)return r;let i=r.slice(0,-1),e=i;for(let n=1;n<i.length;n++){let t=[...i.slice(n),...i.slice(0,n)];if(t.join("")<e.join(""))e=t}return[...e,e[0]]}async function Fs(r,i={}){let e=Date.now(),n=await Zr(r,i),t=ei(n,i);return{hasCircular:t.length>0,cycles:t,graph:n,filesAnalyzed:r,durationMs:Date.now()-e}}function Bs(r,i){let e=[];if(!r.hasCircular)return e.push(`\u2713 No circular dependencies found (${r.filesAnalyzed.length} files analyzed in ${r.durationMs}ms)`),e.join(`
|
|
3
|
+
`);e.push(`\u2717 Found ${r.cycles.length} circular dependency chain(s)`),e.push("");for(let n of r.cycles){let t=n.severity==="error"?"\uD83D\uDD34":"\uD83D\uDFE1";e.push(`${t} ${n.severity.toUpperCase()}: Circular dependency`);let c=n.chain.map((o)=>i?g(i,o):o);if(e.push(` ${c.join(" \u2192 ")}`),n.symbols.length>0)e.push(` Symbols: ${n.symbols.join(", ")}`);e.push(` ${n.reason}`),e.push("")}return e.push(`Analyzed ${r.filesAnalyzed.length} files in ${r.durationMs}ms`),e.join(`
|
|
4
|
+
`)}function _s(r){let i=0,e={file:"",count:0},n={file:"",count:0},t=[];for(let[c,o]of r){let p=o.dependencies.size;if(i+=p,p>e.count)e={file:c,count:p};if(p===0&&o.dependents.size===0)t.push(c);if(o.dependents.size>n.count)n={file:c,count:o.dependents.size}}return{totalFiles:r.size,totalDependencies:i,avgDependencies:r.size>0?i/r.size:0,maxDependencies:e,isolatedFiles:t,mostDepended:n}}function js(r,i){let e=new Set,n=[r];while(n.length>0){let t=n.shift(),c=i.get(t);if(c){for(let o of c.dependents)if(!e.has(o))e.add(o),n.push(o)}}return e}function Gs(r,i){let e=new Set,n=[r];while(n.length>0){let t=n.shift(),c=i.get(t);if(c){for(let o of c.dependencies)if(!e.has(o))e.add(o),n.push(o)}}return e}function Vs(r,i){let e=["digraph dependencies {"," rankdir=LR;"," node [shape=box];",""];for(let[n,t]of r){let c=i?g(i,n):n,o=n.replace(/[^a-z0-9]/gi,"_");e.push(` ${o} [label="${c}"];`);for(let p of t.dependencies){let a=p.replace(/[^a-z0-9]/gi,"_");e.push(` ${o} -> ${a};`)}}return e.push("}"),e.join(`
|
|
5
|
+
`)}function Us(r,i){let e=[];for(let[n,t]of r){let c=i?g(i,n):n;e.push({id:n,path:c,exports:[...t.exports],imports:Object.fromEntries(t.imports),dependencies:[...t.dependencies],dependents:[...t.dependents]})}return JSON.stringify({nodes:e},null,2)}
|
|
6
|
+
export{Zr,ei,Fs,Bs,_s,js,Gs,Vs,Us};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var s=new Map,n=new Map;function
|
|
3
|
-
export{
|
|
2
|
+
var s=new Map,n=new Map;function ac(e){let t=s.get(e);if(t)return s.delete(e),s.set(e,t),t;let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`\\b${o}\\b`);if(s.set(e,c),s.size>500){let r=0;for(let i of s.keys()){if(r++>=50)break;s.delete(i)}}return c}function hr(e){let t=n.get(e);if(t)return n.delete(e),n.set(e,t),t;return null}function gr(e,t){if(n.set(e,t),n.size>200){let o=0;for(let c of n.keys()){if(o++>=20)break;n.delete(c)}}}function yr(){s.clear(),n.clear()}
|
|
3
|
+
export{ac,hr,gr,yr};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`);return{content:d,files:t,declarationCount:D,importCount:w,exportCount:S,size:Buffer.byteLength(d,"utf8"),warnings:[]}}function F(t){if(t.text){let
|
|
4
|
-
`)}`)}e.push("}");break;default:return t.text||""}return e.join(" ")}function V(t){if(!t||t.length===0)return"";return t.map((e)=>{let
|
|
5
|
-
`),m=[],d=0,i=!1;for(let o of b){let
|
|
6
|
-
`),h=B(m[0]);if(!D.has(h)||!e.mergeDuplicates){if(D.add(h),f.push(l),w++,m[0].trim().startsWith("export"))C++}i=!1,m=[]}}else if(
|
|
2
|
+
import{s}from"./chunk-vjmwxye4.js";import{existsSync as j,mkdirSync as N,readFileSync as z,writeFileSync as G}from"fs";import{dirname as K,relative as L,resolve as _}from"path";async function vs(t,e,r){let u=new Map,f=[],x=new Set,D=0,w=0,S=0,C=[];for(let i of t){let o=e.get(i);if(!o)continue;C.push({file:i,decls:s(o,i,r.keepComments)})}for(let{file:i,decls:o}of C){D+=o.length;for(let n of o)if(n.kind==="import"){w++;let c=n.source||"";if(c.startsWith("."))continue;if(!u.has(c))u.set(c,{source:c,specifiers:new Map,isTypeOnly:n.isTypeOnly||!1,isSideEffect:n.isSideEffect||!1});let l=u.get(c);if(n.specifiers)for(let h of n.specifiers){let W=h.alias||h.name;if(!l.specifiers.has(W))l.specifiers.set(W,{name:h.name,alias:h.alias,isType:h.isType||!1})}if(!n.isTypeOnly)l.isTypeOnly=!1}else if(n.isExported||n.kind==="export"){if(S++,n.kind==="export"&&n.source&&(n.source.startsWith(".")||n.source.startsWith("/")))continue;if(n.name&&x.has(n.name))continue;if(n.name)x.add(n.name);f.push({declaration:n,file:i})}}let a=[];a.push("/**"),a.push(" * Bundled TypeScript declarations"),a.push(` * Generated from ${t.length} source files`),a.push(" */"),a.push("");let T=r.importOrder||["bun"],y=Array.from(u.values()),p=Array(y.length);for(let i=0;i<y.length;i++){let o=y[i].source,n=T.length;for(let c=0;c<T.length;c++)if(o.startsWith(T[c])){n=c;break}p[i]=n}let g=y.map((i,o)=>o);g.sort((i,o)=>{let n=p[i],c=p[o];if(n!==c)return n-c;return y[i].source.localeCompare(y[o].source)});let b=g.map((i)=>y[i]);for(let i of b)if(i.isSideEffect)a.push(`import '${i.source}';`);else if(i.specifiers.size>0){let n=Array.from(i.specifiers.values()).map((l)=>{let h=l.isType?"type ":"";return l.alias?`${h}${l.name} as ${l.alias}`:`${h}${l.name}`}),c=i.isTypeOnly?"type ":"";a.push(`import ${c}{ ${n.join(", ")} } from '${i.source}';`)}if(b.length>0)a.push("");let m=new Map;for(let{declaration:i,file:o}of f){if(!m.has(o))m.set(o,[]);m.get(o).push(i)}for(let[i,o]of m){let n=L(r.cwd,i);a.push(`// From: ${n}`);for(let c of o){if(r.keepComments&&c.leadingComments)for(let l of c.leadingComments)a.push(l);a.push(F(c))}a.push("")}let d=a.join(`
|
|
3
|
+
`);return{content:d,files:t,declarationCount:D,importCount:w,exportCount:S,size:Buffer.byteLength(d,"utf8"),warnings:[]}}function F(t){if(t.text){let r=t.text.trim();if(t.isExported&&!r.startsWith("export"))r=`export ${r}`;if(!r.endsWith(";")&&!r.endsWith("}"))r+=";";return r}let e=[];if(t.isExported)e.push("export");if(t.isDefault)e.push("default");switch(t.kind){case"function":if(e.push("declare function"),e.push(t.name),t.generics)e.push(t.generics);if(e.push(`(${V(t.parameters)})`),t.returnType)e.push(`: ${t.returnType}`);break;case"variable":if(e.push("declare const"),e.push(t.name),t.typeAnnotation)e.push(`: ${t.typeAnnotation}`);break;case"interface":if(e.push("interface"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(e.push("{"),t.members)for(let r of t.members)e.push(` ${r.name}${r.typeAnnotation?`: ${r.typeAnnotation}`:""};`);e.push("}");break;case"type":if(e.push("type"),e.push(t.name),t.generics)e.push(t.generics);e.push("="),e.push(t.typeAnnotation||"unknown");break;case"class":if(e.push("declare class"),e.push(t.name),t.generics)e.push(t.generics);if(t.extends)e.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)e.push(`implements ${t.implements.join(", ")}`);if(e.push("{"),t.members)for(let r of t.members)e.push(` ${F(r)}`);e.push("}");break;case"enum":if(e.push("declare enum"),e.push(t.name),e.push("{"),t.members){let r=t.members.map((u)=>u.value!==void 0?`${u.name} = ${u.value}`:u.name);e.push(` ${r.join(`,
|
|
4
|
+
`)}`)}e.push("}");break;default:return t.text||""}return e.join(" ")}function V(t){if(!t||t.length===0)return"";return t.map((e)=>{let r="";if(e.rest)r+="...";if(r+=e.name,e.optional)r+="?";if(e.type)r+=`: ${e.type}`;if(e.defaultValue)r+=` = ${e.defaultValue}`;return r}).join(", ")}async function hn(t,e={}){let r=[],u=new Map,f=[],x=[],D=new Set,w=0,S=0,C=0;for(let p of t){if(!j(p)){r.push(`File not found: ${p}`);continue}let g=z(p,"utf-8");x.push(p);let b=g.split(`
|
|
5
|
+
`),m=[],d=0,i=!1;for(let o of b){let n=o.trim();if(!n&&!i)continue;if(n.startsWith("import ")){S++;let l=n.match(/import\s+(type\s+)?(?:\{([^}]+)\}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/);if(l){let[,h,W,q,H,A]=l;if(e.externals?.some((P)=>A.startsWith(P))){f.push(n);continue}if(A.startsWith("."))continue;if(!u.has(A))u.set(A,{source:A,specifiers:new Map,isTypeOnly:!!h,isSideEffect:!1});let E=u.get(A);if(W){let P=W.split(",").map((k)=>k.trim());for(let k of P){let[I,v]=k.split(/\s+as\s+/).map((M)=>M.trim()),R=I.startsWith("type "),O=R?I.replace("type ",""):I;E.specifiers.set(v||O,{name:O,alias:v!==O?v:void 0,isType:R})}}if(!h)E.isTypeOnly=!1}continue}if(/^(export\s+)?(declare\s+)?(interface|type|class|function|const|let|var|enum|namespace|module)\s/.test(n)){if(i=!0,m=[o],d=(o.match(/\{/g)||[]).length-(o.match(/\}/g)||[]).length,d===0&&(n.endsWith(";")||!n.includes("{"))){let l=B(n);if(!D.has(l)||!e.mergeDuplicates){if(D.add(l),f.push(o),w++,n.startsWith("export"))C++}i=!1,m=[]}}else if(i){if(m.push(o),d+=(o.match(/\{/g)||[]).length-(o.match(/\}/g)||[]).length,d<=0){let l=m.join(`
|
|
6
|
+
`),h=B(m[0]);if(!D.has(h)||!e.mergeDuplicates){if(D.add(h),f.push(l),w++,m[0].trim().startsWith("export"))C++}i=!1,m=[]}}else if(n.startsWith("export ")&&!n.includes("declare"))f.push(o),C++}}let a=[];if(e.banner)a.push(e.banner),a.push("");if(e.includeReferences&&e.references){for(let p of e.references)a.push(`/// <reference types="${p}" />`);a.push("")}let T=Array.from(u.values()).sort((p,g)=>p.source.localeCompare(g.source));for(let p of T)if(p.specifiers.size>0){let b=Array.from(p.specifiers.values()).map((d)=>{let i=d.isType?"type ":"";return d.alias?`${i}${d.name} as ${d.alias}`:`${i}${d.name}`}),m=p.isTypeOnly?"type ":"";a.push(`import ${m}{ ${b.join(", ")} } from '${p.source}';`)}if(T.length>0)a.push("");if(e.ambient&&e.moduleName){a.push(`declare module '${e.moduleName}' {`);for(let p of f){let g=p.split(`
|
|
7
7
|
`).map((b)=>` ${b.replace(/^(\s*)(export\s+)?declare\s+/,"$1$2")}`).join(`
|
|
8
8
|
`);a.push(g)}a.push("}")}else{if(e.sortDeclarations)f.sort((p,g)=>{let b=B(p),m=B(g);return b.localeCompare(m)});for(let p of f)a.push(p)}if(e.footer)a.push(""),a.push(e.footer);let y=a.join(`
|
|
9
|
-
`);return{content:y,files:x,declarationCount:w,importCount:S,exportCount:C,size:Buffer.byteLength(y,"utf-8"),warnings:
|
|
10
|
-
export{
|
|
9
|
+
`);return{content:y,files:x,declarationCount:w,importCount:S,exportCount:C,size:Buffer.byteLength(y,"utf-8"),warnings:r}}function B(t){let e=t.match(/(interface|type|class|function|const|let|var|enum|namespace|module)\s+(\w+)/);return e?`${e[1]}:${e[2]}`:t.trim()}async function jr(t,e,r={}){let u=await hn(t,r),f=K(e);if(!j(f))N(f,{recursive:!0});return G(e,u.content),u}function Ss(t={}){return{bundle:(e)=>hn(e,t),bundleAndWrite:(e,r)=>jr(e,r,{...t,output:r})}}async function $s(t,e=process.cwd()){let r=Array.isArray(t)?t:[t],u=[];for(let f of r){if(f.includes("*"))continue;let x=_(e,f);if(j(x))u.push(x)}return u}
|
|
10
|
+
export{vs,hn,jr,Ss,$s};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{f}from"./chunk-b5wcbnb8.js";function Fa(t){let e=new Map;if(!t.includes("function"))return e;let o=f(t),c=0;for(let r=0;r<o.length;r++){let i=o[r],u=i.start,a=i.end-u;if(c===0&&a===8&&i.kind==="word"&&t.slice(u,i.end)==="function"){let n=r+1,s=o[n];if(s?.kind==="punctuation"&&s.end-s.start===1&&t.charCodeAt(s.start)===42)n++;let d=o[n];if(d?.kind==="word"){let l=t.slice(d.start,d.end);e.set(l,(e.get(l)??0)+1)}continue}if(a===1&&i.kind==="punctuation"){let n=t.charCodeAt(u);if(n===123||n===40||n===91)c++;else if(n===125||n===41||n===93)c--}}return e}function fr(t,e){return Fa(t).get(e)??0}
|
|
3
|
+
export{Fa,fr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class
|
|
3
|
-
export{
|
|
2
|
+
import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class wn{config;profiles=[];cleanupTimer=null;constructor(e={}){this.config={maxMemoryMB:e.maxMemoryMB??512,chunkSize:e.chunkSize??65536,aggressiveGC:e.aggressiveGC??!0,maxDeclarationsInMemory:e.maxDeclarationsInMemory??1e4,profile:e.profile??!1,cleanupInterval:e.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let e=process.memoryUsage();return{heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers,rss:e.rss,heapUsedMB:Math.ceil(e.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(e.heapUsed/e.heapTotal*100))}}async profile(e,t){if(!this.config.profile)return t();let r=this.getMemoryStats(),i=Date.now();try{return await t()}finally{let n=this.getMemoryStats(),s=Date.now()-i;this.profiles.push({timestamp:Date.now(),operation:e,memoryBefore:r,memoryAfter:n,duration:s})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(e){let t=l(e,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),r=u({input:t,crlfDelay:1/0});for await(let i of r)yield i}async processFileInChunks(e,t,r=1000){let i=[],n=[];for await(let s of this.streamFile(e))if(n.push(s),n.length>=r){let a=await t(n);i.push(...a),n=[],this.checkMemoryAndCleanup()}if(n.length>0){let s=await t(n);i.push(...s)}return i}async streamWrite(e,t){let r=c(e,{encoding:"utf-8"});return new Promise((i,n)=>{let s=async()=>{try{for await(let a of t)if(!r.write(a))await new Promise((o)=>r.once("drain",()=>o()));r.end(),r.once("finish",i)}catch(a){n(a)}};r.once("error",n),s()})}}class Kr{declarations=new Map;registry=new FinalizationRegistry((e)=>{this.declarations.delete(e)});maxSize;constructor(e=1e4){this.maxSize=e}add(e,t){if(this.declarations.size>=this.maxSize)this.evictOldest();let r=new WeakRef(t);this.declarations.set(e,r),this.registry.register(t,e)}get(e){return this.declarations.get(e)?.deref()}has(e){return this.declarations.get(e)?.deref()!==void 0}delete(e){this.declarations.delete(e)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let e=Math.ceil(this.maxSize*0.2),t=Array.from(this.declarations.keys());for(let r=0;r<e&&r<t.length;r++)this.declarations.delete(t[r])}}class qr{value=null;loaded=!1;loader;constructor(e){this.loader=e}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class Jr{strings=new Map;maxSize;constructor(e=50000){this.maxSize=e}intern(e){if(e.length>100)return e;let t=this.strings.get(e);if(t!==void 0)return t;if(this.strings.size>=this.maxSize){let r=Array.from(this.strings.keys());for(let i=0;i<r.length/2;i++)this.strings.delete(r[i])}return this.strings.set(e,e),e}get size(){return this.strings.size}clear(){this.strings.clear()}}class Yr{pool=[];factory;reset;maxSize;constructor(e,t,r=1000){this.factory=e,this.reset=t,this.maxSize=r}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(e){if(this.pool.length<this.maxSize)this.reset(e),this.pool.push(e)}get size(){return this.pool.length}clear(){this.pool=[]}}function Ms(e,t={}){return{...e,memory:{maxMemoryMB:t.maxMemoryMB??512,chunkSize:t.chunkSize??65536,aggressiveGC:t.aggressiveGC??!0,maxDeclarationsInMemory:t.maxDeclarationsInMemory??1e4,profile:t.profile??!1,cleanupInterval:t.cleanupInterval??5000}}}function Is(e){let r=m(e).size/1024/1024,i=r*4,n=65536;if(r>10)n=32768;if(r>50)n=16384;return{fileSizeMB:Math.round(r*100)/100,estimatedMemoryMB:Math.round(i*100)/100,recommendedChunkSize:n}}function Ns(e){return[`Heap: ${e.heapUsedMB}MB / ${Math.round(e.heapTotal/1024/1024)}MB (${e.percentUsed}%)`,`RSS: ${Math.round(e.rss/1024/1024)}MB`,`External: ${Math.round(e.external/1024/1024)}MB`].join(" | ")}function Ws(e={}){return new wn(e)}
|
|
3
|
+
export{wn,Kr,qr,Jr,Yr,Ms,Is,Ns,Ws};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{a,i}from"./chunk-ke1h5m7f.js";import{n,f}from"./chunk-b5wcbnb8.js";import{ht,Jt}from"./chunk-30ffarqm.js";import{w}from"./chunk-cb5dj4qy.js";import{r,Zt,en,tn,nn,Z}from"./chunk-kp395d2p.js";function F(p,m){let k=(B)=>n(B).map((h)=>B.slice(h.start,h.end)).join("");return k(p)===k(m)}function fe(p){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(p))return p;let m=r(p,!1);return["number","string","boolean","bigint","undefined","null"].includes(m)?m:void 0}function de(p,m){if(F(p,m))return p;let k=fe(m);if(!k)return;let B=n(p),h=0,S=0,E=[];for(let A of B){let T=p.slice(A.start,A.end);if(T==="("||T==="["||T==="{"||T==="<")h++;else if(T===")"||T==="]"||T==="}"||T===">")h--;else if(T==="|"&&h===0)E.push(p.slice(S,A.start).trim()),S=A.end}E.push(p.slice(S).trim());let O=E.find((A)=>F(A,m));if(O)return O;if(E.includes(k))return k==="boolean"&&(m==="true"||m==="false")?m:k;return}function qt(p){for(let m of p){if(m.kind!=="variable"||m.typeAnnotation||typeof m.value!=="string")continue;let k=en(m.value)??Z(m.value)??Zt(m.value)??nn(m.value)??tn(m.value);if(k&&r(m.value,!1)===k)m.inferredType=k,m.text=`${m.isExported?"export ":""}declare ${m.modifiers?.[0]??"const"} ${m.name}: ${k};`}}function pr(p,m,k,B=new Set){qt([...m,...k.values()]);let h=new Map,S=[],E=new Set;for(let e of[...m,...k.values()]){if(E.has(e))continue;if(E.add(e),S.push(e),e.kind==="import")for(let o of w(e.text))h.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))h.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")h.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}S.sort((e,o)=>(e.start??0)-(o.start??0));let O=new Set(S.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of B)O.add(e);let A=new Map,T=(e)=>{if(e=e.trimStart(),A.has(e))return A.get(e);if(A.set(e,void 0),!a(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!O.has(e.slice(0,o)))return;let t=n(e);if(t[0]?.kind!=="word"||!t[1]||e.slice(t[1].start,t[1].end)!=="(")return;let d=1;for(let s=2;s<t.length;s++){let c=e.slice(t[s].start,t[s].end);if(c==="(")d++;else if(c===")"&&--d===0){let u=s===t.length-1?e.slice(t[0].start,t[0].end):void 0;return A.set(e,u),u}}return},_=new Set(S.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>T(e.value)).filter((e)=>e!==void 0)).size?f(p):void 0,j=new Map;if(_){let e=0;for(let o=0;o<_.length;o++){let t=p.slice(_[o].start,_[o].end);if(e===0&&t==="function"){let d=_[o+1],s=d&&p.slice(d.start,d.end)==="*"?_[o+2]:d;if(s?.kind==="word"){let c=p.slice(s.start,s.end);j.set(c,(j.get(c)??0)+1)}}if(["{","(","["].includes(t))e++;else if(["}",")","]"].includes(t))e--}}let R=new Map;for(let e of S)if(e.kind==="function"&&!e.generics&&j.get(e.name)===1)R.set(e.name,e);for(let e of B){let o=S.find((t)=>t.kind==="import"&&w(t.text).includes(e));if(o)R.set(e,o)}let W="__dtsx_call_result";while(p.includes(W))W+="_";let K=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${W} ? ${W} : never`,X=new Map,H=!1;for(let e of S){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=T(e.value);if(o&&R.has(o))X.set(e,K(o)),h.get(e.name).active=!0,h.get(o).active=!0,H=!0;if(e.modifiers?.[0]!=="const")continue;let t=ht(e.value);if(!t||t===e.name||!h.has(t))continue;h.get(t).active=!0,h.get(e.name).active=!0,H=!0}if(!H)return;let g=_??f(p),l=(e)=>g[e]?p.slice(g[e].start,g[e].end):"",y=new Map,z=new Map,G=new Set,L=new Set,J=new Set,Q=new Map,x=[];for(let e=0;e<g.length;e++){let o=l(e),t=x.at(-1);if(t!==void 0)z.set(e,t);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(l(e-1)))G.add(e);if(["(","[","{"].includes(o))x.push(e);else if([")","]","}"].includes(o)){let d=x.at(-1);if(d!==void 0&&["()","[]","{}"].includes(l(d)+o))x.pop(),y.set(d,e)}}let Y=new Map;for(let e=0;e<g.length;){if(g[e].kind!=="punctuation"){e++;continue}let t=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>p.startsWith(s,g[e].start))??l(e);Y.set(e,t);let d=g[e].start+t.length;do e++;while(e<g.length&&g[e].start<d)}for(let e=0;e<g.length;e++){let o=te(e);if(o!==void 0)L.add(o)}for(let e of L)ce(e);let v=0;function ee(e){let o=ht(e);if(o){let c=h.get(o);return{type:c?.flow,unresolved:c?.unresolved??!1}}let t=T(e),d=t?R.get(t):void 0;if(d)return{type:d.returnType&&fe(d.returnType)?d.returnType:K(t),unresolved:!1};let s=r(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function C(e){return Y.get(e)??""}function P(e){if(g[e]?.kind!=="word"||J.has(e)||l(e-1)==="."||l(e-1)==="#"&&l(e-2)===".")return;let o=h.get(l(e));if(!o?.active)return;let t=C(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(t))return{binding:o,operator:t};if(["++","--"].includes(t)&&!/[\r\n]/.test(p.slice(g[e].end,g[e+1].start)))return{binding:o,operator:t};if(e>=2&&["++","--"].includes(C(e-2))){let d=g[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(l(e-3)));if(!d||!s||/[\r\n;]/.test(p.slice(d.end,g[e-2].start)))return{binding:o,operator:C(e-2)}}return}function ne(e){let o=P(e);return o?.operator==="="?o.binding:void 0}function te(e){if(g[e]?.kind!=="word"||l(e)!=="class"||l(e-1)==="."||["(",":","="].includes(l(e+1)))return;let o=e+1,t=0;while(o<g.length){let d=l(o);if(d==="{"&&t===0)return o;if(d==="class"){let s=te(o);if(s!==void 0){o=(y.get(s)??s)+1;continue}}if(d==="function"){let s=oe(o,g.length);if(s){o=s.end;continue}}if(d==="<")t++;else if(d===">"&&C(o-1)!=="=>"&&t>0)t--;if(d===";")break;o=(y.get(o)??o)+1}return}function ie(e,o,t){let d=e,s=!1,c=t?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(c.includes(l(d))&&!["(","<","?","!",":","=",";","}"].includes(l(d+1))){if(l(d)==="static")s=!0;d++}if(l(d)==="*")d++;if(t&&l(d)==="#")d++;if(l(d)==="["){let b=y.get(d);return b===void 0?void 0:{next:b+1,isStatic:s}}if(g[d]?.kind==="word"||g[d]?.kind==="quoted")return{next:d+1,isStatic:s};let u=d+1;while(u<o&&g[u-1].end===g[u].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(l(u)))u++;if(d<o&&r(p.slice(g[d].start,g[u-1].end),!1)==="number")return{next:u,isStatic:s};return}function U(e,o,t){let d=ie(e,o,t);if(!d)return;let s=d.next;if(t&&["?","!"].includes(l(s)))s++;if(l(s)==="<"){let c=1;s++;while(s<o&&c>0){if(l(s)==="<")c++;else if(l(s)===">"&&C(s-1)!=="=>")c--;s=(y.get(s)??s)+1}if(c!==0)return}return s}function re(e,o,t){return U(e,o,t)===o}function ae(e,o){let t=0,d=-1;for(let s=e;s<o;s=(y.get(s)??s)+1)if(l(s)==="<"&&(t>0||s>e&&(g[s-1].kind==="word"||[")","]"].includes(l(s-1))))){if(t===0)d=s;t++}else if(l(s)===">"&&C(s-1)!=="=>"&&t>0){if(t--,s===o-1&&t===0)return d<s-1}return!1}function le(e,o){if(l(e)==="static"&&l(e+1)==="{")return!0;let t=U(e,o,!0);return t!==void 0&&(t===o||["(",":","=",";","}"].includes(l(t)))}function V(e,o,t=!1){let d=y.get(o)??g.length,s=e;while(s<d){if(l(s)===";"||t&&C(s)==="=")return s;if(s>e&&z.get(s)===o&&/[\r\n]/.test(p.slice(g[s-1].end,g[s].start))){let c=l(s-1),b=!(c===">"&&ae(e,s)&&le(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(c),M=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(l(s));if(!b&&!M)return s}s=(y.get(s)??s)+1}return d}function q(e,o){for(let t=e;t<o;t++){if(l(t)==="["&&y.has(t)){t=y.get(t);continue}if(g[t].kind==="word")J.add(t)}}function ce(e){let o=y.get(e)??g.length,t=e+1;while(t<o){if(l(t)===";"){t++;continue}if(l(t)==="static"&&l(t+1)==="{"){t=(y.get(t+1)??t+1)+1;continue}let d=ie(t,o,!0);if(!d){t++;continue}let s=U(t,o,!0);if(s===void 0){t++;continue}if(q(t,s),l(s)==="("){let u=y.get(s),b=u===void 0?void 0:se(u,o);if(b!==void 0){t=(y.get(b)??b)+1;continue}}let c=s;if(l(c)===":")c=V(c+1,e,!0);if(C(c)==="="){q(t,c+1);let u=c+1,b=V(u,e);if(!d.isStatic&&b>u)Q.set(u,b);t=b}else{let u=V(s,e);q(t,u),t=Math.max(t+1,u)}}}function ue(e){let o=z.get(e);if(o===void 0)return!1;let t=L.has(o);if(!t&&!G.has(o))return!1;if(re(o+1,e,t))return!0;for(let d=o+1;d<e;d++){let s=z.get(d),c=z.get(d)===o&&(l(d)===","||t&&l(d)===";"),u=t&&l(d)==="}"&&s!==void 0&&z.get(s)===o,b=t&&z.get(d+1)===o&&/[\r\n]/.test(p.slice(g[d].end,g[d+1].start));if((c||u||b)&&re(d+1,e,t))return!0}return!1}function se(e,o){let t=e+1,d=l(t)===":"?t+1:void 0;while(t<o){if(l(t)==="{"&&(d===void 0||!Jt(p.slice(g[d].start,g[t].start))))return t;if(d===void 0)return;t=(y.get(t)??t)+1}return}function oe(e,o){let t=-1;if(l(e)==="("){let s=y.get(e);if(s!==void 0&&ue(e))t=se(s,o)??-1;else if(s!==void 0&&C(s+1)==="=>")t=s+3;else if(s!==void 0&&l(s+1)===":"){let c=s+2;while(c<o&&l(c)!==";"){if(C(c)==="=>"){t=c+2;break}c=(y.get(c)??c)+1}}}else if(g[e]?.kind==="word"&&C(e+1)==="=>")t=e+3;else if(l(e)==="function"){let s=e+1;while(s<o&&l(s)!=="(")s=(y.get(s)??s)+1;let c=y.get(s);if(c===void 0)return;t=c+1;let u=l(t)===":"?t+1:void 0;while(t<o){if(l(t)==="{"&&(u===void 0||!Jt(p.slice(g[u].start,g[t].start))))break;t=(y.get(t)??t)+1}}if(t<0||t>=o)return;if(l(t)==="{")return{start:e,end:(y.get(t)??o-1)+1};let d=t;while(d<o&&![",",";",")","]","}"].includes(l(d)))d=(y.get(d)??d)+1;return{start:e,end:d}}function N(e,o,t=!0){for(let d=e;d<o;d++){let s=Q.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let c=t?oe(d,o):void 0;if(c){let b=c.end;while(l(b)===")")b++;if(l(b)==="("||l(b)==="."&&["call","apply"].includes(l(b+1))&&l(b+2)==="(")N(c.start,c.end,!1);d=c.end-1;continue}let u=P(d);if(u)u.binding.flow=void 0,u.binding.unresolved=!0}}function ge(e){let o=!1;while(v<g.length&&g[v].start<e){let t=l(v);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(t))o=!0;if(t===";")o=!1;if(t==="("||t==="{"||t==="["){let u=y.get(v)??v+1;while(u<g.length&&g[u].start>=e)u--;if(N(v+1,u),v=u+1,t==="{")o=!1;continue}let d=ne(v);if(d){let c=v+2,u=c,b=[];while(u<g.length&&g[u].start<e){let D=l(u);if(b.length===0&&(D===";"||u>c&&/[\r\n]/.test(p.slice(g[u-1].end,g[u].start))&&(ne(u)||["if","for","while","switch","try","do","return","throw"].includes(D))))break;if(D==="("||D==="{"||D==="[")b.push(D==="("?")":D==="{"?"}":"]");else if(D===b.at(-1))b.pop();u++}let M=u>c?p.slice(g[c].start,g[u-1].end):"";N(c,u);let I=ee(M);d.flow=!o&&I.type?d.declared?de(d.declared,I.type):I.type:void 0,d.unresolved=o||I.unresolved||!d.flow,v=u;continue}let s=P(v);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;v++}}for(let e of S){ge(e.start??0);let o=v;while(v<g.length&&g[v].start<(e.end??0))v++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let M=o;while(M<v&&g[M].start<e.initializerStart)M++;N(M,v)}let t=h.get(e.name);if(!t.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){t.flow=t.declared;continue}let s=ee(d),c=ht(d),u=c?h.get(c):void 0,b=X.get(e);if(b)e.inferredType=b;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&c&&c!==e.name&&u){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=u.declared&&F(u.declared,s.type)?`typeof ${c}`:s.type}if(e.inferredType)e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${e.inferredType};`;if(e.typeAnnotation)t.flow=s.type?de(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)t.declared=e.inferredType,t.flow=e.inferredType;else{let M=e.modifiers?.[0]==="const",I=d.trim().startsWith("{")||d.trim().startsWith("["),D=r(d,M&&!I);t.declared=D==="unknown"?void 0:D,t.flow=t.declared}t.unresolved=s.unresolved}}
|
|
3
|
+
export{qt,pr};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{f}from"./chunk-b5wcbnb8.js";import{b,v}from"./chunk-cs6538bw.js";function D(h){let i=f(h),e=0,T,N,g,F=[new Map,new Map],n=(t=e)=>i[t]?h.slice(i[t].start,i[t].end):"",c=(t=e)=>i[t]?.kind==="word",y=(t,s)=>/[\r\n]/.test(h.slice(t,s));function r(t){if(n()!==t)return!1;return e++,!0}function k(t){let s=e;for(let l of t)if(!r(l)||e>s+1&&i[e-2].end!==i[e-1].start)return e=s,!1;return!0}function w(t){let s=e;if(t())return!0;return e=s,!1}function d(){if(!c())return!1;return e++,!0}function q(){let t=e,s=e;while(s<i.length&&(s===t||i[s-1].end===i[s].start)){let u=n(s),o=(u==="+"||u==="-")&&/[eE]$/.test(n(s-1));if(!c(s)&&!/^[0-9.]$/.test(u)&&!o)break;s++}if(s===t)return!1;let l=h.slice(i[t].start,i[s-1].end);if(!b(l)&&!v(l))return!1;return e=s,!0}function O(){if(!["(","[","{"].includes(n()))return!1;if(!T){T=new Map;let s=[];for(let l=0;l<i.length;l++){let u=n(l);if(["(","[","{"].includes(u))s.push(l);else if([")","]","}"].includes(u)){let o=s.pop();if(o!==void 0&&["()","[]","{}"].includes(n(o)+u))T.set(o,l+1);else s.length=0}}}let t=T.get(e);if(t===void 0)return!1;return e=t,!0}function G(){return d()||(n()==="{"||n()==="[")&&O()}function S(){if(!r("("))return!1;if(r(")"))return!0;do{if(k("..."),!G())return!1;if(r("?"),r(":")&&!a())return!1;if(n()===")")break}while(r(",")&&n()!==")");return r(")")}function x(){if(!r("<"))return!1;if(n()===">")return!1;do{if(n()==="const")e++;while((n()==="in"||n()==="out")&&c(e+1)&&n(e+1)!=="extends")e++;if(!d())return!1;if(r("extends")&&!a(!1))return!1;if(r("=")&&!a())return!1;if(n()===">")break}while(r(",")&&n()!==">");return r(">")}function E(){if(!r("<")||n()===">")return!1;do{if(!a())return!1;if(n()===">")break}while(r(",")&&n()!==">");return r(">")}function H(){if(r("abstract"),r("new"),n()==="<"&&!x())return!1;return S()&&k("=>")&&A()}function J(){if(i[e]?.kind!=="literal"||h.charCodeAt(i[e].start)!==96)return!1;for(;;){let t=i[e++];if(!t)return!1;if(h.charCodeAt(t.end-1)===96)return!0;if(h.charCodeAt(t.end-1)!==36||!r("{")||!a()||!r("}"))return!1;if(i[e]?.kind!=="literal")return!1}}function K(){if(!r("["))return!1;if(r("]"))return!0;do{k("...");let t=e;if(c()||i[e]?.kind==="quoted"){if(e++,r("?"),!r(":"))e=t}if(!a())return!1;if(r("?"),n()==="]")break}while(r(",")&&n()!=="]");return r("]")}function A(){if(r("asserts")){if(!d())return!1;return!r("is")||a()}if(c()&&n(e+1)==="is")return e+=2,a();return a()}function B(){if(n()==="<"&&!x())return!1;if(!S())return!1;return!r(":")||A()}function Q(){if(!r("["))return!1;if(c()&&(n(e+1)==="in"||n(e+1)===":")){e++;let t=r("in");if(!t&&!r(":"))return!1;if(!a())return!1;if(t&&r("as")&&!a())return!1}else{if(!d()&&!q()){if(i[e]?.kind!=="quoted")return!1;e++}while(r("."))if(!d())return!1}return r("]")}function L(){if(n()==="[")return Q();if(d()||q())return!0;if(i[e]?.kind!=="quoted")return!1;return e++,!0}function U(){if(n()!=="get"&&n()!=="set")return;let t=e++;e=L()&&n()==="("?t+1:t}function P(){if(!r("{"))return!1;while(!r("}")){if(e>=i.length)return!1;let t=e;if((n()==="+"||n()==="-")&&n(e+1)==="readonly")e++;if(n()==="readonly"&&n(e+1)!==":"&&n(e+1)!=="?"&&n(e+1)!=="("&&n(e+1)!==";"&&n(e+1)!=="}")e++;if(n()==="new"&&(n(e+1)==="("||n(e+1)==="<"))e++;if(n()==="("||n()==="<"){if(!B())return!1}else{if(U(),!L())return!1;if(n()==="+"||n()==="-"){if(e++,!r("?"))return!1}else r("?");if(r(":")){if(!a())return!1}else if(n()==="("||n()==="<"){if(!B())return!1}}if(e===t)return!1;if(r(";")||r(","))continue;if(n()!=="}"&&!y(i[e-1].end,i[e]?.start??h.length))return!1}return!0}function R(){if(w(H))return!0;if(r("("))return a()&&r(")");if(n()==="{")return P();if(n()==="[")return K();if(w(J))return!0;if(i[e]?.kind==="quoted")return e++,!0;if(r("-"))return q();if(w(q))return!0;if(r("typeof")){if(n()==="import")return R();if(!d())return!1;while(r("."))if(!d())return!1;if(n()==="<"&&!E())return!1;return!0}if(r("import")){if(!r("(")||!a())return!1;if(r(",")&&!P())return!1;return r(")")}if(["export","function","class","const","let","var","return","throw","default","new","abstract"].includes(n()))return!1;return d()}function M(){if(n()==="keyof"||n()==="readonly"||n()==="unique")return e++,M();if(r("infer")){if(!d())return!1;if(r("extends")&&!a(!1))return!1;return!0}if(!R())return!1;for(;;)if(r(".")){if(!d())return!1}else if(n()==="<"){if(y(i[e-1].end,i[e].start))return!0;if(!E())return!1}else if(n()==="["){if(y(i[e-1].end,i[e].start))return!0;if(e++,!r("]")&&!(a()&&r("]")))return!1}else return!0}function j(){if(r("&"),!M())return!1;while(r("&"))if(!M())return!1;return!0}function a(t=!0){let s=e,l=F[t?1:0],u=l.get(s);if(u!==void 0){if(u<0)return!1;return e=u,!0}let o=V(t);if(l.set(s,o?e:-1),!o)e=s;return o}function V(t){if(r("|"),!j())return!1;while(r("|"))if(!j())return!1;if(t&&n()==="extends"&&!y(i[e-1].end,i[e].start))return e++,a(!1)&&r("?")&&a()&&r(":")&&a();return!0}function W(){if(n()!=="("||!O())return!1;if(r(":")&&!A())return!1;return k("=>")}function X(){r("async");let t=r("function");if(t){if(r("*"),c())e++}if(n()==="<"&&!x())return!1;if(n()!=="("||!O())return!1;if(r(":")&&!A())return!1;return t?n()==="{":k("=>")}function Y(){let t=n();if(t==="<"||t===">"||t==="+"||t==="-")return!1;if(t==="("||i[e]?.kind==="literal"&&h.charCodeAt(i[e].start)===96)return!0;if(!i[e]||y(i[e-1].end,i[e].start))return!0;if(["*","/","%","=","&","|","^","?",":",",",";",")","]","}","in","instanceof","as","satisfies"].includes(t))return!0;if(t==="!")return n(e+1)==="="&&i[e].end===i[e+1]?.start;return!c()&&i[e]?.kind!=="quoted"&&i[e]?.kind!=="literal"&&!["{","[","~","#","@"].includes(t)&&!/^[0-9]$/.test(t)}return(t,s,l)=>{let u=0,o=i.length;while(u<o){let m=u+o>>>1;if(i[m].start<t)u=m+1;else o=m}if(i[u]?.start!==t)return;if(N!==s){N=s,g=void 0;let m=0,C=u;while(m<C){let I=m+C>>>1;if(i[I].start<s)m=I+1;else C=I}if(e=m,X())g=n()==="{"?i[e].start:i[e-1].end}if(g!==void 0&&t<g)return{end:g,completeOperand:!1,parameters:!0};if(n(u)!=="<")return;e=u;let p=n(u-1),z=t===s||["=","+","-","*","/","%","&","|","^","!","~","?",":","<",">","void","typeof","await","yield","delete"].includes(p);if((p==="function"||p==="class"||p==="*"&&n(u-2)==="function"||c(u-1)&&(n(u-2)==="function"||n(u-2)==="class"||n(u-2)==="*"&&n(u-3)==="function"))&&w(x))return{end:i[e-1].end,completeOperand:!1,parameters:!0};if(e=u,(z||p==="async")&&w(x)){let m=i[e-1].end;if(w(W))return{end:m,completeOperand:!1,parameters:!0}}e=u;let Z=p==="."&&n(u-2)==="?"&&i[u-2].end===i[u-1].start;if((i[u-1]?.end??-1)>=s&&(Z||c(u-1)||p===")"||p==="]"||p==="!"||p===">"&&i[u-1].end===l)&&w(E)&&Y())return{end:i[e-1].end,completeOperand:!0};if(e=u,z&&r("<")&&a()&&r(">"))return{end:i[e-1].end,completeOperand:!1};return}}
|
|
3
|
+
export{D};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`),l=[],c=[],g=-1;for(let n=0;n<u.length;n++){let a=u[n].trim();if(a.startsWith("import "))l.push(u[n]),c.push(n),g=n;else if(l.length>0&&a==="")continue;else if(l.length>0&&!a.startsWith("import "))break}if(l.length===0)return e;let m=
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
2
|
+
var gn=["builtin","external","internal","parent","sibling","index","type","unknown"];function yn(e){let i=e.match(/^(import\s+)(type\s+)?(.+?)\s+from\s+['"]([^'"]+)['"]/);if(!i){let p=e.match(/^import\s+['"]([^'"]+)['"]/);if(p)return{statement:e,source:p[1],isTypeOnly:!1,group:xt(p[1]),specifiers:[]};return null}let[,,u,l,c]=i,g=!!u,m,h,f=[],n=l.trim(),a=n.match(/^\*\s+as\s+(\w+)$/);if(a)h=a[1];else if(n.includes("{")){let p=n.match(/^(\w+)\s*,/);if(p)m=p[1];let d=n.match(/\{([^}]+)\}/);if(d){let I=d[1].split(",").map((y)=>y.trim()).filter(Boolean);f.push(...I)}}else if(/^\w+$/.test(n))m=n;else{let p=n.match(/\{([^}]+)\}/);if(p){let d=p[1].split(",").map((I)=>I.trim()).filter(Boolean);f.push(...d)}}return{statement:e,source:c,isTypeOnly:g,group:xt(c,g),specifiers:f,defaultImport:m,namespaceImport:h}}function xt(e,i=!1){if(i)return"type";if(e.startsWith("node:")||O(e))return"builtin";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e==="."||e==="./index")return"index";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@")||/^[a-z]/.test(e))return"external";return"unknown"}var b=new Set(["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"]);function O(e){return b.has(e)}function bn(e,i={}){let{order:u=[],groupByType:l=!0,groups:c=gn,alphabetize:g=!0,caseInsensitive:m=!0,typeImportsLast:h=!1,separateTypeImports:f=!1}=i,n=[];for(let t of e){let r=yn(t);if(r)n.push(r);else n.push({statement:t,source:"",isTypeOnly:!1,group:"unknown",specifiers:[]})}let a=u.length>0?u.map((t)=>{if(t.startsWith("^"))try{return{regex:new RegExp(t),prefix:t.slice(1)}}catch{return{prefix:t.slice(1)}}return{prefix:t}}):[],p=(t)=>{for(let r=0;r<a.length;r++){let s=a[r];if(s.regex){if(s.regex.test(t))return r}else if(t.startsWith(s.prefix)||t.includes(`/${s.prefix}`))return r}return a.length},d=new Map,I=(t)=>{let r=d.get(t);if(r!==void 0)return r;let s=c.indexOf(t),o=s>=0?s:c.length;return d.set(t,o),o},y=(t,r)=>{if(a.length>0){let s=p(t.source),o=p(r.source);if(s!==o)return s-o}if(l){let s=I(t.group),o=I(r.group);if(s!==o)return s-o}if(h&&t.isTypeOnly!==r.isTypeOnly)return t.isTypeOnly?1:-1;if(g){let s=m?t.source.toLowerCase():t.source,o=m?r.source.toLowerCase():r.source;return s.localeCompare(o)}return 0};if(n.sort(y),l){let t=[],r=null;for(let s of n){if(r!==null&&s.group!==r){let o=c.indexOf(r),x=c.indexOf(s.group);if(o>=0&&x>=0&&o!==x)t.push("")}t.push(s.statement),r=s.group}return t}return n.map((t)=>t.statement)}function Gr(e,i={}){let u=e.split(`
|
|
3
|
+
`),l=[],c=[],g=-1;for(let n=0;n<u.length;n++){let a=u[n].trim();if(a.startsWith("import "))l.push(u[n]),c.push(n),g=n;else if(l.length>0&&a==="")continue;else if(l.length>0&&!a.startsWith("import "))break}if(l.length===0)return e;let m=bn(l,i),h=u.slice(0,c[0]),f=u.slice(g+1);while(f.length>0&&f[0].trim()==="")f.shift();return[...h,...m,"",...f].join(`
|
|
4
|
+
`)}function ks(e={}){return{sort:(i)=>bn(i,e),sortContent:(i)=>Gr(i,e),parse:yn,detectGroup:xt}}var Es={default:{groupByType:!0,groups:gn,alphabetize:!0,caseInsensitive:!0},node:{order:["node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},bun:{order:["bun","node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},typeSeparated:{groupByType:!0,groups:["builtin","external","internal","parent","sibling","index","type"],separateTypeImports:!0,alphabetize:!0},alphabetical:{groupByType:!1,alphabetize:!0,caseInsensitive:!0},none:{groupByType:!1,alphabetize:!1}};
|
|
5
|
+
export{gn,yn,xt,bn,Gr,ks,Es};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
defineProps<${s}>()`,null)}function
|
|
4
|
-
`)&&o===0){let
|
|
5
|
-
`),o=null,r=
|
|
2
|
+
import{It,Nt,d,_e,st,Wt,Lt,ot,at,ct,Ft,lt,Bt,_t}from"./chunk-9axwjcna.js";function I(t){return t.endsWith(".stx")}function h(t){let n=[],s=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,o;while((o=s.exec(t))!==null){let r=o[1]??"",i=/\blang\s*=\s*["']([^"']+)["']/i.exec(r)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(r)?"ts":"js"),e=/\bserver\b/i.test(r)?"server":/\bclient\b/i.test(r)?"client":"universal";n.push({content:o[2]??"",kind:"script",attrs:r,context:e,lang:i,start:o.index})}return n}function y(t){let n=[],s=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,o;while((o=s.exec(t))!==null){let r=s.lastIndex,i=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;i.lastIndex=r;let e=i.exec(t),l=e?.index??t.length;if(n.push({content:t.slice(r,l),kind:"ts",attrs:"",context:"universal",lang:"ts",start:o.index}),!e)break;s.lastIndex=i.lastIndex}return n}function Ko(t){return[...h(t),...y(t)].sort((n,s)=>n.start-s.start)}function k(t){if(t.kind==="ts"||t.context!=="universal"||t.lang==="ts")return!0;return/\b(?:defineProps|defineEmits|defineExpose|defineSlots)\b|\bexport\s|\b(?:interface|type)\s+[A-Za-z_$]/.test(t.content)}function w(t){let n=/(?:\$?props)\s+as\s+/g,s;while((s=n.exec(t))!==null){let o=n.lastIndex;while(o<t.length&&/\s/.test(t[o]))o++;if(t[o]==="{"){let e=d(t,o,"{","}");if(e!==-1)return t.slice(o,e+1).trim();continue}let r=/^[A-Za-z_$][\w$]*/.exec(t.slice(o))?.[0];if(!r)continue;let i=o+r.length;while(i<t.length&&/\s/.test(t[i]))i++;if(t[i]==="<"){let e=d(t,i,"<",">");if(e!==-1)i=e+1}return t.slice(o,i).trim()}return null}function T(t){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(t)?.[1]?.trim()??null}function E(t){let n=/^\s*(?:\|\||\?\?)\s*([^;\n]+)/.exec(t)?.[1]?.trim();if(/^['"`]/.test(n??""))return"string";if(/^(?:true|false)\b/.test(n??""))return"boolean";if(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)\b/.test(n??""))return"number";if(/^\[/.test(n??""))return"unknown[]";if(/^\{/.test(n??""))return"Record<string, unknown>";if(/^\s*(?:===?|!==?)\s*(?:true|false)\b/.test(t))return"boolean";return"unknown"}function P(t,n){if(!t||t==="unknown")return n;if(n==="unknown"||t===n)return t;return[...new Set([...t.split(" | "),...n.split(" | ")])].join(" | ")}function v(t){let n=Nt(t),s=new Map,o=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,r;while((r=o.exec(t))!==null){if(n.slice(r.index,r.index+6)!=="$props")continue;let e=r[1]??r[3],l=E(t.slice(o.lastIndex));s.set(e,P(s.get(e),l))}if(s.size===0)return null;return{type:`{ ${[...s].map(([e,l])=>`${/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}?: ${l}`).join(", ")} }`}}function A(t){let n=lt(t,null);if(n)return n;let s=w(t)??T(t);if(!s)return v(t);if(/^[A-Za-z_$][\w$]*$/.test(s)){let o=s.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${o}\\b`).test(t))return{type:s}}return lt(`${t}
|
|
3
|
+
defineProps<${s}>()`,null)}function C(t){return Wt(t)}function S(t){let n=Nt(t).trimStart();if(n==="")return!0;return/^(?:import\b|export\b|declare\b|interface\b|type\b|(?:export\s+)?namespace\b|(?:export\s+)?module\b|(?:abstract\s+)?class\b|const\b|let\b|var\b|(?:async\s+)?function\b)/.test(n)}function R(t){let n=[],s=0,o=0,r=0;while(r<t.length){let e=t[r],l=It(t,r);if(l>r){r=l;continue}if(e==="{"||e==="["||e==="(")o++;else if(e==="}"||e==="]"||e===")")o=Math.max(0,o-1);if((e===";"||e===`
|
|
4
|
+
`)&&o===0){let c=r+1;if(!S(t.slice(s,c)))n.push([s,c]);s=c}r++}if(s<t.length&&!S(t.slice(s)))n.push([s,t.length]);let i=t;for(let e=n.length-1;e>=0;e--)i=i.slice(0,n[e][0])+i.slice(n[e][1]);return i}function _(t){let s=Ko(t).filter(k).map((u)=>u.content).join(`
|
|
5
|
+
`),o=null,r=Lt(s);if(r.passthrough)return s;if(s=r.script,r.options){let u=ot(r.options,"props");if(u)o=st(u)}let i=s,e=C(s),l=A(i),c=l?.type??o??"{}",x=Bt(i,null),m=_t(i,null),g=_e(i,"defineSlots")?.generic??null,f=l?.inlinedLocal;if(f)e=ct(e,f.name,f.declText);let a=`DefineComponent<${c}>`,p=[];if(x)p.push(`readonly __stxEmits?: ${x}`);if(g)p.push(`readonly __stxSlots?: ${g}`);if(m)p.push(`readonly __stxExposed?: ${m}`);if(p.length>0)a+=` & { ${p.join(", ")} }`;a=Ft(a),e=R(at(e,a));let b=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${a}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(e.trim()!=="")b.push(e);return b.join(`
|
|
6
6
|
`)}
|
|
7
|
-
export{
|
|
7
|
+
export{I,Ko,_};
|
|
@@ -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};
|