@zakmandhro/bunti 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/LICENSE +21 -0
- package/README.md +104 -0
- package/package.json +54 -0
- package/src/colors.ts +255 -0
- package/src/components/Button.ts +104 -0
- package/src/components/Card.ts +53 -0
- package/src/components/Header.ts +65 -0
- package/src/components/Input.ts +124 -0
- package/src/components/index.ts +4 -0
- package/src/data/glyphs.ts +30 -0
- package/src/detect.ts +60 -0
- package/src/dsl.ts +661 -0
- package/src/icons.ts +186 -0
- package/src/index.ts +72 -0
- package/src/layout.ts +639 -0
- package/src/render.ts +302 -0
- package/src/state.ts +148 -0
- package/src/utils.ts +165 -0
package/src/icons.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bunti Icon Engine
|
|
3
|
+
* Purely tactical: Nerd Fonts or ASCII fallbacks.
|
|
4
|
+
*/
|
|
5
|
+
import type { TerminalCapabilities } from './detect';
|
|
6
|
+
|
|
7
|
+
export interface IconDefinition {
|
|
8
|
+
nf: string;
|
|
9
|
+
ascii: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ICON_MAP: Record<string, IconDefinition> = {
|
|
13
|
+
add: { nf: '\uf067', ascii: '+' },
|
|
14
|
+
'arrow-left': { nf: '\uf060', ascii: '<' },
|
|
15
|
+
'arrow-right': { nf: '\uf061', ascii: '>' },
|
|
16
|
+
bars: { nf: '\uf0c9', ascii: '≡' },
|
|
17
|
+
bell: { nf: '\uf0f3', ascii: '!' },
|
|
18
|
+
branch: { nf: '\uf418', ascii: '*' },
|
|
19
|
+
bullet: { nf: '\uf111', ascii: '•' },
|
|
20
|
+
bun: { nf: '\ue76f', ascii: 'B' },
|
|
21
|
+
bunti: { nf: '\u{f0065}', ascii: '@' },
|
|
22
|
+
check: { nf: '\uf00c', ascii: 'v' },
|
|
23
|
+
checkbox: { nf: '\uf0c8', ascii: '[ ]' },
|
|
24
|
+
'checkbox-check': { nf: '\uf14a', ascii: '[x]' },
|
|
25
|
+
'chevron-down': { nf: '\uf078', ascii: 'v' },
|
|
26
|
+
'chevron-left': { nf: '\uf053', ascii: '<' },
|
|
27
|
+
'chevron-right': { nf: '\uf054', ascii: '>' },
|
|
28
|
+
close: { nf: '\uf00d', ascii: 'x' },
|
|
29
|
+
cloud: { nf: '\uf0c2', ascii: 'C' },
|
|
30
|
+
code: { nf: '\uf121', ascii: '{' },
|
|
31
|
+
commit: { nf: '\uf172', ascii: '+' },
|
|
32
|
+
copy: { nf: '\uf0c5', ascii: '=' },
|
|
33
|
+
cpu: { nf: '\uf2db', ascii: 'C' },
|
|
34
|
+
database: { nf: '\uf1c0', ascii: 'D' },
|
|
35
|
+
desktop: { nf: '\u{f01c4}', ascii: 'D' },
|
|
36
|
+
disk: { nf: '\uf0a0', ascii: 'D' },
|
|
37
|
+
download: { nf: '\uf019', ascii: 'v' },
|
|
38
|
+
'draft-pr': { nf: '\uebdb', ascii: '!' },
|
|
39
|
+
edit: { nf: '\uf044', ascii: 'e' },
|
|
40
|
+
error: { nf: '\uf00d', ascii: 'x' },
|
|
41
|
+
exit: { nf: '\uf08b', ascii: '<' },
|
|
42
|
+
external: { nf: '\uf08e', ascii: '>' },
|
|
43
|
+
eye: { nf: '\uf06e', ascii: 'v' },
|
|
44
|
+
'eye-off': { nf: '\uf070', ascii: 'h' },
|
|
45
|
+
file: { nf: '\uf15b', ascii: '-' },
|
|
46
|
+
folder: { nf: '\uf07b', ascii: '[' },
|
|
47
|
+
'folder-open': { nf: '\uf115', ascii: '{' },
|
|
48
|
+
fork: { nf: '\uf41a', ascii: 'Y' },
|
|
49
|
+
gear: { nf: '\uf423', ascii: '*' },
|
|
50
|
+
git: { nf: '\ue702', ascii: 'g' },
|
|
51
|
+
grid: { nf: '\uf009', ascii: '#' },
|
|
52
|
+
heart: { nf: '\uf004', ascii: '*' },
|
|
53
|
+
'help-circle': { nf: '\uf059', ascii: '?' },
|
|
54
|
+
home: { nf: '\uf015', ascii: 'H' },
|
|
55
|
+
image: { nf: '\uf03e', ascii: 'I' },
|
|
56
|
+
info: { nf: '\uf05a', ascii: 'i' },
|
|
57
|
+
issue: { nf: '\uebd9', ascii: '#' },
|
|
58
|
+
json: { nf: '\ue60b', ascii: 'J' },
|
|
59
|
+
laptop: { nf: '\uf109', ascii: 'L' },
|
|
60
|
+
list: { nf: '\uf03a', ascii: '=' },
|
|
61
|
+
loading: { nf: '\uf110', ascii: '~' },
|
|
62
|
+
lock: { nf: '\uf023', ascii: 'L' },
|
|
63
|
+
mail: { nf: '\uf0e0', ascii: '@' },
|
|
64
|
+
markdown: { nf: '\uf48a', ascii: 'M' },
|
|
65
|
+
maximize: { nf: '\uf0c8', ascii: '^' },
|
|
66
|
+
memory: { nf: '\uf0c7', ascii: 'M' },
|
|
67
|
+
menu: { nf: '\uf0c9', ascii: '≡' },
|
|
68
|
+
merge: { nf: '\uf419', ascii: '>' },
|
|
69
|
+
minimize: { nf: '\u{f10fe}', ascii: 'v' },
|
|
70
|
+
network: { nf: '\uf0ac', ascii: 'N' },
|
|
71
|
+
node: { nf: '\ue718', ascii: 'N' },
|
|
72
|
+
pause: { nf: '\uf04c', ascii: '|' },
|
|
73
|
+
pencil: { nf: '\uf044', ascii: 'e' },
|
|
74
|
+
planet: { nf: '\ue22e', ascii: '㊀' },
|
|
75
|
+
play: { nf: '\uf04b', ascii: '>' },
|
|
76
|
+
'plus-circle': { nf: '\uea60', ascii: '(+)' },
|
|
77
|
+
pr: { nf: '\uf41d', ascii: '!' },
|
|
78
|
+
refresh: { nf: '\uf021', ascii: 'R' },
|
|
79
|
+
remove: { nf: '\uf068', ascii: '-' },
|
|
80
|
+
repo: { nf: '\uf401', ascii: 'R' },
|
|
81
|
+
robot: { nf: '\u{f06a9}', ascii: 'A' },
|
|
82
|
+
rocket: { nf: '\uf135', ascii: 'R' },
|
|
83
|
+
satellite: { nf: '\uef5f', ascii: 'S' },
|
|
84
|
+
save: { nf: '\uf0c7', ascii: 'S' },
|
|
85
|
+
search: { nf: '\uf002', ascii: '/' },
|
|
86
|
+
send: { nf: '\uec0f', ascii: '>' },
|
|
87
|
+
server: { nf: '\uf233', ascii: 'S' },
|
|
88
|
+
settings: { nf: '\uf013', ascii: '*' },
|
|
89
|
+
'staggered-bars': { nf: '\u{ee19}', ascii: '≡' },
|
|
90
|
+
star: { nf: '\uf005', ascii: '*' },
|
|
91
|
+
stop: { nf: '\uf04d', ascii: 'X' },
|
|
92
|
+
success: { nf: '\uf00c', ascii: 'v' },
|
|
93
|
+
tag: { nf: '\u{f04fc}', ascii: 't' },
|
|
94
|
+
terminal: { nf: '\uf120', ascii: '$' },
|
|
95
|
+
trash: { nf: '\uf1f8', ascii: 'x' },
|
|
96
|
+
user: { nf: '\uf007', ascii: 'U' },
|
|
97
|
+
warning: { nf: '\uf071', ascii: '!' },
|
|
98
|
+
wizard: { nf: '\u{f1477}', ascii: 'W' },
|
|
99
|
+
yaml: { nf: '\ue6a8', ascii: 'Y' },
|
|
100
|
+
zap: { nf: '\uf0e7', ascii: 'z' },
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const EMOJI_MAP: Record<string, string> = {
|
|
104
|
+
'🌿': 'branch',
|
|
105
|
+
'📥': 'pr',
|
|
106
|
+
'📌': 'commit',
|
|
107
|
+
'🔀': 'merge',
|
|
108
|
+
'🍴': 'fork',
|
|
109
|
+
'🏷️': 'tag',
|
|
110
|
+
'📁': 'folder',
|
|
111
|
+
'📂': 'folder-open',
|
|
112
|
+
'📄': 'file',
|
|
113
|
+
'💻': 'laptop',
|
|
114
|
+
'🖥️': 'desktop',
|
|
115
|
+
'📝': 'edit',
|
|
116
|
+
'📦': 'json',
|
|
117
|
+
'📜': 'yaml',
|
|
118
|
+
'✅': 'success',
|
|
119
|
+
'❌': 'error',
|
|
120
|
+
'⚠️': 'warning',
|
|
121
|
+
ℹ️: 'info',
|
|
122
|
+
'⏳': 'loading',
|
|
123
|
+
'🚀': 'rocket',
|
|
124
|
+
'🥟': 'satellite',
|
|
125
|
+
'🪐': 'planet',
|
|
126
|
+
'🌀': 'bunti',
|
|
127
|
+
'🤖': 'robot',
|
|
128
|
+
'🗑️': 'trash',
|
|
129
|
+
'⚙️': 'gear',
|
|
130
|
+
'🔔': 'bell',
|
|
131
|
+
'✉️': 'mail',
|
|
132
|
+
'🖼️': 'image',
|
|
133
|
+
'❓': 'help-circle',
|
|
134
|
+
'🙂': 'success',
|
|
135
|
+
'😊': 'success',
|
|
136
|
+
'😀': 'success',
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const _GENERIC_ICON = '\uf0010';
|
|
140
|
+
|
|
141
|
+
const cachedCaps: TerminalCapabilities = {
|
|
142
|
+
nerdFont: true,
|
|
143
|
+
glyphProtocol: false,
|
|
144
|
+
unicode: true,
|
|
145
|
+
color: true,
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export function replaceEmojis(text: string): string {
|
|
149
|
+
if (!text) return '';
|
|
150
|
+
if (!cachedCaps.nerdFont) return text;
|
|
151
|
+
|
|
152
|
+
let out = text;
|
|
153
|
+
for (const [emoji, name] of Object.entries(EMOJI_MAP)) {
|
|
154
|
+
const glyph = getIcon(name, cachedCaps);
|
|
155
|
+
const regex = new RegExp(`${emoji}[\uFE00-\uFE0F]?`, 'g');
|
|
156
|
+
out = out.replace(regex, glyph);
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export async function init(options?: {
|
|
162
|
+
nerdFont?: boolean;
|
|
163
|
+
}): Promise<TerminalCapabilities> {
|
|
164
|
+
if (options?.nerdFont !== undefined) cachedCaps.nerdFont = options.nerdFont;
|
|
165
|
+
return cachedCaps;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function getIcon(name: string, caps: TerminalCapabilities): string {
|
|
169
|
+
const def = ICON_MAP[name];
|
|
170
|
+
if (!def) return '';
|
|
171
|
+
return caps.nerdFont ? def.nf : def.ascii;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function icon(name: string): string {
|
|
175
|
+
return getIcon(name, cachedCaps);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function nerd(name: string): string {
|
|
179
|
+
return ICON_MAP[name]?.nf || '';
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function register(_name: string, _glyph: string): void {}
|
|
183
|
+
|
|
184
|
+
export function nerdIcon(nfChar: string, fallback: string): string {
|
|
185
|
+
return cachedCaps.nerdFont ? nfChar : fallback;
|
|
186
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as colors from './colors';
|
|
2
|
+
import * as detect from './detect';
|
|
3
|
+
import * as dsl from './dsl';
|
|
4
|
+
import * as icons from './icons';
|
|
5
|
+
import * as layout from './layout';
|
|
6
|
+
import * as render from './render';
|
|
7
|
+
import * as state from './state';
|
|
8
|
+
import * as utils from './utils';
|
|
9
|
+
|
|
10
|
+
export { bg, createGradient, fg, hexToRGB, PALETTE, rgb } from './colors';
|
|
11
|
+
// Type Exports
|
|
12
|
+
export type { TerminalCapabilities } from './detect';
|
|
13
|
+
// Functional API Individual Exports
|
|
14
|
+
export { detectCapabilities } from './detect';
|
|
15
|
+
export type { BuntiContext, DSLBoxOptions } from './dsl';
|
|
16
|
+
export { KEYS, render } from './dsl';
|
|
17
|
+
export type { IconDefinition } from './icons';
|
|
18
|
+
export {
|
|
19
|
+
EMOJI_MAP,
|
|
20
|
+
ICON_MAP,
|
|
21
|
+
icon,
|
|
22
|
+
init,
|
|
23
|
+
nerd,
|
|
24
|
+
nerdIcon,
|
|
25
|
+
register,
|
|
26
|
+
replaceEmojis,
|
|
27
|
+
} from './icons';
|
|
28
|
+
export type {
|
|
29
|
+
BorderStyle,
|
|
30
|
+
ListOptions,
|
|
31
|
+
StyleOptions,
|
|
32
|
+
TableOptions,
|
|
33
|
+
} from './layout';
|
|
34
|
+
export {
|
|
35
|
+
badge,
|
|
36
|
+
blit,
|
|
37
|
+
box,
|
|
38
|
+
createStyle,
|
|
39
|
+
getWindow,
|
|
40
|
+
gradient,
|
|
41
|
+
joinHorizontal,
|
|
42
|
+
joinVertical,
|
|
43
|
+
list,
|
|
44
|
+
rect,
|
|
45
|
+
setCell,
|
|
46
|
+
table,
|
|
47
|
+
viewport,
|
|
48
|
+
wallpaper,
|
|
49
|
+
} from './layout';
|
|
50
|
+
export { flush, loop } from './render';
|
|
51
|
+
export type { Cell, RGB, ScreenOptions, ScreenState } from './state';
|
|
52
|
+
export {
|
|
53
|
+
ANSI,
|
|
54
|
+
clearBackBuffer,
|
|
55
|
+
createScreenState,
|
|
56
|
+
resizeScreen,
|
|
57
|
+
} from './state';
|
|
58
|
+
export { charWidth, stripAnsi, truncate, visibleWidth } from './utils';
|
|
59
|
+
|
|
60
|
+
// Namespaced export for bunti.render style usage
|
|
61
|
+
export const bunti = {
|
|
62
|
+
...detect,
|
|
63
|
+
...icons,
|
|
64
|
+
...layout,
|
|
65
|
+
...render,
|
|
66
|
+
...utils,
|
|
67
|
+
...colors,
|
|
68
|
+
...state,
|
|
69
|
+
...dsl,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default bunti;
|