@socketsecurity/cli-with-sentry 0.14.94 → 0.14.96
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 +178 -159
- 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 +160 -140
- 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,90 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* loading.js - loading 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 Node = require('./node')
|
|
14
|
-
const Box = require('./box')
|
|
15
|
-
const Text = require('./text')
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Loading
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
function Loading(options) {
|
|
22
|
-
if (!(this instanceof Node)) {
|
|
23
|
-
return new Loading(options)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
options = options || {}
|
|
27
|
-
|
|
28
|
-
Box.call(this, options)
|
|
29
|
-
|
|
30
|
-
this._.icon = new Text({
|
|
31
|
-
parent: this,
|
|
32
|
-
align: 'center',
|
|
33
|
-
top: 2,
|
|
34
|
-
left: 1,
|
|
35
|
-
right: 1,
|
|
36
|
-
height: 1,
|
|
37
|
-
content: '|'
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Object.setPrototypeOf(Loading.prototype, Box.prototype)
|
|
42
|
-
|
|
43
|
-
Loading.prototype.type = 'loading'
|
|
44
|
-
|
|
45
|
-
Loading.prototype.load = function (text) {
|
|
46
|
-
const self = this
|
|
47
|
-
|
|
48
|
-
// XXX Keep above:
|
|
49
|
-
// var parent = this.parent;
|
|
50
|
-
// this.detach();
|
|
51
|
-
// parent.append(this);
|
|
52
|
-
|
|
53
|
-
this.show()
|
|
54
|
-
this.setContent(text)
|
|
55
|
-
|
|
56
|
-
if (this._.timer) {
|
|
57
|
-
this.stop()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
this.screen.lockKeys = true
|
|
61
|
-
|
|
62
|
-
this._.timer = setInterval(function () {
|
|
63
|
-
if (self._.icon.content === '|') {
|
|
64
|
-
self._.icon.setContent('/')
|
|
65
|
-
} else if (self._.icon.content === '/') {
|
|
66
|
-
self._.icon.setContent('-')
|
|
67
|
-
} else if (self._.icon.content === '-') {
|
|
68
|
-
self._.icon.setContent('\\')
|
|
69
|
-
} else if (self._.icon.content === '\\') {
|
|
70
|
-
self._.icon.setContent('|')
|
|
71
|
-
}
|
|
72
|
-
self.screen.render()
|
|
73
|
-
}, 200)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
Loading.prototype.stop = function () {
|
|
77
|
-
this.screen.lockKeys = false
|
|
78
|
-
this.hide()
|
|
79
|
-
if (this._.timer) {
|
|
80
|
-
clearInterval(this._.timer)
|
|
81
|
-
delete this._.timer
|
|
82
|
-
}
|
|
83
|
-
this.screen.render()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Expose
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
module.exports = Loading
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* log.js - log 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 util = require('node:util')
|
|
14
|
-
|
|
15
|
-
const nextTick = global.setImmediate || process.nextTick.bind(process)
|
|
16
|
-
|
|
17
|
-
const Node = require('./node')
|
|
18
|
-
const ScrollableText = require('./scrollabletext')
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Log
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function Log(options) {
|
|
25
|
-
const self = this
|
|
26
|
-
|
|
27
|
-
if (!(this instanceof Node)) {
|
|
28
|
-
return new Log(options)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
options = options || {}
|
|
32
|
-
|
|
33
|
-
ScrollableText.call(this, options)
|
|
34
|
-
|
|
35
|
-
this.scrollback = options.scrollback != null ? options.scrollback : Infinity
|
|
36
|
-
this.scrollOnInput = options.scrollOnInput
|
|
37
|
-
|
|
38
|
-
this.on('set content', function () {
|
|
39
|
-
if (!self._userScrolled || self.scrollOnInput) {
|
|
40
|
-
nextTick(function () {
|
|
41
|
-
self.setScrollPerc(100)
|
|
42
|
-
self._userScrolled = false
|
|
43
|
-
self.screen.render()
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
Object.setPrototypeOf(Log.prototype, ScrollableText.prototype)
|
|
50
|
-
|
|
51
|
-
Log.prototype.type = 'log'
|
|
52
|
-
|
|
53
|
-
Log.prototype.log = Log.prototype.add = function () {
|
|
54
|
-
const args = Array.prototype.slice.call(arguments)
|
|
55
|
-
if (typeof args[0] === 'object') {
|
|
56
|
-
args[0] = util.inspect(args[0], true, 20, true)
|
|
57
|
-
}
|
|
58
|
-
const text = util.format.apply(util, args)
|
|
59
|
-
this.emit('log', text)
|
|
60
|
-
const ret = this.pushLine(text)
|
|
61
|
-
if (this._clines.fake.length > this.scrollback) {
|
|
62
|
-
this.shiftLine(0, (this.scrollback / 3) | 0)
|
|
63
|
-
}
|
|
64
|
-
return ret
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
Log.prototype._scroll = Log.prototype.scroll
|
|
68
|
-
Log.prototype.scroll = function (offset, always) {
|
|
69
|
-
if (offset === 0) {
|
|
70
|
-
return this._scroll(offset, always)
|
|
71
|
-
}
|
|
72
|
-
this._userScrolled = true
|
|
73
|
-
const ret = this._scroll(offset, always)
|
|
74
|
-
if (this.getScrollPerc() === 100) {
|
|
75
|
-
this._userScrolled = false
|
|
76
|
-
}
|
|
77
|
-
return ret
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Expose
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
module.exports = Log
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* message.js - message 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 Node = require('./node')
|
|
14
|
-
const Box = require('./box')
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Message / Error
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
function Message(options) {
|
|
21
|
-
if (!(this instanceof Node)) {
|
|
22
|
-
return new Message(options)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
options = options || {}
|
|
26
|
-
options.tags = true
|
|
27
|
-
|
|
28
|
-
Box.call(this, options)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
Object.setPrototypeOf(Message.prototype, Box.prototype)
|
|
32
|
-
|
|
33
|
-
Message.prototype.type = 'message'
|
|
34
|
-
|
|
35
|
-
Message.prototype.log = Message.prototype.display = function (
|
|
36
|
-
text,
|
|
37
|
-
time,
|
|
38
|
-
callback
|
|
39
|
-
) {
|
|
40
|
-
const self = this
|
|
41
|
-
|
|
42
|
-
if (typeof time === 'function') {
|
|
43
|
-
callback = time
|
|
44
|
-
time = null
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (time == null) {
|
|
48
|
-
time = 3
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Keep above:
|
|
52
|
-
// var parent = this.parent;
|
|
53
|
-
// this.detach();
|
|
54
|
-
// parent.append(this);
|
|
55
|
-
|
|
56
|
-
if (this.scrollable) {
|
|
57
|
-
this.screen.saveFocus()
|
|
58
|
-
this.focus()
|
|
59
|
-
this.scrollTo(0)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.show()
|
|
63
|
-
this.setContent(text)
|
|
64
|
-
this.screen.render()
|
|
65
|
-
|
|
66
|
-
if (time === Infinity || time === -1 || time === 0) {
|
|
67
|
-
const end = function () {
|
|
68
|
-
if (end.done) {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
end.done = true
|
|
72
|
-
if (self.scrollable) {
|
|
73
|
-
try {
|
|
74
|
-
self.screen.restoreFocus()
|
|
75
|
-
} catch (e) {}
|
|
76
|
-
}
|
|
77
|
-
self.hide()
|
|
78
|
-
self.screen.render()
|
|
79
|
-
if (callback) {
|
|
80
|
-
callback()
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
setTimeout(function () {
|
|
85
|
-
self.onScreenEvent('keypress', function fn(ch, key) {
|
|
86
|
-
if (key.name === 'mouse') {
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
if (self.scrollable) {
|
|
90
|
-
if (
|
|
91
|
-
key.name === 'up' ||
|
|
92
|
-
(self.options.vi && key.name === 'k') ||
|
|
93
|
-
key.name === 'down' ||
|
|
94
|
-
(self.options.vi && key.name === 'j') ||
|
|
95
|
-
(self.options.vi && key.name === 'u' && key.ctrl) ||
|
|
96
|
-
(self.options.vi && key.name === 'd' && key.ctrl) ||
|
|
97
|
-
(self.options.vi && key.name === 'b' && key.ctrl) ||
|
|
98
|
-
(self.options.vi && key.name === 'f' && key.ctrl) ||
|
|
99
|
-
(self.options.vi && key.name === 'g' && !key.shift) ||
|
|
100
|
-
(self.options.vi && key.name === 'g' && key.shift)
|
|
101
|
-
) {
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (
|
|
106
|
-
self.options.ignoreKeys &&
|
|
107
|
-
~self.options.ignoreKeys.indexOf(key.name)
|
|
108
|
-
) {
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
self.removeScreenEvent('keypress', fn)
|
|
112
|
-
end()
|
|
113
|
-
})
|
|
114
|
-
// XXX May be affected by new element.options.mouse option.
|
|
115
|
-
if (!self.options.mouse) {
|
|
116
|
-
return
|
|
117
|
-
}
|
|
118
|
-
self.onScreenEvent('mouse', function fn(data) {
|
|
119
|
-
if (data.action === 'mousemove') {
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
self.removeScreenEvent('mouse', fn)
|
|
123
|
-
end()
|
|
124
|
-
})
|
|
125
|
-
}, 10)
|
|
126
|
-
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
setTimeout(function () {
|
|
131
|
-
self.hide()
|
|
132
|
-
self.screen.render()
|
|
133
|
-
if (callback) {
|
|
134
|
-
callback()
|
|
135
|
-
}
|
|
136
|
-
}, time * 1000)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
Message.prototype.error = function (text, time, callback) {
|
|
140
|
-
return this.display('{red-fg}Error: ' + text + '{/red-fg}', time, callback)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Expose
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
module.exports = Message
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* node.js - base abstract node 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 EventEmitter = require('../events').EventEmitter
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Node
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
function Node(options) {
|
|
20
|
-
const self = this
|
|
21
|
-
if (!(this instanceof Node)) {
|
|
22
|
-
return new Node(options)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
EventEmitter.call(this)
|
|
26
|
-
|
|
27
|
-
options = options || {}
|
|
28
|
-
this.options = options
|
|
29
|
-
|
|
30
|
-
this.screen = this.screen || options.screen
|
|
31
|
-
|
|
32
|
-
if (!this.screen) {
|
|
33
|
-
const Screen = require('./screen')
|
|
34
|
-
if (this.type === 'screen') {
|
|
35
|
-
this.screen = this
|
|
36
|
-
} else if (Screen.total === 1) {
|
|
37
|
-
this.screen = Screen.global
|
|
38
|
-
} else if (options.parent) {
|
|
39
|
-
this.screen = options.parent
|
|
40
|
-
while (this.screen && this.screen.type !== 'screen') {
|
|
41
|
-
this.screen = this.screen.parent
|
|
42
|
-
}
|
|
43
|
-
} else if (Screen.total) {
|
|
44
|
-
// This _should_ work in most cases as long as the element is appended
|
|
45
|
-
// synchronously after the screen's creation. Throw error if not.
|
|
46
|
-
this.screen = Screen.instances[Screen.instances.length - 1]
|
|
47
|
-
process.nextTick(function () {
|
|
48
|
-
if (!self.parent) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
'Element (' +
|
|
51
|
-
self.type +
|
|
52
|
-
')' +
|
|
53
|
-
' was not appended synchronously after the' +
|
|
54
|
-
" screen's creation. Please set a `parent`" +
|
|
55
|
-
" or `screen` option in the element's constructor" +
|
|
56
|
-
' if you are going to use multiple screens and' +
|
|
57
|
-
' append the element later.'
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
} else {
|
|
62
|
-
throw new Error('No active screen.')
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
this.parent = options.parent || null
|
|
67
|
-
this.children = []
|
|
68
|
-
this.$ = this._ = this.data = {}
|
|
69
|
-
this.uid = Node.uid++
|
|
70
|
-
this.index = this.index != null ? this.index : -1
|
|
71
|
-
|
|
72
|
-
if (this.type !== 'screen') {
|
|
73
|
-
this.detached = true
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (this.parent) {
|
|
77
|
-
this.parent.append(this)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
;(options.children || []).forEach(this.append.bind(this))
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
Node.uid = 0
|
|
84
|
-
|
|
85
|
-
Object.setPrototypeOf(Node.prototype, EventEmitter.prototype)
|
|
86
|
-
|
|
87
|
-
Node.prototype.type = 'node'
|
|
88
|
-
|
|
89
|
-
Node.prototype.insert = function (element, i) {
|
|
90
|
-
const self = this
|
|
91
|
-
|
|
92
|
-
if (element.screen && element.screen !== this.screen) {
|
|
93
|
-
throw new Error("Cannot switch a node's screen.")
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
element.detach()
|
|
97
|
-
element.parent = this
|
|
98
|
-
element.screen = this.screen
|
|
99
|
-
|
|
100
|
-
if (i === 0) {
|
|
101
|
-
this.children.unshift(element)
|
|
102
|
-
} else if (i === this.children.length) {
|
|
103
|
-
this.children.push(element)
|
|
104
|
-
} else {
|
|
105
|
-
this.children.splice(i, 0, element)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
element.emit('reparent', this)
|
|
109
|
-
this.emit('adopt', element)
|
|
110
|
-
|
|
111
|
-
;(function emit(el) {
|
|
112
|
-
const n = el.detached !== self.detached
|
|
113
|
-
el.detached = self.detached
|
|
114
|
-
if (n) {
|
|
115
|
-
el.emit('attach')
|
|
116
|
-
}
|
|
117
|
-
el.children.forEach(emit)
|
|
118
|
-
})(element)
|
|
119
|
-
|
|
120
|
-
if (!this.screen.focused) {
|
|
121
|
-
this.screen.focused = element
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
Node.prototype.prepend = function (element) {
|
|
126
|
-
this.insert(element, 0)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
Node.prototype.append = function (element) {
|
|
130
|
-
this.insert(element, this.children.length)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
Node.prototype.insertBefore = function (element, other) {
|
|
134
|
-
const i = this.children.indexOf(other)
|
|
135
|
-
if (~i) {
|
|
136
|
-
this.insert(element, i)
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
Node.prototype.insertAfter = function (element, other) {
|
|
141
|
-
const i = this.children.indexOf(other)
|
|
142
|
-
if (~i) {
|
|
143
|
-
this.insert(element, i + 1)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
Node.prototype.remove = function (element) {
|
|
148
|
-
if (element.parent !== this) {
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
let i = this.children.indexOf(element)
|
|
153
|
-
if (!~i) {
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
element.clearPos()
|
|
158
|
-
|
|
159
|
-
element.parent = null
|
|
160
|
-
|
|
161
|
-
this.children.splice(i, 1)
|
|
162
|
-
|
|
163
|
-
i = this.screen.clickable.indexOf(element)
|
|
164
|
-
if (~i) {
|
|
165
|
-
this.screen.clickable.splice(i, 1)
|
|
166
|
-
}
|
|
167
|
-
i = this.screen.keyable.indexOf(element)
|
|
168
|
-
if (~i) {
|
|
169
|
-
this.screen.keyable.splice(i, 1)
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
element.emit('reparent', null)
|
|
173
|
-
this.emit('remove', element)
|
|
174
|
-
|
|
175
|
-
;(function emit(el) {
|
|
176
|
-
const n = el.detached !== true
|
|
177
|
-
el.detached = true
|
|
178
|
-
if (n) {
|
|
179
|
-
el.emit('detach')
|
|
180
|
-
}
|
|
181
|
-
el.children.forEach(emit)
|
|
182
|
-
})(element)
|
|
183
|
-
|
|
184
|
-
if (this.screen.focused === element) {
|
|
185
|
-
this.screen.rewindFocus()
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
Node.prototype.detach = function () {
|
|
190
|
-
if (this.parent) {
|
|
191
|
-
this.parent.remove(this)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
Node.prototype.free = function () {
|
|
196
|
-
return
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
Node.prototype.destroy = function () {
|
|
200
|
-
this.detach()
|
|
201
|
-
this.forDescendants(function (el) {
|
|
202
|
-
el.free()
|
|
203
|
-
el.destroyed = true
|
|
204
|
-
el.emit('destroy')
|
|
205
|
-
}, this)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
Node.prototype.forDescendants = function (iter, s) {
|
|
209
|
-
if (s) {
|
|
210
|
-
iter(this)
|
|
211
|
-
}
|
|
212
|
-
this.children.forEach(function emit(el) {
|
|
213
|
-
iter(el)
|
|
214
|
-
el.children.forEach(emit)
|
|
215
|
-
})
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
Node.prototype.forAncestors = function (iter, s) {
|
|
219
|
-
let el = this
|
|
220
|
-
if (s) {
|
|
221
|
-
iter(this)
|
|
222
|
-
}
|
|
223
|
-
while ((el = el.parent)) {
|
|
224
|
-
iter(el)
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
Node.prototype.collectDescendants = function (s) {
|
|
229
|
-
const out = []
|
|
230
|
-
this.forDescendants(function (el) {
|
|
231
|
-
out.push(el)
|
|
232
|
-
}, s)
|
|
233
|
-
return out
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
Node.prototype.collectAncestors = function (s) {
|
|
237
|
-
const out = []
|
|
238
|
-
this.forAncestors(function (el) {
|
|
239
|
-
out.push(el)
|
|
240
|
-
}, s)
|
|
241
|
-
return out
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
Node.prototype.emitDescendants = function () {
|
|
245
|
-
let args = Array.prototype.slice(arguments),
|
|
246
|
-
iter
|
|
247
|
-
|
|
248
|
-
if (typeof args[args.length - 1] === 'function') {
|
|
249
|
-
iter = args.pop()
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return this.forDescendants(function (el) {
|
|
253
|
-
if (iter) {
|
|
254
|
-
iter(el)
|
|
255
|
-
}
|
|
256
|
-
el.emit.apply(el, args)
|
|
257
|
-
}, true)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
Node.prototype.emitAncestors = function () {
|
|
261
|
-
let args = Array.prototype.slice(arguments),
|
|
262
|
-
iter
|
|
263
|
-
|
|
264
|
-
if (typeof args[args.length - 1] === 'function') {
|
|
265
|
-
iter = args.pop()
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return this.forAncestors(function (el) {
|
|
269
|
-
if (iter) {
|
|
270
|
-
iter(el)
|
|
271
|
-
}
|
|
272
|
-
el.emit.apply(el, args)
|
|
273
|
-
}, true)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
Node.prototype.hasDescendant = function (target) {
|
|
277
|
-
return (function find(el) {
|
|
278
|
-
for (let i = 0; i < el.children.length; i++) {
|
|
279
|
-
if (el.children[i] === target) {
|
|
280
|
-
return true
|
|
281
|
-
}
|
|
282
|
-
if (find(el.children[i]) === true) {
|
|
283
|
-
return true
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return false
|
|
287
|
-
})(this)
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
Node.prototype.hasAncestor = function (target) {
|
|
291
|
-
let el = this
|
|
292
|
-
while ((el = el.parent)) {
|
|
293
|
-
if (el === target) {
|
|
294
|
-
return true
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return false
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
Node.prototype.get = function (name, value) {
|
|
301
|
-
if (this.data.hasOwnProperty(name)) {
|
|
302
|
-
return this.data[name]
|
|
303
|
-
}
|
|
304
|
-
return value
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
Node.prototype.set = function (name, value) {
|
|
308
|
-
return (this.data[name] = value)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Expose
|
|
313
|
-
*/
|
|
314
|
-
|
|
315
|
-
module.exports = Node
|