@utsp/render 0.15.0-nightly.20251227200128.cdc09ed → 0.15.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.
@@ -1,2 +1,2 @@
1
1
  "use strict";var b=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var y=(r,e,t)=>e in r?b(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e)=>b(r,"name",{value:e,configurable:!0});var E=(r,e)=>{for(var t in e)b(r,t,{get:e[t],enumerable:!0})},G=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of N(e))!O.call(r,i)&&i!==t&&b(r,i,{get:()=>e[i],enumerable:!(o=B(e,i))||o.enumerable});return r};var z=r=>G(b({},"__esModule",{value:!0}),r);var C=(r,e,t)=>(y(r,typeof e!="symbol"?e+"":e,t),t);var F={};E(F,{TerminalANSI:()=>m,createTestRenderState:()=>v,hexToRGB:()=>T,rgbToHex:()=>$});module.exports=z(F);var S="\x1B[0m",H="\x1B[H",A="\x1B[2J",w="\x1B[?25l",P="\x1B[?25h",W=`
2
- `,I=class I{constructor(e={}){C(this,"options");C(this,"fgCache",[]);C(this,"bgCache",[]);C(this,"lastPalette",null);this.options={optimizeColors:e.optimizeColors??!0,includeHome:e.includeHome??!0,hideCursor:e.hideCursor??!0,includeNewlines:e.includeNewlines??!0,includeReset:e.includeReset??!0}}buildColorCache(e){if(this.lastPalette!==e){this.fgCache=new Array(e.length),this.bgCache=new Array(e.length);for(let t=0;t<e.length;t++){let o=e[t];this.fgCache[t]=`\x1B[38;2;${o.r};${o.g};${o.b}m`,this.bgCache[t]=`\x1B[48;2;${o.r};${o.g};${o.b}m`}this.lastPalette=e}}render(e){let{width:t,height:o,cells:i,palette:s}=e;this.buildColorCache(s);let n="";this.options.hideCursor&&(n+=w),this.options.includeHome&&(n+=H);let g=-1,h=-1,x=this.options.optimizeColors,R=this.options.includeNewlines;for(let l=0;l<o;l++){let u=l*t;for(let a=0;a<t;a++){let c=i[u+a],p=c.fgColorIndex,f=c.bgColorIndex;x?(f!==h&&(n+=this.bgCache[f],h=f),p!==g&&(n+=this.fgCache[p],g=p)):(n+=this.bgCache[f],n+=this.fgCache[p]),n+=c.char||" "}R&&l<o-1&&(n+=W)}return this.options.includeReset&&(n+=S),n}renderRow(e,t){let{width:o,cells:i,palette:s}=e;this.buildColorCache(s);let n=`\x1B[${t+1};1H`,g=-1,h=-1,x=this.options.optimizeColors,R=t*o;for(let l=0;l<o;l++){let u=i[R+l],a=u.fgColorIndex,c=u.bgColorIndex;x?(c!==h&&(n+=this.bgCache[c],h=c),a!==g&&(n+=this.fgCache[a],g=a)):(n+=this.bgCache[c],n+=this.fgCache[a]),n+=u.char||" "}return this.options.includeReset&&(n+=S),n}clear(){return A+H}showCursor(){return P}hideCursor(){return w}reset(){return S}moveTo(e,t){return`\x1B[${e+1};${t+1}H`}};d(I,"TerminalANSI");var m=I;function T(r){let e=r.startsWith("#")?r.slice(1):r,t=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,o=parseInt(t,16);return{r:o>>16&255,g:o>>8&255,b:o&255,a:255}}d(T,"hexToRGB");function $(r){let e=r.r.toString(16).padStart(2,"0"),t=r.g.toString(16).padStart(2,"0"),o=r.b.toString(16).padStart(2,"0");return`#${e}${t}${o}`}d($,"rgbToHex");function v(r,e){let t=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;t.length<256;)t.push({r:128,g:128,b:128,a:255});let o=[];for(let i=0;i<e;i++)for(let s=0;s<r;s++)o.push({char:String.fromCharCode(65+(s+i)%26),fgColorIndex:15,bgColorIndex:(s+i)%16,fgEmission:0,bgEmission:0});return{width:r,height:e,cells:o,palette:t}}d(v,"createTestRenderState");
2
+ `,I=class I{constructor(e={}){C(this,"options");C(this,"fgCache",[]);C(this,"bgCache",[]);C(this,"lastPalette",null);this.options={optimizeColors:e.optimizeColors??!0,includeHome:e.includeHome??!0,hideCursor:e.hideCursor??!0,includeNewlines:e.includeNewlines??!0,includeReset:e.includeReset??!0}}buildColorCache(e){if(this.lastPalette!==e){this.fgCache=new Array(e.length),this.bgCache=new Array(e.length);for(let t=0;t<e.length;t++){let o=e[t];this.fgCache[t]=`\x1B[38;2;${o.r};${o.g};${o.b}m`,this.bgCache[t]=`\x1B[48;2;${o.r};${o.g};${o.b}m`}this.lastPalette=e}}render(e){let{width:t,height:o,cells:i,palette:s}=e;this.buildColorCache(s);let n="";this.options.hideCursor&&(n+=w),this.options.includeHome&&(n+=H);let g=-1,h=-1,x=this.options.optimizeColors,R=this.options.includeNewlines;for(let l=0;l<o;l++){let u=l*t;for(let a=0;a<t;a++){let c=i[u+a],p=c.fgColorIndex,f=c.bgColorIndex;x?(f!==h&&(n+=this.bgCache[f],h=f),p!==g&&(n+=this.fgCache[p],g=p)):(n+=this.bgCache[f],n+=this.fgCache[p]),n+=c.char||" "}R&&l<o-1&&(n+=W)}return this.options.includeReset&&(n+=S),n}renderRow(e,t){let{width:o,cells:i,palette:s}=e;this.buildColorCache(s);let n=`\x1B[${t+1};1H`,g=-1,h=-1,x=this.options.optimizeColors,R=t*o;for(let l=0;l<o;l++){let u=i[R+l],a=u.fgColorIndex,c=u.bgColorIndex;x?(c!==h&&(n+=this.bgCache[c],h=c),a!==g&&(n+=this.fgCache[a],g=a)):(n+=this.bgCache[c],n+=this.fgCache[a]),n+=u.char||" "}return this.options.includeReset&&(n+=S),n}clear(){return A+H}showCursor(){return P}hideCursor(){return w}reset(){return S}moveTo(e,t){return`\x1B[${e+1};${t+1}H`}};d(I,"TerminalANSI");var m=I;function T(r){let e=r.startsWith("#")?r.slice(1):r,t=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,o=parseInt(t,16);return{r:o>>16&255,g:o>>8&255,b:o&255,a:255}}d(T,"hexToRGB");function $(r){let e=r.r.toString(16).padStart(2,"0"),t=r.g.toString(16).padStart(2,"0"),o=r.b.toString(16).padStart(2,"0");return`#${e}${t}${o}`}d($,"rgbToHex");function v(r,e){let t=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;t.length<256;)t.push({r:128,g:128,b:128,a:255});let o=[];for(let i=0;i<e;i++)for(let s=0;s<r;s++)o.push({char:String.fromCharCode(65+(s+i)%26),fgColorIndex:15,bgColorIndex:(s+i)%16,fgEmission:0,bgEmission:0});return{id:0,width:r,height:e,cells:o,palette:t}}d(v,"createTestRenderState");
@@ -1,2 +1,2 @@
1
1
  var I=Object.defineProperty;var T=(o,e,t)=>e in o?I(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var b=(o,e)=>I(o,"name",{value:e,configurable:!0});var d=(o,e,t)=>(T(o,typeof e!="symbol"?e+"":e,t),t);var x="\x1B[0m",H="\x1B[H",$="\x1B[2J",w="\x1B[?25l",v="\x1B[?25h",B=`
2
- `,S=class S{constructor(e={}){d(this,"options");d(this,"fgCache",[]);d(this,"bgCache",[]);d(this,"lastPalette",null);this.options={optimizeColors:e.optimizeColors??!0,includeHome:e.includeHome??!0,hideCursor:e.hideCursor??!0,includeNewlines:e.includeNewlines??!0,includeReset:e.includeReset??!0}}buildColorCache(e){if(this.lastPalette!==e){this.fgCache=new Array(e.length),this.bgCache=new Array(e.length);for(let t=0;t<e.length;t++){let r=e[t];this.fgCache[t]=`\x1B[38;2;${r.r};${r.g};${r.b}m`,this.bgCache[t]=`\x1B[48;2;${r.r};${r.g};${r.b}m`}this.lastPalette=e}}render(e){let{width:t,height:r,cells:i,palette:s}=e;this.buildColorCache(s);let n="";this.options.hideCursor&&(n+=w),this.options.includeHome&&(n+=H);let g=-1,h=-1,f=this.options.optimizeColors,m=this.options.includeNewlines;for(let l=0;l<r;l++){let u=l*t;for(let a=0;a<t;a++){let c=i[u+a],C=c.fgColorIndex,p=c.bgColorIndex;f?(p!==h&&(n+=this.bgCache[p],h=p),C!==g&&(n+=this.fgCache[C],g=C)):(n+=this.bgCache[p],n+=this.fgCache[C]),n+=c.char||" "}m&&l<r-1&&(n+=B)}return this.options.includeReset&&(n+=x),n}renderRow(e,t){let{width:r,cells:i,palette:s}=e;this.buildColorCache(s);let n=`\x1B[${t+1};1H`,g=-1,h=-1,f=this.options.optimizeColors,m=t*r;for(let l=0;l<r;l++){let u=i[m+l],a=u.fgColorIndex,c=u.bgColorIndex;f?(c!==h&&(n+=this.bgCache[c],h=c),a!==g&&(n+=this.fgCache[a],g=a)):(n+=this.bgCache[c],n+=this.fgCache[a]),n+=u.char||" "}return this.options.includeReset&&(n+=x),n}clear(){return $+H}showCursor(){return v}hideCursor(){return w}reset(){return x}moveTo(e,t){return`\x1B[${e+1};${t+1}H`}};b(S,"TerminalANSI");var R=S;function N(o){let e=o.startsWith("#")?o.slice(1):o,t=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,r=parseInt(t,16);return{r:r>>16&255,g:r>>8&255,b:r&255,a:255}}b(N,"hexToRGB");function O(o){let e=o.r.toString(16).padStart(2,"0"),t=o.g.toString(16).padStart(2,"0"),r=o.b.toString(16).padStart(2,"0");return`#${e}${t}${r}`}b(O,"rgbToHex");function y(o,e){let t=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;t.length<256;)t.push({r:128,g:128,b:128,a:255});let r=[];for(let i=0;i<e;i++)for(let s=0;s<o;s++)r.push({char:String.fromCharCode(65+(s+i)%26),fgColorIndex:15,bgColorIndex:(s+i)%16,fgEmission:0,bgEmission:0});return{width:o,height:e,cells:r,palette:t}}b(y,"createTestRenderState");export{R as TerminalANSI,y as createTestRenderState,N as hexToRGB,O as rgbToHex};
2
+ `,S=class S{constructor(e={}){d(this,"options");d(this,"fgCache",[]);d(this,"bgCache",[]);d(this,"lastPalette",null);this.options={optimizeColors:e.optimizeColors??!0,includeHome:e.includeHome??!0,hideCursor:e.hideCursor??!0,includeNewlines:e.includeNewlines??!0,includeReset:e.includeReset??!0}}buildColorCache(e){if(this.lastPalette!==e){this.fgCache=new Array(e.length),this.bgCache=new Array(e.length);for(let t=0;t<e.length;t++){let r=e[t];this.fgCache[t]=`\x1B[38;2;${r.r};${r.g};${r.b}m`,this.bgCache[t]=`\x1B[48;2;${r.r};${r.g};${r.b}m`}this.lastPalette=e}}render(e){let{width:t,height:r,cells:i,palette:s}=e;this.buildColorCache(s);let n="";this.options.hideCursor&&(n+=w),this.options.includeHome&&(n+=H);let g=-1,h=-1,f=this.options.optimizeColors,m=this.options.includeNewlines;for(let l=0;l<r;l++){let u=l*t;for(let a=0;a<t;a++){let c=i[u+a],C=c.fgColorIndex,p=c.bgColorIndex;f?(p!==h&&(n+=this.bgCache[p],h=p),C!==g&&(n+=this.fgCache[C],g=C)):(n+=this.bgCache[p],n+=this.fgCache[C]),n+=c.char||" "}m&&l<r-1&&(n+=B)}return this.options.includeReset&&(n+=x),n}renderRow(e,t){let{width:r,cells:i,palette:s}=e;this.buildColorCache(s);let n=`\x1B[${t+1};1H`,g=-1,h=-1,f=this.options.optimizeColors,m=t*r;for(let l=0;l<r;l++){let u=i[m+l],a=u.fgColorIndex,c=u.bgColorIndex;f?(c!==h&&(n+=this.bgCache[c],h=c),a!==g&&(n+=this.fgCache[a],g=a)):(n+=this.bgCache[c],n+=this.fgCache[a]),n+=u.char||" "}return this.options.includeReset&&(n+=x),n}clear(){return $+H}showCursor(){return v}hideCursor(){return w}reset(){return x}moveTo(e,t){return`\x1B[${e+1};${t+1}H`}};b(S,"TerminalANSI");var R=S;function N(o){let e=o.startsWith("#")?o.slice(1):o,t=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,r=parseInt(t,16);return{r:r>>16&255,g:r>>8&255,b:r&255,a:255}}b(N,"hexToRGB");function O(o){let e=o.r.toString(16).padStart(2,"0"),t=o.g.toString(16).padStart(2,"0"),r=o.b.toString(16).padStart(2,"0");return`#${e}${t}${r}`}b(O,"rgbToHex");function y(o,e){let t=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;t.length<256;)t.push({r:128,g:128,b:128,a:255});let r=[];for(let i=0;i<e;i++)for(let s=0;s<o;s++)r.push({char:String.fromCharCode(65+(s+i)%26),fgColorIndex:15,bgColorIndex:(s+i)%16,fgEmission:0,bgEmission:0});return{id:0,width:o,height:e,cells:r,palette:t}}b(y,"createTestRenderState");export{R as TerminalANSI,y as createTestRenderState,N as hexToRGB,O as rgbToHex};
package/dist/index.cjs CHANGED
@@ -199,4 +199,4 @@
199
199
  height: 100% !important;
200
200
  pointer-events: none !important;
201
201
  `;let i=this.canvas.getContext("2d",{alpha:!0});if(!i)throw new Error("PostProcessOverlay: Failed to get 2D context");this.ctx=i,this.containerDiv.appendChild(this.canvas),this.parentElement.appendChild(this.containerDiv),this.resizeObserver=new ResizeObserver(a=>{for(let r of a){let{width:o,height:n}=r.contentRect;o>0&&n>0&&this.handleResize(Math.floor(o),Math.floor(n))}}),this.resizeObserver.observe(this.parentElement);let s=this.parentElement.getBoundingClientRect();s.width>0&&s.height>0&&this.handleResize(Math.floor(s.width),Math.floor(s.height)),this.hide()}handleResize(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e,this.currentConfig&&this.isActive()&&this.render())}setConfig(t){let e=this.hashConfig(t);if(e!==this.configHash){if(this.currentConfig=t,this.configHash=e,!t||!this.isActiveConfig(t)){this.clear(),this.hide();return}this.show(),this.render()}}setScanlines(t){t===null?this.setConfig({scanlines:{enabled:!1}}):this.setConfig({scanlines:t})}setScanlinesEnabled(t){if(t){let e=this.currentConfig?.scanlines;this.setScanlines({enabled:!0,opacity:e?.opacity??W.POST_PROCESS_DEFAULTS.scanlines.opacity,pattern:e?.pattern??"horizontal",spacing:e?.spacing??2,thickness:e?.thickness??1,color:e?.color??{r:0,g:0,b:0}})}else this.setScanlines({enabled:!1})}setScanlinesOpacity(t){let e=Math.max(0,Math.min(1,t)),i=this.currentConfig?.scanlines;this.setScanlines({enabled:i?.enabled??!0,opacity:e,pattern:i?.pattern??"horizontal",spacing:i?.spacing??2,thickness:i?.thickness??1,color:i?.color??{r:0,g:0,b:0}})}setScanlinesPattern(t){let e=this.currentConfig?.scanlines;this.setScanlines({enabled:e?.enabled??!0,opacity:e?.opacity??W.POST_PROCESS_DEFAULTS.scanlines.opacity,pattern:t,spacing:e?.spacing??2,thickness:e?.thickness??1,color:e?.color??{r:0,g:0,b:0}})}setScanlinesSpacing(t){let e=Math.max(2,Math.round(t)),i=this.currentConfig?.scanlines;this.setScanlines({enabled:i?.enabled??!0,opacity:i?.opacity??W.POST_PROCESS_DEFAULTS.scanlines.opacity,pattern:i?.pattern??"horizontal",spacing:e,thickness:i?.thickness??1,color:i?.color??{r:0,g:0,b:0}})}getConfig(){return this.currentConfig}isActive(){return this.isActiveConfig(this.currentConfig)}destroy(){this.resizeObserver.disconnect(),this.containerDiv.parentElement&&this.containerDiv.parentElement.removeChild(this.containerDiv)}syncWithRenderer(t){}resize(t,e){}setCellDimensions(t,e){}show(){this.containerDiv.style.display="block"}hide(){this.containerDiv.style.display="none"}clear(){this.ctx.clearRect(0,0,this.width,this.height)}isActiveConfig(t){return t?.scanlines?.enabled??!1}render(){this.clear(),this.currentConfig?.scanlines?.enabled&&this.renderScanlines(this.currentConfig.scanlines)}renderScanlines(t){let e=t.opacity??W.POST_PROCESS_DEFAULTS.scanlines.opacity,i=t.pattern??"horizontal",s=t.spacing??2,a=t.thickness??1,r=t.color??{r:0,g:0,b:0},o=this.ctx;switch(o.fillStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${e})`,i){case"horizontal":for(let n=s-1;n<this.height;n+=s)o.fillRect(0,n,this.width,a);break;case"vertical":for(let n=s-1;n<this.width;n+=s)o.fillRect(n,0,a,this.height);break;case"grid":for(let n=s-1;n<this.height;n+=s)o.fillRect(0,n,this.width,a);for(let n=s-1;n<this.width;n+=s)o.fillRect(n,0,a,this.height);break}}hashConfig(t){return t?JSON.stringify(t):"null"}};v(q,"PostProcessOverlay");var z=q;var j="\x1B[0m",rt="\x1B[H",bt="\x1B[2J",at="\x1B[?25l",pt="\x1B[?25h",vt=`
202
- `,Q=class Q{constructor(t={}){l(this,"options");l(this,"fgCache",[]);l(this,"bgCache",[]);l(this,"lastPalette",null);this.options={optimizeColors:t.optimizeColors??!0,includeHome:t.includeHome??!0,hideCursor:t.hideCursor??!0,includeNewlines:t.includeNewlines??!0,includeReset:t.includeReset??!0}}buildColorCache(t){if(this.lastPalette!==t){this.fgCache=new Array(t.length),this.bgCache=new Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];this.fgCache[e]=`\x1B[38;2;${i.r};${i.g};${i.b}m`,this.bgCache[e]=`\x1B[48;2;${i.r};${i.g};${i.b}m`}this.lastPalette=t}}render(t){let{width:e,height:i,cells:s,palette:a}=t;this.buildColorCache(a);let r="";this.options.hideCursor&&(r+=at),this.options.includeHome&&(r+=rt);let o=-1,n=-1,h=this.options.optimizeColors,c=this.options.includeNewlines;for(let d=0;d<i;d++){let f=d*e;for(let m=0;m<e;m++){let g=s[f+m],u=g.fgColorIndex,p=g.bgColorIndex;h?(p!==n&&(r+=this.bgCache[p],n=p),u!==o&&(r+=this.fgCache[u],o=u)):(r+=this.bgCache[p],r+=this.fgCache[u]),r+=g.char||" "}c&&d<i-1&&(r+=vt)}return this.options.includeReset&&(r+=j),r}renderRow(t,e){let{width:i,cells:s,palette:a}=t;this.buildColorCache(a);let r=`\x1B[${e+1};1H`,o=-1,n=-1,h=this.options.optimizeColors,c=e*i;for(let d=0;d<i;d++){let f=s[c+d],m=f.fgColorIndex,g=f.bgColorIndex;h?(g!==n&&(r+=this.bgCache[g],n=g),m!==o&&(r+=this.fgCache[m],o=m)):(r+=this.bgCache[g],r+=this.fgCache[m]),r+=f.char||" "}return this.options.includeReset&&(r+=j),r}clear(){return bt+rt}showCursor(){return pt}hideCursor(){return at}reset(){return j}moveTo(t,e){return`\x1B[${t+1};${e+1}H`}};v(Q,"TerminalANSI");var k=Q;function nt(b){let t=b.startsWith("#")?b.slice(1):b,e=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,i=parseInt(e,16);return{r:i>>16&255,g:i>>8&255,b:i&255,a:255}}v(nt,"hexToRGB");function ot(b){let t=b.r.toString(16).padStart(2,"0"),e=b.g.toString(16).padStart(2,"0"),i=b.b.toString(16).padStart(2,"0");return`#${t}${e}${i}`}v(ot,"rgbToHex");function lt(b,t){let e=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;e.length<256;)e.push({r:128,g:128,b:128,a:255});let i=[];for(let s=0;s<t;s++)for(let a=0;a<b;a++)i.push({char:String.fromCharCode(65+(a+s)%26),fgColorIndex:15,bgColorIndex:(a+s)%16,fgEmission:0,bgEmission:0});return{width:b,height:t,cells:i,palette:e}}v(lt,"createTestRenderState");var Ct="0.1.0";
202
+ `,Q=class Q{constructor(t={}){l(this,"options");l(this,"fgCache",[]);l(this,"bgCache",[]);l(this,"lastPalette",null);this.options={optimizeColors:t.optimizeColors??!0,includeHome:t.includeHome??!0,hideCursor:t.hideCursor??!0,includeNewlines:t.includeNewlines??!0,includeReset:t.includeReset??!0}}buildColorCache(t){if(this.lastPalette!==t){this.fgCache=new Array(t.length),this.bgCache=new Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];this.fgCache[e]=`\x1B[38;2;${i.r};${i.g};${i.b}m`,this.bgCache[e]=`\x1B[48;2;${i.r};${i.g};${i.b}m`}this.lastPalette=t}}render(t){let{width:e,height:i,cells:s,palette:a}=t;this.buildColorCache(a);let r="";this.options.hideCursor&&(r+=at),this.options.includeHome&&(r+=rt);let o=-1,n=-1,h=this.options.optimizeColors,c=this.options.includeNewlines;for(let d=0;d<i;d++){let f=d*e;for(let m=0;m<e;m++){let g=s[f+m],u=g.fgColorIndex,p=g.bgColorIndex;h?(p!==n&&(r+=this.bgCache[p],n=p),u!==o&&(r+=this.fgCache[u],o=u)):(r+=this.bgCache[p],r+=this.fgCache[u]),r+=g.char||" "}c&&d<i-1&&(r+=vt)}return this.options.includeReset&&(r+=j),r}renderRow(t,e){let{width:i,cells:s,palette:a}=t;this.buildColorCache(a);let r=`\x1B[${e+1};1H`,o=-1,n=-1,h=this.options.optimizeColors,c=e*i;for(let d=0;d<i;d++){let f=s[c+d],m=f.fgColorIndex,g=f.bgColorIndex;h?(g!==n&&(r+=this.bgCache[g],n=g),m!==o&&(r+=this.fgCache[m],o=m)):(r+=this.bgCache[g],r+=this.fgCache[m]),r+=f.char||" "}return this.options.includeReset&&(r+=j),r}clear(){return bt+rt}showCursor(){return pt}hideCursor(){return at}reset(){return j}moveTo(t,e){return`\x1B[${t+1};${e+1}H`}};v(Q,"TerminalANSI");var k=Q;function nt(b){let t=b.startsWith("#")?b.slice(1):b,e=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,i=parseInt(e,16);return{r:i>>16&255,g:i>>8&255,b:i&255,a:255}}v(nt,"hexToRGB");function ot(b){let t=b.r.toString(16).padStart(2,"0"),e=b.g.toString(16).padStart(2,"0"),i=b.b.toString(16).padStart(2,"0");return`#${t}${e}${i}`}v(ot,"rgbToHex");function lt(b,t){let e=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;e.length<256;)e.push({r:128,g:128,b:128,a:255});let i=[];for(let s=0;s<t;s++)for(let a=0;a<b;a++)i.push({char:String.fromCharCode(65+(a+s)%26),fgColorIndex:15,bgColorIndex:(a+s)%16,fgEmission:0,bgEmission:0});return{id:0,width:b,height:t,cells:i,palette:e}}v(lt,"createTestRenderState");var Ct="0.1.0";
package/dist/index.mjs CHANGED
@@ -199,4 +199,4 @@ var it=Object.defineProperty;var at=(b,t,e)=>t in b?it(b,t,{enumerable:!0,config
199
199
  height: 100% !important;
200
200
  pointer-events: none !important;
201
201
  `;let i=this.canvas.getContext("2d",{alpha:!0});if(!i)throw new Error("PostProcessOverlay: Failed to get 2D context");this.ctx=i,this.containerDiv.appendChild(this.canvas),this.parentElement.appendChild(this.containerDiv),this.resizeObserver=new ResizeObserver(a=>{for(let r of a){let{width:o,height:n}=r.contentRect;o>0&&n>0&&this.handleResize(Math.floor(o),Math.floor(n))}}),this.resizeObserver.observe(this.parentElement);let s=this.parentElement.getBoundingClientRect();s.width>0&&s.height>0&&this.handleResize(Math.floor(s.width),Math.floor(s.height)),this.hide()}handleResize(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e,this.currentConfig&&this.isActive()&&this.render())}setConfig(t){let e=this.hashConfig(t);if(e!==this.configHash){if(this.currentConfig=t,this.configHash=e,!t||!this.isActiveConfig(t)){this.clear(),this.hide();return}this.show(),this.render()}}setScanlines(t){t===null?this.setConfig({scanlines:{enabled:!1}}):this.setConfig({scanlines:t})}setScanlinesEnabled(t){if(t){let e=this.currentConfig?.scanlines;this.setScanlines({enabled:!0,opacity:e?.opacity??H.scanlines.opacity,pattern:e?.pattern??"horizontal",spacing:e?.spacing??2,thickness:e?.thickness??1,color:e?.color??{r:0,g:0,b:0}})}else this.setScanlines({enabled:!1})}setScanlinesOpacity(t){let e=Math.max(0,Math.min(1,t)),i=this.currentConfig?.scanlines;this.setScanlines({enabled:i?.enabled??!0,opacity:e,pattern:i?.pattern??"horizontal",spacing:i?.spacing??2,thickness:i?.thickness??1,color:i?.color??{r:0,g:0,b:0}})}setScanlinesPattern(t){let e=this.currentConfig?.scanlines;this.setScanlines({enabled:e?.enabled??!0,opacity:e?.opacity??H.scanlines.opacity,pattern:t,spacing:e?.spacing??2,thickness:e?.thickness??1,color:e?.color??{r:0,g:0,b:0}})}setScanlinesSpacing(t){let e=Math.max(2,Math.round(t)),i=this.currentConfig?.scanlines;this.setScanlines({enabled:i?.enabled??!0,opacity:i?.opacity??H.scanlines.opacity,pattern:i?.pattern??"horizontal",spacing:e,thickness:i?.thickness??1,color:i?.color??{r:0,g:0,b:0}})}getConfig(){return this.currentConfig}isActive(){return this.isActiveConfig(this.currentConfig)}destroy(){this.resizeObserver.disconnect(),this.containerDiv.parentElement&&this.containerDiv.parentElement.removeChild(this.containerDiv)}syncWithRenderer(t){}resize(t,e){}setCellDimensions(t,e){}show(){this.containerDiv.style.display="block"}hide(){this.containerDiv.style.display="none"}clear(){this.ctx.clearRect(0,0,this.width,this.height)}isActiveConfig(t){return t?.scanlines?.enabled??!1}render(){this.clear(),this.currentConfig?.scanlines?.enabled&&this.renderScanlines(this.currentConfig.scanlines)}renderScanlines(t){let e=t.opacity??H.scanlines.opacity,i=t.pattern??"horizontal",s=t.spacing??2,a=t.thickness??1,r=t.color??{r:0,g:0,b:0},o=this.ctx;switch(o.fillStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${e})`,i){case"horizontal":for(let n=s-1;n<this.height;n+=s)o.fillRect(0,n,this.width,a);break;case"vertical":for(let n=s-1;n<this.width;n+=s)o.fillRect(n,0,a,this.height);break;case"grid":for(let n=s-1;n<this.height;n+=s)o.fillRect(0,n,this.width,a);for(let n=s-1;n<this.width;n+=s)o.fillRect(n,0,a,this.height);break}}hashConfig(t){return t?JSON.stringify(t):"null"}};v(X,"PostProcessOverlay");var V=X;var q="\x1B[0m",st="\x1B[H",lt="\x1B[2J",rt="\x1B[?25l",ht="\x1B[?25h",ct=`
202
- `,Q=class Q{constructor(t={}){l(this,"options");l(this,"fgCache",[]);l(this,"bgCache",[]);l(this,"lastPalette",null);this.options={optimizeColors:t.optimizeColors??!0,includeHome:t.includeHome??!0,hideCursor:t.hideCursor??!0,includeNewlines:t.includeNewlines??!0,includeReset:t.includeReset??!0}}buildColorCache(t){if(this.lastPalette!==t){this.fgCache=new Array(t.length),this.bgCache=new Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];this.fgCache[e]=`\x1B[38;2;${i.r};${i.g};${i.b}m`,this.bgCache[e]=`\x1B[48;2;${i.r};${i.g};${i.b}m`}this.lastPalette=t}}render(t){let{width:e,height:i,cells:s,palette:a}=t;this.buildColorCache(a);let r="";this.options.hideCursor&&(r+=rt),this.options.includeHome&&(r+=st);let o=-1,n=-1,h=this.options.optimizeColors,c=this.options.includeNewlines;for(let d=0;d<i;d++){let f=d*e;for(let m=0;m<e;m++){let g=s[f+m],u=g.fgColorIndex,p=g.bgColorIndex;h?(p!==n&&(r+=this.bgCache[p],n=p),u!==o&&(r+=this.fgCache[u],o=u)):(r+=this.bgCache[p],r+=this.fgCache[u]),r+=g.char||" "}c&&d<i-1&&(r+=ct)}return this.options.includeReset&&(r+=q),r}renderRow(t,e){let{width:i,cells:s,palette:a}=t;this.buildColorCache(a);let r=`\x1B[${e+1};1H`,o=-1,n=-1,h=this.options.optimizeColors,c=e*i;for(let d=0;d<i;d++){let f=s[c+d],m=f.fgColorIndex,g=f.bgColorIndex;h?(g!==n&&(r+=this.bgCache[g],n=g),m!==o&&(r+=this.fgCache[m],o=m)):(r+=this.bgCache[g],r+=this.fgCache[m]),r+=f.char||" "}return this.options.includeReset&&(r+=q),r}clear(){return lt+st}showCursor(){return ht}hideCursor(){return rt}reset(){return q}moveTo(t,e){return`\x1B[${t+1};${e+1}H`}};v(Q,"TerminalANSI");var j=Q;function dt(b){let t=b.startsWith("#")?b.slice(1):b,e=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,i=parseInt(e,16);return{r:i>>16&255,g:i>>8&255,b:i&255,a:255}}v(dt,"hexToRGB");function ft(b){let t=b.r.toString(16).padStart(2,"0"),e=b.g.toString(16).padStart(2,"0"),i=b.b.toString(16).padStart(2,"0");return`#${t}${e}${i}`}v(ft,"rgbToHex");function ut(b,t){let e=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;e.length<256;)e.push({r:128,g:128,b:128,a:255});let i=[];for(let s=0;s<t;s++)for(let a=0;a<b;a++)i.push({char:String.fromCharCode(65+(a+s)%26),fgColorIndex:15,bgColorIndex:(a+s)%16,fgEmission:0,bgEmission:0});return{width:b,height:t,cells:i,palette:e}}v(ut,"createTestRenderState");var Yt="0.1.0";export{N as AutoplayOverlay,F as BitmapFontAtlas,G as DEFAULT_PALETTE,A as GridOverlay,U as ImageFontAtlas,V as PostProcessOverlay,R as ScalingMode,k as Terminal2D,j as TerminalANSI,P as TerminalGL,ot as colorToPaletteIndex,ut as createTestRenderState,M as getAtlasColumns,B as getCharGridPosition,S as getMaxCharCode,dt as hexToRGB,nt as paletteIndexToColor,ft as rgbToHex,Yt as version};
202
+ `,Q=class Q{constructor(t={}){l(this,"options");l(this,"fgCache",[]);l(this,"bgCache",[]);l(this,"lastPalette",null);this.options={optimizeColors:t.optimizeColors??!0,includeHome:t.includeHome??!0,hideCursor:t.hideCursor??!0,includeNewlines:t.includeNewlines??!0,includeReset:t.includeReset??!0}}buildColorCache(t){if(this.lastPalette!==t){this.fgCache=new Array(t.length),this.bgCache=new Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];this.fgCache[e]=`\x1B[38;2;${i.r};${i.g};${i.b}m`,this.bgCache[e]=`\x1B[48;2;${i.r};${i.g};${i.b}m`}this.lastPalette=t}}render(t){let{width:e,height:i,cells:s,palette:a}=t;this.buildColorCache(a);let r="";this.options.hideCursor&&(r+=rt),this.options.includeHome&&(r+=st);let o=-1,n=-1,h=this.options.optimizeColors,c=this.options.includeNewlines;for(let d=0;d<i;d++){let f=d*e;for(let m=0;m<e;m++){let g=s[f+m],u=g.fgColorIndex,p=g.bgColorIndex;h?(p!==n&&(r+=this.bgCache[p],n=p),u!==o&&(r+=this.fgCache[u],o=u)):(r+=this.bgCache[p],r+=this.fgCache[u]),r+=g.char||" "}c&&d<i-1&&(r+=ct)}return this.options.includeReset&&(r+=q),r}renderRow(t,e){let{width:i,cells:s,palette:a}=t;this.buildColorCache(a);let r=`\x1B[${e+1};1H`,o=-1,n=-1,h=this.options.optimizeColors,c=e*i;for(let d=0;d<i;d++){let f=s[c+d],m=f.fgColorIndex,g=f.bgColorIndex;h?(g!==n&&(r+=this.bgCache[g],n=g),m!==o&&(r+=this.fgCache[m],o=m)):(r+=this.bgCache[g],r+=this.fgCache[m]),r+=f.char||" "}return this.options.includeReset&&(r+=q),r}clear(){return lt+st}showCursor(){return ht}hideCursor(){return rt}reset(){return q}moveTo(t,e){return`\x1B[${t+1};${e+1}H`}};v(Q,"TerminalANSI");var j=Q;function dt(b){let t=b.startsWith("#")?b.slice(1):b,e=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,i=parseInt(e,16);return{r:i>>16&255,g:i>>8&255,b:i&255,a:255}}v(dt,"hexToRGB");function ft(b){let t=b.r.toString(16).padStart(2,"0"),e=b.g.toString(16).padStart(2,"0"),i=b.b.toString(16).padStart(2,"0");return`#${t}${e}${i}`}v(ft,"rgbToHex");function ut(b,t){let e=[{r:0,g:0,b:0,a:255},{r:128,g:0,b:0,a:255},{r:0,g:128,b:0,a:255},{r:128,g:128,b:0,a:255},{r:0,g:0,b:128,a:255},{r:128,g:0,b:128,a:255},{r:0,g:128,b:128,a:255},{r:192,g:192,b:192,a:255},{r:128,g:128,b:128,a:255},{r:255,g:0,b:0,a:255},{r:0,g:255,b:0,a:255},{r:255,g:255,b:0,a:255},{r:0,g:0,b:255,a:255},{r:255,g:0,b:255,a:255},{r:0,g:255,b:255,a:255},{r:255,g:255,b:255,a:255}];for(;e.length<256;)e.push({r:128,g:128,b:128,a:255});let i=[];for(let s=0;s<t;s++)for(let a=0;a<b;a++)i.push({char:String.fromCharCode(65+(a+s)%26),fgColorIndex:15,bgColorIndex:(a+s)%16,fgEmission:0,bgEmission:0});return{id:0,width:b,height:t,cells:i,palette:e}}v(ut,"createTestRenderState");var Yt="0.1.0";export{N as AutoplayOverlay,F as BitmapFontAtlas,G as DEFAULT_PALETTE,A as GridOverlay,U as ImageFontAtlas,V as PostProcessOverlay,R as ScalingMode,k as Terminal2D,j as TerminalANSI,P as TerminalGL,ot as colorToPaletteIndex,ut as createTestRenderState,M as getAtlasColumns,B as getCharGridPosition,S as getMaxCharCode,dt as hexToRGB,nt as paletteIndexToColor,ft as rgbToHex,Yt as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utsp/render",
3
- "version": "0.15.0-nightly.20251227200128.cdc09ed",
3
+ "version": "0.15.0",
4
4
  "description": "UTSP Render - Rendering engine for terminal graphics with WebGL, Canvas 2D, and ANSI terminal support",
5
5
  "author": "THP Software",
6
6
  "license": "MIT",
@@ -86,7 +86,7 @@
86
86
  "access": "public"
87
87
  },
88
88
  "dependencies": {
89
- "@utsp/types": "0.15.0-nightly.20251227200128.cdc09ed"
89
+ "@utsp/types": "0.15.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "typescript": "^5.6.3"