openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
6 lines • 3.57 kB
JavaScript
import{t as ExitError}from"./runtime-DIcLIHcp.mjs";import{t as sleep}from"./sleep-B4CgCyZu.mjs";import{n as isRich,r as theme}from"./theme-DS2CtI9X.mjs";import{i as supportsDecorativeEmoji,t as decorativeEmoji}from"./decorative-emoji-pSMDjFKZ.mjs";
//!src/cli/claw-banner.ts
const MASCOT_ART=[` •●●:. .:●●•`,`:●●●●: :●●●●:`,`.●●●●:.:•●●•:.:●●●●.`,` .●●●: •●●●●• :●●●.`,` ..:••●●●●●●●●••:..`,`.::••••●●●●●●••••::.`,` . .: •●●●●• :. .`,` . :●●●●: .`,` .●●●●●●.`,` :••••:`];const MASCOT_OPEN_ROWS=[`•●•.:. .:.•●•`,`:●●●•: :•●●●:`];const MASCOT_WIDTH=20;const WORDMARK_ROW_OFFSET=3;const WORDMARK_ART=[`█▀▀▀█ █▀▀▀█ █▀▀▀▀ █▄ █ █▀▀▀▀ █ █▀▀▀█ █ █`,`█ █ █▀▀▀▀ █▀▀▀ █ ▀▄█ █ █ █▀▀▀█ █▄▀▄█`,`▀▀▀▀▀ ▀ ▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀ ▀▀▀▀▀ ▀ ▀ ▀ ▀`];const GAP=3;const BANNER_WIDTH=71;const ROWS=MASCOT_ART.length;const identityTint=e=>e;function composeFrame(e){const t=e.mascotRows??MASCOT_ART;const n=[];for(let r=0;r<ROWS;r++){const i=(t[r]??``).padEnd(MASCOT_WIDTH).slice(0,MASCOT_WIDTH);let a=``;for(let t=0;t<i.length;t++){const n=i[t]??` `;a+=n===` `?` `:(e.mascotTint?.(t)??theme.accent)(n)}const o=WORDMARK_ART[r-WORDMARK_ROW_OFFSET];if(o){a+=` `.repeat(GAP);for(let t=0;t<o.length;t++){const n=o[t]??` `;a+=n===` `?` `:(e.wordmarkTint?.(23+t)??identityTint)(n)}}n.push(a.replace(/\s+$/,``))}return n}async function animateBanner(e){const write=e=>process.stdout.write(e);let t=false;let n;const r=e?Promise.resolve(e).then(()=>{t=true},()=>{t=true}):null;const pause=async e=>{if(r)await Promise.race([sleep(e),r]);else await sleep(e);if(n!==void 0)throw new ExitError(n);return!t};let i=false;const draw=e=>{const t=i?`\x1b[${ROWS}F`:``;i=true;write(`${t}${e.map(e=>`\x1b[K${e}`).join(`
`)}\n`)};const onSignal=e=>{n??=e===`SIGINT`?130:143};const onSigint=()=>onSignal(`SIGINT`);const onSigterm=()=>onSignal(`SIGTERM`);process.once(`SIGINT`,onSigint);process.once(`SIGTERM`,onSigterm);write(`\x1B[?25l`);try{const e=5;for(let t=0;t<=e;t++){const n=Math.round(BANNER_WIDTH*t/e);const tintAt=e=>t=>t<n?e:t<n+2?theme.accentBright:theme.muted;draw(composeFrame({mascotTint:tintAt(theme.accent),wordmarkTint:tintAt(identityTint)}));if(!await pause(20))return`settled`}for(let e=MASCOT_WIDTH;e<77;e+=9){const band=t=>t>=e&&t<e+9?theme.accentBright:identityTint;draw(composeFrame({wordmarkTint:band}));if(!await pause(20))return`settled`}draw(composeFrame({mascotRows:[...MASCOT_OPEN_ROWS,...MASCOT_ART.slice(2)]}));if(!await pause(35))return`settled`;draw(composeFrame({}));if(!await pause(35))return`settled`;draw(composeFrame({}));return`completed`}finally{try{if(t&&i&&n===void 0)draw(composeFrame({}))}finally{process.off(`SIGINT`,onSigint);process.off(`SIGTERM`,onSigterm);write(`\x1B[?25h`)}}}async function printClawBanner(e,t={}){if((process.stdout.columns??80)<BANNER_WIDTH){const t=decorativeEmoji(`🦞`);const n=supportsDecorativeEmoji()&&t?`${t} OPENCLAW ${t}`:`OPENCLAW`;e.log(`${n}\n`);return`static`}if(!(process.stdout.isTTY&&isRich()&&!process.env.CI&&!process.env.VITEST)){e.log(`${composeFrame({}).join(`
`)}\n`);return`static`}const n=await animateBanner(t.settleWhen);process.stdout.write(`
`);return n}export{printClawBanner as t};