shellfie 1.3.7 → 2.0.1

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.
Files changed (117) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +225 -165
  3. package/dist/fonts/index.d.ts +21 -0
  4. package/dist/fonts/index.d.ts.map +1 -0
  5. package/dist/fonts/index.js +92 -0
  6. package/dist/fonts/index.js.map +1 -0
  7. package/dist/index.d.ts +14 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +124 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/parser/index.d.ts +6 -0
  12. package/dist/parser/index.d.ts.map +1 -0
  13. package/dist/parser/index.js +189 -0
  14. package/dist/parser/index.js.map +1 -0
  15. package/dist/parser/types.d.ts +17 -0
  16. package/dist/parser/types.d.ts.map +1 -0
  17. package/dist/parser/types.js +3 -0
  18. package/dist/parser/types.js.map +1 -0
  19. package/dist/renderer/colors.d.ts +9 -0
  20. package/dist/renderer/colors.d.ts.map +1 -0
  21. package/dist/renderer/colors.js +100 -0
  22. package/dist/renderer/colors.js.map +1 -0
  23. package/dist/renderer/customGlyphs.d.ts +17 -0
  24. package/dist/renderer/customGlyphs.d.ts.map +1 -0
  25. package/dist/renderer/customGlyphs.js +730 -0
  26. package/dist/renderer/customGlyphs.js.map +1 -0
  27. package/dist/renderer/index.d.ts +10 -0
  28. package/dist/renderer/index.d.ts.map +1 -0
  29. package/dist/renderer/index.js +230 -0
  30. package/dist/renderer/index.js.map +1 -0
  31. package/dist/renderer/text.d.ts +13 -0
  32. package/dist/renderer/text.d.ts.map +1 -0
  33. package/dist/renderer/text.js +128 -0
  34. package/dist/renderer/text.js.map +1 -0
  35. package/dist/templates/base.d.ts +5 -0
  36. package/dist/templates/base.d.ts.map +1 -0
  37. package/dist/templates/base.js +37 -0
  38. package/dist/templates/base.js.map +1 -0
  39. package/dist/templates/index.d.ts +13 -0
  40. package/dist/templates/index.d.ts.map +1 -0
  41. package/dist/templates/index.js +34 -0
  42. package/dist/templates/index.js.map +1 -0
  43. package/dist/templates/macos.d.ts +12 -0
  44. package/dist/templates/macos.d.ts.map +1 -0
  45. package/dist/templates/macos.js +34 -0
  46. package/dist/templates/macos.js.map +1 -0
  47. package/dist/templates/minimal.d.ts +13 -0
  48. package/dist/templates/minimal.d.ts.map +1 -0
  49. package/dist/templates/minimal.js +27 -0
  50. package/dist/templates/minimal.js.map +1 -0
  51. package/dist/templates/windows.d.ts +12 -0
  52. package/dist/templates/windows.d.ts.map +1 -0
  53. package/dist/templates/windows.js +34 -0
  54. package/dist/templates/windows.js.map +1 -0
  55. package/dist/themes/catppuccin-mocha.d.ts +3 -0
  56. package/dist/themes/catppuccin-mocha.d.ts.map +1 -0
  57. package/dist/themes/catppuccin-mocha.js +27 -0
  58. package/dist/themes/catppuccin-mocha.js.map +1 -0
  59. package/dist/themes/dracula.d.ts +3 -0
  60. package/dist/themes/dracula.d.ts.map +1 -0
  61. package/dist/themes/dracula.js +27 -0
  62. package/dist/themes/dracula.js.map +1 -0
  63. package/dist/themes/github-dark.d.ts +3 -0
  64. package/dist/themes/github-dark.d.ts.map +1 -0
  65. package/dist/themes/github-dark.js +27 -0
  66. package/dist/themes/github-dark.js.map +1 -0
  67. package/dist/themes/github-light.d.ts +3 -0
  68. package/dist/themes/github-light.d.ts.map +1 -0
  69. package/dist/themes/github-light.js +27 -0
  70. package/dist/themes/github-light.js.map +1 -0
  71. package/dist/themes/gruvbox-dark.d.ts +3 -0
  72. package/dist/themes/gruvbox-dark.d.ts.map +1 -0
  73. package/dist/themes/gruvbox-dark.js +27 -0
  74. package/dist/themes/gruvbox-dark.js.map +1 -0
  75. package/dist/themes/gruvbox-light.d.ts +3 -0
  76. package/dist/themes/gruvbox-light.d.ts.map +1 -0
  77. package/dist/themes/gruvbox-light.js +27 -0
  78. package/dist/themes/gruvbox-light.js.map +1 -0
  79. package/dist/themes/index.d.ts +27 -0
  80. package/dist/themes/index.d.ts.map +1 -0
  81. package/dist/themes/index.js +54 -0
  82. package/dist/themes/index.js.map +1 -0
  83. package/dist/themes/monokai.d.ts +3 -0
  84. package/dist/themes/monokai.d.ts.map +1 -0
  85. package/dist/themes/monokai.js +27 -0
  86. package/dist/themes/monokai.js.map +1 -0
  87. package/dist/themes/nord.d.ts +3 -0
  88. package/dist/themes/nord.d.ts.map +1 -0
  89. package/dist/themes/nord.js +27 -0
  90. package/dist/themes/nord.js.map +1 -0
  91. package/dist/themes/one-dark.d.ts +3 -0
  92. package/dist/themes/one-dark.d.ts.map +1 -0
  93. package/dist/themes/one-dark.js +27 -0
  94. package/dist/themes/one-dark.js.map +1 -0
  95. package/dist/themes/solarized-dark.d.ts +3 -0
  96. package/dist/themes/solarized-dark.d.ts.map +1 -0
  97. package/dist/themes/solarized-dark.js +27 -0
  98. package/dist/themes/solarized-dark.js.map +1 -0
  99. package/dist/themes/solarized-light.d.ts +3 -0
  100. package/dist/themes/solarized-light.d.ts.map +1 -0
  101. package/dist/themes/solarized-light.js +27 -0
  102. package/dist/themes/solarized-light.js.map +1 -0
  103. package/dist/themes/tokyo-night.d.ts +3 -0
  104. package/dist/themes/tokyo-night.d.ts.map +1 -0
  105. package/dist/themes/tokyo-night.js +27 -0
  106. package/dist/themes/tokyo-night.js.map +1 -0
  107. package/dist/types.d.ts +151 -0
  108. package/dist/types.d.ts.map +1 -0
  109. package/dist/types.js +3 -0
  110. package/dist/types.js.map +1 -0
  111. package/package.json +33 -21
  112. package/shellfie.d.ts +0 -29
  113. package/shellfie.js +0 -114
  114. package/template/template.css +0 -58
  115. package/template/template.html +0 -21
  116. package/utils/config.js +0 -41
  117. package/utils/styles.js +0 -32
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Tal Hayut
3
+ Copyright (c) 2026 tool3
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,178 +1,238 @@
1
- # shellfie 🤳🏽
1
+ # shellfie
2
2
 
