@visulima/vis 3.0.5 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/LICENSE.md +0 -116
- package/README.md +3 -2
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +24 -4
- package/dist/packem_chunks/CONFIG_FILES.js +6 -5
- package/dist/packem_chunks/catalog.js +32 -32
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +153 -152
- package/dist/packem_chunks/handler12.js +25 -10
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler67.js +28 -25
- package/dist/packem_chunks/handler68.js +25 -153
- package/dist/packem_chunks/handler69.js +153 -10
- package/dist/packem_chunks/handler70.js +10 -22
- package/dist/packem_chunks/handler71.js +21 -22
- package/dist/packem_chunks/handler72.js +23 -322
- package/dist/packem_chunks/handler73.js +273 -659
- package/dist/packem_chunks/handler74.js +708 -48
- package/dist/packem_chunks/handler75.js +48 -27
- package/dist/packem_chunks/handler76.js +27 -3
- package/dist/packem_chunks/handler77.js +3 -189
- package/dist/packem_chunks/handler78.js +188 -39
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_shared/{affected-selection-DIgAsQTu.js → affected-selection-BmUh3_Qp.js} +1 -1
- package/dist/packem_shared/{bin-CVfNImCA.js → bin-D-Es9mva.js} +1 -1
- package/dist/packem_shared/{index-5GrALmsb.js → index-BvYJA7e5.js} +1 -1
- package/dist/packem_shared/lockfile-DVFySxTS.js +1 -0
- package/dist/packem_shared/{package-version-CIhwFJn3.js → package-version-B_KfpWKC.js} +1 -1
- package/dist/packem_shared/{project-name-filter-sYH4Zvsm.js → project-name-filter-D6uEN2ot.js} +1 -1
- package/dist/packem_shared/vis-user-error-By2ZNeEA.js +31 -0
- package/index.d.ts +204 -204
- package/index.js +26 -26
- package/package.json +13 -13
- package/schemas/project.schema.json +2 -2
- package/schemas/vis-config.schema.json +8 -9
- package/skills/vis/SKILL.md +1 -1
- package/dist/packem_shared/lockfile-35RFsJDs.js +0 -1
- package/dist/packem_shared/vis-user-error-CgyYA29v.js +0 -30
|
@@ -1,189 +1,3 @@
|
|
|
1
|
-
import{createRequire as rr}from"node:module";import{e as ue,m as Ss,$ as or,a as cr,z as ar}from"../packem_shared/index-DHD8wb6Z.js";import{expandAffected as lr,getChangedFiles as dr,buildEnhancedPath as ur,enforceProjectConstraints as fr,expandTokensInString as zt,parsePartition as hr,TaskScheduler as pr,createTaskGraph as mr,reverseTaskGraph as gr,resolveTurboEnvCompat as wr,CompositeLifeCycle as Yt,defaultTaskRunner as Kt,TerminalBuffer as yt,runConcurrently as tt,createLogReporter as vr,generateRunSummary as Xt,writeRunSummary as yr,readLastRunSummary as xr,getLastRunSummaryPath as jr,writeChromeTrace as kr}from"@visulima/task-runner";import{i as Ye}from"../packem_shared/index-BjdW45xX.js";import{U as Ts,W as br,T as Sr,v as Jt,X as Tr,Y as $r,d as Ir,Z as Cr,ap as Er,aq as Rr,ar as Pr,as as Mr,k as Fr,at as Or}from"./cli-main.js";import{u as U,y as n,X as g,m as a,E as me,R as J,w as Ar,d as Lr,b as Dr,Q as Br}from"./catalog.js";import{V as Ze}from"../packem_shared/vis-user-error-CgyYA29v.js";import{d as _r,r as Nr}from"../packem_shared/lockfile-35RFsJDs.js";import{y as $s}from"../packem_shared/index-BisalDCf.js";import{F as Yr}from"../packem_shared/failure-log-DE_MJCzB.js";import{r as Kr}from"../packem_shared/command-runtime-CiLVo4ED.js";import{r as Xr}from"../packem_shared/toolchain-DY11tPCw.js";import{i as Jr,r as Qr,s as Zr,a as en,b as tn,c as sn,d as rn,e as nn,H as on,f as cn}from"../packem_shared/lifecycle-DW8KRF5d.js";import{s as an}from"../packem_shared/affected-selection-DIgAsQTu.js";import{c as Zt,p as ln,a as dn,b as un,r as fn,f as hn,s as pn}from"../packem_shared/project-name-filter-sYH4Zvsm.js";import{p as mn,r as gn,f as wn,a as vn}from"../packem_shared/selectors-B7lSFz7l.js";import{r as at,l as jt,d as yn,s as xn,m as jn,a as kn}from"../packem_shared/target-options-d_rIrLyq.js";import{T as Is,C as Cs,D as lt,E as Es}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as In,j as Cn,X as ht,F as ts}from"../packem_shared/index.server-BAjDJSEu.js";import{parseStacktrace as En,codeFrame as Rn}from"@visulima/error";import{originalPositionFor as Pn,sourceContentFor as Mn,loadSourceMap as Fn}from"@visulima/source-map";import{l as Rs}from"../packem_shared/spinner-BM_0Bj6x.js";import{R as Bn,c as st}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{c as ss,a as _n,s as rs}from"../packem_shared/watch-Dswvj6Zp.js";import gt from"./index.js";import{U as Ps}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";let nr;const ir=s=>(nr??=rr(import.meta.url))(s),ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Pe=s=>{if(typeof ze<"u"&&ze.versions&&ze.versions.node){const[e,t]=ze.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return ze.getBuiltinModule(s)}return ir(s)},{existsSync:De,mkdirSync:Gr,writeFileSync:xt,readFileSync:We,openSync:Wr,statSync:Qt,readSync:Hr,closeSync:qr,mkdtempSync:Vr}=Pe("node:fs"),{createInterface:Ur,emitKeypressEvents:zr}=Pe("node:readline"),{isAbsolute:bn,resolve:es,dirname:Sn,relative:Tn}=Pe("node:path"),{fileURLToPath:$n}=Pe("node:url"),{createHash:On}=Pe("node:crypto"),{mkdir:An,appendFile:dt}=Pe("node:fs/promises"),{platform:Ln,homedir:kt,tmpdir:Dn}=Pe("node:os"),{spawn:Nn}=Pe("node:child_process"),Gn=27,Wn={95:"apc",80:"dcs",94:"pm",88:"sos"},Hn={159:"apc",144:"dcs",158:"pm",152:"sos"},Ms=s=>s===155||s===157||s===144||s===152||s===158||s===159,Fs=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},rt=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const c=s.codePointAt(r);if(c===156||t&&c===7)return r;if(c===27&&s.codePointAt(r+1)===92)return r+1}return-1},qn=(s,e)=>{const t=s.codePointAt(e+1);if(t===91){const r=Fs(s,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(t===93){const r=rt(s,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===80||t===88||t===94||t===95){const r=rt(s,e+2,!1),c=Wn[t];return r===-1?void 0:{end:r,kind:c}}return t===void 0?void 0:{end:e+1,kind:"escape"}},Vn=(s,e)=>{const t=s.codePointAt(e);if(t===155){const r=Fs(s,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(t===157){const r=rt(s,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===144||t===152||t===158||t===159){const r=rt(s,e+1,!1),c=Hn[t];return r===-1?void 0:{end:r,kind:c}}},Un=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Ms(s.codePointAt(e)))return!0;return!1},zn=s=>{if(!Un(s))return s;let e="",t=0,r=0;const{length:c}=s;for(;r<c;){const o=s.codePointAt(r);let i;if(o===Gn)i=qn(s,r);else if(Ms(o))i=Vn(s,r);else{r+=1;continue}const d=i===void 0?c-1:i.end;e+=s.slice(t,r),t=d+1,r=d+1}return e+=s.slice(t),e},Yn=(s,e,t,r,c,o,i,d,u,p,f,h,l,b)=>{const T={d:r,h:c,m:o,mo:e,ms:d,s:i,w:t,y:s};return T.future=u,T.past=p,T.decimal=f,h!==void 0&&(T.unitMap=h),T.groupSeparator=l,T.placeholderSeparator=b,T},Kn={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Xn=Yn(s=>`year${s===1?"":"s"}`,s=>`month${s===1?"":"s"}`,s=>`week${s===1?"":"s"}`,s=>`day${s===1?"":"s"}`,s=>`hour${s===1?"":"s"}`,s=>`minute${s===1?"":"s"}`,s=>`second${s===1?"":"s"}`,s=>`millisecond${s===1?"":"s"}`,"in %s","%s ago",".",Kn,",","_"),ns=new WeakSet,Jn=s=>{if(ns.has(s))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(s,r))throw new TypeError(`Missing required property: ${r}`);if(s.future!==void 0&&typeof s.future!="string")throw new TypeError("Properties future and past must be of type string");if(s.past!==void 0&&typeof s.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const r of t)if(typeof s[r]!="string"&&typeof s[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(s.decimal&&typeof s.decimal!="string")throw new TypeError("Property decimal must be of type string");if(s.delimiter&&typeof s.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(s._digitReplacements&&!Array.isArray(s._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(s._numberFirst&&typeof s._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(s.unitMap&&typeof s.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(s.unitMap&&Object.values(s.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");ns.add(s)},Os=(s,e)=>{if(!Number.isFinite(s)||e<0||Number.isInteger(s))return s;const t=10**e,r=Number((s*t).toPrecision(15));return Math.trunc(r)/t},is=({unitCount:s,unitName:e},t,r)=>{let{spacer:c}=r;const{maxDecimalPoints:o}=r;let i=".";r.decimal!==void 0?i=r.decimal:t.decimal!==void 0&&(i=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let u,p=s;o!==void 0&&(p=Os(s,o));const f=p.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const b of f)u+=b==="."?i:d[b]}else u=f.replace(".",i);else u="";const h=t[e];let l=h;return typeof h=="function"&&(l=h(s)),t._hideCountIf2&&s===2&&(c=""),t._numberFirst?l+c+u:u+c+l},Qn=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,c=e.largest??Number.POSITIVE_INFINITY,o={};let i,d,u,p=s;for(d=0;d<t.length;d++){i=t[d];const h=r[i];u=d===t.length-1?p/h:Math.floor(p/h),o[i]=u,p-=u*h}if(e.round){let h=c;for(d=0;d<t.length;d++)if(i=t[d],u=o[i],u!==0&&(h--,h===0)){for(let l=d+1;l<t.length;l++){const b=t[l],T=o[b];o[i]=(o[i]??0)+T*r[b]/r[i],o[b]=0}break}for(d=t.length-1;d>=0;d--){if(i=t[d],u=o[i],u===0)continue;const l=Math.round(u);if(o[i]=l,d===0)break;const b=t[d-1],T=r[b],N=Math.floor(l*r[i]/T);if(N)o[b]=(o[b]??0)+N,o[i]=0;else break}}const f=[];for(d=0;d<t.length&&f.length<c;d++){if(i=t[d],u=o[i],u&&!e.round&&f.length===c-1){let h,l=0;for(h=d+1,t.length;h<t.length;h++){const b=t[h];l+=o[b]*(e.unitMeasures[b]/e.unitMeasures[i])}u+=l,e.maxDecimalPoints!==void 0&&(u=Os(u,e.maxDecimalPoints))}u&&f.push({unitCount:u,unitName:i})}return f},Zn=(s,e,t)=>{const{language:r,units:c}=e;if(s.length===0){const h=c.at(-1);return is({unitCount:0,unitName:h},r,e)}const{conjunction:o,serialComma:i}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:r.delimiter!==void 0&&(d=r.delimiter);let u="";e.timeAdverb&&t!==0&&(u=r.future??"",t<0&&(u=r.past??""));const p=s.map(h=>is(h,r,e));let f;return!o||s.length===1?f=p.join(d):s.length===2?f=p.join(o):f=p.slice(0,-1).join(d)+(i?",":"")+o+(p.at(-1)??""),u&&(f=u.replace("%s",f)),f},ei=(s,e)=>{if(Number.isNaN(s))throw new TypeError("Expected a valid number");if(typeof s!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:Xn,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Jn(t.language);const r=Math.abs(s),c=Qn(r,t);return Zn(c,t,s)},be="@voidzero-dev/vite-task-client",bt="@visulima/task-runner-client",nt=`npm:${bt}@^1`,As=ue(".vis",".vite-client-override-declined"),it="pnpm-workspace.yaml",ti=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Ls=s=>{try{return JSON.parse(We(s,"utf8"))}catch{return}},si=s=>{const e=ue(s,it);if(De(e))try{return $s(We(e,"utf8")).toJS()?.overrides}catch{return}},ri=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",ni=s=>{const e=ue(s,it);try{const t=$s(We(e,"utf8"));return t.setIn(["overrides",be],nt),xt(e,t.toString()),!0}catch{return!1}},os=s=>s!==void 0&&ti.some(e=>s[e]?.[be]!==void 0),ii=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[be]!==void 0||s.overrides?.[be]!==void 0||s.resolutions?.[be]!==void 0)||e?.[be]!==void 0,oi=(s,e=[])=>{const t=Ls(ue(s,"package.json")),r=De(ue(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:ii(t,si(s)),declined:De(ue(s,As)),manager:_r(s)?.manager,present:os(t)||r||e.some(c=>os(c))}},ci=s=>{try{const e=ue(s,As);Gr(Ss(e),{recursive:!0}),xt(e,`Declined adding the ${be} → ${bt} override.
|
|
2
|
-
Delete this file to be asked again.
|
|
3
|
-
`)}catch{}},ai=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&De(ue(s,it))&&ni(s))return{file:it,installCommand:t};const r=ue(s,"package.json"),c=Ls(r);if(!c)return;const o=ri(e);o==="pnpm.overrides"?(c.pnpm??={},c.pnpm.overrides??={},c.pnpm.overrides[be]=nt):(c[o]??={},c[o][be]=nt);try{xt(r,`${JSON.stringify(c,void 0,4)}
|
|
4
|
-
`)}catch{return}return{file:"package.json",installCommand:t}},li=async(s,e)=>{const t=oi(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=Ur({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${be}. Its cache hints no-op under @visulima/task-runner unless aliased to ${bt} (a drop-in replacement).`);const c=await new Promise(i=>{r.question("Add the override now? [y/N] ",i)});if(!/^y(?:es)?$/i.test(c.trim()))return ci(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=ai(s,t.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${be}": "${nt}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},di=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,ui=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),fi=(s,e,t)=>{const r=new Set,c=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:c};const o=[...t],i=new Set(o),d=new Map;for(const u of o){const p=u.lastIndexOf(":");if(p===-1)continue;const f=u.slice(p+1),h=d.get(f);h===void 0?d.set(f,[u]):h.push(u)}for(const u of ui(s)){if(u.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${u}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(u)){r.add(u);continue}const p=mn(u);if(!p){c.push(u);continue}let f=!1;switch(p.kind){case"all":{const h=d.get(p.target)??[];for(const l of h)r.add(l),f=!0;break}case"project":{const h=p.projects?.[0];if(h!==void 0){const l=`${h}:${p.target}`;i.has(l)&&(r.add(l),f=!0)}break}case"tag":{const{tag:h}=p;if(h!==void 0){const l=d.get(p.target)??[];for(const b of l){const T=b.slice(0,b.lastIndexOf(":"));e.projects[T]?.tags?.includes(h)===!0&&(r.add(b),f=!0)}}break}}f||c.push(u)}return{skipTaskIds:r,unmatchedPatterns:c}},hi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,pi=new Set(["0","!","#","$","*","-","?","@","_"]),mi=s=>{const e=new Map;for(const t of s.matchAll(hi)){const r=t[1],c=t[3],o=t[2],i=r??c;if(i===void 0||pi.has(i))continue;const d=o!==void 0,u=e.get(i);u===void 0?e.set(i,d):u&&!d&&e.set(i,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},gi=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:c}=s,o=mi(e);if(o.length===0)return;const i=[];for(const{hasDefault:d,name:u}of o){if(d)continue;const p=r[u],f=t[u];p===void 0&&f===void 0&&i.push(u)}if(i.length!==0)return{missing:i.toSorted(),taskId:c}},wi=s=>{const e=s.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${s.taskId} references unset variable${s.missing.length===1?"":"s"} ${e}. Set ${s.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},vi=64*1024,cs=256,yi=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),pt=s=>s.replaceAll(yi,"").replaceAll("\r","");class as{#e=[];#r=new Set;#s=new Map;#n=new Map;constructor(e=[]){for(const t of e)this.#n.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#n.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#n.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#n.has(e)||(this.#n.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,r=>({...r,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,r){const c=r?.message;this.#t(e,o=>({...o,errorMessage:pt(c??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-cs).map(c=>pt(c));this.#t(e,c=>({...c,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
|
|
5
|
-
`).map(c=>pt(c)).filter(c=>c.length>0);r.length!==0&&this.#t(e,c=>{const o=[...c.tailLines,...r];for(;o.length>cs;)o.shift();let i=0;for(let d=o.length-1;d>=0;d--)if(i+=o[d].length+1,i>vi){o.splice(0,d+1);break}return{...c,lastLine:r[r.length-1],tailLines:o}})}abortBoot(e){let t=!1;const r=new Map(this.#n);for(const[c,o]of r)(o.status==="pending"||o.status==="starting")&&(r.set(c,{...o,errorMessage:e,status:"failed"}),t=!0);t&&(this.#n=r,this.#i(),this.#o())}#t(e,t){const r=this.#n.get(e);r&&(this.#n.set(e,t(r)),this.#i(),this.#o())}#i(){this.#s=new Map(this.#n)}#o(){for(const e of this.#r)try{e()}catch{}}}const xi=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(const[t,r]of s.entries())if(!Object.is(r,e[t]))return!1;return!0},ls=({children:s,deps:e,onRender:t,style:r,width:c})=>{const o=U.useRef(null),i=U.useRef(!1),d=U.useRef(e),u=U.useRef(s),p=U.useRef(t);p.current=t;let f=!1;e!==void 0?xi(d.current,e)||(f=!0,d.current=e):s!==u.current&&(f=!0,u.current=s),f&&(i.current=!1,o.current&&(o.current.cachedRender=void 0)),U.useLayoutEffect(()=>{const l=o.current;l&&(l.internal_onRendered=()=>{i.current=!0,p.current?.(l)})}),U.useEffect(()=>()=>{const l=o.current;l&&(l.cachedRender=void 0,l.internal_onRendered=void 0)},[]);const h=U.useMemo(()=>({...r,width:c}),[r,c]);return n.jsx("ink-static-render",{ref:o,style:h,children:i.current?null:s()})},ji=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),ki=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${ji(t)}`,St=(s,e,t)=>{const r=new Set(new Set(t.map(l=>l.target.target))),c=new Set(new Set(t.map(l=>l.target.project))),o=e.filter(l=>r.has(l)),i=s.filter(l=>c.has(l)),d=t.length-i.length*o.length,u=o.length===1?"target":"targets",p=o.join(", "),f=i.length===1?`project ${i[0]}`:`${i.length} projects`;let h=`${u} ${p} for ${f}`;return d>0&&(h+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),h},bi={error:"red",info:"white",success:"green"},wt=({children:s,title:e,variant:t})=>{const r=bi[t];return n.jsxs(g,{flexDirection:"column",children:[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(a,{bold:!0,color:r,children:"•"}),n.jsx(a,{children:e})]}),s]})},Ds=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:c,skippedIds:o,succeeded:i,targets:d,tasks:u,took:p})=>{const f=St(r,d,u),h=c??[];if(e===0&&(!o||o.length===0)){const l=s>0?` (${s} read from cache)`:"";return n.jsx(ls,{children:()=>n.jsx(wt,{title:`Successfully ran ${f}`,variant:"success",children:n.jsxs(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[n.jsxs(a,{children:[n.jsx(a,{color:"green",children:Is})," ",i+s," tasks completed",l?n.jsx(a,{dimColor:!0,children:l}):null,n.jsx(a,{dimColor:!0,children:` · Took ${p}`})]}),h.length>0&&n.jsxs(g,{flexDirection:"column",marginTop:1,children:[n.jsxs(a,{children:[n.jsx(a,{color:"yellow",children:"↻"})," ",n.jsx(a,{color:"yellow",children:String(h.length)})," task",h.length===1?"":"s"," succeeded after retry:"]}),h.map(b=>n.jsxs(a,{children:[" ",n.jsx(a,{color:"yellow",children:"↻"})," ",b]},b))]})]})})})}return n.jsx(ls,{children:()=>n.jsx(wt,{title:`Ran ${f}`,variant:"error",children:n.jsxs(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(a,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(l=>n.jsxs(a,{dimColor:!0,children:[" - ",l]},l)),n.jsx(a,{})]}),e>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(a,{children:[n.jsx(a,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(l=>n.jsxs(a,{children:[" ",n.jsx(a,{color:"red",children:Cs})," ",l]},l)),n.jsx(a,{})]}),h.length>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(a,{children:[n.jsx(a,{color:"yellow",children:String(h.length)})," ","task",h.length===1?"":"s"," ","finished after retry:"]}),h.map(l=>n.jsxs(a,{children:[" ",n.jsx(a,{color:"yellow",children:"↻"})," ",l]},l)),n.jsx(a,{})]}),n.jsx(a,{dimColor:!0,children:` Took ${p}`})]})})})};class ot{#e;#r=new Set;#s=new Map;constructor(e,t){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:t??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const t=[...this.#e.rows];for(const r of e){const c=t.findIndex(o=>o.taskId===r.id);c!==-1&&(t[c]={...t[c],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:t,running:this.#e.running+e.length})}endTasks(e){const t=[...this.#e.rows];let{cached:r,completed:c,failed:o,succeeded:i}=this.#e;const d=new Map(this.#e.outputs),u=[...this.#e.retriedIds];for(const h of e){const l=t.findIndex(b=>b.taskId===h.task.id);switch(l!==-1&&(t[l]={...t[l],duration:h.startTime&&h.endTime?h.endTime-h.startTime:void 0,retryAttempts:h.retryAttempts,status:h.status}),h.retryAttempts&&h.retryAttempts>0&&u.push(h.task.id),c++,h.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}h.terminalOutput&&!d.has(h.task.id)&&d.set(h.task.id,h.terminalOutput),this.#s.delete(h.task.id)}let{selectedIndex:p}=this.#e;if(o>this.#e.failed){const h=t.findIndex(l=>l.status==="failure");h!==-1&&(p=h)}const f=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:c,failed:o,outputs:d,retriedIds:u,rows:t,running:f,selectedIndex:p,succeeded:i})}static#n=256*1024;addOutput(e,t){if(!t.trim())return;let r=(this.#e.outputs.get(e)??"")+t;r.length>ot.#n&&(r=r.slice(-ot.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const t=[...this.#e.rows];for(let r=0;r<t.length;r++){const c=t[r];if(c.status==="running"){const o=this.#s.get(c.taskId);if(o){const i=process.hrtime(o),d=i[0]*1e3+i[1]/1e6;t[r]={...c,elapsed:d},e=!0}}}e&&this.#t({...this.#e,rows:t})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,t){const r=[...this.#e.pinnedTaskIds];r[e]=t,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],r=t.findIndex(d=>d.taskId===e);let{completed:c,failed:o,succeeded:i}=this.#e;if(r!==-1){const d=t[r].status;d==="failure"?(o=Math.max(0,o-1),c=Math.max(0,c-1)):d==="success"&&(i=Math.max(0,i-1),c=Math.max(0,c-1)),t[r]={...t[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:c,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const t of this.#r)try{t()}catch{}}}const Si=s=>zn(s),Ti=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,$i=/^\s*at\s+/,Ii=s=>{const e=s.split(`
|
|
6
|
-
`);let t;for(let r=0;r<e.length;r++){const c=Ti.exec(e[r].trim());if(!c)continue;const o=[];for(let i=r+1;i<e.length&&i<=r+200;i++){const d=e[i];if($i.test(d))o.push(d.trim());else{if(o.length>0)break;if(d.trim()!=="")break}}if(o.length>0){const i=c.groups?.name??"Error",d=c.groups?.message??"";t={message:d,name:i,stack:`${i}: ${d}
|
|
7
|
-
${o.map(u=>` ${u}`).join(`
|
|
8
|
-
`)}`}}}return t},Bs=s=>{if(s.startsWith("file://"))try{return $n(s)}catch{return s}return s},Ci=s=>!s.includes("node_modules")&&!s.startsWith("node:")&&!s.startsWith("internal/"),Ei=s=>{try{return Fn(s)}catch{return}},Ri=(s,e)=>{if(!s.file||s.line===void 0)return;const t=Bs(s.file),r=bn(t)?t:es(e,t);if(!Ci(r)||!De(r))return;const c=Ei(r);if(c){const o=Pn(c,{column:s.column===void 0?0:Math.max(0,s.column-1),line:s.line});if(o.source&&o.line!=null){const i=es(Sn(r),o.source),u=Mn(c,o.source)??(De(i)?We(i,"utf8"):void 0);if(u!==void 0)return{column:o.column==null?void 0:o.column+1,file:i,line:o.line,source:u}}}return{column:s.column,file:r,line:s.line,source:We(r,"utf8")}},ds=(s,e)=>{const t=Tn(e,s);return t&&!t.startsWith("..")?t:s},_s=(s,e)=>{if(!s?.trim())return s;try{const t=Ii(Si(s));if(!t)return s;const r=new Error(t.message);r.name=t.name,r.stack=t.stack;const c=En(r);if(c.length===0)return s;const o=e.color,i={dim:l=>o?ts(l):l,head:l=>o?Cn(ht(l)):l,loc:l=>o?In(l):l};let d,u;for(const l of c){const b=Ri(l,e.cwd);if(b){d=b,u=l;break}}const p=[i.head(`✖ ${t.name}${t.message?`: ${t.message}`:""}`)];if(d){const l=`${ds(d.file,e.cwd)}:${d.line}${d.column?`:${d.column}`:""}`;p.push(` ${i.loc(l)}`,""),p.push(Rn(d.source,{start:{column:d.column,line:d.line}},{color:o?{gutter:ts,marker:ht,message:ht}:void 0,linesAbove:2,linesBelow:3}))}const f=c.filter(l=>l!==u).slice(0,8).map(l=>{const b=l.methodName??"<anonymous>",T=l.file?`${ds(Bs(l.file),e.cwd)}${l.line?`:${l.line}`:""}`:"";return i.dim(` at ${b}${T?` (${T})`:""}`)});f.length>0&&p.push("",...f);const h=i.dim("─".repeat(40));return`${p.join(`
|
|
9
|
-
`)}
|
|
10
|
-
${h}
|
|
11
|
-
${s}`}catch{return s}},Pi={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},Be=s=>ei(s,Pi),Ge=s=>s==="local-cache"||s==="local-cache-kept-existing"||s==="remote-cache",He=s=>{switch(s){case"failure":return{color:"red",icon:Cs};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Is};case"skipped":return{color:"gray",icon:lt};default:return{color:"gray",icon:"?"}}},Ke=s=>{const{color:e,icon:t}=He(s);return me(J.createElement(a,{color:e},t),{columns:10}).trim()},Mi=s=>{const{color:e,icon:t}=He(s);switch(s){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return me(J.createElement(a,null,J.createElement(a,{color:e},t)," ",J.createElement(a,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return me(J.createElement(a,null,J.createElement(a,{dimColor:!0},t)," ",J.createElement(a,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return me(J.createElement(a,{color:e},t),{columns:10}).trim()}},Fi=s=>s==="azure"||s==="buildkite"||s==="github"||s==="gitlab"||s==="off"?s:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",Oi=s=>{const e=s.replaceAll(/\W+/g,"_"),t=On("sha256").update(s).digest("hex").slice(0,6);return`${e}_${t}`},Ai=(s,e,t,r="auto")=>{const c=t.trim();if(!c)return;const o=`
|
|
12
|
-
`,i=Fi(r);if(i==="github"){process.stdout.write(`::group::${Ke(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`::endgroup::${o}`);return}if(i==="gitlab"){const h=Math.floor(Date.now()/1e3),l=Oi(s),b=e==="failure"?"":"[collapsed=true]",T="\x1B[0K";process.stdout.write(`${T}section_start:${String(h)}:${l}${b}\r${T}${Ke(e)} ${s}${o}`),process.stdout.write(c+o);const N=Math.floor(Date.now()/1e3);process.stdout.write(`${T}section_end:${String(N)}:${l}\r${T}${o}`);return}if(i==="buildkite"){const h=e==="failure"?"+++":"---";process.stdout.write(`${h} ${Ke(e)} ${s}${o}`),process.stdout.write(c+o);return}if(i==="azure"){process.stdout.write(`##[group]${Ke(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`##[endgroup]${o}`);return}const d=process.stdout.columns||80,u=me(J.createElement(a,{dimColor:!0},lt.repeat(d)),{columns:d}).trim(),p=Mi(e),f=me(J.createElement(a,{bold:!0},s),{columns:d}).trim();process.stdout.write(`${u}${o}`),process.stdout.write(`${p} ${f}${o}`),process.stdout.write(c+o),process.stdout.write(`${u}${o}`)},Li=s=>s==="running"?{color:"white",icon:"•"}:s==="pending"?{color:"gray",icon:"·"}:He(s),Di=({autoScroll:s,focused:e,interactiveMode:t,showFullscreenHint:r,statusValue:c,supportsInteractive:o,taskId:i})=>{if(!i)return;if(t)return"Esc cancel | Enter send";const d=s?"":" PAUSED (f resume)",u=o?" i INPUT":"";return e&&c==="running"&&r?`⏎ FULLSCREEN${u} f FOLLOW${d}`:e&&c==="running"?`f FOLLOW${u}${d}`:e&&r?`<enter> full screen${d}`:e?d||void 0:"<tab> or <enter> to focus"},us=({autoScroll:s=!0,duration:e,focused:t,interactiveMode:r,output:c,scrollRef:o,showFullscreenHint:i,status:d,supportsInteractive:u=!0,taskId:p})=>{const f=d??"pending",{icon:h}=Li(f),l=t?"bold":"single",b=f==="failure"?"red":f==="success"||Ge(f)?t?"green":"gray":f==="running"?t?"white":"cyan":t?"white":"gray",T=p?`${h} ${p}`:void 0,N=e===void 0?void 0:Be(e),F=Di({autoScroll:s,focused:t,interactiveMode:r??!1,showFullscreenHint:i??!1,statusValue:f,supportsInteractive:u,taskId:p});if(!p)return n.jsxs(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[n.jsx(a,{dimColor:!0,children:"Select a task to view output"}),n.jsx(a,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const S=[];if(c)for(const E of c.split(`
|
|
13
|
-
`))S.push(E.endsWith("\r")?E.slice(0,-1):E);return!c&&(f==="running"||f==="pending")?n.jsx(g,{borderBottomTitle:F,borderColor:b,borderStyle:l,borderTopRightTitle:N,borderTopTitle:T,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:n.jsx(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:n.jsx(a,{dimColor:!0,children:"Waiting for task output…"})})}):n.jsxs(g,{borderBottomTitle:F,borderColor:r?"yellow":b,borderStyle:l,borderTopRightTitle:N,borderTopTitle:T,flexDirection:"column",flexGrow:1,children:[n.jsx(g,{flexGrow:1,flexShrink:1,paddingY:1,children:n.jsx(Ts,{flexGrow:1,followOutput:s,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:n.jsx(a,{children:S.join(`
|
|
14
|
-
`)})})}),r&&n.jsx(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:n.jsx(a,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},Bi={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Ns=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",_i=({status:s})=>s==="starting"?n.jsx(a,{color:"cyan",children:n.jsx(Rs,{type:"dots"})}):n.jsx(a,{bold:!0,color:Ns(s),children:Bi[s]}),Ni=({active:s,focused:e,state:t})=>{const r=e&&s,c=r?">":" ",o=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return n.jsxs(g,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[n.jsx(a,{children:c}),n.jsx(a,{children:" "}),n.jsx(g,{flexShrink:0,width:3,children:n.jsx(_i,{status:t.status})}),n.jsx(g,{flexGrow:0,flexShrink:0,width:28,children:n.jsx(a,{bold:r,inverse:r,children:t.id})}),n.jsx(g,{flexGrow:1,flexShrink:1,overflow:"hidden",children:n.jsxs(a,{color:Ns(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Gi=({states:s})=>{const e=[];for(const r of s)r.status==="ready"&&e.push(r.id);const t=e.join(", ");return n.jsxs(g,{paddingX:1,children:[n.jsxs(a,{bold:!0,color:"green",children:["● ","Services"]}),n.jsxs(a,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&n.jsxs(a,{dimColor:!0,children:[" ",t]}),n.jsx(a,{dimColor:!0,children:" [Tab ↓]"})]})},Wi=({states:s})=>{const e=s.find(t=>t.status==="crashed"||t.status==="failed");return e?n.jsxs(g,{flexDirection:"column",paddingX:1,children:[n.jsxs(a,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>n.jsxs(a,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):n.jsx(n.Fragment,{})},Hi=({activeIndex:s,focused:e,store:t})=>{const r=U.useSyncExternalStore(t.subscribe,t.getSnapshot),c=t.getIds();if(c.length===0)return n.jsx(n.Fragment,{});const o=c.map(f=>r.get(f)).filter(f=>f!==void 0),i=t.getDockState(),d=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan",u=i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",p=e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return i==="ready"&&!e?n.jsx(g,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:n.jsx(Gi,{states:o})}):n.jsxs(g,{borderBottomTitle:p,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:u,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&n.jsx(Wi,{states:o}),o.map((f,h)=>n.jsx(Ni,{active:h===s,focused:e,state:f},f.id))]})},Gs=6,Ws=8,Hs=12,qi=s=>s==="running"||s==="pending"?Es:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":lt,fs=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",hs=({compact:s,focused:e,isSelected:t,pinLabel:r,row:c})=>{const{persistent:o,status:i,taskId:d}=c,u=e&&t,p=u?">":" ",f=i==="running"&&o===!0;let h;if(f)h=n.jsx(a,{bold:!0,color:"green",children:" ● "});else if(i==="running")h=n.jsxs(a,{bold:!0,color:"white",children:[" ",n.jsx(Rs,{type:"dots"})," "]});else if(i==="pending")h=n.jsx(a,{bold:!0,color:"gray",children:" · "});else{const{color:b,icon:T}=He(i);h=n.jsxs(a,{bold:!0,color:b,children:[" ",T," "]})}let l=Es;return f?l="running":i!=="running"&&i!=="pending"?l=c.duration===void 0?lt:Be(c.duration):i==="running"&&c.elapsed!==void 0&&(l=Be(c.elapsed)),n.jsxs(g,{children:[n.jsx(a,{children:p}),n.jsx(g,{width:Gs,children:h}),n.jsxs(g,{flexGrow:1,children:[n.jsx(a,{bold:u,inverse:u,children:d}),r?n.jsx(a,{dimColor:!0,children:` ${r}`}):null]}),!s&&n.jsx(g,{justifyContent:"flex-end",width:Ws,children:n.jsx(a,{dimColor:!Ge(i),children:qi(i)})}),!s&&n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(a,{color:f?"green":void 0,dimColor:i==="pending"||f,children:l})})]})},ps=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:c,parallelSlots:o=3,pinnedTaskIds:i,rows:d,scrollRef:u,selectedIndex:p,title:f})=>{const h=c==="error"?"red":c==="success"?"green":r?"white":"gray",l=d[p]?.taskId,b=[];let T=0;for(const E of d)E.status==="running"?b.push(E):E.status==="pending"&&(T+=1);const N=Math.min(o,b.length+T),F=N>1,S=[];if(F)for(let E=0;E<N;E++){const I=b[E];I?S.push(n.jsx(hs,{compact:s,focused:r,isSelected:I.taskId===l,pinLabel:fs(I.taskId,i),row:I},`par-${I.taskId}`)):S.push(n.jsxs(g,{children:[n.jsx(a,{children:" "}),n.jsx(g,{width:Gs,children:n.jsx(a,{bold:!0,color:"gray",children:" · "})}),n.jsx(a,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(E)}`))}return n.jsxs(g,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n.jsxs(g,{flexShrink:0,paddingX:1,children:[n.jsx(a,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(a,{children:` ${f}`}),!s&&n.jsxs(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[n.jsx(g,{justifyContent:"flex-end",width:Ws,children:n.jsx(a,{dimColor:!0,children:"Cache"})}),n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(a,{dimColor:!0,children:"Duration"})})]})]}),n.jsx(Ts,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:u,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(E=>n.jsx(hs,{compact:s,focused:r,isSelected:E.taskId===l,pinLabel:fs(E.taskId,i),row:E},E.taskId))}),F&&n.jsx(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:S}),e&&n.jsxs(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[n.jsx(a,{bold:!0,color:"white",children:"/ "}),n.jsx(a,{children:t}),n.jsx(a,{inverse:!0,children:" "})]})]})},ms=40,gs=10,ws=100,Vi=Object.freeze([]),Ui=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:c,stdinRegistry:o,store:i,targets:d,tasks:u})=>{const{exit:p}=br(),{columns:f,rows:h}=Sr(),l=U.useSyncExternalStore(i.subscribe,i.getSnapshot),b=U.useCallback($=>c?c.subscribe($):()=>{},[c]);U.useSyncExternalStore(b,()=>c?c.getDockState():"ready");const T=c?c.getIds():Vi,N=T.length>0,[F,S]=U.useState(0),[E,I]=U.useState(null),j=U.useSyncExternalStore(b,()=>E&&c?c.getState(E):void 0),[R,w]=U.useState(!1),O=U.useRef(null),B=U.useRef(null),k=U.useRef(null),[W,se]=U.useState(!1),[ae,Q]=U.useState(!0),ee=U.useRef({list:0,splitList:0,splitOutput:0}),ie=U.useCallback(()=>{l.viewMode==="list"?ee.current.list=B.current?.getScrollOffset()??0:l.viewMode==="split"&&(ee.current.splitList=B.current?.getScrollOffset()??0,ee.current.splitOutput=k.current?.getScrollOffset()??0)},[l.viewMode]),oe=U.useCallback($=>{setTimeout(()=>{if($==="list"){const x=ee.current.list;B.current?.scrollTo(x)}else if($==="split"){const x=ee.current.splitList;x>0?B.current?.scrollTo(x):B.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),k.current?.scrollTo(ee.current.splitOutput)}},0)},[i]),ge=U.useRef(!1);U.useEffect(()=>{l.done&&!ge.current&&(ge.current=!0,s>0&&l.failed===0&&se(!0)),!l.done&&ge.current&&(ge.current=!1,se(!1))},[l.done,l.failed,s]);const le=U.useMemo(()=>{const $=T.length>0?new Set(T):null,x=l.filterText?l.filterText.toLowerCase():null,C=[];for(const te of l.rows)$?.has(te.taskId)||l.statusFilter==="failed"&&te.status!=="failure"||l.statusFilter==="running"&&te.status!=="running"&&te.status!=="pending"||l.statusFilter==="passed"&&te.status!=="success"&&!Ge(te.status)||x&&!te.taskId.toLowerCase().includes(x)||C.push(te);return C},[l.rows,l.filterText,l.statusFilter,T]),K=(le[l.selectedIndex]??null)?.taskId??null,re=E?null:l.pinnedTaskIds[0]??K,X=re?l.rows.find($=>$.taskId===re):null,Se=j??null,_=E?(Se?.tailLines??[]).join(`
|
|
15
|
-
`):re?l.outputs.get(re)??"":"",z=U.useMemo(()=>X?.status==="failure"&&_?_s(_,{color:!process.env.NO_COLOR,cwd:process.cwd()}):_,[X?.status,_]),we=E??re,Me=E?Se?.status==="crashed"||Se?.status==="failed"?"failure":"running":X?.status,Fe=St(r,d,u),_e=l.done?`Completed ${Fe} (${Be((l.endTime??Date.now())-l.startTime)})`:`Running ${Fe}...`,ne=l.done?l.failed>0?"error":"success":"running",Te=U.useCallback($=>{B.current?.scrollTo(Math.max(0,$-2))},[]);if(U.useEffect(()=>{l.interactiveMode&&X?.status!=="running"&&i.setInteractiveMode(!1)},[l.interactiveMode,X?.status,i]),U.useEffect(()=>{if(!re)return;let $=f;l.viewMode==="split"&&f>=ws?$=f-Math.floor(f*.4)-2:(l.viewMode==="split"||l.viewMode==="fullscreen")&&($=f-2);const x=Math.max(1,h-4);o.get(re)?.resize?.($,x)},[f,h,l.viewMode,re]),Jt(($,x)=>{if(x.escape){i.setInteractiveMode(!1);return}if(!re)return;const C=o.get(re);if(!C){i.setInteractiveMode(!1);return}if(x.return)C.write("\r");else if(x.upArrow)C.write("\x1B[A");else if(x.downArrow)C.write("\x1B[B");else if(x.rightArrow)C.write("\x1B[C");else if(x.leftArrow)C.write("\x1B[D");else if(x.backspace)C.write("");else if(x.delete)C.write("\x1B[3~");else if(x.tab)C.write(" ");else if(x.home)C.write("\x1B[H");else if(x.end)C.write("\x1B[F");else if(x.pageUp)C.write("\x1B[5~");else if(x.pageDown)C.write("\x1B[6~");else if(x.ctrl&&$){const te=$.toUpperCase().codePointAt(0);te!==void 0&&te>=65&&te<=90&&C.write(String.fromCodePoint(te-64))}else $&&C.write($)},{isActive:l.interactiveMode}),Jt(($,x)=>{if($==="c"&&x.ctrl){p();return}if(!W){if(R){x.escape||$==="?"?w(!1):$==="q"?(w(!1),se(!0)):x.downArrow||$==="j"?O.current?.scrollBy(1):x.upArrow||$==="k"?O.current?.scrollBy(-1):x.pageDown?O.current?.scrollBy(5):x.pageUp?O.current?.scrollBy(-5):x.home?O.current?.scrollToTop():x.end&&O.current?.scrollToBottom();return}if($==="?"){w(!0);return}if($==="q"){se(!0);return}if($==="r"&&l.done){i.requestRerun();return}if($==="R"&&l.done){const C=le[l.selectedIndex];C?.status==="failure"&&i.requestRetry(C.taskId);return}if($==="F"&&!l.filterActive){const C=["all","failed","running","passed"],te=C.indexOf(l.statusFilter);i.setStatusFilter(C[(te+1)%C.length]);return}if(l.filterActive){if(x.escape){i.setFilterActive(!1);return}if(x.return){i.setFilterActive(!1);return}if(x.backspace){i.setFilter(l.filterText.slice(0,-1));return}if($&&!x.ctrl&&!x.meta){i.setFilter(l.filterText+$);return}return}if($==="i"&&X?.status==="running"&&(l.viewMode==="fullscreen"||l.viewMode==="split"&&l.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(l.viewMode==="fullscreen"){if(x.escape){i.setViewMode("split"),oe("split");return}if($==="f"){const C=!ae;Q(C),C&&k.current?.scrollToBottom();return}if(x.downArrow||$==="j"){Q(!1),k.current?.scrollBy(1);return}if(x.upArrow||$==="k"){Q(!1),k.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&$==="d"){Q(!1),k.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&$==="u"){Q(!1),k.current?.scrollBy(-12);return}if(x.home){Q(!1),k.current?.scrollToTop();return}if(x.end){Q(!0),k.current?.scrollToBottom();return}return}if(l.focusedPanel==="dock"&&N&&c){if(x.tab){I(null),i.setFocusedPanel("tasks");return}if(x.escape){i.setFocusedPanel("tasks"),I(null),l.viewMode==="split"&&(i.setViewMode("list"),oe("list"));return}if(x.downArrow||$==="j"){S(C=>Math.min(C+1,T.length-1));return}if(x.upArrow||$==="k"){S(C=>Math.max(C-1,0));return}if(x.return){const C=T[F];C&&(I(C),Q(!0),ie(),ee.current.splitList=0,ee.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),oe("split"));return}if(($==="r"||$==="R")&&e){const C=T[F],te=C?c.getState(C)?.status:void 0;if(C&&(te==="crashed"||te==="failed")){const Ae=e(C);Ae instanceof Promise&&Ae.catch(()=>{})}return}return}if(l.viewMode==="split"){if(x.tab){l.focusedPanel==="tasks"?i.setFocusedPanel("output"):N?i.setFocusedPanel("dock"):(I(null),i.setFocusedPanel("tasks"));return}if(l.focusedPanel==="output"){if(x.escape){if(E&&N){I(null),i.setViewMode("list"),i.setFocusedPanel("dock"),oe("list");return}I(null),i.setFocusedPanel("tasks");return}if(x.return){ie(),i.setViewMode("fullscreen");return}if($==="f"){const C=!ae;Q(C),C&&k.current?.scrollToBottom();return}if(x.downArrow||$==="j"){Q(!1),k.current?.scrollBy(1);return}if(x.upArrow||$==="k"){Q(!1),k.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&$==="d"){Q(!1),k.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&$==="u"){Q(!1),k.current?.scrollBy(-12);return}if(x.home){Q(!1),k.current?.scrollToTop();return}if(x.end){Q(!0),k.current?.scrollToBottom();return}return}if(x.escape){i.setViewMode("list"),oe("list");return}if(x.return){i.setFocusedPanel("output");return}}if(l.viewMode==="list"||l.viewMode==="split"&&l.focusedPanel==="tasks"){if(x.tab&&l.viewMode==="list"&&N){i.setFocusedPanel("dock");return}if(x.downArrow||$==="j"){const C=Math.min(l.selectedIndex+1,Math.max(0,le.length-1));i.setSelectedIndex(C),Te(C);return}if(x.upArrow||$==="k"){const C=Math.max(l.selectedIndex-1,0);i.setSelectedIndex(C),Te(C);return}if(x.return&&l.viewMode==="list"){Q(!0),ie(),ee.current.splitList=0,ee.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),oe("split");return}if($==="/"){i.setFilterActive(!0);return}if($==="1"&&K){i.pinTask(0,K);return}if($==="2"&&K){i.pinTask(1,K);return}if($==="0"){i.clearPins();return}x.escape&&l.filterText&&i.setFilter("")}}},{isActive:!l.interactiveMode}),f<ms||h<gs)return n.jsx(g,{alignItems:"center",height:h,justifyContent:"center",width:f,children:n.jsxs(a,{color:"yellow",children:["Terminal too small (",f,"x",h,"). Minimum:"," ",ms,"x",gs]})});const Oe=n.jsxs(g,{gap:1,children:[l.succeeded>0&&n.jsxs(a,{bold:!0,color:"green",children:["✓"," ",l.succeeded]}),l.cached>0&&n.jsxs(a,{dimColor:!0,children:["✓"," ",l.cached]}),l.failed>0&&n.jsxs(a,{bold:!0,color:"red",children:["✗"," ",l.failed]}),l.running>0&&n.jsxs(a,{color:"cyan",children:["◷"," ",l.running]}),n.jsxs(a,{dimColor:!0,children:[l.totalTasks," ","total"]}),l.statusFilter!=="all"&&n.jsxs(a,{color:"yellow",children:["[",l.statusFilter,"]"]})]});let fe;if(l.viewMode==="fullscreen")fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Esc"}),n.jsx(a,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"^u ^d"}),n.jsx(a,{dimColor:!0,children:"PAGE"})]},"page"),...X?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"i"}),n.jsx(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q")];else if(l.done){const $=le[l.selectedIndex]?.status==="failure";fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"r"}),n.jsx(a,{dimColor:!0,children:"RERUN"})]},"r"),...$?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"R"}),n.jsx(a,{dimColor:!0,children:"RETRY"})]},"R")]:[],n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"?"}),n.jsx(a,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"F"}),n.jsx(a,{dimColor:!0,children:"FILTER"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"⏎"}),n.jsx(a,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else l.viewMode==="split"&&l.focusedPanel==="output"?fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Esc"}),n.jsx(a,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),...X?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"i"}),n.jsx(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"⏎"}),n.jsx(a,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Tab"}),n.jsx(a,{dimColor:!0,children:"PANEL"})]},"tab"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"?"}),n.jsx(a,{dimColor:!0,children:"HELP"})]},"?")]:fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"?"}),n.jsx(a,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"/"}),n.jsx(a,{dimColor:!0,children:"FILTER"})]},"/"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"F"}),n.jsx(a,{dimColor:!0,children:"STATUS"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"⏎"}),n.jsx(a,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...l.viewMode==="split"?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Tab"}),n.jsx(a,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const xe=n.jsxs(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[n.jsx(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:fe}),n.jsx(g,{flexShrink:0,paddingX:1,children:Oe})]}),$e=n.jsxs(Tr,{backgroundColor:"#1e1e1e",footer:n.jsxs(a,{dimColor:!0,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n.jsx(a,{bold:!0,color:"white",children:"?"}),"/",n.jsx(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:O,title:"KEYBOARD SHORTCUTS",visible:R,width:52,children:[n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(a,{dimColor:!0,children:" Move up"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(a,{dimColor:!0,children:" Move down"})]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Tab"]}),n.jsx(a,{dimColor:!0,children:" Switch panel (split)"})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsx(a,{dimColor:!0,children:" Back / close"})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsx(a,{dimColor:!0,children:" Show output / fullscreen"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"VIEWS"})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsxs(a,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsxs(a,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"ACTIONS"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","/"]}),n.jsx(a,{dimColor:!0,children:" Filter by text"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","F"]}),n.jsx(a,{dimColor:!0,children:" Filter by status"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","1"]}),n.jsx(a,{dimColor:!0,children:"/"}),n.jsx(a,{bold:!0,color:"white",children:"2"}),n.jsx(a,{dimColor:!0,children:" Pin to output pane"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","0"]}),n.jsx(a,{dimColor:!0,children:" Clear pins"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","r"]}),n.jsx(a,{dimColor:!0,children:" Rerun all (done)"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","R"]}),n.jsx(a,{dimColor:!0,children:" Retry failed task"})]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","i"]}),n.jsx(a,{dimColor:!0,children:" Interactive input (running task)"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"SCROLLING"}),n.jsx(a,{dimColor:!0,children:" (output panel)"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(a,{dimColor:!0,children:" Scroll up"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(a,{dimColor:!0,children:" Scroll down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","^u"]}),n.jsx(a,{dimColor:!0,children:" Page up"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","^d"]}),n.jsx(a,{dimColor:!0,children:" Page down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Home"]}),n.jsx(a,{dimColor:!0,children:" Top"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","End"]}),n.jsx(a,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","f"]}),n.jsx(a,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),n.jsxs(g,{flexDirection:"column",children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"GENERAL"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","q"]}),n.jsx(a,{dimColor:!0,children:" Quit"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","?"]}),n.jsx(a,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ve=n.jsx($r,{autoExitSeconds:s>0?s:3,onCancel:()=>{se(!1)},visible:W}),Ce=N&&c?n.jsx(Hi,{activeIndex:F,focused:l.focusedPanel==="dock",store:c}):null;if(l.viewMode==="fullscreen")return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(us,{autoScroll:ae,duration:X?.duration??X?.elapsed,focused:!0,interactiveMode:l.interactiveMode,output:z,scrollRef:k,status:Me,supportsInteractive:!E,taskId:we})}),Ce,xe,ve,$e]});if(l.viewMode==="split"){const $=f>=ws,x=n.jsx(ps,{compact:!0,filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel==="tasks",headerStatus:ne,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:B,selectedIndex:l.selectedIndex,title:_e}),C=n.jsx(us,{autoScroll:ae,duration:X?.duration??X?.elapsed,focused:l.focusedPanel==="output",interactiveMode:l.interactiveMode,output:z,scrollRef:k,showFullscreenHint:!0,status:Me,supportsInteractive:!E,taskId:we});if($){const Ae=Math.floor(f*.4);return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsxs(g,{flexDirection:"row",flexGrow:1,children:[n.jsx(g,{width:Ae,children:x}),n.jsx(g,{flexGrow:1,children:C})]}),Ce,xe,ve,$e]})}const te=Math.floor(h*.45);return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsx(g,{height:te,children:x}),n.jsx(g,{flexGrow:1,children:C}),Ce,xe,ve,$e]})}return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(ps,{filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel!=="dock",headerStatus:ne,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:B,selectedIndex:l.selectedIndex,title:_e})}),Ce,xe,ve,$e]})},zi=s=>{const{args:e,autoExit:t=!1,onRetryService:r,outputStyle:c="normal",projectNames:o,serviceDockStore:i,stdinRegistry:d,tasks:u,totalTaskCount:p}=s,f=new ot(u,p),h=typeof e.parallel=="number"?e.parallel:3,l=t===!0?3:typeof t=="number"?t:0;let b,T;const N=new Promise(k=>{T=k});let F;const S=()=>{F&&(clearInterval(F),F=void 0)},E=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},I=()=>{if(d){for(const k of d.values())k.kill?.();d.clear()}},j=()=>{S(),O(),I(),E(),process.stdout.write("\x1B[?1049l\x1B[?25h"),b?.cleanup(),process.exit(1)},R=()=>{const k=f.getSnapshot(),W=Be(Date.now()-k.startTime),se=k.rows.filter(ee=>ee.status==="failure").map(ee=>ee.taskId),ae=process.stdout.columns||80;process.stdout.write(`
|
|
16
|
-
`);for(const ee of k.rows){const{persistent:ie,status:oe,taskId:ge}=ee,le=oe==="running"||oe==="pending",q=He(oe),K=le&&ie?"■":q.icon,re=le&&ie?"gray":q.color;let X="";switch(oe){case"local-cache":case"local-cache-kept-existing":{X=" [local cache]";break}case"remote-cache":{X=" [remote cache]";break}case"skipped":{X=" [skipped]";break}default:{le&&ie?X=" [stopped]":le&&(X=" [skipped]");break}}const Se=ee.retryAttempts&&ee.retryAttempts>0?` [retried ${ee.retryAttempts}x]`:"",_=me(J.createElement(a,null," ",J.createElement(a,{color:re},K),` vis run ${ge}`,X?J.createElement(a,{dimColor:!0},` ${X}`):null,Se?J.createElement(a,{color:"yellow"},Se):null),{columns:ae});process.stdout.write(`${_}
|
|
17
|
-
`)}process.stdout.write(`
|
|
18
|
-
`);const Q=me(J.createElement(Ds,{cached:k.cached,failed:k.failed,failedIds:se,projectNames:o,retriedIds:k.retriedIds.length>0?k.retriedIds:void 0,succeeded:k.succeeded,targets:e.targets,tasks:u,took:W}),{columns:ae});if(process.stdout.write(`${Q}
|
|
19
|
-
`),c!=="quiet"){const ee=[...k.rows.filter(ie=>ie.status!=="failure"),...k.rows.filter(ie=>ie.status==="failure")];for(const ie of ee){if(ie.status==="running"||ie.status==="pending")continue;const oe=k.outputs.get(ie.taskId);if(!oe?.trim())continue;const{color:ge,icon:le}=He(ie.status),q=me(J.createElement(a,null,`
|
|
20
|
-
`,J.createElement(a,{bold:!0,color:ge},` ${le} vis run ${ie.taskId}`)),{columns:ae});process.stdout.write(`${q}
|
|
21
|
-
|
|
22
|
-
`);const K=oe.trim().split(`
|
|
23
|
-
`).map(re=>` ${re}`).join(`
|
|
24
|
-
`);process.stdout.write(`${K}
|
|
25
|
-
`)}}};let w;const O=()=>{w&&(clearInterval(w),w=void 0)};return{lifeCycle:{endCommand(){S(),f.markDone(),w||(w=setInterval(()=>{},1e3))},endTasks(k){f.endTasks(k)},printCacheDisabledByTask(k){f.addOutput(k.id,`ⓘ caching disabled by task via disableCache()
|
|
26
|
-
`)},printEmptyFingerprintWarning(k,W){f.addOutput(k.id,`ⓘ caching skipped — ${W}
|
|
27
|
-
`)},printSelfModifyingSkip(k,W){f.addOutput(k.id,`ⓘ caching skipped — task modified its own input${W.length===1?"":"s"} (${W.join(", ")})
|
|
28
|
-
`)},printTaskTerminalOutput(k,W,se){f.getSnapshot().outputs.has(k.id)||f.addOutput(k.id,se)},startCommand(){process.on("SIGINT",j),process.on("SIGTERM",j),w||(w=setInterval(()=>{},1e3)),b=Ir(J.createElement(Ui,{autoExitSeconds:l,onRetryService:r,parallelSlots:h,projectNames:o,serviceDockStore:i,stdinRegistry:d??new Map,store:f,targets:e.targets,tasks:u}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),b.waitUntilExit().then(()=>{O(),I(),E(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),R(),T()}).catch(()=>{O(),I(),E(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),T()})},startTasks(k){f.startTasks(k),F||(F=setInterval(()=>{f.tick()},100))}},renderIsDone:N,store:f}},Yi=s=>s==="quiet"?"quiet":"normal",Ki=(s,e)=>typeof s=="string"?Yi(s.toLowerCase()):e===!0?"quiet":"normal",Xi=(s,e)=>{const t=s.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e};class Ji{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#l;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#l=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,t=`Running ${St(this.#e,this.#r,this.#s)}`,r=me(J.createElement(wt,{title:t,variant:"info"}),{columns:e});process.stdout.write(r);const c=this.#s[0],o=c?.overrides?Object.entries(c.overrides).filter(([i])=>i!=="command"):[];if(o.length>0){process.stdout.write(`
|
|
29
|
-
With additional flags:
|
|
30
|
-
`);for(const[i,d]of o)process.stdout.write(`${ki(" ",i,d)}
|
|
31
|
-
`)}process.stdout.write(`
|
|
32
|
-
`)}startTasks(e){const t=process.stdout.columns||80;for(const r of e){const c=me(J.createElement(a,null,J.createElement(a,{dimColor:!0},">"),` ${r.id}`),{columns:t});process.stdout.write(`${c}
|
|
33
|
-
`)}}endTasks(e){const t=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):Ge(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const c=Ke(r.status),o=r.startTime&&r.endTime?` (${Be(r.endTime-r.startTime)})`:"",i=Ge(r.status)?" [cache]":"",d=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",u=me(J.createElement(a,null,c,` ${r.task.id}`,i?J.createElement(a,{color:"cyan"},i):null,d?J.createElement(a,{color:"yellow"},d):null,o?J.createElement(a,{dimColor:!0},o):null),{columns:t});process.stdout.write(`${u}
|
|
34
|
-
`)}}#d(e){const t=process.stdout.columns||80,r=me(J.createElement(a,{dimColor:!0},` ⓘ ${e}`),{columns:t});process.stdout.write(`${r}
|
|
35
|
-
`)}printCacheDisabledByTask(e){this.#d(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,t){this.#d(`${e.id}: caching skipped — task modified its own input${t.length===1?"":"s"} (${t.join(", ")})`)}printEmptyFingerprintWarning(e,t){this.#d(`${e.id}: caching skipped — ${t}`)}printTaskTerminalOutput(e,t,r){if(Xi(e,this.#a)==="quiet"&&(t==="success"||Ge(t)))return;const c=t==="failure"?_s(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,t,c);return}Ai(e.id,t,c,this.#l)}endCommand(){const e=Be(Date.now()-this.#u),t=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);process.stdout.write(`
|
|
36
|
-
`);const r=process.stdout.columns||80,c=me(J.createElement(Ds,{cached:this.#t.length,failed:this.#n.length,failedIds:this.#n.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:t.length>0?t:void 0,succeeded:this.#o.size-this.#n.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${c}
|
|
37
|
-
`)}}const Qi=async s=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Ln()==="win32"){try{await to(s)}catch{}return}const e=process.env.SHELL;if(!e)return;const t=or(e);try{if(t==="zsh"){await Zi(s);return}if(t==="bash"){await eo(s);return}t==="fish"&&await so(s)}catch{}},Tt=s=>s.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Zi=async s=>{const e=process.env.HISTFILE??ue(process.env.ZDOTDIR??kt(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${Tt(s)}
|
|
38
|
-
`;await dt(e,t)},eo=async s=>{const e=process.env.HISTFILE??ue(kt(),".bash_history");await dt(e,`${Tt(s)}
|
|
39
|
-
`)},to=async s=>{const e=process.env.VIS_PSREADLINE_HISTORY,t=process.env.APPDATA;if(e===void 0&&(t===void 0||t===""))return;const r=e??ue(t,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await An(Ss(r),{recursive:!0}),await dt(r,`${Tt(s)}\r
|
|
40
|
-
`)},so=async s=>{const e=ue(kt(),".local","share","fish","fish_history"),r=`- cmd: ${s.replaceAll("\\","\\\\").replaceAll(`
|
|
41
|
-
`,String.raw`\n`).replaceAll("\r",String.raw`\r`)}
|
|
42
|
-
when: ${Math.floor(Date.now()/1e3)}
|
|
43
|
-
`;await dt(e,r)},ro=s=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:r,timeoutMs:c}=s;if(c<=0)return{cancel:()=>{}};const o=Math.max(e,0);let i;const d=setTimeout(()=>{t?.(),r("SIGTERM"),o>0&&(i=setTimeout(()=>{r("SIGKILL")},o))},c);return{cancel:()=>{clearTimeout(d),i&&clearTimeout(i)}}},no=(s,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...s]};const r=t.toLowerCase();return{filter:t,tasks:s.filter(c=>c.target.project.toLowerCase().includes(r))}},io=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
44
|
-
`),oo=s=>{s.write(`${io}
|
|
45
|
-
`)},co=async(s,e)=>{e.write("filter projects (empty to cancel) > ");const t=s,r=t.isRaw===!0;if(r)try{t.setRawMode?.(!1)}catch{}return await new Promise(c=>{let o="";const i=d=>{o+=typeof d=="string"?d:d.toString("utf8");const u=o.indexOf(`
|
|
46
|
-
`);if(u===-1)return;const p=o.slice(0,u).replace(/\r$/,"").trim();if(s.off("data",i),r)try{t.setRawMode?.(!0)}catch{}c(p.length>0?p:void 0)};s.on("data",i)})},ao=s=>{const{handlers:e}=s,t=s.input??process.stdin,r=s.output??process.stdout,c=s.promptFilter??co;if(!t||t.isTTY===!1)return{close:()=>{}};zr(t);const o=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof t.resume=="function"&&t.resume();let i=!1;const d=async f=>{if(f.ctrl===!0&&f.name==="c"){await e.onQuit();return}if(!i)switch(f.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const h=await c(t,r);h===void 0?r.write(`filter cancelled.
|
|
47
|
-
`):await e.onFilter(h)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},u=(f,h)=>{d(h).catch(l=>{r.write(`[vis watch] keybind handler failed: ${l.message}
|
|
48
|
-
`)})},p=t;return p.on("keypress",u),{close:()=>{if(p.off("keypress",u),!o)try{t.setRawMode?.(!1)}catch{}const f=t;if(typeof f.pause=="function")try{f.pause()}catch{}}}},lo=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},uo=async s=>{const{initialTasks:e,probe:t,registeredEntries:r,taskGraph:c,visVersion:o}=s,i=new Map,d=new Map,u=new Map;for(const w of r)if(Jr(w.pid)){if(w.visVersion!==o){d.set(w.id,w);continue}i.set(w.id,w)}if(t){const w=[...i.values()],O=await Promise.all(w.map(async B=>{try{return[B.id,await t(B)]}catch{return[B.id,!1]}}));for(const[B,k]of O)if(!k){const W=i.get(B);i.delete(B),W&&u.set(B,W)}}const p=new Set(e.map(w=>w.id)),f=new Set,h=[],l=[],b=new Set;for(const w of Object.values(c.dependencies))for(const O of w)b.add(O);for(const[w,O]of Object.entries(c.tasks)){if(!lo(O)?.service)continue;if(i.has(w)){f.add(w),l.push(i.get(w));continue}if(p.has(w)||!b.has(w))continue;const W=d.get(w),se=u.get(w);let ae;W?ae=`Service ${w} is registered with vis ${W.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${w}\` to pick up the new version.`:se?ae=`Service ${w} is registered (PID ${String(se.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${w}\` to recover.`:ae=`Target depends on the service ${w}, which is not running. Run \`vis service start ${w}\` first, or invoke \`${w}\` directly.`,h.push({message:ae,targetId:w})}if(f.size===0)return{diagnostics:h,initialTasks:e,satisfiedServices:l,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:c};const T=new Map,N=w=>{const O=new Set,B=[...c.dependencies[w]??[]],k=new Set;for(;B.length>0;){const W=B.pop();if(!k.has(W)){k.add(W),f.has(W)&&O.add(W);for(const se of c.dependencies[W]??[])k.has(se)||B.push(se)}}return[...O].sort()},F=new Map;for(const w of Object.keys(c.dependencies)){if(f.has(w))continue;const O=N(w);if(O.length===0)continue;const B={};for(const k of O){const W=i.get(k);if(!W)continue;Object.assign(B,W.env);const se=F.get(k);se?se.push(w):F.set(k,[w])}Object.keys(B).length>0&&T.set(w,B)}for(const w of F.values())w.sort();const S={};for(const[w,O]of Object.entries(c.tasks))f.has(w)||(S[w]=O);const E={};for(const[w,O]of Object.entries(c.dependencies))f.has(w)||(E[w]=O.filter(B=>!f.has(B)));const I=new Map;for(const w of Object.keys(S))I.set(w,0);for(const w of Object.values(E))for(const O of w)I.has(O)&&I.set(O,(I.get(O)??0)+1);const j=[];for(const w of c.roots)!f.has(w)&&S[w]&&j.push(w);for(const[w,O]of I)O===0&&!j.includes(w)&&S[w]&&j.push(w);const R=e.filter(w=>!f.has(w.id));return{diagnostics:h,initialTasks:R,satisfiedServices:l,serviceDependentsByServiceId:F,serviceEnvByTaskId:T,taskGraph:{dependencies:E,roots:j,tasks:S}}},fo=s=>s.startsWith("./")||s.startsWith("../")||s.startsWith("/")||s.startsWith("**"),ho=s=>{let e=s.trim();if(e==="")return;let t=!1,r=!1,c=!1;e.startsWith("...")&&(t=!0,e=e.slice(3),e.startsWith("^")&&(c=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(c=!0,e=e.slice(0,-1)));let o;const i=/\[([^\]]*)\]$/.exec(e);i&&(o=i[1]??"",e=e.slice(0,i.index));let d=e.trim(),u=!1;return d.startsWith("{")&&d.endsWith("}")&&d.length>=2?(d=d.slice(1,-1),u=!0):fo(d)&&(u=!0),{changedSince:o,excludeSelf:c,includeDependencies:r,includeDependents:t,isPath:u,pattern:d}},vt=s=>{let e=s.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},po=(s,e,t)=>s===""?!1:gt(s,e)?!0:t!==void 0&>(s,t),mo=(s,e)=>{if(e===void 0||e==="")return!1;const t=vt(s),r=vt(e);return gt(t,r)},go=(s,e,t)=>{const{affected:r,downstream:c,upstream:o}=lr(s,t,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const i=new Set([...c,...o]);for(const d of s)i.delete(d);return i},wo=async(s,e)=>{const{packageNameByProject:t,projectGraph:r}=e,c=Object.keys(r.nodes);let o=new Set;if(s.pattern!=="")for(const i of c)s.isPath?mo(s.pattern,r.nodes[i]?.data.root)&&o.add(i):po(s.pattern,i,t?.get(i))&&o.add(i);if(s.changedSince!==void 0){const i=s.changedSince===""?e.defaultBase??"main":s.changedSince,d=e.changedProjectsForRef??vo(e),u=new Set(await d(i));o=s.pattern===""?u:new Set([...o].filter(p=>u.has(p)))}return!s.includeDependents&&!s.includeDependencies?o:go(o,s,r)},vo=s=>async e=>{const{projectGraph:t,workspaceRoot:r}=s;if(!r)return[];let c;try{c=await dr(r,e,"HEAD")}catch(i){const d=i instanceof Error?i.message:String(i);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${d})`,{cause:i})}const o=new Set;for(const[i,d]of Object.entries(t.nodes)){const u=vt(d.data.root??i);if(!(u===""||u==="."))for(const p of c){const f=cr(r,p).replaceAll("\\","/");if(f===u||f.startsWith(`${u}/`)){o.add(i);break}}}return[...o]},yo=async(s,e)=>{const t=new Set;for(const r of s)for(const c of await wo(r,e))t.add(c);return[...t]},xo=async(s,e)=>{const t=[];for(const r of s){const c=ho(r);c&&t.push(c)}return yo(t,e)},et="[[VIS_BOOT]]",jo=250,ko=1e3,vs=3,bo=s=>{try{return process.kill(s,0),!0}catch{return!1}},ys=s=>{try{const e=We(s,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}};class So{#e;#r;#s;#n;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#n=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const t=this.#e.get(e.index);t===void 0||e.text===void 0||this.onTaskOutput(t,e.text)};onTaskOutput(e,t){if(!this.#r.has(e))return;const o=((this.#t.get(e)??"")+t).split(`
|
|
49
|
-
`),i=o.pop()??"";this.#t.set(e,i);for(const d of o)this.#l(e,d)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,t){this.#s.started(e,t)}onRegistryTaskStarted(e){this.#r.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,t,r){if(this.#r.get(e)?.mode!=="registry")return;if(r||t!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:t,killed:r});return}const o=await Qr(this.#n,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:i}=o,d=i.readiness?.tcp?.port??i.port??0,u=i.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:u,logFile:o.logFile,pid:o.pid,port:d})}notifyRegistryReady(e,t){this.#s.ready(e,{host:t.host,port:t.port}),this.#h(e,t.logFile),t.pid!==null&&this.#p(e,t.pid)}notifyRegistryFailed(e,t,r){this.#s.failed(e,t,r)}async retry(e){const t=this.#r.get(e);if(t){if(this.#f(e),this.#t.delete(e),this.#i.delete(e),this.#s.starting(e),t.mode==="registry"){await this.#y(e,t.registry);return}t.mode==="ephemeral"&&this.#v(e,t.ephemeral)}}async dispose(){for(const e of[...this.#o.keys(),...this.#c.keys()])this.#f(e);this.#a.size>0&&(await Promise.race([Promise.all(this.#a),new Promise(e=>{setTimeout(e,2e3)})]),this.#a.clear()),this.#t.clear(),this.#i.clear()}#l(e,t){if(t.startsWith(et)){this.#u(e,t.slice(et.length));return}const r=this.#i.get(e)??[];r.push(t),r.length>vs&&r.shift(),this.#i.set(e,r),this.#s.log(e,`${t}
|
|
50
|
-
`)}#u(e,t){let r;try{r=JSON.parse(t)}catch{this.#s.log(e,`${et+t}
|
|
51
|
-
`);return}switch(r.event){case"failed":{const c=typeof r.reason=="string"?r.reason:"unknown",o={};for(const[i,d]of Object.entries(r))i!=="event"&&i!=="id"&&i!=="reason"&&(o[i]=d);this.#s.failed(e,c,o);break}case"ready":{const c=typeof r.host=="string"?r.host:"127.0.0.1",o=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:c,port:o}),this.#d(e);break}case"started":{const c=typeof r.pid=="number"?r.pid:null;this.#s.started(e,c);break}default:this.#s.log(e,`${et+t}
|
|
52
|
-
`)}}#d(e){const t=this.#r.get(e);if(t?.ephemeral===void 0)return;this.#h(e,t.ephemeral.logFile);const r=ys(t.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,t){if(this.#o.has(e)||!De(t))return;const r=Wr(t,"r"),c=(()=>{try{return Qt(t).size}catch{return 0}})(),o={fd:r,logFile:t,pollTimer:setInterval(()=>{this.#g(e)},jo),position:c};this.#o.set(e,o)}#g(e){const t=this.#o.get(e);if(t)try{const r=Qt(t.logFile);if(r.size<=t.position)return;const c=Buffer.alloc(r.size-t.position),o=Hr(t.fd,c,0,c.length,t.position);if(o>0){t.position+=o;const i=c.subarray(0,o).toString("utf8");for(const d of i.split(`
|
|
53
|
-
`))d.length!==0&&this.#w(e,d);this.#s.log(e,i)}}catch{}}#w(e,t){const r=this.#i.get(e)??[];for(r.push(t);r.length>vs;)r.shift();this.#i.set(e,r)}#p(e,t){if(this.#c.has(e))return;const r={pid:t,timer:setInterval(()=>{if(!bo(t)){const c=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,c)}},ko)};this.#c.set(e,r)}#f(e){const t=this.#o.get(e);if(t){clearInterval(t.pollTimer);try{qr(t.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#v(e,t){if(t===void 0)return;const r=ys(t.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const c=Nn("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});c.stdout.on("data",i=>{this.#m(e,i)}),c.stderr.on("data",i=>{this.#m(e,i)}),c.on("error",i=>{this.#s.failed(e,"respawn-error",{message:i.message})});const o=new Promise(i=>{const d=()=>{this.#a.delete(o),i()};c.once("exit",d),c.once("error",d)});this.#a.add(o)}#m(e,t){const o=((this.#t.get(e)??"")+t.toString("utf8")).split(`
|
|
54
|
-
`),i=o.pop()??"";this.#t.set(e,i);for(const d of o)this.#l(e,d)}async#y(e,t){if(t!==void 0){try{await Zr({id:e,workspaceRoot:this.#n})}catch{}try{const r=await en({command:t.command,config:t.config,cwd:t.cwd,env:t.env,id:e,workspaceRoot:this.#n}),c=t.config.readiness?.tcp?.port??t.config.port??0,o=t.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,r.entry.pid),this.notifyRegistryReady(e,{host:o,logFile:r.entry.logFile,pid:r.entry.pid,port:c})}catch(r){const c=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:c})}}}}const To=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},qs=(s,e,t)=>{const r=[],c=[];for(const o of e){const i=t.tasks[o];if(!i){c.push({id:o,reason:"task not in graph"});continue}const d=i.overrides.command;if(!d){c.push({id:o,reason:"no command resolved"});continue}const u=To(i);if(!u?.service){c.push({id:o,reason:"no service config"});continue}const p=at(s,i.projectRoot,!!u.runFromWorkspaceRoot),{envFile:f}=u,h=f===void 0||f===!1?{}:jt(p,f),l=u.service.env??{};r.push({command:d,config:u.service,cwd:p,env:{...h,...l},id:o})}return{services:r,skipped:c}},$o=(s,e)=>{const t=new Set(s),r=new Map;for(const i of s){const d=(e.dependencies[i]??[]).filter(u=>t.has(u));r.set(i,new Set(d))}const c=[],o=new Set;for(;r.size>0;){const i=[];for(const[d,u]of r){for(const p of u)o.has(p)&&u.delete(p);u.size===0&&i.push(d)}i.length===0&&i.push(...r.keys());for(const d of i)o.add(d),r.delete(d);i.sort(),c.push({ids:i})}return c},Io=(s,e)=>{const t=[];for(const r of $o(s,e))t.push(...r.ids);return t},Co=String.raw`import { spawn } from "node:child_process";
|
|
55
|
-
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
56
|
-
import { createConnection } from "node:net";
|
|
57
|
-
|
|
58
|
-
const cfgPath = process.argv[2];
|
|
59
|
-
|
|
60
|
-
if (!cfgPath) {
|
|
61
|
-
console.error("[vis-service-bootstrap] missing config path");
|
|
62
|
-
process.exit(2);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const cfg = JSON.parse(readFileSync(cfgPath, "utf8"));
|
|
66
|
-
|
|
67
|
-
// Structured marker for service-event-bridge.ts to consume. Plain
|
|
68
|
-
// process.stdout.write keeps the line atomic and on the same stream
|
|
69
|
-
// as the tailed child log, so the parser sees one stream.
|
|
70
|
-
const emit = (event) => {
|
|
71
|
-
process.stdout.write("[[VIS_BOOT]]" + JSON.stringify({ ...event, id: cfg.id }) + "\n");
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// Spawn the child with its stdio bound to a real file descriptor on
|
|
75
|
-
// disk — NOT inherited from the bootstrap. If the child inherited
|
|
76
|
-
// our stdio, it would inherit vis run's task pipes, and vis run would
|
|
77
|
-
// block waiting for those pipes to close even after this bootstrap
|
|
78
|
-
// exits. The logfile gives the grandchild a stable target it can keep
|
|
79
|
-
// writing to long after this bootstrap is gone.
|
|
80
|
-
const childLogFd = openSync(cfg.logFile, "a");
|
|
81
|
-
|
|
82
|
-
const child = spawn(cfg.command, {
|
|
83
|
-
cwd: cfg.cwd,
|
|
84
|
-
detached: true,
|
|
85
|
-
env: { ...process.env, ...cfg.env },
|
|
86
|
-
shell: true,
|
|
87
|
-
stdio: ["ignore", childLogFd, childLogFd],
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// Close the bootstrap's copy of the fd; the child kept its own.
|
|
91
|
-
closeSync(childLogFd);
|
|
92
|
-
|
|
93
|
-
if (child.pid !== undefined) {
|
|
94
|
-
try {
|
|
95
|
-
writeFileSync(cfg.pidFile, String(child.pid));
|
|
96
|
-
} catch (error) {
|
|
97
|
-
console.error("[vis] failed to write pid file: " + (error?.message ?? String(error)));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
emit({ event: "started", pid: child.pid ?? null });
|
|
102
|
-
|
|
103
|
-
let exitedEarly = false;
|
|
104
|
-
|
|
105
|
-
child.once("exit", (code, signal) => {
|
|
106
|
-
exitedEarly = true;
|
|
107
|
-
emit({ code, event: "failed", reason: "exited-before-ready", signal });
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Forward new bytes from the logfile to our stdout while we're alive.
|
|
111
|
-
// Polling-based tail; preflight is short, ~200ms per cycle is fine.
|
|
112
|
-
let tailPos = 0;
|
|
113
|
-
const tailFd = openSync(cfg.logFile, "r");
|
|
114
|
-
|
|
115
|
-
const flushTail = () => {
|
|
116
|
-
try {
|
|
117
|
-
const stat = statSync(cfg.logFile);
|
|
118
|
-
if (stat.size <= tailPos) return;
|
|
119
|
-
const remaining = stat.size - tailPos;
|
|
120
|
-
const buf = Buffer.alloc(remaining);
|
|
121
|
-
const n = readSync(tailFd, buf, 0, remaining, tailPos);
|
|
122
|
-
if (n > 0) {
|
|
123
|
-
process.stdout.write(buf.subarray(0, n));
|
|
124
|
-
tailPos += n;
|
|
125
|
-
}
|
|
126
|
-
} catch {}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const probeOnce = () => new Promise((resolve) => {
|
|
130
|
-
const socket = createConnection({ host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
131
|
-
let settled = false;
|
|
132
|
-
const finish = (ok) => {
|
|
133
|
-
if (settled) return;
|
|
134
|
-
settled = true;
|
|
135
|
-
try { socket.destroy(); } catch {}
|
|
136
|
-
resolve(ok);
|
|
137
|
-
};
|
|
138
|
-
socket.once("connect", () => finish(true));
|
|
139
|
-
socket.once("error", () => finish(false));
|
|
140
|
-
socket.setTimeout(1000, () => finish(false));
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
144
|
-
|
|
145
|
-
(async () => {
|
|
146
|
-
const deadline = Date.now() + (cfg.timeoutMs ?? 30000);
|
|
147
|
-
while (Date.now() < deadline) {
|
|
148
|
-
flushTail();
|
|
149
|
-
if (exitedEarly) {
|
|
150
|
-
try { closeSync(tailFd); } catch {}
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
if (await probeOnce()) {
|
|
154
|
-
flushTail();
|
|
155
|
-
emit({ event: "ready", host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
156
|
-
try { closeSync(tailFd); } catch {}
|
|
157
|
-
child.unref();
|
|
158
|
-
process.exit(0);
|
|
159
|
-
}
|
|
160
|
-
await sleep(200);
|
|
161
|
-
}
|
|
162
|
-
flushTail();
|
|
163
|
-
emit({ event: "failed", reason: "timeout", timeoutMs: cfg.timeoutMs ?? 30000 });
|
|
164
|
-
try { closeSync(tailFd); } catch {}
|
|
165
|
-
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
166
|
-
process.exit(1);
|
|
167
|
-
})();
|
|
168
|
-
`,Eo=()=>{const s=Vr(ue(Dn(),"vis-services-")),e=ue(s,"bootstrap.mjs");return Ps(e,Co),{runDir:s,scriptPath:e}},Vs=(s,e,t)=>{const r=t.replaceAll(/[^\w-]/g,"_");return{configFile:ue(s,`${r}.json`),logFile:ue(s,`${r}.log`),pidFile:ue(s,`${r}.pid`),scriptPath:e}},Ro=s=>{const{paths:e,service:t}=s,r=t.config.readiness?.tcp?.port??t.config.port;if(typeof r!="number")throw new TypeError(`Service ${t.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const c={...t.env,PATH:ur(t.cwd,t.env)};return{command:t.command,cwd:t.cwd,env:c,host:t.config.readiness?.tcp?.host??"127.0.0.1",id:t.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:t.config.readiness?.tcp?.timeoutMs??3e4}},Po=s=>`node ${JSON.stringify(s.scriptPath)} ${JSON.stringify(s.configFile)}`,Mo=s=>{const{id:e,visBin:t,workspaceRoot:r}=s;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},Fo=s=>{const{missingServiceIds:e,mode:t,taskGraph:r,visBin:c,workspaceRoot:o}=s,{services:i,skipped:d}=qs(o,e,r);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const u=Io(i.map(S=>S.id),r),p=new Map(i.map(S=>[S.id,S])),f=[],h=[];if(t==="ephemeral")for(const S of u){const E=p.get(S);E&&h.push({id:S,payload:Ro({paths:{logFile:"",pidFile:""},service:E})})}let l;t==="ephemeral"&&(l=Eo());let b;for(const S of u){const E=p.get(S),I=r.tasks[S];if(!E||!I)continue;let j;if(t==="ephemeral"){const R=Vs(l.runDir,l.scriptPath,S),O={...h.find(B=>B.id===S).payload,logFile:R.logFile,pidFile:R.pidFile};Ps(R.configFile,JSON.stringify(O)),j=Po(R),f.push(R.pidFile)}else j=Mo({id:S,visBin:c,workspaceRoot:o});if(I.overrides={...I.overrides,command:j},I.cache=!1,r.tasks[S]=I,b!==void 0){const R=r.dependencies[S]??[];R.includes(b)||(r.dependencies[S]=[...R,b])}b=S}const T=new Set(u),N=new Map,F=S=>{const E=new Set,I=[...r.dependencies[S]??[]],j=new Set;for(;I.length>0;){const R=I.pop();if(!j.has(R)){j.add(R),T.has(R)&&E.add(R);for(const w of r.dependencies[R]??[])j.has(w)||I.push(w)}}return[...E].sort()};for(const S of Object.keys(r.dependencies)){if(T.has(S))continue;const E=F(S);if(E.length===0)continue;const I={};for(const j of E){const R=p.get(j);R?.config.env&&Object.assign(I,R.config.env)}Object.keys(I).length>0&&N.set(S,I)}return{chain:u,ephemeralPidFiles:f,runDir:l?.runDir,serviceEnvByTaskId:N,skipped:d}},Oo=new Set(["auto","ephemeral","off","persistent"]),Ao=s=>s.cli!==void 0?"cli":s.config===void 0?"default":"config",Lo=s=>{const{cli:e,config:t,isCi:r,isPersistentTarget:c,isTty:o,target:i}=s;if(e!==void 0&&!Oo.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const d=e??t??(o&&!r?"auto":"off");return d==="off"?"off":d==="ephemeral"?"ephemeral":d==="persistent"?"registry":c||i==="dev"?"ephemeral":"registry"},Us=s=>s.replace(/^--?/u,""),Do=new Set(["0","1","false","no","true","yes"]),Bo=s=>!s.startsWith("-")||/^-(?:\d|\.\d)/u.test(s),xs=(s,e,t,r,c,o)=>{if(r!==void 0)return s.set(e,r),0;const i=c[o+1];return(t?.type??"string")==="boolean"?i!==void 0&&Do.has(i.toLowerCase())?(s.set(e,i.toLowerCase()),1):(s.set(e,"true"),0):i!==void 0&&Bo(i)?(s.set(e,i),1):(s.set(e,"true"),0)},_o=(s,e)=>{const t=s.type??"string";if(t==="number"){const r=e.trim(),c=Number(r);return r===""||!Number.isFinite(c)?{error:`--${s.name} expects a number, got "${e}"`}:{value:c}}if(t==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${s.name} expects a boolean, got "${e}"`};if(t==="enum"){const r=s.choices??[];return r.includes(e)?{value:e}:{error:`--${s.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},No=s=>{const e=[],t=new Set;for(const r of s){const c=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${c}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),t.has(r.name)&&e.push(`duplicate argument name "${c}"`),t.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${c}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${c}" has type "enum" but declares no choices`),r.default!==void 0){const i=typeof r.default;o==="number"&&i==="number"||o==="boolean"&&i==="boolean"||(o==="string"||o==="enum")&&i==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${c}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${c}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},Go=(s,e)=>{const t=new Map,r=new Map;for(const p of s)t.set(p.name,p),p.alias&&r.set(p.alias,p);const c=new Map,o=[];for(let p=0;p<e.length;p+=1){const f=e[p];if(f==="--"){o.push(...e.slice(p+1));break}if(f.startsWith("--no-")){c.set(Us(f.slice(5)),"false");continue}const h=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(h){const T=h[1];p+=xs(c,T,t.get(T),h[2],e,p);continue}const l=/^-([^=-])(?:=(.*))?$/su.exec(f),b=l?.[1];if(l&&b!==void 0){const T=r.get(b);p+=xs(c,T?.name??b,T,l[2],e,p);continue}o.push(f)}const i={},d=[];let u=0;for(const p of s){let f=c.get(p.name);if(f===void 0&&p.positional&&u<o.length&&(f=o[u],u+=1),f===void 0){p.default!==void 0?i[p.name]=p.default:p.required&&d.push(`missing required argument --${p.name}`);continue}const{error:h,value:l}=_o(p,f);h?d.push(h):l!==void 0&&(i[p.name]=l)}return{errors:d,values:i}},Wo=s=>`VIS_ARG_${Us(s).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,Ho=s=>{const e={};for(const[t,r]of Object.entries(s))e[Wo(t)]=String(r);return e},mt=(s,e,t)=>{const r=[`Usage: vis run ${s} [-- <args>]`];if(e&&r.push("",e),t.length===0)return r.join(`
|
|
169
|
-
`);r.push("","Arguments:");const c=t.map(i=>{const d=i.positional?`<${i.name}>`:`--${i.name}`,u=i.alias?`, -${i.alias}`:"";return{left:`${d}${u}`,right:i}}),o=Math.max(...c.map(i=>i.left.length));for(const{left:i,right:d}of c){const u=[],p=d.type??"string";u.push(p==="enum"?`enum(${(d.choices??[]).join("|")})`:p),d.required&&u.push("required"),d.default!==void 0&&u.push(`default: ${String(d.default)}`);const f=`${d.description??""}${d.description?" ":""}[${u.join(", ")}]`;r.push(` ${i.padEnd(o)} ${f}`)}return r.join(`
|
|
170
|
-
`)},qo=(s,e,t,r)=>{if(!t||t.length===0)return{env:{},kind:"ok"};const c=No(t);if(c.length>0)return{errors:c.map(i=>`invalid \`arguments\` schema for "${s}": ${i}`),help:mt(s,e,t),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:mt(s,e,t)};const o=Go(t,r);return o.errors.length>0?{errors:o.errors,help:mt(s,e,t),kind:"invalid"}:{env:Ho(o.values),kind:"ok"}},$t="VIS_AFFECTED_FILES",Vo=2e3,js=async(s,e,t,r,c,o)=>{const i=s.map(j=>{const R=j.overrides.command;if(!R)return;const w=j.overrides.visOptions,O=at(e,j.projectRoot,!!w?.runFromWorkspaceRoot),B=w?.envFile?jt(O,w.envFile):{},k=t&&(w?.affectedFiles==="env"||w?.affectedFiles==="both")?{[$t]:t.join(`
|
|
171
|
-
`)}:{},W=o?.get(j.id)??{},se=di({interactive:!!c,taskPty:j.pty,workspacePty:w?.pty});return{command:R,cwd:O,env:{INIT_CWD:r,...B,...W,...k,...j.overrides[Ct]},name:j.id,...se?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(j=>j!==void 0);if(i.length===0)return;if(!c){await tt(i,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:d,lifeCycle:u,stdinRegistry:p,store:f}=c,h=i.map(j=>s.find(R=>R.id===j.name)).filter(Boolean),l=j=>i[j]?.stdin==="pty",b=new Map,T=j=>{if(!l(j))return;let R=b.get(j);return R||(R=new yt(ct),b.set(j,R)),R};f.unmarkDone(),u.startTasks?.(h);const N=new Map,F=new Map;let S;const E=()=>{for(const j of F.values())try{j("SIGTERM")}catch{}S||(S=setTimeout(()=>{for(const j of F.values())try{j("SIGKILL")}catch{}F.clear()},2e3),S.unref?.())};let I;d&&(I=()=>{E()},d.then(()=>{I?.()}).catch(()=>{I?.()}));try{await tt(i,{killOthers:["failure"],onEvent:j=>{const R=h[j.index];if(R)switch(j.kind){case"close":{const w=N.get(R.id)??Date.now(),O=j.killed||j.exitCode===0?"success":"failure";u.endTasks?.([{code:j.exitCode??0,endTime:Date.now(),startTime:w,status:O,task:R,terminalOutput:f.getSnapshot().outputs.get(R.id)??""}]),F.delete(j.index),p?.delete(R.id);break}case"error":{if(j.message){const w=T(j.index);w?(w.write(`${j.message}
|
|
172
|
-
`),f.setOutput(R.id,w.toString())):f.addOutput(R.id,`${j.message}
|
|
173
|
-
`)}break}case"started":{N.set(R.id,Date.now()),j.kill&&F.set(j.index,j.kill),j.write&&p&&p.set(R.id,{kill:j.kill,resize:j.resize,write:j.write});break}case"stderr":case"stdout":{if(j.text){const w=T(j.index);w?(w.write(j.text),f.setOutput(R.id,w.toString())):f.addOutput(R.id,`${j.text}
|
|
174
|
-
`)}break}default:}}})}finally{S&&(clearTimeout(S),S=void 0),f.markDone()}},ks=s=>{try{return process.kill(-s,0),!0}catch{try{return process.kill(s,0),!0}catch{return!1}}},Uo=s=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,s)},zo=s=>{const{extraPids:e=[],pidFiles:t,runDir:r}=s,c=[],o=i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}};for(const i of t){let d;try{const u=ar(i),p=Number.parseInt(u.trim(),10);d=Number.isFinite(p)&&p>0?p:void 0}catch{continue}d!==void 0&&(c.push(d),o(d))}for(const i of e)!Number.isFinite(i)||i<=0||(c.push(i),o(i));if(c.length>0){const u=Date.now()+1500;for(;Date.now()<u;){let p=!0;for(const f of c)if(ks(f)){p=!1;break}if(p)break;Uo(100)}for(const p of c)if(ks(p))try{process.kill(-p,"SIGKILL")}catch{try{process.kill(p,"SIGKILL")}catch{}}}r&&Br(r)},ct=256*1024;class Yo{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
175
|
-
${this.#r}`:this.#r}}const zs=s=>{const e=s.overrides.visOptions;if(e&&typeof e=="object")return e},Ko=s=>`'${s.replaceAll("'",String.raw`'\''`)}'`,It=s=>process.platform==="win32"?s.length>0&&!/[\s"&|<>^()%!]/.test(s)?s:`"${s.replaceAll('"','""')}"`:Ko(s),Xo=(s,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return s;if(t==="args"||t==="both"){const r=e.map(c=>It(c)).join(" ");return`${s} ${r}`}return s},Ys="visForwardedArgs",Ct="visTaskArgEnv",Jo=(s,e)=>{const t=e.overrides[Ys];if(!Array.isArray(t)||t.length===0)return s;const r=t.map(c=>It(c)).join(" ");return`${s} ${r}`},Qo=async(s,e,t)=>{if(!e)return t();const r=s.get(e)??Promise.resolve();let c;const o=new Promise(d=>{c=d}),i=r.then(()=>o);s.set(e,i),await r;try{return await t()}finally{c(),s.get(e)===i&&s.delete(e)}},Zo=s=>{let e=Math.max(0,Math.floor(s));return{claim(t){const r=Math.max(0,Math.min(t,e));return e-=r,r},get remaining(){return e}}},ec=(s,e,t)=>{const r=`${e}\0${typeof t=="string"?t:String(t)}`,c=s.get(r);if(c)return c;const o=jt(e,t);return s.set(r,o),o},bs=s=>{const e=new Map;return async(t,r)=>{const{affectedFiles:c,currentOs:o,hooks:i,initCwd:d,lifeCycle:u,mutexPool:p,onOutput:f,onOutputReplace:h,retryBudget:l,serviceEnvByTaskId:b,serviceEventBridge:T,stdinRegistry:N,strictEnv:F,taskSlots:S,workspaceRoot:E}=s,I=zs(t),j=at(E,r.cwd??t.projectRoot,I?.runFromWorkspaceRoot===!0),R=t.overrides.command;if(!R)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const w=Jo(R,t),O=Xo(w,c,I?.affectedFiles),B=kn(I,o),k=I?.shellArgs,W=k&&k.length>0?k.join(" "):"-c",se=B?`${B} ${W} ${It(O)}`:O,ae=I?.envFile?ec(e,j,I.envFile):void 0,Q={};c&&c.length>0&&(I?.affectedFiles==="env"||I?.affectedFiles==="both")&&(Q[$t]=c.join(`
|
|
176
|
-
`));const ee=b?.get(t.id),ie={INIT_CWD:d,VIS_TASK_SLOTS:String(S),...ae,...ee,...r.env,...Q,...t.overrides[Ct]};if(I?.strictEnv??F??!1){const z=gi({command:O,processEnv:process.env,taskEnv:ie,taskId:t.id});if(z){const we=wi(z);return u?.onTaskStderr?.(t,we),{code:1,terminalOutput:we}}}const ge=I?.pty===!0,le=!!N,q=t.pty===!0?!0:t.pty===!1?!1:le||ge;q&&(t.cache=!1);const K=q?void 0:new Yo(ct),re=q?new yt(ct):void 0;let X;const Se=z=>{if(z.kind==="started"&&(X=z.kill,z.write&&N&&N.set(t.id,{kill:z.kill,resize:z.resize,write:z.write}),T?.onRegistryTaskStarted(t.id)),(z.kind==="stdout"||z.kind==="stderr")&&z.text!==void 0)if(z.kind==="stdout"?u?.onTaskStdout?.(t,z.text):u?.onTaskStderr?.(t,z.text),re)re.write(z.text),le&&h?.(t.id,re.toString()),T&&T.onTaskOutput(t.id,z.text);else{const we=`${z.text}
|
|
177
|
-
`;K.append(we),f?.(t.id,we)}z.kind==="close"&&(N&&N.delete(t.id),T&&T.onRegistryTaskClosed(t.id,z.exitCode??0,!!z.killed).catch(()=>{}))},_=async()=>{const z=I?.retryCount??0,we=I?.retryDelay,Me=l?l.claim(z):z,Fe=typeof I?.timeout=="number"&&I.timeout>0?I.timeout:0,_e=typeof I?.killGracePeriodMs=="number"&&I.killGracePeriodMs>=0?I.killGracePeriodMs:5e3;let ne=!1,Te=0;const Oe=ro({killGracePeriodMs:_e,onTimeout:()=>{ne=!0},sendSignal:ve=>{X?.(ve)},timeoutMs:Fe});let fe;try{fe=await tt([{command:se,cwd:j,env:ie,name:t.id,...q?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:Se,...Me>0?{restart:{delay:we??"exponential",onRetry:async(ve,Ce,$)=>{Te=ve,i&&await i.callHook("task:retry",t,ve,$)},tries:Me}}:{}})}finally{Oe.cancel()}const xe=fe.closeEvents[0],$e=re?re.toString():K.toString();return ne?{code:124,retryAttempts:Te,terminalOutput:`${$e}
|
|
178
|
-
[timeout] Task "${t.id}" exceeded ${Fe}ms budget.
|
|
179
|
-
`}:{code:xe?.exitCode??1,retryAttempts:Te,terminalOutput:$e}};return p?Qo(p,I?.mutex,_):_()}},tc=s=>{if(!s||s.trim().length===0)return;const e=Number.parseFloat(s);return!Number.isFinite(e)||e<=0?{invalid:s}:{value:Math.floor(e)}},sc=async(s,e)=>{const t=await xr(s,{dataDirectory:st(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${jr(s,{dataDirectory:st(s)})}.`);return}const r=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const o=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of o){const d=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${d}ms)`)}e.info("")}const c=[...t.tasks].filter(o=>typeof o.duration=="number").sort((o,i)=>(i.duration??0)-(o.duration??0)).slice(0,5);if(c.length>0){e.info("Slowest tasks:");for(const o of c)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},rc=s=>{if(!(s===void 0||s==="")){if(s!=="read"&&s!=="write"&&s!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${s}")`);return s}},nc=s=>{if(!(s===void 0||s==="")){if(s!=="http"&&s!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${s}")`);return s}},ic=s=>{if(!(s===void 0||s==="")){if(s!=="declared"&&s!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${s}")`);return s}},Mc=async({argument:s,logger:e,options:t,visConfig:r,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=c;if(Kr({logger:e,options:t,visConfig:r},o),Bn(o),t.lastDetails){await sc(o,e);return}const i=process.cwd(),d=await Ar(o),{config:u,packageJsons:p,projectOptions:f,workspace:h}=Lr(o,r,d),l=Dr(o,h,p);let b=s[0];if(!b){const m=Zt(h);if(process.stdout.isTTY&&process.stdin.isTTY){const v=await ln(m);if(!v){e.info("No target selected.");return}b=v,await Qi(`vis run ${v}`)}else{e.info("Available targets:"),e.info(""),e.info(dn(m)),e.info(""),e.info("Usage: vis run <target>");return}}if(u.constraints&&!t.skipConstraints){const m=fr(l,u.constraints);if(m.length>0){for(const v of m)e.error(`[${v.rule}] ${v.message}`);throw new Error(`${m.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(!t.affected){const m=t.uncommitted?"--uncommitted":"--no-uncommitted",v=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[m,t.uncommitted]].filter(([,y])=>y!==void 0).map(([y])=>y);if(v.length>0)throw new Ze(`${v.join(", ")} ${v.length===1?"requires":"require"} --affected.
|
|
180
|
-
Did you mean: vis run ${b} --affected ${v.map(y=>y.includes("uncommitted")?y:`${y}=…`).join(" ")}
|
|
181
|
-
Or use the dedicated command: vis affected ${b} …`)}const T=await gn(b,h,process.cwd(),o),N=un(f),F=fn(T.target,N);F!==T.target&&e.debug?.(`Resolved alias "${T.target}" → "${F}"`);let S=T.projects;const E=s.slice(1).map(String);if(t.projects!==void 0&&(S=hn(S,String(t.projects),Object.keys(h.projects))),t.filter&&t.filter.length>0){const m=new Map;for(const[P,G]of p)m.set(P,G.name);const v=await xo(t.filter,{defaultBase:r?.defaultBase,packageNameByProject:m,projectGraph:l,workspaceRoot:o}),y=new Set(v);if(S=S.filter(P=>y.has(P)),S.length===0){e.info(`Filter ${t.filter.map(P=>`"${P}"`).join(", ")} matched no projects.`);return}}if(t.query&&(S=wn(S,h,t.query),S.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}if(t.tag&&t.tag.length>0&&(S=vn(S,h,t.tag),S.length===0)){e.info(`Tag filter ${t.tag.map(m=>`"${m}"`).join(", ")} matched no projects.`);return}let I;if(t.affected){const m=await an({base:t.base,downstream:t.downstream,head:t.head,uncommitted:t.uncommitted,upstream:t.upstream},{projectGraph:l,projects:h.projects,workspaceRoot:o},{defaultBase:r?.defaultBase});for(const y of m.notes)e.info(`▸ ${y}`);if(m.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}const v=new Set(m.affectedProjects);if(S=S.filter(y=>v.has(y)),S.length===0){e.info("No projects affected by the changes.");return}I=m.changedFiles,e.info(`Affected projects: ${S.join(", ")}`)}const j=yn(),R=process.env[$t],w=I??(R?R.split(`
|
|
182
|
-
`).filter(Boolean):void 0),O=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,B=O?new Set(O.split(",").map(m=>m.trim()).filter(Boolean)):void 0,k=[],W=new Map;for(const m of S){const y=f.get(m)?.[F];if(!y)continue;const P=y.options;if(!P?.internal){if(!xn(P,!!Ye)){e.debug?.(`Skipping ${m}:${F} — runInCI filter`);continue}if(!jn(P,B)){e.debug?.(`Skipping ${m}:${F} — runner-tags filter`);continue}k.push(m),W.set(m,y)}}if(k.length===0){const m=Zt(h),v=Object.entries(h.projects).filter(([,y])=>y.targets?.[F]!==void 0).map(([y])=>y);if(e.error(`No projects have the "${F}" target.`),v.length>0){e.info(""),e.info(`Target "${F}" exists in these projects but was filtered out:`);for(const y of v.slice(0,5))e.info(` - ${y}`);v.length>5&&e.info(` …and ${v.length-5} more`)}else{const y=pn(F,m,3);y.length>0&&(e.info(""),e.info(y.length===1?`Did you mean "${y[0]}"?`:`Did you mean one of: ${y.map(P=>`"${P}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const se=t.pty,ae=k.map(m=>({project:m,schema:W.get(m)?.arguments})).filter(m=>Array.isArray(m.schema)&&m.schema.length>0),Q=new Map;for(const{project:m,schema:v}of ae){const y=JSON.stringify(v),P=Q.get(y)??[];P.push(m),Q.set(y,P)}if(Q.size>1){const m=[...Q.values()].map(v=>v.join(", ")).join(" | ");throw new Error(`Target "${F}" declares conflicting \`arguments\` schemas across projects (${m}). Run a single project (e.g. \`vis run ${ae[0]?.project}:${F}\` or --projects=<name>) so the argument contract is unambiguous.`)}const ee=ae[0]?.schema,ie=W.get(ae[0]?.project??k[0])?.description,oe=qo(F,ie,ee,E);if(oe.kind==="help"){e.info(oe.text);return}if(oe.kind==="invalid"){e.info(`Invalid arguments for "${F}":`);for(const m of oe.errors)e.info(` ✖ ${m}`);throw e.info(""),e.info(oe.help),new Error(`Invalid arguments for target "${F}"`)}const ge=oe.env,le=ic(t.hashMode);let q=k.map(m=>{const v=h.projects[m],y=W.get(m),P={project:m,target:F},G=`${m}:${F}`,Z=se?{...y.options,pty:y.options?.pty??!0}:y.options,D=y.command?zt(y.command,{affectedFiles:w,projectRoot:v?.root}):y.command,A=v?.root&&v.root.length>0?v.root:".",Y=(y.outputs??[]).map(H=>typeof H!="string"?H:H.replaceAll("{projectRoot}",A).replaceAll("{projectName}",m));return{cache:y.cache,hashMode:le??y.hashMode,id:G,outputs:Y,overrides:{command:D,...E.length>0?{[Ys]:E}:{},...Object.keys(ge).length>0?{[Ct]:ge}:{},...Z?{visOptions:Z}:{}},parallelism:y.parallelism,projectRoot:v?.root,target:P}});const K=[],re=[];for(const m of q)zs(m)?.persistent?(m.cache=!1,K.push(m)):re.push(m);q=re;const X=hr(t.partition);if(X&&(q=pr.partitionTasks(q,X),e.info(`Partition ${X.index}/${X.total}: running ${q.length} task(s)`),q.length===0)){e.info("No tasks assigned to this partition.");return}const Se=new Set([...q,...K].map(m=>m.id));let _=mr([...q,...K],{onCycleBroken:m=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${m.join(" → ")}`)},projectGraph:l,targetDefaults:u.tasks,workspace:h});for(const[m,v]of Object.entries(_.tasks)){const y=v.target.project,P=v.target.target,G=f.get(y)?.[P];if(!G){Se.has(m)||e.warn(`${P} required via dependsOn but no command is configured for ${y} — skipping (no-op).`);continue}const Z=h.projects[y];let D=!1;const A={...v.overrides};A.visOptions===void 0&&G.options&&(A.visOptions=G.options,D=!0),A.command===void 0&&G.command&&(A.command=zt(G.command,{affectedFiles:w,projectRoot:Z?.root}),D=!0),D&&(v.overrides=A,_.tasks[m]=v)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const m=fi(t.skipCache,h,Object.keys(_.tasks));for(const v of m.skipTaskIds){const y=_.tasks[v];y!==void 0&&(y.cache=!1)}m.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${m.unmatchedPatterns.map(v=>`"${v}"`).join(", ")}`),m.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(m.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await Xr(o,u.toolchain,{error:m=>{e.error(m)},info:m=>{e.info(m)},warn:m=>{e.warn(m)}},!!t.skipToolchain);const z=t.preflight!==!1&&u.preflight?.lockfile!==!1,we=Nr(o,Ye,{warn:m=>{e.warn(m)}},{skip:!z});if(!we.shouldContinue)throw new Error(`${we.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);z&&!Ye&&process.stdin.isTTY&&process.stdout.isTTY&&await li(o,{interactive:!0,logger:{info:m=>{e.info(m)},warn:m=>{e.warn(m)}},projectManifests:[...p.values()]});const Me=process.env.VIS_VERSION??"0.0.0",Fe=t.dryRun?void 0:async m=>{try{return await tn(m.config,{timeoutMs:Vo}),!0}catch{return!1}},_e=await sn(o),ne=await uo({initialTasks:[...q,...K],probe:Fe,registeredEntries:_e,taskGraph:_,visVersion:Me}),Te=[];let Oe,fe=0;const xe=[],$e=new Map;let ve=[];const Ce=new Set;let $=null,x=null;if(ne.diagnostics.length>0){const m=!!(process.stdout.isTTY&&process.stdin.isTTY),v=t.dryRun?"off":Lo({cli:t.services,config:u.run?.services,isCi:!!Ye,isPersistentTarget:K.length>0,isTty:m,target:F});if(v==="off"){for(const H of ne.diagnostics)e.error(H.message);const A=Ao({cli:t.services,config:u.run?.services}),Y=[];throw t.dryRun?Y.push("`--dry-run` never starts services; drop it to let vis boot them."):A==="default"?Y.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):A==="cli"?Y.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):Y.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new Ze([`${ne.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...Y].join(`
|
|
183
|
-
`))}const y=ne.diagnostics.map(A=>A.targetId),P=v,G=P==="registry"?qs(o,y,_):void 0,Z=process.argv[1]??"vis",D=Fo({missingServiceIds:y,mode:P,taskGraph:_,visBin:Z,workspaceRoot:o});if(D.skipped.length>0){for(const{id:A,reason:Y}of D.skipped)e.error(`Cannot auto-start ${A}: ${Y}`);throw new Ze(`${D.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Te.push(...D.ephemeralPidFiles),Oe=D.runDir,ve=D.chain;for(const A of D.chain)Ce.add(A);if(P==="registry"&&(fe=D.chain.length,xe.push(...D.chain)),D.chain.length>0){const A=new as(D.chain),Y=new Map;if(P==="ephemeral"&&D.runDir)for(const H of D.chain){const M=Vs(D.runDir,`${D.runDir}/bootstrap.mjs`,H);Y.set(H,{ephemeral:{configFile:M.configFile,cwd:o,logFile:M.logFile,pidFile:M.pidFile,scriptPath:M.scriptPath},mode:"ephemeral"})}else if(P==="registry"&&G)for(const H of G.services)Y.set(H.id,{mode:"registry",registry:{command:H.command,config:H.config,cwd:H.cwd,env:H.env}});if(Y.size>0){const H=new So({indexToId:new Map,services:Y,sink:{crashed:(M,L)=>{A.markCrashed(M,L)},failed:(M,L,V)=>{A.markFailed(M,L,V)},log:(M,L)=>{A.appendLog(M,L)},ready:(M,L)=>{A.markReady(M,L)},started:(M,L)=>{A.markStarted(M,L),P==="registry"&&L!==null&&$e.set(M,L)},starting:M=>{A.markStarting(M)}},workspaceRoot:o});$=A,x=H}}for(const[A,Y]of D.serviceEnvByTaskId){const H=ne.serviceEnvByTaskId.get(A)??{};ne.serviceEnvByTaskId.set(A,{...H,...Y})}}const C=new Set(K.map(m=>m.id));if(q=ne.initialTasks.filter(m=>!C.has(m.id)),_=ne.taskGraph,ve.length>0&&(q=[...ve.map(v=>_.tasks[v]).filter(v=>v!==void 0),...q]),K.length>0){const m=new Set(K.map(Z=>Z.id)),v={};for(const[Z,D]of Object.entries(_.tasks))m.has(Z)||(v[Z]=D);const y={};for(const[Z,D]of Object.entries(_.dependencies))m.has(Z)||(y[Z]=D.filter(A=>!m.has(A)));const P=new Set;for(const Z of Object.values(y))for(const D of Z)P.add(D);const G=Object.keys(v).filter(Z=>!P.has(Z));_={dependencies:y,roots:G,tasks:v}}const{serviceEnvByTaskId:te}=ne;if(ne.satisfiedServices.length>0){const m=ne.satisfiedServices.map(v=>v.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${m}`),$)for(const v of ne.satisfiedServices)$.registerService(v.id);else $=new as(ne.satisfiedServices.map(v=>v.id));for(const v of ne.satisfiedServices){const y=v.config.readiness?.tcp?.port??v.config.port??0,P=v.config.readiness?.tcp?.host??"127.0.0.1";$.markReady(v.id,{host:P,port:y})}}if(t.reverse&&(_=gr(_),e.debug?.(`Reversed task graph: ${String(_.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const m=Object.keys(_.tasks).length,v=_.roots.length;e.info(`Execution plan (${String(m)} task(s), ${String(v)} root(s)):`),e.info("");const y=new Set,P=(G,Z)=>{if(y.has(G))return;y.add(G);for(const H of _.dependencies[G]??[])P(H,Z+1);const D=_.tasks[G],A=" ".repeat(Z+1),Y=`${D?.cache===!1?" (no-cache)":""}${D?.hashMode==="trace"?" (trace)":""}`;e.info(`${A}${G}${Y}`)};for(const G of _.roots)P(G,0);for(const G of Object.keys(_.tasks))P(G,0);K.length>0&&(e.info(""),e.info(` + ${String(K.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const Ae=Date.now(),Ie=rn(),Et=(m,v)=>{const y=v instanceof Error?v.message:String(v);e.warn(`Plugin error in ${m}: ${y}`)};await nn(Ie,u.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,Rt=async m=>{if(!qe)return;const v=Xt(m,_,Ae),y=qe.startsWith("/")?qe:`${o}/${qe}`;await kr(v,y),e.info(`Profile written to ${qe}`)},Xe=u.taskRunner??{},Ks=Cr(o,t.cacheDir,Xe.cacheDirectory,u.sharedWorktreeCache),Xs=Er(Ks,o,u.branchScopedCache),Ne=tc(process.env.VIS_RUN_CONCURRENCY_LIMIT);Ne&&"invalid"in Ne&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Ne.invalid} is not a positive number; falling back to default concurrency.`);const Js=Ne&&"value"in Ne?Ne.value:void 0,ut=t.parallel??Js??3,Pt=t.strictEnv??u.strictEnv??!1,Mt=new Set,Le={dryRun:t.dryRun??!1,parallel:ut,skipNxCache:!t.cache,summarize:t.summarize??!1,...Xe,cacheDirectory:Xs,dataDirectory:Xe.dataDirectory??st(o),namedInputs:u.namedInputs,onDiagnostic:(m,v)=>{Mt.has(m)||(Mt.add(m),e.warn(v))},onFingerprint:async(m,v)=>{await Ie.callHook("task:fingerprint",m,v)}},Ft=wr(Xe.remoteCache);if(Ft){const m=rc(t.cacheMode),v=nc(t.cacheBackend);if(Le.remoteCache={...Ft,...m?{mode:m}:{},...v?{backend:v}:{}},Le.remoteCache.attestation){const{expectedIdentity:y,requireOnDownload:P}=Le.remoteCache.attestation;if(!(y!==void 0&&("github"in y&&typeof y.github?.ref=="string"&&typeof y.github.repo=="string"&&typeof y.github.workflow=="string"||"oidcIssuer"in y&&typeof y.oidcIssuer=="string"&&(typeof y.san=="string"||typeof y.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in y&&(!y.sanRegex.startsWith("^")||!y.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:Z,isSigstoreInstalled:D}=await import("./loader.js");D()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
|
|
184
|
-
${Z(o)}`);const{buildCacheAttestationHooks:A}=await import("./cache-attestation.js");Le.remoteCache.attestation=A({expectedIdentity:y,onReject:(Y,H)=>{e.warn(`[vis run] remote cache entry ${Y.slice(0,12)} rejected: attestation ${H}. Treating as a cache miss.`)},onVerifyFailure:Y=>{e.warn(`[vis run] attestation verification failed: ${Y}`)},requireOnDownload:P,workspaceRoot:o})}}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.");const Qs=process.stdout.isTTY&&!Ye,Zs=r?.run?.quietOnSuccess===!0,er=u.tui?.autoExit??(Zs?3:!1),Ot={args:{parallel:Le.parallel,targets:[F]},autoExit:er,projectNames:k,tasks:[...q,...K],totalTaskCount:Object.keys(_.tasks).length+K.length},At=typeof t.retryBudget=="number"?t.retryBudget:void 0,Lt=At===void 0?void 0:Zo(At),Dt=new on(Ie,Et),Bt=new Yr(o),_t=Ki(t.outputStyle,r?.run?.quietOnSuccess);if(ne.satisfiedServices.length>0)for(const m of ne.satisfiedServices){const v=ne.serviceDependentsByServiceId.get(m.id)??[];try{await Ie.callHook("service:attach",m,v)}catch(y){Et("service:attach",y)}}await Ie.callHook("run:before",{tasks:q,workspaceRoot:o});const Ve=t.stopServices;let Nt=!1;const Gt=()=>{if(Nt)return;Nt=!0,x&&x.dispose().catch(()=>{});const m=Ve?[...$e.values()]:void 0;zo({extraPids:m,pidFiles:Te,runDir:Oe})},Je=()=>{Gt()},Wt=Te.length>0||Oe!==void 0||Ve&&xe.length>0;Wt&&(process.on("SIGINT",Je),process.on("SIGTERM",Je));try{if(Qs){const m=new Map,v=zi({...Ot,onRetryService:x?M=>x.retry(M):void 0,outputStyle:_t,serviceDockStore:$,stdinRegistry:m}),{lifeCycle:y,store:P}=v,G=new Yt([y,Dt,Bt]),D=bs({affectedFiles:w,currentOs:j,hooks:Ie,initCwd:i,lifeCycle:G,mutexPool:new Map,onOutput:(M,L)=>{x&&Ce.has(M)?x.onTaskOutput(M,L):P.addOutput(M,L)},onOutputReplace:(M,L)=>{P.setOutput(M,L)},retryBudget:Lt,serviceEnvByTaskId:te,serviceEventBridge:x??void 0,stdinRegistry:m,strictEnv:Pt,taskSlots:ut,workspaceRoot:o});let A="rerun",Y=null,H=new Map;for(;A!=="quit";){if(A==="rerun"){if(H=await Kt(q,Le,{lifeCycle:G,projectGraph:l,taskExecutor:D,taskGraph:_,workspaceRoot:o}),K.length>0&&!t.failFast){const M=new Promise(L=>{const V=P.subscribe(()=>{const de=P.getSnapshot();(de.rerunRequested||de.retryTaskId)&&(V(),L())});v.renderIsDone.then(()=>{V(),L()}).catch(()=>{V(),L()})});await js(K,o,w,i,{abortSignal:M,lifeCycle:G,stdinRegistry:m,store:P},te)}}else if(A==="retry"&&Y){const M=q.find(V=>V.id===Y),L=M?.overrides.command;if(M&&L){const V=at(o,M.projectRoot,!1);G.startTasks?.([M]);const de=new yt(ct),pe=(await tt([{command:L,cwd:V,name:M.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ce=>{ce.kind==="started"&&ce.write&&m.set(M.id,{kill:ce.kill,resize:ce.resize,write:ce.write}),(ce.kind==="stdout"||ce.kind==="stderr")&&ce.text&&(de.write(ce.text),P.setOutput(M.id,de.toString())),ce.kind==="close"&&m.delete(M.id)}})).closeEvents[0];G.endTasks?.([{code:pe?.exitCode??1,status:pe?.exitCode===0?"success":"failure",task:M,terminalOutput:P.getSnapshot().outputs.get(M.id)}])}else M&&G.endTasks?.([{code:1,status:"failure",task:M,terminalOutput:`No command configured for ${M.id}`}]);Y=null,P.markDone()}A=await new Promise(M=>{const L=P.subscribe(()=>{const V=P.getSnapshot();V.rerunRequested&&(P.acknowledgeRerun(),L(),M("rerun")),V.retryTaskId&&(Y=P.acknowledgeRetry(),L(),M("retry"))});v.renderIsDone.then(()=>{L(),M("quit")}).catch(()=>{L(),M("quit")})})}await v.renderIsDone,await Ie.callHook("run:after",H),await Rt(H),fe>0&&(e.info(""),Ve?e.info(`${String(fe)} service(s) stopped (--stop-services).`):e.info(`${String(fe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const m=new Map,v=typeof t.log=="string"?t.log.toLowerCase():"",y=v==="labeled"||v==="grouped"||v==="interleaved"?v:void 0,P=y?vr(y):void 0,G=new Yt([new Ji({...Ot,ciGrouping:r?.run?.ciGrouping??"auto",logReporter:P,outputStyle:_t}),Dt,Bt]),Z=bs({affectedFiles:w,currentOs:j,hooks:Ie,initCwd:i,lifeCycle:G,mutexPool:m,retryBudget:Lt,serviceEnvByTaskId:te,serviceEventBridge:x??void 0,strictEnv:Pt,taskSlots:ut,workspaceRoot:o}),D=async()=>{const L=Date.now(),V=await Kt(q,Le,{lifeCycle:G,projectGraph:l,taskExecutor:Z,taskGraph:_,workspaceRoot:o}),de=Date.now()-L;if(t.summarize){const ye=Xt(V,_,Ae);await yr(ye,o,{dataDirectory:st(o)})}let je=!1;for(const[,ye]of V)ye.status==="failure"&&(je=!0);const pe=Rr(V,de),ce=Pr(o),Ee=Mr(o,de,ce);return e.info(""),e.info(` ${pe}${Ee?` ${Ee}`:""}`),{hasFailure:je,results:V,runHistory:ce}},A=await D();await Ie.callHook("run:after",A.results),await Rt(A.results);const{hasFailure:Y}=A;if(t.watch){const L=k.map(he=>{const Re=h.projects[he]?.root;if(Re)return Re.startsWith("/")?Re:`${o}/${Re}`}).filter(he=>he!==void 0),V=q;let de;const je=he=>{const ke=no(V,he);return de=ke.filter,q=ke.tasks,ke.tasks.length};let pe=!1,ce=A.results;const Ee=()=>{const he=ss(ce,o);if(he.directories.length>0&&he.files.size>0){const ke=_n(he.files,o,he.directories);return{handle:rs({filter:ke,onChange:Qe,paths:he.directories}),mode:"tracked"}}return{handle:rs({onChange:Qe,paths:L}),mode:"roots"}};let ye;const Qe=async he=>{if(!pe){pe=!0;try{e.info(`Change detected in ${he.length} file(s), rerunning…`),ce=(await D()).results,ye?.close(),ye=Ee().handle}finally{pe=!1}}},Ht=Ee();ye=Ht.handle;const tr=Ht.mode==="tracked"?`Watching ${String(ss(ce,o).files.size)} tracked file(s)`:`Watching ${String(L.length)} project root(s)`;e.info(`${tr} — edit a file to rerun, press h for keybinds, q to quit.`);const ft=async()=>{if(!pe){pe=!0;try{if(q.length===0){e.info("No tasks match the active filter — press a to clear it.");return}ce=(await D()).results,ye?.close(),ye=Ee().handle}finally{pe=!1}}};await new Promise(he=>{let ke=!1,Re;const qt=()=>{Vt()},Vt=()=>{ke||(ke=!0,Re?.close(),process.off("SIGINT",qt),ye?.close(),he())};process.on("SIGINT",qt),Re=ao({handlers:{onClearFilter:async()=>{const Ue=je(void 0);e.info(`Filter cleared — running ${String(Ue)} task(s).`),await ft()},onFilter:async Ue=>{const sr=de,Ut=je(Ue);if(Ut===0){e.info(`Filter "${Ue}" matched no projects — keeping previous filter.`),je(sr);return}e.info(`Filter "${Ue}" matched ${String(Ut)} task(s).`),await ft()},onHelp:()=>{oo(process.stdout)},onQuit:()=>{Vt()},onRerun:ft}})});return}if(t.flaky){const L=Fr(o,{minRuns:2},A.runHistory);if(L.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const V of Or(L))e.info(` ${V}`);e.info("")}}const H=[];for(const[L,V]of A.results)V.retryAttempts&&V.retryAttempts>0&&H.push(L);const M=t.failOnRetry&&H.length>0;if(M){const V=H.slice(0,5),de=H.length-V.length,je=de>0?`${V.join(", ")}, and ${String(de)} more`:V.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(H.length)} task(s) succeeded only after retry: ${je}`)}if(Y||M){const L=M&&!Y?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",V=2e3,de=[];for(const[je,pe]of A.results){if(pe.status!=="failure")continue;const ce=pe.terminalOutput??"",Ee=ce.length>V?`…${ce.slice(-V)}`:ce,ye=pe.code??"?";de.push(` ${je} (exit ${String(ye)}):
|
|
185
|
-
${Ee.split(`
|
|
186
|
-
`).map(Qe=>` ${Qe}`).join(`
|
|
187
|
-
`)}`)}throw new Ze(de.length>0?`${L}
|
|
188
|
-
${de.join(`
|
|
189
|
-
`)}`:L)}K.length>0&&!t.failFast&&await js(K,o,w,i,void 0,te),fe>0&&(e.info(""),Ve?e.info(`${String(fe)} service(s) stopped (--stop-services).`):e.info(`${String(fe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Gt(),Wt&&(process.off("SIGINT",Je),process.off("SIGTERM",Je)),Ve&&xe.length>0&&await Promise.all(xe.map(async m=>{try{await cn(o,m)}catch{}}))}};export{Zo as createRetryBudget,Mc as default};
|
|
1
|
+
import{createRequire as Ne}from"node:module";import{v as W,V as Ce,U as ze,W as Ge,T as $e,X as We,Y as Ve,d as Ue}from"./cli-main.js";import{i as Xe}from"../packem_shared/index-BjdW45xX.js";import{u as p,y as e,X as s,m as o,R as He}from"./catalog.js";import{d as Ke}from"../packem_shared/pm-runner-d93_73O6.js";import{i as qe,e as le,z as Ye,m as Qe}from"../packem_shared/index-DHD8wb6Z.js";import{y as Ze}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{h as et}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{n as tt,a as ot}from"../packem_shared/tabs-UDYQ3tqt.js";let Re;const Be=i=>(Re??=Ne(import.meta.url))(i),q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_e=i=>{if(typeof q<"u"&&q.versions&&q.versions.node){const[t,n]=q.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return q.getBuiltinModule(i)}return Be(i)},{writeFileSync:Je}=_e("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(qe,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),V=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],nt=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Ze(t))return null;const n=Ye(t),c=rt(n),l=c!==n;let r;try{r=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:r,hadComments:l}},it=(i,t,n)=>{const c=n?Qe(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");et(c),Je(l,`${JSON.stringify(t,null,2)}
|
|
2
|
+
`,"utf8")},st={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],deno:[{source:"${localWorkspaceFolderBasename}-deno-cache",target:"/home/node/.cache/deno",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},ct=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],pe=(i,t,n)=>{const c=[],l=new Set(n.map(a=>typeof a=="string"?a:a.target));if(i)for(const a of st[i])l.has(a.target)||c.push(a);const r=Object.keys(t);for(const{featureMatch:a,mounts:m}of ct)if(r.some(g=>g.includes(a)))for(const g of m)l.has(g.target)||c.push(g);return c},B=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],Y=i=>structuredClone(i);class lt{#r=new Set;#e;constructor(t,n,c=null){const l=t===null,r=t??{name:""},a=Y(r);this.#e={config:a,detectedPm:c,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:n,isDirty:!1,mode:l?"create":"edit",originalConfig:l?null:Y(r),section:"general",showTemplateSelector:l,suggestedMounts:pe(c,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#r.add(t),()=>{this.#r.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const n=(B.indexOf(this.#e.section)+1)%B.length;this.setSection(B[n])}previousSection(){const n=(B.indexOf(this.#e.section)-1+B.length)%B.length;this.setSection(B[n])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const n=Math.max(0,Math.min(t,V.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=V.find(c=>c.id===t);n&&this.#t(this.#o({...this.#e,config:Y(n.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const n={...this.#e.config.features};n[t]===void 0?n[t]={}:delete n[t],this.#t(this.#o({...this.#e,config:{...this.#e.config,features:n},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const n=this.#e.config.forwardPorts??[];if(n.includes(t))return;const c=[...n,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:c},isDirty:!0})}removePort(t){const n=[...this.#e.config.forwardPorts??[]];n.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:n.length>0?n:void 0},isDirty:!0})}toggleExtension(t){const n={...this.#e.config.customizations},c={...n.vscode},l=[...c.extensions??[]],r=l.indexOf(t);r===-1?l.push(t):l.splice(r,1),c.extensions=l.length>0?l:void 0,n.vscode=c.extensions||c.settings?c:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:n.vscode||n.jetbrains?n:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,n,c){const l=t==="container"?"containerEnv":"remoteEnv",r={...this.#e.config[l],[n]:c};this.#t({...this.#e,config:{...this.#e.config,[l]:r},isDirty:!0})}removeEnvVar(t,n){const c=t==="container"?"containerEnv":"remoteEnv",l={...this.#e.config[c]};delete l[n],this.#t({...this.#e,config:{...this.#e.config,[c]:Object.keys(l).length>0?l:void 0},isDirty:!0})}addMount(t){const n=[...this.#e.config.mounts??[],t];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n},isDirty:!0}))}removeMount(t){const n=[...this.#e.config.mounts??[]];n.splice(t,1),this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n.length>0?n:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,n){this.#t({...this.#e,config:{...this.#e.config,[t]:n||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:Y(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=Y(this.#e.config);for(const[n,c]of Object.entries(t))(c===""||c===void 0)&&delete t[n];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#o(t){return{...t,suggestedMounts:pe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const n of this.#r)try{n()}catch{}}}const xe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],je=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],de=i=>{if(!i)return je;const t=i.toLowerCase();return je.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},ue=i=>{if(!i)return xe;const t=i.toLowerCase();return xe.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},at=/^[a-z]$/i,dt=i=>{const t=i.codePointAt(0);return t!==void 0&&(t<32||t===127)},ut=(i,t)=>i.length===0||dt(i)?!1:t.ctrl&&t.meta?!at.test(i):!(t.ctrl||t.meta),ht=/\S+\s*$/,se=(i,t)=>i.length===0||!t?void 0:t.find(n=>n.startsWith(i))?.slice(i.length)??void 0,ke=-1,mt=(i,t,n,c)=>t.leftArrow?Math.max(0,n-1):t.home||t.ctrl&&i==="a"?0:t.end||t.ctrl&&i==="e"?c:ke,gt=(i,t,n,c)=>{if(t.backspace&&c>0)return[n.slice(0,c-1)+n.slice(c),c-1];if(t.delete&&c<n.length)return[n.slice(0,c)+n.slice(c+1),c];if(t.ctrl&&i==="u")return[n.slice(c),0];if(t.ctrl&&i==="k")return[n.slice(0,c),c];if(t.ctrl&&i==="w"){const l=n.slice(0,c).replace(ht,"");return[l+n.slice(c),l.length]}};function he({defaultValue:i="",isDisabled:t=!1,mask:n=!1,onChange:c,onSubmit:l,placeholder:r,suggestions:a}){const[m,f]=p.useState(i),[g,v]=p.useState(i.length),x=p.useRef(m);x.current=m;const b=p.useRef(g);b.current=g;const y=p.useRef(c);y.current=c;const D=p.useRef(l);D.current=l;const k=se(m,a),M=p.useCallback((T,I)=>{const{current:E}=b,S=x.current;if(I.return){const w=se(S,a),C=w?S+w:S;w&&(f(C),v(C.length),y.current?.(C)),D.current?.(C);return}if(I.escape)return;if(I.rightArrow){const w=se(S,a);if(E===S.length&&w){const C=S+w;f(C),v(C.length),y.current?.(C);return}v(Math.min(S.length,E+1));return}const A=mt(T,I,E,S.length);if(A!==ke){v(A);return}const H=gt(T,I,S,E);if(H){const[w,C]=H;f(w),v(C),y.current?.(w);return}if(ut(T,I)){const w=S.slice(0,E)+T+S.slice(E);f(w),v(E+T.length),y.current?.(w)}},[a]);W(M,{isActive:!t});const L=n?"*".repeat(m.length):m,U=L.slice(0,g),X=L[g],Q=L.slice(g+1);return t?e.jsx(s,{children:e.jsx(o,{dimColor:!0,children:L||r||""})}):m.length===0&&r?e.jsxs(s,{children:[e.jsx(o,{dimColor:!0,inverse:!0,children:r[0]}),e.jsx(o,{dimColor:!0,children:r.slice(1)})]}):e.jsxs(s,{children:[e.jsxs(o,{children:[U,e.jsx(o,{inverse:!0,children:X??" "}),Q]}),k?e.jsx(o,{dimColor:!0,children:k}):void 0]})}const Ee=["dockerComposeFile","service"],ft={dockerComposeFile:"Compose File",service:"Service"},ve={dockerComposeFile:"docker-compose.yml",service:"app"},pt={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},xt=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>{const l=!!i.dockerComposeFile,r=!!(i.image||i.build);return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),r&&l&&e.jsx(s,{marginBottom:1,children:e.jsx(o,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ee.map((a,m)=>{const f=m===n,g=i[a]??"",v=Array.isArray(i[a])?i[a].join(", "):g;return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:f,color:f?"cyan":"white",children:[f?"❯ ":" ",ft[a],":"]})}),e.jsx(s,{flexGrow:1,children:f&&t?e.jsx(he,{defaultValue:v,onChange:x=>{c({[a]:x||void 0})},placeholder:ve[a]}):e.jsx(o,{color:v?"white":"gray",children:v||ve[a]})})]}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:pt[a]})})]},a)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},jt=Ee.length,vt=({config:i,fieldIndex:t})=>{const n=i.containerEnv??{},c=i.remoteEnv??{},l=Object.keys(n),r=Object.keys(c),a=l.length,m=l.length+1,f=m+r.length,g=t<=a,v=t>a;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{borderColor:g?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:l.length>0?1:0,children:[e.jsx(o,{bold:!0,color:g?"cyan":"white",children:"containerEnv"}),e.jsx(o,{dimColor:!0,children:" — baked into the container image"})]}),l.map((x,b)=>{const y=b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:n[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:l.length>0?1:0,children:e.jsxs(o,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(s,{borderColor:v?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:r.length>0?1:0,children:[e.jsx(o,{bold:!0,color:v?"cyan":"white",children:"remoteEnv"}),e.jsx(o,{dimColor:!0,children:" — set at runtime by the IDE"})]}),r.map((x,b)=>{const D=m+b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:D?"cyan":void 0,inverse:D,wrap:"truncate",children:[D?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:c[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:r.length>0?1:0,children:e.jsxs(o,{color:t===f?"cyan":"gray",inverse:t===f,children:[" ","+ Add variable..."]})})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[e.jsx(o,{bold:!0,color:"white",children:"a"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},bt=i=>{const t=Object.keys(i.containerEnv??{}).length,n=Object.keys(i.remoteEnv??{}).length;return t+1+n+1},wt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(i.customizations?.vscode?.extensions),[i.customizations?.vscode?.extensions]),a=p.useMemo(()=>ue(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.id]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No extensions match the search."})})]})},yt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(Object.keys(i.features??{})),[i.features]),a=p.useMemo(()=>de(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.description]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No features match the search."})})]})},ae=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],St={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},be={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},te=["privileged","overrideCommand"],Ct={overrideCommand:"Override Command",privileged:"Privileged"},kt=ae.length+te.length,Et=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"General Configuration"})}),ae.map((l,r)=>{const a=r===n,m=i[l]??"";return e.jsxs(s,{marginBottom:1,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",St[l],":"]})}),e.jsx(s,{flexGrow:1,children:a&&t?e.jsx(he,{defaultValue:m,onChange:f=>{c({[l]:f})},placeholder:be[l]}):e.jsx(o,{color:m?"white":"gray",children:m||be[l]})})]},l)}),te.map((l,r)=>{const m=ae.length+r===n,f=i[l]??!1;return e.jsxs(s,{marginBottom:r<te.length-1?1:0,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:m,color:m?"cyan":"white",children:[m?"❯ ":" ",Ct[l],":"]})}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{color:f?"green":"gray",children:[f?"yes":"no",m&&e.jsx(o,{dimColor:!0,children:" (Space to toggle)"})]})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Ie=kt,ce=te,De=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],It={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},Dt={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Tt=({config:i,fieldEditing:t,fieldIndex:n,onSetCommand:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),De.map((l,r)=>{const a=r===n,m=i[l],f=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsx(s,{children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",It[l]]})}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:Dt[l]})}),e.jsx(s,{paddingLeft:4,children:a&&t?e.jsx(he,{defaultValue:f,onChange:g=>{c(l,g)},placeholder:"e.g. npm install"}):e.jsx(o,{color:f?"green":"gray",children:f||"(not set)"})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),At=De.length,we=i=>typeof i=="string"?i:`[${i.type}] ${i.source} → ${i.target}`,Ft=({addingMount:i,config:t,detectedPm:n,fieldIndex:c,mountPhase:l,mountSource:r,mountTarget:a,mountType:m,suggestedMounts:f})=>{const g=t.mounts??[];return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[g.length," ","mounts"]}),n&&e.jsxs(o,{dimColor:!0,children:["— detected:"," ",e.jsx(o,{color:"white",children:n})]})]}),f.length>0&&!i&&e.jsxs(s,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(s,{flexShrink:0,children:[e.jsx(o,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(o,{dimColor:!0,children:[" ","— press"," ",e.jsx(o,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),f.map((v,x)=>e.jsx(s,{flexShrink:0,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[" + ",we(v)]})},`suggestion-${String(x)}`))]}),g.length>0&&e.jsx(s,{flexDirection:"column",marginBottom:1,children:g.map((v,x)=>{const b=x===c;return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:b?">":" "}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:b,inverse:b,wrap:"truncate",children:[" ",we(v)]})})]},`mount-${String(x)}`)})}),!i&&e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:c===g.length?"cyan":"gray",inverse:c===g.length,children:[" ","+ Add mount..."]})}),i&&e.jsxs(s,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(s,{flexShrink:0,marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="source",color:l==="source"?"cyan":"white",children:[l==="source"?"❯ ":" ","Source:"]})}),e.jsx(o,{color:r?"yellow":"gray",children:r||(l==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="target",color:l==="target"?"cyan":"white",children:[l==="target"?"❯ ":" ","Target:"]})}),e.jsx(o,{color:a?"yellow":"gray",children:a||(l==="target"?"_":"/container/path")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="type",color:l==="type"?"cyan":"white",children:[l==="type"?"❯ ":" ","Type:"]})}),l==="type"?e.jsxs(o,{children:[e.jsx(o,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(o,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(o,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(o,{color:"gray",children:m})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:l==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),g.length===0&&!i&&f.length===0&&e.jsx(s,{marginTop:1,children:e.jsx(o,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Lt=({addingPort:i,addPortValue:t,config:n,fieldIndex:c})=>{const l=n.forwardPorts??[],r=c===l.length;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(o,{dimColor:!0,children:[" ","(",l.length," ","ports)"]})]}),l.map((a,m)=>{const f=m===c;return e.jsx(s,{children:e.jsxs(o,{color:f?"cyan":void 0,inverse:f,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(s,{marginTop:l.length>0?1:0,children:e.jsxs(o,{color:r?"cyan":"gray",inverse:r,children:[" ",r&&i?e.jsxs(o,{children:["Enter port:"," ",e.jsx(o,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ",r?"type port number, Enter to confirm":"select"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},Ot=({focused:i,hadComments:t,jsonPreview:n,mode:c,scrollRef:l})=>e.jsxs(s,{borderColor:i?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,paddingX:1,children:[e.jsx(o,{bold:!0,color:i?"cyan":"white",children:"Preview"}),e.jsxs(o,{dimColor:!0,children:[" ","(",c==="create"?"new":"edit",")"]})]}),t&&c==="edit"&&e.jsx(s,{flexShrink:0,paddingX:1,children:e.jsx(o,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(ze,{flexGrow:1,ref:l,scrollbar:!0,scrollbarColor:"gray",children:n.split(`
|
|
3
|
+
`).map((r,a)=>e.jsx(o,{color:"green",children:r},`line-${String(a)}`))})]}),Pt=i=>{const t=[],n=[],c=[];if(!i.image&&!i.build&&!i.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),i.build&&(i.image&&n.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),i.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),i.dockerComposeFile&&!i.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),i.features!==void 0&&(typeof i.features!="object"||Array.isArray(i.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),i.forwardPorts)if(Array.isArray(i.forwardPorts))for(const[l,r]of i.forwardPorts.entries())typeof r=="number"&&(r<1||r>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(r)} at index ${String(l)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return i.customizations?.vscode?.extensions&&!Array.isArray(i.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),i.customizations?.vscode?.settings&&typeof i.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),i.name||c.push({field:"name",message:"Consider adding a name for better identification"}),(!i.features||Object.keys(i.features).length===0)&&c.push({field:"features",message:"Consider adding features for common tools"}),(!i.customizations?.vscode?.extensions||i.customizations.vscode.extensions.length===0)&&c.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),i.privileged&&n.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:c,valid:t.length===0,warnings:n}},ye=80,Se=15,Mt=120,Te=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Nt=new Map(Te.map(i=>[i.id,i.description])),Rt=(i,t,n,c)=>{switch(i){case"compose":return jt;case"environment":return bt(t);case"extensions":return ue(c).length;case"features":return de(n).length;case"general":return Ie;case"lifecycle":return At;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Bt=({onSave:i,store:t})=>{const{exit:n}=Ge(),{columns:c,rows:l}=$e(),r=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[f,g]=p.useState(!1),[v,x]=p.useState(!1),[b,y]=p.useState(null),[D,k]=p.useState("editor"),[M,L]=p.useState(0),[U,X]=p.useState(!1),[Q,T]=p.useState(""),[I,E]=p.useState(null),[S,A]=p.useState(""),[H,w]=p.useState(""),[C,_]=p.useState("key"),[oe,Z]=p.useState(!1),[re,z]=p.useState(""),[ne,G]=p.useState(""),[me,K]=p.useState("volume"),[O,$]=p.useState("source"),ie=p.useRef(null),R=p.useRef(null),N=p.useRef(null),ee=p.useRef(!0);p.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,N.current&&clearTimeout(N.current)}),[]);const ge=Rt(r.section,r.config,r.featureSearch,r.extensionSearch),J=Math.max(1,l-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||L(u=>r.fieldIndex>=u+J?r.fieldIndex-J+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,J]),p.useEffect(()=>{L(0)},[r.section,r.featureSearch,r.extensionSearch]);const Ae=p.useCallback(()=>{const u=t.cleanConfig(),h=Pt(u);if(!h.valid){const j=h.errors[0];y(j?`Error: ${j.message}`:"Validation failed"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},3e3);return}i(u),t.markClean();const d=h.warnings.length;y(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},2e3)},[i,t]);W((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(r.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(r.templateIndex-1);else if(h.return){const d=V[r.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:r.showTemplateSelector}),W((u,h)=>{if(h.escape){X(!1),T("");return}if(h.return){const d=Number.parseInt(Q,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),X(!1),T("");return}if(h.backspace){T(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&T(d=>d+u)},{isActive:U}),W((u,h)=>{if(h.escape){E(null),A(""),w(""),_("key");return}if(h.return){if(C==="key"&&S){_("value");return}if(C==="value"&&S){t.addEnvVar(I,S,H),E(null),A(""),w(""),_("key");return}}if(h.backspace){C==="key"?A(d=>d.slice(0,-1)):w(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="key"?A(d=>d+u):w(d=>d+u))},{isActive:I!==null}),W((u,h)=>{if(h.escape){Z(!1),z(""),G(""),$("source");return}if(h.return){if(O==="source"&&re){$("target");return}if(O==="target"&&ne){$("type");return}if(O==="type"){t.addMount({source:re,target:ne,type:me}),Z(!1),z(""),G(""),$("source");return}}if(O==="type"){switch(u){case"1":{K("volume");break}case"2":{K("bind");break}case"3":{K("tmpfs");break}}return}if(h.backspace){O==="source"?z(d=>d.slice(0,-1)):O==="target"&&G(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(O==="source"?z(d=>d+u):O==="target"&&G(d=>d+u))},{isActive:oe}),W((u,h)=>{if(u==="c"&&h.ctrl){n();return}if(!f){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?ie.current?.scrollBy(1):h.upArrow||u==="k"?ie.current?.scrollBy(-1):u==="q"&&(m(!1),g(!0));return}if(v){if(h.escape){x(!1),r.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){r.section==="features"?t.setFeatureSearch(r.featureSearch.slice(0,-1)):t.setExtensionSearch(r.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){r.section==="features"?t.setFeatureSearch(r.featureSearch+u):t.setExtensionSearch(r.extensionSearch+u);return}return}if(r.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){r.isDirty?g(!0):n();return}if(u==="s"){Ae();return}if(h.tab){k(d=>d==="editor"?"preview":"editor");return}if(D==="preview"){if(h.downArrow||u==="j"){R.current?.scrollBy(1);return}if(h.upArrow||u==="k"){R.current?.scrollBy(-1);return}if(h.pageDown){R.current?.scrollBy(10);return}if(h.pageUp){R.current?.scrollBy(-10);return}if(h.home){R.current?.scrollToTop();return}if(h.end){R.current?.scrollToBottom();return}h.escape&&k("editor");return}if(h.downArrow||u==="j"){ge>0&&t.setFieldIndex(Math.min(r.fieldIndex+1,ge-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(r.fieldIndex-1,0));return}if(h.return){switch(r.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(r.config.containerEnv??{}).length,j=d,P=d+1+Object.keys(r.config.remoteEnv??{}).length;r.fieldIndex===j?(E("container"),A(""),w(""),_("key")):r.fieldIndex===P&&(E("remote"),A(""),w(""),_("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(Z(!0),z(""),G(""),K("volume"),$("source"));break}case"ports":{const d=r.config.forwardPorts??[];r.fieldIndex===d.length&&(X(!0),T(""));break}}return}if(u===" "){switch(r.section){case"extensions":{const j=ue(r.extensionSearch)[r.fieldIndex];j&&t.toggleExtension(j.id);break}case"features":{const j=de(r.featureSearch)[r.fieldIndex];j&&t.toggleFeature(j.id);break}case"general":{const d=Ie-ce.length,j=r.fieldIndex-d;if(j>=0&&j<ce.length){const P=ce[j];t.updateConfig({[P]:!r.config[P]})}break}}return}if(u==="/"){(r.section==="features"||r.section==="extensions")&&x(!0);return}if(u==="A"&&r.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(r.section==="environment"){const d=Object.keys(r.config.containerEnv??{}).length,j=r.fieldIndex<=d?"container":"remote";E(j),A(""),w(""),_("key")}else r.section==="mounts"&&(Z(!0),z(""),G(""),K("volume"),$("source"));return}if(u==="d")switch(r.section){case"environment":{const d=Object.keys(r.config.containerEnv??{}),j=Object.keys(r.config.remoteEnv??{});if(r.fieldIndex<d.length)t.removeEnvVar("container",d[r.fieldIndex]),d.length===1||r.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const P=r.fieldIndex-d.length-1;P>=0&&P<j.length&&(t.removeEnvVar("remote",j[P]),j.length===1||P>=j.length-1&&t.setFieldIndex(r.fieldIndex-1))}break}case"mounts":{const d=r.config.mounts??[];if(r.fieldIndex<d.length){t.removeMount(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}case"ports":{const d=r.config.forwardPorts??[];if(r.fieldIndex<d.length){t.removePort(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}}}},{isActive:!r.showTemplateSelector&&!U&&I===null&&!oe});const Fe=p.useMemo(()=>t.getJsonPreview(),[r.config]);if(c<ye||l<Se)return e.jsx(s,{alignItems:"center",height:l,justifyContent:"center",width:c,children:e.jsxs(o,{color:"yellow",children:["Terminal too small (",c,"x",l,"), need"," ",ye,"x",Se]})});if(r.showTemplateSelector)return e.jsx(s,{alignItems:"center",flexDirection:"column",height:l,justifyContent:"center",width:c,children:e.jsxs(s,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(s,{justifyContent:"center",marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Select a Template"})}),V.map((u,h)=>{const d=h===r.templateIndex;return e.jsx(s,{children:e.jsxs(o,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(o,{bold:d,children:u.name}),e.jsxs(o,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(s,{justifyContent:"center",marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let F;switch(r.section){case"compose":{F=e.jsx(xt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{F=e.jsxs(s,{flexDirection:"column",children:[e.jsx(vt,{config:r.config,fieldIndex:r.fieldIndex}),I!==null&&e.jsx(s,{marginTop:1,paddingX:1,children:e.jsxs(o,{color:"cyan",children:["Add"," ",I," ","env:"," ",C==="key"?e.jsxs(o,{children:["key=",e.jsx(o,{color:"yellow",children:S||"_"})," ","(Enter to set value)"]}):e.jsxs(o,{children:[S,"=",e.jsx(o,{color:"yellow",children:H||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{F=e.jsx(wt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.extensionSearch,viewportHeight:J});break}case"features":{F=e.jsx(yt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.featureSearch,viewportHeight:J});break}case"general":{F=e.jsx(Et,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{F=e.jsx(Tt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{F=e.jsx(Ft,{addingMount:oe,config:r.config,detectedPm:r.detectedPm,fieldIndex:r.fieldIndex,mountPhase:O,mountSource:re,mountTarget:ne,mountType:me,suggestedMounts:r.suggestedMounts});break}case"ports":{F=e.jsx(Lt,{addingPort:U,addPortValue:Q,config:r.config,fieldIndex:r.fieldIndex});break}default:F=e.jsx(o,{children:"Unknown section"})}const Le=e.jsxs(s,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(s,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:"QUIT"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:"HELP"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),e.jsx(o,{dimColor:!0,children:"NAV"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:"CHECK"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:"TABS"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:"PANEL"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:"FILTER"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(s,{paddingX:1,children:[b&&e.jsxs(o,{color:b.startsWith("Error")?"red":"green",children:[b," "]}),r.isDirty&&e.jsx(o,{color:"yellow",children:"[modified]"}),!r.isDirty&&!b&&e.jsx(o,{dimColor:!0,children:"[saved]"})]})]}),Oe=e.jsxs(We,{footer:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(o,{bold:!0,color:"white",children:"?"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ie,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(o,{bold:!0,color:"white",children:"j/k"}),e.jsx(o,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Enter"}),e.jsx(o,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Esc"}),e.jsx(o,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"a"}),e.jsx(o,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"d"}),e.jsx(o,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:" Quit"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:" Toggle help"})]})]})]}),Pe=e.jsx(Ot,{focused:D==="preview",hadComments:r.hadComments,jsonPreview:Fe,mode:r.mode,scrollRef:R}),fe=c>=Mt,Me=fe?Math.floor(c*.38):0;return e.jsxs(s,{flexDirection:"column",height:l,width:c,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(o,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(o,{wrap:"truncate",children:[r.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(s,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(tt,{defaultValue:r.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),k("editor")},showIndex:!1,children:Te.map(({id:u,label:h})=>e.jsx(ot,{name:u,children:h},u))})}),e.jsx(s,{flexShrink:0,paddingRight:2,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:Nt.get(r.section)??""})}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{borderColor:D==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:F}),fe&&e.jsx(s,{flexShrink:0,width:Me,children:Pe})]}),Le,e.jsx(Ve,{autoExitSeconds:3,onCancel:()=>{g(!1)},visible:f}),Oe]})},Kt=async({logger:i,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const c=n,l=t.template,r=t.output,a=!!process.stdout.isTTY&&!Xe;let m=null;try{m=Ke(c).name}catch{}const f=nt(c);let g=f?.config??null;const v=f?.hadComments??!1;if(l&&!f){const k=V.find(M=>M.id===l);if(!k){const M=V.map(L=>L.id).join(", ");throw new Error(`Unknown template "${l}". Valid templates: ${M}`)}g=k.config}if(!a){g?i.info(JSON.stringify(g,null,2)):(i.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),b=new lt(g,v,m);l&&!f&&b.dismissTemplateSelector();let y=null;if(await Ue(He.createElement(Bt,{onSave:k=>{it(c,k,r),y=k},store:b}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),y){const k=r??".devcontainer/devcontainer.json";i.info(`DevContainer config saved to ${k}`)}};export{Kt as default};
|