shellfie 1.2.8 → 1.3.3
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 +46 -9
- package/package.json +1 -1
- package/shellfie.js +18 -6
- package/template/template.css +4 -0
- package/utils/styles.js +32 -0
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# shellfie 🤳🏽
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="./shellfies/logo.png" />
|
|
4
4
|
|
|
5
5
|
# install
|
|
6
6
|
```bash
|
|
7
|
-
|
|
7
|
+
npm install shellfie
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
# the holy trinity ▽
|
|
11
|
-
`shellfie` respects the holy trinity: the lib, the service, and the cli.
|
|
11
|
+
`shellfie` respects the holy trinity: the lib, the service, and the holy cli.
|
|
12
12
|
- [shellfie](https://github.com/tool3/shellfie)
|
|
13
13
|
- [shellfied](https://github.com/tool3/shellfied)
|
|
14
14
|
- [shellfie-cli](https://github.com/tool3/shellfie-cli)
|
|
15
15
|
|
|
16
16
|
# usage
|
|
17
|
-
```
|
|
17
|
+
```javascript
|
|
18
18
|
const data = [
|
|
19
19
|
'\x1b[105mSHELLFIE\\x1b[0m🤳',
|
|
20
20
|
'\x1b[38;5;225mthe easiest way',
|
|
@@ -95,15 +95,15 @@ outputs:
|
|
|
95
95
|
**type**: `number`
|
|
96
96
|
**description**: viewport height
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
# examples
|
|
99
|
+
```javascript
|
|
100
|
+
await shellfie(["\x1b[32mGreen line", "\x1b[31;1mRED bold"], { name: 'small', viewport: { width: 200, height: 200 } });
|
|
101
|
+
```
|
|
102
102
|
|
|
103
103
|
<img src="./shellfies/small.png" />
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
```
|
|
106
|
+
```javascript
|
|
107
107
|
const testResults = [
|
|
108
108
|
"[2K[1G[1myarn run v1.22.5[22m",
|
|
109
109
|
"[2K[1G[2m$ mocha --no-timeouts tests/ --colors[22m",
|
|
@@ -129,6 +129,43 @@ const testResults = [
|
|
|
129
129
|
"[2K[1GDone in 19.60s.",
|
|
130
130
|
];
|
|
131
131
|
await shellfie(testResults, { name: 'fira', style: { fontFamily: 'Fira Code', fontWeight: 'bold' } });
|
|
132
|
+
await shellfie(testResults, { name: 'monospace', style: { fontFamily: 'monospace' } });
|
|
133
|
+
await shellfie(testResults, { name: 'monaco', style: { fontFamily: 'Monaco' } });
|
|
132
134
|
```
|
|
133
135
|
|
|
134
136
|
<img src="./shellfies/fira.png" />
|
|
137
|
+
<img src="./shellfies/monospace.png" />
|
|
138
|
+
<img src="./shellfies/monaco.png" />
|
|
139
|
+
|
|
140
|
+
### raw mode
|
|
141
|
+
```javascript
|
|
142
|
+
const string = `
|
|
143
|
+
cristal [38;2;189;255;243m■[39m[38;2;187;254;241m■[39m[38;2;184;252;239m■[39m[38;2;182;251;237m■[39m[38;2;179;250;235m■[39m[38;2;177;249;234m■[39m[38;2;174;247;232m■[39m[38;2;172;246;230m■[39m[38;2;169;245;228m■[39m[38;2;167;243;226m■[39m[38;2;165;242;224m■[39m[38;2;162;241;222m■[39m[38;2;160;239;220m■[39m[38;2;157;238;218m■[39m[38;2;155;237;216m■[39m[38;2;152;236;215m■[39m[38;2;150;234;213m■[39m[38;2;147;233;211m■[39m[38;2;145;232;209m■[39m[38;2;143;230;207m■[39m[38;2;140;229;205m■[39m[38;2;138;228;203m■[39m[38;2;135;226;201m■[39m[38;2;133;225;199m■[39m[38;2;130;224;198m■[39m[38;2;128;223;196m■[39m[38;2;125;221;194m■[39m[38;2;123;220;192m■[39m[38;2;120;219;190m■[39m[38;2;118;217;188m■[39m[38;2;116;216;186m■[39m[38;2;113;215;184m■[39m[38;2;111;213;182m■[39m[38;2;108;212;181m■[39m[38;2;106;211;179m■[39m[38;2;103;210;177m■[39m[38;2;101;208;175m■[39m[38;2;98;207;173m■[39m[38;2;96;206;171m■[39m[38;2;94;204;169m■[39m[38;2;91;203;167m■[39m[38;2;89;202;165m■[39m[38;2;86;200;163m■[39m[38;2;84;199;162m■[39m[38;2;81;198;160m■[39m[38;2;79;197;158m■[39m[38;2;76;195;156m■[39m[38;2;74;194;154m■[39m
|
|
144
|
+
teen [38;2;119;161;211m■[39m[38;2;119;163;211m■[39m[38;2;119;165;210m■[39m[38;2;119;166;210m■[39m[38;2;119;168;209m■[39m[38;2;119;170;209m■[39m[38;2;120;172;209m■[39m[38;2;120;174;208m■[39m[38;2;120;176;208m■[39m[38;2;120;177;207m■[39m[38;2;120;179;207m■[39m[38;2;120;181;207m■[39m[38;2;120;183;206m■[39m[38;2;120;185;206m■[39m[38;2;120;187;206m■[39m[38;2;120;188;205m■[39m[38;2;120;190;205m■[39m[38;2;120;192;204m■[39m[38;2;121;194;204m■[39m[38;2;121;196;204m■[39m[38;2;121;198;203m■[39m[38;2;121;199;203m■[39m[38;2;121;201;202m■[39m[38;2;121;203;202m■[39m[38;2;126;200;201m■[39m[38;2;130;197;200m■[39m[38;2;135;194;199m■[39m[38;2;139;191;197m■[39m[38;2;144;188;196m■[39m[38;2;148;185;195m■[39m[38;2;153;182;194m■[39m[38;2;157;179;193m■[39m[38;2;162;176;192m■[39m[38;2;166;173;190m■[39m[38;2;171;170;189m■[39m[38;2;176;168;188m■[39m[38;2;180;165;187m■[39m[38;2;185;162;186m■[39m[38;2;189;159;185m■[39m[38;2;194;156;183m■[39m[38;2;198;153;182m■[39m[38;2;203;150;181m■[39m[38;2;207;147;180m■[39m[38;2;212;144;179m■[39m[38;2;216;141;178m■[39m[38;2;221;138;176m■[39m[38;2;225;135;175m■[39m[38;2;230;132;174m■[39m
|
|
145
|
+
mind [38;2;71;59;123m■[39m[38;2;70;62;125m■[39m[38;2;69;65;127m■[39m[38;2;69;69;129m■[39m[38;2;68;72;131m■[39m[38;2;67;75;133m■[39m[38;2;66;78;134m■[39m[38;2;66;81;136m■[39m[38;2;65;84;138m■[39m[38;2;64;88;140m■[39m[38;2;63;91;142m■[39m[38;2;62;94;144m■[39m[38;2;62;97;146m■[39m[38;2;61;100;148m■[39m[38;2;60;103;150m■[39m[38;2;59;107;152m■[39m[38;2;58;110;154m■[39m[38;2;58;113;156m■[39m[38;2;57;116;157m■[39m[38;2;56;119;159m■[39m[38;2;55;122;161m■[39m[38;2;55;126;163m■[39m[38;2;54;129;165m■[39m[38;2;53;132;167m■[39m[38;2;53;135;168m■[39m[38;2;53;139;169m■[39m[38;2;52;142;170m■[39m[38;2;52;145;171m■[39m[38;2;52;148;172m■[39m[38;2;52;152;173m■[39m[38;2;52;155;174m■[39m[38;2;51;158;175m■[39m[38;2;51;161;176m■[39m[38;2;51;165;177m■[39m[38;2;51;168;178m■[39m[38;2;51;171;179m■[39m[38;2;50;174;179m■[39m[38;2;50;178;180m■[39m[38;2;50;181;181m■[39m[38;2;50;184;182m■[39m[38;2;49;187;183m■[39m[38;2;49;191;184m■[39m[38;2;49;194;185m■[39m[38;2;49;197;186m■[39m[38;2;49;200;187m■[39m[38;2;48;204;188m■[39m[38;2;48;207;189m■[39m[38;2;48;210;190m■[39m
|
|
146
|
+
morning [38;2;255;95;109m■[39m[38;2;255;95;107m■[39m[38;2;255;96;105m■[39m[38;2;255;96;103m■[39m[38;2;255;97;101m■[39m[38;2;255;97;100m■[39m[38;2;255;97;98m■[39m[38;2;255;100;98m■[39m[38;2;255;102;98m■[39m[38;2;255;105;98m■[39m[38;2;255;107;99m■[39m[38;2;255;110;99m■[39m[38;2;255;112;100m■[39m[38;2;255;115;100m■[39m[38;2;255;117;100m■[39m[38;2;255;120;101m■[39m[38;2;255;123;101m■[39m[38;2;255;125;102m■[39m[38;2;255;127;102m■[39m[38;2;255;130;102m■[39m[38;2;255;132;103m■[39m[38;2;255;135;103m■[39m[38;2;255;137;103m■[39m[38;2;255;140;104m■[39m[38;2;255;142;104m■[39m[38;2;255;145;105m■[39m[38;2;255;147;105m■[39m[38;2;255;149;105m■[39m[38;2;255;152;106m■[39m[38;2;255;154;106m■[39m[38;2;255;157;107m■[39m[38;2;255;159;107m■[39m[38;2;255;161;107m■[39m[38;2;255;164;108m■[39m[38;2;255;166;108m■[39m[38;2;255;168;108m■[39m[38;2;255;170;109m■[39m[38;2;255;173;109m■[39m[38;2;255;175;110m■[39m[38;2;255;177;110m■[39m[38;2;255;180;110m■[39m[38;2;255;182;111m■[39m[38;2;255;184;111m■[39m[38;2;255;186;111m■[39m[38;2;255;188;112m■[39m[38;2;255;191;112m■[39m[38;2;255;193;113m■[39m[38;2;255;195;113m■[39m
|
|
147
|
+
vice [38;2;94;231;223m■[39m[38;2;95;230;227m■[39m[38;2;96;228;230m■[39m[38;2;98;223;229m■[39m[38;2;99;218;229m■[39m[38;2;100;213;228m■[39m[38;2;101;208;227m■[39m[38;2;103;203;227m■[39m[38;2;104;198;226m■[39m[38;2;105;194;225m■[39m[38;2;106;189;225m■[39m[38;2;107;185;224m■[39m[38;2;108;181;224m■[39m[38;2;110;177;223m■[39m[38;2;111;173;222m■[39m[38;2;112;169;222m■[39m[38;2;113;166;221m■[39m[38;2;114;162;220m■[39m[38;2;115;159;220m■[39m[38;2;116;155;219m■[39m[38;2;117;152;219m■[39m[38;2;119;149;218m■[39m[38;2;120;146;217m■[39m[38;2;121;143;217m■[39m[38;2;122;141;216m■[39m[38;2;123;138;216m■[39m[38;2;124;136;215m■[39m[38;2;125;133;214m■[39m[38;2;126;131;214m■[39m[38;2;127;129;213m■[39m[38;2;129;128;212m■[39m[38;2;133;129;212m■[39m[38;2;137;130;211m■[39m[38;2;141;131;211m■[39m[38;2;144;132;210m■[39m[38;2;148;133;209m■[39m[38;2;151;134;209m■[39m[38;2;154;135;208m■[39m[38;2;157;136;208m■[39m[38;2;160;137;207m■[39m[38;2;163;138;206m■[39m[38;2;166;139;206m■[39m[38;2;169;140;205m■[39m[38;2;171;140;204m■[39m[38;2;173;141;204m■[39m[38;2;176;142;203m■[39m[38;2;178;143;203m■[39m[38;2;180;144;202m■[39m
|
|
148
|
+
passion [38;2;244;59;71m■[39m[38;2;240;59;73m■[39m[38;2;237;59;74m■[39m[38;2;233;59;76m■[39m[38;2;229;59;78m■[39m[38;2;225;59;79m■[39m[38;2;222;59;81m■[39m[38;2;218;59;82m■[39m[38;2;214;59;84m■[39m[38;2;210;59;86m■[39m[38;2;207;59;87m■[39m[38;2;203;59;89m■[39m[38;2;199;59;91m■[39m[38;2;196;59;92m■[39m[38;2;192;59;94m■[39m[38;2;188;59;96m■[39m[38;2;184;59;97m■[39m[38;2;181;59;99m■[39m[38;2;177;59;100m■[39m[38;2;173;59;102m■[39m[38;2;170;59;104m■[39m[38;2;166;59;105m■[39m[38;2;162;59;107m■[39m[38;2;158;59;109m■[39m[38;2;155;58;110m■[39m[38;2;151;58;112m■[39m[38;2;147;58;114m■[39m[38;2;143;58;115m■[39m[38;2;140;58;117m■[39m[38;2;136;58;119m■[39m[38;2;132;58;120m■[39m[38;2;129;58;122m■[39m[38;2;125;58;123m■[39m[38;2;121;58;125m■[39m[38;2;117;58;127m■[39m[38;2;114;58;128m■[39m[38;2;110;58;130m■[39m[38;2;106;58;132m■[39m[38;2;103;58;133m■[39m[38;2;99;58;135m■[39m[38;2;95;58;137m■[39m[38;2;91;58;138m■[39m[38;2;88;58;140m■[39m[38;2;84;58;141m■[39m[38;2;80;58;143m■[39m[38;2;76;58;145m■[39m[38;2;73;58;146m■[39m[38;2;69;58;148m■[39m
|
|
149
|
+
fruit [38;2;255;78;80m■[39m[38;2;255;81;79m■[39m[38;2;255;84;78m■[39m[38;2;255;87;77m■[39m[38;2;254;89;76m■[39m[38;2;254;92;75m■[39m[38;2;254;95;74m■[39m[38;2;254;98;73m■[39m[38;2;254;101;72m■[39m[38;2;254;104;71m■[39m[38;2;254;107;70m■[39m[38;2;254;109;69m■[39m[38;2;253;112;69m■[39m[38;2;253;115;68m■[39m[38;2;253;118;67m■[39m[38;2;253;121;66m■[39m[38;2;253;124;65m■[39m[38;2;253;126;64m■[39m[38;2;253;129;63m■[39m[38;2;253;132;62m■[39m[38;2;252;135;61m■[39m[38;2;252;138;60m■[39m[38;2;252;141;59m■[39m[38;2;252;144;58m■[39m[38;2;252;146;57m■[39m[38;2;252;149;56m■[39m[38;2;252;152;55m■[39m[38;2;252;155;54m■[39m[38;2;251;158;53m■[39m[38;2;251;161;52m■[39m[38;2;251;164;51m■[39m[38;2;251;166;50m■[39m[38;2;251;169;49m■[39m[38;2;251;172;48m■[39m[38;2;251;175;47m■[39m[38;2;251;178;46m■[39m[38;2;250;181;46m■[39m[38;2;250;183;45m■[39m[38;2;250;186;44m■[39m[38;2;250;189;43m■[39m[38;2;250;192;42m■[39m[38;2;250;195;41m■[39m[38;2;250;198;40m■[39m[38;2;250;201;39m■[39m[38;2;249;203;38m■[39m[38;2;249;206;37m■[39m[38;2;249;209;36m■[39m[38;2;249;212;35m■[39m
|
|
150
|
+
instagram [38;2;131;58;180m■[39m[38;2;136;57;173m■[39m[38;2;142;55;167m■[39m[38;2;147;54;160m■[39m[38;2;152;53;154m■[39m[38;2;158;52;147m■[39m[38;2;163;50;141m■[39m[38;2;168;49;134m■[39m[38;2;173;48;127m■[39m[38;2;179;47;121m■[39m[38;2;184;45;114m■[39m[38;2;189;44;108m■[39m[38;2;195;43;101m■[39m[38;2;200;42;95m■[39m[38;2;205;40;88m■[39m[38;2;211;39;82m■[39m[38;2;216;38;75m■[39m[38;2;221;37;68m■[39m[38;2;226;35;62m■[39m[38;2;232;34;55m■[39m[38;2;237;33;49m■[39m[38;2;242;32;42m■[39m[38;2;248;30;36m■[39m[38;2;253;29;29m■[39m[38;2;253;35;31m■[39m[38;2;253;41;32m■[39m[38;2;253;47;34m■[39m[38;2;253;54;36m■[39m[38;2;253;60;37m■[39m[38;2;253;66;39m■[39m[38;2;253;72;41m■[39m[38;2;253;78;42m■[39m[38;2;253;84;44m■[39m[38;2;253;90;46m■[39m[38;2;253;96;47m■[39m[38;2;253;103;49m■[39m[38;2;252;109;51m■[39m[38;2;252;115;52m■[39m[38;2;252;121;54m■[39m[38;2;252;127;56m■[39m[38;2;252;133;57m■[39m[38;2;252;139;59m■[39m[38;2;252;145;61m■[39m[38;2;252;152;62m■[39m[38;2;252;158;64m■[39m[38;2;252;164;66m■[39m[38;2;252;170;67m■[39m[38;2;252;176;69m■[39m
|
|
151
|
+
atlas [38;2;254;172;94m■[39m[38;2;252;170;99m■[39m[38;2;249;168;104m■[39m[38;2;247;165;109m■[39m[38;2;244;163;114m■[39m[38;2;242;161;119m■[39m[38;2;240;159;124m■[39m[38;2;237;156;129m■[39m[38;2;235;154;134m■[39m[38;2;232;152;139m■[39m[38;2;230;150;144m■[39m[38;2;228;148;149m■[39m[38;2;225;145;153m■[39m[38;2;223;143;158m■[39m[38;2;221;141;163m■[39m[38;2;218;139;168m■[39m[38;2;216;137;173m■[39m[38;2;213;134;178m■[39m[38;2;211;132;183m■[39m[38;2;209;130;188m■[39m[38;2;206;128;193m■[39m[38;2;204;125;198m■[39m[38;2;201;123;203m■[39m[38;2;199;121;208m■[39m[38;2;194;124;208m■[39m[38;2;189;127;207m■[39m[38;2;184;130;207m■[39m[38;2;178;133;207m■[39m[38;2;173;136;206m■[39m[38;2;168;139;206m■[39m[38;2;163;142;206m■[39m[38;2;158;145;205m■[39m[38;2;153;148;205m■[39m[38;2;147;151;205m■[39m[38;2;142;154;204m■[39m[38;2;137;157;204m■[39m[38;2;132;159;204m■[39m[38;2;127;162;203m■[39m[38;2;122;165;203m■[39m[38;2;116;168;203m■[39m[38;2;111;171;202m■[39m[38;2;106;174;202m■[39m[38;2;101;177;202m■[39m[38;2;96;180;201m■[39m[38;2;91;183;201m■[39m[38;2;85;186;201m■[39m[38;2;80;189;200m■[39m[38;2;75;192;200m■[39m
|
|
152
|
+
retro [38;2;63;81;177m■[39m[38;2;68;82;176m■[39m[38;2;74;83;176m■[39m[38;2;79;83;175m■[39m[38;2;85;84;175m■[39m[38;2;90;85;174m■[39m[38;2;96;87;174m■[39m[38;2;101;88;173m■[39m[38;2;107;90;173m■[39m[38;2;112;92;173m■[39m[38;2;118;93;172m■[39m[38;2;123;95;172m■[39m[38;2;126;97;172m■[39m[38;2;130;99;173m■[39m[38;2;133;101;173m■[39m[38;2;136;102;173m■[39m[38;2;140;104;174m■[39m[38;2;143;106;174m■[39m[38;2;147;106;172m■[39m[38;2;151;106;171m■[39m[38;2;156;106;169m■[39m[38;2;160;106;167m■[39m[38;2;164;106;166m■[39m[38;2;168;106;164m■[39m[38;2;174;106;160m■[39m[38;2;180;106;157m■[39m[38;2;186;107;153m■[39m[38;2;192;107;149m■[39m[38;2;198;107;146m■[39m[38;2;204;107;142m■[39m[38;2;210;111;137m■[39m[38;2;216;115;132m■[39m[38;2;223;119;128m■[39m[38;2;229;122;123m■[39m[38;2;235;126;118m■[39m[38;2;241;130;113m■[39m[38;2;241;136;112m■[39m[38;2;242;141;110m■[39m[38;2;242;147;109m■[39m[38;2;242;153;108m■[39m[38;2;243;158;106m■[39m[38;2;243;164;105m■[39m[38;2;244;170;108m■[39m[38;2;244;176;110m■[39m[38;2;245;183;113m■[39m[38;2;246;189;115m■[39m[38;2;246;195;118m■[39m[38;2;247;201;120m■[39m
|
|
153
|
+
summer [38;2;253;187;45m■[39m[38;2;248;187;48m■[39m[38;2;244;187;51m■[39m[38;2;239;187;55m■[39m[38;2;234;188;58m■[39m[38;2;230;188;61m■[39m[38;2;225;188;64m■[39m[38;2;220;188;67m■[39m[38;2;216;188;71m■[39m[38;2;211;188;74m■[39m[38;2;206;188;77m■[39m[38;2;202;188;80m■[39m[38;2;197;189;83m■[39m[38;2;192;189;86m■[39m[38;2;188;189;90m■[39m[38;2;183;189;93m■[39m[38;2;178;189;96m■[39m[38;2;174;189;99m■[39m[38;2;169;189;102m■[39m[38;2;164;189;106m■[39m[38;2;160;190;109m■[39m[38;2;155;190;112m■[39m[38;2;150;190;115m■[39m[38;2;146;190;118m■[39m[38;2;141;190;122m■[39m[38;2;137;190;125m■[39m[38;2;132;190;128m■[39m[38;2;127;190;131m■[39m[38;2;123;191;134m■[39m[38;2;118;191;138m■[39m[38;2;113;191;141m■[39m[38;2;109;191;144m■[39m[38;2;104;191;147m■[39m[38;2;99;191;150m■[39m[38;2;95;191;154m■[39m[38;2;90;191;157m■[39m[38;2;85;192;160m■[39m[38;2;81;192;163m■[39m[38;2;76;192;166m■[39m[38;2;71;192;169m■[39m[38;2;67;192;173m■[39m[38;2;62;192;176m■[39m[38;2;57;192;179m■[39m[38;2;53;192;182m■[39m[38;2;48;193;185m■[39m[38;2;43;193;189m■[39m[38;2;39;193;192m■[39m[38;2;34;193;195m■[39m
|
|
154
|
+
pastel [38;2;116;235;213m■[39m[38;2;116;235;228m■[39m[38;2;116;227;235m■[39m[38;2;116;212;235m■[39m[38;2;116;196;235m■[39m[38;2;116;181;235m■[39m[38;2;116;166;235m■[39m[38;2;116;151;235m■[39m[38;2;116;136;235m■[39m[38;2;116;120;235m■[39m[38;2;127;116;235m■[39m[38;2;142;116;235m■[39m[38;2;157;116;235m■[39m[38;2;172;116;235m■[39m[38;2;188;116;235m■[39m[38;2;203;116;235m■[39m[38;2;218;116;235m■[39m[38;2;233;116;235m■[39m[38;2;235;116;222m■[39m[38;2;235;116;207m■[39m[38;2;235;116;192m■[39m[38;2;235;116;177m■[39m[38;2;235;116;161m■[39m[38;2;235;116;146m■[39m[38;2;235;116;131m■[39m[38;2;236;116;116m■[39m[38;2;236;132;116m■[39m[38;2;236;147;116m■[39m[38;2;236;162;116m■[39m[38;2;236;177;116m■[39m[38;2;236;193;116m■[39m[38;2;236;208;116m■[39m[38;2;236;223;116m■[39m[38;2;233;236;116m■[39m[38;2;218;236;116m■[39m[38;2;202;236;116m■[39m[38;2;187;236;116m■[39m[38;2;172;236;116m■[39m[38;2;157;236;116m■[39m[38;2;141;236;116m■[39m[38;2;126;236;116m■[39m[38;2;116;236;121m■[39m[38;2;116;236;136m■[39m[38;2;116;236;152m■[39m[38;2;116;236;167m■[39m[38;2;116;236;182m■[39m[38;2;116;236;198m■[39m[38;2;116;236;213m■[39m
|
|
155
|
+
rainbow [38;2;255;0;0m■[39m[38;2;255;0;33m■[39m[38;2;255;0;65m■[39m[38;2;255;0;98m■[39m[38;2;255;0;130m■[39m[38;2;255;0;163m■[39m[38;2;255;0;195m■[39m[38;2;255;0;228m■[39m[38;2;250;0;255m■[39m[38;2;217;0;255m■[39m[38;2;185;0;255m■[39m[38;2;152;0;255m■[39m[38;2;120;0;255m■[39m[38;2;87;0;255m■[39m[38;2;55;0;255m■[39m[38;2;22;0;255m■[39m[38;2;0;11;255m■[39m[38;2;0;43;255m■[39m[38;2;0;76;255m■[39m[38;2;0;108;255m■[39m[38;2;0;141;255m■[39m[38;2;0;173;255m■[39m[38;2;0;206;255m■[39m[38;2;0;238;255m■[39m[38;2;0;255;239m■[39m[38;2;0;255;207m■[39m[38;2;0;255;174m■[39m[38;2;0;255;142m■[39m[38;2;0;255;109m■[39m[38;2;0;255;77m■[39m[38;2;0;255;44m■[39m[38;2;0;255;12m■[39m[38;2;21;255;0m■[39m[38;2;54;255;0m■[39m[38;2;86;255;0m■[39m[38;2;119;255;0m■[39m[38;2;151;255;0m■[39m[38;2;184;255;0m■[39m[38;2;216;255;0m■[39m[38;2;249;255;0m■[39m[38;2;255;229;0m■[39m[38;2;255;196;0m■[39m[38;2;255;164;0m■[39m[38;2;255;131;0m■[39m[38;2;255;99;0m■[39m[38;2;255;66;0m■[39m[38;2;255;34;0m■[39m[38;2;255;1;0m■[39m
|
|
156
|
+
`
|
|
157
|
+
await shellfie(string, { name: 'gradient', mode: 'raw', viewport: {width: 600, height: 350} });
|
|
158
|
+
```
|
|
159
|
+
<img src="./shellfies/gradient.png" />
|
|
160
|
+
|
|
161
|
+
### bash colors
|
|
162
|
+
```javascript
|
|
163
|
+
const shellfie = require('shellfie');
|
|
164
|
+
let backgroundColors = '';
|
|
165
|
+
for (let i = 0; i < 255; i++) {
|
|
166
|
+
backgroundColors += `\x1b[48;5;${i}m ${i}\x1b[0m`;
|
|
167
|
+
}
|
|
168
|
+
await shellfie(backgroundColors, { name: 'background', viewport: {width: 500, height: 400} });
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
<img src="./shellfies/background.png" />
|
package/package.json
CHANGED
package/shellfie.js
CHANGED
|
@@ -2,6 +2,7 @@ const puppeteer = require('puppeteer');
|
|
|
2
2
|
const getConfig = require('./utils/config');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs').promises;
|
|
5
|
+
const { getStyles } = require('./utils/styles');
|
|
5
6
|
|
|
6
7
|
async function shellfie(data, config) {
|
|
7
8
|
try {
|
|
@@ -20,8 +21,6 @@ async function shellfie(data, config) {
|
|
|
20
21
|
const lines = (Array.isArray(data) || mode === 'raw') ? data : data.split('\n');
|
|
21
22
|
|
|
22
23
|
// inject js scripts
|
|
23
|
-
const localModules = __dirname + '/node_modules';
|
|
24
|
-
console.log(localModules);
|
|
25
24
|
await page.addScriptTag({ path: require.resolve('xterm/lib/xterm.js') });
|
|
26
25
|
await page.addScriptTag({ path: require.resolve('xterm-addon-fit/lib/xterm-addon-fit.js') });
|
|
27
26
|
|
|
@@ -56,12 +55,25 @@ async function shellfie(data, config) {
|
|
|
56
55
|
document.querySelector('.xterm-screen').style.height = `${height}px`;
|
|
57
56
|
fit.fit();
|
|
58
57
|
|
|
59
|
-
}, { lines, mode, options:
|
|
58
|
+
}, { lines, mode, options: { theme, rendererType }, viewport });
|
|
60
59
|
|
|
61
|
-
// inject styles
|
|
62
|
-
await page.addStyleTag({ path: `${path.resolve(__dirname, 'template/template.css')}` });
|
|
63
|
-
await page.addStyleTag({ path: `${localModules}/xterm/css/xterm.css` });
|
|
64
60
|
await page.evaluate((theme) => document.querySelector('.terminal').style.background = theme.background, theme);
|
|
61
|
+
const templateStyle = __dirname + '/template/template.css';
|
|
62
|
+
|
|
63
|
+
// inject user style
|
|
64
|
+
if (style) {
|
|
65
|
+
const styles = getStyles(style);
|
|
66
|
+
const className = rendererType === 'dom' ? '.terminal.xterm' : 'canvas';
|
|
67
|
+
const content = `${className} {${styles}}`
|
|
68
|
+
await page.addStyleTag({content})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// inject styles
|
|
72
|
+
await page.addStyleTag({ path: templateStyle });
|
|
73
|
+
await page.addStyleTag({ path: `${localPath}/node_modules/xterm/css/xterm.css` });
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
65
77
|
await page.evaluateHandle('document.fonts.ready');
|
|
66
78
|
|
|
67
79
|
// crop image
|
package/template/template.css
CHANGED
package/utils/styles.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function processLine(key, value) {
|
|
2
|
+
const words = key.split(/(?=[A-Z])/);
|
|
3
|
+
if (words.length > 1) {
|
|
4
|
+
key = words.map(word => word.toLowerCase()).join('-')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
return `${key}: ${value};`
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function stringifyStyle(style) {
|
|
11
|
+
return Object.keys(style)
|
|
12
|
+
.map((rule) => processLine(rule, style[rule]))
|
|
13
|
+
.join(' ');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getStyle(className, style) {
|
|
17
|
+
return `${className}{ ${stringifyStyle(style)} }`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getStyles(style) {
|
|
21
|
+
return Object.keys(style)
|
|
22
|
+
.map((key) => {
|
|
23
|
+
if (typeof style[key] === "object") {
|
|
24
|
+
return getStyle(key, style[key]);
|
|
25
|
+
} else {
|
|
26
|
+
return processLine(key, style[key]);
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
.join('');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { stringifyStyle, getStyles, getStyle };
|