tinky-figures 0.1.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/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # tinky-figures
2
+
3
+ Unicode symbols with ASCII fallbacks for tinky applications - matching the figures npm package character set.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install tinky-figures
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { useFigures } from "tinky-figures";
15
+
16
+ function MyComponent() {
17
+ const figures = useFigures();
18
+
19
+ return (
20
+ <>
21
+ <text>{figures.tick} Success!</text>
22
+ <text>{figures.arrowRight} Next step</text>
23
+ </>
24
+ );
25
+ }
26
+ ```
27
+
28
+ ## Features
29
+
30
+ - ✨ **Full figures compatibility** - Uses the same character set as sindresorhus/figures
31
+ - 🔧 **Automatic Unicode detection** - Detects terminal Unicode support via tinky env
32
+ - 🎨 **ASCII fallbacks** - Gracefully degrades to ASCII when Unicode isn't supported
33
+ - ⚛️ **React Hook API** - Clean `useFigures` hook designed for tinky applications
34
+
35
+ ## Unicode Detection
36
+
37
+ The hook automatically detects Unicode support based on the `env` object from tinky:
38
+
39
+ 1. **Explicit `TINKY_UNICODE` flag** - If `env.TINKY_UNICODE` is set to `'true'` or `'false'`, uses that value
40
+ 2. **CI environment** - Disables Unicode in CI environments (checks `env.CI`)
41
+ 3. **Terminal type** - Checks `env.TERM` for unsupported terminals (e.g., `'dumb'`)
42
+ 4. **Platform** - Windows CMD and older PowerShell don't support Unicode well unless a modern terminal emulator is detected via `TERM`.
43
+
44
+ ## API
45
+
46
+ ### `useFigures()`
47
+
48
+ React hook that returns appropriate figures based on the environment from Tinky's `useApp` context.
49
+
50
+ **Returns:** `FiguresMap` - Object containing all figure characters
51
+
52
+ ### `isUnicodeSupported(platform?, env?)`
53
+
54
+ Detects if the current environment supports Unicode.
55
+
56
+ - **platform** (optional): Platform string (default: `process.platform`)
57
+ - **env** (optional): Environment variables object (default: `process.env`)
58
+ - **Returns:** `boolean` - `true` if Unicode is supported, `false` otherwise
59
+
60
+ ### `unicodeFigures`
61
+
62
+ Direct access to the full Unicode symbol map (`FiguresMap`).
63
+
64
+ ### `asciiFigures`
65
+
66
+ Direct access to the ASCII fallback symbol map (`FiguresMap`).
67
+
68
+ ## License
69
+
70
+ MIT
@@ -0,0 +1,9 @@
1
+ import { FiguresMap } from "../types/figures";
2
+ /**
3
+ * Fallback character set for environments that do not support full Unicode.
4
+ *
5
+ * These symbols are chosen to be compatible with most terminals effortlessly,
6
+ * including legacy Windows consoles, or use common extended ASCII/CP437 characters
7
+ * where safe.
8
+ */
9
+ export declare const asciiFigures: FiguresMap;
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Fallback character set for environments that do not support full Unicode.
3
+ *
4
+ * These symbols are chosen to be compatible with most terminals effortlessly,
5
+ * including legacy Windows consoles, or use common extended ASCII/CP437 characters
6
+ * where safe.
7
+ */
8
+ export const asciiFigures = {
9
+ almostEqual: "≈",
10
+ arrowDown: "↓",
11
+ arrowLeft: "←",
12
+ arrowLeftRight: "↔",
13
+ arrowRight: "→",
14
+ arrowUp: "↑",
15
+ arrowUpLeft: "\\",
16
+ arrowUpRight: "/",
17
+ arrowDownLeft: "/",
18
+ arrowDownRight: "\\",
19
+ arrowUpDown: "↕",
20
+ bullet: "●",
21
+ checkboxCircleOff: "( )",
22
+ checkboxCircleOn: "(×)",
23
+ checkboxOff: "[ ]",
24
+ checkboxOn: "[×]",
25
+ circle: "( )",
26
+ circleCircle: "(○)",
27
+ circleCross: "(×)",
28
+ circleDotted: "( )",
29
+ circleDouble: "( )",
30
+ circleFilled: "(*)",
31
+ circlePipe: "(│)",
32
+ circleQuestion: "(?)",
33
+ circleQuestionMark: "(?)",
34
+ cross: "×",
35
+ dot: "․",
36
+ ellipsis: "…",
37
+ fiveEighths: "⅝",
38
+ fiveSixths: "⅚",
39
+ fourFifths: "⅘",
40
+ greaterOrEqual: "≥",
41
+ hamburger: "≡",
42
+ heart: "♥",
43
+ home: "⌂",
44
+ identical: "≡",
45
+ infinity: "∞",
46
+ info: "i",
47
+ lessOrEqual: "≤",
48
+ line: "─",
49
+ lineBackslash: "╲",
50
+ lineBold: "━",
51
+ lineCross: "╳",
52
+ lineDashed0: "┄",
53
+ lineDashed1: "┅",
54
+ lineDashed10: "╼",
55
+ lineDashed11: "╾",
56
+ lineDashed12: "−",
57
+ lineDashed13: "–",
58
+ lineDashed14: "‐",
59
+ lineDashed15: "⁃",
60
+ lineDashed2: "┈",
61
+ lineDashed3: "┉",
62
+ lineDashed4: "╌",
63
+ lineDashed5: "╍",
64
+ lineDashed6: "╴",
65
+ lineDashed7: "╶",
66
+ lineDashed8: "╸",
67
+ lineDashed9: "╺",
68
+ lineDouble: "═",
69
+ lineDownBoldLeft: "┒",
70
+ lineDownBoldLeftBold: "┓",
71
+ lineDownBoldLeftBoldRight: "┱",
72
+ lineDownBoldLeftBoldRightBold: "┳",
73
+ lineDownBoldLeftRight: "┰",
74
+ lineDownBoldLeftRightBold: "┲",
75
+ lineDownBoldRight: "┎",
76
+ lineDownBoldRightBold: "┏",
77
+ lineDownDoubleLeft: "╖",
78
+ lineDownDoubleLeftDouble: "╗",
79
+ lineDownDoubleLeftDoubleRightDouble: "╦",
80
+ lineDownDoubleLeftRight: "╥",
81
+ lineDownDoubleRight: "╓",
82
+ lineDownDoubleRightDouble: "╔",
83
+ lineDownLeft: "┐",
84
+ lineDownLeftArc: "╮",
85
+ lineDownLeftBold: "┑",
86
+ lineDownLeftBoldRight: "┭",
87
+ lineDownLeftBoldRightBold: "┯",
88
+ lineDownLeftDouble: "╕",
89
+ lineDownLeftDoubleRightDouble: "╤",
90
+ lineDownLeftRight: "┬",
91
+ lineDownLeftRightBold: "┮",
92
+ lineDownRight: "┌",
93
+ lineDownRightArc: "╭",
94
+ lineDownRightBold: "┍",
95
+ lineDownRightDouble: "╒",
96
+ lineSlash: "╱",
97
+ lineUpBoldDownBoldLeft: "┨",
98
+ lineUpBoldDownBoldLeftBold: "┫",
99
+ lineUpBoldDownBoldLeftBoldRight: "╉",
100
+ lineUpBoldDownBoldLeftBoldRightBold: "╋",
101
+ lineUpBoldDownBoldLeftRight: "╂",
102
+ lineUpBoldDownBoldLeftRightBold: "╊",
103
+ lineUpBoldDownBoldRight: "┠",
104
+ lineUpBoldDownBoldRightBold: "┣",
105
+ lineUpBoldDownLeft: "┦",
106
+ lineUpBoldDownLeftBold: "┩",
107
+ lineUpBoldDownLeftBoldRight: "╃",
108
+ lineUpBoldDownLeftBoldRightBold: "╇",
109
+ lineUpBoldDownLeftRight: "╀",
110
+ lineUpBoldDownLeftRightBold: "╄",
111
+ lineUpBoldDownRight: "┞",
112
+ lineUpBoldDownRightBold: "┡",
113
+ lineUpBoldLeft: "┚",
114
+ lineUpBoldLeftBold: "┛",
115
+ lineUpBoldLeftBoldRight: "┹",
116
+ lineUpBoldLeftBoldRightBold: "┻",
117
+ lineUpBoldLeftRight: "┸",
118
+ lineUpBoldLeftRightBold: "┺",
119
+ lineUpBoldRight: "┖",
120
+ lineUpBoldRightBold: "┗",
121
+ lineUpDoubleDownDoubleLeft: "╢",
122
+ lineUpDoubleDownDoubleLeftDouble: "╣",
123
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
124
+ lineUpDoubleDownDoubleLeftRight: "╫",
125
+ lineUpDoubleDownDoubleRight: "╟",
126
+ lineUpDoubleDownDoubleRightDouble: "╠",
127
+ lineUpDoubleLeft: "╜",
128
+ lineUpDoubleLeftDouble: "╝",
129
+ lineUpDoubleLeftDoubleRightDouble: "╩",
130
+ lineUpDoubleLeftRight: "╨",
131
+ lineUpDoubleRight: "╙",
132
+ lineUpDoubleRightDouble: "╚",
133
+ lineUpDownBoldLeft: "┧",
134
+ lineUpDownBoldLeftBold: "┪",
135
+ lineUpDownBoldLeftBoldRight: "╅",
136
+ lineUpDownBoldLeftBoldRightBold: "╈",
137
+ lineUpDownBoldLeftRight: "╁",
138
+ lineUpDownBoldLeftRightBold: "╆",
139
+ lineUpDownBoldRight: "┟",
140
+ lineUpDownBoldRightBold: "┢",
141
+ lineUpDownLeft: "┤",
142
+ lineUpDownLeftBold: "┥",
143
+ lineUpDownLeftBoldRight: "┽",
144
+ lineUpDownLeftBoldRightBold: "┿",
145
+ lineUpDownLeftDouble: "╡",
146
+ lineUpDownLeftDoubleRightDouble: "╪",
147
+ lineUpDownLeftRight: "┼",
148
+ lineUpDownLeftRightBold: "┾",
149
+ lineUpDownRight: "├",
150
+ lineUpDownRightBold: "┝",
151
+ lineUpDownRightDouble: "╞",
152
+ lineUpLeft: "┘",
153
+ lineUpLeftArc: "╯",
154
+ lineUpLeftBold: "┙",
155
+ lineUpLeftBoldRight: "┵",
156
+ lineUpLeftBoldRightBold: "┷",
157
+ lineUpLeftDouble: "╛",
158
+ lineUpLeftDoubleRightDouble: "╧",
159
+ lineUpLeftRight: "┴",
160
+ lineUpLeftRightBold: "┶",
161
+ lineUpRight: "└",
162
+ lineUpRightArc: "╰",
163
+ lineUpRightBold: "┕",
164
+ lineUpRightDouble: "╘",
165
+ lineVertical: "│",
166
+ lineVerticalBold: "┃",
167
+ lineVerticalDashed0: "┆",
168
+ lineVerticalDashed1: "┇",
169
+ lineVerticalDashed10: "╽",
170
+ lineVerticalDashed11: "╿",
171
+ lineVerticalDashed2: "┊",
172
+ lineVerticalDashed3: "┋",
173
+ lineVerticalDashed4: "╎",
174
+ lineVerticalDashed5: "╏",
175
+ lineVerticalDashed6: "╵",
176
+ lineVerticalDashed7: "╷",
177
+ lineVerticalDashed8: "╹",
178
+ lineVerticalDashed9: "╻",
179
+ lineVerticalDouble: "║",
180
+ lozenge: "♦",
181
+ lozengeOutline: "◊",
182
+ musicNote: "♪",
183
+ musicNoteBeamed: "♫",
184
+ mustache: "┌─┐",
185
+ nodejs: "♦",
186
+ notEqual: "≠",
187
+ oneEighth: "⅛",
188
+ oneFifth: "⅕",
189
+ oneHalf: "½",
190
+ oneNinth: "1/9",
191
+ oneQuarter: "¼",
192
+ oneSeventh: "1/7",
193
+ oneSixth: "⅙",
194
+ oneTenth: "1/10",
195
+ oneThird: "⅓",
196
+ play: "►",
197
+ pointer: ">",
198
+ pointerSmall: "›",
199
+ questionMarkPrefix: "(?)",
200
+ radioOff: "( )",
201
+ radioOn: "(*)",
202
+ sevenEighths: "⅞",
203
+ smiley: "☺",
204
+ square: "█",
205
+ squareBottom: "▄",
206
+ squareCenter: "■",
207
+ squareDarkShade: "▓",
208
+ squareLeft: "▌",
209
+ squareLightShade: "░",
210
+ squareMediumShade: "▒",
211
+ squareRight: "▐",
212
+ squareSmall: "□",
213
+ squareSmallFilled: "■",
214
+ squareTop: "▀",
215
+ star: "✶",
216
+ subscriptEight: "₈",
217
+ subscriptFive: "₅",
218
+ subscriptFour: "₄",
219
+ subscriptNine: "₉",
220
+ subscriptOne: "₁",
221
+ subscriptSeven: "₇",
222
+ subscriptSix: "₆",
223
+ subscriptThree: "₃",
224
+ subscriptTwo: "₂",
225
+ subscriptZero: "₀",
226
+ threeEighths: "⅜",
227
+ threeFifths: "⅗",
228
+ threeQuarters: "¾",
229
+ tick: "√",
230
+ triangleDown: "▼",
231
+ triangleDownSmall: "▾",
232
+ triangleLeft: "◄",
233
+ triangleLeftSmall: "◂",
234
+ triangleRight: "►",
235
+ triangleRightSmall: "▸",
236
+ triangleUp: "▲",
237
+ triangleUpOutline: "∆",
238
+ triangleUpSmall: "▴",
239
+ topLeftCorner: "┌",
240
+ topRightCorner: "┐",
241
+ bottomLeftCorner: "└",
242
+ bottomRightCorner: "┘",
243
+ teeUp: "┴",
244
+ teeDown: "┬",
245
+ teeLeft: "┤",
246
+ teeRight: "├",
247
+ twoFifths: "⅖",
248
+ twoThirds: "⅔",
249
+ warning: "‼",
250
+ };
@@ -0,0 +1,2 @@
1
+ export { unicodeFigures } from "./unicode";
2
+ export { asciiFigures } from "./ascii";
@@ -0,0 +1,2 @@
1
+ export { unicodeFigures } from "./unicode";
2
+ export { asciiFigures } from "./ascii";
@@ -0,0 +1,8 @@
1
+ import { FiguresMap } from "../types/figures";
2
+ /**
3
+ * Full Unicode character set.
4
+ *
5
+ * These symbols utilize a wide range of Unicode characters for rich CLI output.
6
+ * Only use this set when the environment is known to support Unicode.
7
+ */
8
+ export declare const unicodeFigures: FiguresMap;
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Full Unicode character set.
3
+ *
4
+ * These symbols utilize a wide range of Unicode characters for rich CLI output.
5
+ * Only use this set when the environment is known to support Unicode.
6
+ */
7
+ export const unicodeFigures = {
8
+ almostEqual: "≈",
9
+ arrowDown: "↓",
10
+ arrowLeft: "←",
11
+ arrowLeftRight: "↔",
12
+ arrowRight: "→",
13
+ arrowUp: "↑",
14
+ arrowUpLeft: "↖",
15
+ arrowUpRight: "↗",
16
+ arrowDownLeft: "↙",
17
+ arrowDownRight: "↘",
18
+ arrowUpDown: "↕",
19
+ bullet: "●",
20
+ checkboxCircleOff: "Ⓘ",
21
+ checkboxCircleOn: "ⓧ",
22
+ checkboxOff: "☐",
23
+ checkboxOn: "☒",
24
+ circle: "◯",
25
+ circleCircle: "ⓞ",
26
+ circleCross: "ⓧ",
27
+ circleDotted: "◌",
28
+ circleDouble: "◎",
29
+ circleFilled: "◉",
30
+ circlePipe: "Ⓘ",
31
+ circleQuestion: "❔",
32
+ circleQuestionMark: "(?)",
33
+ cross: "✘",
34
+ dot: "․",
35
+ ellipsis: "…",
36
+ fiveEighths: "⅝",
37
+ fiveSixths: "⅚",
38
+ fourFifths: "⅘",
39
+ greaterOrEqual: "≥",
40
+ hamburger: "☰",
41
+ heart: "♥",
42
+ home: "⌂",
43
+ identical: "≡",
44
+ infinity: "∞",
45
+ info: "ℹ",
46
+ lessOrEqual: "≤",
47
+ line: "─",
48
+ lineBackslash: "╲",
49
+ lineBold: "━",
50
+ lineCross: "╳",
51
+ lineDashed0: "┄",
52
+ lineDashed1: "┅",
53
+ lineDashed10: "╼",
54
+ lineDashed11: "╾",
55
+ lineDashed12: "−",
56
+ lineDashed13: "–",
57
+ lineDashed14: "‐",
58
+ lineDashed15: "⁃",
59
+ lineDashed2: "┈",
60
+ lineDashed3: "┉",
61
+ lineDashed4: "╌",
62
+ lineDashed5: "╍",
63
+ lineDashed6: "╴",
64
+ lineDashed7: "╶",
65
+ lineDashed8: "╸",
66
+ lineDashed9: "╺",
67
+ lineDouble: "═",
68
+ lineDownBoldLeft: "┒",
69
+ lineDownBoldLeftBold: "┓",
70
+ lineDownBoldLeftBoldRight: "┱",
71
+ lineDownBoldLeftBoldRightBold: "┳",
72
+ lineDownBoldLeftRight: "┰",
73
+ lineDownBoldLeftRightBold: "┲",
74
+ lineDownBoldRight: "┎",
75
+ lineDownBoldRightBold: "┏",
76
+ lineDownDoubleLeft: "╖",
77
+ lineDownDoubleLeftDouble: "╗",
78
+ lineDownDoubleLeftDoubleRightDouble: "╦",
79
+ lineDownDoubleLeftRight: "╥",
80
+ lineDownDoubleRight: "╓",
81
+ lineDownDoubleRightDouble: "╔",
82
+ lineDownLeft: "┐",
83
+ lineDownLeftArc: "╮",
84
+ lineDownLeftBold: "┑",
85
+ lineDownLeftBoldRight: "┭",
86
+ lineDownLeftBoldRightBold: "┯",
87
+ lineDownLeftDouble: "╕",
88
+ lineDownLeftDoubleRightDouble: "╤",
89
+ lineDownLeftRight: "┬",
90
+ lineDownLeftRightBold: "┮",
91
+ lineDownRight: "┌",
92
+ lineDownRightArc: "╭",
93
+ lineDownRightBold: "┍",
94
+ lineDownRightDouble: "╒",
95
+ lineSlash: "╱",
96
+ lineUpBoldDownBoldLeft: "┨",
97
+ lineUpBoldDownBoldLeftBold: "┫",
98
+ lineUpBoldDownBoldLeftBoldRight: "╉",
99
+ lineUpBoldDownBoldLeftBoldRightBold: "╋",
100
+ lineUpBoldDownBoldLeftRight: "╂",
101
+ lineUpBoldDownBoldLeftRightBold: "╊",
102
+ lineUpBoldDownBoldRight: "┠",
103
+ lineUpBoldDownBoldRightBold: "┣",
104
+ lineUpBoldDownLeft: "┦",
105
+ lineUpBoldDownLeftBold: "┩",
106
+ lineUpBoldDownLeftBoldRight: "╃",
107
+ lineUpBoldDownLeftBoldRightBold: "╇",
108
+ lineUpBoldDownLeftRight: "╀",
109
+ lineUpBoldDownLeftRightBold: "╄",
110
+ lineUpBoldDownRight: "┞",
111
+ lineUpBoldDownRightBold: "┡",
112
+ lineUpBoldLeft: "┚",
113
+ lineUpBoldLeftBold: "┛",
114
+ lineUpBoldLeftBoldRight: "┹",
115
+ lineUpBoldLeftBoldRightBold: "┻",
116
+ lineUpBoldLeftRight: "┸",
117
+ lineUpBoldLeftRightBold: "┺",
118
+ lineUpBoldRight: "┖",
119
+ lineUpBoldRightBold: "┗",
120
+ lineUpDoubleDownDoubleLeft: "╢",
121
+ lineUpDoubleDownDoubleLeftDouble: "╣",
122
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
123
+ lineUpDoubleDownDoubleLeftRight: "╫",
124
+ lineUpDoubleDownDoubleRight: "╟",
125
+ lineUpDoubleDownDoubleRightDouble: "╠",
126
+ lineUpDoubleLeft: "╜",
127
+ lineUpDoubleLeftDouble: "╝",
128
+ lineUpDoubleLeftDoubleRightDouble: "╩",
129
+ lineUpDoubleLeftRight: "╨",
130
+ lineUpDoubleRight: "╙",
131
+ lineUpDoubleRightDouble: "╚",
132
+ lineUpDownBoldLeft: "┧",
133
+ lineUpDownBoldLeftBold: "┪",
134
+ lineUpDownBoldLeftBoldRight: "╅",
135
+ lineUpDownBoldLeftBoldRightBold: "╈",
136
+ lineUpDownBoldLeftRight: "╁",
137
+ lineUpDownBoldLeftRightBold: "╆",
138
+ lineUpDownBoldRight: "┟",
139
+ lineUpDownBoldRightBold: "┢",
140
+ lineUpDownLeft: "┤",
141
+ lineUpDownLeftBold: "┥",
142
+ lineUpDownLeftBoldRight: "┽",
143
+ lineUpDownLeftBoldRightBold: "┿",
144
+ lineUpDownLeftDouble: "╡",
145
+ lineUpDownLeftDoubleRightDouble: "╪",
146
+ lineUpDownLeftRight: "┼",
147
+ lineUpDownLeftRightBold: "┾",
148
+ lineUpDownRight: "├",
149
+ lineUpDownRightBold: "┝",
150
+ lineUpDownRightDouble: "╞",
151
+ lineUpLeft: "┘",
152
+ lineUpLeftArc: "╯",
153
+ lineUpLeftBold: "┙",
154
+ lineUpLeftBoldRight: "┵",
155
+ lineUpLeftBoldRightBold: "┷",
156
+ lineUpLeftDouble: "╛",
157
+ lineUpLeftDoubleRightDouble: "╧",
158
+ lineUpLeftRight: "┴",
159
+ lineUpLeftRightBold: "┶",
160
+ lineUpRight: "└",
161
+ lineUpRightArc: "╰",
162
+ lineUpRightBold: "┕",
163
+ lineUpRightDouble: "╘",
164
+ lineVertical: "│",
165
+ lineVerticalBold: "┃",
166
+ lineVerticalDashed0: "┆",
167
+ lineVerticalDashed1: "┇",
168
+ lineVerticalDashed10: "╽",
169
+ lineVerticalDashed11: "╿",
170
+ lineVerticalDashed2: "┊",
171
+ lineVerticalDashed3: "┋",
172
+ lineVerticalDashed4: "╎",
173
+ lineVerticalDashed5: "╏",
174
+ lineVerticalDashed6: "╵",
175
+ lineVerticalDashed7: "╷",
176
+ lineVerticalDashed8: "╹",
177
+ lineVerticalDashed9: "╻",
178
+ lineVerticalDouble: "║",
179
+ lozenge: "◆",
180
+ lozengeOutline: "◇",
181
+ musicNote: "♪",
182
+ musicNoteBeamed: "♫",
183
+ mustache: "෴",
184
+ nodejs: "⬢",
185
+ notEqual: "≠",
186
+ oneEighth: "⅛",
187
+ oneFifth: "⅕",
188
+ oneHalf: "½",
189
+ oneNinth: "⅑",
190
+ oneQuarter: "¼",
191
+ oneSeventh: "⅐",
192
+ oneSixth: "⅙",
193
+ oneTenth: "⅒",
194
+ oneThird: "⅓",
195
+ play: "▶",
196
+ pointer: "❯",
197
+ pointerSmall: "›",
198
+ questionMarkPrefix: "(?)",
199
+ radioOff: "◯",
200
+ radioOn: "◉",
201
+ sevenEighths: "⅞",
202
+ smiley: "㋡",
203
+ square: "█",
204
+ squareBottom: "▄",
205
+ squareCenter: "■",
206
+ squareDarkShade: "▓",
207
+ squareLeft: "▌",
208
+ squareLightShade: "░",
209
+ squareMediumShade: "▒",
210
+ squareRight: "▐",
211
+ squareSmall: "◻",
212
+ squareSmallFilled: "◼",
213
+ squareTop: "▀",
214
+ star: "★",
215
+ subscriptEight: "₈",
216
+ subscriptFive: "₅",
217
+ subscriptFour: "₄",
218
+ subscriptNine: "₉",
219
+ subscriptOne: "₁",
220
+ subscriptSeven: "₇",
221
+ subscriptSix: "₆",
222
+ subscriptThree: "₃",
223
+ subscriptTwo: "₂",
224
+ subscriptZero: "₀",
225
+ threeEighths: "⅜",
226
+ threeFifths: "⅗",
227
+ threeQuarters: "¾",
228
+ tick: "✔",
229
+ triangleDown: "▼",
230
+ triangleDownSmall: "▾",
231
+ triangleLeft: "◀",
232
+ triangleLeftSmall: "◂",
233
+ triangleRight: "▶",
234
+ triangleRightSmall: "▸",
235
+ triangleUp: "▲",
236
+ triangleUpOutline: "△",
237
+ triangleUpSmall: "▴",
238
+ topLeftCorner: "┌",
239
+ topRightCorner: "┐",
240
+ bottomLeftCorner: "└",
241
+ bottomRightCorner: "┘",
242
+ teeUp: "┴",
243
+ teeDown: "┬",
244
+ teeLeft: "┤",
245
+ teeRight: "├",
246
+ twoFifths: "⅖",
247
+ twoThirds: "⅔",
248
+ warning: "⚠",
249
+ };
@@ -0,0 +1,43 @@
1
+ import { FiguresMap } from "../types/figures";
2
+ /**
3
+ * Detect if Unicode is supported in the current terminal environment.
4
+ *
5
+ * This function checks various environment variables and platform settings to determine
6
+ * if the terminal is capable of displaying Unicode characters comprehensively.
7
+ * It prioritizes the `TINKY_UNICODE` environment variable if set.
8
+ *
9
+ * Adapted from `sindresorhus/is-unicode-supported`.
10
+ *
11
+ * @param platform - The operating system platform (default: `process.platform`).
12
+ * @param env - The environment variables object (default: `process.env`).
13
+ * @returns `true` if Unicode is supported, `false` otherwise.
14
+ */
15
+ export declare function isUnicodeSupported(platform?: string, env?: Record<string, string | undefined>): boolean;
16
+ /**
17
+ * A React hook that provides a set of figure characters appropriate for the current environment.
18
+ *
19
+ * This hook leverages `useApp()` from `tinky` to access environment details and determines
20
+ * whether to return the full Unicode character set or a fallback ASCII-compatible set.
21
+ *
22
+ * Use this hook to ensure your CLI output renders correctly across different terminals,
23
+ * including those with limited character support (e.g., standard Windows CMD).
24
+ *
25
+ * @returns A `FiguresMap` object containing the character set (Unicode or ASCII fallback).
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * import { useFigures } from 'tinky-figures';
30
+ * import { Text } from 'tinky';
31
+ *
32
+ * function StatusMessage() {
33
+ * const figures = useFigures();
34
+ *
35
+ * return (
36
+ * <Text>
37
+ * {figures.tick} Operation completed successfully.
38
+ * </Text>
39
+ * );
40
+ * }
41
+ * ```
42
+ */
43
+ export declare function useFigures(): FiguresMap;
@@ -0,0 +1,74 @@
1
+ import { useMemo } from "react";
2
+ import { useApp } from "tinky";
3
+ import { unicodeFigures } from "../data/unicode";
4
+ import { asciiFigures } from "../data/ascii";
5
+ /**
6
+ * Detect if Unicode is supported in the current terminal environment.
7
+ *
8
+ * This function checks various environment variables and platform settings to determine
9
+ * if the terminal is capable of displaying Unicode characters comprehensively.
10
+ * It prioritizes the `TINKY_UNICODE` environment variable if set.
11
+ *
12
+ * Adapted from `sindresorhus/is-unicode-supported`.
13
+ *
14
+ * @param platform - The operating system platform (default: `process.platform`).
15
+ * @param env - The environment variables object (default: `process.env`).
16
+ * @returns `true` if Unicode is supported, `false` otherwise.
17
+ */
18
+ export function isUnicodeSupported(platform = process.platform, env = process.env) {
19
+ // If explicitly set via environment variable, use that
20
+ if (env.TINKY_UNICODE === "true") {
21
+ return true;
22
+ }
23
+ if (env.TINKY_UNICODE === "false") {
24
+ return false;
25
+ }
26
+ const { TERM, TERM_PROGRAM } = env;
27
+ if (platform !== "win32") {
28
+ return TERM !== "linux"; // Linux console (kernel)
29
+ }
30
+ return (Boolean(env.WT_SESSION) || // Windows Terminal
31
+ Boolean(env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
32
+ env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
33
+ TERM_PROGRAM === "Terminus-Sublime" ||
34
+ TERM_PROGRAM === "vscode" ||
35
+ TERM === "xterm-256color" ||
36
+ TERM === "alacritty" ||
37
+ TERM === "rxvt-unicode" ||
38
+ TERM === "rxvt-unicode-256color" ||
39
+ env.TERMINAL_EMULATOR === "JetBrains-JediTerm");
40
+ }
41
+ /**
42
+ * A React hook that provides a set of figure characters appropriate for the current environment.
43
+ *
44
+ * This hook leverages `useApp()` from `tinky` to access environment details and determines
45
+ * whether to return the full Unicode character set or a fallback ASCII-compatible set.
46
+ *
47
+ * Use this hook to ensure your CLI output renders correctly across different terminals,
48
+ * including those with limited character support (e.g., standard Windows CMD).
49
+ *
50
+ * @returns A `FiguresMap` object containing the character set (Unicode or ASCII fallback).
51
+ *
52
+ * @example
53
+ * ```tsx
54
+ * import { useFigures } from 'tinky-figures';
55
+ * import { Text } from 'tinky';
56
+ *
57
+ * function StatusMessage() {
58
+ * const figures = useFigures();
59
+ *
60
+ * return (
61
+ * <Text>
62
+ * {figures.tick} Operation completed successfully.
63
+ * </Text>
64
+ * );
65
+ * }
66
+ * ```
67
+ */
68
+ export function useFigures() {
69
+ const { platform, env } = useApp();
70
+ const figures = useMemo(() => {
71
+ return isUnicodeSupported(platform, env) ? unicodeFigures : asciiFigures;
72
+ }, [platform, env]);
73
+ return figures;
74
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * tinky-figures
3
+ *
4
+ * A library providing Unicode symbols with automatic ASCII fallbacks for Tinky applications.
5
+ * It matches the character set of the popular `figures` npm package.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { useFigures, isUnicodeSupported } from "./hooks/useFigures";
10
+ export type { FiguresMap } from "./types/figures";
11
+ export { unicodeFigures, asciiFigures } from "./data";
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * tinky-figures
3
+ *
4
+ * A library providing Unicode symbols with automatic ASCII fallbacks for Tinky applications.
5
+ * It matches the character set of the popular `figures` npm package.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { useFigures, isUnicodeSupported } from "./hooks/useFigures";
10
+ export { unicodeFigures, asciiFigures } from "./data";
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Represents a collection of figure characters used for CLI output.
3
+ * Keys correspond to the symbol names, and values are the characters themselves.
4
+ *
5
+ * This interface matches the structure of `sindresorhus/figures`.
6
+ */
7
+ export interface FiguresMap {
8
+ [key: string]: string;
9
+ almostEqual: string;
10
+ arrowDown: string;
11
+ arrowLeft: string;
12
+ arrowLeftRight: string;
13
+ arrowRight: string;
14
+ arrowUp: string;
15
+ arrowUpLeft: string;
16
+ arrowUpRight: string;
17
+ arrowDownLeft: string;
18
+ arrowDownRight: string;
19
+ arrowUpDown: string;
20
+ bullet: string;
21
+ checkboxCircleOff: string;
22
+ checkboxCircleOn: string;
23
+ checkboxOff: string;
24
+ checkboxOn: string;
25
+ circle: string;
26
+ circleCircle: string;
27
+ circleCross: string;
28
+ circleDotted: string;
29
+ circleDouble: string;
30
+ circleFilled: string;
31
+ circlePipe: string;
32
+ circleQuestion: string;
33
+ circleQuestionMark: string;
34
+ cross: string;
35
+ dot: string;
36
+ ellipsis: string;
37
+ fiveEighths: string;
38
+ fiveSixths: string;
39
+ fourFifths: string;
40
+ greaterOrEqual: string;
41
+ hamburger: string;
42
+ heart: string;
43
+ home: string;
44
+ identical: string;
45
+ infinity: string;
46
+ info: string;
47
+ lessOrEqual: string;
48
+ line: string;
49
+ lineBackslash: string;
50
+ lineBold: string;
51
+ lineCross: string;
52
+ lineDashed0: string;
53
+ lineDashed1: string;
54
+ lineDashed10: string;
55
+ lineDashed11: string;
56
+ lineDashed12: string;
57
+ lineDashed13: string;
58
+ lineDashed14: string;
59
+ lineDashed15: string;
60
+ lineDashed2: string;
61
+ lineDashed3: string;
62
+ lineDashed4: string;
63
+ lineDashed5: string;
64
+ lineDashed6: string;
65
+ lineDashed7: string;
66
+ lineDashed8: string;
67
+ lineDashed9: string;
68
+ lineDouble: string;
69
+ lineDownBoldLeft: string;
70
+ lineDownBoldLeftBold: string;
71
+ lineDownBoldLeftBoldRight: string;
72
+ lineDownBoldLeftBoldRightBold: string;
73
+ lineDownBoldLeftRight: string;
74
+ lineDownBoldLeftRightBold: string;
75
+ lineDownBoldRight: string;
76
+ lineDownBoldRightBold: string;
77
+ lineDownDoubleLeft: string;
78
+ lineDownDoubleLeftDouble: string;
79
+ lineDownDoubleLeftDoubleRightDouble: string;
80
+ lineDownDoubleLeftRight: string;
81
+ lineDownDoubleRight: string;
82
+ lineDownDoubleRightDouble: string;
83
+ lineDownLeft: string;
84
+ lineDownLeftArc: string;
85
+ lineDownLeftBold: string;
86
+ lineDownLeftBoldRight: string;
87
+ lineDownLeftBoldRightBold: string;
88
+ lineDownLeftDouble: string;
89
+ lineDownLeftDoubleRightDouble: string;
90
+ lineDownLeftRight: string;
91
+ lineDownLeftRightBold: string;
92
+ lineDownRight: string;
93
+ lineDownRightArc: string;
94
+ lineDownRightBold: string;
95
+ lineDownRightDouble: string;
96
+ lineSlash: string;
97
+ lineUpBoldDownBoldLeft: string;
98
+ lineUpBoldDownBoldLeftBold: string;
99
+ lineUpBoldDownBoldLeftBoldRight: string;
100
+ lineUpBoldDownBoldLeftBoldRightBold: string;
101
+ lineUpBoldDownBoldLeftRight: string;
102
+ lineUpBoldDownBoldLeftRightBold: string;
103
+ lineUpBoldDownBoldRight: string;
104
+ lineUpBoldDownBoldRightBold: string;
105
+ lineUpBoldDownLeft: string;
106
+ lineUpBoldDownLeftBold: string;
107
+ lineUpBoldDownLeftBoldRight: string;
108
+ lineUpBoldDownLeftBoldRightBold: string;
109
+ lineUpBoldDownLeftRight: string;
110
+ lineUpBoldDownLeftRightBold: string;
111
+ lineUpBoldDownRight: string;
112
+ lineUpBoldDownRightBold: string;
113
+ lineUpBoldLeft: string;
114
+ lineUpBoldLeftBold: string;
115
+ lineUpBoldLeftBoldRight: string;
116
+ lineUpBoldLeftBoldRightBold: string;
117
+ lineUpBoldLeftRight: string;
118
+ lineUpBoldLeftRightBold: string;
119
+ lineUpBoldRight: string;
120
+ lineUpBoldRightBold: string;
121
+ lineUpDoubleDownDoubleLeft: string;
122
+ lineUpDoubleDownDoubleLeftDouble: string;
123
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: string;
124
+ lineUpDoubleDownDoubleLeftRight: string;
125
+ lineUpDoubleDownDoubleRight: string;
126
+ lineUpDoubleDownDoubleRightDouble: string;
127
+ lineUpDoubleLeft: string;
128
+ lineUpDoubleLeftDouble: string;
129
+ lineUpDoubleLeftDoubleRightDouble: string;
130
+ lineUpDoubleLeftRight: string;
131
+ lineUpDoubleRight: string;
132
+ lineUpDoubleRightDouble: string;
133
+ lineUpDownBoldLeft: string;
134
+ lineUpDownBoldLeftBold: string;
135
+ lineUpDownBoldLeftBoldRight: string;
136
+ lineUpDownBoldLeftBoldRightBold: string;
137
+ lineUpDownBoldLeftRight: string;
138
+ lineUpDownBoldLeftRightBold: string;
139
+ lineUpDownBoldRight: string;
140
+ lineUpDownBoldRightBold: string;
141
+ lineUpDownLeft: string;
142
+ lineUpDownLeftBold: string;
143
+ lineUpDownLeftBoldRight: string;
144
+ lineUpDownLeftBoldRightBold: string;
145
+ lineUpDownLeftDouble: string;
146
+ lineUpDownLeftDoubleRightDouble: string;
147
+ lineUpDownLeftRight: string;
148
+ lineUpDownLeftRightBold: string;
149
+ lineUpDownRight: string;
150
+ lineUpDownRightBold: string;
151
+ lineUpDownRightDouble: string;
152
+ lineUpLeft: string;
153
+ lineUpLeftArc: string;
154
+ lineUpLeftBold: string;
155
+ lineUpLeftBoldRight: string;
156
+ lineUpLeftBoldRightBold: string;
157
+ lineUpLeftDouble: string;
158
+ lineUpLeftDoubleRightDouble: string;
159
+ lineUpLeftRight: string;
160
+ lineUpLeftRightBold: string;
161
+ lineUpRight: string;
162
+ lineUpRightArc: string;
163
+ lineUpRightBold: string;
164
+ lineUpRightDouble: string;
165
+ lineVertical: string;
166
+ lineVerticalBold: string;
167
+ lineVerticalDashed0: string;
168
+ lineVerticalDashed1: string;
169
+ lineVerticalDashed10: string;
170
+ lineVerticalDashed11: string;
171
+ lineVerticalDashed2: string;
172
+ lineVerticalDashed3: string;
173
+ lineVerticalDashed4: string;
174
+ lineVerticalDashed5: string;
175
+ lineVerticalDashed6: string;
176
+ lineVerticalDashed7: string;
177
+ lineVerticalDashed8: string;
178
+ lineVerticalDashed9: string;
179
+ lineVerticalDouble: string;
180
+ lozenge: string;
181
+ lozengeOutline: string;
182
+ musicNote: string;
183
+ musicNoteBeamed: string;
184
+ mustache: string;
185
+ nodejs: string;
186
+ notEqual: string;
187
+ oneEighth: string;
188
+ oneFifth: string;
189
+ oneHalf: string;
190
+ oneNinth: string;
191
+ oneQuarter: string;
192
+ oneSeventh: string;
193
+ oneSixth: string;
194
+ oneTenth: string;
195
+ oneThird: string;
196
+ play: string;
197
+ pointer: string;
198
+ pointerSmall: string;
199
+ questionMarkPrefix: string;
200
+ radioOff: string;
201
+ radioOn: string;
202
+ sevenEighths: string;
203
+ smiley: string;
204
+ square: string;
205
+ squareBottom: string;
206
+ squareCenter: string;
207
+ squareDarkShade: string;
208
+ squareLeft: string;
209
+ squareLightShade: string;
210
+ squareMediumShade: string;
211
+ squareRight: string;
212
+ squareSmall: string;
213
+ squareSmallFilled: string;
214
+ squareTop: string;
215
+ star: string;
216
+ subscriptEight: string;
217
+ subscriptFive: string;
218
+ subscriptFour: string;
219
+ subscriptNine: string;
220
+ subscriptOne: string;
221
+ subscriptSeven: string;
222
+ subscriptSix: string;
223
+ subscriptThree: string;
224
+ subscriptTwo: string;
225
+ subscriptZero: string;
226
+ threeEighths: string;
227
+ threeFifths: string;
228
+ threeQuarters: string;
229
+ tick: string;
230
+ triangleDown: string;
231
+ triangleDownSmall: string;
232
+ triangleLeft: string;
233
+ triangleLeftSmall: string;
234
+ triangleRight: string;
235
+ triangleRightSmall: string;
236
+ triangleUp: string;
237
+ triangleUpOutline: string;
238
+ triangleUpSmall: string;
239
+ topLeftCorner: string;
240
+ topRightCorner: string;
241
+ bottomLeftCorner: string;
242
+ bottomRightCorner: string;
243
+ teeUp: string;
244
+ teeDown: string;
245
+ teeLeft: string;
246
+ teeRight: string;
247
+ twoFifths: string;
248
+ twoThirds: string;
249
+ warning: string;
250
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "tinky-figures",
3
+ "version": "0.1.0",
4
+ "description": "Unicode symbols with ASCII fallbacks for tinky applications",
5
+ "keywords": [
6
+ "tinky",
7
+ "unicode",
8
+ "symbols",
9
+ "figures",
10
+ "cli",
11
+ "terminal",
12
+ "hook"
13
+ ],
14
+ "homepage": "https://github.com/ByteLandTechnology/tinky-figures#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/ByteLandTechnology/tinky-figures/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/ByteLandTechnology/tinky-figures.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": {
24
+ "name": "ByteLand Technology Limited"
25
+ },
26
+ "type": "module",
27
+ "main": "./lib/index.js",
28
+ "scripts": {
29
+ "test": "vitest run --coverage",
30
+ "build": "tsc && npm run docs",
31
+ "lint": "eslint src tests",
32
+ "prepublish": "npm run build",
33
+ "prepare": "husky",
34
+ "docs": "typedoc --plugin typedoc-plugin-markdown --disableSources --out docs/api && prettier --write docs/api"
35
+ },
36
+ "dependencies": {
37
+ "tinky": ">=1.5.0"
38
+ },
39
+ "files": [
40
+ "./bin/*",
41
+ "./lib/*"
42
+ ],
43
+ "typings": "./lib/index.d.ts",
44
+ "devDependencies": {
45
+ "@commitlint/cli": "^20.3.0",
46
+ "@commitlint/config-conventional": "^20.3.0",
47
+ "@semantic-release/changelog": "^6.0.3",
48
+ "@semantic-release/commit-analyzer": "^13.0.1",
49
+ "@semantic-release/git": "^10.0.1",
50
+ "@semantic-release/github": "^12.0.2",
51
+ "@semantic-release/npm": "^13.1.3",
52
+ "@semantic-release/release-notes-generator": "^14.1.0",
53
+ "@vitest/coverage-v8": "^4.0.18",
54
+ "conventional-changelog-conventionalcommits": "^9.1.0",
55
+ "eslint": "^9.39.2",
56
+ "eslint-plugin-react": "^7.37.5",
57
+ "husky": "^9.1.7",
58
+ "jiti": "^2.6.1",
59
+ "lint-staged": "^16.2.7",
60
+ "prettier": "^3.7.4",
61
+ "semantic-release": "^25.0.2",
62
+ "typedoc": "^0.28.16",
63
+ "typedoc-plugin-markdown": "^4.9.0",
64
+ "typescript-eslint": "^8.53.0",
65
+ "vitest": "^4.0.18"
66
+ },
67
+ "commitlint": {
68
+ "extends": [
69
+ "@commitlint/config-conventional"
70
+ ]
71
+ },
72
+ "lint-staged": {
73
+ "*.{js,ts,jsx,tsx,json,md,yaml,yml}": "prettier --write"
74
+ }
75
+ }