@socketsecurity/cli-with-sentry 0.14.93 → 0.14.95
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/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/cli.js +177 -157
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/shadow-bin.js +3 -14
- package/dist/module-sync/shadow-bin.js.map +1 -1
- package/dist/module-sync/shadow-npm-inject.js +68 -59
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/shadow-npm-paths.js +16 -29
- package/dist/module-sync/shadow-npm-paths.js.map +1 -1
- package/dist/module-sync/vendor.d.ts +0 -0
- package/dist/module-sync/vendor.js +85829 -12598
- package/dist/module-sync/vendor.js.map +1 -1
- package/dist/require/cli.js +159 -138
- package/dist/require/cli.js.map +1 -1
- package/dist/require/shadow-bin.d.ts +5 -0
- package/dist/require/shadow-bin.js +108 -1
- package/dist/require/shadow-bin.js.map +1 -0
- package/dist/require/shadow-npm-inject.d.ts +1 -0
- package/dist/require/shadow-npm-inject.js +2335 -1
- package/dist/require/shadow-npm-inject.js.map +1 -0
- package/dist/require/shadow-npm-paths.d.ts +29 -0
- package/dist/require/shadow-npm-paths.js +454 -1
- package/dist/require/shadow-npm-paths.js.map +1 -0
- package/package.json +29 -29
- package/dist/blessed/lib/alias.js +0 -521
- package/dist/blessed/lib/blessed.js +0 -34
- package/dist/blessed/lib/colors.js +0 -492
- package/dist/blessed/lib/events.js +0 -197
- package/dist/blessed/lib/gpmclient.js +0 -247
- package/dist/blessed/lib/helpers.js +0 -172
- package/dist/blessed/lib/keys.js +0 -514
- package/dist/blessed/lib/program.js +0 -4532
- package/dist/blessed/lib/tput.js +0 -3113
- package/dist/blessed/lib/unicode.js +0 -914
- package/dist/blessed/lib/widget.js +0 -62
- package/dist/blessed/lib/widgets/ansiimage.js +0 -175
- package/dist/blessed/lib/widgets/bigtext.js +0 -172
- package/dist/blessed/lib/widgets/box.js +0 -36
- package/dist/blessed/lib/widgets/button.js +0 -64
- package/dist/blessed/lib/widgets/checkbox.js +0 -97
- package/dist/blessed/lib/widgets/element.js +0 -2873
- package/dist/blessed/lib/widgets/filemanager.js +0 -225
- package/dist/blessed/lib/widgets/form.js +0 -303
- package/dist/blessed/lib/widgets/image.js +0 -73
- package/dist/blessed/lib/widgets/input.js +0 -36
- package/dist/blessed/lib/widgets/layout.js +0 -251
- package/dist/blessed/lib/widgets/line.js +0 -61
- package/dist/blessed/lib/widgets/list.js +0 -654
- package/dist/blessed/lib/widgets/listbar.js +0 -454
- package/dist/blessed/lib/widgets/listtable.js +0 -267
- package/dist/blessed/lib/widgets/loading.js +0 -90
- package/dist/blessed/lib/widgets/log.js +0 -84
- package/dist/blessed/lib/widgets/message.js +0 -147
- package/dist/blessed/lib/widgets/node.js +0 -315
- package/dist/blessed/lib/widgets/overlayimage.js +0 -796
- package/dist/blessed/lib/widgets/progressbar.js +0 -168
- package/dist/blessed/lib/widgets/prompt.js +0 -129
- package/dist/blessed/lib/widgets/question.js +0 -131
- package/dist/blessed/lib/widgets/radiobutton.js +0 -64
- package/dist/blessed/lib/widgets/radioset.js +0 -38
- package/dist/blessed/lib/widgets/screen.js +0 -2487
- package/dist/blessed/lib/widgets/scrollablebox.js +0 -417
- package/dist/blessed/lib/widgets/scrollabletext.js +0 -37
- package/dist/blessed/lib/widgets/table.js +0 -385
- package/dist/blessed/lib/widgets/terminal.js +0 -454
- package/dist/blessed/lib/widgets/text.js +0 -37
- package/dist/blessed/lib/widgets/textarea.js +0 -378
- package/dist/blessed/lib/widgets/textbox.js +0 -81
- package/dist/blessed/lib/widgets/video.js +0 -132
- package/dist/blessed/usr/fonts/AUTHORS +0 -1
- package/dist/blessed/usr/fonts/LICENSE +0 -94
- package/dist/blessed/usr/fonts/README +0 -340
- package/dist/blessed/usr/fonts/ter-u14b.json +0 -17826
- package/dist/blessed/usr/fonts/ter-u14n.json +0 -17826
- 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 +0 -243
- package/dist/blessed/usr/xterm.terminfo +0 -1977
- package/dist/blessed/vendor/tng.js +0 -1878
|
@@ -1,796 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* overlayimage.js - w3m image element for blessed
|
|
5
|
-
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
|
|
6
|
-
* https://github.com/chjj/blessed
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Modules
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const fs = require('node:fs'),
|
|
14
|
-
cp = require('node:child_process')
|
|
15
|
-
|
|
16
|
-
const helpers = require('../helpers')
|
|
17
|
-
|
|
18
|
-
const Node = require('./node')
|
|
19
|
-
const Box = require('./box')
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* OverlayImage
|
|
23
|
-
* Good example of w3mimgdisplay commands:
|
|
24
|
-
* https://github.com/hut/ranger/blob/master/ranger/ext/img_display.py
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
function OverlayImage(options) {
|
|
28
|
-
const self = this
|
|
29
|
-
|
|
30
|
-
if (!(this instanceof Node)) {
|
|
31
|
-
return new OverlayImage(options)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
options = options || {}
|
|
35
|
-
|
|
36
|
-
Box.call(this, options)
|
|
37
|
-
|
|
38
|
-
if (options.w3m) {
|
|
39
|
-
OverlayImage.w3mdisplay = options.w3m
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (OverlayImage.hasW3MDisplay == null) {
|
|
43
|
-
if (fs.existsSync(OverlayImage.w3mdisplay)) {
|
|
44
|
-
OverlayImage.hasW3MDisplay = true
|
|
45
|
-
} else if (options.search !== false) {
|
|
46
|
-
const file =
|
|
47
|
-
helpers.findFile('/usr', 'w3mimgdisplay') ||
|
|
48
|
-
helpers.findFile('/lib', 'w3mimgdisplay') ||
|
|
49
|
-
helpers.findFile('/bin', 'w3mimgdisplay')
|
|
50
|
-
if (file) {
|
|
51
|
-
OverlayImage.hasW3MDisplay = true
|
|
52
|
-
OverlayImage.w3mdisplay = file
|
|
53
|
-
} else {
|
|
54
|
-
OverlayImage.hasW3MDisplay = false
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.on('hide', function () {
|
|
60
|
-
self._lastFile = self.file
|
|
61
|
-
self.clearImage()
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
this.on('show', function () {
|
|
65
|
-
if (!self._lastFile) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
self.setImage(self._lastFile)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
this.on('detach', function () {
|
|
72
|
-
self._lastFile = self.file
|
|
73
|
-
self.clearImage()
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
this.on('attach', function () {
|
|
77
|
-
if (!self._lastFile) {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
self.setImage(self._lastFile)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
this.onScreenEvent('resize', function () {
|
|
84
|
-
self._needsRatio = true
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
// Get images to overlap properly. Maybe not worth it:
|
|
88
|
-
// this.onScreenEvent('render', function() {
|
|
89
|
-
// self.screen.program.flush();
|
|
90
|
-
// if (!self._noImage) return;
|
|
91
|
-
// function display(el, next) {
|
|
92
|
-
// if (el.type === 'w3mimage' && el.file) {
|
|
93
|
-
// el.setImage(el.file, next);
|
|
94
|
-
// } else {
|
|
95
|
-
// next();
|
|
96
|
-
// }
|
|
97
|
-
// }
|
|
98
|
-
// function done(el) {
|
|
99
|
-
// el.children.forEach(recurse);
|
|
100
|
-
// }
|
|
101
|
-
// function recurse(el) {
|
|
102
|
-
// display(el, function() {
|
|
103
|
-
// var pending = el.children.length;
|
|
104
|
-
// el.children.forEach(function(el) {
|
|
105
|
-
// display(el, function() {
|
|
106
|
-
// if (!--pending) done(el);
|
|
107
|
-
// });
|
|
108
|
-
// });
|
|
109
|
-
// });
|
|
110
|
-
// }
|
|
111
|
-
// recurse(self.screen);
|
|
112
|
-
// });
|
|
113
|
-
|
|
114
|
-
this.onScreenEvent('render', function () {
|
|
115
|
-
self.screen.program.flush()
|
|
116
|
-
if (!self._noImage) {
|
|
117
|
-
self.setImage(self.file)
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
if (this.options.file || this.options.img) {
|
|
122
|
-
this.setImage(this.options.file || this.options.img)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
Object.setPrototypeOf(OverlayImage.prototype, Box.prototype)
|
|
127
|
-
|
|
128
|
-
OverlayImage.prototype.type = 'overlayimage'
|
|
129
|
-
|
|
130
|
-
OverlayImage.w3mdisplay = '/usr/lib/w3m/w3mimgdisplay'
|
|
131
|
-
|
|
132
|
-
OverlayImage.prototype.spawn = function (file, args, opt, callback) {
|
|
133
|
-
let spawn = require('node:child_process').spawn,
|
|
134
|
-
ps
|
|
135
|
-
|
|
136
|
-
opt = opt || {}
|
|
137
|
-
ps = spawn(file, args, opt)
|
|
138
|
-
|
|
139
|
-
ps.on('error', function (err) {
|
|
140
|
-
if (!callback) {
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
return callback(err)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
ps.on('exit', function (code) {
|
|
147
|
-
if (!callback) {
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
if (code !== 0) {
|
|
151
|
-
return callback(new Error('Exit Code: ' + code))
|
|
152
|
-
}
|
|
153
|
-
return callback(null, code === 0)
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
return ps
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
OverlayImage.prototype.setImage = function (img, callback) {
|
|
160
|
-
const self = this
|
|
161
|
-
|
|
162
|
-
if (this._settingImage) {
|
|
163
|
-
this._queue = this._queue || []
|
|
164
|
-
this._queue.push([img, callback])
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
this._settingImage = true
|
|
168
|
-
|
|
169
|
-
const reset = function () {
|
|
170
|
-
self._settingImage = false
|
|
171
|
-
self._queue = self._queue || []
|
|
172
|
-
const item = self._queue.shift()
|
|
173
|
-
if (item) {
|
|
174
|
-
self.setImage(item[0], item[1])
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
179
|
-
reset()
|
|
180
|
-
if (!callback) {
|
|
181
|
-
return
|
|
182
|
-
}
|
|
183
|
-
return callback(new Error('W3M Image Display not available.'))
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (!img) {
|
|
187
|
-
reset()
|
|
188
|
-
if (!callback) {
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
return callback(new Error('No image.'))
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
this.file = img
|
|
195
|
-
|
|
196
|
-
return this.getPixelRatio(function (err, ratio) {
|
|
197
|
-
if (err) {
|
|
198
|
-
reset()
|
|
199
|
-
if (!callback) {
|
|
200
|
-
return
|
|
201
|
-
}
|
|
202
|
-
return callback(err)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return self.renderImage(img, ratio, function (err, success) {
|
|
206
|
-
if (err) {
|
|
207
|
-
reset()
|
|
208
|
-
if (!callback) {
|
|
209
|
-
return
|
|
210
|
-
}
|
|
211
|
-
return callback(err)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (self.shrink || self.options.autofit) {
|
|
215
|
-
delete self.shrink
|
|
216
|
-
delete self.options.shrink
|
|
217
|
-
self.options.autofit = true
|
|
218
|
-
return self.imageSize(function (err, size) {
|
|
219
|
-
if (err) {
|
|
220
|
-
reset()
|
|
221
|
-
if (!callback) {
|
|
222
|
-
return
|
|
223
|
-
}
|
|
224
|
-
return callback(err)
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (
|
|
228
|
-
self._lastSize &&
|
|
229
|
-
ratio.tw === self._lastSize.tw &&
|
|
230
|
-
ratio.th === self._lastSize.th &&
|
|
231
|
-
size.width === self._lastSize.width &&
|
|
232
|
-
size.height === self._lastSize.height &&
|
|
233
|
-
self.aleft === self._lastSize.aleft &&
|
|
234
|
-
self.atop === self._lastSize.atop
|
|
235
|
-
) {
|
|
236
|
-
reset()
|
|
237
|
-
if (!callback) {
|
|
238
|
-
return
|
|
239
|
-
}
|
|
240
|
-
return callback(null, success)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
self._lastSize = {
|
|
244
|
-
tw: ratio.tw,
|
|
245
|
-
th: ratio.th,
|
|
246
|
-
width: size.width,
|
|
247
|
-
height: size.height,
|
|
248
|
-
aleft: self.aleft,
|
|
249
|
-
atop: self.atop
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
self.position.width = (size.width / ratio.tw) | 0
|
|
253
|
-
self.position.height = (size.height / ratio.th) | 0
|
|
254
|
-
|
|
255
|
-
self._noImage = true
|
|
256
|
-
self.screen.render()
|
|
257
|
-
self._noImage = false
|
|
258
|
-
|
|
259
|
-
reset()
|
|
260
|
-
return self.renderImage(img, ratio, callback)
|
|
261
|
-
})
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
reset()
|
|
265
|
-
if (!callback) {
|
|
266
|
-
return
|
|
267
|
-
}
|
|
268
|
-
return callback(null, success)
|
|
269
|
-
})
|
|
270
|
-
})
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
OverlayImage.prototype.renderImage = function (img, ratio, callback) {
|
|
274
|
-
const self = this
|
|
275
|
-
|
|
276
|
-
if (cp.execSync) {
|
|
277
|
-
callback =
|
|
278
|
-
callback ||
|
|
279
|
-
function (err, result) {
|
|
280
|
-
return result
|
|
281
|
-
}
|
|
282
|
-
try {
|
|
283
|
-
return callback(null, this.renderImageSync(img, ratio))
|
|
284
|
-
} catch (e) {
|
|
285
|
-
return callback(e)
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
290
|
-
if (!callback) {
|
|
291
|
-
return
|
|
292
|
-
}
|
|
293
|
-
return callback(new Error('W3M Image Display not available.'))
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (!ratio) {
|
|
297
|
-
if (!callback) {
|
|
298
|
-
return
|
|
299
|
-
}
|
|
300
|
-
return callback(new Error('No ratio.'))
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// clearImage unsets these:
|
|
304
|
-
const _file = self.file
|
|
305
|
-
const _lastSize = self._lastSize
|
|
306
|
-
return self.clearImage(function (err) {
|
|
307
|
-
if (err) {
|
|
308
|
-
return callback(err)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
self.file = _file
|
|
312
|
-
self._lastSize = _lastSize
|
|
313
|
-
|
|
314
|
-
const opt = {
|
|
315
|
-
stdio: 'pipe',
|
|
316
|
-
env: process.env,
|
|
317
|
-
cwd: process.env.HOME
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const ps = self.spawn(
|
|
321
|
-
OverlayImage.w3mdisplay,
|
|
322
|
-
[],
|
|
323
|
-
opt,
|
|
324
|
-
function (err, success) {
|
|
325
|
-
if (!callback) {
|
|
326
|
-
return
|
|
327
|
-
}
|
|
328
|
-
return err ? callback(err) : callback(null, success)
|
|
329
|
-
}
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
const width = (self.width * ratio.tw) | 0,
|
|
333
|
-
height = (self.height * ratio.th) | 0,
|
|
334
|
-
aleft = (self.aleft * ratio.tw) | 0,
|
|
335
|
-
atop = (self.atop * ratio.th) | 0
|
|
336
|
-
|
|
337
|
-
const input =
|
|
338
|
-
'0;1;' +
|
|
339
|
-
aleft +
|
|
340
|
-
';' +
|
|
341
|
-
atop +
|
|
342
|
-
';' +
|
|
343
|
-
width +
|
|
344
|
-
';' +
|
|
345
|
-
height +
|
|
346
|
-
';;;;;' +
|
|
347
|
-
img +
|
|
348
|
-
'\n4;\n3;\n'
|
|
349
|
-
|
|
350
|
-
self._props = {
|
|
351
|
-
aleft: aleft,
|
|
352
|
-
atop: atop,
|
|
353
|
-
width: width,
|
|
354
|
-
height: height
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
ps.stdin.write(input)
|
|
358
|
-
ps.stdin.end()
|
|
359
|
-
})
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
OverlayImage.prototype.clearImage = function (callback) {
|
|
363
|
-
if (cp.execSync) {
|
|
364
|
-
callback =
|
|
365
|
-
callback ||
|
|
366
|
-
function (err, result) {
|
|
367
|
-
return result
|
|
368
|
-
}
|
|
369
|
-
try {
|
|
370
|
-
return callback(null, this.clearImageSync())
|
|
371
|
-
} catch (e) {
|
|
372
|
-
return callback(e)
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
377
|
-
if (!callback) {
|
|
378
|
-
return
|
|
379
|
-
}
|
|
380
|
-
return callback(new Error('W3M Image Display not available.'))
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
if (!this._props) {
|
|
384
|
-
if (!callback) {
|
|
385
|
-
return
|
|
386
|
-
}
|
|
387
|
-
return callback(null)
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const opt = {
|
|
391
|
-
stdio: 'pipe',
|
|
392
|
-
env: process.env,
|
|
393
|
-
cwd: process.env.HOME
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
const ps = this.spawn(
|
|
397
|
-
OverlayImage.w3mdisplay,
|
|
398
|
-
[],
|
|
399
|
-
opt,
|
|
400
|
-
function (err, success) {
|
|
401
|
-
if (!callback) {
|
|
402
|
-
return
|
|
403
|
-
}
|
|
404
|
-
return err ? callback(err) : callback(null, success)
|
|
405
|
-
}
|
|
406
|
-
)
|
|
407
|
-
|
|
408
|
-
let width = this._props.width + 2,
|
|
409
|
-
height = this._props.height + 2,
|
|
410
|
-
aleft = this._props.aleft,
|
|
411
|
-
atop = this._props.atop
|
|
412
|
-
|
|
413
|
-
if (this._drag) {
|
|
414
|
-
aleft -= 10
|
|
415
|
-
atop -= 10
|
|
416
|
-
width += 10
|
|
417
|
-
height += 10
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
const input =
|
|
421
|
-
'6;' + aleft + ';' + atop + ';' + width + ';' + height + '\n4;\n3;\n'
|
|
422
|
-
|
|
423
|
-
delete this.file
|
|
424
|
-
delete this._props
|
|
425
|
-
delete this._lastSize
|
|
426
|
-
|
|
427
|
-
ps.stdin.write(input)
|
|
428
|
-
ps.stdin.end()
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
OverlayImage.prototype.imageSize = function (callback) {
|
|
432
|
-
const img = this.file
|
|
433
|
-
|
|
434
|
-
if (cp.execSync) {
|
|
435
|
-
callback =
|
|
436
|
-
callback ||
|
|
437
|
-
function (err, result) {
|
|
438
|
-
return result
|
|
439
|
-
}
|
|
440
|
-
try {
|
|
441
|
-
return callback(null, this.imageSizeSync())
|
|
442
|
-
} catch (e) {
|
|
443
|
-
return callback(e)
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
448
|
-
if (!callback) {
|
|
449
|
-
return
|
|
450
|
-
}
|
|
451
|
-
return callback(new Error('W3M Image Display not available.'))
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
if (!img) {
|
|
455
|
-
if (!callback) {
|
|
456
|
-
return
|
|
457
|
-
}
|
|
458
|
-
return callback(new Error('No image.'))
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
const opt = {
|
|
462
|
-
stdio: 'pipe',
|
|
463
|
-
env: process.env,
|
|
464
|
-
cwd: process.env.HOME
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const ps = this.spawn(OverlayImage.w3mdisplay, [], opt)
|
|
468
|
-
|
|
469
|
-
let buf = ''
|
|
470
|
-
|
|
471
|
-
ps.stdout.setEncoding('utf8')
|
|
472
|
-
|
|
473
|
-
ps.stdout.on('data', function (data) {
|
|
474
|
-
buf += data
|
|
475
|
-
})
|
|
476
|
-
|
|
477
|
-
ps.on('error', function (err) {
|
|
478
|
-
if (!callback) {
|
|
479
|
-
return
|
|
480
|
-
}
|
|
481
|
-
return callback(err)
|
|
482
|
-
})
|
|
483
|
-
|
|
484
|
-
ps.on('exit', function () {
|
|
485
|
-
if (!callback) {
|
|
486
|
-
return
|
|
487
|
-
}
|
|
488
|
-
const size = buf.trim().split(/\s+/)
|
|
489
|
-
return callback(null, {
|
|
490
|
-
raw: buf.trim(),
|
|
491
|
-
width: +size[0],
|
|
492
|
-
height: +size[1]
|
|
493
|
-
})
|
|
494
|
-
})
|
|
495
|
-
|
|
496
|
-
const input = '5;' + img + '\n'
|
|
497
|
-
|
|
498
|
-
ps.stdin.write(input)
|
|
499
|
-
ps.stdin.end()
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
OverlayImage.prototype.termSize = function (callback) {
|
|
503
|
-
const self = this
|
|
504
|
-
|
|
505
|
-
if (cp.execSync) {
|
|
506
|
-
callback =
|
|
507
|
-
callback ||
|
|
508
|
-
function (err, result) {
|
|
509
|
-
return result
|
|
510
|
-
}
|
|
511
|
-
try {
|
|
512
|
-
return callback(null, this.termSizeSync())
|
|
513
|
-
} catch (e) {
|
|
514
|
-
return callback(e)
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
519
|
-
if (!callback) {
|
|
520
|
-
return
|
|
521
|
-
}
|
|
522
|
-
return callback(new Error('W3M Image Display not available.'))
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const opt = {
|
|
526
|
-
stdio: 'pipe',
|
|
527
|
-
env: process.env,
|
|
528
|
-
cwd: process.env.HOME
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
const ps = this.spawn(OverlayImage.w3mdisplay, ['-test'], opt)
|
|
532
|
-
|
|
533
|
-
let buf = ''
|
|
534
|
-
|
|
535
|
-
ps.stdout.setEncoding('utf8')
|
|
536
|
-
|
|
537
|
-
ps.stdout.on('data', function (data) {
|
|
538
|
-
buf += data
|
|
539
|
-
})
|
|
540
|
-
|
|
541
|
-
ps.on('error', function (err) {
|
|
542
|
-
if (!callback) {
|
|
543
|
-
return
|
|
544
|
-
}
|
|
545
|
-
return callback(err)
|
|
546
|
-
})
|
|
547
|
-
|
|
548
|
-
ps.on('exit', function () {
|
|
549
|
-
if (!callback) {
|
|
550
|
-
return
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
if (!buf.trim()) {
|
|
554
|
-
// Bug: w3mimgdisplay will sometimes
|
|
555
|
-
// output nothing. Try again:
|
|
556
|
-
return self.termSize(callback)
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
const size = buf.trim().split(/\s+/)
|
|
560
|
-
|
|
561
|
-
return callback(null, {
|
|
562
|
-
raw: buf.trim(),
|
|
563
|
-
width: +size[0],
|
|
564
|
-
height: +size[1]
|
|
565
|
-
})
|
|
566
|
-
})
|
|
567
|
-
|
|
568
|
-
ps.stdin.end()
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
OverlayImage.prototype.getPixelRatio = function (callback) {
|
|
572
|
-
const self = this
|
|
573
|
-
|
|
574
|
-
if (cp.execSync) {
|
|
575
|
-
callback =
|
|
576
|
-
callback ||
|
|
577
|
-
function (err, result) {
|
|
578
|
-
return result
|
|
579
|
-
}
|
|
580
|
-
try {
|
|
581
|
-
return callback(null, this.getPixelRatioSync())
|
|
582
|
-
} catch (e) {
|
|
583
|
-
return callback(e)
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// XXX We could cache this, but sometimes it's better
|
|
588
|
-
// to recalculate to be pixel perfect.
|
|
589
|
-
if (this._ratio && !this._needsRatio) {
|
|
590
|
-
return callback(null, this._ratio)
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
return this.termSize(function (err, dimensions) {
|
|
594
|
-
if (err) {
|
|
595
|
-
return callback(err)
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
self._ratio = {
|
|
599
|
-
tw: dimensions.width / self.screen.width,
|
|
600
|
-
th: dimensions.height / self.screen.height
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
self._needsRatio = false
|
|
604
|
-
|
|
605
|
-
return callback(null, self._ratio)
|
|
606
|
-
})
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
OverlayImage.prototype.renderImageSync = function (img, ratio) {
|
|
610
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
611
|
-
throw new Error('W3M Image Display not available.')
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
if (!ratio) {
|
|
615
|
-
throw new Error('No ratio.')
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// clearImage unsets these:
|
|
619
|
-
const _file = this.file
|
|
620
|
-
const _lastSize = this._lastSize
|
|
621
|
-
|
|
622
|
-
this.clearImageSync()
|
|
623
|
-
|
|
624
|
-
this.file = _file
|
|
625
|
-
this._lastSize = _lastSize
|
|
626
|
-
|
|
627
|
-
const width = (this.width * ratio.tw) | 0,
|
|
628
|
-
height = (this.height * ratio.th) | 0,
|
|
629
|
-
aleft = (this.aleft * ratio.tw) | 0,
|
|
630
|
-
atop = (this.atop * ratio.th) | 0
|
|
631
|
-
|
|
632
|
-
const input =
|
|
633
|
-
'0;1;' +
|
|
634
|
-
aleft +
|
|
635
|
-
';' +
|
|
636
|
-
atop +
|
|
637
|
-
';' +
|
|
638
|
-
width +
|
|
639
|
-
';' +
|
|
640
|
-
height +
|
|
641
|
-
';;;;;' +
|
|
642
|
-
img +
|
|
643
|
-
'\n4;\n3;\n'
|
|
644
|
-
|
|
645
|
-
this._props = {
|
|
646
|
-
aleft: aleft,
|
|
647
|
-
atop: atop,
|
|
648
|
-
width: width,
|
|
649
|
-
height: height
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
try {
|
|
653
|
-
cp.execFileSync(OverlayImage.w3mdisplay, [], {
|
|
654
|
-
env: process.env,
|
|
655
|
-
encoding: 'utf8',
|
|
656
|
-
input: input,
|
|
657
|
-
timeout: 1000
|
|
658
|
-
})
|
|
659
|
-
} catch (e) {}
|
|
660
|
-
|
|
661
|
-
return true
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
OverlayImage.prototype.clearImageSync = function () {
|
|
665
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
666
|
-
throw new Error('W3M Image Display not available.')
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
if (!this._props) {
|
|
670
|
-
return false
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
let width = this._props.width + 2,
|
|
674
|
-
height = this._props.height + 2,
|
|
675
|
-
aleft = this._props.aleft,
|
|
676
|
-
atop = this._props.atop
|
|
677
|
-
|
|
678
|
-
if (this._drag) {
|
|
679
|
-
aleft -= 10
|
|
680
|
-
atop -= 10
|
|
681
|
-
width += 10
|
|
682
|
-
height += 10
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
const input =
|
|
686
|
-
'6;' + aleft + ';' + atop + ';' + width + ';' + height + '\n4;\n3;\n'
|
|
687
|
-
|
|
688
|
-
delete this.file
|
|
689
|
-
delete this._props
|
|
690
|
-
delete this._lastSize
|
|
691
|
-
|
|
692
|
-
try {
|
|
693
|
-
cp.execFileSync(OverlayImage.w3mdisplay, [], {
|
|
694
|
-
env: process.env,
|
|
695
|
-
encoding: 'utf8',
|
|
696
|
-
input: input,
|
|
697
|
-
timeout: 1000
|
|
698
|
-
})
|
|
699
|
-
} catch (e) {}
|
|
700
|
-
|
|
701
|
-
return true
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
OverlayImage.prototype.imageSizeSync = function () {
|
|
705
|
-
const img = this.file
|
|
706
|
-
|
|
707
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
708
|
-
throw new Error('W3M Image Display not available.')
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
if (!img) {
|
|
712
|
-
throw new Error('No image.')
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
let buf = ''
|
|
716
|
-
const input = '5;' + img + '\n'
|
|
717
|
-
|
|
718
|
-
try {
|
|
719
|
-
buf = cp.execFileSync(OverlayImage.w3mdisplay, [], {
|
|
720
|
-
env: process.env,
|
|
721
|
-
encoding: 'utf8',
|
|
722
|
-
input: input,
|
|
723
|
-
timeout: 1000
|
|
724
|
-
})
|
|
725
|
-
} catch (e) {}
|
|
726
|
-
|
|
727
|
-
const size = buf.trim().split(/\s+/)
|
|
728
|
-
|
|
729
|
-
return {
|
|
730
|
-
raw: buf.trim(),
|
|
731
|
-
width: +size[0],
|
|
732
|
-
height: +size[1]
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
OverlayImage.prototype.termSizeSync = function (_, recurse) {
|
|
737
|
-
if (OverlayImage.hasW3MDisplay === false) {
|
|
738
|
-
throw new Error('W3M Image Display not available.')
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
let buf = ''
|
|
742
|
-
|
|
743
|
-
try {
|
|
744
|
-
buf = cp.execFileSync(OverlayImage.w3mdisplay, ['-test'], {
|
|
745
|
-
env: process.env,
|
|
746
|
-
encoding: 'utf8',
|
|
747
|
-
timeout: 1000
|
|
748
|
-
})
|
|
749
|
-
} catch (e) {}
|
|
750
|
-
|
|
751
|
-
if (!buf.trim()) {
|
|
752
|
-
// Bug: w3mimgdisplay will sometimes
|
|
753
|
-
// output nothing. Try again:
|
|
754
|
-
recurse = recurse || 0
|
|
755
|
-
if (++recurse === 5) {
|
|
756
|
-
throw new Error('Term size not determined.')
|
|
757
|
-
}
|
|
758
|
-
return this.termSizeSync(_, recurse)
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
const size = buf.trim().split(/\s+/)
|
|
762
|
-
|
|
763
|
-
return {
|
|
764
|
-
raw: buf.trim(),
|
|
765
|
-
width: +size[0],
|
|
766
|
-
height: +size[1]
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
OverlayImage.prototype.getPixelRatioSync = function () {
|
|
771
|
-
// XXX We could cache this, but sometimes it's better
|
|
772
|
-
// to recalculate to be pixel perfect.
|
|
773
|
-
if (this._ratio && !this._needsRatio) {
|
|
774
|
-
return this._ratio
|
|
775
|
-
}
|
|
776
|
-
this._needsRatio = false
|
|
777
|
-
|
|
778
|
-
const dimensions = this.termSizeSync()
|
|
779
|
-
|
|
780
|
-
this._ratio = {
|
|
781
|
-
tw: dimensions.width / this.screen.width,
|
|
782
|
-
th: dimensions.height / this.screen.height
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
return this._ratio
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
OverlayImage.prototype.displayImage = function (callback) {
|
|
789
|
-
return this.screen.displayImage(this.file, callback)
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
* Expose
|
|
794
|
-
*/
|
|
795
|
-
|
|
796
|
-
module.exports = OverlayImage
|