textmode.figlet.js 1.0.1-beta.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textmode.figlet.esm.js +1 -1
- package/dist/textmode.figlet.umd.js +1 -1
- package/dist/types/augmentations/textmode.d.ts +26 -0
- package/dist/types/augmentations/textmode.d.ts.map +1 -1
- package/dist/types/figfont/TextmodeFigFont.d.ts +28 -0
- package/dist/types/figfont/TextmodeFigFont.d.ts.map +1 -1
- package/dist/types/figfont/types.d.ts +169 -29
- package/dist/types/figfont/types.d.ts.map +1 -1
- package/dist/types/plugin/FigletPlugin.d.ts +2 -0
- package/dist/types/plugin/FigletPlugin.d.ts.map +1 -1
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty,e=(e,n,r)=>((e,n,r)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r)(e,"symbol"!=typeof n?n+"":n,r);import{color as n}from"textmode.js";class r extends Error{constructor(t,e){super(r.formatMessage(t,e)),this.name="FigletError"}static formatMessage(t,e){if(!e||0===Object.keys(e).length)return t;return`${t}\n\nContext:${Object.entries(e).map(([t,e])=>`\n - ${t}: ${r.formatValue(e)}`).join("")}`}static formatValue(t){return null===t?"null":void 0===t?"undefined":"string"==typeof t?`"${t}"`:"number"==typeof t||"boolean"==typeof t?t+"":Array.isArray(t)?`[${t.map(t=>r.formatValue(t)).join(", ")}]`:"object"==typeof t?JSON.stringify(t):t+""}}const i=[...Array.from({length:95},(t,e)=>e+32),196,214,220,228,246,252,223];class s{static t(t){if(0===t.length)throw new r("Cannot parse an empty FIGfont file.");const e=t.replace(/\r\n?/g,"\n").split("\n"),n=e[0];if(!n)throw new r("Missing FIGfont header line.");const i=this.i(n);let s=1+i.commentLines;if(s>e.length)throw new r("FIGfont comment line count exceeds file length.",{commentLines:i.commentLines,totalLines:e.length});const o=new Map;return s=this.o(e,s,i,o),this.l(e,s,i,o),{header:i,characters:o}}static i(t){const e=t.trim().split(/\s+/),n=e[0]??"";if(n.length<6)throw new r("Invalid FIGfont header token.",{headerToken:n});const i=n.slice(0,5),s=n.slice(5);if("flf2a"!==i)throw new r("Unsupported FIGfont signature.",{signature:i});if(1!==s.length)throw new r("FIGfont hardblank must be a single character.",{hardblank:s});if(e.length<6)throw new r("Incomplete FIGfont header.",{headerLine:t});return{signature:i,hardblank:s,height:this.u(e[1],"height"),baseline:this.u(e[2],"baseline"),maxLength:this.u(e[3],"maxLength"),oldLayout:this.u(e[4],"oldLayout"),commentLines:this.u(e[5],"commentLines"),printDirection:this.u(e[6]??"0","printDirection"),fullLayout:this.u(e[7]??"0","fullLayout"),codetagCount:this.u(e[8]??"0","codetagCount")}}static o(t,e,n,r){let s=e;for(const e of i){const i=this.h(t,s,n.height,e);r.set(e,i),s+=n.height}return s}static l(t,e,n,r){var i;let s=e;for(;s<t.length;){const e=(null==(i=t[s])?void 0:i.trim())??"";if(0===e.length){s+=1;continue}const o=this._(e);s+=1;const a=this.h(t,s,n.height,o);r.set(o,a),s+=n.height}}static h(t,e,n,i){if(e+n>t.length)throw new r("Unexpected end of FIGfont character data.",{codePoint:i,startIndex:e,height:n,totalLines:t.length});const s=[];let o=0;for(let a=0;a<n;a+=1){const n=t[e+a]??"";if(0===n.length)throw new r("Encountered an empty FIGcharacter row.",{codePoint:i,row:a,startIndex:e});const l=n.at(-1);if(!l)throw new r("Failed to determine FIGcharacter endmark.",{codePoint:i,row:a});const c=n.replace(RegExp(this.escapeForRegExp(l)+"+$"),"");s.push(c),o=Math.max(o,c.length)}return{code:i,lines:s,width:o}}static _(t){const e=t.split(/\s+/,1)[0];if(/^[-+]?0x[0-9a-f]+$/i.test(e))return Number.parseInt(e,16);if(/^[-+]?0[0-7]+$/.test(e))return Number.parseInt(e,8);if(/^[-+]?\d+$/.test(e))return Number.parseInt(e,10);throw new r("Invalid FIGfont code tag.",{codetagLine:t})}static u(t,e){if(!/^-?\d+$/.test(t))throw new r("Invalid FIGfont header value.",{field:e,token:t});return Number.parseInt(t,10)}static escapeForRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class o{static p(t){return 0!==t.fullLayout?63&t.fullLayout:t.oldLayout>0?63&t.oldLayout:0}static m(t){return 7936&t.fullLayout}static I(t,e,n,r){return" "===t?e:" "===e?t:0===r?this.v(t,e,n):(0!==(r&this.RULE_EQUAL_CHARACTER)?this.L(t,e,n):null)??(0!==(r&this.RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(r&this.RULE_HIERARCHY)?this.R(t,e):null)??(0!==(r&this.RULE_OPPOSITE_PAIR)?this.F(t,e):null)??(0!==(r&this.RULE_BIG_X)?this.A(t,e):null)??(0!==(r&this.RULE_HARDBLANK)?this.T(t,e,n):null)}static v(t,e,n){return" "===t?e:" "===e?t:e}static U(t,e,n){return" "===t?e:" "===e?t:0===n?this.v(t,e," "):(0!==(n&this.VERTICAL_RULE_EQUAL_CHARACTER)?this.L(t,e," "):null)??(0!==(n&this.VERTICAL_RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(n&this.VERTICAL_RULE_HIERARCHY)?this.R(t,e):null)??(0!==(n&this.VERTICAL_RULE_HORIZONTAL_LINE)?this.H(t,e):null)??(0!==(n&this.VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH)?this.S(t,e):null)}static L(t,e,n){return t===e&&t!==n?t:null}static C(t,e){const n="|/\\[]{}()<>";return"_"===t&&n.includes(e)?e:"_"===e&&n.includes(t)?t:null}static R(t,e){const n=["|","/\\","[]","{}","()","<>"],r=n.findIndex(e=>e.includes(t)),i=n.findIndex(t=>t.includes(e));return-1===r||-1===i||r===i?null:r>i?t:e}static F(t,e){return["[]","][","{}","}{","()",")("].includes(`${t}${e}`)?"|":null}static A(t,e){const n=`${t}${e}`;return"/\\"===n?"|":"\\/"===n?"Y":"><"===n?"X":null}static T(t,e,n){return t===n&&e===n?n:null}static H(t,e){const n=`${t}${e}`;return"-_"===n||"_-"===n?"=":null}static S(t,e){return"|"===t&&"|"===e?"|":null}}e(o,"RULE_EQUAL_CHARACTER",1),e(o,"RULE_UNDERSCORE",2),e(o,"RULE_HIERARCHY",4),e(o,"RULE_OPPOSITE_PAIR",8),e(o,"RULE_BIG_X",16),e(o,"RULE_HARDBLANK",32),e(o,"VERTICAL_RULE_EQUAL_CHARACTER",256),e(o,"VERTICAL_RULE_UNDERSCORE",512),e(o,"VERTICAL_RULE_HIERARCHY",1024),e(o,"VERTICAL_RULE_HORIZONTAL_LINE",2048),e(o,"VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH",4096);class a{constructor(t){e(this,"_header"),e(this,"_horizontalRuleMask"),e(this,"_verticalRuleMask"),this.$=t,this.k=o.p(t),this.M=o.m(t)}O(t,e){const n=t.map((t,e)=>({inputIndex:e,inputChar:String.fromCodePoint(t.code)})),r=this.G(t,n,e,0),i=Array.from({length:r.rows},()=>Array.from({length:r.cols},()=>" "));for(const t of r.cells)i[t.row][t.col]=t.char;return i}G(t,e,n,r){if(0===t.length)return{lineIndex:r,cells:[],cols:0,rows:this.$.height};let i=this.N(t[0],e[0],r),s=t[0].width;for(let a=1;a<t.length;a+=1){const l=t[a],c=e[a]??{inputIndex:a,inputChar:String.fromCodePoint(l.code)},u=s-this.P(i,s,l,n),h=Math.max(s,u+l.width),f=i.map(t=>Array.from({length:h},(e,n)=>t[n]));for(let t=0;t<this.$.height;t+=1){const e=l.lines[t]??"",n=f[t];for(let i=0;i<l.width;i+=1){const s=e[i]??" ";if(" "===s)continue;const a=u+i,h=n[a],f=this.V(a,t,i,r,l,c,s);if(!h){n[a]=f;continue}const d=o.I(h.char,s,this.$.hardblank,this.k);n[a]=this.D(h,f,d??s)}}i=f,s=h}return this.B(i,s,r)}j(t,e){var n;if(0===t.length)return{cells:[],lines:[],cols:0,rows:0};let r=this.W(t[0]),i=t[0].cols,s=t[0].rows;const a=[this.q(t[0],0)];for(let l=1;l<t.length;l+=1){const c=t[l],u=s-this.X(r,s,i,c,e),h=Math.max(i,c.cols),f=Math.max(s,u+c.rows),d=Array.from({length:f},(t,e)=>Array.from({length:h},(t,n)=>{var i;return null==(i=r[e])?void 0:i[n]}));for(const t of c.cells){const e=u+t.row,r=t.col,i=null==(n=d[e])?void 0:n[r];if(!i){d[e][r]={...t,row:e};continue}const s=o.U(i.char,t.char,this.M);d[e][r]=this.D(i,{...t,row:e},s??t.char)}r=d,i=h,s=f,a.push(this.q(c,u))}return this.Y(r,i,s,a)}P(t,e,n,r){var i;if("full"===r)return 0;for(let s=e;s>=0;s-=1){let o=!0;for(let a=0;a<this.$.height&&o;a+=1){const l=t[a]??[],c=n.lines[a]??"";for(let t=0;t<s;t+=1){const n=(null==(i=l[e-s+t])?void 0:i.char)??" ",a=c[t]??" ";if(!this.J(n,a,r)){o=!1;break}}}if(o)return s}return 0}J(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==o.I(t,e,this.$.hardblank,this.k)}N(t,e={inputIndex:0,inputChar:String.fromCodePoint(t.code)},n=0){return Array.from({length:this.$.height},(r,i)=>{const s=t.lines[i]??"";return Array.from({length:t.width},(r,o)=>{const a=s[o]??" ";return" "===a?void 0:this.V(o,i,o,n,t,e,a)})})}V(t,e,n,r,i,s,o){return{char:o,col:t,row:e,inputIndex:s.inputIndex,inputChar:s.inputChar,figCharCode:i.code,subRow:e,subCol:n,lineIndex:r}}D(t,e,n){return n===t.char?t:{...e,char:n}}B(t,e,n){const r=[];for(let i=0;i<this.$.height;i+=1){const s=t[i]??[];for(let t=0;t<e;t+=1){const e=s[t];!e||e.char===this.$.hardblank||r.push({...e,col:t,row:i,lineIndex:n})}}return{lineIndex:n,cells:r,cols:e,rows:this.$.height}}X(t,e,n,r,i){var s,o;if("full"===i)return 0;const a=this.W(r),l=Math.min(e,r.rows),c=Math.max(n,r.cols);for(let n=l;n>=0;n-=1){let r=!0;for(let l=0;l<n&&r;l+=1){const u=t[e-n+l]??[],h=a[l]??[];for(let t=0;t<c;t+=1){const e=(null==(s=u[t])?void 0:s.char)??" ",n=(null==(o=h[t])?void 0:o.char)??" ";if(!this.K(e,n,i)){r=!1;break}}}if(r)return n}return 0}K(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==o.U(t,e,this.M)}W(t){const e=Array.from({length:t.rows},()=>Array.from({length:t.cols},()=>{}));for(const n of t.cells)e[n.row][n.col]=n;return e}q(t,e){return{...t,cells:t.cells.map(t=>({...t,row:t.row+e}))}}Y(t,e,n,r){var i;const s=[];for(let r=0;r<n;r+=1)for(let n=0;n<e;n+=1){const e=null==(i=t[r])?void 0:i[n];e&&s.push({...e,row:r,col:n})}return{cells:s,lines:r,cols:e,rows:n}}}class l{constructor(){e(this,"_onDisposeCallbacks",new Set)}Z(t){this.tt.add(t)}dispose(){for(const t of this.tt)t();this.tt.clear()}}class c extends l{constructor(t,n,r){super(),e(this,"_name"),e(this,"_header"),e(this,"_characters"),e(this,"_layoutEngine"),this.et=t,this.$=n,this.nt=r,this.rt=new a(n)}static async it(t){const e=await fetch(t);if(!e.ok)throw new r("Failed to load FIGfont file.",{source:t+"",status:e.status,statusText:e.statusText});const n=await e.text();return this.st(this.ot(t),n)}static st(t,e){const n=s.t(e);return new c(t,n.header,n.characters)}getCharacter(t){var e;const n="number"==typeof t?t:null==(e=Array.from(t)[0])?void 0:e.codePointAt(0);if(void 0!==n)return u(this.nt.get(n))}planText(t,e={}){const n=e.horizontalLayout??this.defaultLayout,r=e.verticalLayout??this.defaultVerticalLayout,i=this.lt(e.direction),s=this.ct(t).map(t=>this.ut(t,i)).flatMap(t=>this.ht(t,n,e)).map((t,e)=>{const r=this.ft(t);return this.rt.G(r.map(t=>t.figChar),r.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),n,e)}),o=this.rt.j(s,r);return{cells:o.cells,lines:o.lines,cols:o.cols,rows:o.rows,direction:i}}renderText(t,e={}){const n=this.planText(t,e),r=Array.from({length:n.rows},()=>Array.from({length:n.cols},()=>" "));for(const t of n.cells)r[t.row][t.col]=t.char;return{grid:r,cols:n.cols,rows:n.rows}}measureText(t,e={}){const n=this.planText(t,e);return{cols:n.cols,rows:n.rows}}get name(){return this.et}get header(){return{...this.$}}get characters(){return new Map(Array.from(this.nt,([t,e])=>[t,u(e)]))}get hardblank(){return this.$.hardblank}get height(){return this.$.height}get baseline(){return this.$.baseline}get defaultLayout(){return 128&this.$.fullLayout?"smushed":64&this.$.fullLayout?"fitted":-1===this.$.oldLayout?"full":0===this.$.oldLayout?"fitted":this.$.oldLayout>0?"smushed":"full"}get defaultPrintDirection(){return 1===this.$.printDirection?"rtl":"ltr"}get defaultVerticalLayout(){return 16384&this.$.fullLayout?"smushed":8192&this.$.fullLayout?"fitted":"full"}static ot(t){const e=t instanceof URL?t.pathname:t,n=(e.split(/[?#]/,1)[0]??e).split("/").filter(Boolean).pop()??"figfont";return n.toLowerCase().endsWith(".flf")?n.slice(0,-4)||"figfont":n}ct(t){const e=[[]];for(const[n,r]of Array.from(t).entries())"\n"!==r?e[e.length-1].push({character:r,inputIndex:n}):e.push([]);return e}ut(t,e){return"rtl"===e?[...t].reverse():t}ft(t){const e=t.map(({character:t,inputIndex:e})=>({figChar:this.getCharacter(t)??this.getCharacter(32),inputChar:t,inputIndex:e})),n=e.find(t=>void 0===t.figChar);if(n)throw new r("FIGfont is missing a required character for layout.",{character:n.inputChar,index:n.inputIndex});return e}ht(t,e,n){const r="number"==typeof n.maxCols&&Number.isFinite(n.maxCols)?Math.floor(n.maxCols):void 0,i=n.wrap??"none";return 0===t.length||!r||r<1||"none"===i?[t]:"char"===i?this.dt(t,e,r):this.gt(t,e,r)}gt(t,e,n){const r=this._t(t);if(!r.some(t=>!t.isWhitespace))return[t];const i=[];let s=[],o=[];for(const t of r){if(t.isWhitespace){s.length>0&&(o=t.characters);continue}const r=0===s.length?t.characters:s.concat(o,t.characters);s.length>0&&this.wt(r,e)>n?(i.push(s),s=t.characters.slice()):s=r,o=[]}return 0===s.length?[[]]:(i.push(s),i)}dt(t,e,n){const r=[];let i=[];for(const s of t){const t=i.concat(s);i.length>0&&this.wt(t,e)>n?(r.push(i),i=[s]):i=t}return 0===i.length?[[]]:(r.push(i),r)}wt(t,e){const n=this.ft(t);return this.rt.G(n.map(t=>t.figChar),n.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),e,0).cols}_t(t){const e=[];for(const n of t){const t=/\s/u.test(n.character),r=e[e.length-1];r&&r.isWhitespace===t?r.characters.push(n):e.push({isWhitespace:t,characters:[n]})}return e}lt(t){return"ltr"===t||"rtl"===t?t:this.defaultPrintDirection}}function u(t){if(t)return{...t,lines:[...t.lines]}}const h="textmode.figlet.js",f="1.0.1-beta.1",d=Symbol.for("textmode.figlet.state");function g(t){const e=t;return e[d]||(e[d]={activeFont:void 0,align:"left",baseline:"baseline"}),e[d]}const _=["loadFigFont","parseFigFont","figFont","figText","figTextWidth","figTextHeight","figTextBounds","figTextAlign","figTextBaseline"];function p(t,e){if(void 0!==t)return"function"==typeof t?t(e):t}function w(t,e,r){return r instanceof n.TextmodeColor||"string"==typeof r||"number"==typeof r?"charColor"===e?void t.charColor(r):void t.cellColor(r):4===r.length?"charColor"===e?void t.charColor(r[0],r[1],r[2],r[3]):void t.cellColor(r[0],r[1],r[2],r[3]):void("charColor"!==e?t.cellColor(r[0],r[1],r[2]):t.charColor(r[0],r[1],r[2]))}function m(t){const e=g(t).activeFont;if(!e)throw new r("No FIGlet font is active. Call figFont() first.");return e}function I(t,e){var n;null==(n=t.It)||n.call(t,e)}function v(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0,enumerable:!1})}function L(t){v(t,"loadFigFont",async function(t){const e=await c.it(t);return I(this,e),e}),v(t,"parseFigFont",function(t,e){const n=c.st(t,e);return I(this,n),n}),v(t,"figFont",function(t){const e=g(this);if(void 0===t)return e.activeFont;e.activeFont=t}),v(t,"figText",function(t,e,n,r={}){const i=m(this),s=i.planText(t,r),o=g(this),a=e+function(t,e){return"center"===e?-Math.floor(t/2):"right"===e?-(t-1):0}(s.cols,o.align),l=n+function(t,e,n){return"top"===n?0:"center"===n?-Math.floor(t/2):"bottom"===n?-(t-1):-(e-1)}(s.rows,i.baseline,o.baseline);this.push(),this.translate(a,l,0);for(const t of s.cells){this.push(),this.translate(t.col,t.row,0);const e=p(r.charColor,t),n=p(r.cellColor,t);this.char(t.char),void 0!==e&&w(this,"charColor",e),void 0!==n&&w(this,"cellColor",n),this.point(),this.pop()}this.pop()}),v(t,"figTextWidth",function(t,e={}){return m(this).measureText(t,e).cols}),v(t,"figTextHeight",function(t,e={}){return m(this).measureText(t,e).rows}),v(t,"figTextBounds",function(t,e={}){return m(this).measureText(t,e)}),v(t,"figTextAlign",function(t){const e=g(this);if(void 0===t)return e.align;e.align=t}),v(t,"figTextBaseline",function(t){const e=g(this);if(void 0===t)return e.baseline;e.baseline=t})}function y(t){for(const e of _)delete t[e];!function(t){delete t[d]}(t)}const C={name:h,version:f,install(t,e){L(t)},uninstall(t,e){y(t)}};if(typeof window<"u"){const t=window;t.FigletPlugin=C,t.TextmodeFigFont=c,t.FigFontParser=s,t.FigLayoutEngine=a,t.FigSmushRules=o,t.FIGFONT_REQUIRED_CODEPOINTS=i}export{i as FIGFONT_REQUIRED_CODEPOINTS,s as FigFontParser,a as FigLayoutEngine,o as FigSmushRules,C as FigletPlugin,c as TextmodeFigFont};
|
|
1
|
+
var t=Object.defineProperty,e=(e,n,r)=>((e,n,r)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r)(e,"symbol"!=typeof n?n+"":n,r);import{color as n}from"textmode.js";class r extends Error{constructor(t,e){super(r.formatMessage(t,e)),this.name="FigletError"}static formatMessage(t,e){if(!e||0===Object.keys(e).length)return t;return`${t}\n\nContext:${Object.entries(e).map(([t,e])=>`\n - ${t}: ${r.formatValue(e)}`).join("")}`}static formatValue(t){return null===t?"null":void 0===t?"undefined":"string"==typeof t?`"${t}"`:"number"==typeof t||"boolean"==typeof t?t+"":Array.isArray(t)?`[${t.map(t=>r.formatValue(t)).join(", ")}]`:"object"==typeof t?JSON.stringify(t):t+""}}const i=[...Array.from({length:95},(t,e)=>e+32),196,214,220,228,246,252,223];class s{static t(t){if(0===t.length)throw new r("Cannot parse an empty FIGfont file.");const e=t.replace(/\r\n?/g,"\n").split("\n"),n=e[0];if(!n)throw new r("Missing FIGfont header line.");const i=this.i(n);let s=1+i.commentLines;if(s>e.length)throw new r("FIGfont comment line count exceeds file length.",{commentLines:i.commentLines,totalLines:e.length});const o=new Map;return s=this.o(e,s,i,o),this.l(e,s,i,o),{header:i,characters:o}}static i(t){const e=t.trim().split(/\s+/),n=e[0]??"";if(n.length<6)throw new r("Invalid FIGfont header token.",{headerToken:n});const i=n.slice(0,5),s=n.slice(5);if("flf2a"!==i)throw new r("Unsupported FIGfont signature.",{signature:i});if(1!==s.length)throw new r("FIGfont hardblank must be a single character.",{hardblank:s});if(e.length<6)throw new r("Incomplete FIGfont header.",{headerLine:t});return{signature:i,hardblank:s,height:this.u(e[1],"height"),baseline:this.u(e[2],"baseline"),maxLength:this.u(e[3],"maxLength"),oldLayout:this.u(e[4],"oldLayout"),commentLines:this.u(e[5],"commentLines"),printDirection:this.u(e[6]??"0","printDirection"),fullLayout:this.u(e[7]??"0","fullLayout"),codetagCount:this.u(e[8]??"0","codetagCount")}}static o(t,e,n,r){let s=e;for(const e of i){const i=this.h(t,s,n.height,e);r.set(e,i),s+=n.height}return s}static l(t,e,n,r){var i;let s=e;for(;s<t.length;){const e=(null==(i=t[s])?void 0:i.trim())??"";if(0===e.length){s+=1;continue}const o=this._(e);s+=1;const a=this.h(t,s,n.height,o);r.set(o,a),s+=n.height}}static h(t,e,n,i){if(e+n>t.length)throw new r("Unexpected end of FIGfont character data.",{codePoint:i,startIndex:e,height:n,totalLines:t.length});const s=[];let o=0;for(let a=0;a<n;a+=1){const n=t[e+a]??"";if(0===n.length)throw new r("Encountered an empty FIGcharacter row.",{codePoint:i,row:a,startIndex:e});const l=n.at(-1);if(!l)throw new r("Failed to determine FIGcharacter endmark.",{codePoint:i,row:a});const c=n.replace(RegExp(this.escapeForRegExp(l)+"+$"),"");s.push(c),o=Math.max(o,c.length)}return{code:i,lines:s,width:o}}static _(t){const e=t.split(/\s+/,1)[0];if(/^[-+]?0x[0-9a-f]+$/i.test(e))return Number.parseInt(e,16);if(/^[-+]?0[0-7]+$/.test(e))return Number.parseInt(e,8);if(/^[-+]?\d+$/.test(e))return Number.parseInt(e,10);throw new r("Invalid FIGfont code tag.",{codetagLine:t})}static u(t,e){if(!/^-?\d+$/.test(t))throw new r("Invalid FIGfont header value.",{field:e,token:t});return Number.parseInt(t,10)}static escapeForRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class o{static p(t){return 0!==t.fullLayout?63&t.fullLayout:t.oldLayout>0?63&t.oldLayout:0}static m(t){return 7936&t.fullLayout}static I(t,e,n,r){return" "===t?e:" "===e?t:0===r?this.v(t,e,n):(0!==(r&this.RULE_EQUAL_CHARACTER)?this.L(t,e,n):null)??(0!==(r&this.RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(r&this.RULE_HIERARCHY)?this.R(t,e):null)??(0!==(r&this.RULE_OPPOSITE_PAIR)?this.F(t,e):null)??(0!==(r&this.RULE_BIG_X)?this.A(t,e):null)??(0!==(r&this.RULE_HARDBLANK)?this.T(t,e,n):null)}static v(t,e,n){return" "===t?e:" "===e?t:e}static U(t,e,n){return" "===t?e:" "===e?t:0===n?this.v(t,e," "):(0!==(n&this.VERTICAL_RULE_EQUAL_CHARACTER)?this.L(t,e," "):null)??(0!==(n&this.VERTICAL_RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(n&this.VERTICAL_RULE_HIERARCHY)?this.R(t,e):null)??(0!==(n&this.VERTICAL_RULE_HORIZONTAL_LINE)?this.H(t,e):null)??(0!==(n&this.VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH)?this.S(t,e):null)}static L(t,e,n){return t===e&&t!==n?t:null}static C(t,e){const n="|/\\[]{}()<>";return"_"===t&&n.includes(e)?e:"_"===e&&n.includes(t)?t:null}static R(t,e){const n=["|","/\\","[]","{}","()","<>"],r=n.findIndex(e=>e.includes(t)),i=n.findIndex(t=>t.includes(e));return-1===r||-1===i||r===i?null:r>i?t:e}static F(t,e){return["[]","][","{}","}{","()",")("].includes(`${t}${e}`)?"|":null}static A(t,e){const n=`${t}${e}`;return"/\\"===n?"|":"\\/"===n?"Y":"><"===n?"X":null}static T(t,e,n){return t===n&&e===n?n:null}static H(t,e){const n=`${t}${e}`;return"-_"===n||"_-"===n?"=":null}static S(t,e){return"|"===t&&"|"===e?"|":null}}e(o,"RULE_EQUAL_CHARACTER",1),e(o,"RULE_UNDERSCORE",2),e(o,"RULE_HIERARCHY",4),e(o,"RULE_OPPOSITE_PAIR",8),e(o,"RULE_BIG_X",16),e(o,"RULE_HARDBLANK",32),e(o,"VERTICAL_RULE_EQUAL_CHARACTER",256),e(o,"VERTICAL_RULE_UNDERSCORE",512),e(o,"VERTICAL_RULE_HIERARCHY",1024),e(o,"VERTICAL_RULE_HORIZONTAL_LINE",2048),e(o,"VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH",4096);class a{constructor(t){e(this,"_header"),e(this,"_horizontalRuleMask"),e(this,"_verticalRuleMask"),this.$=t,this.k=o.p(t),this.M=o.m(t)}O(t,e){const n=t.map((t,e)=>({inputIndex:e,inputChar:String.fromCodePoint(t.code)})),r=this.G(t,n,e,0),i=Array.from({length:r.rows},()=>Array.from({length:r.cols},()=>" "));for(const t of r.cells)i[t.row][t.col]=t.char;return i}G(t,e,n,r){if(0===t.length)return{lineIndex:r,cells:[],cols:0,rows:this.$.height};let i=this.N(t[0],e[0],r),s=t[0].width;for(let a=1;a<t.length;a+=1){const l=t[a],c=e[a]??{inputIndex:a,inputChar:String.fromCodePoint(l.code)},u=s-this.P(i,s,l,n),h=Math.max(s,u+l.width),f=i.map(t=>Array.from({length:h},(e,n)=>t[n]));for(let t=0;t<this.$.height;t+=1){const e=l.lines[t]??"",n=f[t];for(let i=0;i<l.width;i+=1){const s=e[i]??" ";if(" "===s)continue;const a=u+i,h=n[a],f=this.V(a,t,i,r,l,c,s);if(!h){n[a]=f;continue}const d=o.I(h.char,s,this.$.hardblank,this.k);n[a]=this.D(h,f,d??s)}}i=f,s=h}return this.B(i,s,r)}j(t,e){var n;if(0===t.length)return{cells:[],lines:[],cols:0,rows:0};let r=this.W(t[0]),i=t[0].cols,s=t[0].rows;const a=[this.q(t[0],0)];for(let l=1;l<t.length;l+=1){const c=t[l],u=s-this.X(r,s,i,c,e),h=Math.max(i,c.cols),f=Math.max(s,u+c.rows),d=Array.from({length:f},(t,e)=>Array.from({length:h},(t,n)=>{var i;return null==(i=r[e])?void 0:i[n]}));for(const t of c.cells){const e=u+t.row,r=t.col,i=null==(n=d[e])?void 0:n[r];if(!i){d[e][r]={...t,row:e};continue}const s=o.U(i.char,t.char,this.M);d[e][r]=this.D(i,{...t,row:e},s??t.char)}r=d,i=h,s=f,a.push(this.q(c,u))}return this.Y(r,i,s,a)}P(t,e,n,r){var i;if("full"===r)return 0;for(let s=e;s>=0;s-=1){let o=!0;for(let a=0;a<this.$.height&&o;a+=1){const l=t[a]??[],c=n.lines[a]??"";for(let t=0;t<s;t+=1){const n=(null==(i=l[e-s+t])?void 0:i.char)??" ",a=c[t]??" ";if(!this.J(n,a,r)){o=!1;break}}}if(o)return s}return 0}J(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==o.I(t,e,this.$.hardblank,this.k)}N(t,e={inputIndex:0,inputChar:String.fromCodePoint(t.code)},n=0){return Array.from({length:this.$.height},(r,i)=>{const s=t.lines[i]??"";return Array.from({length:t.width},(r,o)=>{const a=s[o]??" ";return" "===a?void 0:this.V(o,i,o,n,t,e,a)})})}V(t,e,n,r,i,s,o){return{char:o,col:t,row:e,inputIndex:s.inputIndex,inputChar:s.inputChar,figCharCode:i.code,subRow:e,subCol:n,lineIndex:r}}D(t,e,n){return n===t.char?t:{...e,char:n}}B(t,e,n){const r=[];for(let i=0;i<this.$.height;i+=1){const s=t[i]??[];for(let t=0;t<e;t+=1){const e=s[t];!e||e.char===this.$.hardblank||r.push({...e,col:t,row:i,lineIndex:n})}}return{lineIndex:n,cells:r,cols:e,rows:this.$.height}}X(t,e,n,r,i){var s,o;if("full"===i)return 0;const a=this.W(r),l=Math.min(e,r.rows),c=Math.max(n,r.cols);for(let n=l;n>=0;n-=1){let r=!0;for(let l=0;l<n&&r;l+=1){const u=t[e-n+l]??[],h=a[l]??[];for(let t=0;t<c;t+=1){const e=(null==(s=u[t])?void 0:s.char)??" ",n=(null==(o=h[t])?void 0:o.char)??" ";if(!this.K(e,n,i)){r=!1;break}}}if(r)return n}return 0}K(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==o.U(t,e,this.M)}W(t){const e=Array.from({length:t.rows},()=>Array.from({length:t.cols},()=>{}));for(const n of t.cells)e[n.row][n.col]=n;return e}q(t,e){return{...t,cells:t.cells.map(t=>({...t,row:t.row+e}))}}Y(t,e,n,r){var i;const s=[];for(let r=0;r<n;r+=1)for(let n=0;n<e;n+=1){const e=null==(i=t[r])?void 0:i[n];e&&s.push({...e,row:r,col:n})}return{cells:s,lines:r,cols:e,rows:n}}}class l{constructor(){e(this,"_onDisposeCallbacks",new Set)}Z(t){this.tt.add(t)}dispose(){for(const t of this.tt)t();this.tt.clear()}}class c extends l{constructor(t,n,r){super(),e(this,"_name"),e(this,"_header"),e(this,"_characters"),e(this,"_layoutEngine"),this.et=t,this.$=n,this.nt=r,this.rt=new a(n)}static async it(t){const e=await fetch(t);if(!e.ok)throw new r("Failed to load FIGfont file.",{source:t+"",status:e.status,statusText:e.statusText});const n=await e.text();return this.st(this.ot(t),n)}static st(t,e){const n=s.t(e);return new c(t,n.header,n.characters)}getCharacter(t){var e;const n="number"==typeof t?t:null==(e=Array.from(t)[0])?void 0:e.codePointAt(0);if(void 0!==n)return u(this.nt.get(n))}planText(t,e={}){const n=e.horizontalLayout??this.defaultLayout,r=e.verticalLayout??this.defaultVerticalLayout,i=this.lt(e.direction),s=this.ct(t).map(t=>this.ut(t,i)).flatMap(t=>this.ht(t,n,e)).map((t,e)=>{const r=this.ft(t);return this.rt.G(r.map(t=>t.figChar),r.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),n,e)}),o=this.rt.j(s,r);return{cells:o.cells,lines:o.lines,cols:o.cols,rows:o.rows,direction:i}}renderText(t,e={}){const n=this.planText(t,e),r=Array.from({length:n.rows},()=>Array.from({length:n.cols},()=>" "));for(const t of n.cells)r[t.row][t.col]=t.char;return{grid:r,cols:n.cols,rows:n.rows}}measureText(t,e={}){const n=this.planText(t,e);return{cols:n.cols,rows:n.rows}}get name(){return this.et}get header(){return{...this.$}}get characters(){return new Map(Array.from(this.nt,([t,e])=>[t,u(e)]))}get hardblank(){return this.$.hardblank}get height(){return this.$.height}get baseline(){return this.$.baseline}get defaultLayout(){return 128&this.$.fullLayout?"smushed":64&this.$.fullLayout?"fitted":-1===this.$.oldLayout?"full":0===this.$.oldLayout?"fitted":this.$.oldLayout>0?"smushed":"full"}get defaultPrintDirection(){return 1===this.$.printDirection?"rtl":"ltr"}get defaultVerticalLayout(){return 16384&this.$.fullLayout?"smushed":8192&this.$.fullLayout?"fitted":"full"}static ot(t){const e=t instanceof URL?t.pathname:t,n=(e.split(/[?#]/,1)[0]??e).split("/").filter(Boolean).pop()??"figfont";return n.toLowerCase().endsWith(".flf")?n.slice(0,-4)||"figfont":n}ct(t){const e=[[]];for(const[n,r]of Array.from(t).entries())"\n"!==r?e[e.length-1].push({character:r,inputIndex:n}):e.push([]);return e}ut(t,e){return"rtl"===e?[...t].reverse():t}ft(t){const e=t.map(({character:t,inputIndex:e})=>({figChar:this.getCharacter(t)??this.getCharacter(32),inputChar:t,inputIndex:e})),n=e.find(t=>void 0===t.figChar);if(n)throw new r("FIGfont is missing a required character for layout.",{character:n.inputChar,index:n.inputIndex});return e}ht(t,e,n){const r="number"==typeof n.maxCols&&Number.isFinite(n.maxCols)?Math.floor(n.maxCols):void 0,i=n.wrap??"none";return 0===t.length||!r||r<1||"none"===i?[t]:"char"===i?this.dt(t,e,r):this.gt(t,e,r)}gt(t,e,n){const r=this._t(t);if(!r.some(t=>!t.isWhitespace))return[t];const i=[];let s=[],o=[];for(const t of r){if(t.isWhitespace){s.length>0&&(o=t.characters);continue}const r=0===s.length?t.characters:s.concat(o,t.characters);s.length>0&&this.wt(r,e)>n?(i.push(s),s=t.characters.slice()):s=r,o=[]}return 0===s.length?[[]]:(i.push(s),i)}dt(t,e,n){const r=[];let i=[];for(const s of t){const t=i.concat(s);i.length>0&&this.wt(t,e)>n?(r.push(i),i=[s]):i=t}return 0===i.length?[[]]:(r.push(i),r)}wt(t,e){const n=this.ft(t);return this.rt.G(n.map(t=>t.figChar),n.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),e,0).cols}_t(t){const e=[];for(const n of t){const t=/\s/u.test(n.character),r=e[e.length-1];r&&r.isWhitespace===t?r.characters.push(n):e.push({isWhitespace:t,characters:[n]})}return e}lt(t){return"ltr"===t||"rtl"===t?t:this.defaultPrintDirection}}function u(t){if(t)return{...t,lines:[...t.lines]}}const h="textmode.figlet.js",f="1.0.2",d=Symbol.for("textmode.figlet.state");function g(t){const e=t;return e[d]||(e[d]={activeFont:void 0,align:"left",baseline:"baseline"}),e[d]}const _=["loadFigFont","parseFigFont","figFont","figText","figTextWidth","figTextHeight","figTextBounds","figTextAlign","figTextBaseline"];function p(t,e){if(void 0!==t)return"function"==typeof t?t(e):t}function w(t,e,r){return r instanceof n.TextmodeColor||"string"==typeof r||"number"==typeof r?"charColor"===e?void t.charColor(r):void t.cellColor(r):4===r.length?"charColor"===e?void t.charColor(r[0],r[1],r[2],r[3]):void t.cellColor(r[0],r[1],r[2],r[3]):void("charColor"!==e?t.cellColor(r[0],r[1],r[2]):t.charColor(r[0],r[1],r[2]))}function m(t){const e=g(t).activeFont;if(!e)throw new r("No FIGlet font is active. Call figFont() first.");return e}function I(t,e){var n;null==(n=t.It)||n.call(t,e)}function v(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0,enumerable:!1})}function L(t){v(t,"loadFigFont",async function(t){const e=await c.it(t);return I(this,e),e}),v(t,"parseFigFont",function(t,e){const n=c.st(t,e);return I(this,n),n}),v(t,"figFont",function(t){const e=g(this);if(void 0===t)return e.activeFont;e.activeFont=t}),v(t,"figText",function(t,e,n,r={}){const i=m(this),s=i.planText(t,r),o=g(this),a=e+function(t,e){return"center"===e?-Math.floor(t/2):"right"===e?-(t-1):0}(s.cols,o.align),l=n+function(t,e,n){return"top"===n?0:"center"===n?-Math.floor(t/2):"bottom"===n?-(t-1):-(e-1)}(s.rows,i.baseline,o.baseline);this.push(),this.translate(a,l,0);for(const t of s.cells){this.push(),this.translate(t.col,t.row,0);const e=p(r.charColor,t),n=p(r.cellColor,t);this.char(t.char),void 0!==e&&w(this,"charColor",e),void 0!==n&&w(this,"cellColor",n),this.point(),this.pop()}this.pop()}),v(t,"figTextWidth",function(t,e={}){return m(this).measureText(t,e).cols}),v(t,"figTextHeight",function(t,e={}){return m(this).measureText(t,e).rows}),v(t,"figTextBounds",function(t,e={}){return m(this).measureText(t,e)}),v(t,"figTextAlign",function(t){const e=g(this);if(void 0===t)return e.align;e.align=t}),v(t,"figTextBaseline",function(t){const e=g(this);if(void 0===t)return e.baseline;e.baseline=t})}function y(t){for(const e of _)delete t[e];!function(t){delete t[d]}(t)}const C={name:h,version:f,install(t,e){L(t)},uninstall(t,e){y(t)}};if(typeof window<"u"){const t=window;t.FigletPlugin=C,t.TextmodeFigFont=c,t.FigFontParser=s,t.FigLayoutEngine=a,t.FigSmushRules=o,t.FIGFONT_REQUIRED_CODEPOINTS=i}export{i as FIGFONT_REQUIRED_CODEPOINTS,s as FigFontParser,a as FigLayoutEngine,o as FigSmushRules,C as FigletPlugin,c as TextmodeFigFont};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&typeof module<"u"?e(exports,require("textmode.js")):"function"==typeof define&&define.amd?define(["exports","textmode.js"],e):e((t=typeof globalThis<"u"?globalThis:t||self).TextmodeFiglet={},t.textmode)}(this,function(t,e){"use strict";var n=Object.defineProperty,r=(t,e,r)=>((t,e,r)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r)(t,"symbol"!=typeof e?e+"":e,r);class i extends Error{constructor(t,e){super(i.formatMessage(t,e)),this.name="FigletError"}static formatMessage(t,e){if(!e||0===Object.keys(e).length)return t;return`${t}\n\nContext:${Object.entries(e).map(([t,e])=>`\n - ${t}: ${i.formatValue(e)}`).join("")}`}static formatValue(t){return null===t?"null":void 0===t?"undefined":"string"==typeof t?`"${t}"`:"number"==typeof t||"boolean"==typeof t?String(t):Array.isArray(t)?`[${t.map(t=>i.formatValue(t)).join(", ")}]`:"object"==typeof t?JSON.stringify(t):String(t)}}const s=[...Array.from({length:95},(t,e)=>e+32),196,214,220,228,246,252,223];class o{static t(t){if(0===t.length)throw new i("Cannot parse an empty FIGfont file.");const e=t.replace(/\r\n?/g,"\n").split("\n"),n=e[0];if(!n)throw new i("Missing FIGfont header line.");const r=this.i(n);let s=1+r.commentLines;if(s>e.length)throw new i("FIGfont comment line count exceeds file length.",{commentLines:r.commentLines,totalLines:e.length});const o=new Map;return s=this.o(e,s,r,o),this.l(e,s,r,o),{header:r,characters:o}}static i(t){const e=t.trim().split(/\s+/),n=e[0]??"";if(n.length<6)throw new i("Invalid FIGfont header token.",{headerToken:n});const r=n.slice(0,5),s=n.slice(5);if("flf2a"!==r)throw new i("Unsupported FIGfont signature.",{signature:r});if(1!==s.length)throw new i("FIGfont hardblank must be a single character.",{hardblank:s});if(e.length<6)throw new i("Incomplete FIGfont header.",{headerLine:t});return{signature:r,hardblank:s,height:this.u(e[1],"height"),baseline:this.u(e[2],"baseline"),maxLength:this.u(e[3],"maxLength"),oldLayout:this.u(e[4],"oldLayout"),commentLines:this.u(e[5],"commentLines"),printDirection:this.u(e[6]??"0","printDirection"),fullLayout:this.u(e[7]??"0","fullLayout"),codetagCount:this.u(e[8]??"0","codetagCount")}}static o(t,e,n,r){let i=e;for(const e of s){const s=this.h(t,i,n.height,e);r.set(e,s),i+=n.height}return i}static l(t,e,n,r){var i;let s=e;for(;s<t.length;){const e=(null==(i=t[s])?void 0:i.trim())??"";if(0===e.length){s+=1;continue}const o=this.p(e);s+=1;const a=this.h(t,s,n.height,o);r.set(o,a),s+=n.height}}static h(t,e,n,r){if(e+n>t.length)throw new i("Unexpected end of FIGfont character data.",{codePoint:r,startIndex:e,height:n,totalLines:t.length});const s=[];let o=0;for(let a=0;a<n;a+=1){const n=t[e+a]??"";if(0===n.length)throw new i("Encountered an empty FIGcharacter row.",{codePoint:r,row:a,startIndex:e});const l=n.at(-1);if(!l)throw new i("Failed to determine FIGcharacter endmark.",{codePoint:r,row:a});const c=n.replace(new RegExp(`${this.escapeForRegExp(l)}+$`),"");s.push(c),o=Math.max(o,c.length)}return{code:r,lines:s,width:o}}static p(t){const e=t.split(/\s+/,1)[0];if(/^[-+]?0x[0-9a-f]+$/i.test(e))return Number.parseInt(e,16);if(/^[-+]?0[0-7]+$/.test(e))return Number.parseInt(e,8);if(/^[-+]?\d+$/.test(e))return Number.parseInt(e,10);throw new i("Invalid FIGfont code tag.",{codetagLine:t})}static u(t,e){if(!/^-?\d+$/.test(t))throw new i("Invalid FIGfont header value.",{field:e,token:t});return Number.parseInt(t,10)}static escapeForRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class a{static _(t){return 0!==t.fullLayout?63&t.fullLayout:t.oldLayout>0?63&t.oldLayout:0}static m(t){return 7936&t.fullLayout}static I(t,e,n,r){return" "===t?e:" "===e?t:0===r?this.v(t,e,n):(0!==(r&this.RULE_EQUAL_CHARACTER)?this.L(t,e,n):null)??(0!==(r&this.RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(r&this.RULE_HIERARCHY)?this.R(t,e):null)??(0!==(r&this.RULE_OPPOSITE_PAIR)?this.A(t,e):null)??(0!==(r&this.RULE_BIG_X)?this.F(t,e):null)??(0!==(r&this.RULE_HARDBLANK)?this.T(t,e,n):null)}static v(t,e,n){return" "===t?e:" "===e?t:e}static U(t,e,n){return" "===t?e:" "===e?t:0===n?this.v(t,e," "):(0!==(n&this.VERTICAL_RULE_EQUAL_CHARACTER)?this.L(t,e," "):null)??(0!==(n&this.VERTICAL_RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(n&this.VERTICAL_RULE_HIERARCHY)?this.R(t,e):null)??(0!==(n&this.VERTICAL_RULE_HORIZONTAL_LINE)?this.S(t,e):null)??(0!==(n&this.VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH)?this.$(t,e):null)}static L(t,e,n){return t===e&&t!==n?t:null}static C(t,e){const n="|/\\[]{}()<>";return"_"===t&&n.includes(e)?e:"_"===e&&n.includes(t)?t:null}static R(t,e){const n=["|","/\\","[]","{}","()","<>"],r=n.findIndex(e=>e.includes(t)),i=n.findIndex(t=>t.includes(e));return-1===r||-1===i||r===i?null:r>i?t:e}static A(t,e){return["[]","][","{}","}{","()",")("].includes(`${t}${e}`)?"|":null}static F(t,e){const n=`${t}${e}`;return"/\\"===n?"|":"\\/"===n?"Y":"><"===n?"X":null}static T(t,e,n){return t===n&&e===n?n:null}static S(t,e){const n=`${t}${e}`;return"-_"===n||"_-"===n?"=":null}static $(t,e){return"|"===t&&"|"===e?"|":null}}r(a,"RULE_EQUAL_CHARACTER",1),r(a,"RULE_UNDERSCORE",2),r(a,"RULE_HIERARCHY",4),r(a,"RULE_OPPOSITE_PAIR",8),r(a,"RULE_BIG_X",16),r(a,"RULE_HARDBLANK",32),r(a,"VERTICAL_RULE_EQUAL_CHARACTER",256),r(a,"VERTICAL_RULE_UNDERSCORE",512),r(a,"VERTICAL_RULE_HIERARCHY",1024),r(a,"VERTICAL_RULE_HORIZONTAL_LINE",2048),r(a,"VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH",4096);class l{constructor(t){r(this,"_header"),r(this,"_horizontalRuleMask"),r(this,"_verticalRuleMask"),this.H=t,this.M=a._(t),this.k=a.m(t)}G(t,e){const n=t.map((t,e)=>({inputIndex:e,inputChar:String.fromCodePoint(t.code)})),r=this.O(t,n,e,0),i=Array.from({length:r.rows},()=>Array.from({length:r.cols},()=>" "));for(const t of r.cells)i[t.row][t.col]=t.char;return i}O(t,e,n,r){if(0===t.length)return{lineIndex:r,cells:[],cols:0,rows:this.H.height};let i=this.N(t[0],e[0],r),s=t[0].width;for(let o=1;o<t.length;o+=1){const l=t[o],c=e[o]??{inputIndex:o,inputChar:String.fromCodePoint(l.code)},u=s-this.V(i,s,l,n),h=Math.max(s,u+l.width),f=i.map(t=>Array.from({length:h},(e,n)=>t[n]));for(let t=0;t<this.H.height;t+=1){const e=l.lines[t]??"",n=f[t];for(let i=0;i<l.width;i+=1){const s=e[i]??" ";if(" "===s)continue;const o=u+i,h=n[o],f=this.P(o,t,i,r,l,c,s);if(!h){n[o]=f;continue}const d=a.I(h.char,s,this.H.hardblank,this.M);n[o]=this.B(h,f,d??s)}}i=f,s=h}return this.j(i,s,r)}D(t,e){var n;if(0===t.length)return{cells:[],lines:[],cols:0,rows:0};let r=this.W(t[0]),i=t[0].cols,s=t[0].rows;const o=[this.q(t[0],0)];for(let l=1;l<t.length;l+=1){const c=t[l],u=s-this.X(r,s,i,c,e),h=Math.max(i,c.cols),f=Math.max(s,u+c.rows),d=Array.from({length:f},(t,e)=>Array.from({length:h},(t,n)=>{var i;return null==(i=r[e])?void 0:i[n]}));for(const t of c.cells){const e=u+t.row,r=t.col,i=null==(n=d[e])?void 0:n[r];if(!i){d[e][r]={...t,row:e};continue}const s=a.U(i.char,t.char,this.k);d[e][r]=this.B(i,{...t,row:e},s??t.char)}r=d,i=h,s=f,o.push(this.q(c,u))}return this.Y(r,i,s,o)}V(t,e,n,r){var i;if("full"===r)return 0;for(let s=e;s>=0;s-=1){let o=!0;for(let a=0;a<this.H.height&&o;a+=1){const l=t[a]??[],c=n.lines[a]??"";for(let t=0;t<s;t+=1){const n=(null==(i=l[e-s+t])?void 0:i.char)??" ",a=c[t]??" ";if(!this.J(n,a,r)){o=!1;break}}}if(o)return s}return 0}J(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==a.I(t,e,this.H.hardblank,this.M)}N(t,e={inputIndex:0,inputChar:String.fromCodePoint(t.code)},n=0){return Array.from({length:this.H.height},(r,i)=>{const s=t.lines[i]??"";return Array.from({length:t.width},(r,o)=>{const a=s[o]??" ";return" "===a?void 0:this.P(o,i,o,n,t,e,a)})})}P(t,e,n,r,i,s,o){return{char:o,col:t,row:e,inputIndex:s.inputIndex,inputChar:s.inputChar,figCharCode:i.code,subRow:e,subCol:n,lineIndex:r}}B(t,e,n){return n===t.char?t:{...e,char:n}}j(t,e,n){const r=[];for(let i=0;i<this.H.height;i+=1){const s=t[i]??[];for(let t=0;t<e;t+=1){const e=s[t];!e||e.char===this.H.hardblank||r.push({...e,col:t,row:i,lineIndex:n})}}return{lineIndex:n,cells:r,cols:e,rows:this.H.height}}X(t,e,n,r,i){var s,o;if("full"===i)return 0;const a=this.W(r),l=Math.min(e,r.rows),c=Math.max(n,r.cols);for(let n=l;n>=0;n-=1){let r=!0;for(let l=0;l<n&&r;l+=1){const u=t[e-n+l]??[],h=a[l]??[];for(let t=0;t<c;t+=1){const e=(null==(s=u[t])?void 0:s.char)??" ",n=(null==(o=h[t])?void 0:o.char)??" ";if(!this.K(e,n,i)){r=!1;break}}}if(r)return n}return 0}K(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==a.U(t,e,this.k)}W(t){const e=Array.from({length:t.rows},()=>Array.from({length:t.cols},()=>{}));for(const n of t.cells)e[n.row][n.col]=n;return e}q(t,e){return{...t,cells:t.cells.map(t=>({...t,row:t.row+e}))}}Y(t,e,n,r){var i;const s=[];for(let r=0;r<n;r+=1)for(let n=0;n<e;n+=1){const e=null==(i=t[r])?void 0:i[n];e&&s.push({...e,row:r,col:n})}return{cells:s,lines:r,cols:e,rows:n}}}class c{constructor(){r(this,"_onDisposeCallbacks",new Set)}Z(t){this.tt.add(t)}dispose(){for(const t of this.tt)t();this.tt.clear()}}class u extends c{constructor(t,e,n){super(),r(this,"_name"),r(this,"_header"),r(this,"_characters"),r(this,"_layoutEngine"),this.et=t,this.H=e,this.nt=n,this.rt=new l(e)}static async it(t){const e=await fetch(t);if(!e.ok)throw new i("Failed to load FIGfont file.",{source:String(t),status:e.status,statusText:e.statusText});const n=await e.text();return this.st(this.ot(t),n)}static st(t,e){const n=o.t(e);return new u(t,n.header,n.characters)}getCharacter(t){var e;const n="number"==typeof t?t:null==(e=Array.from(t)[0])?void 0:e.codePointAt(0);if(void 0!==n)return h(this.nt.get(n))}planText(t,e={}){const n=e.horizontalLayout??this.defaultLayout,r=e.verticalLayout??this.defaultVerticalLayout,i=this.lt(e.direction),s=this.ct(t).map(t=>this.ut(t,i)).flatMap(t=>this.ht(t,n,e)).map((t,e)=>{const r=this.ft(t);return this.rt.O(r.map(t=>t.figChar),r.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),n,e)}),o=this.rt.D(s,r);return{cells:o.cells,lines:o.lines,cols:o.cols,rows:o.rows,direction:i}}renderText(t,e={}){const n=this.planText(t,e),r=Array.from({length:n.rows},()=>Array.from({length:n.cols},()=>" "));for(const t of n.cells)r[t.row][t.col]=t.char;return{grid:r,cols:n.cols,rows:n.rows}}measureText(t,e={}){const n=this.planText(t,e);return{cols:n.cols,rows:n.rows}}get name(){return this.et}get header(){return{...this.H}}get characters(){return new Map(Array.from(this.nt,([t,e])=>[t,h(e)]))}get hardblank(){return this.H.hardblank}get height(){return this.H.height}get baseline(){return this.H.baseline}get defaultLayout(){return 128&this.H.fullLayout?"smushed":64&this.H.fullLayout?"fitted":-1===this.H.oldLayout?"full":0===this.H.oldLayout?"fitted":this.H.oldLayout>0?"smushed":"full"}get defaultPrintDirection(){return 1===this.H.printDirection?"rtl":"ltr"}get defaultVerticalLayout(){return 16384&this.H.fullLayout?"smushed":8192&this.H.fullLayout?"fitted":"full"}static ot(t){const e=t instanceof URL?t.pathname:t,n=(e.split(/[?#]/,1)[0]??e).split("/").filter(Boolean).pop()??"figfont";return n.toLowerCase().endsWith(".flf")?n.slice(0,-4)||"figfont":n}ct(t){const e=[[]];for(const[n,r]of Array.from(t).entries())"\n"!==r?e[e.length-1].push({character:r,inputIndex:n}):e.push([]);return e}ut(t,e){return"rtl"===e?[...t].reverse():t}ft(t){const e=t.map(({character:t,inputIndex:e})=>({figChar:this.getCharacter(t)??this.getCharacter(32),inputChar:t,inputIndex:e})),n=e.find(t=>void 0===t.figChar);if(n)throw new i("FIGfont is missing a required character for layout.",{character:n.inputChar,index:n.inputIndex});return e}ht(t,e,n){const r="number"==typeof n.maxCols&&Number.isFinite(n.maxCols)?Math.floor(n.maxCols):void 0,i=n.wrap??"none";return 0===t.length||!r||r<1||"none"===i?[t]:"char"===i?this.dt(t,e,r):this.gt(t,e,r)}gt(t,e,n){const r=this._t(t);if(!r.some(t=>!t.isWhitespace))return[t];const i=[];let s=[],o=[];for(const t of r){if(t.isWhitespace){s.length>0&&(o=t.characters);continue}const r=0===s.length?t.characters:s.concat(o,t.characters);s.length>0&&this.wt(r,e)>n?(i.push(s),s=t.characters.slice()):s=r,o=[]}return 0===s.length?[[]]:(i.push(s),i)}dt(t,e,n){const r=[];let i=[];for(const s of t){const t=i.concat(s);i.length>0&&this.wt(t,e)>n?(r.push(i),i=[s]):i=t}return 0===i.length?[[]]:(r.push(i),r)}wt(t,e){const n=this.ft(t);return this.rt.O(n.map(t=>t.figChar),n.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),e,0).cols}_t(t){const e=[];for(const n of t){const t=/\s/u.test(n.character),r=e[e.length-1];r&&r.isWhitespace===t?r.characters.push(n):e.push({isWhitespace:t,characters:[n]})}return e}lt(t){return"ltr"===t||"rtl"===t?t:this.defaultPrintDirection}}function h(t){if(t)return{...t,lines:[...t.lines]}}const f="textmode.figlet.js",d="1.0.1-beta.1",g=Symbol.for("textmode.figlet.state");function p(t){const e=t;return e[g]||(e[g]={activeFont:void 0,align:"left",baseline:"baseline"}),e[g]}const _=["loadFigFont","parseFigFont","figFont","figText","figTextWidth","figTextHeight","figTextBounds","figTextAlign","figTextBaseline"];function w(t,e){if(void 0!==t)return"function"==typeof t?t(e):t}function m(t,n,r){return r instanceof e.color.TextmodeColor||"string"==typeof r||"number"==typeof r?"charColor"===n?void t.charColor(r):void t.cellColor(r):4===r.length?"charColor"===n?void t.charColor(r[0],r[1],r[2],r[3]):void t.cellColor(r[0],r[1],r[2],r[3]):void("charColor"!==n?t.cellColor(r[0],r[1],r[2]):t.charColor(r[0],r[1],r[2]))}function I(t){const e=p(t).activeFont;if(!e)throw new i("No FIGlet font is active. Call figFont() first.");return e}function y(t,e){var n;null==(n=t.It)||n.call(t,e)}function v(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0,enumerable:!1})}function x(t){v(t,"loadFigFont",async function(t){const e=await u.it(t);return y(this,e),e}),v(t,"parseFigFont",function(t,e){const n=u.st(t,e);return y(this,n),n}),v(t,"figFont",function(t){const e=p(this);if(void 0===t)return e.activeFont;e.activeFont=t}),v(t,"figText",function(t,e,n,r={}){const i=I(this),s=i.planText(t,r),o=p(this),a=e+function(t,e){return"center"===e?-Math.floor(t/2):"right"===e?-(t-1):0}(s.cols,o.align),l=n+function(t,e,n){return"top"===n?0:"center"===n?-Math.floor(t/2):"bottom"===n?-(t-1):-(e-1)}(s.rows,i.baseline,o.baseline);this.push(),this.translate(a,l,0);for(const t of s.cells){this.push(),this.translate(t.col,t.row,0);const e=w(r.charColor,t),n=w(r.cellColor,t);this.char(t.char),void 0!==e&&m(this,"charColor",e),void 0!==n&&m(this,"cellColor",n),this.point(),this.pop()}this.pop()}),v(t,"figTextWidth",function(t,e={}){return I(this).measureText(t,e).cols}),v(t,"figTextHeight",function(t,e={}){return I(this).measureText(t,e).rows}),v(t,"figTextBounds",function(t,e={}){return I(this).measureText(t,e)}),v(t,"figTextAlign",function(t){const e=p(this);if(void 0===t)return e.align;e.align=t}),v(t,"figTextBaseline",function(t){const e=p(this);if(void 0===t)return e.baseline;e.baseline=t})}function L(t){for(const e of _)delete t[e];!function(t){delete t[g]}(t)}const C={name:f,version:d,install(t,e){x(t)},uninstall(t,e){L(t)}};if(typeof window<"u"){const t=window;t.FigletPlugin=C,t.TextmodeFigFont=u,t.FigFontParser=o,t.FigLayoutEngine=l,t.FigSmushRules=a,t.FIGFONT_REQUIRED_CODEPOINTS=s}t.FIGFONT_REQUIRED_CODEPOINTS=s,t.FigFontParser=o,t.FigLayoutEngine=l,t.FigSmushRules=a,t.FigletPlugin=C,t.TextmodeFigFont=u,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&typeof module<"u"?e(exports,require("textmode.js")):"function"==typeof define&&define.amd?define(["exports","textmode.js"],e):e((t=typeof globalThis<"u"?globalThis:t||self).TextmodeFiglet={},t.textmode)}(this,function(t,e){"use strict";var n=Object.defineProperty,r=(t,e,r)=>((t,e,r)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r)(t,"symbol"!=typeof e?e+"":e,r);class i extends Error{constructor(t,e){super(i.formatMessage(t,e)),this.name="FigletError"}static formatMessage(t,e){if(!e||0===Object.keys(e).length)return t;return`${t}\n\nContext:${Object.entries(e).map(([t,e])=>`\n - ${t}: ${i.formatValue(e)}`).join("")}`}static formatValue(t){return null===t?"null":void 0===t?"undefined":"string"==typeof t?`"${t}"`:"number"==typeof t||"boolean"==typeof t?String(t):Array.isArray(t)?`[${t.map(t=>i.formatValue(t)).join(", ")}]`:"object"==typeof t?JSON.stringify(t):String(t)}}const s=[...Array.from({length:95},(t,e)=>e+32),196,214,220,228,246,252,223];class o{static t(t){if(0===t.length)throw new i("Cannot parse an empty FIGfont file.");const e=t.replace(/\r\n?/g,"\n").split("\n"),n=e[0];if(!n)throw new i("Missing FIGfont header line.");const r=this.i(n);let s=1+r.commentLines;if(s>e.length)throw new i("FIGfont comment line count exceeds file length.",{commentLines:r.commentLines,totalLines:e.length});const o=new Map;return s=this.o(e,s,r,o),this.l(e,s,r,o),{header:r,characters:o}}static i(t){const e=t.trim().split(/\s+/),n=e[0]??"";if(n.length<6)throw new i("Invalid FIGfont header token.",{headerToken:n});const r=n.slice(0,5),s=n.slice(5);if("flf2a"!==r)throw new i("Unsupported FIGfont signature.",{signature:r});if(1!==s.length)throw new i("FIGfont hardblank must be a single character.",{hardblank:s});if(e.length<6)throw new i("Incomplete FIGfont header.",{headerLine:t});return{signature:r,hardblank:s,height:this.u(e[1],"height"),baseline:this.u(e[2],"baseline"),maxLength:this.u(e[3],"maxLength"),oldLayout:this.u(e[4],"oldLayout"),commentLines:this.u(e[5],"commentLines"),printDirection:this.u(e[6]??"0","printDirection"),fullLayout:this.u(e[7]??"0","fullLayout"),codetagCount:this.u(e[8]??"0","codetagCount")}}static o(t,e,n,r){let i=e;for(const e of s){const s=this.h(t,i,n.height,e);r.set(e,s),i+=n.height}return i}static l(t,e,n,r){var i;let s=e;for(;s<t.length;){const e=(null==(i=t[s])?void 0:i.trim())??"";if(0===e.length){s+=1;continue}const o=this.p(e);s+=1;const a=this.h(t,s,n.height,o);r.set(o,a),s+=n.height}}static h(t,e,n,r){if(e+n>t.length)throw new i("Unexpected end of FIGfont character data.",{codePoint:r,startIndex:e,height:n,totalLines:t.length});const s=[];let o=0;for(let a=0;a<n;a+=1){const n=t[e+a]??"";if(0===n.length)throw new i("Encountered an empty FIGcharacter row.",{codePoint:r,row:a,startIndex:e});const l=n.at(-1);if(!l)throw new i("Failed to determine FIGcharacter endmark.",{codePoint:r,row:a});const c=n.replace(new RegExp(`${this.escapeForRegExp(l)}+$`),"");s.push(c),o=Math.max(o,c.length)}return{code:r,lines:s,width:o}}static p(t){const e=t.split(/\s+/,1)[0];if(/^[-+]?0x[0-9a-f]+$/i.test(e))return Number.parseInt(e,16);if(/^[-+]?0[0-7]+$/.test(e))return Number.parseInt(e,8);if(/^[-+]?\d+$/.test(e))return Number.parseInt(e,10);throw new i("Invalid FIGfont code tag.",{codetagLine:t})}static u(t,e){if(!/^-?\d+$/.test(t))throw new i("Invalid FIGfont header value.",{field:e,token:t});return Number.parseInt(t,10)}static escapeForRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class a{static _(t){return 0!==t.fullLayout?63&t.fullLayout:t.oldLayout>0?63&t.oldLayout:0}static m(t){return 7936&t.fullLayout}static I(t,e,n,r){return" "===t?e:" "===e?t:0===r?this.v(t,e,n):(0!==(r&this.RULE_EQUAL_CHARACTER)?this.L(t,e,n):null)??(0!==(r&this.RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(r&this.RULE_HIERARCHY)?this.R(t,e):null)??(0!==(r&this.RULE_OPPOSITE_PAIR)?this.A(t,e):null)??(0!==(r&this.RULE_BIG_X)?this.F(t,e):null)??(0!==(r&this.RULE_HARDBLANK)?this.T(t,e,n):null)}static v(t,e,n){return" "===t?e:" "===e?t:e}static U(t,e,n){return" "===t?e:" "===e?t:0===n?this.v(t,e," "):(0!==(n&this.VERTICAL_RULE_EQUAL_CHARACTER)?this.L(t,e," "):null)??(0!==(n&this.VERTICAL_RULE_UNDERSCORE)?this.C(t,e):null)??(0!==(n&this.VERTICAL_RULE_HIERARCHY)?this.R(t,e):null)??(0!==(n&this.VERTICAL_RULE_HORIZONTAL_LINE)?this.S(t,e):null)??(0!==(n&this.VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH)?this.$(t,e):null)}static L(t,e,n){return t===e&&t!==n?t:null}static C(t,e){const n="|/\\[]{}()<>";return"_"===t&&n.includes(e)?e:"_"===e&&n.includes(t)?t:null}static R(t,e){const n=["|","/\\","[]","{}","()","<>"],r=n.findIndex(e=>e.includes(t)),i=n.findIndex(t=>t.includes(e));return-1===r||-1===i||r===i?null:r>i?t:e}static A(t,e){return["[]","][","{}","}{","()",")("].includes(`${t}${e}`)?"|":null}static F(t,e){const n=`${t}${e}`;return"/\\"===n?"|":"\\/"===n?"Y":"><"===n?"X":null}static T(t,e,n){return t===n&&e===n?n:null}static S(t,e){const n=`${t}${e}`;return"-_"===n||"_-"===n?"=":null}static $(t,e){return"|"===t&&"|"===e?"|":null}}r(a,"RULE_EQUAL_CHARACTER",1),r(a,"RULE_UNDERSCORE",2),r(a,"RULE_HIERARCHY",4),r(a,"RULE_OPPOSITE_PAIR",8),r(a,"RULE_BIG_X",16),r(a,"RULE_HARDBLANK",32),r(a,"VERTICAL_RULE_EQUAL_CHARACTER",256),r(a,"VERTICAL_RULE_UNDERSCORE",512),r(a,"VERTICAL_RULE_HIERARCHY",1024),r(a,"VERTICAL_RULE_HORIZONTAL_LINE",2048),r(a,"VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH",4096);class l{constructor(t){r(this,"_header"),r(this,"_horizontalRuleMask"),r(this,"_verticalRuleMask"),this.H=t,this.M=a._(t),this.k=a.m(t)}G(t,e){const n=t.map((t,e)=>({inputIndex:e,inputChar:String.fromCodePoint(t.code)})),r=this.O(t,n,e,0),i=Array.from({length:r.rows},()=>Array.from({length:r.cols},()=>" "));for(const t of r.cells)i[t.row][t.col]=t.char;return i}O(t,e,n,r){if(0===t.length)return{lineIndex:r,cells:[],cols:0,rows:this.H.height};let i=this.N(t[0],e[0],r),s=t[0].width;for(let o=1;o<t.length;o+=1){const l=t[o],c=e[o]??{inputIndex:o,inputChar:String.fromCodePoint(l.code)},u=s-this.V(i,s,l,n),h=Math.max(s,u+l.width),f=i.map(t=>Array.from({length:h},(e,n)=>t[n]));for(let t=0;t<this.H.height;t+=1){const e=l.lines[t]??"",n=f[t];for(let i=0;i<l.width;i+=1){const s=e[i]??" ";if(" "===s)continue;const o=u+i,h=n[o],f=this.P(o,t,i,r,l,c,s);if(!h){n[o]=f;continue}const d=a.I(h.char,s,this.H.hardblank,this.M);n[o]=this.B(h,f,d??s)}}i=f,s=h}return this.j(i,s,r)}D(t,e){var n;if(0===t.length)return{cells:[],lines:[],cols:0,rows:0};let r=this.W(t[0]),i=t[0].cols,s=t[0].rows;const o=[this.q(t[0],0)];for(let l=1;l<t.length;l+=1){const c=t[l],u=s-this.X(r,s,i,c,e),h=Math.max(i,c.cols),f=Math.max(s,u+c.rows),d=Array.from({length:f},(t,e)=>Array.from({length:h},(t,n)=>{var i;return null==(i=r[e])?void 0:i[n]}));for(const t of c.cells){const e=u+t.row,r=t.col,i=null==(n=d[e])?void 0:n[r];if(!i){d[e][r]={...t,row:e};continue}const s=a.U(i.char,t.char,this.k);d[e][r]=this.B(i,{...t,row:e},s??t.char)}r=d,i=h,s=f,o.push(this.q(c,u))}return this.Y(r,i,s,o)}V(t,e,n,r){var i;if("full"===r)return 0;for(let s=e;s>=0;s-=1){let o=!0;for(let a=0;a<this.H.height&&o;a+=1){const l=t[a]??[],c=n.lines[a]??"";for(let t=0;t<s;t+=1){const n=(null==(i=l[e-s+t])?void 0:i.char)??" ",a=c[t]??" ";if(!this.J(n,a,r)){o=!1;break}}}if(o)return s}return 0}J(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==a.I(t,e,this.H.hardblank,this.M)}N(t,e={inputIndex:0,inputChar:String.fromCodePoint(t.code)},n=0){return Array.from({length:this.H.height},(r,i)=>{const s=t.lines[i]??"";return Array.from({length:t.width},(r,o)=>{const a=s[o]??" ";return" "===a?void 0:this.P(o,i,o,n,t,e,a)})})}P(t,e,n,r,i,s,o){return{char:o,col:t,row:e,inputIndex:s.inputIndex,inputChar:s.inputChar,figCharCode:i.code,subRow:e,subCol:n,lineIndex:r}}B(t,e,n){return n===t.char?t:{...e,char:n}}j(t,e,n){const r=[];for(let i=0;i<this.H.height;i+=1){const s=t[i]??[];for(let t=0;t<e;t+=1){const e=s[t];!e||e.char===this.H.hardblank||r.push({...e,col:t,row:i,lineIndex:n})}}return{lineIndex:n,cells:r,cols:e,rows:this.H.height}}X(t,e,n,r,i){var s,o;if("full"===i)return 0;const a=this.W(r),l=Math.min(e,r.rows),c=Math.max(n,r.cols);for(let n=l;n>=0;n-=1){let r=!0;for(let l=0;l<n&&r;l+=1){const u=t[e-n+l]??[],h=a[l]??[];for(let t=0;t<c;t+=1){const e=(null==(s=u[t])?void 0:s.char)??" ",n=(null==(o=h[t])?void 0:o.char)??" ";if(!this.K(e,n,i)){r=!1;break}}}if(r)return n}return 0}K(t,e,n){return" "===t||" "===e||"fitted"!==n&&null!==a.U(t,e,this.k)}W(t){const e=Array.from({length:t.rows},()=>Array.from({length:t.cols},()=>{}));for(const n of t.cells)e[n.row][n.col]=n;return e}q(t,e){return{...t,cells:t.cells.map(t=>({...t,row:t.row+e}))}}Y(t,e,n,r){var i;const s=[];for(let r=0;r<n;r+=1)for(let n=0;n<e;n+=1){const e=null==(i=t[r])?void 0:i[n];e&&s.push({...e,row:r,col:n})}return{cells:s,lines:r,cols:e,rows:n}}}class c{constructor(){r(this,"_onDisposeCallbacks",new Set)}Z(t){this.tt.add(t)}dispose(){for(const t of this.tt)t();this.tt.clear()}}class u extends c{constructor(t,e,n){super(),r(this,"_name"),r(this,"_header"),r(this,"_characters"),r(this,"_layoutEngine"),this.et=t,this.H=e,this.nt=n,this.rt=new l(e)}static async it(t){const e=await fetch(t);if(!e.ok)throw new i("Failed to load FIGfont file.",{source:String(t),status:e.status,statusText:e.statusText});const n=await e.text();return this.st(this.ot(t),n)}static st(t,e){const n=o.t(e);return new u(t,n.header,n.characters)}getCharacter(t){var e;const n="number"==typeof t?t:null==(e=Array.from(t)[0])?void 0:e.codePointAt(0);if(void 0!==n)return h(this.nt.get(n))}planText(t,e={}){const n=e.horizontalLayout??this.defaultLayout,r=e.verticalLayout??this.defaultVerticalLayout,i=this.lt(e.direction),s=this.ct(t).map(t=>this.ut(t,i)).flatMap(t=>this.ht(t,n,e)).map((t,e)=>{const r=this.ft(t);return this.rt.O(r.map(t=>t.figChar),r.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),n,e)}),o=this.rt.D(s,r);return{cells:o.cells,lines:o.lines,cols:o.cols,rows:o.rows,direction:i}}renderText(t,e={}){const n=this.planText(t,e),r=Array.from({length:n.rows},()=>Array.from({length:n.cols},()=>" "));for(const t of n.cells)r[t.row][t.col]=t.char;return{grid:r,cols:n.cols,rows:n.rows}}measureText(t,e={}){const n=this.planText(t,e);return{cols:n.cols,rows:n.rows}}get name(){return this.et}get header(){return{...this.H}}get characters(){return new Map(Array.from(this.nt,([t,e])=>[t,h(e)]))}get hardblank(){return this.H.hardblank}get height(){return this.H.height}get baseline(){return this.H.baseline}get defaultLayout(){return 128&this.H.fullLayout?"smushed":64&this.H.fullLayout?"fitted":-1===this.H.oldLayout?"full":0===this.H.oldLayout?"fitted":this.H.oldLayout>0?"smushed":"full"}get defaultPrintDirection(){return 1===this.H.printDirection?"rtl":"ltr"}get defaultVerticalLayout(){return 16384&this.H.fullLayout?"smushed":8192&this.H.fullLayout?"fitted":"full"}static ot(t){const e=t instanceof URL?t.pathname:t,n=(e.split(/[?#]/,1)[0]??e).split("/").filter(Boolean).pop()??"figfont";return n.toLowerCase().endsWith(".flf")?n.slice(0,-4)||"figfont":n}ct(t){const e=[[]];for(const[n,r]of Array.from(t).entries())"\n"!==r?e[e.length-1].push({character:r,inputIndex:n}):e.push([]);return e}ut(t,e){return"rtl"===e?[...t].reverse():t}ft(t){const e=t.map(({character:t,inputIndex:e})=>({figChar:this.getCharacter(t)??this.getCharacter(32),inputChar:t,inputIndex:e})),n=e.find(t=>void 0===t.figChar);if(n)throw new i("FIGfont is missing a required character for layout.",{character:n.inputChar,index:n.inputIndex});return e}ht(t,e,n){const r="number"==typeof n.maxCols&&Number.isFinite(n.maxCols)?Math.floor(n.maxCols):void 0,i=n.wrap??"none";return 0===t.length||!r||r<1||"none"===i?[t]:"char"===i?this.dt(t,e,r):this.gt(t,e,r)}gt(t,e,n){const r=this._t(t);if(!r.some(t=>!t.isWhitespace))return[t];const i=[];let s=[],o=[];for(const t of r){if(t.isWhitespace){s.length>0&&(o=t.characters);continue}const r=0===s.length?t.characters:s.concat(o,t.characters);s.length>0&&this.wt(r,e)>n?(i.push(s),s=t.characters.slice()):s=r,o=[]}return 0===s.length?[[]]:(i.push(s),i)}dt(t,e,n){const r=[];let i=[];for(const s of t){const t=i.concat(s);i.length>0&&this.wt(t,e)>n?(r.push(i),i=[s]):i=t}return 0===i.length?[[]]:(r.push(i),r)}wt(t,e){const n=this.ft(t);return this.rt.O(n.map(t=>t.figChar),n.map(({inputChar:t,inputIndex:e})=>({inputChar:t,inputIndex:e})),e,0).cols}_t(t){const e=[];for(const n of t){const t=/\s/u.test(n.character),r=e[e.length-1];r&&r.isWhitespace===t?r.characters.push(n):e.push({isWhitespace:t,characters:[n]})}return e}lt(t){return"ltr"===t||"rtl"===t?t:this.defaultPrintDirection}}function h(t){if(t)return{...t,lines:[...t.lines]}}const f="textmode.figlet.js",d="1.0.2",g=Symbol.for("textmode.figlet.state");function p(t){const e=t;return e[g]||(e[g]={activeFont:void 0,align:"left",baseline:"baseline"}),e[g]}const _=["loadFigFont","parseFigFont","figFont","figText","figTextWidth","figTextHeight","figTextBounds","figTextAlign","figTextBaseline"];function w(t,e){if(void 0!==t)return"function"==typeof t?t(e):t}function m(t,n,r){return r instanceof e.color.TextmodeColor||"string"==typeof r||"number"==typeof r?"charColor"===n?void t.charColor(r):void t.cellColor(r):4===r.length?"charColor"===n?void t.charColor(r[0],r[1],r[2],r[3]):void t.cellColor(r[0],r[1],r[2],r[3]):void("charColor"!==n?t.cellColor(r[0],r[1],r[2]):t.charColor(r[0],r[1],r[2]))}function I(t){const e=p(t).activeFont;if(!e)throw new i("No FIGlet font is active. Call figFont() first.");return e}function y(t,e){var n;null==(n=t.It)||n.call(t,e)}function v(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0,enumerable:!1})}function x(t){v(t,"loadFigFont",async function(t){const e=await u.it(t);return y(this,e),e}),v(t,"parseFigFont",function(t,e){const n=u.st(t,e);return y(this,n),n}),v(t,"figFont",function(t){const e=p(this);if(void 0===t)return e.activeFont;e.activeFont=t}),v(t,"figText",function(t,e,n,r={}){const i=I(this),s=i.planText(t,r),o=p(this),a=e+function(t,e){return"center"===e?-Math.floor(t/2):"right"===e?-(t-1):0}(s.cols,o.align),l=n+function(t,e,n){return"top"===n?0:"center"===n?-Math.floor(t/2):"bottom"===n?-(t-1):-(e-1)}(s.rows,i.baseline,o.baseline);this.push(),this.translate(a,l,0);for(const t of s.cells){this.push(),this.translate(t.col,t.row,0);const e=w(r.charColor,t),n=w(r.cellColor,t);this.char(t.char),void 0!==e&&m(this,"charColor",e),void 0!==n&&m(this,"cellColor",n),this.point(),this.pop()}this.pop()}),v(t,"figTextWidth",function(t,e={}){return I(this).measureText(t,e).cols}),v(t,"figTextHeight",function(t,e={}){return I(this).measureText(t,e).rows}),v(t,"figTextBounds",function(t,e={}){return I(this).measureText(t,e)}),v(t,"figTextAlign",function(t){const e=p(this);if(void 0===t)return e.align;e.align=t}),v(t,"figTextBaseline",function(t){const e=p(this);if(void 0===t)return e.baseline;e.baseline=t})}function L(t){for(const e of _)delete t[e];!function(t){delete t[g]}(t)}const C={name:f,version:d,install(t,e){x(t)},uninstall(t,e){L(t)}};if(typeof window<"u"){const t=window;t.FigletPlugin=C,t.TextmodeFigFont=u,t.FigFontParser=o,t.FigLayoutEngine=l,t.FigSmushRules=a,t.FIGFONT_REQUIRED_CODEPOINTS=s}t.FIGFONT_REQUIRED_CODEPOINTS=s,t.FigFontParser=o,t.FigLayoutEngine=l,t.FigSmushRules=a,t.FigletPlugin=C,t.TextmodeFigFont=u,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -6,6 +6,8 @@ import type { FigTextAlign, FigTextBaseline, FigTextOptions } from '../figfont';
|
|
|
6
6
|
/**
|
|
7
7
|
* FIGlet methods added to the `textmode.js` `Textmodifier` API when
|
|
8
8
|
* {@link FigletPlugin} is installed.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions | TextmodifierFigletExtensions API reference}
|
|
9
11
|
*/
|
|
10
12
|
export interface TextmodifierFigletExtensions {
|
|
11
13
|
/**
|
|
@@ -16,6 +18,8 @@ export interface TextmodifierFigletExtensions {
|
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
20
|
* {@includeCode ../../examples/Textmodifier/loadFigFont/sketch.js}
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/loadFigFont | TextmodifierFigletExtensions.loadFigFont API reference}
|
|
19
23
|
*/
|
|
20
24
|
loadFigFont(source: string | URL): Promise<TextmodeFigFont>;
|
|
21
25
|
/**
|
|
@@ -27,6 +31,8 @@ export interface TextmodifierFigletExtensions {
|
|
|
27
31
|
*
|
|
28
32
|
* @example
|
|
29
33
|
* {@includeCode ../../examples/Textmodifier/parseFigFont/sketch.js}
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/parseFigFont | TextmodifierFigletExtensions.parseFigFont API reference}
|
|
30
36
|
*/
|
|
31
37
|
parseFigFont(name: string, data: string): TextmodeFigFont;
|
|
32
38
|
/**
|
|
@@ -36,12 +42,16 @@ export interface TextmodifierFigletExtensions {
|
|
|
36
42
|
*
|
|
37
43
|
* @example
|
|
38
44
|
* {@includeCode ../../examples/Textmodifier/figFont/sketch.js}
|
|
45
|
+
*
|
|
46
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figFont | TextmodifierFigletExtensions.figFont API reference}
|
|
39
47
|
*/
|
|
40
48
|
figFont(): TextmodeFigFont | undefined;
|
|
41
49
|
/**
|
|
42
50
|
* Set the active FIGlet font used by `figText()`.
|
|
43
51
|
*
|
|
44
52
|
* @param font The FIGlet font to use for subsequent text rendering.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figFont | TextmodifierFigletExtensions.figFont API reference}
|
|
45
55
|
*/
|
|
46
56
|
figFont(font: TextmodeFigFont): void;
|
|
47
57
|
/**
|
|
@@ -54,6 +64,8 @@ export interface TextmodifierFigletExtensions {
|
|
|
54
64
|
*
|
|
55
65
|
* @example
|
|
56
66
|
* {@includeCode ../../examples/Textmodifier/figText/sketch.js}
|
|
67
|
+
*
|
|
68
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figText | TextmodifierFigletExtensions.figText API reference}
|
|
57
69
|
*/
|
|
58
70
|
figText(text: string, col: number, row: number, options?: FigTextOptions): void;
|
|
59
71
|
/**
|
|
@@ -65,6 +77,8 @@ export interface TextmodifierFigletExtensions {
|
|
|
65
77
|
*
|
|
66
78
|
* @example
|
|
67
79
|
* {@includeCode ../../examples/Textmodifier/figTextWidth/sketch.js}
|
|
80
|
+
*
|
|
81
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figTextWidth | TextmodifierFigletExtensions.figTextWidth API reference}
|
|
68
82
|
*/
|
|
69
83
|
figTextWidth(text: string, options?: FigTextOptions): number;
|
|
70
84
|
/**
|
|
@@ -76,6 +90,8 @@ export interface TextmodifierFigletExtensions {
|
|
|
76
90
|
*
|
|
77
91
|
* @example
|
|
78
92
|
* {@includeCode ../../examples/Textmodifier/figTextHeight/sketch.js}
|
|
93
|
+
*
|
|
94
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figTextHeight | TextmodifierFigletExtensions.figTextHeight API reference}
|
|
79
95
|
*/
|
|
80
96
|
figTextHeight(text: string, options?: FigTextOptions): number;
|
|
81
97
|
/**
|
|
@@ -87,6 +103,8 @@ export interface TextmodifierFigletExtensions {
|
|
|
87
103
|
*
|
|
88
104
|
* @example
|
|
89
105
|
* {@includeCode ../../examples/Textmodifier/figTextBounds/sketch.js}
|
|
106
|
+
*
|
|
107
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figTextBounds | TextmodifierFigletExtensions.figTextBounds API reference}
|
|
90
108
|
*/
|
|
91
109
|
figTextBounds(text: string, options?: FigTextOptions): {
|
|
92
110
|
cols: number;
|
|
@@ -99,12 +117,16 @@ export interface TextmodifierFigletExtensions {
|
|
|
99
117
|
*
|
|
100
118
|
* @example
|
|
101
119
|
* {@includeCode ../../examples/Textmodifier/figTextAlign/sketch.js}
|
|
120
|
+
*
|
|
121
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figTextAlign | TextmodifierFigletExtensions.figTextAlign API reference}
|
|
102
122
|
*/
|
|
103
123
|
figTextAlign(): FigTextAlign;
|
|
104
124
|
/**
|
|
105
125
|
* Set the horizontal FIGlet text alignment.
|
|
106
126
|
*
|
|
107
127
|
* @param align Alignment mode for subsequent `figText()` calls.
|
|
128
|
+
*
|
|
129
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figTextAlign | TextmodifierFigletExtensions.figTextAlign API reference}
|
|
108
130
|
*/
|
|
109
131
|
figTextAlign(align: FigTextAlign): void;
|
|
110
132
|
/**
|
|
@@ -114,12 +136,16 @@ export interface TextmodifierFigletExtensions {
|
|
|
114
136
|
*
|
|
115
137
|
* @example
|
|
116
138
|
* {@includeCode ../../examples/Textmodifier/figTextBaseline/sketch.js}
|
|
139
|
+
*
|
|
140
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figTextBaseline | TextmodifierFigletExtensions.figTextBaseline API reference}
|
|
117
141
|
*/
|
|
118
142
|
figTextBaseline(): FigTextBaseline;
|
|
119
143
|
/**
|
|
120
144
|
* Set the vertical FIGlet text baseline mode.
|
|
121
145
|
*
|
|
122
146
|
* @param baseline Baseline mode for subsequent `figText()` calls.
|
|
147
|
+
*
|
|
148
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/TextmodifierFigletExtensions/methods/figTextBaseline | TextmodifierFigletExtensions.figTextBaseline API reference}
|
|
123
149
|
*/
|
|
124
150
|
figTextBaseline(baseline: FigTextBaseline): void;
|
|
125
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textmode.d.ts","sourceRoot":"","sources":["../../../src/augmentations/textmode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"textmode.d.ts","sourceRoot":"","sources":["../../../src/augmentations/textmode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;;;;;;;;OAUG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE5D;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IAE1D;;;;;;;;;OASG;IACH,OAAO,IAAI,eAAe,GAAG,SAAS,CAAC;IAEvC;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAErC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAEhF;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAE7D;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAE9D;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAEtF;;;;;;;;;OASG;IACH,YAAY,IAAI,YAAY,CAAC;IAE7B;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAExC;;;;;;;;;OASG;IACH,eAAe,IAAI,eAAe,CAAC;IAEnC;;;;;;OAMG;IACH,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CACjD;AAED,OAAO,QAAQ,aAAa,CAAC;IAC5B,UAAU,YAAa,SAAQ,4BAA4B;KAAG;CAC9D"}
|
|
@@ -2,6 +2,8 @@ import { Disposable } from '../utils/Disposable';
|
|
|
2
2
|
import type { FigCharacter, FigFontHeader, FigHorizontalLayout, FigRenderPlan, FigTextOptions, FigTextResult, FigVerticalLayout } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Parsed FIGfont resource used by `figText()` rendering.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont | TextmodeFigFont API reference}
|
|
5
7
|
*/
|
|
6
8
|
export declare class TextmodeFigFont extends Disposable {
|
|
7
9
|
private readonly _name;
|
|
@@ -36,6 +38,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
36
38
|
*
|
|
37
39
|
* @example
|
|
38
40
|
* {@includeCode ../../examples/TextmodeFigFont/getCharacter/sketch.js}
|
|
41
|
+
*
|
|
42
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/methods/getCharacter | TextmodeFigFont.getCharacter API reference}
|
|
39
43
|
*/
|
|
40
44
|
getCharacter(value: number | string): FigCharacter | undefined;
|
|
41
45
|
/**
|
|
@@ -43,6 +47,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
43
47
|
*
|
|
44
48
|
* @example
|
|
45
49
|
* {@includeCode ../../examples/TextmodeFigFont/planText/sketch.js}
|
|
50
|
+
*
|
|
51
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/methods/planText | TextmodeFigFont.planText API reference}
|
|
46
52
|
*/
|
|
47
53
|
planText(text: string, options?: FigTextOptions): FigRenderPlan;
|
|
48
54
|
/**
|
|
@@ -50,6 +56,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
50
56
|
*
|
|
51
57
|
* @example
|
|
52
58
|
* {@includeCode ../../examples/TextmodeFigFont/renderText/sketch.js}
|
|
59
|
+
*
|
|
60
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/methods/renderText | TextmodeFigFont.renderText API reference}
|
|
53
61
|
*/
|
|
54
62
|
renderText(text: string, options?: FigTextOptions): FigTextResult;
|
|
55
63
|
/**
|
|
@@ -57,6 +65,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
57
65
|
*
|
|
58
66
|
* @example
|
|
59
67
|
* {@includeCode ../../examples/TextmodeFigFont/measureText/sketch.js}
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/methods/measureText | TextmodeFigFont.measureText API reference}
|
|
60
70
|
*/
|
|
61
71
|
measureText(text: string, options?: FigTextOptions): {
|
|
62
72
|
cols: number;
|
|
@@ -67,6 +77,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
67
77
|
*
|
|
68
78
|
* @example
|
|
69
79
|
* {@includeCode ../../examples/TextmodeFigFont/name/sketch.js}
|
|
80
|
+
*
|
|
81
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/name | TextmodeFigFont.name API reference}
|
|
70
82
|
*/
|
|
71
83
|
get name(): string;
|
|
72
84
|
/**
|
|
@@ -74,6 +86,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
74
86
|
*
|
|
75
87
|
* @example
|
|
76
88
|
* {@includeCode ../../examples/TextmodeFigFont/header/sketch.js}
|
|
89
|
+
*
|
|
90
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/header | TextmodeFigFont.header API reference}
|
|
77
91
|
*/
|
|
78
92
|
get header(): FigFontHeader;
|
|
79
93
|
/**
|
|
@@ -81,6 +95,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
81
95
|
*
|
|
82
96
|
* @example
|
|
83
97
|
* {@includeCode ../../examples/TextmodeFigFont/characters/sketch.js}
|
|
98
|
+
*
|
|
99
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/characters | TextmodeFigFont.characters API reference}
|
|
84
100
|
*/
|
|
85
101
|
get characters(): Map<number, FigCharacter>;
|
|
86
102
|
/**
|
|
@@ -88,6 +104,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
88
104
|
*
|
|
89
105
|
* @example
|
|
90
106
|
* {@includeCode ../../examples/TextmodeFigFont/hardblank/sketch.js}
|
|
107
|
+
*
|
|
108
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/hardblank | TextmodeFigFont.hardblank API reference}
|
|
91
109
|
*/
|
|
92
110
|
get hardblank(): string;
|
|
93
111
|
/**
|
|
@@ -95,6 +113,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
95
113
|
*
|
|
96
114
|
* @example
|
|
97
115
|
* {@includeCode ../../examples/TextmodeFigFont/height/sketch.js}
|
|
116
|
+
*
|
|
117
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/height | TextmodeFigFont.height API reference}
|
|
98
118
|
*/
|
|
99
119
|
get height(): number;
|
|
100
120
|
/**
|
|
@@ -102,6 +122,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
102
122
|
*
|
|
103
123
|
* @example
|
|
104
124
|
* {@includeCode ../../examples/TextmodeFigFont/baseline/sketch.js}
|
|
125
|
+
*
|
|
126
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/baseline | TextmodeFigFont.baseline API reference}
|
|
105
127
|
*/
|
|
106
128
|
get baseline(): number;
|
|
107
129
|
/**
|
|
@@ -109,6 +131,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
109
131
|
*
|
|
110
132
|
* @example
|
|
111
133
|
* {@includeCode ../../examples/TextmodeFigFont/defaultLayout/sketch.js}
|
|
134
|
+
*
|
|
135
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/defaultLayout | TextmodeFigFont.defaultLayout API reference}
|
|
112
136
|
*/
|
|
113
137
|
get defaultLayout(): FigHorizontalLayout;
|
|
114
138
|
/**
|
|
@@ -116,6 +140,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
116
140
|
*
|
|
117
141
|
* @example
|
|
118
142
|
* {@includeCode ../../examples/TextmodeFigFont/defaultPrintDirection/sketch.js}
|
|
143
|
+
*
|
|
144
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/defaultPrintDirection | TextmodeFigFont.defaultPrintDirection API reference}
|
|
119
145
|
*/
|
|
120
146
|
get defaultPrintDirection(): 'ltr' | 'rtl';
|
|
121
147
|
/**
|
|
@@ -123,6 +149,8 @@ export declare class TextmodeFigFont extends Disposable {
|
|
|
123
149
|
*
|
|
124
150
|
* @example
|
|
125
151
|
* {@includeCode ../../examples/TextmodeFigFont/defaultVerticalLayout/sketch.js}
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/classes/TextmodeFigFont/accessors/defaultVerticalLayout | TextmodeFigFont.defaultVerticalLayout API reference}
|
|
126
154
|
*/
|
|
127
155
|
get defaultVerticalLayout(): FigVerticalLayout;
|
|
128
156
|
private static _resolveName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextmodeFigFont.d.ts","sourceRoot":"","sources":["../../../src/figfont/TextmodeFigFont.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,OAAO,KAAK,EACX,YAAY,EACZ,aAAa,EACb,mBAAmB,EAEnB,aAAa,EACb,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,MAAM,SAAS,CAAC;AAajB
|
|
1
|
+
{"version":3,"file":"TextmodeFigFont.d.ts","sourceRoot":"","sources":["../../../src/figfont/TextmodeFigFont.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,OAAO,KAAK,EACX,YAAY,EACZ,aAAa,EACb,mBAAmB,EAEnB,aAAa,EACb,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,MAAM,SAAS,CAAC;AAajB;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IACxD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAkB;IAEhD,OAAO;IAQP;;;;;;;OAOG;WACiB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC;IAc5E;;;;;;;;OAQG;WACW,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe;IAKtE;;;;;;;;;;OAUG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS;IAUrE;;;;;;;OAOG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa;IA8B1E;;;;;;;OAOG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa;IAe5E;;;;;;;OAOG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAK9F;;;;;;;OAOG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;;OAOG;IACH,IAAI,MAAM,IAAI,aAAa,CAI1B;IAED;;;;;;;OAOG;IACH,IAAI,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAI1C;IAED;;;;;;;OAOG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;;;OAOG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;;OAOG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;;;;;OAOG;IACH,IAAI,aAAa,IAAI,mBAAmB,CAkBvC;IAED;;;;;;;OAOG;IACH,IAAI,qBAAqB,IAAI,KAAK,GAAG,KAAK,CAEzC;IAED;;;;;;;OAOG;IACH,IAAI,qBAAqB,IAAI,iBAAiB,CAU7C;IAED,OAAO,CAAC,MAAM,CAAC,YAAY;IAQ3B,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,oBAAoB;IA4C5B,OAAO,CAAC,yBAAyB;IA2BjC,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,qBAAqB;IAuB7B,OAAO,CAAC,iBAAiB;CAOzB"}
|
|
@@ -8,38 +8,94 @@ import type { color } from 'textmode.js';
|
|
|
8
8
|
export declare const FIGFONT_REQUIRED_CODEPOINTS: readonly number[];
|
|
9
9
|
/**
|
|
10
10
|
* Parsed FIGfont header metadata from the `.flf` header line.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader | FigFontHeader API reference}
|
|
11
13
|
*/
|
|
12
14
|
export interface FigFontHeader {
|
|
13
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Always `flf2a` for supported FIGfont v2 files.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#signature | FigFontHeader.signature API reference}
|
|
19
|
+
*/
|
|
14
20
|
signature: string;
|
|
15
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Hardblank character used by the font.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#hardblank | FigFontHeader.hardblank API reference}
|
|
25
|
+
*/
|
|
16
26
|
hardblank: string;
|
|
17
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Number of rows in every FIGcharacter.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#height | FigFontHeader.height API reference}
|
|
31
|
+
*/
|
|
18
32
|
height: number;
|
|
19
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Baseline row reported by the font.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#baseline | FigFontHeader.baseline API reference}
|
|
37
|
+
*/
|
|
20
38
|
baseline: number;
|
|
21
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Maximum line length declared by the font.
|
|
41
|
+
*
|
|
42
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#maxlength | FigFontHeader.maxLength API reference}
|
|
43
|
+
*/
|
|
22
44
|
maxLength: number;
|
|
23
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Legacy horizontal layout bitfield.
|
|
47
|
+
*
|
|
48
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#oldlayout | FigFontHeader.oldLayout API reference}
|
|
49
|
+
*/
|
|
24
50
|
oldLayout: number;
|
|
25
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Number of comment lines immediately following the header.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#commentlines | FigFontHeader.commentLines API reference}
|
|
55
|
+
*/
|
|
26
56
|
commentLines: number;
|
|
27
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Font print direction: `0` left-to-right, `1` right-to-left.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#printdirection | FigFontHeader.printDirection API reference}
|
|
61
|
+
*/
|
|
28
62
|
printDirection: number;
|
|
29
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Full FIGfont layout flags when present.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#fulllayout | FigFontHeader.fullLayout API reference}
|
|
67
|
+
*/
|
|
30
68
|
fullLayout: number;
|
|
31
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Number of code-tagged characters declared by the font.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigFontHeader#codetagcount | FigFontHeader.codetagCount API reference}
|
|
73
|
+
*/
|
|
32
74
|
codetagCount: number;
|
|
33
75
|
}
|
|
34
76
|
/**
|
|
35
77
|
* A single parsed FIGcharacter from a FIGfont.
|
|
78
|
+
*
|
|
79
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigCharacter | FigCharacter API reference}
|
|
36
80
|
*/
|
|
37
81
|
export interface FigCharacter {
|
|
38
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Unicode code point represented by the FIGcharacter.
|
|
84
|
+
*
|
|
85
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigCharacter#code | FigCharacter.code API reference}
|
|
86
|
+
*/
|
|
39
87
|
code: number;
|
|
40
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Raw FIGcharacter rows with endmarks removed.
|
|
90
|
+
*
|
|
91
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigCharacter#lines | FigCharacter.lines API reference}
|
|
92
|
+
*/
|
|
41
93
|
lines: string[];
|
|
42
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Maximum row width after endmark removal.
|
|
96
|
+
*
|
|
97
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigCharacter#width | FigCharacter.width API reference}
|
|
98
|
+
*/
|
|
43
99
|
width: number;
|
|
44
100
|
}
|
|
45
101
|
/**
|
|
@@ -53,68 +109,148 @@ export interface ParsedFigFontData {
|
|
|
53
109
|
}
|
|
54
110
|
/**
|
|
55
111
|
* Supported horizontal layout modes for FIGlet rendering.
|
|
112
|
+
*
|
|
113
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigHorizontalLayout | FigHorizontalLayout API reference}
|
|
56
114
|
*/
|
|
57
115
|
export type FigHorizontalLayout = 'full' | 'fitted' | 'smushed';
|
|
58
116
|
/**
|
|
59
117
|
* Supported vertical layout modes for multi-line FIGlet rendering.
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigVerticalLayout | FigVerticalLayout API reference}
|
|
60
120
|
*/
|
|
61
121
|
export type FigVerticalLayout = 'full' | 'fitted' | 'smushed';
|
|
62
122
|
/**
|
|
63
123
|
* Supported wrap modes for FIGlet text layout.
|
|
124
|
+
*
|
|
125
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigWrapMode | FigWrapMode API reference}
|
|
64
126
|
*/
|
|
65
127
|
export type FigWrapMode = 'none' | 'word' | 'char';
|
|
66
128
|
/**
|
|
67
129
|
* Supported print directions for FIGlet text layout.
|
|
130
|
+
*
|
|
131
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigPrintDirection | FigPrintDirection API reference}
|
|
68
132
|
*/
|
|
69
133
|
export type FigPrintDirection = 'font' | 'ltr' | 'rtl';
|
|
70
134
|
/**
|
|
71
135
|
* Accepted color input for per-cell FIGlet styling.
|
|
136
|
+
*
|
|
137
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigTextColorValue | FigTextColorValue API reference}
|
|
72
138
|
*/
|
|
73
139
|
export type FigTextColorValue = number | string | color.TextmodeColor | [number, number, number] | [number, number, number, number];
|
|
74
140
|
/**
|
|
75
141
|
* Public cell metadata exposed to FIGlet styling callbacks.
|
|
142
|
+
*
|
|
143
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext | FigTextCellContext API reference}
|
|
76
144
|
*/
|
|
77
145
|
export interface FigTextCellContext {
|
|
78
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* Final drawable sub-character after layout normalization.
|
|
148
|
+
*
|
|
149
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#char | FigTextCellContext.char API reference}
|
|
150
|
+
*/
|
|
79
151
|
char: string;
|
|
80
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Absolute column within the rendered result.
|
|
154
|
+
*
|
|
155
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#col | FigTextCellContext.col API reference}
|
|
156
|
+
*/
|
|
81
157
|
col: number;
|
|
82
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Absolute row within the rendered result.
|
|
160
|
+
*
|
|
161
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#row | FigTextCellContext.row API reference}
|
|
162
|
+
*/
|
|
83
163
|
row: number;
|
|
84
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Zero-based index into the original input string's character sequence.
|
|
166
|
+
*
|
|
167
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#inputindex | FigTextCellContext.inputIndex API reference}
|
|
168
|
+
*/
|
|
85
169
|
inputIndex: number;
|
|
86
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Original input character that produced this cell.
|
|
172
|
+
*
|
|
173
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#inputchar | FigTextCellContext.inputChar API reference}
|
|
174
|
+
*/
|
|
87
175
|
inputChar: string;
|
|
88
|
-
/**
|
|
176
|
+
/**
|
|
177
|
+
* FIGcharacter code used to produce this cell.
|
|
178
|
+
*
|
|
179
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#figcharcode | FigTextCellContext.figCharCode API reference}
|
|
180
|
+
*/
|
|
89
181
|
figCharCode: number;
|
|
90
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* Row within the source FIGcharacter.
|
|
184
|
+
*
|
|
185
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#subrow | FigTextCellContext.subRow API reference}
|
|
186
|
+
*/
|
|
91
187
|
subRow: number;
|
|
92
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* Column within the source FIGcharacter.
|
|
190
|
+
*
|
|
191
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#subcol | FigTextCellContext.subCol API reference}
|
|
192
|
+
*/
|
|
93
193
|
subCol: number;
|
|
94
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* Logical rendered line index after explicit newline splitting.
|
|
196
|
+
*
|
|
197
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextCellContext#lineindex | FigTextCellContext.lineIndex API reference}
|
|
198
|
+
*/
|
|
95
199
|
lineIndex: number;
|
|
96
200
|
}
|
|
97
201
|
/**
|
|
98
202
|
* Resolver for per-cell FIGlet colors.
|
|
203
|
+
*
|
|
204
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigTextColorResolver | FigTextColorResolver API reference}
|
|
99
205
|
*/
|
|
100
206
|
export type FigTextColorResolver = FigTextColorValue | ((cell: FigTextCellContext) => FigTextColorValue | undefined);
|
|
101
207
|
/**
|
|
102
208
|
* Layout options for rendering FIGlet text.
|
|
209
|
+
*
|
|
210
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions | FigTextOptions API reference}
|
|
103
211
|
*/
|
|
104
212
|
export interface FigTextOptions {
|
|
105
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* Override the font's default horizontal layout.
|
|
215
|
+
*
|
|
216
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions#horizontallayout | FigTextOptions.horizontalLayout API reference}
|
|
217
|
+
*/
|
|
106
218
|
horizontalLayout?: FigHorizontalLayout;
|
|
107
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Override the vertical composition mode for multi-line FIGlet layout.
|
|
221
|
+
*
|
|
222
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions#verticallayout | FigTextOptions.verticalLayout API reference}
|
|
223
|
+
*/
|
|
108
224
|
verticalLayout?: FigVerticalLayout;
|
|
109
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* Override the effective print direction for layout.
|
|
227
|
+
*
|
|
228
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions#direction | FigTextOptions.direction API reference}
|
|
229
|
+
*/
|
|
110
230
|
direction?: FigPrintDirection;
|
|
111
|
-
/**
|
|
231
|
+
/**
|
|
232
|
+
* Optional wrap strategy for multi-line layout.
|
|
233
|
+
*
|
|
234
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions#wrap | FigTextOptions.wrap API reference}
|
|
235
|
+
*/
|
|
112
236
|
wrap?: FigWrapMode;
|
|
113
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Maximum rendered columns per logical line before wrapping occurs.
|
|
239
|
+
*
|
|
240
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions#maxcols | FigTextOptions.maxCols API reference}
|
|
241
|
+
*/
|
|
114
242
|
maxCols?: number;
|
|
115
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* Override or resolve the foreground color for each rendered FIGlet cell.
|
|
245
|
+
*
|
|
246
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions#charcolor | FigTextOptions.charColor API reference}
|
|
247
|
+
*/
|
|
116
248
|
charColor?: FigTextColorResolver;
|
|
117
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* Override or resolve the background color for each rendered FIGlet cell.
|
|
251
|
+
*
|
|
252
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/interfaces/FigTextOptions#cellcolor | FigTextOptions.cellColor API reference}
|
|
253
|
+
*/
|
|
118
254
|
cellColor?: FigTextColorResolver;
|
|
119
255
|
}
|
|
120
256
|
/**
|
|
@@ -170,10 +306,14 @@ export interface FigTextResult {
|
|
|
170
306
|
}
|
|
171
307
|
/**
|
|
172
308
|
* Horizontal alignment options for `figText()` placement.
|
|
309
|
+
*
|
|
310
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigTextAlign | FigTextAlign API reference}
|
|
173
311
|
*/
|
|
174
312
|
export type FigTextAlign = 'left' | 'center' | 'right';
|
|
175
313
|
/**
|
|
176
314
|
* Vertical alignment options for `figText()` placement.
|
|
315
|
+
*
|
|
316
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/type-aliases/FigTextBaseline | FigTextBaseline API reference}
|
|
177
317
|
*/
|
|
178
318
|
export type FigTextBaseline = 'top' | 'center' | 'bottom' | 'baseline';
|
|
179
319
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/figfont/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,MAAM,EASxD,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/figfont/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,MAAM,EASxD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAC1B,MAAM,GACN,MAAM,GACN,KAAK,CAAC,aAAa,GACnB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACxB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG,CAAC,CAAC,IAAI,EAAE,kBAAkB,KAAK,iBAAiB,GAAG,SAAS,CAAC,CAAC;AAErH;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;IACvC;;;;OAIG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,oBAAoB,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,6CAA6C;IAC7C,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,qDAAqD;IACrD,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,mDAAmD;IACnD,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IACjB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC"}
|
|
@@ -4,6 +4,8 @@ import type { TextmodePlugin } from 'textmode.js';
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* {@includeCode ../../examples/FigletPlugin/init/sketch.js}
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://code.textmode.art/api/textmode.figlet.js/variables/FigletPlugin | FigletPlugin API reference}
|
|
7
9
|
*/
|
|
8
10
|
export declare const FigletPlugin: TextmodePlugin;
|
|
9
11
|
//# sourceMappingURL=FigletPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FigletPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugin/FigletPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,aAAa,CAAC;AAKzE
|
|
1
|
+
{"version":3,"file":"FigletPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugin/FigletPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,aAAa,CAAC;AAKzE;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,cAW1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textmode.figlet.js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "FIGlet font support for textmode.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/textmode.figlet.umd.js",
|
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
"build:bundle": "vite build",
|
|
26
26
|
"build:types": "tsc",
|
|
27
27
|
"build": "npm run build:bundle && npm run build:types",
|
|
28
|
-
"check": "npm run check:format && npm run lint && npm run lint:md && npm run check:types && npm run test && npm run build",
|
|
28
|
+
"check": "npm run check:format && npm run lint && npm run lint:md && npm run check:types && npm run check:api-docs && npm run check:examples && npm run test && npm run build",
|
|
29
|
+
"docs:links:add": "node ./scripts/add-api-doc-links.mjs",
|
|
29
30
|
"check:api-docs": "node ./scripts/check-public-api-docs.mjs",
|
|
31
|
+
"check:examples": "node ./scripts/check-examples.mjs",
|
|
30
32
|
"dev:docs": "typedoc --watch",
|
|
31
33
|
"build:docs": "typedoc",
|
|
32
34
|
"preview": "vite preview",
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"markdownlint-cli2-formatter-default": "^0.0.6",
|
|
71
73
|
"prettier": "^3.8.3",
|
|
72
74
|
"semantic-release": "^25.0.3",
|
|
73
|
-
"textmode.js": "^0.16.0
|
|
75
|
+
"textmode.js": "^0.16.0",
|
|
74
76
|
"typedoc": "^0.28.19",
|
|
75
77
|
"typedoc-plugin-frontmatter": "^1.3.1",
|
|
76
78
|
"typedoc-plugin-markdown": "^4.11.0",
|