@arcblock/terminal 2.1.61

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/lib/player.css ADDED
@@ -0,0 +1,378 @@
1
+ .terminal-player,
2
+ .terminal {
3
+ display: inline-block;
4
+ }
5
+
6
+ .terminal .xterm .xterm-viewport {
7
+ overflow-y: hidden !important;
8
+ }
9
+
10
+ .terminal-frame {
11
+ position: relative;
12
+ }
13
+
14
+ /*//// [ Reset ] ////*/
15
+
16
+ .terminal div {
17
+ margin: 0;
18
+ padding: 0;
19
+ border: 0;
20
+ outline: 0;
21
+ font-weight: inherit;
22
+ font-style: inherit;
23
+ font-size: 100%;
24
+ font-family: inherit;
25
+ vertical-align: baseline;
26
+ }
27
+
28
+ /*//// [ Window ] ////*/
29
+
30
+ .terminal-frame.terminal-window {
31
+ -moz-border-radius: 6px;
32
+ -webkit-border-radius: 6px;
33
+ border-radius: 6px;
34
+ border: 1px solid #b3b3b3;
35
+ box-shadow: 0px 0px 18px #b3b3b3;
36
+ margin: 18px;
37
+ overflow: hidden;
38
+ }
39
+
40
+ .terminal-frame.terminal-window .terminal-titlebar {
41
+ -moz-border-top-left-radius: 6px;
42
+ -moz-border-top-right-radius: 6px;
43
+ -webkit-border-top-left-radius: 6px;
44
+ -webkit-border-top-right-radius: 6px;
45
+ background: #e8e8e8;
46
+ border-bottom: 1px solid #b1aeb1;
47
+ border-top-left-radius: 6px;
48
+ border-top-right-radius: 6px;
49
+ border-top: 1px solid #f3f1f3;
50
+ color: #3b4247;
51
+ font-family: Arial, sans-serif;
52
+ font-size: 14px;
53
+ height: 22px;
54
+ line-height: 22px;
55
+ position: relative;
56
+ text-align: center;
57
+ width: 100%;
58
+ }
59
+
60
+ .terminal-frame.terminal-window .terminal-titlebar .buttons {
61
+ left: 8px;
62
+ line-height: 0px;
63
+ position: absolute;
64
+ top: 3.5px;
65
+ }
66
+
67
+ .terminal-frame.terminal-window .terminal-titlebar .close-button {
68
+ -moz-border-radius: 50%;
69
+ -webkit-border-radius: 50%;
70
+ background: #ff5c5c;
71
+ border-radius: 50%;
72
+ border: 1px solid #e33e41;
73
+ display: inline-block;
74
+ height: 12px;
75
+ width: 12px;
76
+ }
77
+
78
+ .terminal-frame.terminal-window .terminal-titlebar .minimize-button {
79
+ -moz-border-radius: 50%;
80
+ -webkit-border-radius: 50%;
81
+ background: #ffbd4c;
82
+ border-radius: 50%;
83
+ border: 1px solid #e09e3e;
84
+ display: inline-block;
85
+ height: 12px;
86
+ margin-left: 4px;
87
+ width: 12px;
88
+ }
89
+
90
+ .terminal-frame.terminal-window .terminal-titlebar .maximize-button {
91
+ -moz-border-radius: 50%;
92
+ -webkit-border-radius: 50%;
93
+ background: #00ca56;
94
+ border-radius: 50%;
95
+ border: 1px solid #14ae46;
96
+ display: inline-block;
97
+ height: 12px;
98
+ margin-left: 4px;
99
+ width: 12px;
100
+ }
101
+
102
+ .terminal-frame.terminal-window .terminal-body {
103
+ background-color: #1d1d1d;
104
+ padding: 10px;
105
+ }
106
+
107
+ /*//// [ Floating ] ////*/
108
+
109
+ .terminal-frame.terminal-floating {
110
+ -moz-border-radius: 6px;
111
+ -webkit-border-radius: 6px;
112
+ background-color: #1d1d1d;
113
+ border-radius: 6px;
114
+ box-shadow: 0px 0px 18px #b3b3b3;
115
+ margin: 18px;
116
+ overflow: hidden;
117
+ }
118
+
119
+ .terminal-frame.terminal-floating .terminal-titlebar {
120
+ color: white;
121
+ font-family: Arial, sans-serif;
122
+ font-size: 14px;
123
+ height: 34px;
124
+ line-height: 34px;
125
+ position: relative;
126
+ text-align: center;
127
+ width: 100%;
128
+ }
129
+
130
+ .terminal-frame.terminal-floating .terminal-titlebar .buttons {
131
+ left: 13px;
132
+ line-height: 0px;
133
+ position: absolute;
134
+ top: 9px;
135
+ }
136
+
137
+ .terminal-frame.terminal-floating .terminal-titlebar .close-button {
138
+ -moz-border-radius: 50%;
139
+ -webkit-border-radius: 50%;
140
+ background: #ff5c5c;
141
+ border-radius: 50%;
142
+ display: inline-block;
143
+ height: 15px;
144
+ width: 15px;
145
+ }
146
+
147
+ .terminal-frame.terminal-floating .terminal-titlebar .minimize-button {
148
+ -moz-border-radius: 50%;
149
+ -webkit-border-radius: 50%;
150
+ background: #ffbd4c;
151
+ border-radius: 50%;
152
+ display: inline-block;
153
+ height: 15px;
154
+ line-height: 10px;
155
+ margin-left: 4px;
156
+ width: 15px;
157
+ }
158
+
159
+ .terminal-frame.terminal-floating .terminal-titlebar .maximize-button {
160
+ -moz-border-radius: 50%;
161
+ -webkit-border-radius: 50%;
162
+ background: #00ca56;
163
+ border-radius: 50%;
164
+ display: inline-block;
165
+ height: 15px;
166
+ line-height: 10px;
167
+ margin-left: 4px;
168
+ width: 15px;
169
+ }
170
+
171
+ .terminal-frame.terminal-floating .terminal-body {
172
+ padding: 20px;
173
+ }
174
+
175
+ /*//// [ Solid ] ////*/
176
+
177
+ .terminal-frame.terminal-solid {
178
+ -moz-border-radius: 6px;
179
+ -webkit-border-radius: 6px;
180
+ background-color: #1d1d1d;
181
+ border-radius: 6px;
182
+ box-shadow: 0px 0px 18px #b3b3b3;
183
+ margin: 18px;
184
+ overflow: hidden;
185
+ }
186
+
187
+ .terminal-frame.terminal-solid .terminal-titlebar {
188
+ color: white;
189
+ font-family: Arial, sans-serif;
190
+ font-size: 14px;
191
+ position: relative;
192
+ text-align: center;
193
+ width: 100%;
194
+ }
195
+
196
+ .terminal-frame.terminal-solid .terminal-titlebar .title {
197
+ margin: 15px 15px 15px;
198
+ }
199
+
200
+ .terminal-frame.terminal-solid .terminal-titlebar .title:empty {
201
+ display: none;
202
+ }
203
+
204
+ .terminal-frame.terminal-solid .terminal-titlebar .buttons {
205
+ display: none;
206
+ }
207
+
208
+ .terminal-frame.terminal-solid .terminal-body {
209
+ padding: 20px;
210
+ }
211
+
212
+ /*//// [ Player ] ////*/
213
+
214
+ .terminal-player {
215
+ position: relative;
216
+ font-size: 0;
217
+ }
218
+
219
+ .terminal-player .controller {
220
+ background: #45484d;
221
+ bottom: 0px;
222
+ display: none;
223
+ font-family: Helvetica, Arial, sans-serif;
224
+ font-size: 12px;
225
+ height: 40px;
226
+ position: absolute;
227
+ width: 100%;
228
+ z-index: 20;
229
+ background: #222222;
230
+ transition: height ease 200ms;
231
+ -webkit-transition: height ease 200ms;
232
+ -moz-transition: height ease 200ms;
233
+ -o-transition: height ease 200ms;
234
+ }
235
+
236
+ .terminal-player.controls .controller {
237
+ display: block;
238
+ }
239
+
240
+ .terminal-player.playing .controller {
241
+ height: 0px;
242
+ overflow: hidden;
243
+ }
244
+
245
+ .terminal-player.playing:hover .controller {
246
+ height: 40px;
247
+ overflow: hidden;
248
+ }
249
+
250
+ .terminal-player .play,
251
+ .terminal-player .pause {
252
+ fill: #cacaca;
253
+ float: left;
254
+ height: 40px;
255
+ line-height: 40px;
256
+ text-align: center;
257
+ width: 40px;
258
+ }
259
+
260
+ .terminal-player .play .icon,
261
+ .terminal-player .pause .icon {
262
+ border-color: transparent transparent transparent #cacaca;
263
+ box-sizing: border-box;
264
+ cursor: pointer;
265
+ display: inline-block;
266
+ height: 15px;
267
+ }
268
+
269
+ .terminal-player .pause .icon {
270
+ border-style: double;
271
+ border-width: 0px 0px 0px 12px;
272
+ margin-top: 11px;
273
+ }
274
+
275
+ .terminal-player .play .icon {
276
+ border-style: solid;
277
+ border-width: 8px 0px 8px 13px;
278
+ margin-top: 10px;
279
+ }
280
+
281
+ .terminal-player .pause {
282
+ display: none;
283
+ }
284
+
285
+ .terminal-player.playing .play {
286
+ display: none;
287
+ }
288
+
289
+ .terminal-player.playing .pause {
290
+ display: inline-block;
291
+ }
292
+
293
+ .terminal-player .timer {
294
+ color: #cacaca;
295
+ float: right;
296
+ line-height: 40px;
297
+ padding: 0 10px;
298
+ }
299
+
300
+ .terminal-player .progressbar-wrapper {
301
+ height: 40px;
302
+ line-height: 38px;
303
+ overflow: hidden;
304
+ }
305
+
306
+ .terminal-player .progressbar {
307
+ background-color: #424242;
308
+ display: inline-block;
309
+ height: 7px;
310
+ overflow: hidden;
311
+ width: 100%;
312
+ border-radius: 10px;
313
+ -moz-border-radius: 10px;
314
+ -webkit-border-radius: 10px;
315
+ }
316
+
317
+ .terminal-player.started .progressbar {
318
+ cursor: pointer;
319
+ }
320
+
321
+ .terminal-player .progress {
322
+ background-color: #cacaca;
323
+ height: 7px;
324
+ position: relative;
325
+ width: 0%;
326
+ }
327
+
328
+ .terminal-player .cover {
329
+ cursor: pointer;
330
+ height: 100%;
331
+ position: absolute;
332
+ width: 100%;
333
+ z-index: 10;
334
+ }
335
+
336
+ .terminal-player .start svg {
337
+ cursor: pointer;
338
+ fill: #eaeaea;
339
+ height: 130px;
340
+ left: 50%;
341
+ margin-left: -65px;
342
+ margin-top: -65px;
343
+ position: absolute;
344
+ top: 50%;
345
+ width: 130px;
346
+ z-index: 20;
347
+ filter: drop-shadow(10px 10px 15px rgba(0, 0, 0, 0.4));
348
+ -webkit-filter: drop-shadow(10px 10px 15px rgba(0, 0, 0, 0.4));
349
+ }
350
+
351
+ .terminal-player.small .start svg {
352
+ height: 60px;
353
+ margin-left: -30px;
354
+ margin-top: -30px;
355
+ width: 60px;
356
+ }
357
+
358
+ .terminal-player.framed .start svg {
359
+ transform: translate(0px, 8px);
360
+ -webkit-transform: translate(0px, 8px);
361
+ -moz-transform: translate(0px, 8px);
362
+ -o-transform: translate(0px, 8px);
363
+ -ms-transform: translate(0px, 8px);
364
+ }
365
+
366
+ .terminal-player .cover:hover + .start svg,
367
+ .terminal-player .start:hover svg {
368
+ fill: white;
369
+ }
370
+
371
+ .terminal-player.started .cover,
372
+ .terminal-player.started .start {
373
+ display: none;
374
+ }
375
+
376
+ .terminal-player .terminal-watermark {
377
+ z-index: 99999;
378
+ }
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _xterm = require("xterm");
13
+
14
+ var _xtermAddonWebLinks = require("xterm-addon-web-links");
15
+
16
+ var _xtermAddonFit = require("xterm-addon-fit");
17
+
18
+ var _lodash = require("lodash");
19
+
20
+ require("./xterm.css");
21
+
22
+ var _jsxRuntime = require("react/jsx-runtime");
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
+
28
+ class Terminal extends _react.default.Component {
29
+ constructor() {
30
+ super(...arguments);
31
+
32
+ _defineProperty(this, "xterm", null);
33
+
34
+ _defineProperty(this, "container", null);
35
+
36
+ _defineProperty(this, "onData", data => {
37
+ if (this.props.onData) {
38
+ this.props.onData(data);
39
+ }
40
+ });
41
+
42
+ _defineProperty(this, "onRender", data => {
43
+ if (this.props.onRender) {
44
+ this.props.onRender(data);
45
+ }
46
+ });
47
+ }
48
+
49
+ componentDidMount() {
50
+ const {
51
+ value,
52
+ options
53
+ } = this.props;
54
+ this.fitAddon = new _xtermAddonFit.FitAddon();
55
+ this.xterm = new _xterm.Terminal(options);
56
+ this.xterm.loadAddon(new _xtermAddonWebLinks.WebLinksAddon());
57
+ this.xterm.loadAddon(this.fitAddon);
58
+ this.xterm.open(this.container);
59
+ this.xterm.onData(this.onData.bind(this));
60
+ this.xterm.onRender(this.onRender.bind(this));
61
+
62
+ if (value) {
63
+ this.xterm.write(value);
64
+ }
65
+
66
+ setTimeout(() => {
67
+ if (this.xterm) {
68
+ this.fitAddon.fit();
69
+ }
70
+ }, 0);
71
+ this.debounceFit = (0, _lodash.debounce)(() => {
72
+ this.fitAddon.fit();
73
+ }, 600);
74
+ window.addEventListener('resize', this.debounceFit);
75
+ }
76
+
77
+ componentWillUnmount() {
78
+ if (this.xterm) {
79
+ this.xterm.dispose();
80
+ this.xterm = null;
81
+ }
82
+
83
+ window.removeEventListener('resize', this.debounceFit);
84
+ }
85
+
86
+ shouldComponentUpdate(nextProps) {
87
+ // eslint-disable-next-line no-prototype-builtins
88
+ if (nextProps.hasOwnProperty('value') && nextProps.value !== this.props.value) {
89
+ if (this.xterm) {
90
+ this.xterm.clear();
91
+ setTimeout(() => {
92
+ this.xterm.write(nextProps.value);
93
+ }, 0);
94
+ }
95
+ }
96
+
97
+ return false;
98
+ }
99
+
100
+ getXTerm() {
101
+ return this.xterm;
102
+ }
103
+
104
+ write(data, cb) {
105
+ if (this.xterm) {
106
+ this.xterm.write(data, cb);
107
+ }
108
+ }
109
+
110
+ focus() {
111
+ if (this.xterm) {
112
+ this.xterm.focus();
113
+ }
114
+ }
115
+
116
+ reset() {
117
+ if (this.xterm) {
118
+ this.xterm.reset();
119
+ }
120
+ }
121
+
122
+ resize(cols, rows) {
123
+ if (this.xterm) {
124
+ this.xterm.resize(Math.round(cols), Math.round(rows));
125
+ }
126
+ }
127
+
128
+ setOption(key, value) {
129
+ if (this.xterm) {
130
+ this.xterm.setOption(key, value);
131
+ }
132
+ }
133
+
134
+ getOption(key) {
135
+ if (this.xterm) {
136
+ this.xterm.setOption(key);
137
+ }
138
+ }
139
+
140
+ refresh() {
141
+ if (this.xterm) {
142
+ this.xterm.refresh(0, this.xterm.rows - 1);
143
+ }
144
+ }
145
+
146
+ render() {
147
+ const className = ['react-xterm', this.props.className].filter(Boolean).join(' ');
148
+ return (
149
+ /*#__PURE__*/
150
+ // eslint-disable-next-line no-return-assign
151
+ (0, _jsxRuntime.jsx)("div", {
152
+ ref: _ref => this.container = _ref,
153
+ className: className,
154
+ style: this.props.style
155
+ })
156
+ );
157
+ }
158
+
159
+ }
160
+
161
+ exports.default = Terminal;
162
+ Terminal.propTypes = {
163
+ onData: _propTypes.default.func,
164
+ onRender: _propTypes.default.func,
165
+ options: _propTypes.default.object,
166
+ value: _propTypes.default.string,
167
+ className: _propTypes.default.string,
168
+ style: _propTypes.default.object
169
+ };
170
+
171
+ const noop = () => {};
172
+
173
+ Terminal.defaultProps = {
174
+ onData: noop,
175
+ onRender: noop,
176
+ options: {},
177
+ value: '',
178
+ className: '',
179
+ style: {}
180
+ };