@stacksjs/dtsx 0.9.18 → 0.9.20
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 +5 -5
- package/dist/{chunk-zfrp784r.js → chunk-0cfb4831.js} +1 -1
- package/dist/{chunk-w71syh0b.js → chunk-0d5r9n78.js} +1 -1
- package/dist/chunk-1b1j60g0.js +2 -0
- package/dist/{chunk-fxh731yj.js → chunk-1hy2eypj.js} +1 -1
- package/dist/chunk-4mtbtmee.js +25 -0
- package/dist/{chunk-bb28rgpz.js → chunk-5zt12z1t.js} +1 -1
- package/dist/chunk-7hy98p24.js +62 -0
- package/dist/{chunk-w08v45h7.js → chunk-9e542zj7.js} +1 -1
- package/dist/{chunk-m5508xqy.js → chunk-a0gah6hn.js} +1 -1
- package/dist/{chunk-gc9n9za8.js → chunk-bymtns9a.js} +1 -1
- package/dist/chunk-c60qpa3j.js +2 -0
- package/dist/chunk-cdv5r51q.js +156 -0
- package/dist/chunk-dnbr0hke.js +2 -0
- package/dist/{chunk-fmhrt2ca.js → chunk-dymmh9x0.js} +1 -1
- package/dist/chunk-eqfegkc1.js +2 -0
- package/dist/{chunk-4hpfq116.js → chunk-fqym6cgw.js} +1 -1
- package/dist/chunk-ft0nf9jb.js +19 -0
- package/dist/{chunk-zs5mk604.js → chunk-fvgc14nk.js} +1 -1
- package/dist/{chunk-f7fatmz3.js → chunk-h0dndwyc.js} +1 -1
- package/dist/chunk-m94gn6yx.js +2 -0
- package/dist/chunk-nmmv0nrk.js +2 -0
- package/dist/{chunk-acf8x00j.js → chunk-nqwz71ak.js} +1 -1
- package/dist/{chunk-1zqrzfqx.js → chunk-r1yqh3qg.js} +1 -1
- package/dist/{chunk-72tqwhpx.js → chunk-rd7n0yj1.js} +1 -1
- package/dist/{chunk-7pwy4m0c.js → chunk-vx4a5crm.js} +1 -1
- package/dist/{chunk-zn70hw8f.js → chunk-wtqapt0n.js} +1 -1
- package/dist/chunk-xw9wfq8f.js +17 -0
- package/dist/{chunk-wcdd51hr.js → chunk-y2pe3jq3.js} +1 -1
- package/dist/{chunk-5qqybwef.js → chunk-y4g1csn2.js} +1 -1
- package/dist/extractor/builders.d.ts +1 -1
- package/dist/extractor/helpers.d.ts +9 -0
- package/dist/src/index.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/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-1s045wj0.js +0 -2
- package/dist/chunk-4jw8qvts.js +0 -16
- package/dist/chunk-a3txc27m.js +0 -33
- package/dist/chunk-aafhn8pf.js +0 -2
- package/dist/chunk-asnnmvct.js +0 -19
- package/dist/chunk-e13937tc.js +0 -2
- package/dist/chunk-j0rnj1z0.js +0 -25
- package/dist/chunk-rv908n0q.js +0 -2
- package/dist/chunk-s8yqbjn4.js +0 -2
- package/dist/chunk-trm0gptj.js +0 -134
- package/dist/chunk-y515fe4f.js +0 -2
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-mcdb3q06.js";import{existsSync as EZ}from"fs";import HJ from"fs/promises";import CJ from"os";import KJ from"path";import p from"process";import{EventEmitter as IZ}from"events";import m from"process";import kJ from"process";import MJ from"process";import qJ from"process";import vJ from"process";import o from"process";import SJ from"tty";import zZ,{stdin as j0,stdout as G0}from"process";import*as c from"readline";import{ReadStream as yJ,WriteStream as H0}from"tty";import gJ,{stdin as P0,stdout as N0}from"process";import w0 from"readline";import A0 from"process";import S0 from"process";import{WriteStream as y0}from"tty";import f0 from"process";import xJ from"process";import d0 from"process";import{stripVTControlCharacters as WJ}from"util";import{existsSync as c0,lstatSync as dJ,readdirSync as p0}from"fs";import{dirname as uJ,join as i0}from"path";import n0 from"process";import b from"process";import e from"process";import{stripVTControlCharacters as DJ}from"util";import r0 from"process";import{Buffer as iJ}from"buffer";import y from"fs/promises";import a0 from"os";import XJ from"path";import w from"process";import{Readable as s0,Writable as t0}from"stream";class nJ{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let J=CJ.homedir(),Z=KJ.join(J,".config","clapp");this.configPath=KJ.join(Z,"telemetry.json")}async isEnabled(){if(p.env.DO_NOT_TRACK==="1"||p.env.DO_NOT_TRACK==="true")return!1;if(p.env.NO_TELEMETRY==="1"||p.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let J=await this.loadConfig();if(J.enabled=!0,!J.userId)J.userId=this.generateUserId();await this.saveConfig(J)}async disable(){let J=await this.loadConfig();J.enabled=!1,await this.saveConfig(J)}async track(J,Z){if(!await this.isEnabled())return;let Q={event:J,...Z,timestamp:Date.now(),platform:CJ.platform(),nodeVersion:p.version};if(this.events.push(Q),this.events.length>=10)await this.send()}async trackCommand(J,Z){await this.track("command",{command:J,duration:Z})}async trackError(J,Z){await this.track("error",{error:J,command:Z})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let Z=await this.loadConfig();return Z.lastSent=Date.now(),await this.saveConfig(Z),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let Z=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(Z),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(J){return new Promise((Z)=>setTimeout(Z,J))}async status(){let J=await this.loadConfig();return{enabled:J.enabled,doNotTrack:p.env.DO_NOT_TRACK==="1"||p.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:J.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(EZ(this.configPath)){let J=await HJ.readFile(this.configPath,"utf-8");return this.config=JSON.parse(J),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(J){this.config=J;try{let Z=KJ.dirname(this.configPath);await HJ.mkdir(Z,{recursive:!0}),await HJ.writeFile(this.configPath,JSON.stringify(J,null,2),"utf-8")}catch{}}generateUserId(){let J=Math.random().toString(36).substring(2,15),Z=Date.now().toString(36);return`${J}-${Z}`}}var Y$=new nJ;function AZ(J,Z={}){let $={_:[]},Q=Z.alias||{},Y=new Set(Z.boolean||[]),q={};for(let F of Object.keys(Q))for(let X of Q[F])q[X]=F;for(let F of Y)if(Q[F])for(let X of Q[F])Y.add(X);function U(F,X){let j=q[F]||F;if($[j]=X,Q[j])for(let G of Q[j])$[G]=X;if(q[F]&&Q[q[F]])for(let G of Q[q[F]])$[G]=X;$[F]=X}for(let F=0;F<J.length;F++){let X=J[F];if(X==="--"){$._.push(...J.slice(F+1));break}if(X.startsWith("--")){let j=X.indexOf("=");if(j!==-1){let G=X.slice(2,j),V=X.slice(j+1);U(G,V)}else{let G=X.slice(2);if(G.startsWith("no-")){let W=G.slice(3);U(W,!1);continue}let V=q[G]||G;if(Y.has(V)||Y.has(G))U(G,!0);else{let W=J[F+1];if(W!==void 0&&!W.startsWith("-"))U(G,W),F++;else U(G,!0)}}}else if(X.startsWith("-")&&X.length>1){let j=X.slice(1);for(let G=0;G<j.length;G++){let V=j[G],W=q[V]||V;if(G===j.length-1&&!Y.has(W)&&!Y.has(V)){let K=J[F+1];if(K!==void 0&&!K.startsWith("-"))U(V,K),F++;else U(V,!0)}else U(V,!0)}}else $._.push(X)}return $}function LJ(J){return J.replace(/[<[].+/,"").trim()}function RZ(J){let Z=/<([^>]+)>/g,$=/\[([^\]]+)\]/g,Q=[],Y=(F)=>{let X=!1,j=F[1];if(j.startsWith("..."))j=j.slice(3),X=!0;return{required:F[0].startsWith("<"),value:j,variadic:X}},q;while(q=Z.exec(J))Q.push(Y(q));let U;while(U=$.exec(J))Q.push(Y(U));return Q}function xZ(J){let Z={alias:{},boolean:[]};for(let[$,Q]of J.entries()){if(Q.names.length>1)Z.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!J.some((q,U)=>{return U!==$&&q.names.some((F)=>Q.names.includes(F))&&typeof q.required==="boolean"}))Z.boolean.push(Q.names[0])}else Z.boolean.push(Q.names[0])}return Z}function hJ(J){return J.reduce((Z,$)=>Z.length>=$.length?Z:$,"")}function VJ(J,Z){return J.length>=Z?J:`${J}${" ".repeat(Z-J.length)}`}function CZ(J){return J.replace(/([a-z])-([a-z])/g,(Z,$,Q)=>{return $+Q.toUpperCase()})}function kZ(J,Z,$){let Q=0,Y=Z.length,q=J,U;for(;Q<Y;++Q)U=q[Z[Q]],q=q[Z[Q]]=Q===Y-1?$:U!=null?U:!!~Z[Q+1].indexOf(".")||!(+Z[Q+1]>-1)?{}:[]}function hZ(J,Z){for(let $ of Object.keys(Z)){let Q=Z[$];if(Q.shouldTransform){if(J[$]=Array.prototype.concat.call([],J[$]),typeof Q.transformFunction==="function")J[$]=J[$].map(Q.transformFunction)}}}function bZ(J){let Z=/([^\\/]+)$/.exec(J);return Z?Z[1]:""}function lJ(J){return J.split(".").map((Z,$)=>{return $===0?CZ(Z):Z}).join(".")}class YJ extends Error{exitCode=2;isUsageError=!0;constructor(J){super(J);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(J).stack}format(J=!1){if(J&&this.stack)return`${this.message}
|
|
3
|
+
|
|
4
|
+
Stack trace:
|
|
5
|
+
${this.stack}`;return this.message}}function vZ(){let{env:J}=kJ,{TERM:Z,TERM_PROGRAM:$}=J;if(kJ.platform!=="win32")return Z!=="linux";return Boolean(J.WT_SESSION)||Boolean(J.TERMINUS_SUBLIME)||J.ConEmuTask==="{cmd::Cmder}"||$==="Terminus-Sublime"||$==="vscode"||Z==="xterm-256color"||Z==="alacritty"||Z==="rxvt-unicode"||Z==="rxvt-unicode-256color"||J.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var UJ="\x1B",T=`${UJ}[`,F$="\x07",C={to(J,Z){if(!Z)return`${T}${J+1}G`;return`${T}${Z+1};${J+1}H`},move(J,Z){let $="";if(J<0)$+=`${T}${-J}D`;else if(J>0)$+=`${T}${J}C`;if(Z<0)$+=`${T}${-Z}A`;else if(Z>0)$+=`${T}${Z}B`;return $},up:(J=1)=>`${T}${J}A`,down:(J=1)=>`${T}${J}B`,forward:(J=1)=>`${T}${J}C`,backward:(J=1)=>`${T}${J}D`,nextLine:(J=1)=>`${T}E`.repeat(J),prevLine:(J=1)=>`${T}F`.repeat(J),left:`${T}G`,hide:`${T}?25l`,show:`${T}?25h`,save:`${UJ}7`,restore:`${UJ}8`},j$={up:(J=1)=>`${T}S`.repeat(J),down:(J=1)=>`${T}T`.repeat(J)},JJ={screen:`${T}2J`,up:(J=1)=>`${T}1J`.repeat(J),down:(J=1)=>`${T}J`.repeat(J),line:`${T}2K`,lineEnd:`${T}K`,lineStart:`${T}1K`,lines(J){let Z="";for(let $=0;$<J;$++)Z+=this.line+($<J-1?C.up():"");if(J)Z+=C.left;return Z}},G$={screen:`${UJ}c`};function SZ(J,Z){let $=[];for(let Q=0;Q<=Z.length;Q++)$[Q]=[Q];for(let Q=0;Q<=J.length;Q++)$[0][Q]=Q;for(let Q=1;Q<=Z.length;Q++)for(let Y=1;Y<=J.length;Y++)if(Z.charAt(Q-1)===J.charAt(Y-1))$[Q][Y]=$[Q-1][Y-1];else $[Q][Y]=Math.min($[Q-1][Y-1]+1,$[Q][Y-1]+1,$[Q-1][Y]+1);return $[Z.length][J.length]}function rJ(J,Z,$=2,Q=3){return Z.map((Y)=>({cmd:Y,distance:SZ(J,Y)})).filter(({distance:Y})=>Y<=$).sort((Y,q)=>Y.distance-q.distance).slice(0,Q).map(({cmd:Y})=>Y)}class aJ{rawName;description;name;names;isBoolean;required;config;negated;constructor(J,Z,$){if(this.rawName=J,this.description=Z,this.config=Object.assign({},$),J=J.replace(/\.\*/g,""),this.negated=!1,this.names=LJ(J).split(",").map((Q)=>{let Y=Q.trim().replace(/^-{1,2}/,"");if(Y.startsWith("no-"))this.negated=!0,Y=Y.replace(/^no-/,"");return lJ(Y)}).sort((Q,Y)=>Q.length>Y.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(J.includes("<"))this.required=!0;else if(J.includes("["))this.required=!1;else this.isBoolean=!0}}var K$=MJ.argv,yZ=`${MJ.platform}-${MJ.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,bJ=qJ.argv,gZ=`${qJ.platform}-${qJ.arch} node-${qJ.version}`;class BJ{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(J,Z,$,Q){this.rawName=J,this.description=Z,this.config=$,this.cli=Q,this.options=[],this.aliasNames=[],this.name=LJ(J);let Y=LJ(J),q=Y.indexOf(":");if(q>0)this.namespace=Y.substring(0,q),this.name=Y.substring(q+1);if(this.args=RZ(J),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!$)this.config={}}usage(J){return this.usageText=J,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(J,Z="-v, --version"){return this.versionNumber=J,this.option(Z,"Display version number"),this}example(J){return this.examples.push(J),this}option(J,Z,$){let Q=new aJ(J,Z,$);return this.options.push(Q),this}alias(J){return this.aliasNames.push(J),this}action(J){return this.commandAction=J,this}before(J){return this.beforeHooks.push(J),this}after(J){return this.afterHooks.push(J),this}use(J){return this.middleware.push(J),this}isMatched(J){return this.name===J||this.aliasNames.includes(J)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof EJ}hasOption(J){return J=J.split(".")[0],!!this.options.find((Z)=>{return Z.names.includes(J)})}outputHelp(){let{name:J,commands:Z}=this.cli,{versionNumber:$,options:Q,helpCallback:Y}=this.cli.globalCommand,q=[{body:`${J}${$?`/${$}`:""}`}];if(q.push({title:"Usage",body:` $ ${J} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&Z.length>0){let X=hJ(Z.map((K)=>K.rawName)),j=new Map,G=[];for(let K of Z)if(K.namespace){if(!j.has(K.namespace))j.set(K.namespace,[]);j.get(K.namespace).push(K)}else G.push(K);let V="";if(G.length>0)V+=G.map((K)=>{return` ${VJ(K.rawName,X.length)} ${K.description}`}).join(`
|
|
6
|
+
`);let W=Array.from(j.keys()).sort();for(let K of W){let L=j.get(K);if(V.length>0)V+=`
|
|
7
|
+
|
|
8
|
+
`;V+=` ${K}:
|
|
9
|
+
`,V+=L.map((P)=>{return` ${VJ(P.rawName,X.length-2)} ${P.description}`}).join(`
|
|
10
|
+
`)}q.push({title:"Commands",body:V}),q.push({title:"For more info, run any command with the `--help` flag",body:Z.map((K)=>` $ ${J}${K.name===""?"":` ${K.name}`} --help`).join(`
|
|
11
|
+
`)})}let F=this.isGlobalCommand?Q:[...this.options,...Q||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)F=F.filter((X)=>X.name!=="version");if(F.length>0){let X=hJ(F.map((j)=>j.rawName));q.push({title:"Options",body:F.map((j)=>{return` ${VJ(j.rawName,X.length)} ${j.description} ${j.config.default===void 0?"":`(default: ${j.config.default})`}`}).join(`
|
|
12
|
+
`)})}if(this.examples.length>0)q.push({title:"Examples",body:this.examples.map((X)=>{if(typeof X==="function")return X(J);return X}).join(`
|
|
13
|
+
`)});if(Y)q=Y(q)||q;console.log(q.map((X)=>{return X.title?`${X.title}:
|
|
14
|
+
${X.body}`:X.body}).join(`
|
|
15
|
+
|
|
16
|
+
`))}outputVersion(){let{name:J}=this.cli,{versionNumber:Z}=this.cli.globalCommand;if(Z)console.log(`${J}/${Z} ${typeof Bun<"u"?yZ:gZ}`)}checkRequiredArgs(){let J=this.args.filter((Z)=>Z.required).length;if(this.cli.args.length<J){let $=this.args.filter((Y)=>Y.required).slice(this.cli.args.length),Q=$.map((Y)=>`<${Y.value}>`).join(" ");throw new YJ(`Missing required argument${$.length>1?"s":""}: ${Q}
|
|
17
|
+
|
|
18
|
+
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`)}}checkUnknownOptions(){let{options:J,globalCommand:Z}=this.cli;if(!this.config.allowUnknownOptions){for(let $ of Object.keys(J))if($!=="--"&&!this.hasOption($)&&!Z.hasOption($)){let Y=[...Z.options,...this.options].flatMap((X)=>X.names),q=$.length>1?`--${$}`:`-${$}`,U=rJ($,Y),F=`Unknown option \`${q}\``;if(U.length>0)F+=`
|
|
19
|
+
|
|
20
|
+
Did you mean one of these?`,U.forEach((X)=>{let j=X.length>1?`--${X}`:`-${X}`;F+=`
|
|
21
|
+
\u2022 ${j}`});throw F+=`
|
|
22
|
+
|
|
23
|
+
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new YJ(F)}}}checkOptionValue(){let{options:J,globalCommand:Z}=this.cli,$=[...Z.options,...this.options];for(let Q of $){let Y=J[Q.name.split(".")[0]];if(Q.required){let q=$.some((U)=>U.negated&&U.names.includes(Q.name));if(Y===!0||Y===!1&&!q)throw new YJ(`Option \`${Q.rawName}\` requires a value.
|
|
24
|
+
|
|
25
|
+
Example: ${this.cli.name} ${this.rawName} ${Q.rawName} <value>`)}}}}class EJ extends BJ{constructor(J){super("@@global@@","",{},J)}}var _Z=BJ,d={red:["\x1B[31m","\x1B[39m"],green:["\x1B[32m","\x1B[39m"],blue:["\x1B[34m","\x1B[39m"],yellow:["\x1B[33m","\x1B[39m"],cyan:["\x1B[36m","\x1B[39m"],magenta:["\x1B[35m","\x1B[39m"],white:["\x1B[37m","\x1B[39m"],gray:["\x1B[90m","\x1B[39m"],bgRed:["\x1B[41m","\x1B[49m"],bgGreen:["\x1B[42m","\x1B[49m"],bgBlue:["\x1B[44m","\x1B[49m"],bgYellow:["\x1B[43m","\x1B[49m"],bgCyan:["\x1B[46m","\x1B[49m"],bgMagenta:["\x1B[45m","\x1B[49m"],bold:["\x1B[1m","\x1B[22m"],italic:["\x1B[3m","\x1B[23m"],underline:["\x1B[4m","\x1B[24m"],dim:["\x1B[2m","\x1B[22m"],inverse:["\x1B[7m","\x1B[27m"],hidden:["\x1B[8m","\x1B[28m"],strikethrough:["\x1B[9m","\x1B[29m"]},PJ={default:{primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"},dracula:{primary:"magenta",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"blue",muted:"gray"},nord:{primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"cyan",muted:"gray"},solarized:{primary:"cyan",secondary:"blue",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"},monokai:{primary:"magenta",secondary:"blue",success:"green",warning:"yellow",error:"red",info:"cyan",muted:"gray"}},a={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function fZ(){return!0}function mZ(){let J={};J.supportsColor=fZ();function Z(Q,Y=[]){let q=Q===""?[]:[...Y,Q],U=function(X){if(!J.supportsColor)return X;let j="",G="";for(let V of q)if(V in a&&a[V]in d){let W=a[V];j+=d[W][0],G=d[W][1]+G}else if(V in d)j+=d[V][0],G=d[V][1]+G;return j+X+G},F=[...Object.keys(d),...Object.keys(a)];for(let X of F)if(!(X in U))Object.defineProperty(U,X,{get(){return Z(X,q)}});return U}let $=[...Object.keys(d),...Object.keys(a)];for(let Q of $)if(!(Q in J))Object.defineProperty(J,Q,{get(){return Z(Q)}});return J}var i=mZ();function dZ(J){for(let Z in J)if(J[Z]!==void 0)a[Z]=J[Z]}function W$(J){if(J in PJ)dZ(PJ[J])}function D$(){return Object.keys(PJ)}function L$(J){if(J.colors!==void 0)i.supportsColor=J.colors}function M$(J,Z){let $=Z?.title?` ${Z.title} `:"",Q=Z?.padding||0,Y=" ".repeat(Q),q=J.split(`
|
|
26
|
+
`),F=Math.max(...q.map((j)=>j.length))+Q*2,X=F;console.log(`\u250C${$?"\u2500".repeat(Math.floor((X-$.length)/2))+$+"\u2500".repeat(Math.ceil((X-$.length)/2)):"\u2500".repeat(X)}\u2510`),console.log(`\u2502${" ".repeat(X)}\u2502`);for(let j of q){let G=F-j.length-Q;console.log(`\u2502${Y}${j}${" ".repeat(G)}\u2502`)}console.log(`\u2502${" ".repeat(X)}\u2502`),console.log(`\u2514${"\u2500".repeat(X)}\u2518`)}function P$(J){let Z=J?.title?` ${J.title} `:"",Q=J.content.split(`
|
|
27
|
+
`),q=Math.max(...Q.map((U)=>U.length))+2;console.log(`\u2554${Z?"\u2550".repeat(Math.floor((q-Z.length)/2))+Z+"\u2550".repeat(Math.ceil((q-Z.length)/2)):"\u2550".repeat(q)}\u2557`),console.log(`\u2551${" ".repeat(q)}\u2551`);for(let U of Q){let F=q-U.length-1;console.log(`\u2551 ${U}${" ".repeat(F)}\u2551`)}console.log(`\u2551${" ".repeat(q)}\u2551`),console.log(`\u255A${"\u2550".repeat(q)}\u255D`)}function N$(J,Z){if(!J||J.length===0)return;let $=Array.from({length:J[0].length},()=>0);for(let Y of J)for(let q=0;q<Y.length;q++)$[q]=Math.max($[q],String(Y[q]).length);if(Z?.border)console.log(`\u250C${$.map((Y)=>"\u2500".repeat(Y+2)).join("\u252C")}\u2510`);if(Z?.header&&J.length>0)if(console.log((Z.border?"\u2502 ":"")+J[0].map((Y,q)=>`${Y}${" ".repeat($[q]-String(Y).length)}`).join(" \u2502 ")+(Z.border?" \u2502":"")),Z.border)console.log(`\u251C${$.map((Y)=>"\u2500".repeat(Y+2)).join("\u253C")}\u2524`);else console.log(`${$.map((Y)=>"\u2500".repeat(Y)).join("\u2500\u253C\u2500")}`);let Q=Z?.header?1:0;for(let Y=Q;Y<J.length;Y++)console.log((Z?.border?"\u2502 ":"")+J[Y].map((q,U)=>`${q}${" ".repeat($[U]-String(q).length)}`).join(" \u2502 ")+(Z?.border?" \u2502":""));if(Z?.border)console.log(`\u2514${$.map((Y)=>"\u2500".repeat(Y+2)).join("\u2534")}\u2518`)}class sJ extends IZ{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;enableDidYouMean=!0;signalHandlersSet=!1;isVerbose=!1;isQuiet=!1;isDebug=!1;isNoInteraction=!1;environment;isDryRun=!1;isForce=!1;useEmoji=!0;theme;isNoCache=!1;constructor(J=""){super();this.name=J,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new EJ(this),this.globalCommand.usage("<command> [options]")}handleSignals(J){if(this.signalHandlersSet)return this;let Z=async($)=>{if(console.log(`
|
|
28
|
+
|
|
29
|
+
Received ${$}, cleaning up...`),J)try{await J()}catch(Q){console.error("Error during cleanup:",Q)}m.exit(0)};return m.on("SIGINT",()=>Z("SIGINT")),m.on("SIGTERM",()=>Z("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(J=!0){return this.enableDidYouMean=J,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(J){return this.globalCommand.usage(J),this}command(J,Z,$){if(!$)$={};let Q=new _Z(J,Z||"",$,this);return Q.globalCommand=this.globalCommand,this.commands.push(Q),Q}option(J,Z,$){return this.globalCommand.option(J,Z,$),this}help(J){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=J,this.showHelpOnExit=!0,this}version(J,Z="-v, --version"){return this.globalCommand.version(J,Z),this.showVersionOnExit=!0,this}example(J){return this.globalCommand.example(J),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:J,options:Z},$,Q){if(this.args=J,this.options=Z,$)this.matchedCommand=$;if(Q)this.matchedCommandName=Q;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(J){if(console.log(i.red(`
|
|
30
|
+
\u2717 Command "${J}" not found.
|
|
31
|
+
`)),this.enableDidYouMean){let Z=[];for(let Q of this.commands){if(Q.name)Z.push(Q.name);if(Q.aliasNames)Z.push(...Q.aliasNames)}let $=rJ(J,Z);if($.length>0)console.log(i.yellow("Did you mean one of these?")),$.forEach((Q)=>console.log(` ${i.dim("\u2022")} ${this.name} ${Q}`)),console.log("")}console.log(i.dim("Run"),`${this.name} --help`,i.dim("to see all available commands")),m.exit(1)}async parse(J=bJ,Z={}){let{run:$=!0,exitOnError:Q=!1}=Z;if(Q)try{return await this.parse(J,{run:$})}catch(X){throw this.handleUsageError(X),X}if(this.rawArgs=J,!this.name)this.name=J[1]?bZ(J[1]):"cli";let Y=!0,q=J.slice(2),U=q[0];if(U&&!U.startsWith("-")){for(let X of this.commands)if(X.isMatched(U)){let j=this.mri(q,X);Y=!1;let G={...j,args:j.args.slice(1)};this.setParsedInfo(G,X,U),this.emit(`command:${U}`,X);break}}if(Y){for(let X of this.commands)if(X.name===""){Y=!1;let j=this.mri(q,X);this.setParsedInfo(j,X),this.emit("command:!",X);break}}if(Y){let X=this.mri(J.slice(2));this.setParsedInfo(X)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji!==void 0)this.useEmoji=!this.options.noEmoji;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache!==void 0)this.isNoCache=Boolean(this.options.noCache);if(this.options.help&&this.showHelpOnExit)this.outputHelp(),$=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),$=!1,this.unsetMatchedCommand();let F={args:this.args,options:this.options};if($)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return F}mri(J,Z){let $=[...this.globalCommand.options,...Z?Z.options:[]],Q=xZ($),Y=[],q=J.indexOf("--");if(q>-1)Y=J.slice(q+1),J=J.slice(0,q);let U=AZ(J,Q),F={_:U._};for(let W of Object.keys(U))if(W!=="_")F[lJ(W)]=U[W];let X=F._,j={"--":Y},G=Z&&Z.config.ignoreOptionDefaultValue?Z.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,V=Object.create(null);for(let W of $){if(!G&&W.config.default!==void 0)for(let K of W.names)j[K]=W.config.default;if(Array.isArray(W.config.type)){if(V[W.name]===void 0)V[W.name]={shouldTransform:!0,transformFunction:W.config.type[0]}}}for(let W of Object.keys(F))if(W!=="_"){let K=W.split(".");kZ(j,K,F[W]),hZ(j,V)}return{args:X,options:j}}async run(J=bJ){return this.parse(J,{run:!0,exitOnError:!0})}handleUsageError(J){if(!(!!J&&typeof J==="object"&&J.name==="ClappError"&&J.isUsageError!==!1))return;let Q=J,Y=Q.message??"command-line error",q=this.name?`${this.name}: `:"",U=/--help/.test(Y)?"":`
|
|
32
|
+
Run \`${this.name??"cli"} --help\` for usage.`;m.stderr.write(`${q}${Y}${U}
|
|
33
|
+
`),m.exit(Q.exitCode??2)}async runMatchedCommand(){let{args:J,options:Z,matchedCommand:$}=this;if(!$||!$.commandAction)return;$.checkUnknownOptions(),$.checkOptionValue(),$.checkRequiredArgs();let Q=[];$.args.forEach((F,X)=>{if(F.variadic)Q.push(J.slice(X));else Q.push(J[X])}),Q.push(Z);let Y={command:$,args:Q,options:Z};for(let F of $.beforeHooks)await F(Y);let q,U=async()=>{let F=$.commandAction.apply(this,Q);if(F instanceof Promise)q=await F;else q=F;return q};if($.middleware.length>0){let F=0,X=async()=>{if(F<$.middleware.length){let j=$.middleware[F++];await j({...Y,next:X})}else await U()};await X()}else await U();for(let F of $.afterHooks)await F(Y);return q}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return m.removeAllListeners("SIGINT"),m.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}var tJ=(J="")=>new sJ(J);class oJ{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(J){if(!this.enabled){this.misses++;return}let Z=this.cache.get(J);if(!Z){this.misses++;return}if(Date.now()-Z.timestamp>Z.ttl){this.cache.delete(J),this.misses++;return}return this.hits++,Z.value}set(J,Z,$=5000){if(!this.enabled)return;this.cache.set(J,{value:Z,timestamp:Date.now(),ttl:$})}has(J){if(!this.enabled)return!1;let Z=this.cache.get(J);if(!Z)return!1;if(Date.now()-Z.timestamp>Z.ttl)return this.cache.delete(J),!1;return!0}delete(J){this.cache.delete(J)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let J=Date.now();for(let[Z,$]of this.cache.entries())if(J-$.timestamp>$.ttl)this.cache.delete(Z)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var w$=new oJ;function T$(J,Z){J.on(`${Z}:*`,()=>{let $=J.args??[];vJ.stderr.write(`Unknown ${Z} subcommand: ${[...$].join(" ")}
|
|
34
|
+
Run \`${J.name??"cli"} ${Z} --help\` to see available subcommands.
|
|
35
|
+
`),vJ.exit(64)})}function uZ(){if("FORCE_COLOR"in o.env)return o.env.FORCE_COLOR!=="0";if("NO_COLOR"in o.env||o.env.TERM==="dumb")return!1;if(o.platform==="win32")return!0;return SJ.isatty(1)&&SJ.isatty(2)}var eJ=uZ();function B(J,Z){if(!eJ)return($)=>$;return($)=>J+$+Z}var cZ=B("\x1B[0m","\x1B[0m"),pZ=B("\x1B[31m","\x1B[39m"),JZ=B("\x1B[32m","\x1B[39m"),iZ=B("\x1B[33m","\x1B[39m"),nZ=B("\x1B[34m","\x1B[39m"),lZ=B("\x1B[35m","\x1B[39m"),rZ=B("\x1B[36m","\x1B[39m"),aZ=B("\x1B[37m","\x1B[39m"),ZZ=B("\x1B[90m","\x1B[39m"),$Z=B("\x1B[1m","\x1B[22m"),sZ=B("\x1B[3m","\x1B[23m"),tZ=B("\x1B[4m","\x1B[24m"),QZ=B("\x1B[2m","\x1B[22m"),oZ=B("\x1B[7m","\x1B[27m"),eZ=B("\x1B[8m","\x1B[28m"),J0=B("\x1B[9m","\x1B[29m"),Z0=B("\x1B[41m","\x1B[49m"),$0=B("\x1B[42m","\x1B[49m"),Q0=B("\x1B[43m","\x1B[49m"),z0=B("\x1B[44m","\x1B[49m"),Y0=B("\x1B[45m","\x1B[49m"),q0=B("\x1B[46m","\x1B[49m"),X0=B("\x1B[47m","\x1B[49m"),U0=eJ,F0={reset:cZ,red:pZ,green:JZ,yellow:iZ,blue:nZ,magenta:lZ,cyan:rZ,white:aZ,gray:ZZ,bold:$Z,italic:sZ,underline:tZ,dim:QZ,inverse:oZ,hidden:eZ,strikethrough:J0,bgRed:Z0,bgGreen:$0,bgYellow:Q0,bgBlue:z0,bgMagenta:Y0,bgCyan:q0,bgWhite:X0,isColorSupported:U0},z=F0,K0=["up","down","left","right","space","enter","cancel"],v={actions:new Set(K0),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};function R$(J){if(J.aliases!==void 0){let Z=J.aliases;for(let $ in Z){if(!Object.hasOwn(Z,$))continue;let Q=Z[$];if(!v.actions.has(Q))continue;if(!v.aliases.has($))v.aliases.set($,Q)}}if(J.messages!==void 0){let Z=J.messages;if(Z.cancel!==void 0)v.messages.cancel=Z.cancel;if(Z.error!==void 0)v.messages.error=Z.error}}function IJ(J,Z){if(typeof J==="string")return v.aliases.get(J)===Z;for(let $ of J){if($===void 0)continue;if(IJ($,Z))return!0}return!1}function V0(J,Z){if(J===Z)return[];let $=J.split(`
|
|
36
|
+
`),Q=Z.split(`
|
|
37
|
+
`),Y=[];for(let q=0;q<Math.max($.length,Q.length);q++)if($[q]!==Q[q])Y.push(q);return Y}var W0=zZ.platform.startsWith("win"),NJ=Symbol("clapp:cancel");function D0(J){return J===NJ}function zJ(J,Z){let $=J;if($.isTTY)$.setRawMode(Z)}function L0(J){let{input:Z=j0,output:$=G0,overwrite:Q=!0,hideCursor:Y=!0}=J||{},q=c.createInterface({input:Z,output:$,prompt:"",tabSize:1});if(c.emitKeypressEvents(Z,q),Z instanceof yJ&&Z.isTTY)Z.setRawMode(!0);let U=(F,{name:X,sequence:j})=>{let G=String(F);if(IJ([G,X,j],"cancel")){if(Y)$.write(C.show);zZ.exit(0);return}if(!Q)return;c.moveCursor($,X==="return"?0:-1,X==="return"?-1:0,()=>{c.clearLine($,1,()=>{Z.once("keypress",U)})})};if(Y)$.write(C.hide);return Z.once("keypress",U),()=>{if(Z.off("keypress",U),Y)$.write(C.show);if(Z instanceof yJ&&Z.isTTY&&!W0)Z.setRawMode(!1);q.terminal=!1,q.close()}}function M0(J){if(J instanceof H0&&J.columns)return J.columns;return 80}function O0(J){return J.replace(/\x1b\[[0-9;]*m/g,"")}function T0(J){return O0(J).length}function _J(J,Z,$){if(!Z||Z<1)return J;let Q=$?.hard??!1,Y=$?.trim??!0,q=J.split(`
|
|
38
|
+
`),U=[];for(let F of q){if(T0(F)<=Z){U.push(Y?F.trimEnd():F);continue}if(Q){let X="",j=0,G=0;while(G<F.length){let V=F.slice(G).match(/^\x1b\[[0-9;]*m/);if(V){X+=V[0],G+=V[0].length;continue}if(j>=Z)U.push(Y?X.trimEnd():X),X="",j=0;X+=F[G],j++,G++}if(X)U.push(Y?X.trimEnd():X)}else U.push(Y?F.trimEnd():F)}return U.join(`
|
|
39
|
+
`)}class _{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;_manualLine="";state="initial";error="";value;userInput="";constructor(J,Z=!0){let{input:$=P0,output:Q=N0,render:Y,signal:q,...U}=J;this.opts=U,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=Z,this._abortSignal=q,this.input=$,this.output=Q}unsubscribe(){this._subscribers.clear()}setSubscriber(J,Z){let $=this._subscribers.get(J)??[];$.push(Z),this._subscribers.set(J,$)}on(J,Z){return this.setSubscriber(J,{cb:Z}),this}once(J,Z){return this.setSubscriber(J,{cb:Z,once:!0}),this}emit(J,...Z){let $=this._subscribers.get(J)??[],Q=[];for(let Y of $)if(Y.cb(...Z),Y.once)Q.push(()=>$.splice($.indexOf(Y),1));for(let Y of Q)Y();return this}prompt(){return new Promise((J)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),J(NJ);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}if(this.rl=w0.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0)this._setUserInput(this.opts.initialUserInput,!0);this.input.on("keypress",this.onKeypress),zJ(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(C.show),this.output.off("resize",this.render),zJ(this.input,!1),J(this.value)}),this.once("cancel",()=>{this.output.write(C.show),this.output.off("resize",this.render),zJ(this.input,!1),J(NJ)})})}_isActionKey(J,Z){return J==="\t"}_setValue(J){this.value=J,this.emit("value",this.value)}_setUserInput(J,Z){if(this.userInput=J??"",this.emit("userInput",this.userInput),Z&&this._track&&this.rl)this.rl.write(this.userInput),this._cursor=this.rl.cursor}onKeypress(J,Z){if(this._track&&Z.name!=="return"){if(Z.name&&this._isActionKey(J,Z))this.rl?.write(null,{ctrl:!0,name:"h"});this._cursor=this.rl?.cursor??0;let $=Z.name==="tab"||Z.name==="escape"||Z.name==="backspace"||Z.name==="delete"||Z.name==="enter"||Z.name==="return"||Z.name&&["up","down","left","right"].includes(Z.name);if(J&&!$&&J.length===1&&J>=" ")this._manualLine+=J;else if(Z.name==="backspace"&&this._manualLine.length>0)this._manualLine=this._manualLine.slice(0,-1);let Q=this._manualLine.length>=(this.rl?.line?.length||0)?this._manualLine:this.rl?.line;this._setUserInput(Q)}if(this.state==="error")this.state="active",this.error="";if(Z?.name){if(!this._track&&v.aliases.has(Z.name))this.emit("cursor",v.aliases.get(Z.name));if(v.actions.has(Z.name))this.emit("cursor",Z.name)}if(J&&(J.toLowerCase()==="y"||J.toLowerCase()==="n"))this.emit("confirm",J.toLowerCase()==="y");if(this.emit("key",J?.toLowerCase(),Z),Z?.name==="return"){if(this.opts.validate){let $=this.opts.validate(this.value);if($)this.error=$ instanceof Error?$.message:$,this.state="error"}if(this.state!=="error")this.state="submit"}if(IJ([J,Z?.name,Z?.sequence],"cancel"))this.state="cancel";if(this.state==="submit"||this.state==="cancel")this.emit("finalize");if(this.render(),this.state==="submit"||this.state==="cancel")this.close()}close(){if(this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
40
|
+
`),zJ(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.state==="cancel")setTimeout(()=>{this.unsubscribe()},10);else this.unsubscribe()}restoreCursor(){let J=_J(this._prevFrame,gJ.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
41
|
+
`).length-1;this.output.write(C.move(-999,J*-1))}render(){let J=_J(this._render(this)??"",gJ.stdout.columns,{hard:!0,trim:!1});if(J===this._prevFrame)return;if(this.state==="initial")this.output.write(C.hide);else{let Z=V0(this._prevFrame,J);if(this.restoreCursor(),Z&&Z?.length===1){let $=Z[0];this.output.write(C.move(0,$)),this.output.write(JJ.lines(1));let Q=J.split(`
|
|
42
|
+
`);this.output.write(Q[$]),this._prevFrame=J,this.output.write(C.move(0,Q.length-$-1));return}if(Z&&Z?.length>1){let $=Z[0];this.output.write(C.move(0,$)),this.output.write(JJ.down());let Y=J.split(`
|
|
43
|
+
`).slice($);this.output.write(Y.join(`
|
|
44
|
+
`)),this._prevFrame=J;return}this.output.write(JJ.down())}if(this.output.write(J),this.state==="initial")this.state="active";this._prevFrame=J}}function B0(J,Z){if(J===void 0)return 0;if(Z.length===0)return 0;let Q=Z.findIndex((Y)=>Y.value===J);return Q!==-1?Q:0}function E0(J,Z){return(Z.label??String(Z.value)).toLowerCase().includes(J.toLowerCase())}function I0(J,Z){if(!Z)return;if(J)return Z;return Z[0]}class AJ extends _{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#J=0;#$="";#Q;#Z;get cursor(){return this.#J}get userInputWithCursor(){if(!this.userInput)return z.inverse(z.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let J=this.userInput.slice(0,this._cursor),[Z,...$]=this.userInput.slice(this._cursor);return`${J}${z.inverse(Z)}${$.join("")}`}get options(){if(typeof this.#Z==="function")return this.#Z();return this.#Z}constructor(J){super(J);this.#Z=J.options;let Z=this.options;this.filteredOptions=[...Z],this.multiple=J.multiple===!0,this.#Q=J.filter??E0;let $;if(J.initialValue&&Array.isArray(J.initialValue))if(this.multiple)$=J.initialValue;else $=J.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)$=[this.options[0].value];if($)for(let Q of $){let Y=Z.findIndex((q)=>q.value===Q);if(Y!==-1)this.toggleSelected(Q),this.#J=Y}this.focusedValue=this.options[this.#J]?.value,this.on("key",(Q,Y)=>this.#z(Q,Y)),this.on("userInput",(Q)=>this.#Y(Q))}_isActionKey(J,Z){return J==="\t"||this.multiple&&this.isNavigating&&Z.name==="space"&&J!==void 0&&J!==""}#z(J,Z){let $=Z.name==="up",Q=Z.name==="down",Y=Z.name==="return";if($||Q){if(this.#J=Math.max(0,Math.min(this.#J+($?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#J]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(Y)this.value=I0(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&(Z.name==="tab"||this.isNavigating&&Z.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(J){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(J))this.selectedValues=this.selectedValues.filter((Z)=>Z!==J);else this.selectedValues=[...this.selectedValues,J];else this.selectedValues=[J]}#Y(J){if(J!==this.#$){this.#$=J;let Z=this.options;if(J)this.filteredOptions=Z.filter(($)=>this.#Q(J,$));else this.filteredOptions=[...Z];if(this.#J=B0(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#J]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class YZ extends _{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(J){super(J,!1);this.value=!!J.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(Z)=>{this.output.write(C.move(0,-1)),this.value=Z,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class qZ extends _{options;cursor=0;#J;getGroupItems(J){return this.options.filter((Z)=>Z.group===J)}isGroupSelected(J){let Z=this.getGroupItems(J),$=this.value;if($===void 0)return!1;return Z.every((Q)=>$.includes(Q.value))}toggleValue(){let J=this.options[this.cursor];if(this.value===void 0)this.value=[];if(J.group===!0){let Z=J.value,$=this.getGroupItems(Z);if(this.isGroupSelected(Z))this.value=this.value.filter((Q)=>$.findIndex((Y)=>Y.value===Q)===-1);else this.value=[...this.value,...$.map((Q)=>Q.value)];this.value=Array.from(new Set(this.value))}else{let Z=this.value.includes(J.value);this.value=Z?this.value.filter(($)=>$!==J.value):[...this.value,J.value]}}constructor(J){super(J,!1);let{options:Z}=J;this.#J=J.selectableGroups!==!1,this.options=Object.entries(Z).flatMap(([$,Q])=>[{value:$,group:!0,label:$},...Q.map((Y)=>({...Y,group:$}))]),this.value=[...J.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:$})=>$===J.cursorAt),this.#J?0:1),this.on("cursor",($)=>{switch($){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Q=this.options[this.cursor]?.group===!0;if(!this.#J&&Q)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Q=this.options[this.cursor]?.group===!0;if(!this.#J&&Q)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}class XZ extends _{options;cursor=0;get _value(){return this.options[this.cursor].value}toggleAll(){let J=this.value!==void 0&&this.value.length===this.options.length;this.value=J?[]:this.options.map((Z)=>Z.value)}toggleValue(){if(this.value===void 0)this.value=[];let J=this.value.includes(this._value);this.value=J?this.value.filter((Z)=>Z!==this._value):[...this.value,this._value]}constructor(J){super(J,!1);this.options=J.options,this.value=[...J.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Z})=>Z===J.cursorAt),0),this.on("key",(Z)=>{if(Z==="a")this.toggleAll()}),this.on("cursor",(Z)=>{switch(Z){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}}class UZ extends _{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let J=this.userInput;if(this.cursor>=J.length)return`${this.masked}${z.inverse(z.hidden("_"))}`;let Z=this.masked,$=Z.slice(0,this.cursor),Q=Z.slice(this.cursor);return`${$}${z.inverse(Q[0])}${Q.slice(1)}`}constructor({mask:J,...Z}){super(Z);this._mask=J??"\u2022",this.on("userInput",($)=>{this._setValue($)})}}class FZ extends _{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(J){super(J,!1);if(this.options=J.options,this.cursor=this.options.findIndex(({value:Z})=>Z===J.initialValue),this.cursor===-1)this.cursor=0;this.changeValue(),this.on("cursor",(Z)=>{switch(Z){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}}class jZ extends _{options;cursor=0;constructor(J){super(J,!1);this.options=J.options;let Z=this.options.map(({value:[$]})=>$?.toLowerCase());this.cursor=Math.max(Z.indexOf(J.initialValue),0),this.on("key",($)=>{if(!$||!Z.includes($))return;let Q=this.options.find(({value:[Y]})=>Y?.toLowerCase()===$);if(Q)this.value=Q.value,this.state="submit",this.emit("submit")})}}class GZ extends _{placeholder;get userInputWithCursor(){if(this.state==="submit")return this.userInput;let J=this.userInput;if(this.cursor>=J.length)return`${this.userInput}\u2588`;let Z=J.slice(0,this.cursor),[$,...Q]=J.slice(this.cursor);return`${Z}${z.inverse($)}${Q.join("")}`}get cursor(){return this._cursor}constructor(J){super({...J,initialUserInput:J.initialUserInput??J.initialValue});this.placeholder=J.placeholder,this.on("key",(Z)=>{if(Z==="\t"&&this.placeholder){if(!this.userInput||this.userInput==="\t")this._setValue(this.placeholder),this._setUserInput(this.placeholder,!0)}}),this.on("userInput",(Z)=>{this._setValue(Z)}),this.on("finalize",()=>{if(!this.userInput&&this.placeholder)this.value=this.placeholder;if(!this.value)this.value=J.defaultValue;if(this.value===void 0)this.value=""})}}var wJ=vZ(),HZ=()=>A0.env.CI==="true";function R0(J){return J.isTTY===!0}var O=(J,Z)=>wJ?J:Z,x0=O("\u25C6","*"),KZ=O("\u25A0","x"),VZ=O("\u25B2","x"),t=O("\u25C7","o"),C0=O("\u250C","T"),H=O("\u2502","|"),x=O("\u2514","\u2014"),FJ=O("\u25CF",">"),jJ=O("\u25CB"," "),OJ=O("\u25FB","[\u2022]"),s=O("\u25FC","[+]"),RJ=O("\u25FB","[ ]"),k0=O("\u25AA","\u2022"),fJ=O("\u2500","-"),h0=O("\u256E","+"),b0=O("\u251C","+"),v0=O("\u256F","+"),WZ=O("\u25CF","\u2022"),DZ=O("\u25C6","*"),LZ=O("\u25B2","!"),MZ=O("\u25A0","x");function f(J){switch(J){case"initial":case"active":return z.cyan(x0);case"cancel":return z.red(KZ);case"error":return z.yellow(VZ);case"submit":return z.green(t)}}function n(J){return J.replace(/_([^_]+)_/g,(Z,$)=>i.italic($))}function ZJ(J){let{cursor:Z,options:$,style:Q}=J,Y=J.output??S0.stdout,q=Y instanceof y0&&Y.rows!==void 0?Y.rows:10,U=z.dim("..."),F=J.maxItems??Number.POSITIVE_INFINITY,X=Math.max(q-4,0),j=Math.min(X,Math.max(F,5)),G=0;if(Z>=G+j-3)G=Math.max(Math.min(Z-j+3,$.length-j),0);else if(Z<G+2)G=Math.max(Z-2,0);let V=j<$.length&&G>0,W=j<$.length&&G+j<$.length;return $.slice(G,G+j).map((K,L,P)=>{let D=L===0&&V,M=L===P.length-1&&W;return D||M?U:Q(K,L+G===Z)})}function mJ(J){return J.label??String(J.value??"")}function PZ(J,Z){if(!J)return!0;let $=(Z.label??String(Z.value??"")).toLowerCase(),Q=(Z.hint??"").toLowerCase(),Y=String(Z.value).toLowerCase(),q=J.toLowerCase();return $.includes(q)||Q.includes(q)||Y.includes(q)}function g0(J,Z){let $=[];for(let Q of Z)if(J.includes(Q.value))$.push(Q);return $}function _0(J){return new AJ({options:J.options,initialValue:J.initialValue?[J.initialValue]:void 0,initialUserInput:J.initialUserInput,filter:($,Q)=>{return PZ($,Q)},signal:J.signal,input:J.input,output:J.output,validate:J.validate,render(){let $=`${z.gray(H)}
|
|
45
|
+
${f(this.state)} ${J.message}
|
|
46
|
+
`,Q=this.userInput,Y=String(this.value??""),q=this.options,U=J.placeholder,F=Y===""&&U!==void 0;switch(this.state){case"submit":{let X=g0(this.selectedValues,q),j=X.length>0?` ${z.dim(X.map(mJ).join(", "))}`:"";return`${$}${z.gray(H)}${j}`}case"cancel":{let X=Q?` ${z.strikethrough(z.dim(Q))}`:"";return`${$}${z.gray(H)}${X}`}default:{let X="";if(this.isNavigating||F){let L=F?U:Q;X=L!==""?` ${z.dim(L)}`:""}else X=` ${this.userInputWithCursor}`;let j=this.filteredOptions.length!==q.length?z.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",G=this.filteredOptions.length===0?[]:ZJ({cursor:this.cursor,options:this.filteredOptions,style:(L,P)=>{let D=mJ(L),M=L.hint&&L.value===this.focusedValue?z.dim(` (${L.hint})`):"";return P?`${z.green(FJ)} ${D}${M}`:`${z.dim(jJ)} ${z.dim(D)}${M}`},maxItems:J.maxItems,output:J.output}),V=[`${z.dim("\u2191/\u2193")} to select`,`${z.dim("Enter:")} confirm`,`${z.dim("Type:")} to search`],W=this.filteredOptions.length===0&&Q?[`${z.cyan(H)} ${z.yellow("No matches found")}`]:[],K=this.state==="error"?[`${z.yellow(H)} ${z.yellow(this.error)}`]:[];return[`${$}${z.cyan(H)}`,`${z.cyan(H)} ${z.dim("Search:")}${X}${j}`,...W,...K,...G.map((L)=>`${z.cyan(H)} ${L}`),`${z.cyan(H)} ${z.dim(V.join(" \u2022 "))}`,`${z.cyan(x)}`].join(`
|
|
47
|
+
`)}}}}).prompt()}function v$(J){let Z=(Q,Y,q,U)=>{let F=q.includes(Q.value),X=Q.label??String(Q.value??""),j=Q.hint&&U!==void 0&&Q.value===U?z.dim(` (${Q.hint})`):"",G=F?z.green(s):z.dim(RJ);if(Y)return`${G} ${X}${j}`;return`${G} ${z.dim(X)}`},$=new AJ({options:J.options,multiple:!0,filter:(Q,Y)=>{return PZ(Q,Y)},validate:()=>{if(J.required&&$.selectedValues.length===0)return"Please select at least one item";return},initialValue:J.initialValues,signal:J.signal,input:J.input,output:J.output,render(){let Q=`${z.gray(H)}
|
|
48
|
+
${f(this.state)} ${J.message}
|
|
49
|
+
`,Y=this.userInput,q=J.placeholder,U=Y===""&&q!==void 0,F=this.isNavigating||U?z.dim(U?q:Y):this.userInputWithCursor,X=this.options,j=this.filteredOptions.length!==X.length?z.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${Q}${z.gray(H)} ${z.dim(`${this.selectedValues.length} items selected`)}`;case"cancel":return`${Q}${z.gray(H)} ${z.strikethrough(z.dim(Y))}`;default:{let G=[`${z.dim("\u2191/\u2193")} to navigate`,`${z.dim("Space:")} select`,`${z.dim("Enter:")} confirm`,`${z.dim("Type:")} to search`],V=this.filteredOptions.length===0&&Y?[`${z.cyan(H)} ${z.yellow("No matches found")}`]:[],W=this.state==="error"?[`${z.cyan(H)} ${z.yellow(this.error)}`]:[],K=ZJ({cursor:this.cursor,options:this.filteredOptions,style:(L,P)=>Z(L,P,this.selectedValues,this.focusedValue),maxItems:J.maxItems,output:J.output});return[Q,`${z.cyan(H)} ${z.dim("Search:")} ${F}${j}`,...V,...W,...K.map((L)=>`${z.cyan(H)} ${L}`),`${z.cyan(H)} ${z.dim(G.join(" \u2022 "))}`,`${z.cyan(x)}`].join(`
|
|
50
|
+
`)}}}});return $.prompt()}function S$(J){let Z=J.active??"Yes",$=J.inactive??"No",Q=n(J.message);return new YZ({active:Z,inactive:$,signal:J.signal,input:J.input,output:J.output,initialValue:J.initialValue??!0,render(){let Y=`${z.gray(H)}
|
|
51
|
+
${f(this.state)} ${Q}
|
|
52
|
+
`,q=this.value?Z:$;switch(this.state){case"submit":return`${Y}${z.gray(H)} ${z.dim(q)}`;case"cancel":return`${Y}${z.gray(H)} ${z.strikethrough(z.dim(q))}
|
|
53
|
+
${z.gray(H)}`;default:return`${Y}${z.cyan(H)} ${this.value?`${z.green(FJ)} ${Z}`:`${z.dim(jJ)} ${z.dim(Z)}`} ${z.dim("/")} ${!this.value?`${z.green(FJ)} ${$}`:`${z.dim(jJ)} ${z.dim($)}`}
|
|
54
|
+
${z.cyan(x)}
|
|
55
|
+
`}}}).prompt()}async function y$(J,Z){let $={},Q=Object.keys(J);for(let Y of Q){let q=J[Y],U=await q({results:$})?.catch((F)=>{throw F});if(typeof Z?.onCancel==="function"&&D0(U)){$[Y]="canceled",Z.onCancel({results:$});continue}$[Y]=U}return $}function g$(J){let{selectableGroups:Z=!0,groupSpacing:$=0}=J,Q=(q,U,F=[])=>{let X=q.label??String(q.value),j=typeof q.group==="string",G=j&&(F[F.indexOf(q)+1]??{group:!0}),V=j&&G.group===!0,W=j?Z?`${V?x:H} `:" ":"",K="";if($>0&&!j){let P=`
|
|
56
|
+
${z.cyan(H)}`;K=`${P.repeat($-1)}${P} `}if(U==="active")return`${K}${z.dim(W)}${z.cyan(OJ)} ${X}${q.hint?` ${z.dim(`(${q.hint})`)}`:""}`;if(U==="group-active")return`${K}${W}${z.cyan(OJ)} ${z.dim(X)}`;if(U==="group-active-selected")return`${K}${W}${z.green(s)} ${z.dim(X)}`;if(U==="selected"){let P=j||Z?z.green(s):"";return`${K}${z.dim(W)}${P} ${z.dim(X)}${q.hint?` ${z.dim(`(${q.hint})`)}`:""}`}if(U==="cancelled")return`${z.strikethrough(z.dim(X))}`;if(U==="active-selected")return`${K}${z.dim(W)}${z.green(s)} ${X}${q.hint?` ${z.dim(`(${q.hint})`)}`:""}`;if(U==="submitted")return`${z.dim(X)}`;let L=j||Z?z.dim(RJ):"";return`${K}${z.dim(W)}${L} ${z.dim(X)}`},Y=J.required??!0;return new qZ({options:J.options,signal:J.signal,input:J.input,output:J.output,initialValues:J.initialValues,required:Y,cursorAt:J.cursorAt,selectableGroups:Z,validate(q){if(Y&&(q===void 0||q.length===0))return`Please select at least one option.
|
|
57
|
+
${z.reset(z.dim(`Press ${z.gray(z.bgWhite(z.inverse(" space ")))} to select, ${z.gray(z.bgWhite(z.inverse(" enter ")))} to submit`))}`},render(){let q=`${z.gray(H)}
|
|
58
|
+
${f(this.state)} ${J.message}
|
|
59
|
+
`,U=this.value??[];switch(this.state){case"submit":{let F=this.options.filter(({value:j})=>U.includes(j)).map((j)=>Q(j,"submitted")),X=F.length===0?"":` ${F.join(z.dim(", "))}`;return`${q}${z.gray(H)}${X}`}case"cancel":{let F=this.options.filter(({value:X})=>U.includes(X)).map((X)=>Q(X,"cancelled")).join(z.dim(", "));return`${q}${z.gray(H)} ${F.trim()?`${F}
|
|
60
|
+
${z.gray(H)}`:""}`}case"error":{let F=this.error.split(`
|
|
61
|
+
`).map((X,j)=>j===0?`${z.yellow(x)} ${z.yellow(X)}`:` ${X}`).join(`
|
|
62
|
+
`);return`${q}${z.yellow(H)} ${this.options.map((X,j,G)=>{let V=U.includes(X.value)||X.group===!0&&this.isGroupSelected(`${X.value}`),W=j===this.cursor;if(!W&&typeof X.group==="string"&&this.options[this.cursor].value===X.group)return Q(X,V?"group-active-selected":"group-active",G);if(W&&V)return Q(X,"active-selected",G);if(V)return Q(X,"selected",G);return Q(X,W?"active":"inactive",G)}).join(`
|
|
63
|
+
${z.yellow(H)} `)}
|
|
64
|
+
${F}
|
|
65
|
+
`}default:{let F=this.options.map((j,G,V)=>{let W=U.includes(j.value)||j.group===!0&&this.isGroupSelected(`${j.value}`),K=G===this.cursor,L=!K&&typeof j.group==="string"&&this.options[this.cursor].value===j.group,P="";if(L)P=Q(j,W?"group-active-selected":"group-active",V);else if(K&&W)P=Q(j,"active-selected",V);else if(W)P=Q(j,"selected",V);else P=Q(j,K?"active":"inactive",V);return`${G!==0&&!P.startsWith(`
|
|
66
|
+
`)?" ":""}${P}`}).join(`
|
|
67
|
+
${z.cyan(H)}`),X=F.startsWith(`
|
|
68
|
+
`)?"":" ";return`${q}${z.cyan(H)}${X}${F}
|
|
69
|
+
${z.cyan(x)}
|
|
70
|
+
`}}}}).prompt()}function m0(J){if(Array.isArray(J))return J.map((Z)=>n(Z));return n(J)}var k={message:(J=[],{symbol:Z=z.gray(H),secondarySymbol:$=z.gray(H),output:Q=f0.stdout,spacing:Y=1}={})=>{let q=[];for(let X=0;X<Y;X++)q.push(`${$}`);let U=m0(J),F=Array.isArray(U)?U:U.split(`
|
|
71
|
+
`);if(F.length>0){let[X,...j]=F;if(X.length>0)q.push(`${Z} ${X}`);else q.push(Z);for(let G of j)if(G.length>0)q.push(`${$} ${G}`);else q.push($)}Q.write(`${q.join(`
|
|
72
|
+
`)}
|
|
73
|
+
`)},info:(J,Z)=>{k.message(J,{...Z,symbol:z.blue(WZ)})},success:(J,Z)=>{k.message(J,{...Z,symbol:z.green(DZ)})},step:(J,Z)=>{k.message(J,{...Z,symbol:z.green(t)})},warn:(J,Z)=>{k.message(J,{...Z,symbol:z.yellow(LZ)})},warning:(J,Z)=>{k.warn(J,Z)},error:(J,Z)=>{k.message(J,{...Z,symbol:z.red(MZ)})},custom:(J,Z,$,Q)=>{let Y=typeof $==="string"?(q)=>z[$]?.(q)||q:$;k.message(Z,{...Q,symbol:Y(J),secondarySymbol:Y(J)})}};function m$(J="",Z){(Z?.output??xJ.stdout).write(`${z.gray(x)} ${z.red(J)}
|
|
74
|
+
|
|
75
|
+
`)}function d$(J="",Z){(Z?.output??xJ.stdout).write(`${z.gray(C0)} ${J}
|
|
76
|
+
`)}function u$(J="",Z){(Z?.output??xJ.stdout).write(`${z.gray(H)}
|
|
77
|
+
${z.gray(x)} ${J}
|
|
78
|
+
|
|
79
|
+
`)}function c$(J){let Z=(Q,Y)=>{let q=Q.label??String(Q.value);if(Y==="active")return`${z.cyan(OJ)} ${q}${Q.hint?` ${z.dim(`(${Q.hint})`)}`:""}`;if(Y==="selected")return`${z.green(s)} ${z.dim(q)}${Q.hint?` ${z.dim(`(${Q.hint})`)}`:""}`;if(Y==="cancelled")return`${z.strikethrough(z.dim(q))}`;if(Y==="active-selected")return`${z.green(s)} ${q}${Q.hint?` ${z.dim(`(${Q.hint})`)}`:""}`;if(Y==="submitted")return`${z.dim(q)}`;return`${z.dim(RJ)} ${z.dim(q)}`},$=J.required??!0;return new XZ({options:J.options,input:J.input,output:J.output,initialValues:J.initialValues,required:$,cursorAt:J.cursorAt,validate(Q){if($&&(Q===void 0||Q.length===0))return`Please select at least one option.
|
|
80
|
+
${z.reset(z.dim(`Press ${z.gray(z.bgWhite(z.inverse(" space ")))} to select, ${z.gray(z.bgWhite(z.inverse(" enter ")))} to submit`))}`},render(){let Q=`${z.gray(H)}
|
|
81
|
+
${f(this.state)} ${J.message}
|
|
82
|
+
`,Y=this.value??[],q=(U,F)=>{let X=Y.includes(U.value);if(F&&X)return Z(U,"active-selected");if(X)return Z(U,"selected");return Z(U,F?"active":"inactive")};switch(this.state){case"submit":return`${Q}${z.gray(H)} ${this.options.filter(({value:U})=>Y.includes(U)).map((U)=>Z(U,"submitted")).join(z.dim(", "))||z.dim("none")}`;case"cancel":{let U=this.options.filter(({value:F})=>Y.includes(F)).map((F)=>Z(F,"cancelled")).join(z.dim(", "));return`${Q}${z.gray(H)}${U.trim()?` ${U}
|
|
83
|
+
${z.gray(H)}`:""}`}case"error":{let U=this.error.split(`
|
|
84
|
+
`).map((F,X)=>X===0?`${z.yellow(x)} ${z.yellow(F)}`:` ${F}`).join(`
|
|
85
|
+
`);return`${Q+z.yellow(H)} ${ZJ({output:J.output,options:this.options,cursor:this.cursor,maxItems:J.maxItems,style:q}).join(`
|
|
86
|
+
${z.yellow(H)} `)}
|
|
87
|
+
${U}
|
|
88
|
+
`}default:return`${Q}${z.cyan(H)} ${ZJ({output:J.output,options:this.options,cursor:this.cursor,maxItems:J.maxItems,style:q}).join(`
|
|
89
|
+
${z.cyan(H)} `)}
|
|
90
|
+
${z.cyan(x)}
|
|
91
|
+
`}}}).prompt()}var u0=(J)=>z.dim(J);function n$(J="",Z="",$){let Q=$?.format??u0,Y=n(J),q=n(Z),U=["",...Y.split(`
|
|
92
|
+
`).map(Q),""],F=WJ(q).length,X=$?.output??d0.stdout,j=Math.max(U.reduce((V,W)=>{let K=WJ(W);return K.length>V?K.length:V},0),F)+2,G=U.map((V)=>`${z.gray(H)} ${V}${" ".repeat(j-WJ(V).length)}${z.gray(H)}`).join(`
|
|
93
|
+
`);X.write(`${z.gray(H)}
|
|
94
|
+
${z.green(t)} ${z.reset(q)} ${z.gray(fJ.repeat(Math.max(j-F-1,1))+h0)}
|
|
95
|
+
${G}
|
|
96
|
+
${z.gray(b0+fJ.repeat(j+2)+v0)}
|
|
97
|
+
`)}function l$(J){return new UZ({validate:J.validate,mask:J.mask??k0,signal:J.signal,input:J.input,output:J.output,render(){let Z=`${z.gray(H)}
|
|
98
|
+
${f(this.state)} ${J.message}
|
|
99
|
+
`,$=this.userInputWithCursor,Q=this.masked;switch(this.state){case"error":{let Y=Q?` ${Q}`:"";return`${Z.trim()}
|
|
100
|
+
${z.yellow(H)}${Y}
|
|
101
|
+
${z.yellow(x)} ${z.yellow(this.error)}
|
|
102
|
+
`}case"submit":{let Y=Q?` ${z.dim(Q)}`:"";return`${Z}${z.gray(H)}${Y}`}case"cancel":{let Y=Q?` ${z.strikethrough(z.dim(Q))}`:"";return`${Z}${z.gray(H)}${Y}${Q?`
|
|
103
|
+
${z.gray(H)}`:""}`}default:return`${Z}${z.cyan(H)} ${$}
|
|
104
|
+
${z.cyan(x)}
|
|
105
|
+
`}}}).prompt()}function t$(J){let Z=J.validate;return _0({...J,initialUserInput:J.initialValue??J.root??n0.cwd(),maxItems:5,validate($){if(Array.isArray($))return;if(!$)return"Please select a path";if(Z)return Z($);return},options(){let $=this.userInput;if($==="")return[];try{let Q;if(!c0($))Q=uJ($);else if(dJ($).isDirectory())Q=$;else Q=uJ($);return p0(Q).map((q)=>{let U=i0(Q,q),F=dJ(U);return{name:q,path:U,isDirectory:F.isDirectory()}}).filter(({path:q,isDirectory:U})=>q.startsWith($)&&(J.directory||!U)).map((q)=>({value:q.path}))}catch(Q){return console.error("Error reading directory:",Q),[]}}})}function NZ({indicator:J="dots",onCancel:Z,output:$=b.stdout,cancelMessage:Q,errorMessage:Y,frames:q=wJ?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:U=wJ?80:120,signal:F}={}){let X=HZ(),j,G,V=!1,W=!1,K="",L,P=performance.now();function D(){if(L===void 0)return;if(X)$.write(`
|
|
106
|
+
`);let R=L.split(`
|
|
107
|
+
`);$.write(C.move(-999,R.length-1)),$.write(JJ.down(R.length))}function M(R){return R.replace(/\.+$/,"")}function E(R){let h=(performance.now()-R)/1000,S=Math.floor(h/60),l=Math.floor(h%60);return S>0?`[${S}m ${l}s]`:`[${l}s]`}function N(R="",h=0){V=!1,clearInterval(G),D();let S=h===0?z.green(t):h===1?z.red(KZ):z.red(VZ);if(K=R??K,J==="timer")$.write(`${S} ${K} ${E(P)}
|
|
108
|
+
`);else $.write(`${S} ${K}
|
|
109
|
+
`);QJ(),j()}function I(R){let h=R>1?Y??v.messages.error:Q??v.messages.cancel;if(W=R===1,V){if(N(h,R),W&&typeof Z==="function")Z()}}function A(){I(2)}function g(){I(1)}function $J(){b.on("uncaughtExceptionMonitor",A),b.on("unhandledRejection",A),b.on("SIGINT",g),b.on("SIGTERM",g),b.on("exit",I)}function QJ(){if(b.removeListener("uncaughtExceptionMonitor",A),b.removeListener("unhandledRejection",A),b.removeListener("SIGINT",g),b.removeListener("SIGTERM",g),b.removeListener("exit",I),F)F.removeEventListener("abort",g)}function OZ(R=""){V=!0,j=L0({output:$}),K=M(R),P=performance.now(),$.write(`${z.gray(H)}
|
|
110
|
+
`);let h=0,S=0;$J(),G=setInterval(()=>{if(X&&K===L)return;D(),L=K;let l=z.magenta(q[h]);if(X)$.write(`${l} ${K}...`);else if(J==="timer")$.write(`${l} ${K} ${E(P)}`);else{let BZ=".".repeat(Math.floor(S)).slice(0,3);$.write(`${l} ${K}${BZ}`)}h=h+1<q.length?h+1:0,S=S<4?S+0.125:0},U)}function TZ(R=""){K=M(R??K)}return{start:OZ,stop:N,message:TZ,get isCancelled(){return W}}}var cJ={light:O("\u2500","-"),heavy:O("\u2501","="),block:O("\u2588","#")};function e$(J={}){let{style:Z="heavy",max:$=100,size:Q=40,...Y}=J,q=NZ(Y),U=0,F="",X=Math.max(1,$),j=Math.max(1,Q),G=(L)=>{switch(L){case"initial":case"active":return z.magenta;case"error":case"cancel":return z.red;case"submit":return z.green;default:return z.magenta}},V=(L,P)=>{let D=Math.floor(U/X*j);return`${G(L)(cJ[Z].repeat(D))}${z.dim(cJ[Z].repeat(j-D))} ${P}`},W=(L="")=>{return F=L,q.start(V("initial",L))},K=(L=1,P)=>{U=Math.min(X,L+U),q.message(V("active",P??F)),F=P??F};return{start:W,stop:q.stop,advance:K,isCancelled:q.isCancelled,message:(L)=>K(0,L)}}function JQ(J){let Z=n(J.message),$=(Q,Y)=>{let q=Q.label??String(Q.value);switch(Y){case"selected":return`${z.dim(q)}`;case"active":return`${z.green(FJ)} ${q}${Q.hint?` ${z.dim(`(${Q.hint})`)}`:""}`;case"cancelled":return`${z.strikethrough(z.dim(q))}`;default:return`${z.dim(jJ)} ${z.dim(q)}`}};return new FZ({options:J.options,signal:J.signal,input:J.input,output:J.output,initialValue:J.initialValue,render(){let Q=`${z.gray(H)}
|
|
111
|
+
${f(this.state)} ${Z}
|
|
112
|
+
`;switch(this.state){case"submit":return`${Q}${z.gray(H)} ${$(this.options[this.cursor],"selected")}`;case"cancel":return`${Q}${z.gray(H)} ${$(this.options[this.cursor],"cancelled")}
|
|
113
|
+
${z.gray(H)}`;default:return`${Q}${z.cyan(H)} ${ZJ({output:J.output,cursor:this.cursor,options:this.options,maxItems:J.maxItems,style:(Y,q)=>$(Y,q?"active":"inactive")}).join(`
|
|
114
|
+
${z.cyan(H)} `)}
|
|
115
|
+
${z.cyan(x)}
|
|
116
|
+
`}}}).prompt()}function ZQ(J){let Z=($,Q="inactive")=>{let Y=$.label??String($.value);if(Q==="selected")return`${z.dim(Y)}`;if(Q==="cancelled")return`${z.strikethrough(z.dim(Y))}`;if(Q==="active")return`${z.bgCyan(z.gray(` ${$.value} `))} ${Y} ${$.hint?z.dim(`(${$.hint})`):""}`;return`${z.gray(z.bgWhite(z.inverse(` ${$.value} `)))} ${Y} ${$.hint?z.dim(`(${$.hint})`):""}`};return new jZ({options:J.options,signal:J.signal,input:J.input,output:J.output,initialValue:J.initialValue,render(){let $=`${z.gray(H)}
|
|
117
|
+
${f(this.state)} ${J.message}
|
|
118
|
+
`;switch(this.state){case"submit":return`${$}${z.gray(H)} ${Z(this.options.find((Q)=>Q.value===this.value)??J.options[0],"selected")}`;case"cancel":return`${$}${z.gray(H)} ${Z(this.options[0],"cancelled")}
|
|
119
|
+
${z.gray(H)}`;default:return`${$}${z.cyan(H)} ${this.options.map((Q,Y)=>Z(Q,Y===this.cursor?"active":"inactive")).join(`
|
|
120
|
+
${z.cyan(H)} `)}
|
|
121
|
+
${z.cyan(x)}
|
|
122
|
+
`}}}).prompt()}function l0(){return`${z.gray(H)} `}var pJ=l0(),r={message:async(J,{symbol:Z=z.gray(H)}={})=>{e.stdout.write(`${z.gray(H)}
|
|
123
|
+
${Z} `);let $=3;for await(let Q of J){if(Q=Q.replace(/\n/g,`
|
|
124
|
+
${pJ}`),Q.includes(`
|
|
125
|
+
`))$=3+DJ(Q.slice(Q.lastIndexOf(`
|
|
126
|
+
`))).length;let Y=DJ(Q).length;if($+Y<e.stdout.columns)$+=Y,e.stdout.write(Q);else e.stdout.write(`
|
|
127
|
+
${pJ}${Q.trimStart()}`),$=3+DJ(Q.trimStart()).length}e.stdout.write(`
|
|
128
|
+
`)},info:(J)=>{return r.message(J,{symbol:z.blue(WZ)})},success:(J)=>{return r.message(J,{symbol:z.green(DZ)})},step:(J)=>{return r.message(J,{symbol:z.green(t)})},warn:(J)=>{return r.message(J,{symbol:z.yellow(LZ)})},warning:(J)=>{return r.warn(J)},error:(J)=>{return r.message(J,{symbol:z.red(MZ)})}};async function zQ(J,Z){for(let $ of J){if($.enabled===!1)continue;let Q=NZ(Z);Q.start($.title);let Y=await $.task(Q.message);Q.stop(Y||$.title)}}function qQ(J){let Z=J.output??r0.stdout,$=M0(Z),Q=ZZ(H),Y=J.spacing??1,q=3,U=J.retainLog===!0,F=!HZ()&&R0(Z);Z.write(`${Q}
|
|
129
|
+
`),Z.write(`${JZ(t)} ${J.title}
|
|
130
|
+
`);for(let D=0;D<Y;D++)Z.write(`${Q}
|
|
131
|
+
`);let X=[{value:"",full:""}],j=!1,G=(D)=>{if(X.length===0)return;let M=0;if(D)M+=Y+2;for(let E of X){let{value:N,result:I}=E,A=I?.message??N;if(A.length===0)continue;if(I===void 0&&E.header!==void 0&&E.header!=="")A+=`
|
|
132
|
+
${E.header}`;let g=A.split(`
|
|
133
|
+
`).reduce(($J,QJ)=>{if(QJ==="")return $J+1;return $J+Math.ceil((QJ.length+3)/$)},0);M+=g}if(M>0)M+=1,Z.write(JJ.lines(M))},V=(D,M,E)=>{let N=E?`${D.full}
|
|
134
|
+
${D.value}`:D.value;if(D.header!==void 0&&D.header!=="")k.message(D.header.split(`
|
|
135
|
+
`).map($Z),{output:Z,secondarySymbol:Q,symbol:Q,spacing:0});k.message(N.split(`
|
|
136
|
+
`).map(QZ),{output:Z,secondarySymbol:Q,symbol:Q,spacing:M??Y})},W=()=>{for(let D of X){let{header:M,value:E,full:N}=D;if((M===void 0||M.length===0)&&E.length===0)continue;V(D,void 0,U===!0&&N.length>0)}},K=()=>{for(let D of X)if(D.result)if(D.result.status==="error")k.error(D.result.message,{output:Z,secondarySymbol:Q,spacing:0});else k.success(D.result.message,{output:Z,secondarySymbol:Q,spacing:0});else if(D.value!=="")V(D,0)},L=(D,M,E)=>{if(G(!1),(E?.raw!==!0||!j)&&D.value!=="")D.value+=`
|
|
137
|
+
`;if(D.value+=M,j=E?.raw===!0,J.limit!==void 0){let N=D.value.split(`
|
|
138
|
+
`),I=N.length-J.limit;if(I>0){let A=N.splice(0,I);if(U)D.full+=(D.full===""?"":`
|
|
139
|
+
`)+A.join(`
|
|
140
|
+
`)}D.value=N.join(`
|
|
141
|
+
`)}if(F)K()},P=(D,M)=>{if(G(!1),D.result=M,F)K()};return{message(D,M){L(X[0],D,M)},group(D){let M={header:D,value:"",full:""};return X.push(M),{message(E,N){L(M,E,N)},error(E){P(M,{status:"error",message:E})},success(E){P(M,{status:"success",message:E})}}},error(D,M){if(G(!0),k.error(D,{output:Z,secondarySymbol:Q,spacing:1}),M?.showLog!==!1)W();X.splice(1,X.length-1),X[0].value="",X[0].full=""},success(D,M){if(G(!0),k.success(D,{output:Z,secondarySymbol:Q,spacing:1}),M?.showLog===!0)W();X.splice(1,X.length-1),X[0].value="",X[0].full=""}}}function XQ(J){let Z=n(J.message);return new GZ({validate:J.validate,placeholder:J.placeholder,defaultValue:J.defaultValue,initialValue:J.initialValue,output:J.output,signal:J.signal,input:J.input,render(){let $=`${z.gray(H)}
|
|
142
|
+
${f(this.state)} ${Z}
|
|
143
|
+
`,Q=J.placeholder?z.inverse(J.placeholder[0])+z.dim(J.placeholder.slice(1)):z.inverse(z.hidden("_")),Y=!this.userInput?Q:this.userInputWithCursor,q=this.value??"";switch(this.state){case"error":{let U=this.error?` ${z.yellow(this.error)}`:"";return`${$.trim()}
|
|
144
|
+
${z.yellow(H)} ${Y}
|
|
145
|
+
${z.yellow(x)}${U}
|
|
146
|
+
`}case"submit":{let F=(this.userInput||q!==J.placeholder)&&q?` ${z.dim(q)}`:"";return`${$}${z.gray(H)}${F}`}case"cancel":{let U=q?` ${z.strikethrough(z.dim(q))}`:"";return`${$}${z.gray(H)}${U}${q.trim()?`
|
|
147
|
+
${z.gray(H)}`:""}`}default:return`${$}${z.cyan(H)} ${Y}
|
|
148
|
+
${z.cyan(x)}
|
|
149
|
+
`}}}).prompt()}class TJ extends t0{buffer=[];_write(J,Z,$){this.buffer.push(J.toString()),$()}}class wZ extends s0{_buffer=[];_read(){if(this._buffer===null){this.push(null);return}for(let J of this._buffer)this.push(J);this._buffer=[]}pushValue(J){this._buffer?.push(J)}close(){this._buffer=null}}function VQ(J={}){return tJ(J.name||"")}function o0(){let J=new TJ,Z=new TJ,$=new wZ,Q=w.exit,Y=w.stdout,q=w.stderr,U=w.stdin,F=console.log;return w.exit=(X)=>{throw Error(`Process exit with code: ${X||0}`)},Object.defineProperty(w,"stdout",{value:J,writable:!0}),Object.defineProperty(w,"stderr",{value:Z,writable:!0}),Object.defineProperty(w,"stdin",{value:$,writable:!0}),{stdout:J,stderr:Z,stdin:$,originalExit:Q,originalStdout:Y,originalStderr:q,originalStdin:U,originalConsoleLog:F}}function e0(J){w.exit=J.originalExit,Object.defineProperty(w,"stdout",{value:J.originalStdout,writable:!0}),Object.defineProperty(w,"stderr",{value:J.originalStderr,writable:!0}),Object.defineProperty(w,"stdin",{value:J.originalStdin,writable:!0}),console.log=J.originalConsoleLog}async function WQ(J,Z,$={}){let Q=Date.now(),{inputs:Y=[],env:q={},cwd:U=w.cwd(),timeout:F=5000}=$,X=o0(),{stdin:j,stdout:G,stderr:V}=X,W=Z.includes("--help")||Z.includes("-h"),K=[];if(w.stdout.write=function(N){let I=N.toString();return K.push(I),G.write(I),!0},console.log=function(...N){let I=N.map((A)=>String(A)).join(" ");K.push(`${I}
|
|
150
|
+
`),G.write(`${I}
|
|
151
|
+
`);return},Y.length>0)for(let N of Y)j.pushValue(`${N}
|
|
152
|
+
`);let L={...w.env},P=w.cwd();if(Object.entries(q).forEach(([N,I])=>{w.env[N]=I}),U!==P)w.chdir(U);let D,M=0;try{let N=new Promise((A,g)=>{setTimeout(()=>g(Error("Command execution timed out")),F)}),I=Promise.resolve().then(async()=>{try{if(J.showHelpOnExit=!1,J.showVersionOnExit=!1,await J.parse(["node","cli",...Z],{run:!1}),W)J.outputHelp();return D=await J.runMatchedCommand(),D}catch(A){throw M=1,V.write(`${A}
|
|
153
|
+
`),A}});await Promise.race([I,N])}catch(N){if(N.message==="Command execution timed out")throw N}finally{if(w.env=L,U!==P)w.chdir(P);e0(X)}let E=Date.now()-Q;if(W)M=0;return{stdout:K.join(""),stderr:V.buffer.join(""),exitCode:M,duration:E,outputs:[...K],result:D}}var u=null;function DQ(J){u=J}function LQ(J){if(!u)return;if(J in u)return u[J];for(let[Z,$]of Object.entries(u))if(Z.startsWith("/")&&Z.endsWith("/i")){let Q=Z.slice(1,-2);if(new RegExp(Q,"i").test(J))return $}else if(Z.startsWith("/")&&Z.endsWith("/")){let Q=Z.slice(1,-1);if(new RegExp(Q).test(J))return $}if("*"in u)return u["*"];return}function MQ(){u=null}var GJ=null;function PQ(){let J=[],Z=[],$=w.stdout.write,Q=w.stderr.write;w.stdout.write=function(q){return J.push(q.toString()),!0},w.stderr.write=function(q){return Z.push(q.toString()),!0};let Y={stdout:J,stderr:Z,stop:()=>{return w.stdout.write=$,w.stderr.write=Q,GJ=null,{stdout:J.join(""),stderr:Z.join("")}}};return GJ=Y,Y}function NQ(){if(!GJ)throw Error("No output capture in progress. Call captureOutput() first.");return GJ.stdout.join("")}async function wQ(J){let Z=await y.mkdtemp(XJ.join(a0.tmpdir(),"clapp-test-")),$=async(Q,Y)=>{for(let[q,U]of Object.entries(Y)){let F=XJ.join(Q,q);if(typeof U==="object"&&!iJ.isBuffer(U))if(q.endsWith("/"))await y.mkdir(F,{recursive:!0}),await $(F,U);else await y.mkdir(F,{recursive:!0}),await $(F,U);else{let X=XJ.dirname(F);if(await y.mkdir(X,{recursive:!0}),iJ.isBuffer(U))await y.writeFile(F,U);else if(typeof U==="string")await y.writeFile(F,U,"utf8");else await y.writeFile(F,JSON.stringify(U),"utf8")}}};return await $(Z,J),Z}async function OQ(J){let Z=async($)=>{let Q=await y.readdir($,{withFileTypes:!0});for(let Y of Q){let q=XJ.join($,Y.name);if(Y.isDirectory())await Z(q);else await y.unlink(q)}await y.rmdir($)};await Z(J)}var TQ={outputToContain(J,Z){if(!J.stdout.includes(Z))throw Error(`Expected output to contain "${Z}", but got:
|
|
154
|
+
${J.stdout}`)},outputToMatch(J,Z){if(!Z.test(J.stdout))throw Error(`Expected output to match ${Z}, but got:
|
|
155
|
+
${J.stdout}`)},exitCode(J,Z){if(J.exitCode!==Z)throw Error(`Expected exit code ${Z}, but got ${J.exitCode}`)},completedWithin(J,Z){if(J.duration>Z)throw Error(`Expected command to complete within ${Z}ms, but took ${J.duration}ms`)},outputNotToContain(J,Z){if(J.stdout.includes(Z))throw Error(`Expected output not to contain "${Z}", but it did`)},stderrToContain(J,Z){if(!J.stderr.includes(Z))throw Error(`Expected stderr to contain "${Z}", but got:
|
|
156
|
+
${J.stderr}`)}},BQ=tJ;export{R$ as updateSettings,O as unicodeOr,wJ as unicode,PJ as themes,XQ as text,Y$ as telemetry,e0 as teardownTest,zQ as tasks,qQ as taskLog,N$ as table,f as symbol,i as style,r as stream,NZ as spinner,o0 as setupTest,v as settings,dZ as setTheme,zJ as setRawMode,kZ as setDotProp,hZ as setByType,L$ as setAccessibility,ZQ as selectKey,JQ as select,j$ as scroll,MQ as resetMockPrompts,LJ as removeBrackets,e$ as progress,n as processMarkdown,t$ as path,l$ as password,P$ as panel,VJ as padRight,u$ as outro,T$ as onUnknownSubcommand,n$ as note,c$ as multiselect,DQ as mockPrompt,k as log,ZJ as limitOptions,SZ as levenshteinDistance,vZ as isUnicodeSupported,R0 as isTTY,D0 as isCancel,HZ as isCI,IJ as isActionKey,d$ as intro,g$ as groupMultiselect,y$ as group,xZ as getMriOptions,LQ as getMockResponse,NQ as getLastOutput,bZ as getFileName,M0 as getColumns,D$ as getAvailableThemes,rJ as findSimilarCommands,hJ as findLongest,RZ as findAllBrackets,TQ as expect,WQ as execCommand,JJ as erase,V0 as diffLines,BQ as default,C as cursor,wQ as createTestFS,VQ as createTestCLI,S$ as confirm,d as codes,w$ as cliCache,tJ as cli,G$ as clear,OQ as cleanupTestFS,PQ as captureOutput,m$ as cancel,lJ as camelcaseOptionName,CZ as camelcase,M$ as box,L0 as block,F$ as beep,v$ as autocompleteMultiselect,_0 as autocomplete,W$ as applyTheme,LZ as S_WARN,DZ as S_SUCCESS,t as S_STEP_SUBMIT,VZ as S_STEP_ERROR,KZ as S_STEP_CANCEL,x0 as S_STEP_ACTIVE,jJ as S_RADIO_INACTIVE,FJ as S_RADIO_ACTIVE,k0 as S_PASSWORD_MASK,WZ as S_INFO,MZ as S_ERROR,h0 as S_CORNER_TOP_RIGHT,v0 as S_CORNER_BOTTOM_RIGHT,b0 as S_CONNECT_LEFT,s as S_CHECKBOX_SELECTED,RJ as S_CHECKBOX_INACTIVE,OJ as S_CHECKBOX_ACTIVE,C0 as S_BAR_START,fJ as S_BAR_H,x as S_BAR_END,H as S_BAR,EJ as GlobalCommand,UJ as ESC,BJ as Command,YJ as ClappError,T as CSI,sJ as CLI,NJ as CANCEL_SYMBOL};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tb as c,ub as d,vb as e}from"./chunk-y4g1csn2.js";import"./chunk-ft0nf9jb.js";import"./chunk-2n1bbm2c.js";import{ic as a,jc as b}from"./chunk-bymtns9a.js";import"./chunk-y2pe3jq3.js";import"./chunk-4mtbtmee.js";import"./chunk-vx4a5crm.js";import"./chunk-xw9wfq8f.js";import"./chunk-7hy98p24.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{e as watch,a as processSource,d as processFile,c as generate,b as clearResultCache};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ac as u,Bc as v,Cc as w,pc as j,qc as k,rc as l,sc as m,tc as n,uc as o,vc as p,wc as q,xc as r,yc as s,zc as t}from"./chunk-
|
|
2
|
+
import{Ac as u,Bc as v,Cc as w,pc as j,qc as k,rc as l,sc as m,tc as n,uc as o,vc as p,wc as q,xc as r,yc as s,zc as t}from"./chunk-vx4a5crm.js";import{Fc as a,Gc as b,Hc as c,Ic as d,Jc as e,Kc as f,Lc as g,Mc as h,Nc as i}from"./chunk-xw9wfq8f.js";import"./chunk-mcdb3q06.js";export{l as processVariableDeclaration,n as processTypeDeclaration,s as processModuleDeclaration,m as processInterfaceDeclaration,q as processImportDeclaration,k as processFunctionDeclaration,r as processExportDeclaration,p as processEnumDeclaration,w as processDeclarations,o as processClassDeclaration,u as parseImportStatement,d as parseArrayElements,h as isGenericType,e as inferObjectType,b as inferNarrowTypeInUnion,a as inferNarrowType,g as inferFunctionType,c as inferArrayType,j as formatComments,f as findMatchingBracket,i as extractSatisfiesType,v as extractAllImportedItems,t as clearProcessorCaches};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ic as a,jc as b,kc as c}from"./chunk-bymtns9a.js";import"./chunk-y2pe3jq3.js";import"./chunk-4mtbtmee.js";import"./chunk-vx4a5crm.js";import"./chunk-xw9wfq8f.js";import"./chunk-mcdb3q06.js";export{c as processSourceDirect,a as processSource,b as clearResultCache};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as K}from"./chunk-
|
|
2
|
+
import{tb as K}from"./chunk-y4g1csn2.js";function L(N={}){let{buildStart:P=!0,buildEnd:Q=!1,writeBundle:T=!1,modes:y,onGenerated:U,onError:H,...W}=N,I="production",z=async()=>{try{let q=await K(W);U?.(q)}catch(q){let J=q instanceof Error?q:Error(String(q));if(H?.(J),!H)console.error("[dtsx] Generation failed:",J.message)}},F=()=>{if(!y||y.length===0)return!0;return y.includes(I)};return{name:"dtsx",apply(q){return I=q.mode,!0},async buildStart(){if(P&&F())await z()},async buildEnd(){if(Q&&F())await z()},async writeBundle(){if(T&&F())await z()}}}var Y=L,_=L;
|
|
3
3
|
export{L as ca,Y as da,_ as ea};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{hc as E}from"./chunk-2n1bbm2c.js";import{lc as c,mc as Bq,nc as Oq}from"./chunk-y2pe3jq3.js";import{Fc as Rq}from"./chunk-xw9wfq8f.js";import{bd as N}from"./chunk-mcdb3q06.js";var L=N(E(),1);var A=N(E(),1);var v=new Map,T=new Map,Lq=100;function _q(){while(v.size>Lq){let q=v.keys().next().value;if(q===void 0)break;v.delete(q)}}function wq(){v.clear()}function Iq(){return v.size}var Yq={asyncThreshold:1e5,chunkSize:50000,yieldInterval:0};function l(q){return new Promise(($)=>{if(q===0)if(typeof setImmediate<"u")setImmediate($);else setTimeout($,0);else setTimeout($,q)})}async function vq(q,$,Q){if($.length<Q.asyncThreshold)return A.createSourceFile(q,$,A.ScriptTarget.Latest,!0,A.ScriptKind.TS);await l(Q.yieldInterval);let W=A.createSourceFile(q,$,A.ScriptTarget.Latest,!1,A.ScriptKind.TS);return await l(Q.yieldInterval),W}async function h(q,$,Q={}){let W={...Yq,...Q},X=c($),Z=q,U=Date.now(),V=v.get(Z);if(V&&V.contentHash===X)return V.lastAccess=U,v.delete(Z),v.set(Z,V),V.sourceFile;let j=T.get(Z);if(j)return j;let w=(async()=>{try{let H=await vq(q,$,W);return v.set(Z,{sourceFile:H,contentHash:X,lastAccess:U}),_q(),H}finally{T.delete(Z)}})();return T.set(Z,w),w}async function Aq(q,$={}){let Q=$.concurrency??4,W=new Map,X=[];for(let Z=0;Z<q.length;Z+=Q){let U=q.slice(Z,Z+Q),V=await Promise.allSettled(U.map(async({filePath:j,sourceCode:w})=>{let H=await h(j,w,$);return{filePath:j,sourceFile:H}}));for(let j=0;j<V.length;j++){let w=V[j];if(w.status==="fulfilled")W.set(w.value.filePath,w.value.sourceFile);else X.push({filePath:U[j].filePath,error:w.reason})}if(Z+Q<q.length)await l(0)}if(X.length>0)console.warn(`[dtsx] ${X.length} file(s) failed to parse:`,X.map((Z)=>Z.filePath));return W}function kq(q,$={}){let Q=$.asyncThreshold??Yq.asyncThreshold;return q.length>=Q}function Kq(){return T.size}var R=N(E(),1);var Y=N(E(),1);var O=N(E(),1);function M(q,$,Q){return $.slice(Q?q.getStart(Q):q.getStart(),q.getEnd())}var Hq=/\/\*[\s\S]*?\*\//g;function I(q,$){let Q=[],W=q.getFullStart(),X=q.getStart($);if(W===X)return Q;let Z=$.text.substring(W,X);if(Z.indexOf("/*")!==-1){Hq.lastIndex=0;let U;while((U=Hq.exec(Z))!==null)Q.push(U[0])}if(Z.indexOf("//")!==-1){let U=Z.split(`
|
|
3
|
+
`),V=[];for(let j=U.length-1;j>=0;j--){let w=U[j].trim();if(w.startsWith("//"))V.unshift(w);else if(w==="")continue;else break}if(V.length>0)Q.push(V.join(`
|
|
4
|
+
`))}return Q}function k(q,$){if(O.isObjectBindingPattern(q.name)){let Q=q.name.elements.map((W)=>{if(O.isBindingElement(W)&&O.isIdentifier(W.name))return W.name.getText($);return""}).filter(Boolean);if(Q.length>3)return`{
|
|
5
|
+
${Q.join(`,
|
|
6
|
+
`)},
|
|
7
|
+
}`;return`{ ${Q.join(", ")} }`}else if(O.isArrayBindingPattern(q.name))return`[${q.name.elements.map((W)=>{if(W&&O.isBindingElement(W)&&O.isIdentifier(W.name))return W.name.getText($);return""}).filter(Boolean).join(", ")}]`;else return q.name.getText($)}function B(q){if(!("modifiers"in q)||!q.modifiers)return!1;return q.modifiers.some((Q)=>Q.kind===O.SyntaxKind.ExportKeyword)}function g(q){if(!("modifiers"in q)||!q.modifiers)return!1;return q.modifiers.some((Q)=>Q.kind===O.SyntaxKind.DefaultKeyword)}function d(q){return q.modifiers?.some(($)=>$.kind===O.SyntaxKind.AsyncKeyword)||!1}function m(q,$){return!1}var S=new Map;function i(q,$){let Q=S.get(q);if(!Q){let W=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(Q={funcPattern:new RegExp(`export\\s+[^\\n]*:\\s*[^\\n]*\\b${W}\\b`,"gm"),typePattern:new RegExp(`export\\s+[^\\n]*\\b${W}\\b`,"gm")},S.set(q,Q),S.size>200){let X=Array.from(S.keys()).slice(0,50);for(let Z of X)S.delete(Z)}}return Q.funcPattern.lastIndex=0,Q.typePattern.lastIndex=0,Q.funcPattern.test($)||Q.typePattern.test($)}var Mq=new Set(["string","number","boolean","object","any","unknown","never","void","undefined","null","Array","Promise","Record","Partial","Required","Pick","Omit","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Function","Date","RegExp","Error","Map","Set","WeakMap","WeakSet","T","K","V","U","R","P","E","A","B","C","D","F","G","H","I","J","L","M","N","O","Q","S","W","X","Y","Z"]);function t(q){return Mq.has(q)}var Jq=/(?:export\s+)?(?:declare\s+)?(?:const\s+)?(?:interface|type|class|enum)\s+([A-Z][a-zA-Z0-9]*)/g;function a(q){let $=[];Jq.lastIndex=0;let Q;while((Q=Jq.exec(q))!==null)$.push(Q[1]);return $}var Dq=/\s+as\s+(\S+)\s*$/;function K(q,$){let Q=q.trim();if(!Q.endsWith("as const")){let X=Q.match(Dq);if(X)return X[1]}let W=Rq(Q,$);if(W==="unknown")return"unknown";if(!$){if(W==="true"||W==="false")return"boolean";if(/^-?\d+(\.\d+)?$/.test(W))return"number";if(W.startsWith('"')&&W.endsWith('"')||W.startsWith("'")&&W.endsWith("'"))return"string"}return W}function n(q,$){let Q=[],W=q.modifiers?.some((j)=>j.kind===Y.SyntaxKind.AsyncKeyword),X=!!q.asteriskToken,Z=B(q)&&g(q);if(B(q))Q.push("export ");if(Z)Q.push("default function ");else Q.push("declare function ");if(q.name)Q.push(q.name.getText($));if(q.typeParameters){let j=q.typeParameters.map((w)=>w.getText($)).join(", ");Q.push("<",j,">")}let U=q.parameters.map((j)=>{let w=k(j,$),H=j.type?.getText($)||(j.initializer?K(j.initializer.getText($),!1):"unknown"),G=j.questionToken||j.initializer?"?":"";if(!!j.dotDotDotToken)return`...${w}: ${H}`;return`${w}${G}: ${H}`}).join(", ");Q.push("(",U,")");let V=q.type?.getText($);if(!V)if(W&&X)V="AsyncGenerator<unknown, void, unknown>";else if(X)V="Generator<unknown, void, unknown>";else if(W)V="Promise<void>";else V="void";return Q.push(": ",V,";"),Q.join("")}function s(q,$,Q,W){let X=[];if(W)X.push("export ");if(X.push("declare ",Q," ",q),$)X.push(": ",$);return X.push(";"),X.join("")}function r(q,$,Q){let W=[];if($)W.push("export ");if(W.push("declare interface ",q.name.getText(Q)),q.typeParameters){let Z=q.typeParameters.map((U)=>U.getText(Q)).join(", ");W.push("<",Z,">")}if(q.heritageClauses){let Z=q.heritageClauses.find((U)=>U.token===Y.SyntaxKind.ExtendsKeyword);if(Z){let U=Z.types.map((V)=>V.getText(Q)).join(", ");W.push(" extends ",U)}}let X=o(q,Q);return W.push(" ",X),W.join("")}function Gq(q,$){if(!q.name)return"";return q.name.getText($)}function o(q,$){let Q=[];for(let W of q.members)if(Y.isPropertySignature(W)){let X=Gq(W,$),Z=W.type?.getText($)||"unknown",U=W.questionToken?"?":"",V=W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.ReadonlyKeyword)?"readonly ":"";Q.push(` ${V}${X}${U}: ${Z}`)}else if(Y.isMethodSignature(W)){let X=Gq(W,$),Z="";if(W.typeParameters&&W.typeParameters.length>0)Z=`<${W.typeParameters.map((w)=>w.getText($)).join(", ")}>`;let U=W.parameters.map((w)=>{let H=w.name.getText($),G=w.type?.getText($)||"unknown",J=w.questionToken?"?":"";if(!!w.dotDotDotToken)return`...${H}: ${G}`;return`${H}${J}: ${G}`}).join(", "),V=W.type?.getText($)||"void",j=W.questionToken?"?":"";Q.push(` ${X}${j}${Z}(${U}): ${V}`)}else if(Y.isCallSignatureDeclaration(W)){let X=W.parameters.map((U)=>{let V=U.name.getText($),j=U.type?.getText($)||"unknown",w=U.questionToken?"?":"";if(!!U.dotDotDotToken)return`...${V}: ${j}`;return`${V}${w}: ${j}`}).join(", "),Z=W.type?.getText($)||"void";Q.push(` (${X}): ${Z}`)}else if(Y.isConstructSignatureDeclaration(W)){let X=W.parameters.map((U)=>{let V=U.name.getText($),j=U.type?.getText($)||"unknown",w=U.questionToken?"?":"";if(!!U.dotDotDotToken)return`...${V}: ${j}`;return`${V}${w}: ${j}`}).join(", "),Z=W.type?.getText($)||"unknown";Q.push(` new (${X}): ${Z}`)}else if(Y.isIndexSignatureDeclaration(W)){let X=W.parameters.map((U)=>{let V=U.name.getText($),j=U.type?.getText($)||"any";return`${V}: ${j}`}).join(", "),Z=W.type?.getText($)||"unknown";Q.push(` [${X}]: ${Z}`)}return`{
|
|
8
|
+
${Q.join(`
|
|
9
|
+
`)}
|
|
10
|
+
}`}function e(q,$,Q){let W=[];if($)W.push("export ");if(W.push("type ",q.name.getText(Q)),q.typeParameters){let X=q.typeParameters.map((Z)=>Z.getText(Q)).join(", ");W.push("<",X,">")}return W.push(" = ",q.type.getText(Q)),W.join("")}function qq(q,$,Q,W=!1){let X=[];if($)X.push("export ");if(W)X.push("default ");else X.push("declare ");if(q.modifiers?.some((j)=>j.kind===Y.SyntaxKind.AbstractKeyword))X.push("abstract ");if(X.push("class ",q.name?.getText(Q)||"AnonymousClass"),q.typeParameters){let j=q.typeParameters.map((w)=>w.getText(Q)).join(", ");X.push("<",j,">")}let U=q.heritageClauses?.find((j)=>j.token===Y.SyntaxKind.ExtendsKeyword)?.types[0]?.getText(Q);if(U)X.push(" extends ",U);let V=q.heritageClauses?.find((j)=>j.token===Y.SyntaxKind.ImplementsKeyword)?.types.map((j)=>j.getText(Q));if(V&&V.length>0)X.push(" implements ",V.join(", "));return X.push(" ",zq(q,Q)),X.join("")}function b(q,$,Q,W,X){let Z=[" "];if(W)Z.push("private ");else if(X)Z.push("protected ");if(q)Z.push("static ");if($)Z.push("abstract ");if(Q)Z.push("readonly ");return Z.join("")}function x(q){return q.name?Y.isPrivateIdentifier(q.name):!1}function F(q,$){if(!q.name)return"";return q.name.getText($)}function zq(q,$){let Q=[];for(let W of q.members){if(W.kind===Y.SyntaxKind.ClassStaticBlockDeclaration)continue;if(Y.isConstructorDeclaration(W)){for(let Z of W.parameters)if(Z.modifiers&&Z.modifiers.length>0){if(Z.modifiers.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let V=k(Z,$),j=Z.type?.getText($)||(Z.initializer?K(Z.initializer.getText($),!1):"unknown"),w=Z.questionToken||Z.initializer?"?":"",H=Z.modifiers.map((J)=>J.getText($)).join(" "),G=H?`${H} `:"";Q.push(` ${G}${V}${w}: ${j};`)}let X=W.parameters.map((Z)=>{let U=k(Z,$),V=Z.type?.getText($)||(Z.initializer?K(Z.initializer.getText($),!1):"unknown"),j=Z.questionToken||Z.initializer?"?":"";return`${U}${j}: ${V}`}).join(", ");Q.push(` constructor(${X});`)}else if(Y.isMethodDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=!!W.asteriskToken,j=[b(!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ProtectedKeyword))];if(U)j.push("*");if(j.push(Z),W.typeParameters){let J=W.typeParameters.map((z)=>z.getText($)).join(", ");j.push("<",J,">")}let w=W.parameters.map((J)=>{let z=k(J,$),_=J.type?.getText($)||(J.initializer?K(J.initializer.getText($),!1):"unknown"),D=J.questionToken||J.initializer?"?":"";return`${z}${D}: ${_}`}).join(", ");j.push("(",w,")");let H=!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AsyncKeyword),G=W.type?.getText($);if(!G)if(H&&U)G="AsyncGenerator<unknown, void, unknown>";else if(U)G="Generator<unknown, void, unknown>";else if(H)G="Promise<void>";else G="void";j.push(": ",G,";"),Q.push(j.join(""))}else if(Y.isPropertyDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=b(!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AbstractKeyword),!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ReadonlyKeyword),!1,!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ProtectedKeyword)),V=W.questionToken?"?":"",j=!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),w=!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ReadonlyKeyword),H=j&&w,G=W.type?.getText($)||(W.initializer?K(W.initializer.getText($),H):"unknown");Q.push(`${U}${Z}${V}: ${G};`)}else if(Y.isGetAccessorDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=b(!!W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.ProtectedKeyword)),V=W.type?.getText($)||"unknown";Q.push(`${U}get ${Z}(): ${V};`)}else if(Y.isSetAccessorDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=b(!!W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.ProtectedKeyword)),V=W.parameters[0],j=V?.type?.getText($)||"unknown",w=V?.name?.getText($)||"value";Q.push(`${U}set ${Z}(${w}: ${j});`)}}return`{
|
|
11
|
+
${Q.join(`
|
|
12
|
+
`)}
|
|
13
|
+
}`}function Qq(q,$,Q){let W=[];if(q.flags&Y.NodeFlags.GlobalAugmentation)return`declare global ${C(q,Q)}`;if($)W.push("export ");W.push("declare ");let Z=q.flags&Y.NodeFlags.Namespace;return W.push(Z?"namespace ":"module "),W.push(q.name.getText(Q)),W.push(" ",C(q,Q)),W.join("")}function C(q,$){if(!q.body)return"{}";let Q=[];function W(X){if(Y.isFunctionDeclaration(X)){let Z=B(X),U=X.name?.getText($)||"",V=[" "];if(Z)V.push("export ");if(V.push("function ",U),X.typeParameters){let H=X.typeParameters.map((G)=>G.getText($)).join(", ");V.push("<",H,">")}let j=X.parameters.map((H)=>{let G=k(H,$),J=H.type?.getText($)||(H.initializer?K(H.initializer.getText($),!1):"unknown"),z=H.questionToken||H.initializer?"?":"";return`${G}${z}: ${J}`}).join(", ");V.push("(",j,")");let w=X.type?.getText($)||"void";V.push(": ",w,";"),Q.push(V.join(""))}else if(Y.isVariableStatement(X)){let Z=B(X);for(let U of X.declarationList.declarations)if(U.name&&Y.isIdentifier(U.name)){let V=U.name.getText($),j=U.type?.getText($),w=U.initializer?.getText($),H=X.declarationList.flags&Y.NodeFlags.Const?"const":X.declarationList.flags&Y.NodeFlags.Let?"let":"var",G=[" "];if(Z)G.push("export ");if(G.push(H," ",V),j)G.push(": ",j);else if(w){let J=K(w,H==="const");G.push(": ",J)}else G.push(": unknown");G.push(";"),Q.push(G.join(""))}}else if(Y.isInterfaceDeclaration(X)){let Z=B(X),U=X.name.getText($),V=[" "];if(Z)V.push("export ");if(V.push("interface ",U),X.typeParameters){let w=X.typeParameters.map((H)=>H.getText($)).join(", ");V.push("<",w,">")}if(X.heritageClauses){let w=X.heritageClauses.find((H)=>H.token===Y.SyntaxKind.ExtendsKeyword);if(w){let H=w.types.map((G)=>G.getText($)).join(", ");V.push(" extends ",H)}}let j=o(X,$);V.push(" ",j),Q.push(V.join(""))}else if(Y.isTypeAliasDeclaration(X)){let Z=B(X),U=X.name.getText($),V=[" "];if(Z)V.push("export ");if(V.push("type ",U),X.typeParameters){let j=X.typeParameters.map((w)=>w.getText($)).join(", ");V.push("<",j,">")}V.push(" = ",X.type.getText($)),Q.push(V.join(""))}else if(Y.isEnumDeclaration(X)){let Z=B(X),U=X.name.getText($),V=X.modifiers?.some((H)=>H.kind===Y.SyntaxKind.ConstKeyword),j=[" "];if(Z)j.push("export ");if(V)j.push("const ");j.push("enum ",U);let w=[];for(let H of X.members)if(Y.isEnumMember(H)){let G=H.name.getText($);if(H.initializer){let J=H.initializer.getText($);w.push(` ${G} = ${J}`)}else w.push(` ${G}`)}j.push(` {
|
|
14
|
+
`,w.join(`,
|
|
15
|
+
`),`
|
|
16
|
+
}`),Q.push(j.join(""))}else if(Y.isModuleDeclaration(X)){let Z=B(X),U=X.name.getText($),V=[" "];if(Z)V.push("export ");let j=X.flags&Y.NodeFlags.Namespace;V.push(j?"namespace ":"module "),V.push(U," ",C(X,$)),Q.push(V.join(""))}else if(Y.isExportAssignment(X)){let Z=[" export default "];if(X.expression)Z.push(X.expression.getText($));Z.push(";"),Q.push(Z.join(""))}}if(Y.isModuleBlock(q.body))for(let X of q.body.statements)W(X);else if(Y.isModuleDeclaration(q.body))W(q.body);return`{
|
|
17
|
+
${Q.join(`
|
|
18
|
+
`)}
|
|
19
|
+
}`}function Wq(q,$,Q){let W=M(q,$,Q),X=!!q.importClause?.isTypeOnly,Z=!q.importClause;return{kind:"import",name:"",text:W,isExported:!1,isTypeOnly:X,isSideEffect:Z,source:q.moduleSpecifier.getText(Q).slice(1,-1),start:q.getStart(Q),end:q.getEnd()}}function $q(q,$,Q,W=!1){let X=M(q,$,Q),Z=!!q.isTypeOnly,U=W?I(q,Q):void 0;return{kind:"export",name:"",text:X,isExported:!0,isTypeOnly:Z,leadingComments:U,source:q.moduleSpecifier?.getText(Q).slice(1,-1),start:q.getStart(Q),end:q.getEnd()}}function jq(q,$,Q,W=!1){let X=M(q,$,Q),Z=W?I(q,Q):void 0;return{kind:"export",name:"default",text:X,isExported:!0,isTypeOnly:!1,leadingComments:Z,start:q.getStart(Q),end:q.getEnd()}}function Xq(q,$,Q,W){if(!q.name)return null;if(q.body){let _=q.name.getText(Q),D=!1;if(R.forEachChild(Q,(P)=>{if(R.isFunctionDeclaration(P)&&P!==q&&P.name?.getText(Q)===_&&!P.body)D=!0}),D)return null}let X=q.name.getText(Q),Z=B(q),U=Z&&g(q),V=d(q),j=!!q.asteriskToken,w=n(q,Q),H=q.parameters.map((_)=>({name:_.name.getText(Q),type:_.type?.getText(Q)||"any",optional:!!_.questionToken,defaultValue:_.initializer?.getText(Q)})),G=q.type?.getText(Q);if(!G)if(V&&j)G="AsyncGenerator<unknown, void, unknown>";else if(j)G="Generator<unknown, void, unknown>";else if(V)G="Promise<void>";else G="void";let J=q.typeParameters?.map((_)=>_.getText(Q)).join(", "),z=W?I(q,Q):void 0;return{kind:"function",name:X,text:w,isExported:Z,isDefault:U,isAsync:V,isGenerator:j,parameters:H,returnType:G,generics:J?`<${J}>`:void 0,leadingComments:z,start:q.getStart(Q),end:q.getEnd()}}function Nq(q,$){let Q=q.getText($);if(q.kind===R.SyntaxKind.ObjectLiteralExpression)return`typeof ${Q} as const`;if(q.kind===R.SyntaxKind.ArrayLiteralExpression)return`readonly ${Q}`;if(q.kind===R.SyntaxKind.StringLiteral)return Q;if(q.kind===R.SyntaxKind.NumericLiteral)return Q;if(q.kind===R.SyntaxKind.TrueKeyword||q.kind===R.SyntaxKind.FalseKeyword)return Q;return`typeof ${Q}`}function Zq(q,$,Q,W){let X=[];if(!B(q))return X;for(let U of q.declarationList.declarations){if(!U.name||!R.isIdentifier(U.name))continue;let V=U.name.getText(Q),j=U.type?.getText(Q),w=U.initializer,H=w?.getText(Q),G=q.declarationList.flags&R.NodeFlags.Const?"const":q.declarationList.flags&R.NodeFlags.Let?"let":"var",J=!1;if(w&&R.isAsExpression(w)){if(w.type.getText(Q)==="const"){J=!0;let P=w.expression;if(!j)j=Nq(P,Q)}}let z=s(V,j,G,!0),_=W?I(q,Q):void 0;X.push({kind:"variable",name:V,text:z,isExported:!0,typeAnnotation:j,value:H,modifiers:J?[G,"const assertion"]:[G],leadingComments:_,start:q.getStart(Q),end:q.getEnd()})}return X}function y(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=r(q,Z,Q),V=q.heritageClauses?.find((H)=>H.token===R.SyntaxKind.ExtendsKeyword)?.types.map((H)=>H.getText(Q)).join(", "),j=q.typeParameters?.map((H)=>H.getText(Q)).join(", "),w=W?I(q,Q):void 0;return{kind:"interface",name:X,text:U,isExported:Z,extends:V,generics:j?`<${j}>`:void 0,leadingComments:w,start:q.getStart(Q),end:q.getEnd()}}function f(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=e(q,Z,Q),V=q.typeParameters?.map((w)=>w.getText(Q)).join(", "),j=W?I(q,Q):void 0;return{kind:"type",name:X,text:U,isExported:Z,generics:V?`<${V}>`:void 0,leadingComments:j,start:q.getStart(Q),end:q.getEnd()}}function u(q,$,Q,W){let X=q.name?.getText(Q)||"AnonymousClass",Z=B(q),U=Z&&g(q),V=qq(q,Z,Q,U),j=q.heritageClauses?.find((z)=>z.token===R.SyntaxKind.ExtendsKeyword)?.types[0]?.getText(Q),w=q.heritageClauses?.find((z)=>z.token===R.SyntaxKind.ImplementsKeyword)?.types.map((z)=>z.getText(Q)),H=q.typeParameters?.map((z)=>z.getText(Q)).join(", "),G=q.modifiers?.some((z)=>z.kind===R.SyntaxKind.AbstractKeyword),J=W?I(q,Q):void 0;return{kind:"class",name:X,text:V,isExported:Z,isDefault:U,extends:j,implements:w,generics:H?`<${H}>`:void 0,modifiers:G?["abstract"]:void 0,leadingComments:J,start:q.getStart(Q),end:q.getEnd()}}function p(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=M(q,$,Q),V=q.modifiers?.some((w)=>w.kind===R.SyntaxKind.ConstKeyword),j=W?I(q,Q):void 0;return{kind:"enum",name:X,text:U,isExported:Z,modifiers:V?["const"]:void 0,leadingComments:j,start:q.getStart(Q),end:q.getEnd()}}function Vq(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=Qq(q,Z,Q),V=R.isStringLiteral(q.name),j=W?I(q,Q):void 0;return{kind:"module",name:X,text:U,isExported:Z,source:V?X.slice(1,-1):void 0,leadingComments:j,start:q.getStart(Q),end:q.getEnd()}}function Uq(q,$){let Q=new Set,W=new Set,X=new Set;for(let Z of q)if(Z.kind==="import"){let U=Z.text.match(/import\s+(?:type\s+)?\{([^}]+)\}/g);if(U)for(let V of U){let j=V.replace(/import\s+(?:type\s+)?\{([^}]+)\}/,"$1").split(",");for(let w of j){let H=w.replace(/^type\s+/,"").trim();W.add(H)}}}for(let Z of q){if(["interface","type","class","enum"].includes(Z.kind))X.add(Z.name);if(Z.kind==="module")a(Z.text).forEach((V)=>X.add(V))}for(let Z of q)if(Z.kind!=="import"&&Z.kind!=="export"){let U=Z.text.match(/:\s*([A-Z][a-zA-Z0-9]*)/g)||[];for(let V of U){let j=V.replace(/:\s*/,"");if(!W.has(j)&&!X.has(j)&&!t(j))Q.add(j)}}return Q}function Eq(q,$,Q,W=!0){let X=[];if($.size===0)return X;function Z(U){switch(U.kind){case R.SyntaxKind.InterfaceDeclaration:{let V=U,j=V.name.getText(q);if($.has(j)){let w=y(V,Q,q,W);X.push(w),$.delete(j)}break}case R.SyntaxKind.TypeAliasDeclaration:{let V=U,j=V.name.getText(q);if($.has(j)){let w=f(V,Q,q,W);X.push(w),$.delete(j)}break}case R.SyntaxKind.ClassDeclaration:{let V=U;if(V.name){let j=V.name.getText(q);if($.has(j)){let w=u(V,Q,q,W);X.push(w),$.delete(j)}}break}case R.SyntaxKind.EnumDeclaration:{let V=U,j=V.name.getText(q);if($.has(j)){let w=p(V,Q,q,W);X.push(w),$.delete(j)}break}}R.forEachChild(U,Z)}return Z(q),X}function aq(){wq(),Oq()}function nq(q,$,Q=!0,W=!1){return Bq(q,$,Q,W)}function Sq(q,$,Q){let W=[],X=new Map,Z=0;function U(V){if(Z!==1){Z++,L.forEachChild(V,U),Z--;return}switch(V.kind){case L.SyntaxKind.ImportDeclaration:W.push(Wq(V,$,q));break;case L.SyntaxKind.ExportDeclaration:W.push($q(V,$,q,Q));break;case L.SyntaxKind.ExportAssignment:W.push(jq(V,$,q,Q));break;case L.SyntaxKind.FunctionDeclaration:{let j=Xq(V,$,q,Q);if(j&&(j.isExported||m(j.name,$)))W.push(j);break}case L.SyntaxKind.VariableStatement:{let j=Zq(V,$,q,Q);W.push(...j);break}case L.SyntaxKind.InterfaceDeclaration:{let j=y(V,$,q,Q);if(j.isExported||i(j.name,$))W.push(j);else X.set(j.name,j);break}case L.SyntaxKind.TypeAliasDeclaration:{let j=f(V,$,q,Q);if(W.push(j),!j.isExported)X.set(j.name,j);break}case L.SyntaxKind.ClassDeclaration:{let j=u(V,$,q,Q);if(W.push(j),!j.isExported&&j.name)X.set(j.name,j);break}case L.SyntaxKind.EnumDeclaration:{let j=p(V,$,q,Q);if(W.push(j),!j.isExported)X.set(j.name,j);break}case L.SyntaxKind.ModuleDeclaration:W.push(Vq(V,$,q,Q));break}}if(U(q),X.size>0){let V=Uq(W,$);for(let j of V){let w=X.get(j);if(w)W.push(w)}}return W}async function gq(q,$,Q=!0,W={}){let X=await h($,q,W);return Sq(X,q,Q)}async function sq(q,$={}){let Q=$.concurrency??4,W=new Map;for(let X=0;X<q.length;X+=Q){let Z=q.slice(X,X+Q),U=await Promise.all(Z.map(async({filePath:V,sourceCode:j,keepComments:w})=>{let H=await gq(j,V,w,$);return{filePath:V,declarations:H}}));for(let{filePath:V,declarations:j}of U)W.set(V,j)}return W}export{Iq as wb,h as xb,Aq as yb,kq as zb,Kq as Ab,M as Bb,I as Cb,k as Db,B as Eb,d as Fb,m as Gb,i as Hb,t as Ib,a as Jb,n as Kb,s as Lb,r as Mb,o as Nb,e as Ob,qq as Pb,zq as Qb,Qq as Rb,C as Sb,Wq as Tb,$q as Ub,jq as Vb,Xq as Wb,Zq as Xb,y as Yb,f as Zb,u as _b,p as $b,Vq as ac,Uq as bc,Eq as cc,aq as dc,nq as ec,gq as fc,sq as gc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ec as F}from"./chunk-
|
|
2
|
+
import{ec as F}from"./chunk-ft0nf9jb.js";import{Cc as N}from"./chunk-vx4a5crm.js";import{existsSync as H,readFileSync as P,unwatchFile as T}from"fs";var k;((J)=>{J[J.Error=1]="Error";J[J.Warning=2]="Warning";J[J.Information=3]="Information";J[J.Hint=4]="Hint"})(k||={});var L;((O)=>{O[O.File=1]="File";O[O.Module=2]="Module";O[O.Namespace=3]="Namespace";O[O.Package=4]="Package";O[O.Class=5]="Class";O[O.Method=6]="Method";O[O.Property=7]="Property";O[O.Field=8]="Field";O[O.Constructor=9]="Constructor";O[O.Enum=10]="Enum";O[O.Interface=11]="Interface";O[O.Function=12]="Function";O[O.Variable=13]="Variable";O[O.Constant=14]="Constant";O[O.String=15]="String";O[O.Number=16]="Number";O[O.Boolean=17]="Boolean";O[O.Array=18]="Array";O[O.Object=19]="Object";O[O.Key=20]="Key";O[O.Null=21]="Null";O[O.EnumMember=22]="EnumMember";O[O.Struct=23]="Struct";O[O.Event=24]="Event";O[O.Operator=25]="Operator";O[O.TypeParameter=26]="TypeParameter"})(L||={});var M;((Q)=>{Q[Q.Text=1]="Text";Q[Q.Method=2]="Method";Q[Q.Function=3]="Function";Q[Q.Constructor=4]="Constructor";Q[Q.Field=5]="Field";Q[Q.Variable=6]="Variable";Q[Q.Class=7]="Class";Q[Q.Interface=8]="Interface";Q[Q.Module=9]="Module";Q[Q.Property=10]="Property";Q[Q.Unit=11]="Unit";Q[Q.Value=12]="Value";Q[Q.Enum=13]="Enum";Q[Q.Keyword=14]="Keyword";Q[Q.Snippet=15]="Snippet";Q[Q.Color=16]="Color";Q[Q.File=17]="File";Q[Q.Reference=18]="Reference";Q[Q.Folder=19]="Folder";Q[Q.EnumMember=20]="EnumMember";Q[Q.Constant=21]="Constant";Q[Q.Struct=22]="Struct";Q[Q.Event=23]="Event";Q[Q.Operator=24]="Operator";Q[Q.TypeParameter=25]="TypeParameter"})(M||={});var v;((A)=>{A[A.Text=1]="Text";A[A.Read=2]="Read";A[A.Write=3]="Write"})(v||={});class E{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(j){return this.rootUri=j.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(j){let{uri:z,text:G,version:A}=j.textDocument;this.updateDocument(z,G,A)}didChange(j){let{uri:z,version:G}=j.textDocument,A=j.contentChanges[0]?.text||"";this.updateDocument(z,A,G)}didClose(j){let z=j.textDocument.uri;if(this.documents.delete(z),this.watchers.get(z))T(this.uriToPath(z)),this.watchers.delete(z)}updateDocument(j,z,G){let A=this.uriToPath(j),J=F(z,A,!0);this.documents.set(j,{content:z,version:G,declarations:J})}getDiagnostics(j){let z=this.documents.get(j);if(!z)return[];let G=[];for(let A of z.declarations){if(A.isExported&&A.kind==="variable"&&!A.typeAnnotation)G.push({range:this.getDeclarationRange(A,z.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${A.name}' should have an explicit type annotation for better declaration generation`});if(A.typeAnnotation==="any"||A.returnType==="any")G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(A.kind==="function"&&A.isExported&&!A.returnType)G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${A.name}' should have an explicit return type for better declaration generation`})}return G}hover(j){let z=this.documents.get(j.textDocument.uri);if(!z)return null;let{line:G,character:A}=j.position,R=z.content.split(`
|
|
3
3
|
`)[G]||"",U=R.slice(0,A).match(/[\w$]+$/),V=R.slice(A).match(/^[\w$]+/);if(!U&&!V)return null;let X=(U?.[0]||"")+(V?.[0]||""),Y=z.declarations.find((W)=>W.name===X);if(!Y)return null;let B=`\`\`\`typescript
|
|
4
4
|
${this.buildSignature(Y)}
|
|
5
5
|
\`\`\``;if(Y.leadingComments&&Y.leadingComments.length>0){let q=Y.leadingComments.join(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as C}from"./chunk-
|
|
2
|
+
import{tb as C}from"./chunk-y4g1csn2.js";function y(F={}){let{onStart:H=!1,onEnd:I=!0,onGenerated:J,onError:z,...q}=F,B=async()=>{try{let k=await C(q);J?.(k)}catch(k){let j=k instanceof Error?k:Error(String(k));if(z?.(j),!z)console.error("[dtsx] Generation failed:",j.message)}};return{name:"dtsx",setup(k){let j=k.initialOptions;if(!q.entrypoints&&j.entryPoints)if(Array.isArray(j.entryPoints))q.entrypoints=j.entryPoints;else q.entrypoints=Object.values(j.entryPoints);if(!q.outdir){if(j.outdir)q.outdir=j.outdir;else if(j.outfile){let w=j.outfile.lastIndexOf("/");if(w!==-1)q.outdir=j.outfile.substring(0,w)}}if(H)k.onStart(async()=>{await B()});if(I)k.onEnd(async(w)=>{if(w.errors.length===0)await B()})}}}var L=y,M=y,P=y;
|
|
3
3
|
export{y as ia,L as ja,M as ka,P as la};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{a,b,c}from"./chunk-0cfb4831.js";import"./chunk-ft0nf9jb.js";import"./chunk-2n1bbm2c.js";import"./chunk-y2pe3jq3.js";import"./chunk-4mtbtmee.js";import"./chunk-xw9wfq8f.js";import"./chunk-mcdb3q06.js";export{b as optimizeFile,a as optimizeDeclarations,c as minifyDts};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s as a,t as b,u as c,v as d,w as e,x as f,y as g}from"./chunk-
|
|
2
|
+
import{s as a,t as b,u as c,v as d,w as e,x as f,y as g}from"./chunk-fvgc14nk.js";import"./chunk-ft0nf9jb.js";import"./chunk-2n1bbm2c.js";import"./chunk-y2pe3jq3.js";import"./chunk-4mtbtmee.js";import"./chunk-vx4a5crm.js";import"./chunk-xw9wfq8f.js";import"./chunk-mcdb3q06.js";export{f as startLSPServer,g as createFileWatcher,b as SymbolKind,a as LspDiagnosticSeverity,e as DtsxLanguageServer,d as DocumentHighlightKind,c as CompletionItemKind};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as z}from"./chunk-
|
|
2
|
+
import{tb as z}from"./chunk-y4g1csn2.js";function C(F={}){let{preBuild:H=!1,postBuild:I=!0,onGenerated:J,onError:w,...q}=F,y=async()=>{try{let j=await z(q);J?.(j)}catch(j){let k=j instanceof Error?j:Error(String(j));if(w?.(k),!w)console.error("[dtsx] Generation failed:",k.message)}};return{name:"dtsx",async setup(j){let k=j.config;if(!q.entrypoints&&k.entrypoints)q.entrypoints=k.entrypoints;if(!q.outdir&&k.outdir)q.outdir=k.outdir;if(!q.root&&k.root)q.root=k.root;if(H)j.onStart(async()=>{await y()});if(I){let v=!1;j.onLoad({filter:/.*/},async(K)=>{if(!v)queueMicrotask(async()=>{if(!v)v=!0,await y()});return})}}}}var M=C,P=C;
|
|
3
3
|
export{C as fa,M as ga,P as ha};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$b as G,Ab as e,Bb as g,Cb as h,Db as i,Eb as j,Fb as k,Gb as l,Hb as m,Ib as n,Jb as o,Kb as p,Lb as q,Mb as r,Nb as s,Ob as t,Pb as u,Qb as v,Rb as w,Sb as x,Tb as y,Ub as z,Vb as A,Wb as B,Xb as C,Yb as D,Zb as E,_b as F,ac as H,bc as I,cc as J,dc as K,ec as L,fc as M,gc as N,wb as a,xb as b,yb as c,zb as d}from"./chunk-
|
|
2
|
+
import{$b as G,Ab as e,Bb as g,Cb as h,Db as i,Eb as j,Fb as k,Gb as l,Hb as m,Ib as n,Jb as o,Kb as p,Lb as q,Mb as r,Nb as s,Ob as t,Pb as u,Qb as v,Rb as w,Sb as x,Tb as y,Ub as z,Vb as A,Wb as B,Xb as C,Yb as D,Zb as E,_b as F,ac as H,bc as I,cc as J,dc as K,ec as L,fc as M,gc as N,wb as a,xb as b,yb as c,zb as d}from"./chunk-ft0nf9jb.js";import"./chunk-2n1bbm2c.js";import"./chunk-y2pe3jq3.js";import"./chunk-4mtbtmee.js";import{Oc as f}from"./chunk-xw9wfq8f.js";import"./chunk-mcdb3q06.js";export{d as shouldUseAsyncParsing,m as shouldIncludeNonExportedInterface,l as shouldIncludeNonExportedFunction,n as isBuiltInType,j as hasExportModifier,k as hasAsyncModifier,a as getSourceFileCacheSize,b as getSourceFileAsync,e as getPendingParseCount,i as getParameterName,g as getNodeText,s as getInterfaceBody,I as findReferencedTypes,C as extractVariableStatement,o as extractTypesFromModuleText,E as extractTypeAliasDeclaration,f as extractTripleSlashDirectives,J as extractReferencedTypeDeclarations,H as extractModuleDeclaration,h as extractJSDocComments,D as extractInterfaceDeclaration,y as extractImportDeclaration,B as extractFunctionDeclaration,z as extractExportDeclaration,A as extractExportAssignment,G as extractEnumDeclaration,M as extractDeclarationsAsync,L as extractDeclarations,F as extractClassDeclaration,K as clearSourceFileCache,q as buildVariableDeclaration,t as buildTypeDeclaration,w as buildModuleDeclaration,x as buildModuleBody,r as buildInterfaceDeclaration,p as buildFunctionSignature,u as buildClassDeclaration,v as buildClassBody,c as batchParseSourceFiles,N as batchExtractDeclarations};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Dc as Uz,Ec as Yz,Fc as T,Mc as u,Nc as p,Oc as Gz}from"./chunk-
|
|
2
|
+
import{Dc as Uz,Ec as Yz,Fc as T,Mc as u,Nc as p,Oc as Gz}from"./chunk-xw9wfq8f.js";function k(z,$=!0){if(!$||!z||z.length===0)return"";if(z.length===1){let U=z[0];if(U.length>0&&U.charCodeAt(0)>32&&U.charCodeAt(U.length-1)>32)return`${U}
|
|
3
3
|
`;return`${U.trim()}
|
|
4
4
|
`}let K="";for(let U=0;U<z.length;U++){if(U>0)K+=`
|
|
5
5
|
`;K+=z[U].trim()}return`${K}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tb as y}from"./chunk-
|
|
2
|
+
import{tb as y}from"./chunk-y4g1csn2.js";import{Wc as H,Yc as F}from"./chunk-gssantc8.js";import{dd as R}from"./chunk-mcdb3q06.js";import{existsSync as V,readFileSync as G}from"fs";import{dirname as M,join as X,resolve as x}from"path";async function S(E){let A=[],z=new Set;async function q(I,O){let w=x(I);if(z.has(w))return;if(z.add(w),!V(w)){H.warn(`tsconfig not found: ${w}`);return}try{let K=G(w,"utf-8"),Q=K.indexOf("//")!==-1||K.indexOf("/*")!==-1?K.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""):K,L=JSON.parse(Q),U=M(w),Y=B(U,O),W=[];if(L.references)for(let D of L.references){let $=x(U,D.path),J=V(X($,"tsconfig.json"))?X($,"tsconfig.json"):$;await q(J,Y);let b=B(M(J),Y);W.push(b)}let Z="./src";if(L.compilerOptions?.rootDir)Z=L.compilerOptions.rootDir;else if(L.include&&L.include.length>0){if(L.include[0].startsWith("src/"))Z="./src"}let _="./dist";if(L.compilerOptions?.outDir)_=L.compilerOptions.outDir;else if(L.compilerOptions?.declarationDir)_=L.compilerOptions.declarationDir;A.push({name:Y,root:U,tsconfigPath:w,references:W,config:{root:Z,outdir:_}})}catch(K){let Q=K instanceof Error?K.message:String(K);H.warn(`Failed to parse ${w}: ${Q}`)}}return await q(E),A}function B(E,A){let z=X(E,"package.json");if(V(z))try{let I=G(z,"utf-8"),O=JSON.parse(I);if(O.name)return O.name}catch{}let q=E.split("/").pop()||"unknown";return A?`${A}/${q}`:q}function N(E){let A=new Map(E.map((w)=>[w.name,w])),z=[],q=new Set,I=new Set;function O(w){if(q.has(w))return;if(I.has(w)){H.warn(`Circular dependency detected involving: ${w}`);return}I.add(w);let K=A.get(w);if(K){for(let Q of K.references)O(Q);z.push(K)}I.delete(w),q.add(w)}for(let w of E)O(w.name);return z}async function T(E){let A=Date.now(),z=N(E.projects);H.info(`Generating declarations for ${z.length} projects...`);let q=[],I=!0;for(let Q of z){H.info(`
|
|
3
3
|
[${Q.name}] Generating...`);try{let L={...E.sharedConfig,...Q.config,cwd:Q.root,tsconfigPath:Q.tsconfigPath},U=await y(L),Y=U.filesFailed===0;if(!Y)I=!1;q.push({name:Q.name,stats:U,success:Y}),H.info(`[${Q.name}] Generated ${U.filesGenerated} files`)}catch(L){I=!1;let U=L instanceof Error?L.message:String(L);q.push({name:Q.name,stats:{filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:U}),H.error(`[${Q.name}] Failed: ${U}`)}}let O=Date.now()-A,w=q.filter((Q)=>Q.success).length,K=q.length-w;if(H.info(`
|
|
4
4
|
--- Workspace Generation Summary ---`),H.info(`Projects processed: ${q.length}`),H.info(`Successful: ${w}`),K>0)H.info(`Failed: ${K}`);return H.info(`Total duration: ${O}ms`),H.info(`------------------------------------
|
|
5
5
|
`),{success:I,projects:q,durationMs:O}}async function f(E,A){if(A?.logLevel)F(A.logLevel);let z=X(E,"tsconfig.json");if(!V(z))throw Error(`Root tsconfig.json not found at: ${z}`);H.info("Discovering workspace projects...");let q=await S(z);if(q.length===0)return H.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return H.info(`Found ${q.length} projects`),T({root:E,projects:q,sharedConfig:A})}async function v(E){let A=X(E,"package.json");if(!V(A))return[];try{let z=G(A,"utf-8"),q=JSON.parse(z),I=[];if(Array.isArray(q.workspaces))I=q.workspaces;else if(q.workspaces?.packages)I=q.workspaces.packages;return I}catch{return[]}}async function C(E,A){let{Glob:z}=awaitPromise.resolve(globalThis.Bun),q=[];for(let I of A){let O=new z(I);for await(let w of O.scan({cwd:E,absolute:!0,onlyFiles:!1})){let K=X(w,"package.json");if(V(K))q.push(w)}}return q}async function l(E,A){if(A?.logLevel)F(A.logLevel);let z=await v(E);if(z.length===0)return H.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};H.info(`Found workspace patterns: ${z.join(", ")}`);let q=await C(E,z);if(q.length===0)return H.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};H.info(`Found ${q.length} workspace packages`);let I=q.map((O)=>{let w=X(O,"tsconfig.json");return{name:B(O),root:O,tsconfigPath:V(w)?w:"",references:[]}});return T({root:E,projects:I,sharedConfig:A})}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var E=!1,R=null;function h(J){if(J.indexOf("/*")===-1)return J.trim();let X=[],Q=0,z=0,L=J.length;while(z<L)if(J.charCodeAt(z)===47&&z+1<L&&J.charCodeAt(z+1)===42){if(z>Q)X.push(J.substring(Q,z));z+=2;while(z<L-1){if(J.charCodeAt(z)===42&&J.charCodeAt(z+1)===47){z+=2;break}z++}Q=z}else z++;if(Q<L)X.push(J.substring(Q));return X.join("").trim()}function Qz(){E=!0,R=null}function Hz(){E=!1;let J=R;return R=null,J}function S(J){let Y=J.length;if(Y===0)return!1;let X=0;if(J.charCodeAt(X)===45)X++;if(X>=Y)return!1;let Q=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===Q)return!1;if(X<Y&&J.charCodeAt(X)===46){X++;let z=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===z)return!1}return X===Y}function o(J){for(let Y=0,X=J.length-1;Y<X;Y++){let Q=J.charCodeAt(Y);if(Q<48||Q>57)return!1}return!0}function D(J,Y){let X=0,Q=0;while((Q=J.indexOf(Y,Q))!==-1)X++,Q+=Y.length;return X}function _(J){let Y=J.length,X=!1;for(let Z=1;Z<Y;Z++)if(J.charCodeAt(Z)<=32&&J.charCodeAt(Z-1)<=32){X=!0;break}if(!X)for(let Z=0;Z<Y;Z++){let $=J.charCodeAt(Z);if($===10||$===13||$===9){X=!0;break}}if(!X)return J;let Q=[],z=-1,L=!1;for(let Z=0;Z<Y;Z++)if(J.charCodeAt(Z)<=32){if(!L){if(z>=0)Q.push(J.substring(z,Z));Q.push(" "),L=!0,z=-1}}else{if(L||z<0)z=Z;L=!1}if(z>=0)Q.push(J.substring(z));return Q.join("")}function b(J,Y=!1,X=!1,Q=0){if(!J||typeof J!=="string")return"unknown";if(Q>=20)return"unknown";let z=J.trim();if(z.startsWith("BigInt("))return"bigint";if(z.startsWith("Symbol.for("))return"symbol";if(z.includes(".raw`")||z.includes("String.raw`"))return"string";if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'")||z.startsWith("`")&&z.endsWith("`")){if(!z.includes("${")){if(!Y)return"string";return z}if(Y)return z;return"string"}if(S(z)){if(!Y)return"number";return z}if(z==="true"||z==="false"){if(!Y)return"boolean";return z}if(z==="null")return"null";if(z==="undefined")return"undefined";if(z.startsWith("[")&&z.endsWith("]"))return I(z,Y,Q+1);if(z.startsWith("{")&&z.endsWith("}"))return s(z,Y,Q+1);if(z.startsWith("class ")||z.startsWith("class{"))return d(z);if(z.startsWith("new "))return c(z);if(z.includes("=>")||z.startsWith("function")||z.startsWith("async"))return y(z,X,Q,Y);if(z.endsWith("as const")){let L=z.slice(0,-8).trim();if(L.startsWith("[")&&L.endsWith("]")){let Z=L.slice(1,-1).trim();if(!Z)return"readonly []";let $=w(Z),H=[];for(let O=0;O<$.length;O++)H.push(b($[O].trim(),!0,!1,Q+1));return`readonly [${H.join(", ")}]`}return b(L,!0,X,Q+1)}if(z.startsWith("`")&&z.endsWith("`"))return p(z,Y);if(z.startsWith("Promise."))return f(z,Y,Q);if(z.startsWith("await "))return"unknown";if(z.charCodeAt(z.length-1)===110&&z.length>1&&o(z)){if(Y)return z;return"bigint"}if(z.startsWith("Symbol(")||z==="Symbol.for")return"symbol";return"unknown"}function l(J,Y=!1,X=0){return b(J,Y,!0,X)}function p(J,Y){if(J.includes(".raw`")||J.includes("String.raw`"))return"string";if(!Y)return"string";if(!J.includes("${"))return J;return"string"}function c(J){let Y=4;while(Y<J.length&&J.charCodeAt(Y)<=32)Y++;let X=Y,Q=J.charCodeAt(Y);if(Q<65||Q>90)return"unknown";while(Y<J.length&&(k(J.charCodeAt(Y))||J.charCodeAt(Y)===46))Y++;if(Y===X)return"unknown";let z=J.slice(X,Y);{let L=J.slice(Y),Z=L;if(L.startsWith("<")){let H=0,O=-1;for(let K=0;K<L.length;K++)if(L[K]==="<")H++;else if(L[K]===">"){if(H--,H===0){O=K;break}}if(O!==-1){let K=L.slice(0,O+1);Z=L.slice(O+1);let q=Z.indexOf("(");if(q!==-1){let G=0,B=-1;for(let F=q;F<Z.length;F++)if(Z[F]==="(")G++;else if(Z[F]===")"){if(G--,G===0){B=F;break}}if(B!==-1){if(Z.slice(B+1).trimStart().startsWith("."))return"unknown"}}return`${z}${K}`}}let $=Z.indexOf("(");if($!==-1){let H=0,O=-1;for(let K=$;K<Z.length;K++)if(Z[K]==="(")H++;else if(Z[K]===")"){if(H--,H===0){O=K;break}}if(O!==-1){if(Z.slice(O+1).trimStart().startsWith("."))return"unknown"}}switch(z){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return z}}return"unknown"}function d(J){let Y=J.trimStart(),X=5;while(X<Y.length&&Y.charCodeAt(X)<=32)X++;let Q=X;if(X<Y.length&&k(Y.charCodeAt(X))){while(X<Y.length&&k(Y.charCodeAt(X)))X++;return`typeof ${Y.slice(Q,X)}`}return"{ new (...args: any[]): any }"}function f(J,Y,X=0){if(J.startsWith("Promise.resolve(")){let z=J.indexOf(")",16);if(z!==-1){let L=J.slice(16,z).trim();if(L)return`Promise<${b(L,Y,!1,X+1)}>`}return"Promise<unknown>"}if(J.startsWith("Promise.reject("))return"Promise<never>";if(J.startsWith("Promise.all(")){let Q=J.indexOf("[",12),z=J.lastIndexOf("]");if(Q!==-1&&z>Q){let L=J.slice(Q+1,z).trim(),Z=w(L),$=[];for(let H=0;H<Z.length;H++){let O=Z[H].trim();if(O.startsWith("Promise.resolve(")){let K=f(O,Y,X+1),q=K.indexOf("<"),G=K.lastIndexOf(">");$.push(q!==-1&&G>q?K.slice(q+1,G):"unknown")}else $.push(b(O,Y,!1,X+1))}return`Promise<[${$.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function I(J,Y,X=0){let Q=J.slice(1,-1).trim();if(!Q)return"never[]";if(X>=20)return"unknown[]";let z=w(Q),L=!1;for(let G=0;G<z.length;G++){let B=z[G],F=B.length;while(F>0&&B.charCodeAt(F-1)<=32)F--;if(F>=8&&B.slice(F-8,F)==="as const"){L=!0;break}}if(L){let G=[];for(let B=0;B<z.length;B++){let F=z[B].trim();if(F.endsWith("as const")){let W=F.slice(0,-8).trim();if(W.startsWith("[")&&W.endsWith("]")){let N=W.slice(1,-1).trim(),U=w(N),M=[];for(let V=0;V<U.length;V++)M.push(b(U[V].trim(),!0,!1,X+1));G.push(`readonly [${M.join(", ")}]`)}else G.push(b(W,!0,!1,X+1))}else if(F.startsWith("[")&&F.endsWith("]"))G.push(I(F,!0,X+1));else G.push(b(F,!0,!1,X+1))}return`readonly [
|
|
3
|
+
${G.join(` |
|
|
4
|
+
`)}
|
|
5
|
+
]`}let Z=E&&!Y,$=[],H=[];for(let G of z){let B=G.trim(),F=R;if(R=null,B.startsWith("[")&&B.endsWith("]"))$.push(I(B,Y,X+1));else $.push(l(B,Y,X+1));if(Z)H.push(R);R=F}if(Z)if(g(J))R=_(J);else{let G=[];for(let B=0;B<z.length;B++){let F=z[B].trim();if(F.endsWith("as const"))continue;if(x(F)||F==="null"||F==="undefined")G.push(F);else if(F.startsWith("[")&&g(F))G.push(_(F));else if(F.startsWith("{")){if(H[B])G.push(H[B])}else{let W=b(F,!1,!1,0);if(W!=="unknown")G.push(W)}}if(G.length>0)R=`[${G.join(", ")}]`}if(Y)return`readonly [${$.join(", ")}]`;let O=new Set,K=[],q=!0;for(let G of $){if(!O.has(G))O.add(G),K.push(G);if(q){if(!(S(G)||G==="true"||G==="false"||G.charCodeAt(0)===34&&G.charCodeAt(G.length-1)===34||G.charCodeAt(0)===39&&G.charCodeAt(G.length-1)===39))q=!1}}if(q&&$.length<=10)return`readonly [${$.join(", ")}]`;if(K.length===1)return`${K[0]}[]`;return`(${K.join(" | ")})[]`}function w(J){let Y=[],X=0,Q=0,z=!1,L=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(!z&&(H===34||H===39||H===96))z=!0,L=H;else if(z&&H===L&&($===0||J.charCodeAt($-1)!==92))z=!1;if(!z){if(H===91||H===123||H===40)Q++;else if(H===93||H===125||H===41)Q--;else if(H===44&&Q===0){let O=J.substring(X,$).trim();if(O)Y.push(O);X=$+1;continue}}}let Z=J.substring(X).trim();if(Z)Y.push(Z);return Y}function x(J){if(S(J))return!0;if(J==="true"||J==="false")return!0;if(J.startsWith('"')&&J.endsWith('"')||J.startsWith("'")&&J.endsWith("'"))return!0;return!1}function m(J){return J==="number"||J==="string"||J==="boolean"}function g(J){let Y=!1,X=0,Q=J.length;for(let z=0;z<Q;z++){let L=J.charCodeAt(z);if(Y){if(L===92){z++;continue}if(L===X)Y=!1;continue}if(L===34||L===39||L===96){Y=!0,X=L;continue}if(L===61&&z+1<Q&&J.charCodeAt(z+1)===62)return!1;if(L>=97&&L<=122){let Z=z;while(z<Q&&(J.charCodeAt(z)>=97&&J.charCodeAt(z)<=122||J.charCodeAt(z)>=65&&J.charCodeAt(z)<=90||J.charCodeAt(z)>=48&&J.charCodeAt(z)<=57||J.charCodeAt(z)===95||J.charCodeAt(z)===36))z++;let $=J.slice(Z,z);if($==="new"||$==="async"||$==="await"||$==="function"||$==="yield"||$==="console"||$==="process")return!1;let H=z;while(H<Q&&J.charCodeAt(H)<=32)H++;if(H<Q&&J.charCodeAt(H)===40)return!1;z--}}return!0}function s(J,Y,X=0){let Q=J.slice(1,-1).trim();if(!Q)return"{}";if(X>=20)return"Record<string, unknown>";let z=r(Q),L=[],Z=E&&!Y,$=[];for(let[H,O]of z){let K=R;R=null;let q,G=O.trim();if(zz(G))q=Jz(H,G);else if(q=b(O,Y,!1,X+1),q.includes("=>")||q.includes("function")||q.includes("async"))q=i(q);let B=R;R=K;let F=O.trim(),W=t(H);if(W){let N=e(W.kind,W.name,q);if(N){L.push(N);continue}}if(!Y&&m(q)&&x(F))L.push(`/** @defaultValue ${F} */
|
|
6
|
+
${H}: ${q}`);else L.push(`${H}: ${q}`);if(Z){let N=h(H);if(F.endsWith("as const"));else if(x(F))$.push(`${N}: ${F}`);else if(F.startsWith("[")&&g(F))$.push(`${N}: ${_(F)}`);else if(F.startsWith("{")){if(B)$.push(`${N}: ${B}`)}else if(!F.startsWith("[")&&(F.includes("=>")||F.startsWith("function")||F.startsWith("async"))){let U=y(F,!1,0,!0);$.push(`${N}: ${U}`)}}}if(Z&&$.length>0){let H=X>0?(X-1)/2:0,O=`{ ${$.join(", ")} }`;if(O.length<=80)R=O;else{let K=" ".repeat((H+1)*2),q=" ".repeat(H*2);R=`{
|
|
7
|
+
${K}${$.join(`,
|
|
8
|
+
${K}`)}
|
|
9
|
+
${q}}`}}return`{
|
|
10
|
+
${L.join(`;
|
|
11
|
+
`)}
|
|
12
|
+
}`}function i(J){let X=J.split(`
|
|
13
|
+
`).map((K)=>C(K)).join(`
|
|
14
|
+
`),Q=X.indexOf("async");if(Q!==-1){let K=Q>0?X.charCodeAt(Q-1):32,q=Q+5<X.length?X.charCodeAt(Q+5):32;if(!k(K)&&!k(q))X=(X.slice(0,Q)+X.slice(Q+5)).trim()}let z=X.indexOf("(");if(z!==-1){let K=A(X,z,"(",")");if(K!==-1){let q=X.slice(z,K+1),G=P(q);X=X.slice(0,z)+G+X.slice(K+1)}}let L=X.length,Z="",$=[],H=!1,O=!1;for(let K=0;K<L;K++){let q=X.charCodeAt(K);if(q===123||q===40)$.push(q);else if(q===125||q===41)$.pop();if(q<=32){if(H=!0,q===10||q===13)O=!0;continue}if(H&&Z.length>0){let B=($.length>0?$[$.length-1]:0)===123;if(O&&B){let F=Z.charCodeAt(Z.length-1),W=F===59||F===44||F===123||q===125,N=Z.length>=2&&Z.charCodeAt(Z.length-1)===47&&Z.charCodeAt(Z.length-2)===42;if(!W&&!N)Z+="; ";else Z+=" "}else Z+=" "}H=!1,O=!1,Z+=X[K]}return Z.trim()}function k(J){return J>=97&&J<=122||J>=65&&J<=90||J>=48&&J<=57||J===95||J===36}function P(J){let Y=J.trim(),X,Q=!1;if(Y.startsWith("(")&&Y.endsWith(")"))X=Y.slice(1,-1),Q=!0;else X=Y;let z=X.trim();if(!z)return Q?"()":"";let L=!1;{let F=0;for(let W=0;W<z.length;W++){let N=z.charCodeAt(W);if(N===40||N===60||N===91||N===123)F++;else if(N===41||N===62||N===93||N===125)F--;else if(F===0&&N===61){let U=W>0?z.charCodeAt(W-1):0,M=W+1<z.length?z.charCodeAt(W+1):0;if(U!==61&&U!==33&&U!==60&&U!==62&&M!==61&&M!==62){L=!0;break}}}}if(!L)return Y;let Z=[],$=[],H=0,O=0,K=!1,q=0;for(let F=0;F<=z.length;F++){if(F===z.length){Z.push(z.slice(H));break}let W=z.charCodeAt(F);if(K){if(W===92){F++;continue}if(W===q)K=!1;continue}if(W===47&&F+1<z.length){let N=z.charCodeAt(F+1);if(N===42){F+=2;while(F+1<z.length&&!(z.charCodeAt(F)===42&&z.charCodeAt(F+1)===47))F++;F++;continue}if(N===47){while(F<z.length&&z.charCodeAt(F)!==10)F++;continue}}if(W===39||W===34||W===96){K=!0,q=W;continue}if(W===40||W===60||W===91||W===123)O++;else if(W===41||W===62||W===93||W===125)O--;else if(W===44&&O===0){Z.push(z.slice(H,F));let N=",",U=F+1;while(U<z.length&&z.charCodeAt(U)<=32)N+=z[U],U++;$.push(N),H=U}}let G=[];for(let F of Z){let W=F.trim();if(!W){G.push(F);continue}if(W.startsWith("//"))continue;let N=C(W),U=F.slice(0,F.length-F.trimStart().length);G.push(U+n(N))}let B=G[0]||"";for(let F=1;F<G.length;F++)B+=($[F-1]||", ")+G[F];return Q?`(${B})`:B}function C(J){let Y=!1,X=0;for(let Q=0;Q<J.length-1;Q++){let z=J.charCodeAt(Q);if(Y){if(z===92){Q++;continue}if(z===X)Y=!1;continue}if(z===39||z===34||z===96){Y=!0,X=z;continue}if(z===47&&J.charCodeAt(Q+1)===47)return J.slice(0,Q).trimEnd()}return J}function n(J){if(J.startsWith("..."))return J;let Y=-1,X=-1,Q=0,z=!1,L=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(z){if(H===92){$++;continue}if(H===L)z=!1;continue}if(H===47&&$+1<J.length){let O=J.charCodeAt($+1);if(O===42){$+=2;while($+1<J.length&&!(J.charCodeAt($)===42&&J.charCodeAt($+1)===47))$++;$++;continue}if(O===47){while($<J.length&&J.charCodeAt($)!==10)$++;continue}}if(H===39||H===34||H===96){z=!0,L=H;continue}if(H===40||H===60||H===91||H===123)Q++;else if(H===41||H===62||H===93||H===125)Q--;else if(Q===0){if(H===58&&Y===-1)Y=$;else if(H===61&&X===-1&&($===0||J.charCodeAt($-1)!==61)&&($+1>=J.length||J.charCodeAt($+1)!==61&&J.charCodeAt($+1)!==62))X=$}}let Z=X!==-1;if(Y!==-1&&(X===-1||Y<X)){let $=J.slice(0,Y).trim(),H=X!==-1?J.slice(Y+1,X).trim():J.slice(Y+1).trim(),O=Z&&!$.endsWith("?")?"?":"";return`${$}${O}: ${H}`}else if(X!==-1){let $=J.slice(0,X).trim(),H=!$.endsWith("?")?"?":"",O=J.slice(X+1).trim(),K="unknown";if(O==="true"||O==="false")K="boolean";else if(/^-?\d+(\.\d+)?$/.test(O))K="number";else if(O.startsWith("'")&&O.endsWith("'")||O.startsWith('"')&&O.endsWith('"'))K="string";else if(O.startsWith("["))K="unknown[]";else if(O.startsWith("{"))K="Record<string, unknown>";return`${$}${H}: ${K}`}return J}function a(J){let Y=0,X=J.length;while(Y<X){while(Y<X&&(J.charCodeAt(Y)===32||J.charCodeAt(Y)===9||J.charCodeAt(Y)===10||J.charCodeAt(Y)===13))Y++;if(Y+1<X&&J.charCodeAt(Y)===47&&J.charCodeAt(Y+1)===42){Y+=2;while(Y+1<X&&!(J.charCodeAt(Y)===42&&J.charCodeAt(Y+1)===47))Y++;Y+=2;continue}break}return Y}function r(J){let Y=[],X="",Q="",z=0,L=!1,Z="",$=!0,H=!1,O=0,K=!1,q=!1;for(let G=0;G<J.length;G++){let B=J.charCodeAt(G),F=G>0?J.charCodeAt(G-1):0,W=G<J.length-1?J.charCodeAt(G+1):0;if(!L&&!H&&B===47&&W===47){G+=2;while(G<J.length&&J.charCodeAt(G)!==10)G++;continue}if(!L&&!H&&B===47&&W===42){H=!0,O=1,X+="/*",G++;continue}else if(H&&B===42&&W===47){if(O--,X+="*/",G++,O===0)H=!1;continue}else if(H&&B===47&&W===42){O++,X+="/*",G++;continue}let N=J[G];if(!L&&(B===34||B===39||B===96))L=!0,Z=N,X+=N;else if(L&&N===Z&&F!==92)L=!1,X+=N;else if(!L&&!H)if(B===40&&z===0&&$){Q=X.trim();let U=a(Q),M=U>0?Q.slice(0,U):"",V=Q.slice(U),j="";if(V.startsWith("async ")||V.startsWith("async\t")||V.startsWith(`async
|
|
15
|
+
`))V=V.slice(6).trimStart(),j="async ";if(V.startsWith("*"))V=V.slice(1).trimStart(),j+="*";Q=M+V,X=j+N,$=!1,K=!0,q=!1,z=1}else if(B===123||B===91||B===40){if(z++,X+=N,q&&B===123)q=!1}else if(B===125||B===93||B===41){if(z--,X+=N,K){if(B===41&&z===0&&!q)q=!0;else if(B===125&&z===0)K=!1,q=!1}}else if(B===58&&z===0&&$)Q=X.trim(),X="",$=!1;else if(B===44&&z===0&&!q){if(Q&&X.trim()){let U=X.trim();Y.push([Q,U])}X="",Q="",$=!0}else X+=N;else X+=N}if(Q&&X.trim()){let G=X.trim();Y.push([Q,G])}return Y}function t(J){let Y=J.trim();if(Y.startsWith("get ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"get",name:X}}if(Y.startsWith("set ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"set",name:X}}return null}function e(J,Y,X){let Q=X.trim();if(Q.charCodeAt(0)!==40)return null;let z=A(Q,0,"(",")");if(z===-1)return null;let L=Q.slice(1,z).trim(),Z=Q.slice(z+1).trimStart();if(!Z.startsWith("=>"))return null;let $=Z.slice(2).trim();if(J==="get")return`get ${Y}(): ${$||"unknown"}`;return`set ${Y}(${L})`}function zz(J){let Y=J;if(Y.startsWith("async ")||Y.startsWith("async\t"))Y=Y.slice(5).trimStart();if(Y.startsWith("*"))Y=Y.slice(1).trimStart();if(!Y.startsWith("("))return!1;let X=0;for(let Q=0;Q<Y.length;Q++){let z=Y.charCodeAt(Q);if(z===40)X++;else if(z===41){if(X--,X===0){let L=Y.slice(Q+1).trimStart();if(L.startsWith("{"))return!0;if(L.startsWith(":")){let Z=0;for(let $=0;$<L.length;$++){let H=L.charCodeAt($);if(H===40||H===91)Z++;else if(H===41||H===93)Z--;else if(H===60)Z++;else if(H===62){if(Z>0)Z--}else if(Z===0&&H===61&&$+1<L.length&&L.charCodeAt($+1)===62)return!1;else if(Z===0&&H===123)return!0}}return!1}}}return!1}function Jz(J,Y){let X=Y.trimStart(),Q=!1,z=!1;if(X.startsWith("async ")||X.startsWith("async\t"))Q=!0,X=X.slice(5).trimStart();if(X.startsWith("*"))z=!0,X=X.slice(1).trimStart();let L="";if(X.charCodeAt(0)===60){let G=0,B=-1;for(let F=0;F<X.length;F++)if(X.charCodeAt(F)===60)G++;else if(X.charCodeAt(F)===62){if(G--,G===0){B=F;break}}if(B!==-1)L=X.slice(0,B+1),X=X.slice(B+1).trimStart()}let Z=X.indexOf("("),$=A(X,Z,"(",")");if(Z===-1||$===-1)return"() => unknown";let H=X.slice(Z,$+1),O="unknown",K=X.slice($+1).trimStart();if(K.charCodeAt(0)===58){let G=K.slice(1),B=0,F=-1,W=!1;for(let N=0;N<G.length;N++){let U=G.charCodeAt(N);if(U===40||U===91)B++;else if(U===41||U===93)B--;else if(U===123&&B===0){F=N;break}else if(U===61&&N+1<G.length&&G.charCodeAt(N+1)===62&&B===0){F=N,W=!0;break}}if(F!==-1)O=G.slice(0,F).trim();else O=G.trim()}if(O==="unknown"){if(Q&&z)O="AsyncGenerator<unknown, void, unknown>";else if(z)O="Generator<unknown, void, unknown>";else if(Q)O="Promise<void>"}else if(Q&&!O.startsWith("Promise<")&&!O.startsWith("AsyncGenerator<"))O=`Promise<${O}>`;let q=P(H);return`${L}${q} => ${O}`}function A(J,Y,X,Q){let z=0;for(let L=Y;L<J.length;L++)if(J[L]===X)z++;else if(J[L]===Q){if(z--,z===0)return L}return-1}function Xz(J){let Y=0,X=0,Q=!1,z="";for(let L=0;L<J.length-1;L++){let Z=J[L],$=J[L+1],H=L>0?J[L-1]:"";if(!Q&&(Z==='"'||Z==="'"||Z==="`"))Q=!0,z=Z;else if(Q&&Z===z&&H!=="\\")Q=!1;if(!Q){if(Z==="(")Y++;else if(Z===")")Y--;else if(Z==="[")X++;else if(Z==="]")X--;if(Z==="="&&$===">"&&Y===0&&X===0)return L}}return-1}function y(J,Y=!1,X=0,Q=!0){let z=J.trim();if(z.length>200&&D(z,"=>")>2&&D(z,"<")>5&&!z.startsWith("function"))return Y?"((...args: any[]) => any)":"(...args: any[]) => any";if(z.startsWith("async ")&&z.includes("=>")){let Z=z.slice(5).trim(),$=Z.indexOf("=>"),H=Z.substring(0,$).trim(),O=Z.substring($+2).trim();if(H=P(H),H==="()"||H==="")H="()";else if(!H.startsWith("("))H=`(${H})`;let K="unknown";if(O.startsWith("{"))K="unknown";else K=b(O,Q,!1,X+1);let q=`${H} => Promise<${K}>`;return Y?`(${q})`:q}if(z.includes("=>")){let Z="",$=z;if(z.startsWith("<")){let W=A(z,0,"<",">");if(W!==-1)Z=z.substring(0,W+1),$=z.substring(W+1).trim()}let H=Xz($);if(H===-1)return Y?"(() => unknown)":"() => unknown";let O=$.substring(0,H).trim(),K=$.substring(H+2).trim(),q="",G=O.lastIndexOf("):");if(G!==-1){let W=O.substring(G+2).trim();if(W&&!W.includes("=>")&&!W.includes("="))q=W,O=O.substring(0,G+1)}if(O=P(O),O==="()"||O==="")O="()";else if(!O.startsWith("("))O=`(${O})`;let B="unknown";if(q)B=q;else if(K.startsWith("{"))B="unknown";else if(K.includes("=>")){let W=K.trimStart(),N=W.indexOf("("),U=N!==-1?A(W,N,"(",")"):-1,M=U!==-1?W.indexOf("=>",U):-1;if(N===0&&U!==-1&&M!==-1){let V=W.substring(N+1,U).trim(),j=P(V);if(Z.includes("T")&&j.includes("T"))B=`(${j}) => T`;else B=`(${j}) => any`}else B="any"}else if(Y)B="unknown";else B=b(K,Q,!1,X+1);let F=`${Z}${O} => ${B}`;return Y?`(${F})`:F}if(z.startsWith("function")){let Z=8,$=z.length;while(Z<$&&z.charCodeAt(Z)<=32)Z++;let H=!1;if(Z<$&&z.charCodeAt(Z)===42){H=!0,Z++;while(Z<$&&z.charCodeAt(Z)<=32)Z++}let O="";if(Z<$&&z.charCodeAt(Z)===60){let G=Z,B=1;Z++;while(Z<$&&B>0){let F=z.charCodeAt(Z);if(F===60)B++;else if(F===62)B--;Z++}O=z.substring(G,Z);while(Z<$&&z.charCodeAt(Z)<=32)Z++}let K=z.indexOf("(",Z);if(K!==-1){let G=1,B=K+1;while(B<$&&G>0){let U=z.charCodeAt(B);if(U===40)G++;else if(U===41)G--;B++}let F=z.substring(K+1,B-1).trim(),W=F?`(${F})`:"()";if(H){let U=z.substring(B).trim(),M=U.indexOf("Generator<");if(M!==-1){let j=M+10,T=U.indexOf(">",j);if(T!==-1){let u=U.substring(j,T),v=`${O}${W} => Generator<${u}>`;return Y?`(${v})`:v}}let V=`${O}${W} => Generator<any, any, any>`;return Y?`(${V})`:V}let N=`${O}${W} => unknown`;return Y?`(${N})`:N}let q="(...args: any[]) => unknown";return Y?`(${q})`:q}if(z.includes("=>")&&z.includes("(")&&z.includes(")")){if(z.length>100||D(z,"=>")>2){let Z="";if(z.charCodeAt(0)===60){let q=A(z,0,"<",">");if(q!==-1)Z=z.substring(0,q+1)}let $=z.indexOf("("),H=$!==-1?A(z,$,"(",")"):-1,O=$!==-1&&H!==-1?z.substring($,H+1):"(...args: any[])";O=P(O);let K=`${Z}${O} => any`;return Y?`(${K})`:K}return Y?`(${z})`:z}let L="() => unknown";return Y?`(${L})`:L}function Fz(J){let Y=J.trim();if(Y==="any"||Y==="object"||Y==="unknown")return!0;if(Y.startsWith("Record<")&&Y.endsWith(">"))return!0;if(Y.startsWith("Array<")&&Y.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(Y))return!0;return!1}function Lz(J){let Y=J.lastIndexOf(" satisfies ");if(Y===-1)return null;let X=J.slice(Y+11).trim();if(X.endsWith(";"))X=X.slice(0,-1).trim();return X||null}var Yz=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Zz=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,$z=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function Gz(J){let Y=[],X=0;for(let Q=0;Q<=J.length;Q++)if(Q===J.length||J[Q]===`
|
|
16
|
+
`){let z=X,L=Q;while(z<L&&(J[z]===" "||J[z]==="\t"||J[z]==="\r"))z++;while(L>z&&(J[L-1]===" "||J[L-1]==="\t"||J[L-1]==="\r"))L--;let Z=J.slice(z,L);if(X=Q+1,Z.startsWith("///")){if(Z.indexOf("<")===-1)continue;if(Yz.test(Z)||Zz.test(Z)||$z.test(Z))Y.push(Z)}else if(Z===""||Z.startsWith("//"))continue;else break}return Y}
|
|
17
|
+
export{Qz as Dc,Hz as Ec,b as Fc,l as Gc,I as Hc,w as Ic,s as Jc,A as Kc,y as Lc,Fz as Mc,Lz as Nc,Gz as Oc};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{oc as J}from"./chunk-
|
|
2
|
+
import{oc as J}from"./chunk-4mtbtmee.js";var S=typeof globalThis.Bun?.hash==="function";function z(B){if(S)return Bun.hash(B);let g=0;for(let T=0;T<B.length;T++){let p=B.charCodeAt(T);g=(g<<5)-g+p,g=g&g}return g}var U=100,G=0,f=new Map;function $(B,g,T=!0,p=!1){let b=z(B),j=`${g}:${T?1:0}:${p?1:0}`,w=f.get(j);if(w&&w.contentHash===b)return w.lastAccess=++G,w.declarations;let q=J(B,g,T,p);if(f.set(j,{declarations:q,contentHash:b,lastAccess:++G}),f.size>U){let Q=Math.max(1,Math.ceil(f.size*0.1)),x=[];for(let[u,F]of f)x.push([u,F.lastAccess]);x.sort((u,F)=>u[1]-F[1]);for(let u=0;u<Q&&u<x.length;u++)f.delete(x[u][0])}return q}function v(){f.clear()}
|
|
3
3
|
export{z as lc,$ as mc,v as nc};
|