@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,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gpmclient.js - support the gpm mouse protocol
|
|
3
|
+
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
|
|
4
|
+
* https://github.com/chjj/blessed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const net = require('node:net')
|
|
8
|
+
const fs = require('node:fs')
|
|
9
|
+
const EventEmitter = require('node:events').EventEmitter
|
|
10
|
+
|
|
11
|
+
const GPM_USE_MAGIC = false
|
|
12
|
+
|
|
13
|
+
const GPM_MOVE = 1,
|
|
14
|
+
GPM_DRAG = 2,
|
|
15
|
+
GPM_DOWN = 4,
|
|
16
|
+
GPM_UP = 8
|
|
17
|
+
|
|
18
|
+
const GPM_DOUBLE = 32,
|
|
19
|
+
GPM_MFLAG = 128
|
|
20
|
+
|
|
21
|
+
const GPM_REQ_NOPASTE = 3,
|
|
22
|
+
GPM_HARD = 256
|
|
23
|
+
|
|
24
|
+
const GPM_MAGIC = 0x47706d4c
|
|
25
|
+
const GPM_SOCKET = '/dev/gpmctl'
|
|
26
|
+
|
|
27
|
+
// typedef struct Gpm_Connect {
|
|
28
|
+
// unsigned short eventMask, defaultMask;
|
|
29
|
+
// unsigned short minMod, maxMod;
|
|
30
|
+
// int pid;
|
|
31
|
+
// int vc;
|
|
32
|
+
// } Gpm_Connect;
|
|
33
|
+
|
|
34
|
+
function send_config(socket, Gpm_Connect, callback) {
|
|
35
|
+
let buffer
|
|
36
|
+
if (GPM_USE_MAGIC) {
|
|
37
|
+
buffer = new Buffer(20)
|
|
38
|
+
buffer.writeUInt32LE(GPM_MAGIC, 0)
|
|
39
|
+
buffer.writeUInt16LE(Gpm_Connect.eventMask, 4)
|
|
40
|
+
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 6)
|
|
41
|
+
buffer.writeUInt16LE(Gpm_Connect.minMod, 8)
|
|
42
|
+
buffer.writeUInt16LE(Gpm_Connect.maxMod, 10)
|
|
43
|
+
buffer.writeInt16LE(process.pid, 12)
|
|
44
|
+
buffer.writeInt16LE(Gpm_Connect.vc, 16)
|
|
45
|
+
} else {
|
|
46
|
+
buffer = new Buffer(16)
|
|
47
|
+
buffer.writeUInt16LE(Gpm_Connect.eventMask, 0)
|
|
48
|
+
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 2)
|
|
49
|
+
buffer.writeUInt16LE(Gpm_Connect.minMod, 4)
|
|
50
|
+
buffer.writeUInt16LE(Gpm_Connect.maxMod, 6)
|
|
51
|
+
buffer.writeInt16LE(Gpm_Connect.pid, 8)
|
|
52
|
+
buffer.writeInt16LE(Gpm_Connect.vc, 12)
|
|
53
|
+
}
|
|
54
|
+
socket.write(buffer, function () {
|
|
55
|
+
if (callback) {
|
|
56
|
+
callback()
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// typedef struct Gpm_Event {
|
|
62
|
+
// unsigned char buttons, modifiers; // try to be a multiple of 4
|
|
63
|
+
// unsigned short vc;
|
|
64
|
+
// short dx, dy, x, y; // displacement x,y for this event, and absolute x,y
|
|
65
|
+
// enum Gpm_Etype type;
|
|
66
|
+
// // clicks e.g. double click are determined by time-based processing
|
|
67
|
+
// int clicks;
|
|
68
|
+
// enum Gpm_Margin margin;
|
|
69
|
+
// // wdx/y: displacement of wheels in this event. Absolute values are not
|
|
70
|
+
// // required, because wheel movement is typically used for scrolling
|
|
71
|
+
// // or selecting fields, not for cursor positioning. The application
|
|
72
|
+
// // can determine when the end of file or form is reached, and not
|
|
73
|
+
// // go any further.
|
|
74
|
+
// // A single mouse will use wdy, "vertical scroll" wheel.
|
|
75
|
+
// short wdx, wdy;
|
|
76
|
+
// } Gpm_Event;
|
|
77
|
+
|
|
78
|
+
function parseEvent(raw) {
|
|
79
|
+
const evnt = {}
|
|
80
|
+
evnt.buttons = raw[0]
|
|
81
|
+
evnt.modifiers = raw[1]
|
|
82
|
+
evnt.vc = raw.readUInt16LE(2)
|
|
83
|
+
evnt.dx = raw.readInt16LE(4)
|
|
84
|
+
evnt.dy = raw.readInt16LE(6)
|
|
85
|
+
evnt.x = raw.readInt16LE(8)
|
|
86
|
+
evnt.y = raw.readInt16LE(10)
|
|
87
|
+
evnt.type = raw.readInt16LE(12)
|
|
88
|
+
evnt.clicks = raw.readInt32LE(16)
|
|
89
|
+
evnt.margin = raw.readInt32LE(20)
|
|
90
|
+
evnt.wdx = raw.readInt16LE(24)
|
|
91
|
+
evnt.wdy = raw.readInt16LE(26)
|
|
92
|
+
return evnt
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function GpmClient(options) {
|
|
96
|
+
if (!(this instanceof GpmClient)) {
|
|
97
|
+
return new GpmClient(options)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
EventEmitter.call(this)
|
|
101
|
+
|
|
102
|
+
const pid = process.pid
|
|
103
|
+
|
|
104
|
+
// check tty for /dev/tty[n]
|
|
105
|
+
let path
|
|
106
|
+
try {
|
|
107
|
+
path = fs.readlinkSync('/proc/' + pid + '/fd/0')
|
|
108
|
+
} catch (e) {}
|
|
109
|
+
let tty = /tty[0-9]+$/.exec(path)
|
|
110
|
+
if (tty === null) {
|
|
111
|
+
// TODO: should also check for /dev/input/..
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let vc
|
|
115
|
+
if (tty) {
|
|
116
|
+
tty = tty[0]
|
|
117
|
+
vc = +/[0-9]+$/.exec(tty)[0]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const self = this
|
|
121
|
+
|
|
122
|
+
if (tty) {
|
|
123
|
+
fs.stat(GPM_SOCKET, function (err, stat) {
|
|
124
|
+
if (err || !stat.isSocket()) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const conf = {
|
|
129
|
+
eventMask: 0xffff,
|
|
130
|
+
defaultMask: GPM_MOVE | GPM_HARD,
|
|
131
|
+
minMod: 0,
|
|
132
|
+
maxMod: 0xffff,
|
|
133
|
+
pid: pid,
|
|
134
|
+
vc: vc
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const gpm = net.createConnection(GPM_SOCKET)
|
|
138
|
+
this.gpm = gpm
|
|
139
|
+
|
|
140
|
+
gpm.on('connect', function () {
|
|
141
|
+
send_config(gpm, conf, function () {
|
|
142
|
+
conf.pid = 0
|
|
143
|
+
conf.vc = GPM_REQ_NOPASTE
|
|
144
|
+
//send_config(gpm, conf);
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
gpm.on('data', function (packet) {
|
|
149
|
+
const evnt = parseEvent(packet)
|
|
150
|
+
switch (evnt.type & 15) {
|
|
151
|
+
case GPM_MOVE:
|
|
152
|
+
if (evnt.dx || evnt.dy) {
|
|
153
|
+
self.emit('move', evnt.buttons, evnt.modifiers, evnt.x, evnt.y)
|
|
154
|
+
}
|
|
155
|
+
if (evnt.wdx || evnt.wdy) {
|
|
156
|
+
self.emit(
|
|
157
|
+
'mousewheel',
|
|
158
|
+
evnt.buttons,
|
|
159
|
+
evnt.modifiers,
|
|
160
|
+
evnt.x,
|
|
161
|
+
evnt.y,
|
|
162
|
+
evnt.wdx,
|
|
163
|
+
evnt.wdy
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
break
|
|
167
|
+
case GPM_DRAG:
|
|
168
|
+
if (evnt.dx || evnt.dy) {
|
|
169
|
+
self.emit('drag', evnt.buttons, evnt.modifiers, evnt.x, evnt.y)
|
|
170
|
+
}
|
|
171
|
+
if (evnt.wdx || evnt.wdy) {
|
|
172
|
+
self.emit(
|
|
173
|
+
'mousewheel',
|
|
174
|
+
evnt.buttons,
|
|
175
|
+
evnt.modifiers,
|
|
176
|
+
evnt.x,
|
|
177
|
+
evnt.y,
|
|
178
|
+
evnt.wdx,
|
|
179
|
+
evnt.wdy
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
break
|
|
183
|
+
case GPM_DOWN:
|
|
184
|
+
self.emit('btndown', evnt.buttons, evnt.modifiers, evnt.x, evnt.y)
|
|
185
|
+
if (evnt.type & GPM_DOUBLE) {
|
|
186
|
+
self.emit(
|
|
187
|
+
'dblclick',
|
|
188
|
+
evnt.buttons,
|
|
189
|
+
evnt.modifiers,
|
|
190
|
+
evnt.x,
|
|
191
|
+
evnt.y
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
break
|
|
195
|
+
case GPM_UP:
|
|
196
|
+
self.emit('btnup', evnt.buttons, evnt.modifiers, evnt.x, evnt.y)
|
|
197
|
+
if (!(evnt.type & GPM_MFLAG)) {
|
|
198
|
+
self.emit('click', evnt.buttons, evnt.modifiers, evnt.x, evnt.y)
|
|
199
|
+
}
|
|
200
|
+
break
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
gpm.on('error', function () {
|
|
205
|
+
self.stop()
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
Object.setPrototypeOf(GpmClient.prototype, EventEmitter.prototype)
|
|
212
|
+
|
|
213
|
+
GpmClient.prototype.stop = function () {
|
|
214
|
+
if (this.gpm) {
|
|
215
|
+
this.gpm.end()
|
|
216
|
+
}
|
|
217
|
+
delete this.gpm
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
GpmClient.prototype.ButtonName = function (btn) {
|
|
221
|
+
if (btn & 4) {
|
|
222
|
+
return 'left'
|
|
223
|
+
}
|
|
224
|
+
if (btn & 2) {
|
|
225
|
+
return 'middle'
|
|
226
|
+
}
|
|
227
|
+
if (btn & 1) {
|
|
228
|
+
return 'right'
|
|
229
|
+
}
|
|
230
|
+
return ''
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
GpmClient.prototype.hasShiftKey = function (mod) {
|
|
234
|
+
return mod & 1 ? true : false
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
GpmClient.prototype.hasCtrlKey = function (mod) {
|
|
238
|
+
return mod & 4 ? true : false
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
GpmClient.prototype.hasMetaKey = function (mod) {
|
|
242
|
+
return mod & 8 ? true : false
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
module.exports = GpmClient
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* helpers.js - helpers for blessed
|
|
3
|
+
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
|
|
4
|
+
* https://github.com/chjj/blessed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Modules
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('node:fs')
|
|
12
|
+
|
|
13
|
+
const unicode = require('./unicode')
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Helpers
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const helpers = exports
|
|
20
|
+
|
|
21
|
+
helpers.merge = function (a, b) {
|
|
22
|
+
Object.keys(b).forEach(function (key) {
|
|
23
|
+
a[key] = b[key]
|
|
24
|
+
})
|
|
25
|
+
return a
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
helpers.asort = function (obj) {
|
|
29
|
+
return obj.sort(function (a, b) {
|
|
30
|
+
a = a.name.toLowerCase()
|
|
31
|
+
b = b.name.toLowerCase()
|
|
32
|
+
|
|
33
|
+
if (a[0] === '.' && b[0] === '.') {
|
|
34
|
+
a = a[1]
|
|
35
|
+
b = b[1]
|
|
36
|
+
} else {
|
|
37
|
+
a = a[0]
|
|
38
|
+
b = b[0]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return a > b ? 1 : a < b ? -1 : 0
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
helpers.hsort = function (obj) {
|
|
46
|
+
return obj.sort(function (a, b) {
|
|
47
|
+
return b.index - a.index
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
helpers.findFile = function (start, target) {
|
|
52
|
+
return (function read(dir) {
|
|
53
|
+
let files, file, stat, out
|
|
54
|
+
|
|
55
|
+
if (dir === '/dev' || dir === '/sys' || dir === '/proc' || dir === '/net') {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
files = fs.readdirSync(dir)
|
|
61
|
+
} catch (e) {
|
|
62
|
+
files = []
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < files.length; i++) {
|
|
66
|
+
file = files[i]
|
|
67
|
+
|
|
68
|
+
if (file === target) {
|
|
69
|
+
return (dir === '/' ? '' : dir) + '/' + file
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
stat = fs.lstatSync((dir === '/' ? '' : dir) + '/' + file)
|
|
74
|
+
} catch (e) {
|
|
75
|
+
stat = null
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (stat && stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
79
|
+
out = read((dir === '/' ? '' : dir) + '/' + file)
|
|
80
|
+
if (out) {
|
|
81
|
+
return out
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null
|
|
87
|
+
})(start)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Escape text for tag-enabled elements.
|
|
91
|
+
helpers.escape = function (text) {
|
|
92
|
+
return text.replace(/[{}]/g, function (ch) {
|
|
93
|
+
return ch === '{' ? '{open}' : '{close}'
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
helpers.parseTags = function (text, screen) {
|
|
98
|
+
return helpers.Element.prototype._parseTags.call(
|
|
99
|
+
{ parseTags: true, screen: screen || helpers.Screen.global },
|
|
100
|
+
text
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
helpers.generateTags = function (style, text) {
|
|
105
|
+
let open = '',
|
|
106
|
+
close = ''
|
|
107
|
+
|
|
108
|
+
Object.keys(style || {}).forEach(function (key) {
|
|
109
|
+
let val = style[key]
|
|
110
|
+
if (typeof val === 'string') {
|
|
111
|
+
val = val.replace(/^light(?!-)/, 'light-')
|
|
112
|
+
val = val.replace(/^bright(?!-)/, 'bright-')
|
|
113
|
+
open = '{' + val + '-' + key + '}' + open
|
|
114
|
+
close += '{/' + val + '-' + key + '}'
|
|
115
|
+
} else {
|
|
116
|
+
if (val === true) {
|
|
117
|
+
open = '{' + key + '}' + open
|
|
118
|
+
close += '{/' + key + '}'
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
if (text != null) {
|
|
124
|
+
return open + text + close
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
open: open,
|
|
129
|
+
close: close
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
helpers.attrToBinary = function (style, element) {
|
|
134
|
+
return helpers.Element.prototype.sattr.call(element || {}, style)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
helpers.stripTags = function (text) {
|
|
138
|
+
if (!text) {
|
|
139
|
+
return ''
|
|
140
|
+
}
|
|
141
|
+
return text.replace(/{(\/?)([\w\-,;!#]*)}/g, '').replace(/\x1b\[[\d;]*m/g, '')
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
helpers.cleanTags = function (text) {
|
|
145
|
+
return helpers.stripTags(text).trim()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
helpers.dropUnicode = function (text) {
|
|
149
|
+
if (!text) {
|
|
150
|
+
return ''
|
|
151
|
+
}
|
|
152
|
+
return text
|
|
153
|
+
.replace(unicode.chars.all, '??')
|
|
154
|
+
.replace(unicode.chars.combining, '')
|
|
155
|
+
.replace(unicode.chars.surrogate, '?')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
helpers.__defineGetter__('Screen', function () {
|
|
159
|
+
if (!helpers._screen) {
|
|
160
|
+
helpers._screen = require('./widgets/screen')
|
|
161
|
+
}
|
|
162
|
+
return helpers._screen
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
helpers.__defineGetter__('Element', function () {
|
|
166
|
+
if (!helpers._element) {
|
|
167
|
+
helpers._element = require('./widgets/element')
|
|
168
|
+
}
|
|
169
|
+
return helpers._element
|
|
170
|
+
})
|