3
- <img src="./shellfies/logo.png" />
3
+ Take a shell selfie.
4
+ Your terminal output deserves better than a blurry screenshot.
5
+
6
+ ![shellfie](examples/svgs/logo-2.svg)
7
+
8
+ | Feature | shellfie | carbon-now-cli | svg-term | termtosvg |
9
+ | ------------------- | -------- | -------------- | -------- | --------- |
10
+ | Zero dependencies | ✅ | ❌ | ❌ | ❌ |
11
+ | No native bindings | ✅ | ❌ | ❌ | ❌ |
12
+ | No headless browser | ✅ | ❌ | ✅ | ✅ |
13
+ | Full ANSI support | ✅ | ✅ | ✅ | ✅ |
14
+ | 24-bit true color | ✅ | ✅ | ❌ | ✅ |
15
+ | Runs in browser | ✅ | ❌ | ❌ | ❌ |
16
+ | Synchronous API | ✅ | ❌ | ❌ | ❌ |
17
+
18
+ ```typescript
19
+ import { execSync } from "child_process";
20
+ import shellfie from 'shellfie'
21
+
22
+ const log = execSync("git log --oneline --graph --color=always").toString();
23
+ const svg = shellfie(log, { title: "git log" });
24
+ ```
25
+
26
+ ![Git Log](examples/svgs/git-log.svg)
27
+
28
+ ## Why SVG?
29
+
30
+ ✅ **Infinitely scalable** — pixel-perfect at any zoom level, retina-ready by default.
31
+ ✅ **Selectable text** — copy code directly from the image.
32
+ ✅ **Embeddable everywhere** — high quality embedding in READMEs, docs, blogs, everywhere.
33
+ ✅ **Tiny files** — 2-10KB vs blurry 500KB+ PNGs.
34
+ ✅ **No rendering pipeline** — runs anywhere JavaScript runs.
35
+
36
+ ## Install
4
37
 
