icoa-cli 2.19.648 → 2.19.649

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.
@@ -0,0 +1 @@
1
+ export function colorMode(t,o,n){if(!n)return"none";const e=`${t.LC_ALL||""}${t.LC_CTYPE||""}${t.LANG||""}`;return e&&!/utf-?8/i.test(e)||o<60?"none":"Apple_Terminal"===t.TERM_PROGRAM?"256":/truecolor|24bit/i.test(t.COLORTERM||"")||t.WT_SESSION||"vscode"===t.TERM_PROGRAM?"truecolor":"256"}export function videoSize(t){const o=Math.max(32,Math.min(96,t-4));let n=Math.round(9*o/16);return n%2&&(n+=1),{w:o,h:n}}const t=[0,95,135,175,215,255],o=t=>t<48?0:t<115?1:Math.min(5,Math.floor((t-35)/40));export function rgbTo256(n,e,r){const i=o(n),c=o(e),s=o(r),u=t[i],a=t[c],$=t[s],l=Math.round((n+e+r)/3),f=l>238?23:Math.max(0,Math.round((l-8)/10)),M=8+10*f;return(n-M)**2+(e-M)**2+(r-M)**2<(n-u)**2+(e-a)**2+(r-$)**2?232+f:16+36*i+6*c+s}export function encodeFrame(t,o,n,e,r){const i=[];if("none"===r)return i;for(let c=0;c+1<e;c+=2){let e="",s="",u="";for(let i=0;i<n;i++){const a=o+3*(c*n+i),$=a+3*n;let l,f;"truecolor"===r?(l=`38;2;${248&t[a]};${248&t[a+1]};${248&t[a+2]}`,f=`48;2;${248&t[$]};${248&t[$+1]};${248&t[$+2]}`):(l=`38;5;${rgbTo256(t[a],t[a+1],t[a+2])}`,f=`48;5;${rgbTo256(t[$],t[$+1],t[$+2])}`),l===s&&f===u||(e+=`[${l};${f}m`,s=l,u=f),e+="▀"}i.push(` ${e}`)}return i}const n=t=>new Promise(o=>setTimeout(o,t));export async function playFrames(t,o,e,r){const{w:i,h:c,n:s,fps:u}=o,a=process.stdout;if("none"===e||0===s)return void(s&&a.write(`${r(s-1)}\n`));const $=c/2+1,l=i*c*3;a.write("[?25l");try{for(let o=0;o<s;o++){const s=Date.now(),f=encodeFrame(t,o*l,i,c,e);a.write(`${o?`[${$}A`:""}${f.join("\n")}\n${r(o)}\n`);const M=1e3/u-(Date.now()-s);M>0&&await n(M)}}finally{a.write("[?25h")}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.648",
3
+ "version": "2.19.649",
4
4
  "description": "ICOA CLI — AI-native competition runtime of the International Cyber Olympiad in AI: learn, practise, and compete in AI & cybersecurity from the terminal (AI4CTF · CTF4AI · CTF4EAI)",
5
5
  "author": "Charlie Zhu",
6
6
  "type": "module",