textmode.figlet.js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/textmode.figlet.esm.js +1 -0
- package/dist/textmode.figlet.umd.js +1 -0
- package/dist/types/augmentations/index.d.ts +6 -0
- package/dist/types/augmentations/index.d.ts.map +1 -0
- package/dist/types/augmentations/textmode.d.ts +130 -0
- package/dist/types/augmentations/textmode.d.ts.map +1 -0
- package/dist/types/error/FigletError.d.ts +15 -0
- package/dist/types/error/FigletError.d.ts.map +1 -0
- package/dist/types/extensions/index.d.ts +5 -0
- package/dist/types/extensions/index.d.ts.map +1 -0
- package/dist/types/extensions/textmodifier.d.ts +14 -0
- package/dist/types/extensions/textmodifier.d.ts.map +1 -0
- package/dist/types/figfont/FigFontParser.d.ts +29 -0
- package/dist/types/figfont/FigFontParser.d.ts.map +1 -0
- package/dist/types/figfont/FigLayoutEngine.d.ts +46 -0
- package/dist/types/figfont/FigLayoutEngine.d.ts.map +1 -0
- package/dist/types/figfont/FigSmushRules.d.ts +52 -0
- package/dist/types/figfont/FigSmushRules.d.ts.map +1 -0
- package/dist/types/figfont/TextmodeFigFont.d.ts +139 -0
- package/dist/types/figfont/TextmodeFigFont.d.ts.map +1 -0
- package/dist/types/figfont/index.d.ts +7 -0
- package/dist/types/figfont/index.d.ts.map +1 -0
- package/dist/types/figfont/types.d.ts +179 -0
- package/dist/types/figfont/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/plugin/FigletPlugin.d.ts +9 -0
- package/dist/types/plugin/FigletPlugin.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +5 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/state/figletState.d.ts +29 -0
- package/dist/types/state/figletState.d.ts.map +1 -0
- package/dist/types/utils/Disposable.d.ts +17 -0
- package/dist/types/utils/Disposable.d.ts.map +1 -0
- package/package.json +100 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 humanbydefinition
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# textmode.figlet.js (✿◠‿◠)
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<table>
|
|
6
|
+
<tr>
|
|
7
|
+
<td align="center">
|
|
8
|
+
<a href="https://www.typescriptlang.org/"><img alt="TypeScript badge" src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" /></a> <a href="https://vitejs.dev/"><img alt="Vite badge" src="https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white" /></a> <a href="http://www.figlet.org/"><img alt="FIGlet badge" src="https://img.shields.io/badge/FIGlet-111111" /></a>
|
|
9
|
+
</td>
|
|
10
|
+
<td align="center">
|
|
11
|
+
<a href="https://code.textmode.art/"><img alt="docs badge" src="https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white" /></a> <a href="https://discord.gg/sjrw8QXNks"><img alt="Discord badge" src="https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white" /></a>
|
|
12
|
+
</td>
|
|
13
|
+
<td align="center">
|
|
14
|
+
<a href="https://ko-fi.com/V7V8JG2FY"><img alt="Ko-fi badge" src="https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi" /></a> <a href="https://github.com/sponsors/humanbydefinition"><img alt="GitHub Sponsors badge" src="https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=%23EA4AAA" /></a>
|
|
15
|
+
</td>
|
|
16
|
+
</tr>
|
|
17
|
+
</table>
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
`textmode.figlet.js` is an add-on library for `textmode.js` that provides FIGlet / FIGfont support. It includes a FIGfont parser, layout engine, and rendering API that integrates with the `Textmodifier` system in `textmode.js`, allowing you to draw FIGlet text with configurable layout behavior and measurement helpers.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Parse raw `.flf` sources into reusable `TextmodeFigFont` instances
|
|
26
|
+
- Load FIGfonts at runtime with `loadFigFont()`
|
|
27
|
+
- Draw FIGlet text with configurable horizontal and vertical layout behavior
|
|
28
|
+
- Measure rendered output with width, height, and bounds helpers before drawing
|
|
29
|
+
- Store alignment and baseline preferences per `Textmodifier` instance
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### Prerequisites
|
|
34
|
+
|
|
35
|
+
To get started with `textmode.figlet.js`, you'll need:
|
|
36
|
+
|
|
37
|
+
- `textmode.js` `0.11.0` or newer
|
|
38
|
+
- A modern browser with the same runtime requirements as `textmode.js`
|
|
39
|
+
- Node.js `20.8.1+` and `npm` (optional, for ESM installation)
|
|
40
|
+
|
|
41
|
+
### UMD
|
|
42
|
+
|
|
43
|
+
To use `textmode.figlet.js` in a browser without a bundler, load the UMD builds for both `textmode.js` and this add-on. `textmode.js` must be loaded first so the FIGlet add-on can attach to the expected global runtime.
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<!doctype html>
|
|
47
|
+
<html lang="en">
|
|
48
|
+
<head>
|
|
49
|
+
<meta charset="utf-8" />
|
|
50
|
+
<title>textmode.figlet.js sketch</title>
|
|
51
|
+
|
|
52
|
+
<script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
|
|
53
|
+
<script src="https://cdn.jsdelivr.net/npm/textmode.figlet.js@latest/dist/textmode.figlet.umd.js"></script>
|
|
54
|
+
</head>
|
|
55
|
+
<body>
|
|
56
|
+
<script src="./sketch.js"></script>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
const t = textmode.create({
|
|
63
|
+
width: window.innerWidth,
|
|
64
|
+
height: window.innerHeight,
|
|
65
|
+
fontSize: 16,
|
|
66
|
+
plugins: [FigletPlugin],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
t.setup(async () => {
|
|
70
|
+
const bulbhead = await t.loadFigFont('https://cdn.jsdelivr.net/gh/xero/figlet-fonts@master/Bulbhead.flf');
|
|
71
|
+
|
|
72
|
+
t.figFont(bulbhead);
|
|
73
|
+
t.figTextAlign('center');
|
|
74
|
+
t.figTextBaseline('center');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
t.draw(() => {
|
|
78
|
+
t.background(8, 12, 24);
|
|
79
|
+
t.charColor(255, 220, 120);
|
|
80
|
+
t.figText('FIGLET', 0, 0, {
|
|
81
|
+
horizontalLayout: 'fitted',
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
t.windowResized(() => {
|
|
86
|
+
t.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The UMD bundle exposes `FigletPlugin` globally, along with the other runtime exports such as `TextmodeFigFont` and `FigFontParser`.
|
|
91
|
+
|
|
92
|
+
### ESM
|
|
93
|
+
|
|
94
|
+
Install the core library and the FIGlet add-on together:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install textmode.js textmode.figlet.js
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then import both packages in your sketch or application code:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { textmode } from 'textmode.js';
|
|
104
|
+
import { FigletPlugin } from 'textmode.figlet.js';
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Importing `textmode.figlet.js` provides the TypeScript augmentation. Installing `FigletPlugin` enables the runtime FIGlet methods on that `Textmodifier` instance.
|
|
108
|
+
|
|
109
|
+
## Plugin setup
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { textmode } from 'textmode.js';
|
|
113
|
+
import { FigletPlugin } from 'textmode.figlet.js';
|
|
114
|
+
|
|
115
|
+
const t = textmode.create({
|
|
116
|
+
width: 800,
|
|
117
|
+
height: 600,
|
|
118
|
+
plugins: [FigletPlugin],
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The plugin installs the FIGlet drawing and measurement API during setup and removes it again if the plugin is uninstalled.
|
|
123
|
+
|
|
124
|
+
## Loading `.flf` fonts
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const bulbhead = await t.loadFigFont('https://cdn.jsdelivr.net/gh/xero/figlet-fonts@master/Bulbhead.flf');
|
|
128
|
+
|
|
129
|
+
t.figFont(bulbhead);
|
|
130
|
+
|
|
131
|
+
const custom = t.parseFigFont('Custom', figFontSource);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Any CORS-enabled `.flf` URL works for runtime loading.
|
|
135
|
+
|
|
136
|
+
## Drawing and measuring text
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
t.figTextAlign('center');
|
|
140
|
+
t.figTextBaseline('center');
|
|
141
|
+
|
|
142
|
+
t.figText('HELLO', 0, 0, {
|
|
143
|
+
horizontalLayout: 'fitted',
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const width = t.figTextWidth('HELLO');
|
|
147
|
+
const height = t.figTextHeight('HELLO');
|
|
148
|
+
const bounds = t.figTextBounds('HELLO');
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Use the measurement helpers when you need to position FIGlet text precisely before rendering it.
|
|
152
|
+
|
|
153
|
+
## Alignment and baseline
|
|
154
|
+
|
|
155
|
+
- `figTextAlign('left' | 'center' | 'right')`
|
|
156
|
+
- `figTextBaseline('top' | 'center' | 'baseline' | 'bottom')`
|
|
157
|
+
|
|
158
|
+
These settings are stored in plugin-owned state per `Textmodifier` instance and apply to subsequent `figText()` calls until changed.
|
|
159
|
+
|
|
160
|
+
## Next steps
|
|
161
|
+
|
|
162
|
+
Visit the `textmode.js` documentation at [code.textmode.art](https://code.textmode.art/) for broader library guides and API reference, then use the local examples in this package to validate your FIGlet setup and rendering behavior.
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
`textmode.figlet.js` is licensed under the MIT License.
|
|
@@ -0,0 +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{TextmodeColor 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.C(t,e,n):null)??(0!==(r&this.RULE_UNDERSCORE)?this.L(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.C(t,e," "):null)??(0!==(n&this.VERTICAL_RULE_UNDERSCORE)?this.L(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 C(t,e,n){return t===e&&t!==n?t:null}static L(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.0",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||"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 C(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 L(t){for(const e of _)delete t[e];!function(t){delete t[d]}(t)}const y={name:h,version:f,install(t,e){C(t)},uninstall(t,e){L(t)}};if(typeof window<"u"){const t=window;t.FigletPlugin=y,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,y as FigletPlugin,c as TextmodeFigFont};
|
|
@@ -0,0 +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.0",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.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"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/augmentations/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,YAAY,CAAC;AAEpB,YAAY,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript augmentation for `textmode.figlet.js`.
|
|
3
|
+
*/
|
|
4
|
+
import type { TextmodeFigFont } from '../figfont';
|
|
5
|
+
import type { FigTextAlign, FigTextBaseline, FigTextOptions } from '../figfont';
|
|
6
|
+
/**
|
|
7
|
+
* FIGlet methods added to the `textmode.js` `Textmodifier` API when
|
|
8
|
+
* {@link FigletPlugin} is installed.
|
|
9
|
+
*/
|
|
10
|
+
export interface TextmodifierFigletExtensions {
|
|
11
|
+
/**
|
|
12
|
+
* Load a FIGlet font from a `.flf` file URL or path.
|
|
13
|
+
*
|
|
14
|
+
* @param source The `.flf` file source.
|
|
15
|
+
* @returns A parsed FIGlet font instance.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* {@includeCode ../../examples/Textmodifier/loadFigFont/sketch.js}
|
|
19
|
+
*/
|
|
20
|
+
loadFigFont(source: string | URL): Promise<TextmodeFigFont>;
|
|
21
|
+
/**
|
|
22
|
+
* Parse a FIGlet font from raw `.flf` contents.
|
|
23
|
+
*
|
|
24
|
+
* @param name Human-readable font name.
|
|
25
|
+
* @param data Raw `.flf` file contents.
|
|
26
|
+
* @returns A parsed FIGlet font instance.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* {@includeCode ../../examples/Textmodifier/parseFigFont/sketch.js}
|
|
30
|
+
*/
|
|
31
|
+
parseFigFont(name: string, data: string): TextmodeFigFont;
|
|
32
|
+
/**
|
|
33
|
+
* Get the active FIGlet font used by `figText()`.
|
|
34
|
+
*
|
|
35
|
+
* @returns The currently active FIGlet font, if any.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* {@includeCode ../../examples/Textmodifier/figFont/sketch.js}
|
|
39
|
+
*/
|
|
40
|
+
figFont(): TextmodeFigFont | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Set the active FIGlet font used by `figText()`.
|
|
43
|
+
*
|
|
44
|
+
* @param font The FIGlet font to use for subsequent text rendering.
|
|
45
|
+
*/
|
|
46
|
+
figFont(font: TextmodeFigFont): void;
|
|
47
|
+
/**
|
|
48
|
+
* Render a FIGlet string onto the current textmode grid using the active FIGlet font.
|
|
49
|
+
*
|
|
50
|
+
* @param text The text to render.
|
|
51
|
+
* @param col Target column in grid space.
|
|
52
|
+
* @param row Target row in grid space.
|
|
53
|
+
* @param options Optional layout overrides.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* {@includeCode ../../examples/Textmodifier/figText/sketch.js}
|
|
57
|
+
*/
|
|
58
|
+
figText(text: string, col: number, row: number, options?: FigTextOptions): void;
|
|
59
|
+
/**
|
|
60
|
+
* Measure the rendered width of a FIGlet string in grid cells.
|
|
61
|
+
*
|
|
62
|
+
* @param text The text to measure.
|
|
63
|
+
* @param options Optional layout overrides.
|
|
64
|
+
* @returns Width in grid cells.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* {@includeCode ../../examples/Textmodifier/figTextWidth/sketch.js}
|
|
68
|
+
*/
|
|
69
|
+
figTextWidth(text: string, options?: FigTextOptions): number;
|
|
70
|
+
/**
|
|
71
|
+
* Measure the rendered height of a FIGlet string in grid cells.
|
|
72
|
+
*
|
|
73
|
+
* @param text The text to measure.
|
|
74
|
+
* @param options Optional layout overrides.
|
|
75
|
+
* @returns Height in grid cells.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* {@includeCode ../../examples/Textmodifier/figTextHeight/sketch.js}
|
|
79
|
+
*/
|
|
80
|
+
figTextHeight(text: string, options?: FigTextOptions): number;
|
|
81
|
+
/**
|
|
82
|
+
* Measure the rendered bounds of a FIGlet string in grid cells.
|
|
83
|
+
*
|
|
84
|
+
* @param text The text to measure.
|
|
85
|
+
* @param options Optional layout overrides.
|
|
86
|
+
* @returns Width and height in grid cells.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* {@includeCode ../../examples/Textmodifier/figTextBounds/sketch.js}
|
|
90
|
+
*/
|
|
91
|
+
figTextBounds(text: string, options?: FigTextOptions): {
|
|
92
|
+
cols: number;
|
|
93
|
+
rows: number;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Get the current horizontal FIGlet text alignment.
|
|
97
|
+
*
|
|
98
|
+
* @returns The current alignment mode.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* {@includeCode ../../examples/Textmodifier/figTextAlign/sketch.js}
|
|
102
|
+
*/
|
|
103
|
+
figTextAlign(): FigTextAlign;
|
|
104
|
+
/**
|
|
105
|
+
* Set the horizontal FIGlet text alignment.
|
|
106
|
+
*
|
|
107
|
+
* @param align Alignment mode for subsequent `figText()` calls.
|
|
108
|
+
*/
|
|
109
|
+
figTextAlign(align: FigTextAlign): void;
|
|
110
|
+
/**
|
|
111
|
+
* Get the current vertical FIGlet text baseline mode.
|
|
112
|
+
*
|
|
113
|
+
* @returns The current baseline mode.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* {@includeCode ../../examples/Textmodifier/figTextBaseline/sketch.js}
|
|
117
|
+
*/
|
|
118
|
+
figTextBaseline(): FigTextBaseline;
|
|
119
|
+
/**
|
|
120
|
+
* Set the vertical FIGlet text baseline mode.
|
|
121
|
+
*
|
|
122
|
+
* @param baseline Baseline mode for subsequent `figText()` calls.
|
|
123
|
+
*/
|
|
124
|
+
figTextBaseline(baseline: FigTextBaseline): void;
|
|
125
|
+
}
|
|
126
|
+
declare module 'textmode.js' {
|
|
127
|
+
interface Textmodifier extends TextmodifierFigletExtensions {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=textmode.d.ts.map
|
|
@@ -0,0 +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;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;;;;;;OAQG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE5D;;;;;;;;;OASG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IAE1D;;;;;;;OAOG;IACH,OAAO,IAAI,eAAe,GAAG,SAAS,CAAC;IAEvC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAErC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAEhF;;;;;;;;;OASG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAE7D;;;;;;;;;OASG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAE9D;;;;;;;;;OASG;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;;;;;;;OAOG;IACH,YAAY,IAAI,YAAY,CAAC;IAE7B;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAExC;;;;;;;OAOG;IACH,eAAe,IAAI,eAAe,CAAC;IAEnC;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CACjD;AAED,OAAO,QAAQ,aAAa,CAAC;IAC5B,UAAU,YAAa,SAAQ,4BAA4B;KAAG;CAC9D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error type used by the `textmode.figlet.js` package internals.
|
|
3
|
+
*/
|
|
4
|
+
export declare class FigletError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Create a new `FigletError`.
|
|
7
|
+
*
|
|
8
|
+
* @param message The main error message.
|
|
9
|
+
* @param context Optional structured context appended to the message.
|
|
10
|
+
*/
|
|
11
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
12
|
+
private static formatMessage;
|
|
13
|
+
private static formatValue;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=FigletError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigletError.d.ts","sourceRoot":"","sources":["../../../src/error/FigletError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACrC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAK9D,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B,OAAO,CAAC,MAAM,CAAC,WAAW;CAgB1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Textmodifier } from 'textmode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Install FIGlet Textmodifier extensions on a specific `Textmodifier` instance.
|
|
4
|
+
*
|
|
5
|
+
* @param textmodifier Target instance.
|
|
6
|
+
*/
|
|
7
|
+
export declare function installTextmodifierFigletExtensions(textmodifier: Textmodifier): void;
|
|
8
|
+
/**
|
|
9
|
+
* Remove FIGlet Textmodifier extensions from a specific `Textmodifier` instance.
|
|
10
|
+
*
|
|
11
|
+
* @param textmodifier Target instance.
|
|
12
|
+
*/
|
|
13
|
+
export declare function uninstallTextmodifierFigletExtensions(textmodifier: Textmodifier): void;
|
|
14
|
+
//# sourceMappingURL=textmodifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textmodifier.d.ts","sourceRoot":"","sources":["../../../src/extensions/textmodifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqIhD;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAyGpF;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAMtF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ParsedFigFontData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parser for FIGfont v2 `.flf` files.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class FigFontParser {
|
|
8
|
+
/**
|
|
9
|
+
* Parse a complete `.flf` file string into structured header and character data.
|
|
10
|
+
*
|
|
11
|
+
* @param data Raw FIGfont file contents.
|
|
12
|
+
* @returns Parsed header metadata and a character map keyed by code point.
|
|
13
|
+
*/
|
|
14
|
+
static _parse(data: string): ParsedFigFontData;
|
|
15
|
+
/**
|
|
16
|
+
* Parse the FIGfont header line.
|
|
17
|
+
*
|
|
18
|
+
* @param headerLine First line of a `.flf` file.
|
|
19
|
+
* @returns Parsed header metadata.
|
|
20
|
+
*/
|
|
21
|
+
private static _parseHeader;
|
|
22
|
+
private static _parseRequiredCharacters;
|
|
23
|
+
private static _parseCodeTaggedCharacters;
|
|
24
|
+
private static _readCharacter;
|
|
25
|
+
private static _parseCodetag;
|
|
26
|
+
private static _parseIntegerToken;
|
|
27
|
+
private static escapeForRegExp;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=FigFontParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigFontParser.d.ts","sourceRoot":"","sources":["../../../src/figfont/FigFontParser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA+B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG9E;;;;GAIG;AACH,qBAAa,aAAa;IACzB;;;;;OAKG;WACW,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB;IA+BrD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IA8C3B,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAiBvC,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAwBzC,OAAO,CAAC,MAAM,CAAC,cAAc;IAgD7B,OAAO,CAAC,MAAM,CAAC,aAAa;IAkB5B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAQjC,OAAO,CAAC,MAAM,CAAC,eAAe;CAG9B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { FigCharacter, FigFontHeader, FigHorizontalLayout, FigRenderCell, FigRenderLine, FigVerticalLayout } from './types';
|
|
2
|
+
interface FigLayoutInput {
|
|
3
|
+
inputIndex: number;
|
|
4
|
+
inputChar: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Horizontal FIGlet layout engine for composing FIGcharacters into a character grid.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class FigLayoutEngine {
|
|
12
|
+
private readonly _header;
|
|
13
|
+
private readonly _horizontalRuleMask;
|
|
14
|
+
private readonly _verticalRuleMask;
|
|
15
|
+
constructor(header: FigFontHeader);
|
|
16
|
+
/**
|
|
17
|
+
* Lay out a sequence of FIGcharacters into a combined 2D grid.
|
|
18
|
+
*/
|
|
19
|
+
_layoutHorizontal(figChars: readonly FigCharacter[], mode: FigHorizontalLayout): string[][];
|
|
20
|
+
/**
|
|
21
|
+
* Lay out a sequence of FIGcharacters into a positioned render line.
|
|
22
|
+
*/
|
|
23
|
+
_layoutHorizontalPlan(figChars: readonly FigCharacter[], inputs: readonly FigLayoutInput[], mode: FigHorizontalLayout, lineIndex: number): FigRenderLine;
|
|
24
|
+
/**
|
|
25
|
+
* Compose multiple planned FIGlet lines vertically.
|
|
26
|
+
*/
|
|
27
|
+
_layoutVerticalPlan(lines: readonly FigRenderLine[], mode: FigVerticalLayout): {
|
|
28
|
+
cells: FigRenderCell[];
|
|
29
|
+
lines: FigRenderLine[];
|
|
30
|
+
cols: number;
|
|
31
|
+
rows: number;
|
|
32
|
+
};
|
|
33
|
+
private _calculateSmushAmountForRows;
|
|
34
|
+
private _canOverlap;
|
|
35
|
+
private _createRowsFromCharacter;
|
|
36
|
+
private _createCell;
|
|
37
|
+
private _resolveSmushedCell;
|
|
38
|
+
private _materializeLine;
|
|
39
|
+
private _calculateVerticalSmushAmount;
|
|
40
|
+
private _canOverlapVertically;
|
|
41
|
+
private _createRowsFromLine;
|
|
42
|
+
private _offsetLine;
|
|
43
|
+
private _materializePlan;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=FigLayoutEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigLayoutEngine.d.ts","sourceRoot":"","sources":["../../../src/figfont/FigLayoutEngine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,MAAM,SAAS,CAAC;AAEjB,UAAU,cAAc;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;gBAE/B,MAAM,EAAE,aAAa;IAMjC;;OAEG;IACI,iBAAiB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,IAAI,EAAE,mBAAmB,GAAG,MAAM,EAAE,EAAE;IAelG;;OAEG;IACI,qBAAqB,CAC3B,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,MAAM,EAAE,SAAS,cAAc,EAAE,EACjC,IAAI,EAAE,mBAAmB,EACzB,SAAS,EAAE,MAAM,GACf,aAAa;IAqEhB;;OAEG;IACI,mBAAmB,CACzB,KAAK,EAAE,SAAS,aAAa,EAAE,EAC/B,IAAI,EAAE,iBAAiB,GACrB;QACF,KAAK,EAAE,aAAa,EAAE,CAAC;QACvB,KAAK,EAAE,aAAa,EAAE,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACb;IAyDD,OAAO,CAAC,4BAA4B;IAoCpC,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,wBAAwB;IAmBhC,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,gBAAgB;IAiCxB,OAAO,CAAC,6BAA6B;IAyCrC,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,gBAAgB;CAmCxB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { FigFontHeader } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Horizontal FIGlet smushing rules.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class FigSmushRules {
|
|
8
|
+
static readonly RULE_EQUAL_CHARACTER = 1;
|
|
9
|
+
static readonly RULE_UNDERSCORE = 2;
|
|
10
|
+
static readonly RULE_HIERARCHY = 4;
|
|
11
|
+
static readonly RULE_OPPOSITE_PAIR = 8;
|
|
12
|
+
static readonly RULE_BIG_X = 16;
|
|
13
|
+
static readonly RULE_HARDBLANK = 32;
|
|
14
|
+
static readonly VERTICAL_RULE_EQUAL_CHARACTER = 256;
|
|
15
|
+
static readonly VERTICAL_RULE_UNDERSCORE = 512;
|
|
16
|
+
static readonly VERTICAL_RULE_HIERARCHY = 1024;
|
|
17
|
+
static readonly VERTICAL_RULE_HORIZONTAL_LINE = 2048;
|
|
18
|
+
static readonly VERTICAL_RULE_VERTICAL_LINE_SUPERSMUSH = 4096;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the active horizontal rule mask from the parsed FIGfont header.
|
|
21
|
+
*/
|
|
22
|
+
static _getHorizontalRuleMask(header: FigFontHeader): number;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the active vertical rule mask from the parsed FIGfont header.
|
|
25
|
+
*/
|
|
26
|
+
static _getVerticalRuleMask(header: FigFontHeader): number;
|
|
27
|
+
/**
|
|
28
|
+
* Attempt to smush two horizontally overlapping characters.
|
|
29
|
+
*
|
|
30
|
+
* Returns `null` when the two characters cannot be merged in controlled-smush mode.
|
|
31
|
+
*/
|
|
32
|
+
static _smushHorizontal(left: string, right: string, hardblank: string, rules: number): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Universal smushing used when a font requests smushing without any rule bits enabled.
|
|
35
|
+
*/
|
|
36
|
+
static _smushUniversal(left: string, right: string, _hardblank: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Attempt to smush two vertically overlapping characters.
|
|
39
|
+
*
|
|
40
|
+
* Returns `null` when the two characters cannot be merged in controlled-smush mode.
|
|
41
|
+
*/
|
|
42
|
+
static _smushVertical(top: string, bottom: string, rules: number): string | null;
|
|
43
|
+
static _rule1EqualCharacter(left: string, right: string, hardblank: string): string | null;
|
|
44
|
+
static _rule2Underscore(left: string, right: string): string | null;
|
|
45
|
+
static _rule3Hierarchy(left: string, right: string): string | null;
|
|
46
|
+
static _rule4OppositePair(left: string, right: string): string | null;
|
|
47
|
+
static _rule5BigX(left: string, right: string): string | null;
|
|
48
|
+
static _rule6Hardblank(left: string, right: string, hardblank: string): string | null;
|
|
49
|
+
static _verticalRule4HorizontalLine(top: string, bottom: string): string | null;
|
|
50
|
+
static _verticalRule5VerticalLineSupersmush(top: string, bottom: string): string | null;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=FigSmushRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigSmushRules.d.ts","sourceRoot":"","sources":["../../../src/figfont/FigSmushRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;GAIG;AACH,qBAAa,aAAa;IACzB,gBAAuB,oBAAoB,KAAK;IAChD,gBAAuB,eAAe,KAAK;IAC3C,gBAAuB,cAAc,KAAK;IAC1C,gBAAuB,kBAAkB,KAAK;IAC9C,gBAAuB,UAAU,MAAM;IACvC,gBAAuB,cAAc,MAAM;IAC3C,gBAAuB,6BAA6B,OAAO;IAC3D,gBAAuB,wBAAwB,OAAO;IACtD,gBAAuB,uBAAuB,QAAQ;IACtD,gBAAuB,6BAA6B,QAAQ;IAC5D,gBAAuB,sCAAsC,QAAQ;IAErE;;OAEG;WACW,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IAQnE;;OAEG;WACW,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IAIjE;;;;OAIG;WACW,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAuB5G;;OAEG;WACW,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAYtF;;;;OAIG;WACW,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WA0BzE,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WAQnF,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WAc5D,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WAY3D,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WAK9D,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WAkBtD,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WAI9E,4BAA4B,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;WAKxE,oCAAoC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAG9F"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Disposable } from '../utils/Disposable';
|
|
2
|
+
import type { FigCharacter, FigFontHeader, FigHorizontalLayout, FigRenderPlan, FigTextOptions, FigTextResult, FigVerticalLayout } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Parsed FIGfont resource used by `figText()` rendering.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TextmodeFigFont extends Disposable {
|
|
7
|
+
private readonly _name;
|
|
8
|
+
private readonly _header;
|
|
9
|
+
private readonly _characters;
|
|
10
|
+
private readonly _layoutEngine;
|
|
11
|
+
private constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Load a FIGfont from a URL or path.
|
|
14
|
+
*
|
|
15
|
+
* @param source URL or relative path to a `.flf` file.
|
|
16
|
+
* @returns A parsed FIGfont instance.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
static _fromURL(source: string | URL): Promise<TextmodeFigFont>;
|
|
21
|
+
/**
|
|
22
|
+
* Parse a FIGfont from a raw `.flf` string.
|
|
23
|
+
*
|
|
24
|
+
* @param name Human-readable font name.
|
|
25
|
+
* @param data Raw `.flf` contents.
|
|
26
|
+
* @returns A parsed FIGfont instance.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
static _fromString(name: string, data: string): TextmodeFigFont;
|
|
31
|
+
/**
|
|
32
|
+
* Look up a FIGcharacter by Unicode code point or by the first character in a string.
|
|
33
|
+
*
|
|
34
|
+
* @param value Unicode code point or string to resolve.
|
|
35
|
+
* @returns The matching FIGcharacter, if present.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* {@includeCode ../../examples/TextmodeFigFont/getCharacter/sketch.js}
|
|
39
|
+
*/
|
|
40
|
+
getCharacter(value: number | string): FigCharacter | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Plan a string into positioned FIGlet cells and logical lines.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* {@includeCode ../../examples/TextmodeFigFont/planText/sketch.js}
|
|
46
|
+
*/
|
|
47
|
+
planText(text: string, options?: FigTextOptions): FigRenderPlan;
|
|
48
|
+
/**
|
|
49
|
+
* Render a string into a FIGlet sub-character grid.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* {@includeCode ../../examples/TextmodeFigFont/renderText/sketch.js}
|
|
53
|
+
*/
|
|
54
|
+
renderText(text: string, options?: FigTextOptions): FigTextResult;
|
|
55
|
+
/**
|
|
56
|
+
* Measure rendered FIGlet text without drawing it.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* {@includeCode ../../examples/TextmodeFigFont/measureText/sketch.js}
|
|
60
|
+
*/
|
|
61
|
+
measureText(text: string, options?: FigTextOptions): {
|
|
62
|
+
cols: number;
|
|
63
|
+
rows: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The display name associated with this FIGfont.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* {@includeCode ../../examples/TextmodeFigFont/name/sketch.js}
|
|
70
|
+
*/
|
|
71
|
+
get name(): string;
|
|
72
|
+
/**
|
|
73
|
+
* The parsed FIGfont header metadata.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* {@includeCode ../../examples/TextmodeFigFont/header/sketch.js}
|
|
77
|
+
*/
|
|
78
|
+
get header(): FigFontHeader;
|
|
79
|
+
/**
|
|
80
|
+
* Parsed FIGcharacters keyed by Unicode code point.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* {@includeCode ../../examples/TextmodeFigFont/characters/sketch.js}
|
|
84
|
+
*/
|
|
85
|
+
get characters(): Map<number, FigCharacter>;
|
|
86
|
+
/**
|
|
87
|
+
* Hardblank character declared by the font.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* {@includeCode ../../examples/TextmodeFigFont/hardblank/sketch.js}
|
|
91
|
+
*/
|
|
92
|
+
get hardblank(): string;
|
|
93
|
+
/**
|
|
94
|
+
* Number of rows in each FIGcharacter.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* {@includeCode ../../examples/TextmodeFigFont/height/sketch.js}
|
|
98
|
+
*/
|
|
99
|
+
get height(): number;
|
|
100
|
+
/**
|
|
101
|
+
* Baseline row declared by the font.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* {@includeCode ../../examples/TextmodeFigFont/baseline/sketch.js}
|
|
105
|
+
*/
|
|
106
|
+
get baseline(): number;
|
|
107
|
+
/**
|
|
108
|
+
* Default horizontal layout implied by the header metadata.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* {@includeCode ../../examples/TextmodeFigFont/defaultLayout/sketch.js}
|
|
112
|
+
*/
|
|
113
|
+
get defaultLayout(): FigHorizontalLayout;
|
|
114
|
+
/**
|
|
115
|
+
* Default print direction implied by the FIGfont header metadata.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* {@includeCode ../../examples/TextmodeFigFont/defaultPrintDirection/sketch.js}
|
|
119
|
+
*/
|
|
120
|
+
get defaultPrintDirection(): 'ltr' | 'rtl';
|
|
121
|
+
/**
|
|
122
|
+
* Default vertical layout implied by the FIGfont header metadata.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* {@includeCode ../../examples/TextmodeFigFont/defaultVerticalLayout/sketch.js}
|
|
126
|
+
*/
|
|
127
|
+
get defaultVerticalLayout(): FigVerticalLayout;
|
|
128
|
+
private static _resolveName;
|
|
129
|
+
private _splitInputLines;
|
|
130
|
+
private _applyDirectionToInputLine;
|
|
131
|
+
private _resolveCharacters;
|
|
132
|
+
private _wrapInputLine;
|
|
133
|
+
private _wrapInputLineByWord;
|
|
134
|
+
private _wrapInputLineByCharacter;
|
|
135
|
+
private _measureInputLine;
|
|
136
|
+
private _tokenizeByWhitespace;
|
|
137
|
+
private _resolveDirection;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=TextmodeFigFont.d.ts.map
|
|
@@ -0,0 +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;;GAEG;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;;;;;;;;OAQG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS;IAUrE;;;;;OAKG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa;IA8B1E;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa;IAe5E;;;;;OAKG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAK9F;;;;;OAKG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,IAAI,MAAM,IAAI,aAAa,CAI1B;IAED;;;;;OAKG;IACH,IAAI,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAI1C;IAED;;;;;OAKG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;OAKG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;OAKG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;;;OAKG;IACH,IAAI,aAAa,IAAI,mBAAmB,CAkBvC;IAED;;;;;OAKG;IACH,IAAI,qBAAqB,IAAI,KAAK,GAAG,KAAK,CAEzC;IAED;;;;;OAKG;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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { FigFontParser } from './FigFontParser';
|
|
2
|
+
export { FigLayoutEngine } from './FigLayoutEngine';
|
|
3
|
+
export { FigSmushRules } from './FigSmushRules';
|
|
4
|
+
export { TextmodeFigFont } from './TextmodeFigFont';
|
|
5
|
+
export type { FigCharacter, FigFontHeader, FigHorizontalLayout, FigPrintDirection, FigRenderCell, FigRenderLine, FigRenderPlan, FigTextAlign, FigTextBaseline, FigTextCellContext, FigTextColorResolver, FigTextColorValue, FigTextOptions, FigTextResult, FigVerticalLayout, FigWrapMode, ParsedFigFontData, } from './types';
|
|
6
|
+
export { FIGFONT_REQUIRED_CODEPOINTS } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/figfont/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,YAAY,EACX,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,iBAAiB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { TextmodeColor } from 'textmode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Required FIGfont character order defined by the FIGfont v2 spec:
|
|
4
|
+
* ASCII 32-126 followed by 7 German characters.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const FIGFONT_REQUIRED_CODEPOINTS: readonly number[];
|
|
9
|
+
/**
|
|
10
|
+
* Parsed FIGfont header metadata from the `.flf` header line.
|
|
11
|
+
*/
|
|
12
|
+
export interface FigFontHeader {
|
|
13
|
+
/** Always `flf2a` for supported FIGfont v2 files. */
|
|
14
|
+
signature: string;
|
|
15
|
+
/** Hardblank character used by the font. */
|
|
16
|
+
hardblank: string;
|
|
17
|
+
/** Number of rows in every FIGcharacter. */
|
|
18
|
+
height: number;
|
|
19
|
+
/** Baseline row reported by the font. */
|
|
20
|
+
baseline: number;
|
|
21
|
+
/** Maximum line length declared by the font. */
|
|
22
|
+
maxLength: number;
|
|
23
|
+
/** Legacy horizontal layout bitfield. */
|
|
24
|
+
oldLayout: number;
|
|
25
|
+
/** Number of comment lines immediately following the header. */
|
|
26
|
+
commentLines: number;
|
|
27
|
+
/** Font print direction: `0` left-to-right, `1` right-to-left. */
|
|
28
|
+
printDirection: number;
|
|
29
|
+
/** Full FIGfont layout flags when present. */
|
|
30
|
+
fullLayout: number;
|
|
31
|
+
/** Number of code-tagged characters declared by the font. */
|
|
32
|
+
codetagCount: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A single parsed FIGcharacter from a FIGfont.
|
|
36
|
+
*/
|
|
37
|
+
export interface FigCharacter {
|
|
38
|
+
/** Unicode code point represented by the FIGcharacter. */
|
|
39
|
+
code: number;
|
|
40
|
+
/** Raw FIGcharacter rows with endmarks removed. */
|
|
41
|
+
lines: string[];
|
|
42
|
+
/** Maximum row width after endmark removal. */
|
|
43
|
+
width: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Complete parsed output from a FIGfont file.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export interface ParsedFigFontData {
|
|
51
|
+
header: FigFontHeader;
|
|
52
|
+
characters: Map<number, FigCharacter>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Supported horizontal layout modes for FIGlet rendering.
|
|
56
|
+
*/
|
|
57
|
+
export type FigHorizontalLayout = 'full' | 'fitted' | 'smushed';
|
|
58
|
+
/**
|
|
59
|
+
* Supported vertical layout modes for multi-line FIGlet rendering.
|
|
60
|
+
*/
|
|
61
|
+
export type FigVerticalLayout = 'full' | 'fitted' | 'smushed';
|
|
62
|
+
/**
|
|
63
|
+
* Supported wrap modes for FIGlet text layout.
|
|
64
|
+
*/
|
|
65
|
+
export type FigWrapMode = 'none' | 'word' | 'char';
|
|
66
|
+
/**
|
|
67
|
+
* Supported print directions for FIGlet text layout.
|
|
68
|
+
*/
|
|
69
|
+
export type FigPrintDirection = 'font' | 'ltr' | 'rtl';
|
|
70
|
+
/**
|
|
71
|
+
* Accepted color input for per-cell FIGlet styling.
|
|
72
|
+
*/
|
|
73
|
+
export type FigTextColorValue = number | string | TextmodeColor | [number, number, number] | [number, number, number, number];
|
|
74
|
+
/**
|
|
75
|
+
* Public cell metadata exposed to FIGlet styling callbacks.
|
|
76
|
+
*/
|
|
77
|
+
export interface FigTextCellContext {
|
|
78
|
+
/** Final drawable sub-character after layout normalization. */
|
|
79
|
+
char: string;
|
|
80
|
+
/** Absolute column within the rendered result. */
|
|
81
|
+
col: number;
|
|
82
|
+
/** Absolute row within the rendered result. */
|
|
83
|
+
row: number;
|
|
84
|
+
/** Zero-based index into the original input string's character sequence. */
|
|
85
|
+
inputIndex: number;
|
|
86
|
+
/** Original input character that produced this cell. */
|
|
87
|
+
inputChar: string;
|
|
88
|
+
/** FIGcharacter code used to produce this cell. */
|
|
89
|
+
figCharCode: number;
|
|
90
|
+
/** Row within the source FIGcharacter. */
|
|
91
|
+
subRow: number;
|
|
92
|
+
/** Column within the source FIGcharacter. */
|
|
93
|
+
subCol: number;
|
|
94
|
+
/** Logical rendered line index after explicit newline splitting. */
|
|
95
|
+
lineIndex: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Resolver for per-cell FIGlet colors.
|
|
99
|
+
*/
|
|
100
|
+
export type FigTextColorResolver = FigTextColorValue | ((cell: FigTextCellContext) => FigTextColorValue | undefined);
|
|
101
|
+
/**
|
|
102
|
+
* Layout options for rendering FIGlet text.
|
|
103
|
+
*/
|
|
104
|
+
export interface FigTextOptions {
|
|
105
|
+
/** Override the font's default horizontal layout. */
|
|
106
|
+
horizontalLayout?: FigHorizontalLayout;
|
|
107
|
+
/** Override the vertical composition mode for multi-line FIGlet layout. */
|
|
108
|
+
verticalLayout?: FigVerticalLayout;
|
|
109
|
+
/** Override the effective print direction for layout. */
|
|
110
|
+
direction?: FigPrintDirection;
|
|
111
|
+
/** Optional wrap strategy for multi-line layout. */
|
|
112
|
+
wrap?: FigWrapMode;
|
|
113
|
+
/** Maximum rendered columns per logical line before wrapping occurs. */
|
|
114
|
+
maxCols?: number;
|
|
115
|
+
/** Override or resolve the foreground color for each rendered FIGlet cell. */
|
|
116
|
+
charColor?: FigTextColorResolver;
|
|
117
|
+
/** Override or resolve the background color for each rendered FIGlet cell. */
|
|
118
|
+
cellColor?: FigTextColorResolver;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A single drawable cell produced by FIGlet layout.
|
|
122
|
+
*
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
export type FigRenderCell = FigTextCellContext;
|
|
126
|
+
/**
|
|
127
|
+
* A single logical line within a planned FIGlet render.
|
|
128
|
+
*
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
export interface FigRenderLine {
|
|
132
|
+
/** Logical line index. */
|
|
133
|
+
lineIndex: number;
|
|
134
|
+
/** Drawable cells in row-major order. */
|
|
135
|
+
cells: FigRenderCell[];
|
|
136
|
+
/** Width of the line in grid cells, including blanks. */
|
|
137
|
+
cols: number;
|
|
138
|
+
/** Height of the line in grid cells. */
|
|
139
|
+
rows: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Full internal render plan for FIGlet text.
|
|
143
|
+
*
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
export interface FigRenderPlan {
|
|
147
|
+
/** All drawable cells in row-major order. */
|
|
148
|
+
cells: FigRenderCell[];
|
|
149
|
+
/** Logical lines included in the rendered output. */
|
|
150
|
+
lines: FigRenderLine[];
|
|
151
|
+
/** Total rendered width in grid cells. */
|
|
152
|
+
cols: number;
|
|
153
|
+
/** Total rendered height in grid cells. */
|
|
154
|
+
rows: number;
|
|
155
|
+
/** Effective print direction for the plan. */
|
|
156
|
+
direction: 'ltr' | 'rtl';
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Rendered FIGlet text as a 2D sub-character grid.
|
|
160
|
+
*
|
|
161
|
+
* @internal
|
|
162
|
+
*/
|
|
163
|
+
export interface FigTextResult {
|
|
164
|
+
/** Grid rows made up of single-character cells. */
|
|
165
|
+
grid: string[][];
|
|
166
|
+
/** Number of occupied columns in the rendered grid. */
|
|
167
|
+
cols: number;
|
|
168
|
+
/** Number of rows in the rendered grid. */
|
|
169
|
+
rows: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Horizontal alignment options for `figText()` placement.
|
|
173
|
+
*/
|
|
174
|
+
export type FigTextAlign = 'left' | 'center' | 'right';
|
|
175
|
+
/**
|
|
176
|
+
* Vertical alignment options for `figText()` placement.
|
|
177
|
+
*/
|
|
178
|
+
export type FigTextBaseline = 'top' | 'center' | 'bottom' | 'baseline';
|
|
179
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/figfont/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,MAAM,EASxD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,cAAc,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+CAA+C;IAC/C,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;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAC1B,MAAM,GACN,MAAM,GACN,aAAa,GACb,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACxB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG,CAAC,CAAC,IAAI,EAAE,kBAAkB,KAAK,iBAAiB,GAAG,SAAS,CAAC,CAAC;AAErH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;IACvC,2EAA2E;IAC3E,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,yDAAyD;IACzD,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,oDAAoD;IACpD,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,8EAA8E;IAC9E,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;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,iBAAiB,CAAC;AAKzB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AACpE,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TextmodePlugin } from 'textmode.js/plugins';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin entrypoint for the FIGlet add-on.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* {@includeCode ../../examples/FigletPlugin/init/sketch.js}
|
|
7
|
+
*/
|
|
8
|
+
export declare const FigletPlugin: TextmodePlugin;
|
|
9
|
+
//# sourceMappingURL=FigletPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigletPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugin/FigletPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AAK7E;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,cAW1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Textmodifier } from 'textmode.js';
|
|
2
|
+
import type { FigTextAlign, FigTextBaseline } from '../figfont';
|
|
3
|
+
import type { TextmodeFigFont } from '../figfont';
|
|
4
|
+
/**
|
|
5
|
+
* Symbol used to store per-instance FIGlet plugin state.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FIGLET_STATE_KEY: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Per-textmodifier FIGlet plugin state.
|
|
10
|
+
*/
|
|
11
|
+
export interface FigletPluginState {
|
|
12
|
+
activeFont?: TextmodeFigFont;
|
|
13
|
+
align: FigTextAlign;
|
|
14
|
+
baseline: FigTextBaseline;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the FIGlet plugin state for a Textmodifier instance, creating it when missing.
|
|
18
|
+
*
|
|
19
|
+
* @param textmodifier Target instance.
|
|
20
|
+
* @returns Mutable FIGlet plugin state for that instance.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getFigletState(textmodifier: Textmodifier): FigletPluginState;
|
|
23
|
+
/**
|
|
24
|
+
* Remove the FIGlet plugin state from a Textmodifier instance.
|
|
25
|
+
*
|
|
26
|
+
* @param textmodifier Target instance.
|
|
27
|
+
*/
|
|
28
|
+
export declare function clearFigletState(textmodifier: Textmodifier): void;
|
|
29
|
+
//# sourceMappingURL=figletState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figletState.d.ts","sourceRoot":"","sources":["../../../src/state/figletState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAAsC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,YAAY,GAAG,iBAAiB,CAc5E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEjE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for objects that support explicit disposal.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Disposable {
|
|
5
|
+
private readonly _onDisposeCallbacks;
|
|
6
|
+
/**
|
|
7
|
+
* Register a callback to run when the resource is disposed.
|
|
8
|
+
*
|
|
9
|
+
* @param callback Callback to run on disposal.
|
|
10
|
+
*/
|
|
11
|
+
_addOnDispose(callback: () => void): void;
|
|
12
|
+
/**
|
|
13
|
+
* Dispose the resource and invoke all registered callbacks.
|
|
14
|
+
*/
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Disposable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../../src/utils/Disposable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAyB;IAE7D;;;;OAIG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIhD;;OAEG;IACI,OAAO,IAAI,IAAI;CAOtB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "textmode.figlet.js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "FIGlet font add-on for textmode.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/types/index.d.ts",
|
|
7
|
+
"main": "./dist/textmode.figlet.umd.js",
|
|
8
|
+
"module": "./dist/textmode.figlet.esm.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/textmode.figlet.esm.js",
|
|
13
|
+
"require": "./dist/textmode.figlet.umd.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./dist/textmode.figlet.esm.js",
|
|
18
|
+
"./dist/textmode.figlet.umd.js"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite --port 5175 --host",
|
|
22
|
+
"build": "vite build && tsc -p tsconfig.json",
|
|
23
|
+
"check": "npm run format:check && npm run lint && npm run lint:md && npm run typecheck && npm run check:api-docs && npm run test && npm run build",
|
|
24
|
+
"check:api-docs": "node ./scripts/check-public-api-docs.mjs --include-accessors",
|
|
25
|
+
"dev:docs": "typedoc --watch",
|
|
26
|
+
"build:docs": "typedoc",
|
|
27
|
+
"preview": "vite preview",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest",
|
|
30
|
+
"test:ui": "vitest --ui",
|
|
31
|
+
"test:coverage": "vitest --coverage",
|
|
32
|
+
"test:unit": "vitest run --project unit",
|
|
33
|
+
"test:integration": "vitest run --project integration",
|
|
34
|
+
"test:contracts": "vitest run --project contracts",
|
|
35
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"*.{js,ts,json,md}\"",
|
|
36
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"*.{js,ts,json,md}\"",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"lint:md": "markdownlint-cli2 --no-globs README.md",
|
|
39
|
+
"lint:md:fix": "markdownlint-cli2 --fix --no-globs README.md",
|
|
40
|
+
"lint": "eslint src --config eslint.config.js",
|
|
41
|
+
"prepare": "husky"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"textmode.js": ">=0.11.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@commitlint/cli": "^20.3.1",
|
|
48
|
+
"@commitlint/config-conventional": "^20.3.1",
|
|
49
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
50
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
51
|
+
"@semantic-release/exec": "^7.1.0",
|
|
52
|
+
"@semantic-release/github": "^11.0.6",
|
|
53
|
+
"@semantic-release/npm": "^12.0.2",
|
|
54
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
55
|
+
"@types/node": "^24.0.13",
|
|
56
|
+
"@vitest/ui": "^3.1.2",
|
|
57
|
+
"eslint": "^9.39.2",
|
|
58
|
+
"eslint-plugin-jsdoc": "^62.4.1",
|
|
59
|
+
"globals": "^17.1.0",
|
|
60
|
+
"husky": "^9.1.7",
|
|
61
|
+
"jsdom": "^26.1.0",
|
|
62
|
+
"lint-staged": "^16.4.0",
|
|
63
|
+
"markdownlint-cli2": "^0.20.0",
|
|
64
|
+
"prettier": "^3.7.4",
|
|
65
|
+
"semantic-release": "^24.2.9",
|
|
66
|
+
"textmode.js": "^0.11.0",
|
|
67
|
+
"typedoc": "^0.28.13",
|
|
68
|
+
"typedoc-plugin-frontmatter": "^1.3.1",
|
|
69
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
70
|
+
"typedoc-vitepress-theme": "^1.1.2",
|
|
71
|
+
"typescript": "^5.9.2",
|
|
72
|
+
"typescript-eslint": "^8.53.1",
|
|
73
|
+
"vite": "^6.3.4",
|
|
74
|
+
"vitest": "^3.1.2"
|
|
75
|
+
},
|
|
76
|
+
"keywords": [
|
|
77
|
+
"ascii",
|
|
78
|
+
"figlet",
|
|
79
|
+
"figfont",
|
|
80
|
+
"textmode",
|
|
81
|
+
"creative-coding",
|
|
82
|
+
"graphics"
|
|
83
|
+
],
|
|
84
|
+
"author": "humanbydefinition <hello@textmode.art> (https://code.textmode.art)",
|
|
85
|
+
"license": "MIT",
|
|
86
|
+
"homepage": "https://code.textmode.art",
|
|
87
|
+
"lint-staged": {
|
|
88
|
+
"src/**/*.{ts,js}": "prettier --write"
|
|
89
|
+
},
|
|
90
|
+
"files": [
|
|
91
|
+
"dist"
|
|
92
|
+
],
|
|
93
|
+
"repository": {
|
|
94
|
+
"type": "git",
|
|
95
|
+
"url": "git+https://github.com/humanbydefinition/textmode.figlet.js.git"
|
|
96
|
+
},
|
|
97
|
+
"bugs": {
|
|
98
|
+
"url": "https://github.com/humanbydefinition/textmode.figlet.js/issues"
|
|
99
|
+
}
|
|
100
|
+
}
|