5
- # install
6
38
  ```bash
7
39
  npm install shellfie
8
40
  ```
9
41
 
10
- # the holy trinity ▽
11
- `shellfie` respects the holy trinity: the lib, the service, and the holy cli.
12
- - [shellfie](https://github.com/tool3/shellfie)
13
- - [shellfied](https://github.com/tool3/shellfied)
14
- - [shellfie-cli](https://github.com/tool3/shellfie-cli)
15
-
16
- # usage
17
- ```javascript
18
- const data = [
19
- '\x1b[105mSHELLFIE\\x1b[0m🤳',
20
- '\x1b[38;5;225mthe easiest way',
21
- '\x1b[38;5;213mto create beautiful',
22
- '\x1b[38;5;14mCLI screenshots 📸',
23
- '\x1b[38;5;199mprogrammatically 🚀'
24
- ];
25
- const options = {
26
- name: 'shellfie',
27
- style: {
28
- fontSize: 15,
29
- fontWeight: 'bold',
30
- fontFamily: 'Fira Code'
31
- },
32
- viewport: {
33
- width: 400,
34
- height: 300
35
- }
36
- }
37
- await shellfie(data, options);
42
+ ## Usage
43
+
44
+ ```typescript
45
+ import shellfie from "shellfie";
46
+
47
+ const svg = shellfie(terminalOutput, {
48
+ template: "macos",
49
+ title: "npm test",
50
+ });
38
51
  ```
39
52
 
40
- outputs:
41
- <img src="./shellfies/shellfie.png" />
53
+ ## Browser
42
54
 
55
+ ```html
56
+ <script type="module">
57
+ import shellfie from "https://esm.sh/shellfie";
43
58
 
44
- ### Apple Silicon
45
- ```bash
46
- # NOTE! if you are running on Apple Silicon you may need to set the following env variables:
47
- export PUPPETEER_EXECUTABLE_PATH=`which chromium`
48
- export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
49
- ```f
50
-
51
- # data
52
- **type**: `string[]` || `string`
53
- **description**: string data to output to the terminal
54
-
55
- # options
56
- **type**: `object`
57
- **description**: optional config for `shellfie`
58
- ### `name`
59
- **type**: `string`
60
- **description**: name of image
61
- ### `location`
62
- **type**: `string`
63
- **description**: relative path to save your shellfies
64
- ### `puppeteerOptions`
65
- **type**: `object`
66
- **description**: optional puppteer args
67
- **default**: `{ args: ['--no-sandbox', '--disable-setuid-sandbox'] }`
68
- ### `mode`
69
- **type**: `string`
70
- **description**: can allow raw string input. for example: `yarn test --colors > help.txt`, then copy the text and provide it to `shellfie` with this option set to `raw`.
71
- **default**: `default`
72
- ### `theme`
73
- **type**: `object`
74
- **description**: optional theme style
75
- - #### `background`
76
- **type**: `string`
77
- **description**: css color for terminal background
78
- **default**: `'#151515'`
79
- - #### `forground`
80
- **type**: `string`
81
- **description**: css color for any unformatted string provided in `data`
82
- ### `style`
83
- **type**: `object`
84
- **description**: css properties for terminal output
85
- - #### `fontSize`
86
- **type**: `number`
87
- **description**: font size
88
- - #### `fontWeight`
89
- **type**: `string`
90
- **description**: font weight
91
- - #### `fontFamily`
92
- **type**: `string`
93
- **description**: font family
94
- ### `viewport`
95
- **type**: `object`
96
- **description**: viewport of terminal
97
- **default**: `{ width: 700, height: 600 }`
98
- - #### `width`
99
- **type**: `number`
100
- **description**: viewport width
101
- - #### `height`
102
- **type**: `number`
103
- **description**: viewport height
104
-
105
- # examples
106
- ```javascript
107
- await shellfie(["\x1b[32mGreen line", "\x1b[31;1mRED bold"], { name: 'small', viewport: { width: 200, height: 200 } });
108
- ```
109
-
110
- <img src="./shellfies/small.png" />
111
-
112
-
113
- ```javascript
114
- const testResults = [
115
- "yarn run v1.22.5",
116
- "$ mocha --no-timeouts tests/ --colors",
117
- "",
118
- "",
119
- " shellfie",
120
- "  ✓ should support array of string and output a png file (1106ms)",
121
- "  ✓ should show into img (983ms)",
122
- "  ✓ should support custom viewport (982ms)",
123
- "  ✓ should support long raw output (2287ms)",
124
- "  ✓ should support raw string (1087ms)",
125
- "  ✓ should support complex string (1079ms)",
126
- "  ✓ should support different font family (5541ms)",
127
- "  ✓ should support chartscii fancy example (1123ms)",
128
- "  ✓ should support fancy unsplitted (1082ms)",
129
- "  ✓ should support string output (947ms)",
130
- "  ✓ should magically work with magic numbers (1945ms)",
131
- "  ✓ should work with lolcat (1102ms)",
132
- "",
133
- "",
134
- "  12 passing (19s)",
135
- "",
136
- "Done in 19.60s.",
137
- ];
138
- await shellfie(testResults, { name: 'fira', style: { fontFamily: 'Fira Code', fontWeight: 'bold' } });
139
- await shellfie(testResults, { name: 'monospace', style: { fontFamily: 'monospace' } });
140
- await shellfie(testResults, { name: 'monaco', style: { fontFamily: 'Monaco' } });
141
- ```
142
-
143
- <img src="./shellfies/fira.png" />
144
- <img src="./shellfies/monospace.png" />
145
- <img src="./shellfies/monaco.png" />
146
-
147
- ### raw mode
148
- ```javascript
149
- const string = `
150
- cristal ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
151
- teen ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
152
- mind ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
153
- morning ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
154
- vice ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
155
- passion ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
156
- fruit ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
157
- instagram ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
158
- atlas ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
159
- retro ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
160
- summer ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
161
- pastel ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
162
- rainbow ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
163
- `
164
- await shellfie(string, { name: 'gradient', mode: 'raw', viewport: {width: 600, height: 350} });
59
+ const svg = shellfie("\x1b[32m$ npm test\x1b[0m\nAll tests passed!", {
60
+ template: "macos",
61
+ title: "terminal",
62
+ });
63
+
64
+ document.body.innerHTML = svg;
65
+ </script>
165
66
  ```
166
- <img src="./shellfies/gradient.png" />
167
-
168
- ### bash colors
169
- ```javascript
170
- const shellfie = require('shellfie');
171
- let backgroundColors = '';
172
- for (let i = 0; i < 255; i++) {
173
- backgroundColors += `\x1b[48;5;${i}m ${i}\x1b[0m`;
174
- }
175
- await shellfie(backgroundColors, { name: 'background', viewport: {width: 500, height: 400} });
67
+
68
+ ## Templates
69
+
70
+ | macOS | Windows | Minimal |
71
+ | --------------------------------- | ------------------------------------- | ------------------------------------- |
72
+ | ![macos](examples/svgs/macos.svg) | ![windows](examples/svgs/windows.svg) | ![minimal](examples/svgs/minimal.svg) |
73
+
74
+ ```typescript
75
+ shellfie(output, { template: "macos" }); // default
76
+ shellfie(output, { template: "windows" });
77
+ shellfie(output, { template: "minimal" });
176
78
  ```
177
79
 
178
- <img src="./shellfies/background.png" />
80
+ ## Options
81
+
82
+ ```typescript
83
+ shellfie(input, {
84
+ template?: "macos", // 'macos' | 'windows' | 'minimal' | Template
85
+ title?: "my-terminal", // window title
86
+ width?: 80, // terminal columns (auto-detected if not set)
87
+ padding?: 16, // number | [v, h] | [top, right, bottom, left]
88
+ controls?: true, // show window control buttons
89
+ fontSize?: 14, // font size in pixels
90
+ lineHeight?: 1.4, // line height multiplier
91
+ fontFamily?: "'SF Mono', Monaco, monospace", // font stack
92
+ customGlyphs?: true, // pixel-perfect box drawing characters
93
+ embedFont?: true, // embed default font as base64 (async only)
94
+ customFont?: { // use your own font
95
+ data: base64FontData, // base64-encoded font data
96
+ format: "woff2", // 'woff2' | 'woff' | 'ttf'
97
+ },
98
+ theme?: customTheme, // custom color theme or see themes below
99
+ watermark?: "Generated by shellfie", // bottom-right text (supports ANSI)
100
+ watermarkPadding?: 16, // number | [v, h] | [top, right, bottom, left]
101
+ header?: { // header configuration
102
+ backgroundColor?: "#2d2d2d", // title bar background color
103
+ height?: 40, // title bar height in pixels
104
+ border?: true, // show bottom border
105
+ borderColor?: "#1a1a1a", // border color
106
+ borderWidth?: 1, // border width in pixels
107
+ },
108
+ footer?: { // footer configuration
109
+ backgroundColor?: "#2d2d2d", // footer background color
110
+ height?: 30, // footer height in pixels
111
+ border?: true, // show top border
112
+ borderColor?: "#1a1a1a", // border color
113
+ borderWidth?: 1, // border width in pixels
114
+ },
115
+ });
116
+ ```
117
+
118
+ ## Font Embedding
119
+
120
+ For portable SVGs that render identically everywhere:
121
+
122
+ ```typescript
123
+ import { shellfieAsync } from "shellfie";
124
+
125
+ const svg = await shellfieAsync(input, { embedFont: true });
126
+ ```
127
+
128
+ The font gets base64-encoded directly into the SVG. No external requests, no CORS issues, no "why does this look different on their machine" debugging sessions.
129
+
130
+ ## Themes
131
+
132
+ shellfie comes with 12 built-in themes:
133
+
134
+ ```typescript
135
+ import shellfie, { dracula, nord, tokyoNight } from "shellfie";
136
+
137
+ shellfie(output, { theme: dracula });
138
+ ```
139
+
140
+ | Dracula | Nord | Tokyo Night |
141
+ | -------------------------------------------- | -------------------------------------- | ---------------------------------------------------- |
142
+ | ![Dracula](examples/svgs/themes/dracula.svg) | ![Nord](examples/svgs/themes/nord.svg) | ![Tokyo Night](examples/svgs/themes/tokyo-night.svg) |
143
+
144
+ | One Dark | Monokai | Catppuccin Mocha |
145
+ | ---------------------------------------------- | -------------------------------------------- | -------------------------------------------------------------- |
146
+ | ![One Dark](examples/svgs/themes/one-dark.svg) | ![Monokai](examples/svgs/themes/monokai.svg) | ![Catppuccin Mocha](examples/svgs/themes/catppuccin-mocha.svg) |
147
+
148
+ | GitHub Dark | GitHub Light | Gruvbox Dark |
149
+ | ---------------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------ |
150
+ | ![GitHub Dark](examples/svgs/themes/github-dark.svg) | ![GitHub Light](examples/svgs/themes/github-light.svg) | ![Gruvbox Dark](examples/svgs/themes/gruvbox-dark.svg) |
151
+
152
+ | Gruvbox Light | Solarized Dark | Solarized Light |
153
+ | -------------------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
154
+ | ![Gruvbox Light](examples/svgs/themes/gruvbox-light.svg) | ![Solarized Dark](examples/svgs/themes/solarized-dark.svg) | ![Solarized Light](examples/svgs/themes/solarized-light.svg) |
155
+
156
+ ## Custom Themes
157
+
158
+ ```typescript
159
+ import shellfie, { createTheme } from "shellfie";
160
+
161
+ const theme = createTheme({
162
+ name: "ocean",
163
+ background: "#0a2540",
164
+ foreground: "#e6f1ff",
165
+ red: "#ff6b6b",
166
+ green: "#69db7c",
167
+ // ... all 16 ANSI colors
168
+ });
169
+
170
+ shellfie(output, { theme });
171
+ ```
172
+
173
+ ## Full Color Support
174
+
175
+ ### 24-bit True Color & 256-color palette
176
+
177
+ ```typescript
178
+ import gradient from "gradient-string";
179
+ import shellfie from "shellfie";
180
+
181
+ const svg = shellfie(gradient.rainbow("Hello World"), {
182
+ template: "macos",
183
+ title: "gradient string",
184
+ });
185
+ ```
186
+
187
+ ![Gradient String](examples/svgs/gradient-string.svg)
188
+
189
+ ### Works with any ANSI output
190
+
191
+ ```typescript
192
+ import Chartscii from "chartscii";
193
+ import shellfie from "shellfie";
194
+
195
+ const chart = new Chartscii(data, {
196
+ barSize: 2,
197
+ fill: "▒",
198
+ colorLabels: true,
199
+ orientation: "vertical",
200
+ valueLabels: true,
201
+ });
202
+
203
+ const svg = shellfie(chart.create(), {
204
+ template: "macos",
205
+ title: "Chartscii",
206
+ padding: 50,
207
+ });
208
+ ```
209
+
210
+ ![Chartscii](examples/svgs/chartscii.svg)
211
+
212
+ ### CLI tools, test runners, anything
213
+
214
+ ```typescript
215
+ shellfie(execSync("git diff --color=always").toString());
216
+ shellfie(execSync("npm test 2>&1").toString());
217
+ shellfie(execSync("ls -la --color=always").toString());
218
+ ```
219
+
220
+ ## Utilities
221
+
222
+ ```typescript
223
+ import { parse, render, stripAnsi, getMaxWidth } from "shellfie";
224
+
225
+ const lines = parse("\x1b[31mred\x1b[0m text");
226
+ const svg = render(lines, options);
227
+
228
+ stripAnsi("\x1b[31mred\x1b[0m"); // 'red'
229
+ getMaxWidth(lines); // 80
230
+ ```
231
+
232
+ ## Related
233
+ - See [shellfie-cli](https://github.com/tool3/shellfie-cli) for command line usage
234
+
235
+ ## License
236
+
237
+ MIT — do whatever you want with it. If you build something cool, I'd love to see it.
238
+
@@ -0,0 +1,21 @@
1
+ import type { FontConfig } from '../types';
2
+ export declare const defaultFontFamily = "'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace";
3
+ export declare const systemFontPaths: Record<string, string[]>;
4
+ export declare function getFontFormat(path: string): 'woff2' | 'woff' | 'ttf' | null;
5
+ export declare function loadFont(path: string): Promise<{
6
+ data: string;
7
+ format: 'woff2' | 'woff' | 'ttf';
8
+ } | null>;
9
+ export declare function createFontConfig(options: {
10
+ family?: string;
11
+ size?: number;
12
+ lineHeight?: number;
13
+ embedData?: string;
14
+ embedFormat?: 'woff2' | 'woff' | 'ttf';
15
+ }): FontConfig;
16
+ export declare function findSystemFont(): string | null;
17
+ export declare function loadEmbeddedFont(customPath?: string): Promise<{
18
+ data: string;
19
+ format: 'woff2' | 'woff' | 'ttf';
20
+ } | null>;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fonts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,eAAO,MAAM,iBAAiB,sFACuD,CAAC;AAEtF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAepD,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAa3E;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;CAAE,GAAG,IAAI,CAAC,CAkBpE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC,GAAG,UAAU,CASb;AAED,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAW9C;AAED,wBAAsB,gBAAgB,CACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;CAAE,GAAG,IAAI,CAAC,CAcpE"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.systemFontPaths = exports.defaultFontFamily = void 0;
4
+ exports.getFontFormat = getFontFormat;
5
+ exports.loadFont = loadFont;
6
+ exports.createFontConfig = createFontConfig;
7
+ exports.findSystemFont = findSystemFont;
8
+ exports.loadEmbeddedFont = loadEmbeddedFont;
9
+ const promises_1 = require("node:fs/promises");
10
+ const node_fs_1 = require("node:fs");
11
+ exports.defaultFontFamily = "'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace";
12
+ exports.systemFontPaths = {
13
+ darwin: [
14
+ '/System/Library/Fonts/SFMono.ttf',
15
+ '/System/Library/Fonts/Monaco.dfont',
16
+ '/System/Library/Fonts/Menlo.ttc',
17
+ ],
18
+ linux: [
19
+ '/usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf',
20
+ '/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',
21
+ '/usr/share/fonts/TTF/DejaVuSansMono.ttf',
22
+ ],
23
+ win32: [
24
+ 'C:\\Windows\\Fonts\\consola.ttf',
25
+ 'C:\\Windows\\Fonts\\cour.ttf',
26
+ ],
27
+ };
28
+ function getFontFormat(path) {
29
+ const ext = path.toLowerCase().split('.').pop();
30
+ switch (ext) {
31
+ case 'woff2':
32
+ return 'woff2';
33
+ case 'woff':
34
+ return 'woff';
35
+ case 'ttf':
36
+ case 'otf':
37
+ return 'ttf';
38
+ default:
39
+ return null;
40
+ }
41
+ }
42
+ async function loadFont(path) {
43
+ try {
44
+ if (!(0, node_fs_1.existsSync)(path)) {
45
+ return null;
46
+ }
47
+ const format = getFontFormat(path);
48
+ if (!format) {
49
+ return null;
50
+ }
51
+ const buffer = await (0, promises_1.readFile)(path);
52
+ const data = buffer.toString('base64');
53
+ return { data, format };
54
+ }
55
+ catch {
56
+ return null;
57
+ }
58
+ }
59
+ function createFontConfig(options) {
60
+ return {
61
+ family: options.family ?? exports.defaultFontFamily,
62
+ size: options.size ?? 14,
63
+ lineHeight: options.lineHeight ?? 1.4,
64
+ charWidth: 0.6,
65
+ embedData: options.embedData,
66
+ embedFormat: options.embedFormat,
67
+ };
68
+ }
69
+ function findSystemFont() {
70
+ const platform = process.platform;
71
+ const paths = exports.systemFontPaths[platform] ?? [];
72
+ for (const path of paths) {
73
+ if ((0, node_fs_1.existsSync)(path)) {
74
+ return path;
75
+ }
76
+ }
77
+ return null;
78
+ }
79
+ async function loadEmbeddedFont(customPath) {
80
+ if (customPath) {
81
+ const result = await loadFont(customPath);
82
+ if (result) {
83
+ return result;
84
+ }
85
+ }
86
+ const systemPath = findSystemFont();
87
+ if (systemPath) {
88
+ return loadFont(systemPath);
89
+ }
90
+ return null;
91
+ }
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fonts/index.ts"],"names":[],"mappings":";;;AAwBA,sCAaC;AAED,4BAoBC;AAED,4CAeC;AAED,wCAWC;AAED,4CAgBC;AA1GD,+CAA4C;AAC5C,qCAAqC;AAExB,QAAA,iBAAiB,GAC5B,mFAAmF,CAAC;AAEzE,QAAA,eAAe,GAA6B;IACvD,MAAM,EAAE;QACN,kCAAkC;QAClC,oCAAoC;QACpC,iCAAiC;KAClC;IACD,KAAK,EAAE;QACL,mDAAmD;QACnD,qDAAqD;QACrD,yCAAyC;KAC1C;IACD,KAAK,EAAE;QACL,iCAAiC;QACjC,8BAA8B;KAC/B;CACF,CAAC;AAEF,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAChD,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACR,OAAO,KAAK,CAAC;QACf;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,QAAQ,CAC5B,IAAY;IAEZ,IAAI,CAAC;QACH,IAAI,CAAC,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAMhC;IACC,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,yBAAiB;QAC3C,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,GAAG;QACrC,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC;AACJ,CAAC;AAED,SAAgB,cAAc;IAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,KAAK,GAAG,uBAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAE9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,KAAK,UAAU,gBAAgB,CACpC,UAAmB;IAEnB,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,cAAc,EAAE,CAAC;IACpC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ParsedLine, shellfieOptions } from './types';
2
+ export declare const shellfie: (input: string, options?: shellfieOptions) => string;
3
+ export declare const shellfieAsync: (input: string, options?: shellfieOptions) => Promise<string>;
4
+ export declare const parse: (input: string) => ParsedLine[];
5
+ export declare const render: (lines: ParsedLine[], options?: shellfieOptions) => string;
6
+ export type { ControlStyle, FontConfig, ParsedLine, RGB, ShellConfig, shellfieOptions, Template, TextSpan, TextStyle, Theme } from './types';
7
+ export { createFontConfig, loadEmbeddedFont, loadFont } from './fonts';
8
+ export { getMaxWidth, parseAnsi, stripAnsi } from './parser';
9
+ export { createTheme, darkTheme } from './renderer';
10
+ export { createTemplate, resolveTemplate, templates } from './templates';
11
+ export * from './themes';
12
+ export { themes } from './themes';
13
+ export default shellfie;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAIV,UAAU,EAKV,eAAe,EAEhB,MAAM,SAAS,CAAC;AAmFjB,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,EAAE,UAAS,eAAoB,KAAG,MACd,CAAC;AAE3D,eAAO,MAAM,aAAa,GACxB,OAAO,MAAM,EACb,UAAS,eAAoB,KAC5B,OAAO,CAAC,MAAM,CAYhB,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,UAAU,EAAsB,CAAC;AAEvE,eAAO,MAAM,MAAM,GAAI,OAAO,UAAU,EAAE,EAAE,UAAS,eAAoB,KAAG,MAC7B,CAAC;AAEhD,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,GAAG,EACH,WAAW,EACX,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzE,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAe,QAAQ,CAAC"}