@dtsx/dtsx 0.11.46 → 0.11.48
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-2h5p8n7w.js → chunk-02yqpwv0.js} +2 -2
- package/dist/{chunk-0gwj2fct.js → chunk-1dnqddk9.js} +1 -1
- package/dist/chunk-29m9mhwt.js +3 -0
- package/dist/{chunk-0nw1w523.js → chunk-475bjqea.js} +4 -4
- package/dist/{chunk-6m8f0y7w.js → chunk-4e02xmrg.js} +1 -1
- package/dist/{chunk-ga769zw5.js → chunk-4kv50gfv.js} +1 -1
- package/dist/{chunk-c7dw612y.js → chunk-564pr6v4.js} +1 -1
- package/dist/{chunk-2wxgt73q.js → chunk-689tfwjh.js} +1 -1
- package/dist/{chunk-nmjxxcvg.js → chunk-8dyz1cte.js} +8 -8
- package/dist/{chunk-ry1c863d.js → chunk-8hwmssy9.js} +1 -1
- package/dist/{chunk-rkpwmkrm.js → chunk-adhnnbe1.js} +1 -1
- package/dist/{chunk-kdqckf54.js → chunk-agq858s0.js} +1 -1
- package/dist/{chunk-trvp818c.js → chunk-atzh1g6f.js} +1 -1
- package/dist/{chunk-pjqd38w1.js → chunk-bxjswrak.js} +1 -1
- package/dist/{chunk-xg8yhpe6.js → chunk-c87yyjv7.js} +2 -2
- package/dist/{chunk-hcf0hd85.js → chunk-cgrta603.js} +1 -1
- package/dist/{chunk-em9pz9s0.js → chunk-cgz4sy6k.js} +1 -1
- package/dist/chunk-d0dbet9n.js +7 -0
- package/dist/{chunk-z0aa0gd8.js → chunk-d27xpsa4.js} +1 -1
- package/dist/{chunk-ehpz5rg3.js → chunk-ex02f2vm.js} +15 -15
- package/dist/{chunk-ac95p5v4.js → chunk-fkngq7na.js} +3 -3
- package/dist/{chunk-j32xn94r.js → chunk-fn2xxavw.js} +1 -1
- package/dist/{chunk-yaej6q2v.js → chunk-g4eb5tgt.js} +1 -1
- package/dist/{chunk-gsvb5wey.js → chunk-h2007n8k.js} +1 -1
- package/dist/{chunk-6bmr0e81.js → chunk-h5esm323.js} +2 -2
- package/dist/{chunk-zaka2jk1.js → chunk-h6ngkqg7.js} +1 -1
- package/dist/{chunk-t89jepjk.js → chunk-hnw7mwcw.js} +1 -1
- package/dist/chunk-hzjesnf1.js +38 -0
- package/dist/{chunk-dpd2b7dd.js → chunk-hzybfasv.js} +1 -1
- package/dist/{chunk-2xp48sa2.js → chunk-jjdjk59m.js} +1 -1
- package/dist/{chunk-yapmefw7.js → chunk-kdz4gxdq.js} +18 -18
- package/dist/{chunk-t7jvkq9j.js → chunk-mjaf2je8.js} +1 -1
- package/dist/{chunk-0af0hsfc.js → chunk-mm1cfz16.js} +4 -4
- package/dist/{chunk-swmftav9.js → chunk-nf10pph8.js} +1 -1
- package/dist/{chunk-h7tsf2qg.js → chunk-nqdc6n5d.js} +21 -21
- package/dist/chunk-p458sykz.js +3 -0
- package/dist/{chunk-1xgcs6aq.js → chunk-pkdrq4sh.js} +1 -1
- package/dist/{chunk-kp6qv2fb.js → chunk-qpahzkm0.js} +1 -1
- package/dist/{chunk-k472ve44.js → chunk-r2h572w9.js} +1 -1
- package/dist/{chunk-nxqap7nx.js → chunk-rkdyetby.js} +1 -1
- package/dist/{chunk-rdb7j1d6.js → chunk-s6bjmr93.js} +2 -2
- package/dist/{chunk-k75z3nef.js → chunk-vhna4qch.js} +2 -2
- package/dist/{chunk-986k5306.js → chunk-vk5r6pgx.js} +2 -2
- package/dist/{chunk-hbe5sg17.js → chunk-vwn5fx4f.js} +1 -1
- package/dist/chunk-w5m9qv5k.js +10 -0
- package/dist/{chunk-v4z6808c.js → chunk-wrvgt39b.js} +1 -1
- package/dist/{chunk-thzkm86y.js → chunk-x5bspdyq.js} +1 -1
- package/dist/chunk-xs0ke3f2.js +27 -0
- package/dist/{chunk-dw84pjmf.js → chunk-y3vhsctr.js} +1 -1
- package/dist/{chunk-y1xq2hm4.js → chunk-zerajrvv.js} +1 -1
- package/dist/{chunk-4mrq1jdn.js → chunk-zesjexqf.js} +1 -1
- package/dist/{chunk-wrjrwren.js → chunk-znsgvx9t.js} +1 -1
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.js +1 -1
- package/dist/src/bundle-linker.js +1 -1
- package/dist/src/bundler.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/call-signatures.js +1 -1
- package/dist/src/circular.js +1 -1
- package/dist/src/compat.js +1 -1
- package/dist/src/computed-keys.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/declaration-project.js +1 -1
- package/dist/src/declaration-publication.js +1 -1
- package/dist/src/declaration-references.js +1 -1
- package/dist/src/diff.js +1 -1
- package/dist/src/docs.js +1 -1
- package/dist/src/enum-declarations.js +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/extractor/extract.js +1 -1
- package/dist/src/extractor/scanner.js +1 -1
- package/dist/src/extractor.js +1 -1
- package/dist/src/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/initializer-type-spans.js +1 -1
- package/dist/src/lexical.js +1 -1
- package/dist/src/lsp.js +1 -1
- package/dist/src/module-graph.js +1 -1
- package/dist/src/module-references.js +1 -1
- package/dist/src/native-checker.js +1 -1
- package/dist/src/native-extractor.js +1 -1
- package/dist/src/native-generation.js +1 -1
- package/dist/src/native-project.js +1 -1
- package/dist/src/numeric-literals.js +1 -1
- package/dist/src/optimizer.js +1 -1
- package/dist/src/parallel-processor.js +1 -1
- package/dist/src/parameters.js +1 -1
- package/dist/src/parser.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsdown.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/declarations.js +1 -1
- package/dist/src/processor/import-usage.js +1 -1
- package/dist/src/processor/imports.js +1 -1
- package/dist/src/processor/index.js +1 -1
- package/dist/src/processor/type-inference.js +1 -1
- package/dist/src/processor.js +1 -1
- package/dist/src/return-type-scope.js +1 -1
- package/dist/src/security.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/worker-thread.js +1 -1
- package/dist/src/workspace.js +1 -1
- package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
- package/native/darwin-x64/libzig-dtsx.dylib +0 -0
- package/native/freebsd-x64/libzig-dtsx.so +0 -0
- package/native/linux-arm64/libzig-dtsx.so +0 -0
- package/native/linux-x64/libzig-dtsx.so +0 -0
- package/native/windows-x64/zig-dtsx.dll +0 -0
- package/package.json +1 -1
- package/dist/chunk-8ab8793q.js +0 -27
- package/dist/chunk-jtq24yb8.js +0 -3
- package/dist/chunk-kcbbz8t7.js +0 -37
- package/dist/chunk-t03y036d.js +0 -3
- package/dist/chunk-tsbthwf0.js +0 -7
- package/dist/chunk-vdhzc40m.js +0 -10
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
${tt()}`),p=j===-1?t:t.slice(0,j),
|
|
4
|
-
${H}`);else e.debug(`[no changes] ${c}`)}catch{e.info(`[new file] ${
|
|
5
|
-
...`:"")),e.debug("--- End preview ---")};if(g){let
|
|
6
|
-
`);if(t.failOnUnresolvedReExport)throw Error(m);e.warn(m),e.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(t.bundle&&(o.filesGenerated>0||
|
|
7
|
-
--- Generation Statistics ---`),e.info(`Files processed: ${o.filesProcessed}`),e.info(`Files generated: ${o.filesGenerated}`),
|
|
2
|
+
import{w,le,Mt,u}from"./chunk-02yqpwv0.js";import{G}from"./chunk-srfpcjtn.js";import{L,N}from"./chunk-8gksa73c.js";import{O,I}from"./chunk-kcfc6zg6.js";import{r}from"./chunk-wrvgt39b.js";import{Re}from"./chunk-p458sykz.js";import{e,M}from"./chunk-qmg1535a.js";import{Oe,D,Fn,Z}from"./chunk-29m9mhwt.js";import{Dn}from"./chunk-xs0ke3f2.js";import{et,kt}from"./chunk-mjaf2je8.js";import{P}from"./chunk-kdz4gxdq.js";import{Pe,oe,X,De}from"./chunk-475bjqea.js";import{tt,Y,re,Tt,At,Pt,Dt}from"./chunk-h5esm323.js";import{ne,$e}from"./chunk-cgrta603.js";import{Qe,Et}from"./chunk-fkngq7na.js";import{te}from"./chunk-s9e2a0t7.js";import{In,rt}from"./chunk-r2h572w9.js";import{q,Ee}from"./chunk-a0900w7b.js";import{Xe}from"./chunk-9kfzjkd1.js";import{Ae}from"./chunk-290jpwny.js";import{l}from"./chunk-w5m9qv5k.js";import{ie,Rt}from"./chunk-j0y149qx.js";import{mkdir as ye}from"fs/promises";import{availableParallelism as Se}from"os";import{basename as fe,dirname as pe,relative as V,resolve as ee}from"path";var Q=new WeakMap,ce=new WeakMap;function se(d){let a=Q.get(d);if(!a)a=Oe(d),Q.set(d,a),a.catch(()=>Q.delete(d));return a}async function de(d,a,t,f,h,g=Y){let o=fe(d)||"output.d.ts",C=V(pe(d),a),T=`${o}.map`,j=t.lastIndexOf(`
|
|
3
|
+
${tt()}`),p=j===-1?t:t.slice(0,j),y=Pt(p,o,C,f),b=`${d}.map`;return await g(b,JSON.stringify(y)),e.debug(` Generated source map: ${V(h,b)}`),T}async function s(d){let a=Date.now(),t={...P,...d};if(t.logLevel)M(t.logLevel);else if(t.verbose)M("debug");let f=new Ae;if(t.plugins&&t.plugins.length>0){for(let n of t.plugins)f.register(n),e.debug(`Registered plugin: ${n.name}`);t=await f.runOnStart(t)}if(t.moduleSpecifierMode!==void 0&&t.moduleSpecifierMode!=="preserve"&&t.moduleSpecifierMode!=="node")throw Error("moduleSpecifierMode must be preserve or node");if(q(t.engine,"engine"),await ne(t),t.isolatedDeclarations===void 0)t.isolatedDeclarations=await re(t);let h=t.typeMappings?ie(t.typeMappings):void 0,g=null,o={generationMode:t.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},C=0;e.debug("Starting DTS generation..."),e.debug(`Using ${o.generationMode} declaration generation path`),e.debug("Config:",t);let T=await Pe(t,()=>se(t)),j=T.entryFiles,p=[...T.files],{resolver:y,reachability:b}=T;if(ce.set(t,new Set(p)),t.incremental){let n=T.getResolutionFingerprint();if(!t.isolatedDeclarations){let i=new Set(p),m=new Map;for(let S of p){let F=await u(S);m.set(S,rt(F));for(let U of D(F,{includeImports:!0})){let R=y(U.specifier,S).resolved;if(R&&!R.split(/[/\\]/).includes("node_modules")&&!i.has(R))i.add(R),m.set(R,rt(await u(R)))}}let c=[...m].sort(([S],[F])=>S.localeCompare(F));n=JSON.stringify([n,c])}if(g=new et(t,n),t.clearCache){if(e.debug("Clearing build cache..."),!t.dryRun)g.clear()}else if(g.load()){let m=g.getStats();e.debug(`Loaded build cache with ${m.entries} entries`)}else e.debug("No existing build cache found, starting fresh");if(!t.dryRun)kt(t.cwd)}if(g&&!t.dryRun){let n=g.prune(new Set(p),t.cwd);if(n>0)e.debug(`Pruned ${n} deleted files from cache`)}if(e.debug(`Found ${p.length} TypeScript files`),t.progress&&p.length>0){let n=t.parallel?"parallel":"sequential";e.info(`Processing ${p.length} files (${n})...`)}let k=new Map,z=new Map,v=async(n,i,m="lf")=>{z.set(n,{content:i,lineEnding:m})},E=async(n,i)=>{let m;try{let c=X(n,t),S=async(x)=>{if(!t.diff)return;try{let B=await u(c),H=At(B,x,V(t.cwd,c));if(H)e.info(`
|
|
4
|
+
${H}`);else e.debug(`[no changes] ${c}`)}catch{e.info(`[new file] ${V(t.cwd,c)}`)}},F=(x)=>{if(!t.validate)return 0;let B=Tt(x,c);if(B.isValid)return e.debug(`[validation] ${c} - OK`),0;e.warn(`[validation] ${V(t.cwd,c)} has ${B.errors.length} error(s):`);for(let H of B.errors){let ae=` Line ${H.line}:${H.column}`;if(H.code)ae+=` [${H.code}]`;if(ae+=` - ${H.message}`,e.warn(ae),H.suggestion)e.warn(` Suggestion: ${H.suggestion}`)}return B.errors.length},U=(x)=>{e.info(`[dry-run] Would generate: ${c}`),e.debug("--- Content preview ---"),e.debug(x.slice(0,500)+(x.length>500?`
|
|
5
|
+
...`:"")),e.debug("--- End preview ---")};if(g){let x=g.getCachedIfValid(n,t.cwd);if(x){if(t.bundle)k.set(n,x);await S(x);let B=F(x);if(t.dryRun)U(x);else{if(t.declarationMap)m=i??await u(n),await de(c,n,x,m,t.cwd,v);await v(c,x,t.lineEnding)}return e.debug(`[cached] ${V(t.cwd,c)}`),{success:!0,file:n,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:B}}}m=i??await u(n);let{content:R,declarationCount:he,importCount:we,exportCount:Ce}=await ge(n,m,t,f,h,T.augmentationImports.get(n));if(t.bundle)k.set(n,R);let A=R;if(t.prettier||t.indentStyle||t.indentSize){let x=await te(A,{usePrettier:t.prettier,builtIn:{indentSize:t.indentSize||2,useTabs:t.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},c);A=x.content;for(let B of x.warnings??[])e.warn(`[format] ${B}`)}if(t.declarationMap){let x=`${fe(c)||"output.d.ts"}.map`;A=Dt(A,x)}await S(A);let be=F(A);if(t.dryRun)U(A);else{if(t.declarationMap&&m)await de(c,n,A,m,t.cwd,v);if(await v(c,A,t.lineEnding),g&&m)g.update(n,m,A,t.cwd);e.debug(`Generated: ${c}`)}return{success:!0,file:n,declarationCount:he,importCount:we,exportCount:Ce,validationErrorCount:be}}catch(c){let S=Qe(c,n,m);if(t.plugins&&t.plugins.length>0)await f.runOnError(c instanceof Error?c:Error(String(c)),n,m||"");return{success:!1,file:n,declarationCount:0,importCount:0,exportCount:0,dtsError:S,validationErrorCount:0}}},W=t.parallel||t.parallel!==!1&&p.length>=10,J=G(t.concurrency,Se?.()??8),_=new Map;if(W&&p.length>1){let n=p.map(async(i)=>{try{let m=await u(i);return{file:i,source:m}}catch{return{file:i,source:null}}});for(let i of await Promise.all(n))if(i.source!==null)_.set(i.file,i.source)}let K=(n)=>{if(o.filesProcessed++,n.success){if(n.cached)C++;else o.filesGenerated++,o.declarationsFound+=n.declarationCount,o.importsProcessed+=n.importCount,o.exportsProcessed+=n.exportCount;if(t.validate){if(o.filesValidated++,n.validationErrorCount)o.validationErrors+=n.validationErrorCount}}else if(o.filesFailed++,n.dtsError){o.errors.push(n.dtsError);let i=Et(n.dtsError);if(t.continueOnError)e.warn(i);else throw e.error(i),Error(n.dtsError.message)}};if(W)for(let n=0;n<p.length;n+=J){let i=p.slice(n,n+J),m=await Promise.all(i.map((c)=>E(c,_.get(c))));for(let c of m)K(c);if(t.progress){let c=Math.round(o.filesProcessed/p.length*100);e.info(`[${o.filesProcessed}/${p.length}] ${c}%`)}}else for(let n of p){let i=await E(n);if(K(i),t.progress){let m=Math.round(o.filesProcessed/p.length*100),c=i.cached?"[cached]":"";e.info(`[${o.filesProcessed}/${p.length}] ${m}% - ${V(t.cwd,n)} ${c}`)}}if(!t.bundle){let n=[];if(b)for(let i of b.unresolved)n.push({from:i.from,specifier:i.specifier,reason:"missing"});if(t.autoIncludeReExports===!1&&p.length>0){let i=new Set(p);for(let m of p){let c;try{c=await u(m)}catch{continue}for(let S of D(c)){let F=y(S.specifier,m);if(!F.isRelative)continue;if(!F.resolved)n.push({from:m,specifier:S.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(F.resolved)&&!i.has(F.resolved))n.push({from:m,specifier:S.specifier,reason:"not-emitted"})}}}if(n.length>0){let i=[];i.push(`Found ${n.length} re-export(s) pointing at siblings that won't be in the output:`);for(let c of n){let S=V(t.cwd,c.from);if(c.reason==="missing")i.push(` ${S} \u2192 '${c.specifier}' (path not found on disk)`);else i.push(` ${S} \u2192 '${c.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let m=i.join(`
|
|
6
|
+
`);if(t.failOnUnresolvedReExport)throw Error(m);e.warn(m),e.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(t.bundle&&(o.filesGenerated>0||C>0)&&j.length>0)try{e.debug("Bundling declarations...");let n=j.length===1&&!!t.bundleOutput;for(let i of j){let m=await Z([i],{includeImports:!0,resolveSpecifier:y}),c=new Set;for(let R of m.reachable){if(R.endsWith(".d.ts"))continue;if(R.includes("node_modules"))continue;c.add(R)}let S=p.filter((R)=>c.has(R));if(!S.includes(i))S.push(i);let F=Dn(i,S,k,{cwd:t.cwd,keepComments:t.keepComments});for(let R of new Set(F.warnings))e.warn(`[bundle] ${R}`);let U=n?ee(t.cwd,t.outdir,t.bundleOutput):X(i,t);if(t.dryRun)e.info(`[dry-run] Would bundle ${F.files.length} files to: ${V(t.cwd,U)}`);else await v(U,F.content,t.lineEnding),e.debug(`Prepared ${F.files.length} bundled files for: ${V(t.cwd,U)}`);if(n)break}}catch(n){let i=n instanceof Error?n.message:String(n);throw e.error(`Bundle failed: ${i}`),n}if(!t.dryRun)await $e(t,z);if(g&&!t.dryRun)g.save(),e.debug("Saved build cache");if(o.durationMs=Date.now()-a,t.stats)if(t.outputFormat==="json")console.log(JSON.stringify(o,null,2));else{if(e.info(`
|
|
7
|
+
--- Generation Statistics ---`),e.info(`Files processed: ${o.filesProcessed}`),e.info(`Files generated: ${o.filesGenerated}`),C>0)e.info(`Files cached: ${C}`);if(o.filesFailed>0)e.info(`Files failed: ${o.filesFailed}`);if(e.info(`Declarations found: ${o.declarationsFound}`),e.info(`Imports processed: ${o.importsProcessed}`),e.info(`Exports processed: ${o.exportsProcessed}`),o.filesValidated>0){if(e.info(`Files validated: ${o.filesValidated}`),o.validationErrors>0)e.info(`Validation errors: ${o.validationErrors}`)}if(e.info(`Duration: ${o.durationMs}ms`),o.errors.length>0){e.info(`
|
|
8
8
|
Errors:`);for(let n of o.errors){let i=` - ${n.file}`;if(n.location)i+=`:${n.location.line}:${n.location.column}`;if(n.code)i+=` [${n.code}]`;if(i+=`: ${n.message}`,e.info(i),n.suggestion)e.info(` Suggestion: ${n.suggestion}`)}}e.info(`-----------------------------
|
|
9
|
-
`)}if(t.plugins&&t.plugins.length>0)await f.runOnEnd(o);return e.debug("DTS generation complete!"),o}async function ve(d,a,t){let f=await se(t),h=De(a,t,f,ce.get(t));return Fn(d,(g)=>h(g).emittedSpecifier)}async function fo(d,a){Q.delete(a),ce.delete(a);let t=await se(a),f=await Z([d],{includeImports:!0,resolveSpecifier:t}),h=await Re([...f.sources.keys()],t,a.isolatedDeclarations??!1,f.sources);return(await me(d,a,void 0,h.get(ee(d)))).content}async function me(d,a,t,f){let h=await u(d),g=a.typeMappings?ie(a.typeMappings):void 0;return ge(d,h,a,t,g,f)}async function ge(d,a,t,f,h,g){let o=a;if(f)o=await f.runOnBeforeFile(d,a);let
|
|
10
|
-
`)){if(!h||h.startsWith(" ")||h.startsWith("\t")||h.startsWith("}")||h.startsWith("*")||h.startsWith("/"))continue;if(a++,h.startsWith("import "))t++;else if(h.startsWith("export "))f++}return{declarationCount:a,importCount:t,exportCount:f}}function Me(d,a,t,f,h){let g=t.importOrder??["bun"];if(g.length!==1||g[0]!=="bun")return null;let o=L(a)?N(d):O(a)?I(d):d;return Ee(o,{keepComments:t.keepComments??!0,isolatedDeclarations:t.isolatedDeclarations??!1,engine:t.engine,sourceFile:a,inferenceSources:f,augmentationImports:h})}async function ue(d,a,t,f,h,g,o){let
|
|
9
|
+
`)}if(t.plugins&&t.plugins.length>0)await f.runOnEnd(o);return e.debug("DTS generation complete!"),o}async function ve(d,a,t){let f=await se(t),h=De(a,t,f,ce.get(t));return Fn(d,(g)=>h(g).emittedSpecifier)}async function fo(d,a){Q.delete(a),ce.delete(a);let t=await se(a),f=await Z([d],{includeImports:!0,resolveSpecifier:t}),h=await Re([...f.sources.keys()],t,a.isolatedDeclarations??!1,f.sources);return(await me(d,a,void 0,h.get(ee(d)))).content}async function me(d,a,t,f){let h=await u(d),g=a.typeMappings?ie(a.typeMappings):void 0;return ge(d,h,a,t,g,f)}async function ge(d,a,t,f,h,g){let o=a;if(f)o=await f.runOnBeforeFile(d,a);let C=new Map;if(!t.isolatedDeclarations){let v=await se(t);for(let E of D(o,{includeImports:!0})){let W=v(E.specifier,d).resolved;if(W&&!W.split(/[/\\]/).includes("node_modules"))C.set(E.specifier,await u(W))}}let T=f?.hasDeclarationHooks()?null:Me(o,d,t,C,g);if(T!==null)return ue(T,d,o,t,f,h,xe(T));let j=C.size?In(o,C):void 0,p=r(o,d,t.keepComments,t.isolatedDeclarations??!1,j);if(f)p=await f.runOnDeclarations(d,o,p);let y=0,b=0;for(let v=0;v<p.length;v++){let E=p[v];if(E.kind==="import")y++;if(E.kind==="export"||E.isExported)b++}let z=l(p,{filePath:d,sourceCode:o,declarations:p,augmentationImports:g},t.keepComments,t.importOrder);return ue(z,d,o,t,f,h,{declarationCount:p.length,importCount:y,exportCount:b})}function xe(d){let a=0,t=0,f=0;for(let h of d.split(`
|
|
10
|
+
`)){if(!h||h.startsWith(" ")||h.startsWith("\t")||h.startsWith("}")||h.startsWith("*")||h.startsWith("/"))continue;if(a++,h.startsWith("import "))t++;else if(h.startsWith("export "))f++}return{declarationCount:a,importCount:t,exportCount:f}}function Me(d,a,t,f,h){let g=t.importOrder??["bun"];if(g.length!==1||g[0]!=="bun")return null;let o=L(a)?N(d):O(a)?I(d):d;return Ee(o,{keepComments:t.keepComments??!0,isolatedDeclarations:t.isolatedDeclarations??!1,engine:t.engine,sourceFile:a,inferenceSources:f,augmentationImports:h})}async function ue(d,a,t,f,h,g,o){let C=await ve(d,a,f);if(g)C=Rt(C,g,{filePath:a});if(f.normalizeOutput===!0||f.declarationOrder)C=Xe(C,{lineEnding:"lf",declarationOrder:f.declarationOrder,indent:{style:f.indentStyle??"spaces",size:f.indentSize??2}});if(h)C=await h.runOnAfterFile(a,t,C);return{content:C,...o}}async function po(d){let a={...P,...d};if(a.logLevel)M(a.logLevel);let t=ee(a.cwd,a.root),f=150,h=5,g=1e4,o={pendingChanges:new Set,debounceTimer:null,isProcessing:!1,errorCount:0,lastErrorTime:0};e.info(`Watching for changes in ${t}...`),e.info(`Press Ctrl+C to stop
|
|
11
11
|
`);try{await s(a),e.info(`[watch] Initial generation complete
|
|
12
|
-
`)}catch(
|
|
13
|
-
`)}async function
|
|
14
|
-
[${
|
|
15
|
-
[${
|
|
12
|
+
`)}catch(y){let b=y instanceof Error?y.message:String(y);e.error(`[watch] Initial generation failed: ${b}`),e.info(`[watch] Continuing to watch for changes...
|
|
13
|
+
`)}async function C(){if(o.isProcessing||o.pendingChanges.size===0)return;let y=Date.now();if(o.errorCount>=h){if(y-o.lastErrorTime<g){e.warn(`[watch] Too many errors, pausing for ${Math.ceil((g-(y-o.lastErrorTime))/1000)}s...`);return}o.errorCount=0}o.isProcessing=!0;let b=Array.from(o.pendingChanges);o.pendingChanges.clear();let k=new Date().toLocaleTimeString();if(b.length===1)e.info(`
|
|
14
|
+
[${k}] File changed: ${b[0]}`);else e.info(`
|
|
15
|
+
[${k}] ${b.length} files changed`);let z=0,v=0;for(let E of b){let W=ee(t,E);try{let J=a.exclude||[];if(oe(W,J,t)){e.debug(` Skipping excluded file: ${E}`);continue}if(!await le(W).exists()){e.debug(` Skipping deleted file: ${E}`);continue}let K=X(W,a),{content:n}=await me(W,a);await ye(pe(K),{recursive:!0}),await Y(K,n,a.lineEnding),e.info(` \u2713 ${V(a.cwd,K)}`),z++}catch(J){v++,o.errorCount++,o.lastErrorTime=Date.now();let _=Qe(J,W);if(e.error(` \u2717 ${E}: ${_.message}`),_.suggestion)e.error(` Suggestion: ${_.suggestion}`)}}if(b.length>1)e.info(` Done: ${z} generated, ${v} failed`);if(v===0)o.errorCount=0;if(o.isProcessing=!1,o.pendingChanges.size>0)o.debounceTimer=setTimeout(C,f)}function T(y){if(o.pendingChanges.add(y),o.debounceTimer)clearTimeout(o.debounceTimer);o.debounceTimer=setTimeout(C,f)}let p=Mt([w?"bun":"node","-e",`
|
|
16
16
|
const fs = require('fs');
|
|
17
17
|
|
|
18
18
|
const rootPath = '${t}';
|
|
@@ -25,7 +25,7 @@ Errors:`);for(let n of o.errors){let i=` - ${n.file}`;if(n.location)i+=`:${n.lo
|
|
|
25
25
|
|
|
26
26
|
// Keep process alive
|
|
27
27
|
setInterval(() => {}, 1000);
|
|
28
|
-
`],{stdout:"pipe",stderr:"inherit"});if(
|
|
29
|
-
`);
|
|
30
|
-
`);
|
|
28
|
+
`],{stdout:"pipe",stderr:"inherit"});if(w){let y=p.stdout.getReader(),b=new TextDecoder,k="";while(!0){let{done:z,value:v}=await y.read();if(z)break;k+=b.decode(v,{stream:!0});let E=k.split(`
|
|
29
|
+
`);k=E.pop()||"";for(let W of E)if(W.startsWith("CHANGED:")){let J=W.slice(8);T(J)}}}else{let y=p.stdout,b="";y.on("data",(k)=>{b+=k.toString();let z=b.split(`
|
|
30
|
+
`);b=z.pop()||"";for(let v of z)if(v.startsWith("CHANGED:")){let E=v.slice(8);T(E)}}),await p.exited}}
|
|
31
31
|
export{s,fo,po};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var Se={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class
|
|
3
|
-
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class Tn extends
|
|
2
|
+
var Se={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class T extends Error{code;context;constructor(n,e="UNKNOWN_ERROR",t){super(n);if(this.name="DtsxError",this.code=e,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let n=`${this.name} [${this.code}]: ${this.message}`;if(this.context)n+=`
|
|
3
|
+
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class Tn extends T{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class ui extends T{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class fi extends T{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class An extends T{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Pn extends T{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class di extends T{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function xo(n){return n instanceof T}function Co(n){return n instanceof Tn}function vo(n){return n instanceof An}function So(n){return n instanceof Pn}function $o(n,e="UNKNOWN_ERROR",t){if(n instanceof T)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new T(s,e);if(n instanceof Error)r.cause=n;return r}function Eo(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
|
|
4
4
|
`)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function ko(n,e,t,s){let r=n.split(`
|
|
5
5
|
`),i=e.line-1,o=[];if(s)o.push(`${s}:${e.line}:${e.column}`);else o.push(`Line ${e.line}, Column ${e.column}`);o.push(`Error: ${t}`),o.push("");let E=Math.max(0,i-1),c=Math.min(r.length-1,i+1);for(let a=E;a<=c;a++){let R=(a+1).toString().padStart(4," "),u=a===i?">":" ";if(o.push(`${u} ${R} | ${r[a]}`),a===i){let l=" ".repeat(8+e.column-1);o.push(`${l}^`)}}return o.join(`
|
|
6
6
|
`)}function Qe(n,e,t){let s={file:e,message:"Unknown error",code:Se.UNKNOWN_ERROR};if(n instanceof Error){s.message=n.message,s.stack=n.stack;let r=n.message.match(/\((\d+),(\d+)\)/);if(r)s.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(n.message.includes("Cannot find")||n.message.includes("not found"))s.code=Se.FILE_NOT_FOUND,s.suggestion="Check that the file path is correct and the file exists.";else if(n.message.includes("syntax")||n.message.includes("Unexpected token"))s.code=Se.SYNTAX_ERROR,s.suggestion="Check for syntax errors in your TypeScript code.";else if(n.message.includes("type")&&n.message.includes("cannot"))s.code=Se.TYPE_INFERENCE_ERROR,s.suggestion="Add explicit type annotations to help with type inference.";else if(n.message.includes("parse")||n.message.includes("Parse"))s.code=Se.PARSE_ERROR,s.suggestion="The file contains invalid TypeScript syntax."}else if(typeof n==="string")s.message=n;return s}function Et(n,e){let t=[],s=n.file;if(n.location)s+=`:${n.location.line}:${n.location.column}`;if(n.code)s+=` [${n.code}]`;if(t.push(s),t.push(` Error: ${n.message}`),e&&n.location){t.push("");let r=e.split(`
|
|
7
7
|
`),i=n.location.line-1;if(i>=0&&i<r.length){let o=Math.max(0,i-1),E=Math.min(r.length-1,i+1);for(let c=o;c<=E;c++){let a=(c+1).toString().padStart(4," "),R=c===i?">":" ";if(t.push(` ${R} ${a} | ${r[c]}`),c===i&&n.location.column>0){let u=" ".repeat(10+n.location.column-1);t.push(` ${u}^`)}}}}if(n.suggestion)t.push(""),t.push(` Suggestion: ${n.suggestion}`);return t.join(`
|
|
8
8
|
`)}function To(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
|
|
9
9
|
`)}
|
|
10
|
-
export{Se,
|
|
10
|
+
export{Se,T,Tn,ui,fi,An,Pn,di,xo,Co,vo,So,$o,Eo,ko,Qe,Et,To};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,d,
|
|
2
|
+
import{t,d,E}from"./chunk-d0dbet9n.js";import{S}from"./chunk-c87yyjv7.js";function D(n){return typeof n==="string"?E(n,"'"):String(n)}function va(n,y,m=new Map){let o=t(n),e=new Map(m),i=new Map,f=[],c=1,p=0,q=0;for(let r=1;r<o.length;r++){let w=o[r],K=n.slice(w.start,w.end);if(w.kind==="punctuation"&&p===0&&(K===","||K==="}")){let l=o.slice(c,r),a=l[0];if(a){let u=a.kind==="quoted"?d(n.slice(a.start,a.end)):n.slice(a.start,a.end),v=l.findIndex((g)=>g.kind==="punctuation"&&n[g.start]==="="),s=q;if(v>=0){let g=l.slice(v+1),B="",C=l[v].end;for(let x=0;x+2<g.length;x++){let[h,A,M]=g.slice(x,x+3);if(h.kind!=="word"||M.kind!=="word"||n.slice(A.start,A.end)!==".")continue;let b=e.get(`${n.slice(h.start,h.end)}.${n.slice(M.start,M.end)}`);if(b===void 0||typeof b==="object")continue;B+=n.slice(C,h.start)+D(b),C=M.end,x+=2}B+=n.slice(C,l.at(-1).end),s=S(B,e),f.push({start:l[v].start,end:l.at(-1).end,text:s===void 0?"":`= ${D(s)}`})}else if(s!==void 0)f.push({start:a.end,end:a.end,text:` = ${D(s)}`});if(q=typeof s==="number"?s+1:void 0,u!==void 0){if(e.delete(u),e.delete(`${y}.${u}`),s!==void 0)i.set(u,s),e.set(u,s),e.set(`${y}.${u}`,s)}}c=r+1}else if(w.kind==="punctuation"){if("([{".includes(K))p++;else if(")]}".includes(K))p--}}let k=n;for(let r of f.reverse())k=k.slice(0,r.start)+r.text+k.slice(r.end);return{body:k,members:i}}function Hn(n,y){let m=[...new Set([...n,...y.values()])];if(!m.some((e)=>e.kind==="enum"))return;m.sort((e,i)=>(e.start??0)-(i.start??0));let o=new Map;for(let e of m)if(e.kind==="enum"){let i=e.text.indexOf("{");if(i<0)continue;if(t(e.text.slice(0,i)).some((c)=>e.text.slice(c.start,c.end)==="declare"))continue;let f=va(e.text.slice(i),e.name,o);e.text=e.text.slice(0,i)+f.body;for(let[c,p]of f.members)o.set(`${e.name}.${c}`,p)}else if(e.kind==="variable"&&e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion")&&typeof e.value==="string"){let i=S(e.value,o);if(i!==void 0)o.set(e.name,i)}}
|
|
3
3
|
export{va,Hn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var e="@dtsx/dtsx",i="module",n="0.11.
|
|
2
|
+
var e="@dtsx/dtsx",i="module",n="0.11.48",r=!0,c="A modern, fast .d.ts generation tool, powered by Bun.",u="Chris Breuer <chris@stacksjs.org>",a="MIT",b="https://github.com/stacksjs/dtsx#readme",o={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},p={url:"https://github.com/stacksjs/dtsx/issues"},d=["dts","generation","isolated declarations","development","bun","stacks","typescript","javascript"],m={".":{import:"./dist/index.js"},"./*":{import:"./dist/*"}},k="./dist/index.js",l="./dist/index.d.ts",x={dtsx:"./dist/cli.js"},g=["dist"],h={benchmark:"bun benchmark/index.ts","benchmark:prepare":"cd packages/zig-dtsx && zig build -Doptimize=ReleaseFast && cd ../.. && bun build benchmark/oxc-emit.ts --compile --splitting --bytecode --minify --format=esm --outfile benchmark/oxc-emit","benchmark:publish":"bun benchmark/index.ts --json benchmark/results.json --runs 3 && bun benchmark/render.ts","benchmark:tsdown":"bun benchmark/tsdown.ts",build:"bun --filter './packages/dtsx' build",test:"find packages -name '*.test.ts' -print | xargs bun test","test:public-sdk":"bun scripts/verify-public-sdk.ts","test:standalone":"bun scripts/verify-standalone.ts","typecheck:public-sdk":"bun x tsc --project tsconfig.public-sdk.json",lint:"bun x --bun pickier .","lint:fix":"bun x --bun pickier . --fix",format:"bun x --bun pickier . --format","format:fix":"bun x --bun pickier . --format --write",changelog:"bun x @stacksjs/logsmith --verbose","changelog:generate":"bun x @stacksjs/logsmith --output CHANGELOG.md",release:"bun x --bun @stacksjs/bumpx prompt --recursive","release:patch":"bun x --bun @stacksjs/bumpx patch --recursive --commit --tag --push --yes","release:minor":"bun x --bun @stacksjs/bumpx minor --recursive --commit --tag --push --yes",typecheck:"bun x tsc --noEmit","dev:docs":"bun --bun bunpress dev docs","build:docs":"bun --bun bunpress build docs","preview:docs":"bun --bun bunpress preview docs"},j={"@stacksjs/bumpx":"^0.2.32","@stacksjs/bunpress":"^0.2.31","@stacksjs/clapp":"^0.2.16",pickier:"^0.1.88","@stacksjs/gitlint":"^0.1.8","@stacksjs/logsmith":"^0.2.14","@types/bun":"^1.4.4","buddy-bot":"^0.10.5","bun-git-hooks":"^0.3.3","@dtsx/bun":"workspace:*",mitata:"^1.0.34","oxc-transform":"^0.157.0","oxc-parser":"^0.157.0",tsdown:"^0.23.7",typescript:"^7.0.2"},y=["packages/*"],f={typescript:"^7.0.2"},v={name:e,type:i,version:n,private:r,description:c,author:u,license:a,homepage:b,repository:o,bugs:p,keywords:d,exports:m,module:k,types:l,bin:x,files:g,scripts:h,devDependencies:j,workspaces:y,overrides:f,"git-hooks":{"pre-commit":{"staged-lint":{"*.{js,ts,json,yaml,yml,md}":"bun x --bun pickier lint --fix"}},"commit-msg":"bun x gitlint --edit .git/COMMIT_EDITMSG"}};export{u as author,x as bin,p as bugs,v as default,c as description,j as devDependencies,m as exports,g as files,b as homepage,d as keywords,a as license,k as module,e as name,f as overrides,r as private,o as repository,h as scripts,i as type,l as types,n as version,y as workspaces};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t}from"./chunk-
|
|
2
|
+
import{t}from"./chunk-d0dbet9n.js";function j(n){let s=t(n),r=(e)=>s[e]?n.slice(s[e].start,s[e].end):"",d=new Map,k=[];for(let e=0;e<s.length;e++)if(["(","[","{"].includes(r(e)))k.push(e);else if([")","]","}"].includes(r(e))){let i=k.pop();if(i===void 0||!["()","[]","{}"].includes(r(i)+r(e)))throw Error("Unbalanced binding pattern");d.set(i,e)}if(k.length)throw Error("Unbalanced binding pattern");for(let e=0;e<s.length;e++){if(r(e)!=="<")continue;let i=["=",",","(",":","?","[","{"].includes(r(e-1)),f=1;for(let a=e+1;a<s.length;a++){if(r(a)==="="&&r(a+1)!==">"&&f===1&&!i)break;if(r(a)==="<")f++;else if(r(a)===">"&&r(a-1)!=="="&&--f===0){if(a+1===s.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(r(a+1)))d.set(e,a);break}let u=d.get(a);if(u!==void 0)a=u}}let g=(e,i)=>({text:e<i?n.slice(s[e].start,s[i-1].end):"",offset:s[e]?.start??n.length}),w=(e,i,f)=>{for(let a=e;a<i;a++){if(r(a)===f)return a;let u=d.get(a);if(u!==void 0)a=u}return},b=(e,i)=>{let f=w(e,i,"="),a=f===void 0?void 0:g(f+1,i);if(f!==void 0)i=f;if(e+1===i&&s[e]?.kind==="word")return{kind:"name",name:r(e),defaultValue:a};let u=r(e)==="{"?"object":r(e)==="["?"array":void 0;if(!u||d.get(e)!==i-1)throw Error(`Invalid binding target: ${g(e,i).text}`);let m=[],o=e+1;while(o<i-1){let h=w(o,i-1,","),p=h??i-1;if(o===p)m.push(void 0);else if(r(o)==="."&&r(o+1)==="."&&r(o+2)===".")m.push({rest:!0,target:b(o+3,p)});else if(u==="array")m.push({rest:!1,target:b(o,p)});else if(r(o)==="["){let c=d.get(o);if(c===void 0||r(c+1)!==":")throw Error("Computed binding needs a target");m.push({computed:g(o+1,c),rest:!1,target:b(c+2,p)})}else{let c=o+1;if(s[o].kind!=="word"&&s[o].kind!=="quoted")while(c<p&&r(c)!==":")c++;let l=r(c)===":";if(!l&&s[o].kind!=="word")throw Error("Invalid object binding key");m.push({key:g(o,l?c:o+1).text,rest:!1,target:b(l?c+1:o,p)})}if(h===void 0)break;o=h+1}return{kind:u,elements:m,defaultValue:a}};return b(0,s.length)}function y(n,s){if(n.kind==="name")s.push(n.name);else for(let r of n.elements)if(r)y(r.target,s)}function Ge(n){let s=[];return y(j(n),s),s}function cr(n){let s=j(n.pattern),r=[];if(y(s,r),!r.length)return[];let d=[n.root],k=!1,g={start:n.root.start,end:n.root.end},w=(e,i)=>{let f=n.allocateName();return d.push({kind:"variable",name:f,text:`declare ${i} ${f}: unknown;`,value:e.text,initializerStart:n.patternOffset+e.offset,modifiers:[i],isExported:!1,...g}),f},b=(e,i)=>{if(e.defaultValue){let l=w(e.defaultValue,n.kind),x=n.allocateName();i=`(${i}) extends infer ${x} ? ${x} extends undefined ? typeof ${l} : ${x} : never`}if(e.kind==="name"){let l=k?void 0:n.comments;k=!0,d.push({kind:"variable",name:e.name,text:`${n.exported?"export ":""}declare ${n.kind} ${e.name}: ${i};`,typeAnnotation:i,modifiers:[n.kind],isExported:n.exported,leadingComments:l,...g});return}let f=e.elements,a=[],u=[],m=[];for(let l of f){if(!l){a.push("");continue}let x=n.allocateName(),E=l.key;if(l.computed)E=`[${w(l.computed,"const")}]`;a.push(l.rest?`...${x}`:e.kind==="object"?`${E}: ${x}`:x),u.push({target:l.target,index:m.length}),m.push(`typeof ${x}`)}let o=n.allocateName(),h=n.allocateName(),p=n.allocateName(),c=e.kind==="object"?`{ ${a.join(", ")} }`:`[${a.join(", ")}]`;d.push({kind:"function",name:o,text:`declare function ${o}(${c}: ${i}): [${m.join(", ")}];`,isExported:!1,...g}),d.push({kind:"type",name:h,text:`type ${h} = (typeof ${o}) extends (...args: never[]) => infer ${p} ? ${p} : never;`,isExported:!1,...g});for(let l of u)b(l.target,`${h}[${l.index}]`)};return b(s,`typeof ${n.root.name}`),d}
|
|
3
3
|
export{Ge,cr};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{st}from"./chunk-
|
|
2
|
+
import{st}from"./chunk-02yqpwv0.js";import{P}from"./chunk-kdz4gxdq.js";import{Mn}from"./chunk-rwdcmcx3.js";import{ke}from"./chunk-hgg4aqvf.js";import{ce}from"./chunk-x6ddycvm.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function tt(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function Mo(n,r){throw Error(r||`Unexpected value: ${n}`)}async function Y(n,r,o="lf"){let t=r.replace(/\r\n/g,`
|
|
3
3
|
`);if(!t.endsWith(`
|
|
4
4
|
`))t+=`
|
|
5
5
|
`;if(o==="crlf")t=t.replace(/\n/g,`\r
|
|
6
|
-
`);if(await st(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function yi(n){let r=n??
|
|
6
|
+
`);if(await st(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function yi(n){let r=n??P.root,o=await v(r,{withFileTypes:!0});return(await Promise.all(o.map((i)=>{let c=C(r,i.name);return i.isDirectory()?yi(c):c}))).flat(1/0).filter((i)=>{if(typeof i!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(i)&&!/\.d\.(?:ts|mts|cts)$/.test(i)})}async function re(n){try{let r=n?.cwd||y.cwd();return(await ce(D(r,n?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function Tt(n,r){let o={isValid:!0,errors:[]};for(let t of ke(n))o.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of Mn(n))o.errors.push({line:t.line,column:1,message:`'${t.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${t.context}`,code:"dangling-type-reference"});return o.isValid=o.errors.length===0,o}function At(n,r,o){if(n===r)return"";let t=n.split(`
|
|
7
7
|
`),i=r.split(`
|
|
8
8
|
`),c=new Map,a=new Map;for(let e=0;e<t.length;e++)c.set(t[e],(c.get(t[e])??0)+1);for(let e=0;e<i.length;e++)a.set(i[e],(a.get(i[e])??0)+1);let g=[],u=[];for(let[e,s]of c){let m=s-(a.get(e)??0);for(let l=0;l<m;l++)g.push(e)}for(let[e,s]of a){let m=s-(c.get(e)??0);for(let l=0;l<m;l++)u.push(e)}if(g.length===0&&u.length===0)return"";let p=[`--- ${o}`,`+++ ${o}`];for(let e=0;e<g.length;e++)p.push(`- ${g[e]}`);for(let e=0;e<u.length;e++)p.push(`+ ${u[e]}`);return p.join(`
|
|
9
9
|
`)}function Pt(n,r,o,t){let i=n.split(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
2
|
+
import{s}from"./chunk-ex02f2vm.js";function ve(d={}){let{onBuildStart:u=!1,onBuildEnd:f=!0,onGenerated:l,onError:i,...c}=d,o,r,e=async()=>{let t={...c};if(!t.outdir&&o)t.outdir=o;if(!t.entrypoints&&r)t.entrypoints=r;try{let n=await s(t);l?.(n)}catch(n){let a=n instanceof Error?n:Error(String(n));if(i?.(a),!i)console.error("[dtsx] Generation failed:",a.message)}};return{name:"dtsx",esbuildOptions(t){if(t.outdir&&typeof t.outdir==="string")o=t.outdir;if(t.entryPoints){if(Array.isArray(t.entryPoints))r=t.entryPoints;else if(typeof t.entryPoints==="object")r=Object.values(t.entryPoints)}},async buildStart(){if(u)await e()},async buildEnd(t){if(f)await e()}}}var La=ve,dr=ve,Na=ve;
|
|
3
3
|
export{ve,La,dr,Na};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,m}from"./chunk-
|
|
2
|
+
import{t,m}from"./chunk-d0dbet9n.js";import{Ge}from"./chunk-h2007n8k.js";function ft(o){let f=t(o);if(f.length!==1||f[0].kind!=="word")return;let l=o.slice(f[0].start,f[0].end);return["true","false","null","undefined","this","super"].includes(l)?void 0:l}function Gt(o){let f=t(o);if(f.length===0)return!0;let l=f[f.length-1],s=o.slice(l.start,l.end);if(l.kind==="word"&&(s==="is"||s==="extends"))return!0;if(s==="|"||s==="&")return!0;let n=f[f.length-2];return s===">"&&n!==void 0&&o.slice(n.start,n.end)==="="}function V(o){return v(o,m(o))}function er(o){for(let f=1024;f<o.length;f*=8){let l=o.slice(0,f),s=S(l,t(l),f);if(s!==void 0)return s}return v(o,t(o))}function v(o,f){return S(o,f,1/0)??!1}function S(o,f,l){let s=0;for(let n=0;n<f.length;n++){let a=f[n];if(a.end>=l)return;if(a.kind==="punctuation"){let d=o.charCodeAt(a.start);if(d===123||d===40||d===91)s++;else if(d===125||d===41||d===93)s--;continue}if(s!==0||a.kind!=="word"||a.end-a.start!==6)continue;let c=o.slice(a.start,a.end);if(c==="export")return!0;if(c==="import"){let d=f[n+1];if(d===void 0?l!==1/0:d.end>=l)return;let y=d?o.slice(d.start,d.end):"";if(y!=="("&&y!==".")return!0}}return l===1/0?!1:void 0}function tr(o){if(o.isExported)return!1;if(["function","variable","interface","type","class","enum","namespace"].includes(o.kind))return!0;return o.kind==="module"&&(o.moduleForm==="namespace"||o.moduleForm==="identifier")}function nr(o,f){let l=o.text,s=t(l),n=(i)=>s[i]?l.slice(s[i].start,s[i].end):"",a=(i)=>s[i]?.kind==="word",c=new Map,d=[];for(let i=0;i<s.length;i++){let e=n(i);if(e==="("||e==="["||e==="{"||e==="<")d.push(i);else if(e===")"||e==="]"||e==="}"||e===">"&&n(i-1)!=="="){let r=d.at(-1);if(r!==void 0&&(n(r)==="("&&e===")"||n(r)==="["&&e==="]"||n(r)==="{"&&e==="}"||n(r)==="<"&&e===">"))d.pop(),c.set(r,i)}}let y=[];for(let i=0;i<s.length;i++){if(n(i)!=="(")continue;let e=c.get(i);if(e===void 0||!(n(e+1)===":"||n(e+1)==="="&&n(e+2)===">"))continue;let r=new Set,u=i+1;while(u<e){let p=u;while(p<e&&n(p)!==","){let x=c.get(p);if(x!==void 0)p=x+1;else p++}let h=u;while(h<p&&n(h)!==":"&&n(h)!=="="){let x=c.get(h);if(x!==void 0)h=x+1;else h++}let b=u;while([".","public","private","protected","readonly","override"].includes(n(b)))b++;if(n(b)==="{"||n(b)==="[")for(let x of Ge(l.slice(s[b].start,s[h-1].end)))r.add(x);else if(a(b))r.add(n(b));u=p+1}let g=e+(n(e+1)===":"?2:3);while(g<s.length){if([";",",",")","]","}"].includes(n(g))||n(g)===">"&&n(g-1)!=="=")break;let p=c.get(g);if(p!==void 0)g=p+1;else g++}y.push({start:i,end:g,names:r})}let k=(i)=>{if(!a(i))return;let e=n(i);if(!y.some((r)=>i>=r.start&&i<r.end&&r.names.has(e)))f.add(e)},w=(i,e)=>{for(let r=i;r<e;r++){if(n(r)==="<"&&c.has(r)){r=c.get(r);continue}if(!a(r)||n(r-1)==="."||n(r+1)===":")continue;if(["true","false","null","undefined","new","this","super","as","satisfies","typeof","void","keyof"].includes(n(r)))continue;k(r)}};for(let i=0;i<s.length;i++){if(n(i)==="typeof")k(i+1);if(n(i)==="export"){let e=i+1;if(n(e)==="default"){if(!["function","class","abstract"].includes(n(e+1)))w(e+1,s.length);continue}if(n(e)==="type")e++;if(n(e)==="{"){let r=c.get(e);if(r===void 0||n(r+1)==="from")continue;for(let u=e+1;u<r;){if(n(u)==="type"&&a(u+1)&&n(u+1)!=="as")u++;k(u);while(u<r&&n(u)!==",")u++;u++}}}if(n(i)==="["){let e=c.get(i);if(e!==void 0&&[":","?","("].includes(n(e+1))&&n(i+2)!==":"&&n(i+2)!=="in")w(i+1,e)}}if(o.kind==="class"){let i=-1;for(let e=0;e<s.length&&n(e)!=="{";e++)if(n(e)==="<"&&c.has(e))e=c.get(e);else if(n(e)==="extends"){i=e;break}if(i!==-1){let e=i+1;while(e<s.length&&n(e)!=="{"&&n(e)!=="implements"){let r=c.get(e);if(r!==void 0)e=r+1;else e++}w(i+1,e)}}}
|
|
3
3
|
export{ft,Gt,V,er,tr,nr};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{a,i,h,g,xe,ze}from"./chunk-mm1cfz16.js";import{t,m,d,Ue,b}from"./chunk-d0dbet9n.js";import{cr}from"./chunk-h2007n8k.js";import{Ve}from"./chunk-znsgvx9t.js";import{ir}from"./chunk-c87yyjv7.js";import{V,nr}from"./chunk-hnw7mwcw.js";import{Hn}from"./chunk-fn2xxavw.js";import{y,K}from"./chunk-vk5r6pgx.js";import{H}from"./chunk-d27xpsa4.js";import{_e,we,je}from"./chunk-564pr6v4.js";import{n,B,W,Ht,rr,Kt,U,z}from"./chunk-nqdc6n5d.js";import{zn}from"./chunk-bxjswrak.js";import{x}from"./chunk-8dyz1cte.js";import{Jn}from"./chunk-vwn5fx4f.js";function Oi(E,ne,Q,Y,ue=""){let fe=new Map,f={start:0,end:E.length,header:0,name:"",children:[],results:new Map},J=t(E),be=[],w=[],Ke=[],tt=new Map;for(let te=0;te<J.length;te++){let e=J[te];if(e.kind!=="punctuation")continue;let pe=E.slice(e.start,e.end);if(pe==="(")Ke.push(te);else if(pe===")"){let me=Ke.pop();if(me!==void 0)tt.set(te,me)}else if(pe==="{")w.push(te);else if(pe==="}"){let me=w.pop();if(me===void 0)continue;let ae=J[me].start,ie=me-1,re=ie>=0?E.slice(J[ie].start,J[ie].end):"";if(re===")"){let Te=tt.get(ie);if(Te!==void 0&&Te>0&&["if","for","while","switch","catch","with"].includes(E.slice(J[Te-1].start,J[Te-1].end)))ae=J[Te-1].start}else if(["else","try","finally","do"].includes(re))ae=J[ie].start;be.push({open:J[me].start,close:e.start,header:ae})}}let N=0,G=(te,e=new Set)=>{let pe=new Set(e),me=t(E.slice(te.start,te.end)),ae=0;for(let he=0;he+1<me.length;he++){let He=E.slice(te.start+me[he].start,te.start+me[he].end);if(He==="{")ae++;else if(He==="}")ae--;else if(!ae&&["type","interface"].includes(He))pe.add(E.slice(te.start+me[he+1].start,te.start+me[he+1].end))}let ie="",re=te.start,Te=[...te.results].map(([he,He])=>({type:he,name:He}));for(let he of te.children.sort((He,lt)=>He.header-lt.header)){let He=G(he,pe);ie+=E.slice(re,he.header)+`
|
|
3
|
+
declare namespace ${he.name} {
|
|
4
|
+
${He.text}
|
|
5
|
+
}
|
|
6
|
+
`,re=he.end+1;for(let lt of He.exports)Te.push({type:`${he.name}.${lt.name}`,name:lt.name})}ie+=`${E.slice(re,te.end)}
|
|
7
|
+
;
|
|
8
|
+
${Te.map((he)=>`export type ${he.name} = ${he.type};`).join(`
|
|
9
|
+
`)}`;let Qe=F(ie,ne,!1);for(let he of Te)pe.add(he.name);let ge=ue?Gt(ue).map((he,He)=>[he,`${ce}_capture_${He}`]):[],st=Qe.map((he)=>ue&&["type","interface"].includes(he.kind)?Wn(he,ue,ge,pe):(he.kind==="variable"?x(he,!1):he.text).replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
|
|
10
|
+
`);return{declarations:Qe,text:st,exports:Te}},ce;return{resolve(te,e){ce??=Q();let pe=f;for(let ae of be.filter((ie)=>ie.open<e&&e<ie.close).sort((ie,re)=>ie.open-re.open)){let ie=pe.children.find((re)=>re.start===ae.open+1);if(!ie)ie={start:ae.open+1,end:ae.close,header:ae.header,name:`${ce}_scope_${N++}`,children:[],results:new Map},pe.children.push(ie);pe=ie}let me=pe.results.get(te);if(!me)me=`${ce}_result_${fe.size}`,pe.results.set(te,me),fe.set(me,te);return`${ce}.${me}`},finish(te){if(!ce)return te;let e=G(f),pe=e.declarations,me=new Set(fe.keys());if(pe.every((ie)=>me.has(ie.name))){let ie=new Map(fe),re=t(te),Te="",Qe=0;for(let ge=0;ge+2<re.length;ge++){if(te.slice(re[ge].start,re[ge].end)!==ce||te.slice(re[ge+1].start,re[ge+1].end)!==".")continue;let st=ie.get(te.slice(re[ge+2].start,re[ge+2].end));if(!st)continue;Te+=te.slice(Qe,re[ge].start)+`(${st})`,Qe=re[ge+2].end,ge+=2}return Te+te.slice(Qe)}if(ue){let ie=Gt(ue).join(", "),re=t(te),Te="",Qe=0;for(let ge=0;ge+2<re.length;ge++){if(te.slice(re[ge].start,re[ge].end)!==ce||te.slice(re[ge+1].start,re[ge+1].end)!=="."||!me.has(te.slice(re[ge+2].start,re[ge+2].end)))continue;Te+=`${te.slice(Qe,re[ge+2].end)}<${ie}>`,Qe=re[ge+2].end,ge+=2}te=Te+te.slice(Qe)}let ae=e.text;return Y({kind:"module",name:ce,text:`declare namespace ${ce} {
|
|
11
|
+
${ae}
|
|
12
|
+
}`,moduleForm:"namespace",isExported:!1}),te}}}function Gt(E){let ne=t(E),Q=[],Y=0,ue=0,fe=!1;for(let f of ne){let J=E.slice(f.start,f.end);if(J==="<"){if(Y++,Y===1)fe=!0}else if(J===">"&&E[f.start-1]!=="=")Y--;else if(["(","[","{"].includes(J))ue++;else if([")","]","}"].includes(J))ue--;else if(J===","&&Y===1&&!ue)fe=!0;else if(fe&&f.kind==="word"&&!["const","in","out"].includes(J))Q.push(J),fe=!1}return Q}function Wn(E,ne,Q,Y){let ue=new Set(Gt(E.generics||"")),fe=(G,ce,te)=>{let e=t(G),pe="",me=0;for(let ae=0;ae<e.length;ae++){let ie=e[ae],re=G.slice(ie.start,ie.end),Te=e[ae+1]&&G.slice(e[ae+1].start,e[ae+1].end),Qe=e[ae+2]&&G.slice(e[ae+2].start,e[ae+2].end),ge=e[ae-1]&&G.slice(e[ae-1].start,e[ae-1].end);if(ie.kind!=="word"||Te===":"||Te==="?"&&Qe===":")continue;let st=!te.has(re)&&ge!=="."&&Q.find(([he])=>he===re)?.[1];if(st)pe+=G.slice(me,ie.start)+st,me=ie.end;else if(ce&&Y.has(re)&&!te.has(re)){let he=Q.map(([,He])=>He).join(", ");pe+=`${G.slice(me,ie.end)}<${he}${Te==="<"?", ":">"}`,me=Te==="<"?e[++ae].end:ie.end}}return pe+G.slice(me)},f=t(E.text),J=f.findIndex((G)=>["type","interface"].includes(E.text.slice(G.start,G.end))),be=f[J+1],w=E.generics||"",Ke=w?E.text.indexOf(w,be.end)+w.length:be.end,tt=fe(Bn(ne),!1,new Set),N=w?`, ${fe(w.slice(1,-1),!0,ue)}`:"";return`${E.text.slice(0,be.end)}<${tt}${N}>${fe(E.text.slice(Ke),!0,ue)}`.replace(/^export\s+/,"").replace(/^declare\s+/,"")}function Bn(E){let ne=E.slice(1,-1),Q=t(ne),Y=0,ue=0,fe=!1,f="";for(let J=0;J<Q.length;J++){let be=Q[J],w=ne.slice(be.start,be.end);if(["(","[","{","<"].includes(w))Y++;else if([")","]","}"].includes(w)||w===">"&&ne[be.start-1]!=="=")Y--;else if(!Y&&w==="const")f+=ne.slice(ue,be.start),ue=be.end;else if(!Y&&w==="="&&ne.slice(Q[J+1]?.start,Q[J+1]?.end)!==">")f+=ne.slice(ue,be.start),fe=!0;else if(!Y&&w===","&&fe)ue=be.start,fe=!1}return f+(fe?"":ne.slice(ue))}var Fe=32,Ge=9,ye=10,Ee=13,X=47,ke=42,Ae=39,$e=34,We=96,Ye=92,L=123,ee=125,le=40,Ce=41,De=91,Me=93,Se=60,Ie=62,oe=59,et=58,Oe=61,nt=44,Ct=46,It=63,pn=35,Ln=64,Nn=36;function Ne(E){return E===Fe||E===Ge||E===ye||E===Ee}function qn(E){let ne=!0;for(let Q=0;Q<E.length;Q++){let Y=E.charCodeAt(Q);if(Y===Ct){if(ne)return!1;ne=!0}else if(ne){if(!a(Y))return!1;ne=!1}else if(!i(Y))return!1}return E.length>0&&!ne}function $t(E,ne,Q){let Y=ne+1;while(Y<E.length){let ue=E.charCodeAt(Y);if(ue===Ye){Y+=2;continue}if(Y++,ue===Q)break}return Y}function jn(E){if(E==="any"||E==="object"||E==="unknown")return!0;if(E.startsWith("Record<")||E.startsWith("Array<"))return!0;return E.charCodeAt(0)===L&&E.includes("[")&&E.includes("]:")}var Ut=["public","protected","private","readonly","override"];function Ba(E,ne,Q=!0,Y=!1){return Y?R(E,ne,Q):F(E,ne,Q)}function R(E,ne,Q=!0){return Vt(E,ne,Q,!0)}function F(E,ne,Q=!0,Y){return Vt(E,ne,Q,!1,!1,Y)}function jt(E,ne,Q=!0){return Vt(E,ne,Q,!0,!0)}function Vt(E,ne,Q,Y,ue=!1,fe){let f=E,J=Q,be=Y,w=f.length,Ke=ze(f),tt=V(f),N=[],G=new Map,ce=new Map,te=new Set,e=0,pe,me=0,ae=[],ie=[],re=[],Te=[],Qe;function ge(s){let o=`__dtsx_constructor_field_${Te.length}__`;Qe??=new Set(m(f).filter((r)=>r.kind==="word").map((r)=>f.slice(r.start,r.end)).filter((r)=>r.startsWith("__dtsx_constructor_field_")));while(Qe.has(o))o+="_";return Te.push({marker:o,initializer:s,classes:ae.map((r)=>r.name),namespaces:[...re]}),o}function st(s){let o=/^this\.([\w$]+)$/.exec(s);if(o){let p=ae.at(-1);return p?.fields.get(`${p.isStatic?"static:":""}${o[1]}`)}let r=/^([\w$]+)\s*\(/.exec(s);if(!r||!s.endsWith(")"))return;let c=t(s),l=0;for(let p=1;p<c.length;p++){let S=s.slice(c[p].start,c[p].end);if(S==="(")l++;else if(S===")"&&--l===0&&p!==c.length-1)return}let u=[...N,...G.values()].filter((p)=>p.kind==="function"&&p.name===r[1]);if(u.length!==1||u[0].generics||Ve(f,r[1])!==1)return;return u[0].returnType}function he(s){let o=s.trim(),r=st(o);if(r)return r;if(!o.startsWith("class"))return;let c=t(o);if(c[0]?.kind!=="word"||o.slice(c[0].start,c[0].end)!=="class")return;let l;do l=`__dtsx_class_${me++}`;while(f.includes(l));let u=c[1],p=u?o.slice(u.start,u.end):"",S=u?.kind==="word"&&!["extends","implements"].includes(p),A=S?p:`${l}_value`,C=S?`export ${o}`:`export class ${A} ${o.slice(5)}`,v=F(C,ne,J),O=v.find((k)=>k.kind==="class");if(!O)throw Error("Cannot extract the class expression declaration");if(t(C.slice(O.end??C.length)).some((k)=>C.slice((O.end??0)+k.start,(O.end??0)+k.end)!==";"))return;let M=v.map((k)=>k.text.replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
|
|
13
|
+
`);return G.set(l,{kind:"module",name:l,text:`declare namespace ${l} {
|
|
14
|
+
${M}
|
|
15
|
+
}`,moduleForm:"namespace",isExported:!1,start:e,end:e}),`typeof ${l}.${A}`}function He(s,o){let r=/^this\.([\w$]+)$/.exec(s);if(r)return ae.at(-1)?.fields.get(`${o?"static:":""}${r[1]}`);return he(s)}function lt(s){let o=ce.get(s.name);if(o)o.push(s);else ce.set(s.name,[s]);G.set(s.name,s)}if(e<w&&f.charCodeAt(e)===65279)e++;function ve(s,o){if(s<o){let r=f.charCodeAt(s),c=f.charCodeAt(o-1);if(r!==Fe&&r!==Ge&&r!==ye&&r!==Ee&&c!==Fe&&c!==Ge&&c!==ye&&c!==Ee)return f.slice(s,o)}while(s<o&&Ne(f.charCodeAt(s)))s++;while(o>s&&Ne(f.charCodeAt(o-1)))o--;return f.slice(s,o)}let Qt=/[\r\n]/g;function ft(s){return Qt.lastIndex=s,Qt.exec(f)?.index??w}function D(){if(e>=w)return;let s=f.charCodeAt(e);if(s!==Fe&&s!==Ge&&s!==ye&&s!==Ee&&s!==X)return;while(e<w){let o=f.charCodeAt(e);if(o===Fe||o===Ge||o===ye||o===Ee){e++;continue}if(o===X&&e+1<w){let r=f.charCodeAt(e+1);if(r===X){e=ft(e+2);continue}if(r===ke){let c=f.indexOf("*/",e+2);e=c===-1?w:c+2;continue}}break}}function Cn(s){if(s.indexOf("//")===-1&&s.indexOf("/*")===-1)return s;let o=0,r=0;while(r<s.length){let c=s.charCodeAt(r);if(c===Ae||c===$e||c===We){r=$t(s,r,c),o=r;continue}if(c===Ye){r+=2,o=Math.min(r,s.length);continue}if(c===X&&s.charCodeAt(r+1)===X){while(r<s.length&&s.charCodeAt(r)!==ye&&s.charCodeAt(r)!==Ee)r++;continue}if(c===X&&s.charCodeAt(r+1)===ke){let l=s.indexOf("*/",r+2);r=l===-1?s.length:l+2;continue}if(r++,c>32)o=r}return o<s.length?s.slice(0,o).trimEnd():s}function An(s){let o=s.length,r=0,c=o;for(let l=0;l<o;l++){let u=s.charCodeAt(l);if(r){if(u===Ye){l++;continue}if(u===r)r=0;continue}if(u===Ae||u===$e||u===We){r=u;continue}if(u===X&&l+1<o){let p=s.charCodeAt(l+1);if(p===X){c=l;while(c>0&&(s.charCodeAt(c-1)===Fe||s.charCodeAt(c-1)===Ge))c--;return s.slice(0,c)}if(p===ke){let S=s.indexOf("*/",l+2);if(S!==-1){s=`${s.slice(0,l)} ${s.slice(S+2)}`,l--;continue}}}}c=o;while(c>0&&(s.charCodeAt(c-1)===Fe||s.charCodeAt(c-1)===Ge||s.charCodeAt(c-1)===Ee))c--;return c<o?s.slice(0,c):s}function it(s){e++;let o=s===Ae?"'":'"';while(e<w){let r=f.indexOf(o,e);if(r===-1){e=w;return}let c=0,l=r-1;while(l>=0&&f.charCodeAt(l)===Ye)c++,l--;if(c%2===0){e=r+1;return}e=r+1}}function At(){e++;let s=[];while(e<w){let o=f.charCodeAt(e);if(s.length===0){if(o===Ye){e+=2;continue}if(o===We){e++;return}if(o===Nn&&e+1<w&&f.charCodeAt(e+1)===L){e+=2,s.push(0);continue}e++;continue}if(o===Ae||o===$e){it(o);continue}if(o===We){At();continue}if(o===X&&e+1<w){let r=f.charCodeAt(e+1);if(r===X){e=ft(e+2);continue}if(r===ke){let c=f.indexOf("*/",e+2);e=c===-1?w:c+2;continue}if(Jt()){Zt();continue}e++;continue}if(o===L){s[s.length-1]++,e++;continue}if(o===ee){let r=s[s.length-1];if(r===0){s.pop(),e++;continue}s[s.length-1]=r-1,e++;continue}e++}}let Ot=!1;function qe(){Ot=!1;let s=f.charCodeAt(e);if(s===Ae||s===$e)return it(s),!0;if(s===We)return At(),!0;if(s===X&&e+1<w){let o=f.charCodeAt(e+1);if(o===X)return e=ft(e+2),!0;if(o===ke){let r=f.indexOf("*/",e+2);return Ot=ft(e+2)<(r===-1?w:r),e=r===-1?w:r+2,!0}if(Jt())return Zt(),!0}return!1}function Jt(){return h(f,e)}function Zt(){e=g(f,e)}function Re(){let s=e;while(e<w&&i(f.charCodeAt(e)))e++;return f.slice(s,e)}function _(s){if(e+s.length>w)return!1;for(let o=0;o<s.length;o++)if(f.charCodeAt(e+o)!==s.charCodeAt(o))return!1;if(e+s.length<w&&i(f.charCodeAt(e+s.length)))return!1;return!0}function xt(s){let o=e+s;while(o<w){let r=f.charCodeAt(o);if(r===Fe||r===Ge||r===ye||r===Ee){o++;continue}return r!==Ct&&r!==Oe}return!1}function Xt(){if(!Ot)return!1;let s=e;D();let o=e>=w||Et()||f.charCodeAt(e)===ee;return e=s,o}function Et(){if(e>=w)return!1;switch(f.charCodeAt(e)){case 101:return _("export")||_("enum");case 105:return _("import")||_("interface");case 102:return _("function");case 99:return _("class")||_("const");case 116:return _("type");case 108:return _("let");case 118:return _("var");case 100:return _("declare")||_("default");case 109:return _("module");case 110:return _("namespace");case 97:return _("abstract")||_("async");default:return!1}}function ht(){let s=f.charCodeAt(e);if(s!==ye&&s!==Ee)return!1;let o=e;if(e++,s===Ee&&e<w&&f.charCodeAt(e)===ye)e++;while(e<w){let c=f.charCodeAt(e);if(c===Fe||c===Ge||c===Ee||c===ye){e++;continue}if(c===X&&e+1<w){let l=f.charCodeAt(e+1);if(l===X){e=ft(e+2);continue}if(l===ke){let u=f.indexOf("*/",e+2);e=u===-1?w:u+2;continue}}break}let r=e>=w||Et()||f.charCodeAt(e)===ee;return e=o,r}function bn(s){let o=s-1;while(o>=0){let A=f.charCodeAt(o);if(A===Fe||A===Ge||A===Ee||A===ye){o--;continue}break}if(o<0)return!0;let r=f[o];if("+-*/%=<>&|^!~?:,.([{".includes(r))return!0;let c=o;while(c>0&&f.charCodeAt(c-1)!==ye)c--;let l=f.slice(c,o+1),u=l.lastIndexOf("<");if(u!==-1&&/^<[A-Za-z]/.test(l.slice(u))&&!l.slice(u).includes(">"))return!0;let p=o;while(p>=0&&/[a-z]/i.test(f[p]))p--;let S=f.slice(p+1,o+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(S)}function wn(s,o){let r=f.charCodeAt(e);if(r!==ye&&r!==Ee&&!(r===X&&(f[e+1]==="/"||f[e+1]==="*")))return!1;let c=m(f),l=0,u=c.length;while(l<u){let v=l+u>>>1;if(c[v].start<e)l=v+1;else u=v}let p=c[l-1],S=c[l];if(!p||p.start<s||!/[\r\n]/.test(f.slice(e,S?.start??w)))return!1;let A=f.slice(p.start,p.end);if(p.end!==o&&p.kind==="punctuation"&&"+-*/%=<>&|^!~?:,.([{".includes(A))return!1;if(p.kind==="word"&&["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(A))return!1;if(!S)return!0;let C=f.slice(S.start,S.end);return!(".?:)]},+-*/%<>=&|^`([".includes(C)||S.kind==="literal"&&f.charCodeAt(S.start)===We||["as","satisfies","instanceof","in"].includes(C))}function Yt(){let s=f.charCodeAt(e);if(s!==ye&&s!==Ee)return!1;if(bn(e))return!1;let o=e;e++;while(e<w){let l=f.charCodeAt(e);if(l===Fe||l===Ge||l===Ee||l===ye){e++;continue}if(l===X&&e+1<w){let u=f.charCodeAt(e+1);if(u===X){e=ft(e+2);continue}if(u===ke){let p=f.indexOf("*/",e+2);e=p===-1?w:p+2;continue}}break}let r=e<w?f[e]:"",c=r==="|"||r==="&"||r==="["||r==="."||r==="?"||r===":"||r===">"||r===")"||r===","||_("extends");return e=o,!c}function bt(){let s=f.charCodeAt(e);if(s!==ye&&s!==Ee)return!1;let o=e;if(e++,s===Ee&&e<w&&f.charCodeAt(e)===ye)e++;while(e<w){let c=f.charCodeAt(e);if(c===Fe||c===Ge||c===Ee||c===ye){e++;continue}if(c===X&&e+1<w&&f.charCodeAt(e+1)===X){e=ft(e+2);continue}break}if(e>=w)return e=o,!0;let r=f.charCodeAt(e);if(r===124||r===38||r===Ct||r===It||r===et)return e=o,!1;if(_("extends")||_("keyof")||_("typeof")||_("infer")||_("is")||_("as")||_("in"))return e=o,!1;return e=o,!0}let kn=/[{}'"`\/]/g,$n=/[()'"`\/]/g,xn=/[[\]'"`\/]/g,yn=/[<>'"`\/]/g;function Be(s,o){let r=1;e++;let c=s===L?kn:s===le?$n:s===De?xn:yn;c.lastIndex=e;let l;while((l=c.exec(f))!==null){let u=l.index,p=f.charCodeAt(u);if(p===Ae||p===$e){e=u,it(p),c.lastIndex=e;continue}if(p===We){e=u,At(),c.lastIndex=e;continue}if(p===X){if(e=u,qe()){c.lastIndex=e;continue}c.lastIndex=u+1;continue}if(p===s)r++;else if(p===o){if(o===Ie&&u>0&&f.charCodeAt(u-1)===Oe){c.lastIndex=u+1;continue}if(r--,r===0)return e=u+1,e}c.lastIndex=u+1}return e=w,e}function Xe(){return e>0&&f.charCodeAt(e-1)===Oe}function Rt(){return e+1<w&&f.charCodeAt(e+1)===Ie}let Je=/[<{};'"`\/\n\r()[\]]/g;function Le(s=!1){let o=0,r=0,c=0,l=0,u=f.charCodeAt(e)===L;Je.lastIndex=e;let p;while((p=Je.exec(f))!==null){let S=p.index,A=f.charCodeAt(S);if(A===Ae||A===$e){e=S,it(A),Je.lastIndex=e;continue}if(A===We){e=S,At(),Je.lastIndex=e;continue}if(A===X){if(S>0&&f.charCodeAt(S-1)===Se){Je.lastIndex=S+1;continue}if(e=S,qe()){if(o===0&&r===0&&c===0&&l===0&&Xt())return;Je.lastIndex=e;continue}Je.lastIndex=S+1;continue}if(A===Se){let C=Ke(S)?.delta??null;if(C!==null)l=Math.max(0,l+C);Je.lastIndex=S+1;continue}if(A===le){r++,Je.lastIndex=S+1;continue}if(A===Ce){r--,Je.lastIndex=S+1;continue}if(A===De){c++,Je.lastIndex=S+1;continue}if(A===Me){c--,Je.lastIndex=S+1;continue}if(A===L){o++,Je.lastIndex=S+1;continue}if(A===ee){let C=o>0;if(!C&&s&&r===0&&c===0&&l===0){e=S;return}if(C)o--;if((!C||u)&&o===0&&r===0&&c===0&&l===0){e=S+1;return}if(C&&o===0&&r===0&&c===0&&l===0){e=S+1;let v=e;D();let O=Et();if(e=v,O)return}Je.lastIndex=S+1;continue}if(A===oe&&o===0&&r===0&&c===0&&l===0){e=S+1;return}if((A===ye||A===Ee)&&o===0&&r===0&&c===0&&l===0){if(e=S,ht())return}Je.lastIndex=S+1}e=w}function vn(){e++;while(e<w&&(f.charCodeAt(e)===Fe||f.charCodeAt(e)===Ge))e++;let s=f.indexOf(`
|
|
16
|
+
`,e),o=s===-1?w:s,r=f.indexOf(";",e);if(r!==-1&&r<o){let c=r-1;while(c>=e&&(f.charCodeAt(c)===Fe||f.charCodeAt(c)===Ge))c--;let l=f.charCodeAt(e),u=f.charCodeAt(c);if(l===L&&u===ee||l===De&&u===Me||l===Ae&&u===Ae||l===$e&&u===$e||l===We&&u===We){e=r+1;return}}Le()}function en(){Be(L,ee);while(e<w&&Ne(f.charCodeAt(e)))e++;if(_("from")){e+=4;while(e<w&&Ne(f.charCodeAt(e)))e++;if(e<w){let s=f.charCodeAt(e);if(s===Ae||s===$e)it(s)}}while(e<w&&(f.charCodeAt(e)===Fe||f.charCodeAt(e)===Ge))e++;if(e<w&&f.charCodeAt(e)===oe)e++}function tn(){e++;while(e<w&&Ne(f.charCodeAt(e)))e++;if(_("as")){e+=2;while(e<w&&Ne(f.charCodeAt(e)))e++;Re();while(e<w&&Ne(f.charCodeAt(e)))e++}if(_("from")){e+=4;while(e<w&&Ne(f.charCodeAt(e)))e++;if(e<w){let s=f.charCodeAt(e);if(s===Ae||s===$e)it(s)}}while(e<w&&(f.charCodeAt(e)===Fe||f.charCodeAt(e)===Ge))e++;if(e<w&&f.charCodeAt(e)===oe)e++}function yt(s){let o=s.indexOf("from ");if(o===-1)return;let r=o+5;while(r<s.length&&(s.charCodeAt(r)===32||s.charCodeAt(r)===9))r++;if(r>=s.length)return;let c=s.charCodeAt(r);if(c!==39&&c!==34)return;let l=s.indexOf(s[r],r+1);if(l===-1)return;return s.slice(r+1,l)}function Ze(s){if(!J)return;let o=s-1;while(o>=0&&Ne(f.charCodeAt(o)))o--;if(o<0)return;let r=[],c=!1;while(o>=0){if(o>=1&&f.charCodeAt(o)===X&&f.charCodeAt(o-1)===ke){let p=f.lastIndexOf("/*",o-2);if(p>=0){r.push(f.slice(p,o+1)),c=!0,o=p-1;while(o>=0&&Ne(f.charCodeAt(o)))o--;continue}break}let l=o;while(l>0&&f.charCodeAt(l-1)!==ye)l--;let u=ve(l,o+1);if(u.startsWith("//")){if(c)break;let p=[u];o=l-1;while(o>=0&&(f.charCodeAt(o)===ye||f.charCodeAt(o)===Ee))o--;while(o>=0){let S=o;while(S>0&&f.charCodeAt(S-1)!==ye)S--;let A=ve(S,o+1);if(A.startsWith("//")){p.push(A),o=S-1;while(o>=0&&(f.charCodeAt(o)===ye||f.charCodeAt(o)===Ee))o--}else if(A===""){o=S-1;while(o>=0&&(f.charCodeAt(o)===ye||f.charCodeAt(o)===Ee))o--}else break}p.reverse(),r.push(p.join(`
|
|
17
|
+
`));continue}break}if(r.length===0)return;return r.reverse(),r}function Sn(s){let o=s,r=!1,c=0,l;while(e<w){let I=f.charCodeAt(e);if(I===X&&(f.charCodeAt(e+1)===X||f.charCodeAt(e+1)===ke)){D();continue}if(I===oe){e++;break}if(I===L)c++;else if(I===ee&&c>0)c--;if(I===Ae||I===$e){if(it(I),c>0)continue;r=!0;let M=e;if(D(),f.charCodeAt(e)===Ce){let k=e+1;l=Ue(f.slice(o,k)),e=l?k:M}else e=M;while(e<w&&(f.charCodeAt(e)===Fe||f.charCodeAt(e)===Ge))e++;if(e<w&&f.charCodeAt(e)===oe)e++;break}if(I===ye&&r)break;e++}let u=ve(o,e),p=b(u).find((I)=>I.category==="static-import"),S=t(u),A=l?.isTypeOnly??p?.isTypeOnly??!1,C=S[1]?.kind==="quoted",v=l?.source??p?.specifier??"",O=Ze(o);return{kind:"import",name:"",text:u,isExported:!1,isTypeOnly:A,isSideEffect:C,source:v,leadingComments:O,start:o,end:e}}function Mt(){let s=e;return Be(L,ee),f.slice(s,e)}function nn(s){let o=s.indexOf("(");if(o===-1)return s;let r=s.slice(o);if(r.indexOf("=")===-1)return s;let c=!1;for(let A=0;A<r.length;A++)if(r.charCodeAt(A)===61){let v=A>0?r.charCodeAt(A-1):0,O=A+1<r.length?r.charCodeAt(A+1):0;if(v!==61&&v!==33&&v!==60&&v!==62&&O!==61&&O!==62){c=!0;break}}if(!c)return s;let l=0,u=-1;for(let A=o;A<s.length;A++){let C=s.charCodeAt(A);if(C===40)l++;else if(C===41){if(l--,l===0){u=A;break}}}if(u===-1)return s;let p=s.slice(o,u+1),S=pt(p);return s.slice(0,o)+S+s.slice(u+1)}function sn(s){let o=s.indexOf("//")!==-1||s.indexOf("/*")!==-1,r=s.split(`
|
|
18
|
+
`),c=[],l=[],u=[],p=!1,S=1/0;for(let v=0;v<r.length;v++){let O=r[v];if(o){if(p){if(O.includes("*/"))p=!1;continue}let I=O.trim();if(I.length===0)continue;let M=I.charCodeAt(0);if(M===X){let Z=I.charCodeAt(1);if(Z===X)continue;if(Z===ke){if(!I.includes("*/"))p=!0;continue}}if(M===ke)continue;let k=An(O);if(k.charCodeAt(k.length-1)===oe)k=k.slice(0,-1);k=nn(k);let T=k.trim();if(!T)continue;c.push(k),l.push(T);let j=0;while(j<k.length&&Ne(k.charCodeAt(j)))j++;if(T!=="{"&&T!=="}"){if(j<S)S=j}u.push(j)}else{let I=O.length;while(I>0&&(O.charCodeAt(I-1)===Fe||O.charCodeAt(I-1)===Ge||O.charCodeAt(I-1)===Ee))I--;if(I===0)continue;let M=I<O.length?O.slice(0,I):O;if(M.charCodeAt(M.length-1)===oe)M=M.slice(0,-1);M=nn(M);let k=M.trim();if(!k)continue;c.push(M),l.push(k);let T=0;while(T<M.length&&Ne(M.charCodeAt(T)))T++;if(k!=="{"&&k!=="}"){if(T<S)S=T}u.push(T)}}if(c.length===0)return"{}";if(S===1/0||S<=2)return c.join(`
|
|
19
|
+
`);let A=S-2,C=Array(c.length);for(let v=0;v<c.length;v++){let O=l[v];if(O==="{"){C[v]=O;continue}let I=u[v];if(I>S)C[v]=c[v];else if(I===S&&(O.charCodeAt(0)===ee||O.charCodeAt(0)===Me||O.charCodeAt(0)===Ce))C[v]=c[v];else{let M=Math.max(0,I-A);C[v]=" ".repeat(M)+O}}return C.join(`
|
|
20
|
+
`)}function rt(){if(e>=w||f.charCodeAt(e)!==Se)return"";let s=e;Be(Se,Ie);let o=f.slice(s,e);if(o.includes(`
|
|
21
|
+
`)){let r="",c=!1;for(let l=0;l<o.length;l++){let u=o.charCodeAt(l);if(u===32||u===9||u===10||u===13){if(!c&&r.length>0)r+=" ",c=!0}else r+=o[l],c=!1}if(r.charCodeAt(1)===32)r=`<${r.slice(2)}`;if(r.charCodeAt(r.length-2)===32)r=`${r.slice(0,-2)}>`;return r}return o}function ot(){if(e>=w||f.charCodeAt(e)!==le)return"()";let s=e;return Be(le,Ce),f.slice(s,e)}function vt(s){if(s.indexOf("/")===-1)return s;let o="",r=!1,c=0;for(let l=0;l<s.length;l++){let u=s.charCodeAt(l);if(r){if(o+=s[l],u===Ye&&l+1<s.length){o+=s[++l];continue}if(u===c)r=!1;continue}if(u===Ae||u===$e||u===We){r=!0,c=u,o+=s[l];continue}if(u===X&&l+1<s.length){let p=s.charCodeAt(l+1);if(p===ke){let S=s.indexOf("*/",l+2);l=S===-1?s.length:S+1,o+=" ";continue}if(p===X){let S=s.indexOf(`
|
|
22
|
+
`,l+2);l=S===-1?s.length:S-1;continue}if(h(s,l)){let S=g(s,l);o+=s.slice(l,S),l=S-1;continue}}o+=s[l]}return o.trim()}function pt(s){let o=s.slice(1,-1).trim();if(!o)return"()";if(s.indexOf(`
|
|
23
|
+
`)===-1&&o.indexOf(":")!==-1&&o.indexOf("{")===-1&&o.indexOf("[")===-1&&o.indexOf("=")===-1&&o.indexOf("@")===-1&&o.indexOf("...")===-1){let A=0,C=0,v=0;for(let O=0;O<o.length;O++){let I=o.charCodeAt(O);if(I===le||I===Se||I===L)v++;else if(I===Ce||I===Ie||I===ee)v--;else if(v===0){if(I===et)A++;else if(I===nt)C++}}if(A>=C+1){let O=!1;for(let I=0;I<Ut.length;I++){let M=Ut[I],k=o.indexOf(M);if(k!==-1){let T=k+M.length;if((k===0||!i(o.charCodeAt(k-1)))&&(T>=o.length||!i(o.charCodeAt(T)))){O=!0;break}}}if(!O)return s}}let r=[],c=0,l=0,u=!1,p=0;for(let A=0;A<=o.length;A++){if(A===o.length){r.push(vt(o.slice(c).trim()));break}let C=o.charCodeAt(A);if(u){if(C===Ye){A++;continue}if(C===p)u=!1;continue}if(C===X&&A+1<o.length){let v=o.charCodeAt(A+1);if(v===ke){A+=2;while(A+1<o.length&&!(o.charCodeAt(A)===ke&&o.charCodeAt(A+1)===X))A++;A++;continue}if(v===X){while(A<o.length&&o.charCodeAt(A)!==10)A++;continue}if(h(o,A)){A=g(o,A)-1;continue}}if(C===Ae||C===$e||C===We){u=!0,p=C;continue}if(C===le||C===L||C===De||C===Se)l++;else if(C===Ce||C===ee||C===Me||C===Ie&&!(A>0&&o.charCodeAt(A-1)===Oe))l--;else if(C===nt&&l===0)r.push(vt(o.slice(c,A).trim())),c=A+1}let S=[];for(let A of r){if(!A)continue;let C=A.trim();if(C.startsWith("//")||C.startsWith("/*"))continue;let v=A;{let O=!1,I=0,M=0,k=0;for(let T=0;T<v.length-1;T++){let j=v.charCodeAt(T);if(j===ye){k=T+1;continue}if(O){if(j===Ye){T++;continue}if(j===I)O=!1;continue}if(j===Ae||j===$e||j===We){O=!0,I=j;continue}if(j===L||j===De||j===le||j===Se){M++;continue}if(j===ee||j===Me||j===Ce||j===Ie){if(M>0)M--;continue}if(j===X&&h(v,T)){T=g(v,T)-1;continue}if(j===X&&v.charCodeAt(T+1)===X){if(M===0){v=v.slice(0,T).trimEnd();break}let Z=v.indexOf(`
|
|
24
|
+
`,T);if(Z===-1){v=v.slice(0,k).trimEnd();break}let q=v.slice(0,k),P=v.slice(Z+1);v=`${q}${P}`,T=k-1}}}if(!v.trim())continue;S.push(rn(v))}return _e(`(${S.join(", ")})`)}function _n(s){if(!s.startsWith("{")&&!s.startsWith("["))return s;let o="",r=0,c=0,l=!1,u=0;while(r<s.length){let p=s.charCodeAt(r);if(l){if(p===Ye&&r+1<s.length){o+=s[r]+s[r+1],r+=2;continue}if(p===u)l=!1;o+=s[r],r++;continue}if(p===X&&r+1<s.length){let S=s.charCodeAt(r+1);if(S===ke){let A=r;r+=2;while(r+1<s.length&&!(s.charCodeAt(r)===ke&&s.charCodeAt(r+1)===X))r++;r=Math.min(r+2,s.length),o+=s.slice(A,r);continue}if(S===X){let A=r;while(r<s.length&&s.charCodeAt(r)!==10)r++;o+=s.slice(A,r);continue}}if(p===Ae||p===$e||p===We){l=!0,u=p,o+=s[r],r++;continue}if(p===L||p===De||p===le)c++;else if(p===ee||p===Me||p===Ce)c--;if(c>=1&&p===Oe&&(r+1>=s.length||s.charCodeAt(r+1)!==Oe&&s.charCodeAt(r+1)!==Ie)){while(o.length>0&&(o[o.length-1]===" "||o[o.length-1]==="\t"||o[o.length-1]===`
|
|
25
|
+
`))o=o.slice(0,-1);r++;let S=0;while(r<s.length){let A=s.charCodeAt(r);if(A===X){if(s.charCodeAt(r+1)===X){let C=s.indexOf(`
|
|
26
|
+
`,r+2);r=C===-1?s.length:C+1;continue}if(s.charCodeAt(r+1)===ke){let C=s.indexOf("*/",r+2);r=C===-1?s.length:C+2;continue}if(h(s,r)){r=g(s,r);continue}}if(A===Ae||A===$e||A===We){let C=A;r++;while(r<s.length){if(s.charCodeAt(r)===Ye){r+=2;continue}if(s.charCodeAt(r)===C){r++;break}r++}continue}if(A===L||A===De||A===le)S++;else if(A===ee||A===Me||A===Ce){if(S===0)break;S--}else if(A===nt&&S===0)break;r++}continue}o+=s[r],r++}return o}function rn(s){let o=s.trim(),r=o.startsWith("...");if(r)o=o.slice(3).trim();while(o.startsWith("@")){let k=1;while(k<o.length&&i(o.charCodeAt(k)))k++;if(k<o.length&&o.charCodeAt(k)===le){let T=1;k++;while(k<o.length&&T>0){if(o.charCodeAt(k)===le)T++;else if(o.charCodeAt(k)===Ce)T--;k++}}o=o.slice(k).trim()}let c=!0;while(c){c=!1;for(let k of Ut)if(o.startsWith(k)&&o.length>k.length&&!i(o.charCodeAt(k.length))){let T=o.slice(k.length).trim();if(T.charCodeAt(0)===et||T.charCodeAt(0)===It&&T.length>1&&T.charCodeAt(1)===et)break;o=T,c=!0;break}}let l=-1,u=-1,p=0,S=!1,A=0;for(let k=0;k<o.length;k++){let T=o.charCodeAt(k);if(S){if(T===Ye){k++;continue}if(T===A)S=!1;continue}if(T===X&&k+1<o.length){let j=o.charCodeAt(k+1);if(j===ke){k+=2;while(k+1<o.length&&!(o.charCodeAt(k)===ke&&o.charCodeAt(k+1)===X))k++;k++;continue}if(j===X){while(k<o.length&&o.charCodeAt(k)!==10)k++;continue}if(h(o,k)){k=g(o,k)-1;continue}}if(T===Ae||T===$e||T===We){S=!0,A=T;continue}if(T===le||T===L||T===De||T===Se)p++;else if(T===Ce||T===ee||T===Me||T===Ie&&!(k>0&&o.charCodeAt(k-1)===Oe))p--;else if(p===0){if(T===et&&l===-1)l=k;else if(T===Oe&&u===-1&&(k===0||o.charCodeAt(k-1)!==Oe)&&(k+1>=o.length||o.charCodeAt(k+1)!==Oe&&o.charCodeAt(k+1)!==Ie))u=k}}let C,v,O=u!==-1;if(l!==-1&&(u===-1||l<u))if(C=o.slice(0,l).trim(),u!==-1)v=o.slice(l+1,u).trim();else v=o.slice(l+1).trim();else if(u!==-1){C=o.slice(0,u).trim();let k=r?null:we(C,o.slice(u+1));if(k)return je(k,wt);v=wt(o.slice(u+1).trim())}else C=o,v="unknown";if(C=_n(C),(C.startsWith("{")||C.startsWith("["))&&C.includes(`
|
|
27
|
+
`)){let k=C.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(k.length<=40)C=k;else C=C.split(`
|
|
28
|
+
`).map((j)=>{let Z=j.trim();if(!Z)return"";if(Z==="{"||Z==="}"||Z==="["||Z==="]"||Z.startsWith("}")||Z.startsWith("]"))return Z;return` ${Z}`}).join(`
|
|
29
|
+
`)}let I=C.endsWith("?")||O;if(C.endsWith("?"))C=C.slice(0,-1).trim();let M=I&&!r?"?":"";if(r)return`...${C}: ${v}`;return`${C}${M}: ${v}`}function wt(s){let o=s.trim(),r=st(o);if(r)return r;if(o==="true"||o==="false")return"boolean";if(y(o))return"number";if(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))return"string";if(o.startsWith("["))return"unknown[]";if(o.startsWith("{"))return"Record<string, unknown>";return U(o)??"unknown"}function Pt(s){let o=s.trim();if(o.endsWith("as const"))o=o.slice(0,-8).trim();if(o==="true"||o==="false")return o;if(y(o))return K(o);let r=Tn(o);if(r!==null)return r;return U(o)??"unknown"}function Tn(s){if(s==="")return null;if(s.charCodeAt(0)===Ae||s.charCodeAt(0)===$e){if($t(s,0,s.charCodeAt(0))===s.length)return s}let o=Dn(s,"+");if(o.length>1){let r=!1,c=!0,l=[];for(let u of o){let p=u.trim(),S=p.charCodeAt(0);if((S===Ae||S===$e)&&$t(p,0,S)===p.length)r=!0,l.push(In(p));else c=!1}if(c)return On(l.join(""));if(r)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(s)&&/\d/.test(s)&&/[+*/%\-\s]/.test(s))return"number";return null}function Dn(s,o){let r=[],c=0,l="",u=0;while(u<s.length){let p=s.charCodeAt(u);if(p===Ae||p===$e||p===We){let S=$t(s,u,p);l+=s.slice(u,S),u=S;continue}if(p===X&&(s.charCodeAt(u+1)===X||s.charCodeAt(u+1)===42)){if(s.charCodeAt(u+1)===X){let C=s.indexOf(`
|
|
30
|
+
`,u+2),v=C===-1?s.length:C;l+=s.slice(u,v),u=v;continue}let S=s.indexOf("*/",u+2),A=S===-1?s.length:S+2;l+=s.slice(u,A),u=A;continue}if(p===le||p===De||p===L)c++;else if(p===Ce||p===Me||p===ee)c--;if(s[u]===o&&c===0){r.push(l),l="",u++;continue}l+=s[u],u++}return r.push(l),r}function In(s){return s.slice(1,-1).replace(/\\(.)/g,(r,c)=>{if(c==="n")return`
|
|
31
|
+
`;if(c==="t")return"\t";if(c==="r")return"\r";if(c==="0")return"\x00";return c})}function On(s){return`'${s.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function St(s){if(s.endsWith("as const"))return null;let o=0,r=-1;for(let l=0;l<s.length;l++){let u=s.charCodeAt(l);if(u===Ae||u===$e||u===We)l=$t(s,l,u)-1;else if(u===123||u===91||u===40)o++;else if(u===125||u===93||u===41)o--;else if(o===0&&u===32&&l+4<=s.length&&s.substring(l,l+4)===" as ")r=l}if(r===-1)return null;return s.slice(r+4).trim()||null}function kt(){if(D(),e<w&&f.charCodeAt(e)===et){let c=function(){let l=ve(s,r),u=(p)=>{let S=l.length-p.length;return S>=0&&l.endsWith(p)&&(S===0||!i(l.charCodeAt(S-1)))};return l.length===0||l.endsWith("=>")||l.endsWith("|")||l.endsWith("&")||u("is")||u("extends")};e++,D();let s=e,o=0,r=s;while(e<w){let l=e;if(qe()){if(f.charCodeAt(l)!==X)r=e;continue}let u=f.charCodeAt(e);if(u===le||u===De||u===Se)o++;else if(u===Ce||u===Me||u===Ie&&!Xe())o--;else if(u===L)if(o>0)o++;else if(c())o++;else break;else if(u===ee){if(o===0)break;o--}else if(o===0&&u===oe)break;if(o===0&&bt()&&!c())break;if(!Ne(u))r=e+1;e++}return ve(s,e)}return""}function ct(s,o,r,c){e+=8,D();let l=e<w&&f.charCodeAt(e)===ke;if(l)e++,D();let u=Re();if(!u&&!c)return null;D();let p=rt();D();let S=ot();D();let A=kt(),C=A.length>0;if(!A)if(r&&l)A="AsyncGenerator<unknown, void, unknown>";else if(l)A="Generator<unknown, void, unknown>";else if(r)A="Promise<void>";else A="void";D();let v=!1;if(e<w&&f.charCodeAt(e)===L){v=!0;let Z=e+1;if(Be(L,ee),!C&&!l){let q=f.slice(Z,e-1),P=Oi(q,ne??"stdin.ts",()=>{let de;do de=`__dtsx_return_${me++}`;while(f.includes(de));return de},(de)=>G.set(de.name,{...de,start:e,end:e}),p);A=P.finish(B(q,r,S,he,P.resolve))}}else if(e<w&&f.charCodeAt(e)===oe)e++;let O=pt(S),k=`${o?c?"export default function ":"export declare function ":"declare function "}${u||(c?"":"default")}${p}${O}: ${A};`,T=Ze(s),j={kind:"function",name:u||"default",text:k,isExported:o,isDefault:c,isAsync:r,isGenerator:l,returnType:A,generics:p||void 0,leadingComments:T,start:s,end:e};if(v)te.add(j);return j}let Wt,En=0;function on(){Wt??=new Set(t(f).filter((s)=>s.kind==="word").map((s)=>f.slice(s.start,s.end)));for(;;){let s=`__dtsx_binding_${En++}`;if(Wt.has(s))continue;return Wt.add(s),s}}function dt(s,o,r){e+=o.length,D();let c=[];do{if(D(),e>=w)break;let l=f.charCodeAt(e),u,p=e;if(l===L||l===De)Be(l,l===L?ee:Me),u=f.slice(p,e);let S=u?on():Re();if(!S)return Le(),c;D();let A,C,v,O=!1;if(e<w&&f.charCodeAt(e)===et){e++,D();let Z=e,q=0;while(e<w){if(qe()){if(q===0&&Xt())break;continue}let P=f.charCodeAt(e);if(P===le||P===L||P===De||P===Se)q++;else if(P===Ce||P===ee||P===Me||P===Ie&&!Xe())q--;else if(q===0&&(P===oe||P===nt))break;else if(q===0&&P===Oe&&!Rt())break;if(q===0&&(ht()||Yt()))break;e++}A=ve(Z,e)}if(e<w&&f.charCodeAt(e)===Oe)if(be&&A&&(!J||!jn(A)))vn();else{e++,D();let Z=e;v=Z;let q=0,P=0,de;while(e<w){if(q===0&&P===0&&wn(Z,de))break;if(qe())continue;let se=f.charCodeAt(e);if(se===le||se===L||se===De)q++;else if(se===Ce||se===ee||se===Me)q--;else if(se===Se){pe??=H(f);let Pe=q===0&&P===0?pe(e,Z,de):void 0;if(Pe?.parameters||Pe?.completeOperand||Pe&&ne!==void 0&&!/\.[jt]sx$/.test(ne)){e=Pe.end,de=Pe.completeOperand?Pe.end:void 0;continue}let ut=P>0||f[e+1]!=="/"&&xe(f,e)?Ke(e):null;if(ut){if(P=Math.max(0,P+ut.delta),e=ut.end+1,P===0)de=e;continue}else if(P===0){if(Pe){e=Pe.end,de=Pe.completeOperand?Pe.end:void 0;continue}}}else if(q===0&&P===0&&(se===oe||se===nt))break;e++}if(C=Cn(ve(Z,e)),C.endsWith(" as const")||C==="const"){if(O=!0,!A){let se=C.endsWith(" as const")?C.slice(0,-9).trim():C,Pe=Pt(se);A=Pe!=="unknown"?Pe:void 0}}else if(!A){let se=z(C)??St(C)??he(C);if(se)A=se}}let I=c.length===0?Ze(s):void 0,M=u?"const":o,k=u?!1:r,T=`${k?"export ":""}declare ${M} ${S}: ${A||"unknown"};`,j={kind:"variable",name:S,text:T,isExported:k,typeAnnotation:A,value:C,initializerStart:v,modifiers:O?[M,"const assertion"]:[M],leadingComments:u?void 0:I,start:s,end:e};if(u)c.push(...cr({pattern:u,patternOffset:p,root:j,kind:o,exported:r,comments:I,allocateName:on}));else c.push(j);if(f.charCodeAt(e)===nt){e++;continue}if(f.charCodeAt(e)===oe)e++;break}while(e<w);return c}function Bt(s,o){e+=9,D();let r=Re();D();let c=rt();D();let l="";if(_("extends")){e+=7,D();let C=e,v=0;while(e<w){if(qe())continue;let O=f.charCodeAt(e);if(O===Se)v++;else if(O===Ie&&!Xe())v--;else if(O===L&&v===0)break;e++}l=ve(C,e)}D();let u=e<w&&f.charCodeAt(e)===L?Mt():"{}",p=sn(u),S=`${o?"export ":""}declare interface ${r}${c}${l?` extends ${l}`:""} ${p}`,A=Ze(s);return{kind:"interface",name:r,text:S,isExported:o,extends:l||void 0,generics:c||void 0,leadingComments:A,start:s,end:e}}function Lt(s,o){e+=4,D();let r=Re();D();let c=rt();if(D(),e<w&&f.charCodeAt(e)===Oe)e++;D();let l=e,u=0;while(e<w){if(qe())continue;let C=f.charCodeAt(e);if(C===le||C===L||C===De||C===Se)u++;else if(C===Ce||C===ee||C===Me||C===Ie&&!Xe())u--;else if(u===0&&C===oe)break;if(u===0&&(ht()||Yt()))break;e++}let p=ve(l,e);if(e<w&&f.charCodeAt(e)===oe)e++;let S=`${o?"export ":""}type ${r}${c} = ${p}`,A=Ze(s);return{kind:"type",name:r,text:S,isExported:o,generics:c||void 0,leadingComments:A,start:s,end:e}}function mt(s,o,r){e+=4,D();let c=Re();D();let l=e;if(e<w&&f.charCodeAt(e)===L)Be(L,ee);let u=ve(s,e),p=Ze(s);return{kind:"enum",name:c,text:u,isExported:o,modifiers:r?["const"]:void 0,leadingComments:p,start:s,end:e}}function at(s,o,r,c=!1){e+=5,D();let l=Re()||"AnonymousClass";D();let u=rt();D();let p="";if(_("extends")){e+=7,D();let I=e,M=0;while(e<w){if(qe())continue;let k=f.charCodeAt(e);if(k===Se)M++;else if(k===Ie&&!Xe())M--;else if(M===0&&(k===L||_("implements")))break;e++}p=ve(I,e)}let S;if(_("implements")){e+=10,D();let I=e,M=0;while(e<w){if(qe())continue;let T=f.charCodeAt(e);if(T===Se)M++;else if(T===Ie&&!Xe())M--;else if(M===0&&T===L)break;e++}let k=ve(I,e);if(k)S=k.split(",").map((T)=>T.trim())}D();let A=zt(l),v=`${o?c?"export default ":"export declare ":"declare "}${r?"abstract ":""}class ${l}${u}${p?` extends ${p}`:""}${S&&S.length>0?` implements ${S.join(", ")}`:""} ${A}`,O=Ze(s);return{kind:"class",name:l,text:v,isExported:o,isDefault:c,extends:p||void 0,implements:S,generics:u||void 0,modifiers:r?["abstract"]:void 0,leadingComments:O,start:s,end:e}}let Nt;function zt(s){if(e>=w||f.charCodeAt(e)!==L)return"{}";e++;let o={name:s,fields:new Map,pending:[],isStatic:!1};ae.push(o);let r=[],c=new Set;while(e<w){if(D(),e>=w)break;if(f.charCodeAt(e)===ee){e++;break}if(f.charCodeAt(e)===oe){e++;continue}if(Nt=Ze(e),_("static")&&Tt("static")===L){e+=6,D(),Be(L,ee);continue}let l=!1,u=!1,p=!1,S=!1,A=!1,C=!1,v=!1,O=!1,I=!0;while(I){D();let q=e,P=Re();if(e=q,P){let de=Tt(P);if(de===le||de===Se||de===It||de===33||de===et||de===Oe||de===oe||de===ee)break}if(_("private")){l=!0,e+=7;continue}if(_("protected")){u=!0,e+=9;continue}if(_("public")){e+=6;continue}if(_("static")){p=!0,e+=6;continue}if(_("abstract")){S=!0,e+=8;continue}if(_("readonly")){A=!0,e+=8;continue}if(_("override")){C=!0,e+=8;continue}if(_("accessor")){v=!0,e+=8;continue}if(_("async")){O=!0,e+=5;continue}if(_("declare")){e+=7;continue}break}if(D(),e>=w||f.charCodeAt(e)===ee)break;let M=e;if(o.isStatic=p,(_("get")||_("set"))&&qt(Tt(f.slice(e,e+3))))e+=3,D();if(f.charCodeAt(e)===ke)e++,D();let k=_t();e=M;let T=k.startsWith("#");if(T)l=!0;if(l&&k&&k!=="constructor"){let q=T?p?" static #private_static;":" #private;":` private ${p?"static ":""}${k};`,de=k[0]==="'"||k[0]==='"'?d(k)??k:k,se=T?`${p?"static":"instance"}#`:`${p?"static:":"instance:"}${de}`;if(!c.has(se))c.add(se),r.push(q)}let j=l?[]:r,Z=" ";if(u)Z+="protected ";if(p)Z+="static ";if(S)Z+="abstract ";if(A)Z+="readonly ";if(_("constructor")){e+=11,D();let q=ot();if(D(),Mn(q,r),e<w&&f.charCodeAt(e)===L)Be(L,ee);else if(e<w&&f.charCodeAt(e)===oe)e++;let P=pt(q);r.push(l?" private constructor();":` ${u?"protected ":""}constructor${P};`)}else if(_("get"))if(e+=3,D(),e<w&&qt(f.charCodeAt(e))){let q=_t();if(q.startsWith("#")){if(D(),e<w&&f.charCodeAt(e)===le)ot();if(D(),kt(),D(),e<w&&f.charCodeAt(e)===L)Be(L,ee);else if(e<w&&f.charCodeAt(e)===oe)e++;continue}D(),ot(),D();let P=kt(),de;if(D(),e<w&&f.charCodeAt(e)===L){let Pe=e+1;if(Be(L,ee),!P&&!be)de=f.slice(Pe,e-1),P=B(de,!1,"()",(ut)=>He(ut,p))}else if(e<w&&f.charCodeAt(e)===oe)e++;let se=j.length;if(j.push(`${Z}get ${q}(): ${de?W(P):P||"unknown"};`),de)o.pending.push(()=>{let Pe=B(de,!1,"()",(ut)=>He(ut,p));j[se]=`${Z}get ${q}(): ${W(Pe)};`})}else an("get",Z,p,A,O,j);else if(_("set"))if(e+=3,D(),e<w&&qt(f.charCodeAt(e))){let q=_t();if(q.startsWith("#")){if(D(),e<w&&f.charCodeAt(e)===le)ot();if(D(),e<w&&f.charCodeAt(e)===L)Be(L,ee);else if(e<w&&f.charCodeAt(e)===oe)e++;continue}D();let P=ot();if(D(),e<w&&f.charCodeAt(e)===L)Be(L,ee);else if(e<w&&f.charCodeAt(e)===oe)e++;let de=pt(P);j.push(`${Z}set ${q}${de};`)}else an("set",Z,p,A,O,j);else{let q=f.charCodeAt(e)===ke;if(q)e++,D();let P=_t();if(!P){cn();continue}ln(P,Z,p,A,q,S,O,j)}}for(let l of o.pending)l();return ae.pop(),`{
|
|
32
|
+
${r.join(`
|
|
33
|
+
`)}
|
|
34
|
+
}`}function qt(s){return a(s)||s===De||s===pn||s===Ae||s===$e}function _t(){if(e>=w)return"";let s=f.charCodeAt(e);if(s===De){let o=e;return Be(De,Me),f.slice(o,e)}if(s===pn)return e++,`#${Re()}`;if(s===Ae||s===$e){let o=e;return it(s),f.slice(o,e)}return Re()}function Tt(s){let o=e;e+=s.length,D();let r=e<w?f.charCodeAt(e):0;return e=o,r}function cn(){let s=0;while(e<w){if(qe())continue;let o=f.charCodeAt(e);if(o===L||o===le)s++;else if(o===ee||o===Ce){if(s===0)return;s--}else if(o===oe&&s===0){e++;return}if(s===0&&bt())return;e++}}function an(s,o,r,c,l,u){ln(s,o,r,c,!1,!1,l,u)}function ln(s,o,r,c,l,u,p,S){let A=Nt;if(Nt=void 0,D(),e>=w)return;let C=f.charCodeAt(e),v=!1;if(C===It)v=!0,e++,D();if(e<w&&f.charCodeAt(e)===33)e++,D();let O=e<w?f.charCodeAt(e):0;if(O===le||O===Se){let I=O===Se?rt():"";D();let M=ot();D();let k=kt(),T,j=k.length>0;if(!k)if(p&&l)k="AsyncGenerator<unknown, void, unknown>";else if(l)k="Generator<unknown, void, unknown>";else if(p)k="Promise<void>";else k="void";if(D(),e<w&&f.charCodeAt(e)===L){let de=e+1;if(Be(L,ee),!j&&!l)T=f.slice(de,e-1),k=B(T,p,M,(se)=>He(se,r))}else if(e<w&&f.charCodeAt(e)===oe)e++;let Z=pt(M),q=v?"?":"",P=S.length;if(S.push(`${o}${s}${q}${I}${Z}: ${T?W(k):k};`),T)ae.at(-1)?.pending.push(()=>{let de=B(T,p,M,(se)=>He(se,r));S[P]=`${o}${s}${q}${I}${Z}: ${W(de)};`})}else if(O===et||O===Oe||O===oe||O===ee||O===ye||O===Ee){let I="";if(O===et){e++,D();let Z=e,q=0;while(e<w){if(qe())continue;let P=f.charCodeAt(e);if(P===le||P===L||P===De||P===Se)q++;else if(P===Ce||P===ee||P===Me||P===Ie&&!Xe()){if(q===0)break;q--}else if(q===0&&(P===oe||P===nt))break;else if(q===0&&P===Oe&&!Rt())break;if(q===0&&bt())break;e++}I=ve(Z,e)}let M="";if(e<w&&f.charCodeAt(e)===Oe)if(be&&I){e++;let Z=0;while(e<w){if(qe())continue;let q=f.charCodeAt(e);if(q===le||q===L||q===De)Z++;else if(q===Ce||q===ee||q===Me){if(Z===0&&q===ee)break;Z--}else if(Z===0&&q===oe)break;if(Z===0&&bt())break;e++}}else{e++,D();let Z=e,q=0;while(e<w){if(qe())continue;let P=f.charCodeAt(e);if(P===le||P===L||P===De)q++;else if(P===Ce||P===ee||P===Me){if(q===0&&P===ee)break;q--}else if(q===0&&P===oe)break;if(q===0&&bt())break;e++}M=ve(Z,e)}if(e<w&&f.charCodeAt(e)===oe)e++;let k=I.length>0;if(!I)if(M){let Z=St(M);if(Z)I=Z;else if(M.startsWith("new "))I=ge(M);else I=M.endsWith("as const")||r&&c?Pt(M):wt(M)}else I="unknown";let T=v?"?":"";ae.at(-1)?.fields.set(`${r?"static:":""}${s}`,v?`(${I}) | undefined`:I);let j=J&&!k&&M?Kt(A,M,I):"";S.push(`${j}${o}${s}${T}: ${I};`)}else cn()}function Rn(s){let o=0;for(let r=0;r<s.length;r++){let c=s.charCodeAt(r);if(c===le||c===L||c===De||c===Se)o++;else if(c===Ce||c===ee||c===Me||c===Ie&&s.charCodeAt(r-1)!==Oe)o--;else if(c===Oe&&o===0&&s.charCodeAt(r+1)!==Ie&&s.charCodeAt(r+1)!==Oe)return!0}return!1}function Mn(s,o){let r=s.slice(1,-1).trim();if(!r)return;let c=[],l=0,u=0,p=!1,S=0,A=[];for(let C=0;C<=r.length;C++){if(C===r.length){A.push(r.slice(l)),c.push(vt(r.slice(l).trim()));break}let v=r.charCodeAt(C);if(p){if(v===Ye){C++;continue}if(v===S)p=!1;continue}if(v===X&&C+1<r.length){let O=r.charCodeAt(C+1);if(O===ke){C+=2;while(C+1<r.length&&!(r.charCodeAt(C)===ke&&r.charCodeAt(C+1)===X))C++;C++;continue}if(O===X){while(C<r.length&&r.charCodeAt(C)!==10)C++;continue}}if(v===Ae||v===$e||v===We){p=!0,S=v;continue}if(v===le||v===L||v===De||v===Se)u++;else if(v===Ce||v===ee||v===Me||v===Ie&&!(C>0&&r.charCodeAt(C-1)===Oe))u--;else if(v===nt&&u===0)A.push(r.slice(l,C)),c.push(vt(r.slice(l,C).trim())),l=C+1}for(let[C,v]of c.entries()){let O=v.startsWith("public ")||v.startsWith("public\t"),I=v.startsWith("protected ")||v.startsWith("protected\t"),M=v.startsWith("private ")||v.startsWith("private\t"),k=v.includes("readonly ");if(!O&&!I&&!M&&!k)continue;let T=v,j=[];if(M){let se=7;while(se<T.length&&Ne(T.charCodeAt(se)))se++;T=T.slice(se),j.push("private")}if(O){let se=6;while(se<T.length&&Ne(T.charCodeAt(se)))se++;T=T.slice(se),j.push("public")}if(I){let se=9;while(se<T.length&&Ne(T.charCodeAt(se)))se++;T=T.slice(se),j.push("protected")}if(k){let se=T.indexOf("readonly ");if(se!==-1){let Pe=se+8;while(Pe<T.length&&Ne(T.charCodeAt(Pe)))Pe++;T=T.slice(0,se)+T.slice(Pe)}j.push("readonly")}let Z=j.length>0?`${j.join(" ")} `:"",q=rn(T),P=T.search(/[?:=]/);if(P!==-1&&T.charCodeAt(P)!==63&&Rn(T))q=q.replace(/^([\w$]+)\?:/,"$1:");let de="";if(J&&!M&&P!==-1&&T.charCodeAt(P)===Oe){let se=T.slice(P+1);de=Kt(rr(A[C]),se,wt(se))}o.push(M?` private ${q.split(/[?:]/,1)[0]};`:`${de} ${Z}${q};`)}}function Ft(s=" ",o="",r=!1){if(e>=w||f.charCodeAt(e)!==L)return"{}";e++;let c=re.at(-1)?.path,l={path:c?`${c}.${o}`:o,bindings:new Map,exports:new Set,ambient:r||re.at(-1)?.ambient===!0};ie.push(l),re.push(l);let u=[];while(e<w){if(D(),e>=w)break;if(f.charCodeAt(e)===ee){e++;break}if(f.charCodeAt(e)===oe){e++;continue}let p=!1;if(_("export"))p=!0,e+=6,D();let S=!1;if(_("declare"))S=!0,e+=7,D();let A=p?"export ":"";if(_("function")||_("async")&&Pn("async","function")){let C=!1;if(_("async"))C=!0,e+=5,D();if(e+=8,D(),e<w&&f.charCodeAt(e)===ke)e++,D();let O=Re();D();let I=rt();D();let M=ot();D();let k=kt();if(!k)k=C?"Promise<void>":"void";if(D(),e<w&&f.charCodeAt(e)===L)Be(L,ee);else if(e<w&&f.charCodeAt(e)===oe)e++;let T=pt(M);u.push(`${s}${A}function ${O}${I}${T}: ${k};`)}else if(_("const")||_("let")||_("var")){let C=_("const")?"const":_("let")?"let":"var";e+=C.length,D();let v=Re();if(l.bindings.set(v,"value"),p||l.ambient)l.exports.add(v);if(!v){Le(!0);continue}D();let O="";if(e<w&&f.charCodeAt(e)===et){e++,D();let M=e,k=0;while(e<w){if(qe())continue;let T=f.charCodeAt(e);if(T===le||T===L||T===De||T===Se)k++;else if(T===ee&&k===0)break;else if(T===Ce||T===ee||T===Me||T===Ie&&!Xe())k--;else if(k===0&&(T===oe||T===nt))break;else if(k===0&&T===Oe&&!Rt())break;if(k===0&&ht())break;e++}O=ve(M,e)}let I="";if(e<w&&f.charCodeAt(e)===Oe){e++,D();let M=e,k=0;while(e<w){if(qe())continue;let T=f.charCodeAt(e);if(T===le||T===L||T===De||T===Se)k++;else if(T===ee&&k===0)break;else if(T===Ce||T===ee||T===Me||T===Ie&&!Xe())k--;else if(k===0&&(T===oe||T===nt))break;if(k===0&&ht())break;e++}I=ve(M,e)}if(e<w&&f.charCodeAt(e)===oe)e++;if(!O&&I){let M=St(I);if(M)O=M;else if(C==="const")O=Pt(I);else O=wt(I)}if(!O)O="unknown";u.push(`${s}${A}${C} ${v}: ${O};`)}else if(_("interface")){e+=9,D();let C=Re();D();let v=rt();D();let O="";if(_("extends")){e+=7,D();let M=e,k=0;while(e<w){if(qe())continue;let T=f.charCodeAt(e);if(T===Se)k++;else if(T===Ie&&!Xe())k--;else if(T===L&&k===0)break;e++}O=ve(M,e)}let I=sn(Mt());u.push(`${s}${A}interface ${C}${v}${O?` extends ${O}`:""} ${I}`)}else if(_("type")){e+=4,D();let C=Re();D();let v=rt();if(D(),e<w&&f.charCodeAt(e)===Oe){e++,D();let O=e,I=0;while(e<w){if(qe())continue;let k=f.charCodeAt(e);if(k===le||k===L||k===De||k===Se)I++;else if(k===ee&&I===0)break;else if(k===Ce||k===ee||k===Me||k===Ie&&!Xe())I--;else if(I===0&&k===oe)break;if(I===0&&ht())break;e++}let M=ve(O,e);if(e<w&&f.charCodeAt(e)===oe)e++;u.push(`${s}${A}type ${C}${v} = ${M}`)}}else if(_("class")){e+=5,D();let C=Re();D();let v=rt();D();let O=e,I=0;while(e<w){if(qe())continue;let j=f.charCodeAt(e);if(j===Se)I++;else if(j===Ie&&!Xe())I--;else if(j===L&&I===0)break;e++}let M=ve(O,e),k=M?` ${M}`:"";if(l.bindings.set(C,"class"),p||l.ambient)l.exports.add(C);let T=zt(C);u.push(`${s}${A}class ${C}${v}${k} ${T}`)}else if(_("enum")){e+=4,D();let C=Re();D();let v=Mt();u.push(`${s}${A}enum ${C} ${v}`)}else if(_("namespace")||_("module")){let C=_("namespace")?"namespace":"module";e+=C.length,D();let v=Re();if(!l.bindings.has(v))l.bindings.set(v,"namespace");if(p||l.ambient)l.exports.add(v);D();let O=Ft(s,v,S);u.push(`${s}${A}${C} ${v} ${O}`)}else if(_("abstract"))if(e+=8,D(),_("class")){e+=5,D();let C=Re();D();let v=rt();D();let O=e,I=0;while(e<w){if(qe())continue;let j=f.charCodeAt(e);if(j===Se)I++;else if(j===Ie&&!Xe())I--;else if(j===L&&I===0)break;e++}let M=ve(O,e),k=M?` ${M}`:"";if(l.bindings.set(C,"class"),p||l.ambient)l.exports.add(C);let T=zt(C);u.push(`${s}${A}abstract class ${C}${v}${k} ${T}`)}else Le(!0);else if(p&&_("default")){e+=7,D();let C=e;Le(!0);let v=ve(C,e);if(v.charCodeAt(v.length-1)===oe)v=v.slice(0,-1);if(v)u.push(`${s}export default ${v};`)}else if(!p&&(f.charCodeAt(e)===Ae||f.charCodeAt(e)===$e||f.charCodeAt(e)===We))Le(!0);else Le(!0)}if(re.pop(),u.length===0)return"{}";return`{
|
|
35
|
+
${u.join(`
|
|
36
|
+
`)}
|
|
37
|
+
}`}function Pn(s,o){let r=e+s.length;while(r<w&&Ne(f.charCodeAt(r)))r++;for(let c=0;c<o.length;c++)if(r+c>=w||f.charCodeAt(r+c)!==o.charCodeAt(c))return!1;return r+o.length>=w||!i(f.charCodeAt(r+o.length))}function gt(s,o,r){e+=r.length,D();let c="",l=f.charCodeAt(e);if(l===Ae||l===$e){let I=e;it(l),c=f.slice(I,e)}else{c=Re();while(e<w&&f.charCodeAt(e)===Ct)e++,c+=`.${Re()}`}D();let u=t(f.slice(s,e)),p=u.findIndex((I)=>I.kind==="word"&&["namespace","module"].includes(f.slice(s+I.start,s+I.end))),S=u.slice(0,p).some((I)=>I.kind==="word"&&f.slice(s+I.start,s+I.end)==="declare"),A=e<w&&f.charCodeAt(e)===L?Ft(" ",c,S):"{}",C=`${o?"export ":""}declare ${r} ${c} ${A}`,v=Ze(s),O=c.startsWith("'")||c.startsWith('"');return{kind:"module",name:c,text:C,isExported:o,moduleForm:O?"quoted":r==="namespace"?"namespace":"identifier",source:O?c.slice(1,-1):void 0,leadingComments:v,start:s,end:e}}function fn(s,o){Le();let r=ve(o,e);if(r.charCodeAt(r.length-1)===oe)r=r.slice(0,-1).trimEnd();if(!r)return;let c=a(r.charCodeAt(0));for(let v=1;c&&v<r.length;v++)c=i(r.charCodeAt(v));let l=Ze(s);if(c){N.push({kind:"export",name:"default",text:`export default ${r};`,isExported:!0,isTypeOnly:!1,leadingComments:l,start:s,end:e});return}let u="__dtsx_default_export__",p=1;while(f.includes(u))u=`__dtsx_default_export_${p++}__`;let A=St(r)||he(r)||n(r,!1),C=A==="unknown"&&qn(r)?`typeof ${r}`:A;N.push({kind:"variable",name:u,text:`declare const ${u}: ${C};`,isExported:!1,typeAnnotation:C,modifiers:["const"],start:s,end:e}),N.push({kind:"export",name:"default",text:`export default ${u};`,isExported:!0,isTypeOnly:!1,leadingComments:l,start:s,end:e})}function dn(){if(f.charCodeAt(e)===L)return Be(L,ee),!0;let s=_("if"),o=_("do"),r=_("try"),c=_("for");if(!s&&!o&&!r&&!c&&!_("while")&&!_("switch")&&!_("with"))return!1;if(Re(),D(),c&&_("await"))e+=5,D();if(!o&&!r&&f.charCodeAt(e)===le)Be(le,Ce);if(Dt(),D(),s&&_("else"))e+=4,Dt();else if(o&&_("while")){if(e+=5,D(),f.charCodeAt(e)===le)Be(le,Ce);if(D(),f.charCodeAt(e)===oe)e++}else if(r){if(_("catch")){if(e+=5,D(),f.charCodeAt(e)===le)Be(le,Ce);Dt(),D()}if(_("finally"))e+=7,Dt()}return!0}function Dt(){if(D(),!dn())Le()}while(e<w){if(D(),e>=w)break;if(dn())continue;let s=e,o=f.charCodeAt(e);if(o===105&&_("import"))N.push(Sn(s));else if(o===101&&_("export")){e+=6,D();let r=f.charCodeAt(e);if(r===100&&_("default")){e+=7,D();let c=e,l=f.charCodeAt(e);if(l===102&&_("function")){let u=ct(s,!0,!1,!0);if(u)N.push(u)}else if(l===97&&_("async")&&Tt("async")!==oe)if(e+=5,D(),_("function")){let u=ct(s,!0,!0,!0);if(u)N.push(u)}else fn(s,c);else if(l===99&&_("class")){let u=at(s,!0,!1,!0);N.push(u)}else if(l===97&&_("abstract")){if(e+=8,D(),_("class")){let u=at(s,!0,!0,!0);N.push(u)}}else fn(s,c)}else if(r===116&&_("type")){let c=e;if(e+=4,D(),e<w&&f.charCodeAt(e)===L){en();let l=ve(s,e),u=Ze(s);N.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:!0,source:yt(l),leadingComments:u,start:s,end:e})}else if(e<w&&f.charCodeAt(e)===ke){tn();let l=ve(s,e);N.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:!0,source:yt(l),start:s,end:e})}else{e=c;let l=Lt(s,!0);N.push(l)}}else if(r===105&&_("interface")){let c=Bt(s,!0);N.push(c)}else if(r===102&&_("function")){let c=ct(s,!0,!1,!1);if(c)N.push(c)}else if(r===97&&_("async"))if(e+=5,D(),_("function")){let c=ct(s,!0,!0,!1);if(c)N.push(c)}else Le();else if(r===99)if(_("class")){let c=at(s,!0,!1);N.push(c)}else if(_("const")){let c=e;if(e+=5,D(),_("enum")){e=c+5,D();let l=mt(s,!0,!0);N.push(l)}else{e=c;let l=dt(s,"const",!0);for(let u=0;u<l.length;u++)N.push(l[u])}}else Le();else if(r===97&&_("abstract")){if(e+=8,D(),_("class")){let c=at(s,!0,!0);N.push(c)}}else if(r===108&&_("let")){let c=dt(s,"let",!0);for(let l=0;l<c.length;l++)N.push(c[l])}else if(r===118&&_("var")){let c=dt(s,"var",!0);for(let l=0;l<c.length;l++)N.push(c[l])}else if(r===101&&_("enum")){let c=mt(s,!0,!1);N.push(c)}else if(r===100&&_("declare"))e+=7,D(),hn(s,!0);else if(r===110&&_("namespace")&&xt(9)){let c=gt(s,!0,"namespace");N.push(c)}else if(r===109&&_("module")&&xt(6)){let c=gt(s,!0,"module");N.push(c)}else if(r===L){en();let c=ve(s,e),l=c.includes("export type"),u=Ze(s);N.push({kind:"export",name:"",text:c,isExported:!0,isTypeOnly:l,source:yt(c),leadingComments:u,start:s,end:e})}else if(r===ke){tn();let c=ve(s,e),l=Ze(s);N.push({kind:"export",name:"",text:c,isExported:!0,isTypeOnly:!1,source:yt(c),leadingComments:l,start:s,end:e})}else{Le();let c=ve(s,e);if(c)N.push({kind:"export",name:"",text:c,isExported:!0,start:s,end:e})}}else if(o===100&&_("declare"))e+=7,D(),hn(s,!1);else if(o===105&&_("interface")){let r=Bt(s,!1);G.set(r.name,r)}else if(o===116&&_("type")){let r=Lt(s,!1);G.set(r.name,r),N.push(r)}else if(o===102&&_("function")){let r=ct(s,!1,!1,!1);if(r)lt(r);else Le()}else if(o===97)if(_("async")){let r=e;if(e+=5,D(),_("function")){let c=ct(s,!1,!0,!1);if(c)lt(c);else e=r,Le()}else e=r,Le()}else if(_("abstract"))if(e+=8,D(),_("class")){let r=at(s,!1,!1);G.set(r.name,r),N.push(r)}else Le();else e++,Le();else if(o===99)if(_("class")){let r=at(s,!1,!1);G.set(r.name,r),N.push(r)}else if(_("const")){let r=e;if(e+=5,D(),_("enum")){e=r+5,D();let c=mt(s,!1,!0);G.set(c.name,c),N.push(c)}else{e=r;let c=dt(s,"const",!1);for(let l=0;l<c.length;l++)G.set(c[l].name,c[l])}}else e++,Le();else if(o===101&&_("enum")){let r=mt(s,!1,!1);G.set(r.name,r),N.push(r)}else if(o===108&&_("let")||o===118&&_("var")){let r=_("let")?"let":"var",c=dt(s,r,!1);for(let l=0;l<c.length;l++)G.set(c[l].name,c[l])}else if(o===109&&_("module")&&xt(6)){let r=gt(s,!1,"module");N.push(r)}else if(o===110&&_("namespace")&&xt(9)){let r=gt(s,!1,"namespace");N.push(r)}else{let r=f.charCodeAt(e);if(r===oe)e++;else if(r===Ae||r===$e){if(it(r),e<w&&f.charCodeAt(e)===oe)e++}else if(r===We){if(At(),e<w&&f.charCodeAt(e)===oe)e++}else if(r===Ln){if(e++,Re(),D(),e<w&&f.charCodeAt(e)===Ct)e++,Re(),D();if(e<w&&f.charCodeAt(e)===le)Be(le,Ce)}else e++,Le()}}if(Te.length){let s=new Set([...N,...G.values()]),o=new Set([...s].filter((u)=>u.kind==="class").map((u)=>u.name)),r=new Map;for(let u of ie)for(let[p,S]of u.bindings){let A=u.path?`${u.path}.${p}`:p;if(u.exports.has(p)&&(S!=="namespace"||!r.has(A)))r.set(A,S)}let c=new Map;for(let u of Te)c.set(u.marker,Ht(u.initializer,(p)=>{if(u.classes.includes(p))return!0;for(let S=u.namespaces.length-1;S>=0;S--){let A=u.namespaces[S],C=A.path?`${A.path}.${p}`:p,v=p.split(".")[0],O=A.bindings.get(v);if(O){if(p===v&&O!=="namespace")return O==="class";return r.get(C)==="class"}let I=A.path?`${A.path}.${v}`:v;if(r.has(I))return r.get(C)==="class"}return r.has(p)?r.get(p)==="class":o.has(p)}));let l=(u)=>{if(!u.includes("__dtsx_constructor_field_"))return u;let p="",S=0;for(let A of t(u)){if(A.kind!=="word")continue;let C=c.get(u.slice(A.start,A.end));if(!C)continue;p+=u.slice(S,A.start)+C,S=A.end}return p+u.slice(S)};for(let u of s){u.text=l(u.text);for(let p of["typeAnnotation","inferredType","returnType"])if(u[p])u[p]=l(u[p])}}if(te.size>0){un(N);for(let s of ce.values())un(s)}if(zn(f,N,G,ce),Hn(N,G),ir(N,G),!be)Jn(f,N,G,fe);if(ue){let s=new Set(N);for(let o of[...G.values(),...[...ce.values()].flat()])if(!s.has(o))N.push(o),s.add(o);return N.sort((o,r)=>(o.start??0)-(r.start??0))}if(G.size>0)Fn(N,G,ce,tt);return N;function un(s){let o=new Map;for(let c of s)if(c.kind==="function")o.set(c.name,(o.get(c.name)||0)+1);let r=new Set;for(let[c,l]of o)if(l>1)r.add(c);if(r.size>0){let c=new Set;for(let l of r)for(let u=s.length-1;u>=0;u--)if(s[u].kind==="function"&&s[u].name===l&&te.has(s[u])){c.add(u);break}if(c.size>0){let l=[...c].sort((u,p)=>p-u);for(let u of l)s.splice(u,1)}}}function hn(s,o){if(_("function")){let r=ct(s,o,!1,!1);if(r)N.push(r)}else if(_("async")){if(e+=5,D(),_("function")){let r=ct(s,o,!0,!1);if(r)N.push(r)}}else if(_("class")){let r=at(s,o,!1);N.push(r)}else if(_("abstract")){if(e+=8,D(),_("class")){let r=at(s,o,!0);N.push(r)}}else if(_("interface")){let r=Bt(s,o);N.push(r)}else if(_("type")){let r=Lt(s,o);N.push(r)}else if(_("enum")){let r=mt(s,o,!1);N.push(r)}else if(_("const")){let r=e;if(e+=5,D(),_("enum")){e=r+5,D();let c=mt(s,o,!0);N.push(c)}else{e=r;let c=dt(s,"const",o);for(let l=0;l<c.length;l++)if(o||!tt)N.push(c[l]);else G.set(c[l].name,c[l])}}else if(_("let")||_("var")){let r=_("let")?"let":"var",c=dt(s,r,o);for(let l=0;l<c.length;l++)if(o||!tt)N.push(c[l]);else G.set(c[l].name,c[l])}else if(_("module")){let r=gt(s,o,"module");N.push(r)}else if(_("namespace")){let r=gt(s,o,"namespace");N.push(r)}else if(_("global")){e+=6,D();let c=`declare global ${e<w&&f.charCodeAt(e)===L?Ft(" ","",!0):"{}"}`,l=Ze(s);N.push({kind:"module",name:"global",text:c,isExported:!1,moduleForm:"global",leadingComments:l,start:s,end:e})}else Le()}}class gn{names;lengths=new Uint8Array(65);firstUnits=new Uint8Array(65536);size;constructor(E){this.names=E;for(let ne of E.keys()){if(!ne)continue;this.lengths[Math.min(ne.length,64)]=1,this.firstUnits[ne.charCodeAt(0)]=1}this.size=E.size}scan(E,ne){if(this.size===0)return!1;let Q=!1,Y=0,ue=E.length;while(Y<ue){let fe=E.charCodeAt(Y);if(fe>=65&&fe<=90||fe>=97&&fe<=122||fe===95||fe===36||fe>127){let f=Y;Y++;while(Y<ue){let J=E.charCodeAt(Y);if(J>=65&&J<=90||J>=97&&J<=122||J>=48&&J<=57||J===95||J===36||J>127)Y++;else break}if(this.firstUnits[fe]===1&&this.lengths[Math.min(Y-f,64)]===1){let J=E.substring(f,Y),be=this.names.get(J);if(be!==void 0){if(ne.add(J),be.kind==="function"||be.kind==="variable")Q=!0}}}else Y++}return Q}}function mn(E,ne){let Q=0;while(Q<E.length){let Y=E.charCodeAt(Q);if(Y===Ae||Y===$e||Y===We){let Ke=Y;Q++;while(Q<E.length)if(E.charCodeAt(Q)===Ye)Q+=2;else if(E.charCodeAt(Q++)===Ke)break;continue}if(Y===X&&E.charCodeAt(Q+1)===X){Q+=2;while(Q<E.length&&E.charCodeAt(Q)!==ye&&E.charCodeAt(Q)!==Ee)Q++;continue}if(Y===X&&E.charCodeAt(Q+1)===ke){let Ke=E.indexOf("*/",Q+2);Q=Ke===-1?E.length:Ke+2;continue}if(!a(Y)){Q++;continue}let ue=Q++;while(Q<E.length&&i(E.charCodeAt(Q)))Q++;let fe=ue-1,f=Q;while(fe>=0&&Ne(E.charCodeAt(fe)))fe--;while(f<E.length&&Ne(E.charCodeAt(f)))f++;let J=fe>=0?E.charCodeAt(fe):0,be=f<E.length?E.charCodeAt(f):0,w=ue>=3&&E.slice(ue-3,ue)==="...";if(be===et||J===Ct&&!w)continue;if(be===le&&(J===L||J===nt))continue;ne.add(E.slice(ue,Q))}}function Fn(E,ne,Q,Y){let ue=new Map;if(Y){let G=0;for(let ce of E)if(ce.kind==="class"&&!ce.isExported){if(ue.set(ce.name,ce),!ne.has(ce.name))ne.set(ce.name,ce)}else E[G++]=ce;E.length=G}let fe=new Set(E),f=new Set,J=new Set;for(let G of E)J.add(G.name);let be=new gn(ne),w=new Set,Ke=new Set,tt=(G)=>{if(be.scan(G.text,w))nr(G,Ke)},N=new Set;for(let G=0;G<E.length;G++){let ce=E[G];if(ce.kind!=="import"){if(tt(ce),typeof ce.value==="string")mn(ce.value,N)}}for(;;){let G=[];for(let[e,pe]of ne){if(f.has(e))continue;if((pe.kind==="function"||pe.kind==="variable"?Ke:w).has(e)||pe.kind!=="function"&&N.has(e)){let ae=ue.get(e);if(ae){for(let ie of[ae,pe])if(!fe.has(ie))G.push(ie),fe.add(ie);J.add(e)}else if(!J.has(e)){let ie=pe.kind==="function"?Q.get(e):void 0;if(ie)for(let re of ie)G.push(re);else G.push(pe);J.add(e)}f.add(e)}}if(G.length===0)break;G.sort((e,pe)=>(e.start??1/0)-(pe.start??1/0));let ce=[],te=0;for(let e=0;e<E.length;e++){let pe=E[e].start??1/0;while(te<G.length&&(G[te].start??1/0)<=pe)ce.push(G[te++]);ce.push(E[e])}while(te<G.length)ce.push(G[te++]);E.length=0;for(let e=0;e<ce.length;e++)E.push(ce[e]);for(let e of G)if(e.kind!=="import"){if(tt(e),typeof e.value==="string")mn(e.value,N)}}}
|
|
38
|
+
export{Oi,Ba,R,F,jt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
2
|
+
import{s}from"./chunk-ex02f2vm.js";import{mkdtemp as y,readFile as v,realpath as l,rm as x}from"fs/promises";import{tmpdir as b}from"os";import{join as p,resolve as i}from"path";function mt(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 d=u.get(c(t.dir??"dist",t.format??"es"));if(!d)throw Error("dtsx: expected a resolved tsdown build before generating declarations");let f=await l(i(r.cwd??d.cwd??process.cwd())),m=await l(i(f,r.root??d.root)),a=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 l(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 s({...r,cwd:f,root:m,entrypoints:[w],outdir:a,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(a,o),"utf8")})}}finally{await x(a,{recursive:!0,force:!0})}}}}var Ia=mt;
|
|
3
3
|
export{mt,Ia};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-
|
|
2
|
+
import{r}from"./chunk-wrvgt39b.js";import{l}from"./chunk-w5m9qv5k.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 $r(e,o=process.cwd()){let i=new Map;for(let t of e){let n=S(o,t),s=await F(n,o);i.set(n,{path:n,dependencies:s,dependents:new Set,state:"pending"})}for(let[t,n]of i)for(let s of n.dependencies){let c=i.get(s);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 s of r(t,e,!1)){let c=s.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 s=`${t}.ts`;return s.includes("node_modules")?null:s}function G(e){let o=[];for(let[i,t]of e){if(t.state!=="pending")continue;let n=!0;for(let s of t.dependencies){let c=e.get(s);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=r(i,e,t,o.isolatedDeclarations??!1);return l(n,{filePath:e,sourceCode:i,declarations:n},t,o.importOrder)}async function ms(e,o={}){let i=performance.now(),{maxConcurrency:t=4,rootDir:n=process.cwd(),config:s={},onProgress:c,onError:a}=o,g=await $r(e,n),w=new Map,P=new Map,h=[],x=0,u=0,m=0,b=g.size;while(m<b){let y=G(g);if(y.length===0){let f=[...g.values()].filter((d)=>d.state==="pending");if(f.length>0)for(let d of f)d.state="failed",d.error=Error("Circular dependency detected or dependency failed"),P.set(d.path,d.error),m++;break}let C=y.slice(0,t-u);for(let f of C){let d=g.get(f);d.state="processing",u++}x=Math.max(x,u);let E=C.map(async(f)=>{let d=g.get(f),M=performance.now();try{let p=await I(f,s);d.state="completed",d.result=p,d.duration=performance.now()-M,w.set(f,p),h.push(f)}catch(p){if(d.state="failed",d.error=p instanceof Error?p:Error(String(p)),d.duration=performance.now()-M,P.set(f,d.error),a&&!a(f,d.error))throw Error("Processing aborted by error handler")}finally{u--,m++,c?.(m,b,f)}});await Promise.all(E)}return{success:w,failed:P,totalTimeMs:performance.now()-i,maxConcurrent:x,processingOrder:h}}function gs(e){let o=[],i=new Set,t=new Set;function n(s){if(i.has(s))return;if(t.has(s))return;t.add(s);let c=e.get(s);if(c){for(let a of c.dependencies)if(e.has(a))n(a)}t.delete(s),i.add(s),o.push(s)}for(let s of e.keys())n(s);return o}function Er(e){let o=[];for(let[i,t]of e){let n=!1;for(let s of t.dependencies)if(e.has(s)){n=!0;break}if(!n)o.push(i)}return o}function kr(e){let o=[],i=new Set;while(i.size<e.size){let t=[];for(let[n,s]of e){if(i.has(n))continue;let c=!0;for(let a of s.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 hs(e){let o=kr(e),i=Er(e),t=Math.max(...o.map((s)=>s.length)),n=e.size/o.length;return{totalFiles:e.size,independentFiles:i.length,maxParallelism:t,levels:o.length,estimatedSpeedup:n}}
|
|
3
3
|
export{$r,ms,gs,Er,kr,hs};
|