@socketsecurity/cli-with-sentry 0.14.137 → 0.14.139
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/dist/blessed/LICENSE +20 -0
- package/dist/blessed/lib/alias.js +519 -0
- package/dist/blessed/lib/blessed.js +32 -0
- package/dist/blessed/lib/colors.js +490 -0
- package/dist/blessed/lib/events.js +195 -0
- package/dist/blessed/lib/gpmclient.js +245 -0
- package/dist/blessed/lib/helpers.js +170 -0
- package/dist/blessed/lib/keys.js +512 -0
- package/dist/blessed/lib/program.js +4530 -0
- package/dist/blessed/lib/tput.js +3111 -0
- package/dist/blessed/lib/unicode.js +912 -0
- package/dist/blessed/lib/widget.js +60 -0
- package/dist/blessed/lib/widgets/ansiimage.js +173 -0
- package/dist/blessed/lib/widgets/bigtext.js +170 -0
- package/dist/blessed/lib/widgets/box.js +34 -0
- package/dist/blessed/lib/widgets/button.js +62 -0
- package/dist/blessed/lib/widgets/checkbox.js +95 -0
- package/dist/blessed/lib/widgets/element.js +2871 -0
- package/dist/blessed/lib/widgets/filemanager.js +223 -0
- package/dist/blessed/lib/widgets/form.js +301 -0
- package/dist/blessed/lib/widgets/image.js +71 -0
- package/dist/blessed/lib/widgets/input.js +34 -0
- package/dist/blessed/lib/widgets/layout.js +249 -0
- package/dist/blessed/lib/widgets/line.js +59 -0
- package/dist/blessed/lib/widgets/list.js +652 -0
- package/dist/blessed/lib/widgets/listbar.js +452 -0
- package/dist/blessed/lib/widgets/listtable.js +265 -0
- package/dist/blessed/lib/widgets/loading.js +88 -0
- package/dist/blessed/lib/widgets/log.js +82 -0
- package/dist/blessed/lib/widgets/message.js +145 -0
- package/dist/blessed/lib/widgets/node.js +314 -0
- package/dist/blessed/lib/widgets/overlayimage.js +794 -0
- package/dist/blessed/lib/widgets/progressbar.js +166 -0
- package/dist/blessed/lib/widgets/prompt.js +127 -0
- package/dist/blessed/lib/widgets/question.js +129 -0
- package/dist/blessed/lib/widgets/radiobutton.js +62 -0
- package/dist/blessed/lib/widgets/radioset.js +36 -0
- package/dist/blessed/lib/widgets/screen.js +2485 -0
- package/dist/blessed/lib/widgets/scrollablebox.js +415 -0
- package/dist/blessed/lib/widgets/scrollabletext.js +35 -0
- package/dist/blessed/lib/widgets/table.js +383 -0
- package/dist/blessed/lib/widgets/terminal.js +452 -0
- package/dist/blessed/lib/widgets/text.js +35 -0
- package/dist/blessed/lib/widgets/textarea.js +376 -0
- package/dist/blessed/lib/widgets/textbox.js +79 -0
- package/dist/blessed/lib/widgets/video.js +130 -0
- package/dist/blessed/usr/fonts/AUTHORS +1 -0
- package/dist/blessed/usr/fonts/LICENSE +94 -0
- package/dist/blessed/usr/fonts/README +340 -0
- package/dist/blessed/usr/fonts/ter-u14b.json +17826 -0
- package/dist/blessed/usr/fonts/ter-u14n.json +17826 -0
- package/dist/blessed/usr/linux +0 -0
- package/dist/blessed/usr/windows-ansi +0 -0
- package/dist/blessed/usr/xterm +0 -0
- package/dist/blessed/usr/xterm-256color +0 -0
- package/dist/blessed/usr/xterm.termcap +243 -0
- package/dist/blessed/usr/xterm.terminfo +1977 -0
- package/dist/blessed/vendor/tng.js +1876 -0
- package/dist/blessed-contrib/LICENSE.md +21 -0
- package/dist/blessed-contrib/lib/layout/carousel.js +82 -0
- package/dist/blessed-contrib/lib/layout/grid.js +46 -0
- package/dist/blessed-contrib/lib/server-utils.js +83 -0
- package/dist/blessed-contrib/lib/utils.js +73 -0
- package/dist/blessed-contrib/lib/widget/canvas.js +52 -0
- package/dist/blessed-contrib/lib/widget/charts/bar.js +99 -0
- package/dist/blessed-contrib/lib/widget/charts/line.js +311 -0
- package/dist/blessed-contrib/lib/widget/charts/stacked-bar.js +245 -0
- package/dist/blessed-contrib/lib/widget/donut.js +183 -0
- package/dist/blessed-contrib/lib/widget/gauge-list.js +111 -0
- package/dist/blessed-contrib/lib/widget/gauge.js +127 -0
- package/dist/blessed-contrib/lib/widget/lcd.js +497 -0
- package/dist/blessed-contrib/lib/widget/log.js +32 -0
- package/dist/blessed-contrib/lib/widget/map.js +97 -0
- package/dist/blessed-contrib/lib/widget/markdown.js +68 -0
- package/dist/blessed-contrib/lib/widget/picture.js +61 -0
- package/dist/blessed-contrib/lib/widget/sparkline.js +66 -0
- package/dist/blessed-contrib/lib/widget/table.js +141 -0
- package/dist/blessed-contrib/lib/widget/tree.js +179 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/index.js +6 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/license +21 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/package.json +64 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/readme.md +39 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/index.js +67 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/license +21 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/package.json +50 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/readme.md +86 -0
- package/dist/blessed-contrib/node_modules/chalk/index.js +118 -0
- package/dist/blessed-contrib/node_modules/chalk/license +21 -0
- package/dist/blessed-contrib/node_modules/chalk/package.json +70 -0
- package/dist/blessed-contrib/node_modules/chalk/readme.md +213 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/index.js +13 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/license +21 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/package.json +41 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/readme.md +27 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/index.js +8 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/license +21 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/package.json +57 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/readme.md +33 -0
- package/dist/blessed-contrib/node_modules/supports-color/index.js +52 -0
- package/dist/blessed-contrib/node_modules/supports-color/license +21 -0
- package/dist/blessed-contrib/node_modules/supports-color/package.json +49 -0
- package/dist/blessed-contrib/node_modules/supports-color/readme.md +36 -0
- package/dist/cli.js +9 -8
- package/dist/cli.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/shadow-npm-inject.js +2 -2
- package/dist/shadow-npm-inject.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* colors.js - color-related functions for blessed.
|
|
3
|
+
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
|
|
4
|
+
* https://github.com/chjj/blessed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
exports.match = function (r1, g1, b1) {
|
|
8
|
+
if (typeof r1 === 'string') {
|
|
9
|
+
let hex = r1
|
|
10
|
+
if (hex[0] !== '#') {
|
|
11
|
+
return -1
|
|
12
|
+
}
|
|
13
|
+
hex = exports.hexToRGB(hex)
|
|
14
|
+
;(r1 = hex[0]), (g1 = hex[1]), (b1 = hex[2])
|
|
15
|
+
} else if (Array.isArray(r1)) {
|
|
16
|
+
;(b1 = r1[2]), (g1 = r1[1]), (r1 = r1[0])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const hash = (r1 << 16) | (g1 << 8) | b1
|
|
20
|
+
|
|
21
|
+
if (exports._cache[hash] != null) {
|
|
22
|
+
return exports._cache[hash]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let ldiff = Infinity,
|
|
26
|
+
li = -1,
|
|
27
|
+
i = 0,
|
|
28
|
+
c,
|
|
29
|
+
r2,
|
|
30
|
+
g2,
|
|
31
|
+
b2,
|
|
32
|
+
diff
|
|
33
|
+
|
|
34
|
+
for (; i < exports.vcolors.length; i++) {
|
|
35
|
+
c = exports.vcolors[i]
|
|
36
|
+
r2 = c[0]
|
|
37
|
+
g2 = c[1]
|
|
38
|
+
b2 = c[2]
|
|
39
|
+
|
|
40
|
+
diff = colorDistance(r1, g1, b1, r2, g2, b2)
|
|
41
|
+
|
|
42
|
+
if (diff === 0) {
|
|
43
|
+
li = i
|
|
44
|
+
break
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (diff < ldiff) {
|
|
48
|
+
ldiff = diff
|
|
49
|
+
li = i
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (exports._cache[hash] = li)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exports.RGBToHex = function (r, g, b) {
|
|
57
|
+
if (Array.isArray(r)) {
|
|
58
|
+
;(b = r[2]), (g = r[1]), (r = r[0])
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function hex(n) {
|
|
62
|
+
n = n.toString(16)
|
|
63
|
+
if (n.length < 2) {
|
|
64
|
+
n = '0' + n
|
|
65
|
+
}
|
|
66
|
+
return n
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return '#' + hex(r) + hex(g) + hex(b)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exports.hexToRGB = function (hex) {
|
|
73
|
+
if (hex.length === 4) {
|
|
74
|
+
hex = hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const col = parseInt(hex.substring(1), 16),
|
|
78
|
+
r = (col >> 16) & 0xff,
|
|
79
|
+
g = (col >> 8) & 0xff,
|
|
80
|
+
b = col & 0xff
|
|
81
|
+
|
|
82
|
+
return [r, g, b]
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// As it happens, comparing how similar two colors are is really hard. Here is
|
|
86
|
+
// one of the simplest solutions, which doesn't require conversion to another
|
|
87
|
+
// color space, posted on stackoverflow[1]. Maybe someone better at math can
|
|
88
|
+
// propose a superior solution.
|
|
89
|
+
// [1] http://stackoverflow.com/questions/1633828
|
|
90
|
+
|
|
91
|
+
function colorDistance(r1, g1, b1, r2, g2, b2) {
|
|
92
|
+
return (
|
|
93
|
+
Math.pow(30 * (r1 - r2), 2) +
|
|
94
|
+
Math.pow(59 * (g1 - g2), 2) +
|
|
95
|
+
Math.pow(11 * (b1 - b2), 2)
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// This might work well enough for a terminal's colors: treat RGB as XYZ in a
|
|
100
|
+
// 3-dimensional space and go midway between the two points.
|
|
101
|
+
exports.mixColors = function (c1, c2, alpha) {
|
|
102
|
+
// if (c1 === 0x1ff) return c1;
|
|
103
|
+
// if (c2 === 0x1ff) return c1;
|
|
104
|
+
if (c1 === 0x1ff) {
|
|
105
|
+
c1 = 0
|
|
106
|
+
}
|
|
107
|
+
if (c2 === 0x1ff) {
|
|
108
|
+
c2 = 0
|
|
109
|
+
}
|
|
110
|
+
if (alpha == null) {
|
|
111
|
+
alpha = 0.5
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
c1 = exports.vcolors[c1]
|
|
115
|
+
let r1 = c1[0]
|
|
116
|
+
let g1 = c1[1]
|
|
117
|
+
let b1 = c1[2]
|
|
118
|
+
|
|
119
|
+
c2 = exports.vcolors[c2]
|
|
120
|
+
const r2 = c2[0]
|
|
121
|
+
const g2 = c2[1]
|
|
122
|
+
const b2 = c2[2]
|
|
123
|
+
|
|
124
|
+
r1 += ((r2 - r1) * alpha) | 0
|
|
125
|
+
g1 += ((g2 - g1) * alpha) | 0
|
|
126
|
+
b1 += ((b2 - b1) * alpha) | 0
|
|
127
|
+
|
|
128
|
+
return exports.match([r1, g1, b1])
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exports.blend = function blend(attr, attr2, alpha) {
|
|
132
|
+
let name, i, c, nc
|
|
133
|
+
|
|
134
|
+
let bg = attr & 0x1ff
|
|
135
|
+
if (attr2 != null) {
|
|
136
|
+
let bg2 = attr2 & 0x1ff
|
|
137
|
+
if (bg === 0x1ff) {
|
|
138
|
+
bg = 0
|
|
139
|
+
}
|
|
140
|
+
if (bg2 === 0x1ff) {
|
|
141
|
+
bg2 = 0
|
|
142
|
+
}
|
|
143
|
+
bg = exports.mixColors(bg, bg2, alpha)
|
|
144
|
+
} else {
|
|
145
|
+
if (blend._cache[bg] != null) {
|
|
146
|
+
bg = blend._cache[bg]
|
|
147
|
+
// } else if (bg < 8) {
|
|
148
|
+
// bg += 8;
|
|
149
|
+
} else if (bg >= 8 && bg <= 15) {
|
|
150
|
+
bg -= 8
|
|
151
|
+
} else {
|
|
152
|
+
name = exports.ncolors[bg]
|
|
153
|
+
if (name) {
|
|
154
|
+
for (i = 0; i < exports.ncolors.length; i++) {
|
|
155
|
+
if (name === exports.ncolors[i] && i !== bg) {
|
|
156
|
+
c = exports.vcolors[bg]
|
|
157
|
+
nc = exports.vcolors[i]
|
|
158
|
+
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
|
|
159
|
+
blend._cache[bg] = i
|
|
160
|
+
bg = i
|
|
161
|
+
break
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
attr &= ~0x1ff
|
|
170
|
+
attr |= bg
|
|
171
|
+
|
|
172
|
+
let fg = (attr >> 9) & 0x1ff
|
|
173
|
+
if (attr2 != null) {
|
|
174
|
+
let fg2 = (attr2 >> 9) & 0x1ff
|
|
175
|
+
// 0, 7, 188, 231, 251
|
|
176
|
+
if (fg === 0x1ff) {
|
|
177
|
+
// XXX workaround
|
|
178
|
+
fg = 248
|
|
179
|
+
} else {
|
|
180
|
+
if (fg === 0x1ff) {
|
|
181
|
+
fg = 7
|
|
182
|
+
}
|
|
183
|
+
if (fg2 === 0x1ff) {
|
|
184
|
+
fg2 = 7
|
|
185
|
+
}
|
|
186
|
+
fg = exports.mixColors(fg, fg2, alpha)
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
if (blend._cache[fg] != null) {
|
|
190
|
+
fg = blend._cache[fg]
|
|
191
|
+
// } else if (fg < 8) {
|
|
192
|
+
// fg += 8;
|
|
193
|
+
} else if (fg >= 8 && fg <= 15) {
|
|
194
|
+
fg -= 8
|
|
195
|
+
} else {
|
|
196
|
+
name = exports.ncolors[fg]
|
|
197
|
+
if (name) {
|
|
198
|
+
for (i = 0; i < exports.ncolors.length; i++) {
|
|
199
|
+
if (name === exports.ncolors[i] && i !== fg) {
|
|
200
|
+
c = exports.vcolors[fg]
|
|
201
|
+
nc = exports.vcolors[i]
|
|
202
|
+
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
|
|
203
|
+
blend._cache[fg] = i
|
|
204
|
+
fg = i
|
|
205
|
+
break
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
attr &= ~(0x1ff << 9)
|
|
214
|
+
attr |= fg << 9
|
|
215
|
+
|
|
216
|
+
return attr
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
exports.blend._cache = {}
|
|
220
|
+
|
|
221
|
+
exports._cache = {}
|
|
222
|
+
|
|
223
|
+
exports.reduce = function (color, total) {
|
|
224
|
+
if (color >= 16 && total <= 16) {
|
|
225
|
+
color = exports.ccolors[color]
|
|
226
|
+
} else if (color >= 8 && total <= 8) {
|
|
227
|
+
color -= 8
|
|
228
|
+
} else if (color >= 2 && total <= 2) {
|
|
229
|
+
color %= 2
|
|
230
|
+
}
|
|
231
|
+
return color
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// XTerm Colors
|
|
235
|
+
// These were actually tough to track down. The xterm source only uses color
|
|
236
|
+
// keywords. The X11 source needed to be examined to find the actual values.
|
|
237
|
+
// They then had to be mapped to rgb values and then converted to hex values.
|
|
238
|
+
exports.xterm = [
|
|
239
|
+
'#000000', // black
|
|
240
|
+
'#cd0000', // red3
|
|
241
|
+
'#00cd00', // green3
|
|
242
|
+
'#cdcd00', // yellow3
|
|
243
|
+
'#0000ee', // blue2
|
|
244
|
+
'#cd00cd', // magenta3
|
|
245
|
+
'#00cdcd', // cyan3
|
|
246
|
+
'#e5e5e5', // gray90
|
|
247
|
+
'#7f7f7f', // gray50
|
|
248
|
+
'#ff0000', // red
|
|
249
|
+
'#00ff00', // green
|
|
250
|
+
'#ffff00', // yellow
|
|
251
|
+
'#5c5cff', // rgb:5c/5c/ff
|
|
252
|
+
'#ff00ff', // magenta
|
|
253
|
+
'#00ffff', // cyan
|
|
254
|
+
'#ffffff' // white
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
// Seed all 256 colors. Assume xterm defaults.
|
|
258
|
+
// Ported from the xterm color generation script.
|
|
259
|
+
exports.colors = (function () {
|
|
260
|
+
let cols = (exports.colors = []),
|
|
261
|
+
_cols = (exports.vcolors = []),
|
|
262
|
+
r,
|
|
263
|
+
g,
|
|
264
|
+
b,
|
|
265
|
+
i,
|
|
266
|
+
l
|
|
267
|
+
|
|
268
|
+
function hex(n) {
|
|
269
|
+
n = n.toString(16)
|
|
270
|
+
if (n.length < 2) {
|
|
271
|
+
n = '0' + n
|
|
272
|
+
}
|
|
273
|
+
return n
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function push(i, r, g, b) {
|
|
277
|
+
cols[i] = '#' + hex(r) + hex(g) + hex(b)
|
|
278
|
+
_cols[i] = [r, g, b]
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// 0 - 15
|
|
282
|
+
exports.xterm.forEach(function (c, i) {
|
|
283
|
+
c = parseInt(c.substring(1), 16)
|
|
284
|
+
push(i, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff)
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
// 16 - 231
|
|
288
|
+
for (r = 0; r < 6; r++) {
|
|
289
|
+
for (g = 0; g < 6; g++) {
|
|
290
|
+
for (b = 0; b < 6; b++) {
|
|
291
|
+
i = 16 + r * 36 + g * 6 + b
|
|
292
|
+
push(i, r ? r * 40 + 55 : 0, g ? g * 40 + 55 : 0, b ? b * 40 + 55 : 0)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// 232 - 255 are grey.
|
|
298
|
+
for (g = 0; g < 24; g++) {
|
|
299
|
+
l = g * 10 + 8
|
|
300
|
+
i = 232 + g
|
|
301
|
+
push(i, l, l, l)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return cols
|
|
305
|
+
})()
|
|
306
|
+
|
|
307
|
+
// Map higher colors to the first 8 colors.
|
|
308
|
+
// This allows translation of high colors to low colors on 8-color terminals.
|
|
309
|
+
exports.ccolors = (function () {
|
|
310
|
+
let _cols = exports.vcolors.slice(),
|
|
311
|
+
cols = exports.colors.slice(),
|
|
312
|
+
out
|
|
313
|
+
|
|
314
|
+
exports.vcolors = exports.vcolors.slice(0, 8)
|
|
315
|
+
exports.colors = exports.colors.slice(0, 8)
|
|
316
|
+
|
|
317
|
+
out = cols.map(exports.match)
|
|
318
|
+
|
|
319
|
+
exports.colors = cols
|
|
320
|
+
exports.vcolors = _cols
|
|
321
|
+
exports.ccolors = out
|
|
322
|
+
|
|
323
|
+
return out
|
|
324
|
+
})()
|
|
325
|
+
|
|
326
|
+
const colorNames = (exports.colorNames = {
|
|
327
|
+
// special
|
|
328
|
+
default: -1,
|
|
329
|
+
normal: -1,
|
|
330
|
+
bg: -1,
|
|
331
|
+
fg: -1,
|
|
332
|
+
// normal
|
|
333
|
+
black: 0,
|
|
334
|
+
red: 1,
|
|
335
|
+
green: 2,
|
|
336
|
+
yellow: 3,
|
|
337
|
+
blue: 4,
|
|
338
|
+
magenta: 5,
|
|
339
|
+
cyan: 6,
|
|
340
|
+
white: 7,
|
|
341
|
+
// light
|
|
342
|
+
lightblack: 8,
|
|
343
|
+
lightred: 9,
|
|
344
|
+
lightgreen: 10,
|
|
345
|
+
lightyellow: 11,
|
|
346
|
+
lightblue: 12,
|
|
347
|
+
lightmagenta: 13,
|
|
348
|
+
lightcyan: 14,
|
|
349
|
+
lightwhite: 15,
|
|
350
|
+
// bright
|
|
351
|
+
brightblack: 8,
|
|
352
|
+
brightred: 9,
|
|
353
|
+
brightgreen: 10,
|
|
354
|
+
brightyellow: 11,
|
|
355
|
+
brightblue: 12,
|
|
356
|
+
brightmagenta: 13,
|
|
357
|
+
brightcyan: 14,
|
|
358
|
+
brightwhite: 15,
|
|
359
|
+
// alternate spellings
|
|
360
|
+
grey: 8,
|
|
361
|
+
gray: 8,
|
|
362
|
+
lightgrey: 7,
|
|
363
|
+
lightgray: 7,
|
|
364
|
+
brightgrey: 7,
|
|
365
|
+
brightgray: 7
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
exports.convert = function (color) {
|
|
369
|
+
if (typeof color === 'number') {
|
|
370
|
+
} else if (typeof color === 'string') {
|
|
371
|
+
color = color.replace(/[- ]/g, '')
|
|
372
|
+
if (colorNames[color] != null) {
|
|
373
|
+
color = colorNames[color]
|
|
374
|
+
} else {
|
|
375
|
+
color = exports.match(color)
|
|
376
|
+
}
|
|
377
|
+
} else if (Array.isArray(color)) {
|
|
378
|
+
color = exports.match(color)
|
|
379
|
+
} else {
|
|
380
|
+
color = -1
|
|
381
|
+
}
|
|
382
|
+
return color !== -1 ? color : 0x1ff
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Map higher colors to the first 8 colors.
|
|
386
|
+
// This allows translation of high colors to low colors on 8-color terminals.
|
|
387
|
+
// Why the hell did I do this by hand?
|
|
388
|
+
exports.ccolors = {
|
|
389
|
+
blue: [
|
|
390
|
+
4,
|
|
391
|
+
12,
|
|
392
|
+
[17, 21],
|
|
393
|
+
[24, 27],
|
|
394
|
+
[31, 33],
|
|
395
|
+
[38, 39],
|
|
396
|
+
45,
|
|
397
|
+
[54, 57],
|
|
398
|
+
[60, 63],
|
|
399
|
+
[67, 69],
|
|
400
|
+
[74, 75],
|
|
401
|
+
81,
|
|
402
|
+
[91, 93],
|
|
403
|
+
[97, 99],
|
|
404
|
+
[103, 105],
|
|
405
|
+
[110, 111],
|
|
406
|
+
117,
|
|
407
|
+
[128, 129],
|
|
408
|
+
[134, 135],
|
|
409
|
+
[140, 141],
|
|
410
|
+
[146, 147],
|
|
411
|
+
153,
|
|
412
|
+
165,
|
|
413
|
+
171,
|
|
414
|
+
177,
|
|
415
|
+
183,
|
|
416
|
+
189
|
|
417
|
+
],
|
|
418
|
+
|
|
419
|
+
green: [
|
|
420
|
+
2,
|
|
421
|
+
10,
|
|
422
|
+
22,
|
|
423
|
+
[28, 29],
|
|
424
|
+
[34, 36],
|
|
425
|
+
[40, 43],
|
|
426
|
+
[46, 50],
|
|
427
|
+
[64, 65],
|
|
428
|
+
[70, 72],
|
|
429
|
+
[76, 79],
|
|
430
|
+
[82, 86],
|
|
431
|
+
[106, 108],
|
|
432
|
+
[112, 115],
|
|
433
|
+
[118, 122],
|
|
434
|
+
[148, 151],
|
|
435
|
+
[154, 158],
|
|
436
|
+
[190, 194]
|
|
437
|
+
],
|
|
438
|
+
|
|
439
|
+
cyan: [
|
|
440
|
+
6, 14, 23, 30, 37, 44, 51, 66, 73, 80, 87, 109, 116, 123, 152, 159, 195
|
|
441
|
+
],
|
|
442
|
+
|
|
443
|
+
red: [
|
|
444
|
+
1,
|
|
445
|
+
9,
|
|
446
|
+
52,
|
|
447
|
+
[88, 89],
|
|
448
|
+
[94, 95],
|
|
449
|
+
[124, 126],
|
|
450
|
+
[130, 132],
|
|
451
|
+
[136, 138],
|
|
452
|
+
[160, 163],
|
|
453
|
+
[166, 169],
|
|
454
|
+
[172, 175],
|
|
455
|
+
[178, 181],
|
|
456
|
+
[196, 200],
|
|
457
|
+
[202, 206],
|
|
458
|
+
[208, 212],
|
|
459
|
+
[214, 218],
|
|
460
|
+
[220, 224]
|
|
461
|
+
],
|
|
462
|
+
|
|
463
|
+
magenta: [
|
|
464
|
+
5, 13, 53, 90, 96, 127, 133, 139, 164, 170, 176, 182, 201, 207, 213, 219,
|
|
465
|
+
225
|
|
466
|
+
],
|
|
467
|
+
|
|
468
|
+
yellow: [3, 11, 58, [100, 101], [142, 144], [184, 187], [226, 230]],
|
|
469
|
+
|
|
470
|
+
black: [0, 8, 16, 59, 102, [232, 243]],
|
|
471
|
+
|
|
472
|
+
white: [7, 15, 145, 188, 231, [244, 255]]
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
exports.ncolors = []
|
|
476
|
+
|
|
477
|
+
Object.keys(exports.ccolors).forEach(function (name) {
|
|
478
|
+
exports.ccolors[name].forEach(function (offset) {
|
|
479
|
+
if (typeof offset === 'number') {
|
|
480
|
+
exports.ncolors[offset] = name
|
|
481
|
+
exports.ccolors[offset] = exports.colorNames[name]
|
|
482
|
+
return
|
|
483
|
+
}
|
|
484
|
+
for (let i = offset[0], l = offset[1]; i <= l; i++) {
|
|
485
|
+
exports.ncolors[i] = name
|
|
486
|
+
exports.ccolors[i] = exports.colorNames[name]
|
|
487
|
+
}
|
|
488
|
+
})
|
|
489
|
+
delete exports.ccolors[name]
|
|
490
|
+
})
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* events.js - event emitter for blessed
|
|
3
|
+
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
|
|
4
|
+
* https://github.com/chjj/blessed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const slice = Array.prototype.slice
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* EventEmitter
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function EventEmitter() {
|
|
14
|
+
if (!this._events) {
|
|
15
|
+
this._events = {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
EventEmitter.prototype.setMaxListeners = function (n) {
|
|
20
|
+
this._maxListeners = n
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
EventEmitter.prototype.addListener = function (type, listener) {
|
|
24
|
+
if (!this._events[type]) {
|
|
25
|
+
this._events[type] = listener
|
|
26
|
+
} else if (typeof this._events[type] === 'function') {
|
|
27
|
+
this._events[type] = [this._events[type], listener]
|
|
28
|
+
} else {
|
|
29
|
+
this._events[type].push(listener)
|
|
30
|
+
}
|
|
31
|
+
this._emit('newListener', [type, listener])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener
|
|
35
|
+
|
|
36
|
+
EventEmitter.prototype.removeListener = function (type, listener) {
|
|
37
|
+
const handler = this._events[type]
|
|
38
|
+
if (!handler) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (typeof handler === 'function' || handler.length === 1) {
|
|
43
|
+
delete this._events[type]
|
|
44
|
+
this._emit('removeListener', [type, listener])
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (let i = 0; i < handler.length; i++) {
|
|
49
|
+
if (handler[i] === listener || handler[i].listener === listener) {
|
|
50
|
+
handler.splice(i, 1)
|
|
51
|
+
this._emit('removeListener', [type, listener])
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener
|
|
58
|
+
|
|
59
|
+
EventEmitter.prototype.removeAllListeners = function (type) {
|
|
60
|
+
if (type) {
|
|
61
|
+
delete this._events[type]
|
|
62
|
+
} else {
|
|
63
|
+
this._events = {}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
EventEmitter.prototype.once = function (type, listener) {
|
|
68
|
+
function on() {
|
|
69
|
+
this.removeListener(type, on)
|
|
70
|
+
return listener.apply(this, arguments)
|
|
71
|
+
}
|
|
72
|
+
on.listener = listener
|
|
73
|
+
return this.on(type, on)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
EventEmitter.prototype.listeners = function (type) {
|
|
77
|
+
return typeof this._events[type] === 'function'
|
|
78
|
+
? [this._events[type]]
|
|
79
|
+
: this._events[type] || []
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
EventEmitter.prototype._emit = function (type, args) {
|
|
83
|
+
let handler = this._events[type],
|
|
84
|
+
ret
|
|
85
|
+
|
|
86
|
+
// if (type !== 'event') {
|
|
87
|
+
// this._emit('event', [type.replace(/^element /, '')].concat(args));
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
if (!handler) {
|
|
91
|
+
if (type === 'error') {
|
|
92
|
+
throw new args[0]()
|
|
93
|
+
}
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (typeof handler === 'function') {
|
|
98
|
+
return handler.apply(this, args)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
for (let i = 0; i < handler.length; i++) {
|
|
102
|
+
if (handler[i].apply(this, args) === false) {
|
|
103
|
+
ret = false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return ret !== false
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
EventEmitter.prototype.emit = function (type) {
|
|
111
|
+
let args = slice.call(arguments, 1),
|
|
112
|
+
params = slice.call(arguments),
|
|
113
|
+
el = this
|
|
114
|
+
|
|
115
|
+
this._emit('event', params)
|
|
116
|
+
|
|
117
|
+
if (this.type === 'screen') {
|
|
118
|
+
return this._emit(type, args)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this._emit(type, args) === false) {
|
|
122
|
+
return false
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type = 'element ' + type
|
|
126
|
+
args.unshift(this)
|
|
127
|
+
// `element` prefix
|
|
128
|
+
// params = [type].concat(args);
|
|
129
|
+
// no `element` prefix
|
|
130
|
+
// params.splice(1, 0, this);
|
|
131
|
+
|
|
132
|
+
do {
|
|
133
|
+
// el._emit('event', params);
|
|
134
|
+
if (!el._events[type]) {
|
|
135
|
+
continue
|
|
136
|
+
}
|
|
137
|
+
if (el._emit(type, args) === false) {
|
|
138
|
+
return false
|
|
139
|
+
}
|
|
140
|
+
} while ((el = el.parent))
|
|
141
|
+
|
|
142
|
+
return true
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// For hooking into the main EventEmitter if we want to.
|
|
146
|
+
// Might be better to do things this way being that it
|
|
147
|
+
// will always be compatible with node, not to mention
|
|
148
|
+
// it gives us domain support as well.
|
|
149
|
+
// Node.prototype._emit = Node.prototype.emit;
|
|
150
|
+
// Node.prototype.emit = function(type) {
|
|
151
|
+
// var args, el;
|
|
152
|
+
//
|
|
153
|
+
// if (this.type === 'screen') {
|
|
154
|
+
// return this._emit.apply(this, arguments);
|
|
155
|
+
// }
|
|
156
|
+
//
|
|
157
|
+
// this._emit.apply(this, arguments);
|
|
158
|
+
// if (this._bubbleStopped) return false;
|
|
159
|
+
//
|
|
160
|
+
// args = slice.call(arguments, 1);
|
|
161
|
+
// el = this;
|
|
162
|
+
//
|
|
163
|
+
// args.unshift('element ' + type, this);
|
|
164
|
+
// this._bubbleStopped = false;
|
|
165
|
+
// //args.push(stopBubble);
|
|
166
|
+
//
|
|
167
|
+
// do {
|
|
168
|
+
// if (!el._events || !el._events[type]) continue;
|
|
169
|
+
// el._emit.apply(el, args);
|
|
170
|
+
// if (this._bubbleStopped) return false;
|
|
171
|
+
// } while (el = el.parent);
|
|
172
|
+
//
|
|
173
|
+
// return true;
|
|
174
|
+
// };
|
|
175
|
+
//
|
|
176
|
+
// Node.prototype._addListener = Node.prototype.addListener;
|
|
177
|
+
// Node.prototype.on =
|
|
178
|
+
// Node.prototype.addListener = function(type, listener) {
|
|
179
|
+
// function on() {
|
|
180
|
+
// if (listener.apply(this, arguments) === false) {
|
|
181
|
+
// this._bubbleStopped = true;
|
|
182
|
+
// }
|
|
183
|
+
// }
|
|
184
|
+
// on.listener = listener;
|
|
185
|
+
// return this._addListener(type, on);
|
|
186
|
+
// };
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Expose
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
exports = EventEmitter
|
|
193
|
+
exports.EventEmitter = EventEmitter
|
|
194
|
+
|
|
195
|
+
module.exports = exports
|