@arcblock/terminal 2.13.69 → 3.0.0

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/Terminal.js CHANGED
@@ -1,147 +1,86 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _xterm = require("xterm");
10
- var _xtermAddonWebLinks = require("xterm-addon-web-links");
11
- var _xtermAddonFit = require("xterm-addon-fit");
12
- var _debounce = _interopRequireDefault(require("lodash/debounce"));
13
- var _noop = _interopRequireDefault(require("lodash/noop"));
14
- require("./xterm.css");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
19
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable react/no-unused-class-component-methods */
20
- class Terminal extends _react.default.Component {
1
+ var a = Object.defineProperty;
2
+ var d = (r, i, t) => i in r ? a(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
3
+ var o = (r, i, t) => d(r, typeof i != "symbol" ? i + "" : i, t);
4
+ import { jsx as p } from "react/jsx-runtime";
5
+ import f from "react";
6
+ import s from "prop-types";
7
+ import { Terminal as x } from "xterm";
8
+ import { WebLinksAddon as l } from "xterm-addon-web-links";
9
+ import { FitAddon as c } from "xterm-addon-fit";
10
+ import u from "lodash/debounce";
11
+ import m from "lodash/noop";
12
+ /* empty css */
13
+ class w extends f.Component {
21
14
  constructor() {
22
15
  super(...arguments);
23
- _defineProperty(this, "xterm", null);
24
- _defineProperty(this, "container", null);
25
- _defineProperty(this, "onData", data => {
26
- if (this.props.onData) {
27
- this.props.onData(data);
28
- }
16
+ o(this, "xterm", null);
17
+ o(this, "container", null);
18
+ o(this, "onData", (t) => {
19
+ const { onData: e = m } = this.props;
20
+ e(t);
29
21
  });
30
- _defineProperty(this, "onRender", data => {
31
- if (this.props.onRender) {
32
- this.props.onRender(data);
33
- }
22
+ o(this, "onRender", (t) => {
23
+ const { onRender: e = m } = this.props;
24
+ e(t);
34
25
  });
35
26
  }
36
27
  componentDidMount() {
37
- const {
38
- value,
39
- options
40
- } = this.props;
41
- this.fitAddon = new _xtermAddonFit.FitAddon();
42
- this.xterm = new _xterm.Terminal(options);
43
- this.xterm.loadAddon(new _xtermAddonWebLinks.WebLinksAddon());
44
- this.xterm.loadAddon(this.fitAddon);
45
- this.xterm.open(this.container);
46
- this.xterm.onData(this.onData.bind(this));
47
- this.xterm.onRender(this.onRender.bind(this));
48
- if (value) {
49
- this.xterm.write(value);
50
- }
51
- setTimeout(() => {
52
- if (this.xterm) {
53
- this.fitAddon.fit();
54
- }
55
- }, 0);
56
- this.debounceFit = (0, _debounce.default)(() => {
28
+ const { value: t = "", options: e = {} } = this.props;
29
+ this.fitAddon = new c(), this.xterm = new x(e), this.xterm.loadAddon(new l()), this.xterm.loadAddon(this.fitAddon), this.xterm.open(this.container), this.xterm.onData(this.onData.bind(this)), this.xterm.onRender(this.onRender.bind(this)), t && this.xterm.write(t), setTimeout(() => {
30
+ this.xterm && this.fitAddon.fit();
31
+ }, 0), this.debounceFit = u(() => {
57
32
  this.fitAddon.fit();
58
- }, 600);
59
- window.addEventListener('resize', this.debounceFit);
33
+ }, 600), window.addEventListener("resize", this.debounceFit);
60
34
  }
61
35
  componentWillUnmount() {
62
- if (this.xterm) {
63
- this.xterm.dispose();
64
- this.xterm = null;
65
- }
66
- window.removeEventListener('resize', this.debounceFit);
36
+ this.xterm && (this.xterm.dispose(), this.xterm = null), window.removeEventListener("resize", this.debounceFit);
67
37
  }
68
- shouldComponentUpdate(nextProps) {
69
- // eslint-disable-next-line no-prototype-builtins
70
- if (nextProps.hasOwnProperty('value') && nextProps.value !== this.props.value) {
71
- if (this.xterm) {
72
- this.xterm.clear();
73
- setTimeout(() => {
74
- this.xterm.write(nextProps.value);
75
- }, 0);
76
- }
77
- }
78
- return false;
38
+ shouldComponentUpdate(t) {
39
+ const { value: e = "" } = t, { value: n = "" } = this.props;
40
+ return t.hasOwnProperty("value") && e !== n && this.xterm && (this.xterm.clear(), setTimeout(() => {
41
+ this.xterm.write(e);
42
+ }, 0)), !1;
79
43
  }
80
44
  getXTerm() {
81
45
  return this.xterm;
82
46
  }
83
- write(data, cb) {
84
- if (this.xterm) {
85
- this.xterm.write(data, cb);
86
- }
47
+ write(t, e) {
48
+ this.xterm && this.xterm.write(t, e);
87
49
  }
88
50
  focus() {
89
- if (this.xterm) {
90
- this.xterm.focus();
91
- }
51
+ this.xterm && this.xterm.focus();
92
52
  }
93
53
  reset() {
94
- if (this.xterm) {
95
- this.xterm.reset();
96
- }
54
+ this.xterm && this.xterm.reset();
97
55
  }
98
- resize(cols, rows) {
99
- if (this.xterm) {
100
- this.xterm.resize(Math.round(cols), Math.round(rows));
101
- }
56
+ resize(t, e) {
57
+ this.xterm && this.xterm.resize(Math.round(t), Math.round(e));
102
58
  }
103
- setOption(key, value) {
104
- if (this.xterm) {
105
- this.xterm.setOption(key, value);
106
- }
59
+ setOption(t, e) {
60
+ this.xterm && this.xterm.setOption(t, e);
107
61
  }
108
- getOption(key) {
109
- if (this.xterm) {
110
- this.xterm.setOption(key);
111
- }
62
+ getOption(t) {
63
+ this.xterm && this.xterm.setOption(t);
112
64
  }
113
65
  refresh() {
114
- if (this.xterm) {
115
- this.xterm.refresh(0, this.xterm.rows - 1);
116
- }
66
+ this.xterm && this.xterm.refresh(0, this.xterm.rows - 1);
117
67
  }
118
68
  render() {
119
- const className = ['react-xterm', this.props.className].filter(Boolean).join(' ');
69
+ const { className: t = "", style: e = {} } = this.props, n = ["react-xterm", t].filter(Boolean).join(" ");
120
70
  return (
121
- /*#__PURE__*/
122
71
  // eslint-disable-next-line no-return-assign
123
- (0, _jsxRuntime.jsx)("div", {
124
- ref: _ref => this.container = _ref,
125
- className: className,
126
- style: this.props.style
127
- })
72
+ /* @__PURE__ */ p("div", { ref: (h) => this.container = h, className: n, style: e })
128
73
  );
129
74
  }
130
75
  }
131
- exports.default = Terminal;
132
- Terminal.propTypes = {
133
- onData: _propTypes.default.func,
134
- onRender: _propTypes.default.func,
135
- options: _propTypes.default.object,
136
- value: _propTypes.default.string,
137
- className: _propTypes.default.string,
138
- style: _propTypes.default.object
76
+ w.propTypes = {
77
+ onData: s.func,
78
+ onRender: s.func,
79
+ options: s.object,
80
+ value: s.string,
81
+ className: s.string,
82
+ style: s.object
83
+ };
84
+ export {
85
+ w as default
139
86
  };
140
- Terminal.defaultProps = {
141
- onData: _noop.default,
142
- onRender: _noop.default,
143
- options: {},
144
- value: '',
145
- className: '',
146
- style: {}
147
- };
package/lib/index.js CHANGED
@@ -1,20 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Terminal", {
7
- enumerable: true,
8
- get: function get() {
9
- return _Terminal.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "TerminalPlayer", {
13
- enumerable: true,
14
- get: function get() {
15
- return _Player.default;
16
- }
17
- });
18
- var _Terminal = _interopRequireDefault(require("./Terminal"));
19
- var _Player = _interopRequireDefault(require("./Player"));
20
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1
+ import { default as r } from "./Terminal.js";
2
+ import { default as f } from "./Player.js";
3
+ export {
4
+ r as Terminal,
5
+ f as TerminalPlayer
6
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) 2014 The xterm.js authors. All rights reserved.
3
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4
+ * https://github.com/chjj/term.js
5
+ * @license MIT
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ * Originally forked from (with the author's permission):
26
+ * Fabrice Bellard's javascript vt100 for jslinux:
27
+ * http://bellard.org/jslinux/
28
+ * Copyright (c) 2011 Fabrice Bellard
29
+ * The original design remains. The terminal itself
30
+ * has been extended to include xterm CSI codes, among
31
+ * other features.
32
+ */.xterm{font-feature-settings:"liga" 0;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm{cursor:text}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility,.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:.5}.xterm-underline{text-decoration:underline}.terminal-player,.terminal{display:inline-block}.terminal .xterm .xterm-viewport{overflow-y:hidden!important}.terminal-frame{position:relative}.terminal div{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline}.terminal-frame.terminal-window{-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;border:1px solid #b3b3b3;box-shadow:0 0 18px #b3b3b3;margin:18px;overflow:hidden}.terminal-frame.terminal-window .terminal-titlebar{-moz-border-top-left-radius:6px;-moz-border-top-right-radius:6px;-webkit-border-top-left-radius:6px;-webkit-border-top-right-radius:6px;background:#e8e8e8;border-bottom:1px solid #b1aeb1;border-top-left-radius:6px;border-top-right-radius:6px;border-top:1px solid #f3f1f3;color:#3b4247;font-family:Arial,sans-serif;font-size:14px;height:22px;line-height:22px;position:relative;text-align:center;width:100%}.terminal-frame.terminal-window .terminal-titlebar .buttons{left:8px;line-height:0px;position:absolute;top:3.5px}.terminal-frame.terminal-window .terminal-titlebar .close-button{-moz-border-radius:50%;-webkit-border-radius:50%;background:#ff5c5c;border-radius:50%;border:1px solid #e33e41;display:inline-block;height:12px;width:12px}.terminal-frame.terminal-window .terminal-titlebar .minimize-button{-moz-border-radius:50%;-webkit-border-radius:50%;background:#ffbd4c;border-radius:50%;border:1px solid #e09e3e;display:inline-block;height:12px;margin-left:4px;width:12px}.terminal-frame.terminal-window .terminal-titlebar .maximize-button{-moz-border-radius:50%;-webkit-border-radius:50%;background:#00ca56;border-radius:50%;border:1px solid #14ae46;display:inline-block;height:12px;margin-left:4px;width:12px}.terminal-frame.terminal-window .terminal-body{background-color:#1d1d1d;padding:10px}.terminal-frame.terminal-floating{-moz-border-radius:6px;-webkit-border-radius:6px;background-color:#1d1d1d;border-radius:6px;box-shadow:0 0 18px #b3b3b3;margin:18px;overflow:hidden}.terminal-frame.terminal-floating .terminal-titlebar{color:#fff;font-family:Arial,sans-serif;font-size:14px;height:34px;line-height:34px;position:relative;text-align:center;width:100%}.terminal-frame.terminal-floating .terminal-titlebar .buttons{left:13px;line-height:0px;position:absolute;top:9px}.terminal-frame.terminal-floating .terminal-titlebar .close-button{-moz-border-radius:50%;-webkit-border-radius:50%;background:#ff5c5c;border-radius:50%;display:inline-block;height:15px;width:15px}.terminal-frame.terminal-floating .terminal-titlebar .minimize-button{-moz-border-radius:50%;-webkit-border-radius:50%;background:#ffbd4c;border-radius:50%;display:inline-block;height:15px;line-height:10px;margin-left:4px;width:15px}.terminal-frame.terminal-floating .terminal-titlebar .maximize-button{-moz-border-radius:50%;-webkit-border-radius:50%;background:#00ca56;border-radius:50%;display:inline-block;height:15px;line-height:10px;margin-left:4px;width:15px}.terminal-frame.terminal-floating .terminal-body{padding:20px}.terminal-frame.terminal-solid{-moz-border-radius:6px;-webkit-border-radius:6px;background-color:#1d1d1d;border-radius:6px;box-shadow:0 0 18px #b3b3b3;margin:18px;overflow:hidden}.terminal-frame.terminal-solid .terminal-titlebar{color:#fff;font-family:Arial,sans-serif;font-size:14px;position:relative;text-align:center;width:100%}.terminal-frame.terminal-solid .terminal-titlebar .title{margin:15px}.terminal-frame.terminal-solid .terminal-titlebar .title:empty{display:none}.terminal-frame.terminal-solid .terminal-titlebar .buttons{display:none}.terminal-frame.terminal-solid .terminal-body{padding:20px}.terminal-player{position:relative;font-size:0}.terminal-player .controller{background:#45484d;bottom:0;display:none;font-family:Helvetica,Arial,sans-serif;font-size:12px;height:40px;position:absolute;width:100%;z-index:20;background:#222;transition:height ease .2s;-webkit-transition:height ease .2s;-moz-transition:height ease .2s;-o-transition:height ease .2s}.terminal-player.controls .controller{display:block}.terminal-player.playing .controller{height:0px;overflow:hidden}.terminal-player.playing:hover .controller{height:40px;overflow:hidden}.terminal-player .play,.terminal-player .pause{fill:#cacaca;float:left;height:40px;line-height:40px;text-align:center;width:40px}.terminal-player .play .icon,.terminal-player .pause .icon{border-color:transparent transparent transparent #cacaca;box-sizing:border-box;cursor:pointer;display:inline-block;height:15px}.terminal-player .pause .icon{border-style:double;border-width:0px 0px 0px 12px;margin-top:11px}.terminal-player .play .icon{border-style:solid;border-width:8px 0px 8px 13px;margin-top:10px}.terminal-player .pause,.terminal-player.playing .play{display:none}.terminal-player.playing .pause{display:inline-block}.terminal-player .timer{color:#cacaca;float:right;line-height:40px;padding:0 10px}.terminal-player .progressbar-wrapper{height:40px;line-height:38px;overflow:hidden}.terminal-player .progressbar{background-color:#424242;display:inline-block;height:7px;overflow:hidden;width:100%;border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:10px}.terminal-player.started .progressbar{cursor:pointer}.terminal-player .progress{background-color:#cacaca;height:7px;position:relative;width:0%}.terminal-player .cover{cursor:pointer;height:100%;position:absolute;width:100%;z-index:10}.terminal-player .start svg{cursor:pointer;fill:#eaeaea;height:130px;left:50%;margin-left:-65px;margin-top:-65px;position:absolute;top:50%;width:130px;z-index:20;filter:drop-shadow(10px 10px 15px rgba(0,0,0,.4));-webkit-filter:drop-shadow(10px 10px 15px rgba(0,0,0,.4))}.terminal-player.small .start svg{height:60px;margin-left:-30px;margin-top:-30px;width:60px}.terminal-player.framed .start svg{transform:translateY(8px);-webkit-transform:translate(0px,8px);-moz-transform:translate(0px,8px);-o-transform:translate(0px,8px);-ms-transform:translate(0px,8px)}.terminal-player .cover:hover+.start svg,.terminal-player .start:hover svg{fill:#fff}.terminal-player.started .cover,.terminal-player.started .start{display:none}.terminal-player .terminal-watermark{z-index:99999}
package/lib/util.js CHANGED
@@ -1,166 +1,59 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isFrameAt = exports.getPlayerClass = exports.getFrameClass = exports.formatTime = exports.formatFrames = exports.findFrameAt = exports.defaultState = exports.defaultOptions = void 0;
7
- /**
8
- * Adjust the delays of the frames, considering to the options
9
- *
10
- * - frameDelay
11
- * - Delay between frames in ms
12
- * - If the value is `auto` use the actual recording delays
13
- *
14
- * - maxIdleTime
15
- * - Maximum delay between frames in ms
16
- * - Ignored if the `frameDelay` isn't set to `auto`
17
- * - Set to `auto` to prevnt limiting the max idle time
18
- *
19
- * - speedFactor
20
- * - Multiply the frames delays by this factor
21
- */
22
- const formatFrames = (frames, options) => {
23
- frames.forEach(x => {
24
- let {
25
- delay
26
- } = x;
27
-
28
- // Adjust the delay according to the options
29
- if (options.frameDelay !== 'auto') {
30
- delay = options.frameDelay;
31
- } else if (options.maxIdleTime !== 'auto' && delay > options.maxIdleTime) {
32
- delay = options.maxIdleTime;
33
- }
34
-
35
- // Apply speedFactor
36
- delay *= options.speedFactor;
37
-
38
- // Set the adjusted delay
39
- x.delay = delay;
1
+ const f = (t, e) => {
2
+ t.forEach((n) => {
3
+ let { delay: l } = n;
4
+ e.frameDelay !== "auto" ? l = e.frameDelay : e.maxIdleTime !== "auto" && l > e.maxIdleTime && (l = e.maxIdleTime), l *= e.speedFactor, n.delay = l;
40
5
  });
41
-
42
- // Calculate and set the duration, startTime, and endTime for each frame
43
- let currentTime = 0;
44
- const framesCount = frames.length;
45
- frames.forEach((x, index) => {
46
- // Set the duration (the delay of the next frame)
47
- // The % is used to take the delay of the first frame
48
- // as the duration of the last frame
49
- const duration = frames[(index + 1) % framesCount].delay;
50
-
51
- // Set timing values for the current frame
52
- x.duration = duration;
53
- x.startTime = currentTime;
54
- x.endTime = currentTime + duration;
55
- currentTime += duration;
6
+ let r = 0;
7
+ const a = t.length;
8
+ t.forEach((n, l) => {
9
+ const i = t[(l + 1) % a].delay;
10
+ n.duration = i, n.startTime = r, n.endTime = r + i, r += i;
56
11
  });
57
-
58
- // Total duration
59
- const totalDuration = frames.reduce((sum, x) => sum + x.delay, 0);
60
- return {
61
- frames,
62
- totalDuration
63
- };
64
- };
65
-
66
- /**
67
- * Get the frame's index at a specific time
68
- */
69
- exports.formatFrames = formatFrames;
70
- const findFrameAt = (frames, time, fromIndex) => {
71
- let frame = null;
72
- if (typeof fromIndex === 'undefined') {
73
- // eslint-disable-next-line no-param-reassign
74
- fromIndex = 0;
75
- }
76
- for (let i = fromIndex; i < frames.length; i++) {
77
- frame = frames[i];
78
- if (frame.startTime <= time && time < frame.endTime) {
79
- return i;
80
- }
81
- }
82
-
83
- // The endTime of the final frame belongs to it
84
- if (frame.startTime <= time && time <= frame.endTime) {
85
- return frames.length - 1;
86
- }
87
- return -1;
88
- };
89
-
90
- /**
91
- * Check if the time belongs to the frame's duration
92
- *
93
- * @param {Number} time
94
- * @param {Number} frameIndex
95
- * @return {Number}
96
- */
97
- exports.findFrameAt = findFrameAt;
98
- const isFrameAt = (frames, time, frameIndex) => {
99
- const frame = frames[frameIndex];
100
- if (typeof frame === 'undefined') {
101
- return false;
102
- }
103
- if (frame.startTime <= time && time < frame.endTime) {
104
- return true;
105
- }
106
- return false;
107
- };
108
- exports.isFrameAt = isFrameAt;
109
- const formatTime = time => {
110
- let minutes = Math.floor(time / 60000);
111
- let seconds = parseInt((time - minutes * 60000) / 1000, 10);
112
- if (minutes < 10) {
113
- minutes = "0".concat(minutes);
114
- }
115
- if (seconds < 10) {
116
- seconds = "0".concat(seconds);
117
- }
118
- return "".concat(minutes, ":").concat(seconds);
119
- };
120
- exports.formatTime = formatTime;
121
- const getPlayerClass = (options, state) => {
122
- const playerClass = ['terminal-player'];
123
- if (options.controls) {
124
- playerClass.push('controls');
125
- }
126
- if (options.frameBox.type) {
127
- playerClass.push('framed');
128
- }
129
- if (options.rows < 10) {
130
- playerClass.push('small');
131
- }
132
- if (state.isStarted) {
133
- playerClass.push('started');
134
- }
135
- if (state.isPlaying) {
136
- playerClass.push('playing');
137
- }
138
- return playerClass.filter(Boolean).join(' ');
139
- };
140
- exports.getPlayerClass = getPlayerClass;
141
- const getFrameClass = options => {
142
- const frameClass = ['terminal-frame'];
143
- if (options.frameBox.type) {
144
- frameClass.push("terminal-".concat(options.frameBox.type));
145
- }
146
- return frameClass.join(' ');
147
- };
148
- exports.getFrameClass = getFrameClass;
149
- const defaultState = exports.defaultState = {
150
- isPlaying: false,
151
- isStarted: false,
152
- isRendering: false,
153
- requireReset: false,
12
+ const s = t.reduce((n, l) => n + l.delay, 0);
13
+ return { frames: t, totalDuration: s };
14
+ }, u = (t, e, r) => {
15
+ let a = null;
16
+ typeof r > "u" && (r = 0);
17
+ for (let s = r; s < t.length; s++)
18
+ if (a = t[s], a.startTime <= e && e < a.endTime)
19
+ return s;
20
+ return a.startTime <= e && e <= a.endTime ? t.length - 1 : -1;
21
+ }, o = (t, e, r) => {
22
+ const a = t[r];
23
+ return typeof a > "u" ? !1 : a.startTime <= e && e < a.endTime;
24
+ }, m = (t) => {
25
+ let e = Math.floor(t / 6e4), r = parseInt((t - e * 6e4) / 1e3, 10);
26
+ return e < 10 && (e = `0${e}`), r < 10 && (r = `0${r}`), `${e}:${r}`;
27
+ }, c = (t, e) => {
28
+ const r = ["terminal-player"];
29
+ return t.controls && r.push("controls"), t.frameBox.type && r.push("framed"), t.rows < 10 && r.push("small"), e.isStarted && r.push("started"), e.isPlaying && r.push("playing"), r.filter(Boolean).join(" ");
30
+ }, d = (t) => {
31
+ const e = ["terminal-frame"];
32
+ return t.frameBox.type && e.push(`terminal-${t.frameBox.type}`), e.join(" ");
33
+ }, y = {
34
+ isPlaying: !1,
35
+ isStarted: !1,
36
+ isRendering: !1,
37
+ requireReset: !1,
154
38
  currentFrame: -1,
155
39
  currentTime: 0,
156
40
  lastTickTime: null
157
- };
158
- const defaultOptions = exports.defaultOptions = {
159
- realTiming: false,
160
- speedFactor: 1.0,
161
- controls: true,
162
- repeat: false,
163
- autoplay: false,
41
+ }, T = {
42
+ realTiming: !1,
43
+ speedFactor: 1,
44
+ controls: !0,
45
+ repeat: !1,
46
+ autoplay: !1,
164
47
  thumbnailTime: 999999,
165
48
  frameBox: {}
166
- };
49
+ };
50
+ export {
51
+ T as defaultOptions,
52
+ y as defaultState,
53
+ u as findFrameAt,
54
+ f as formatFrames,
55
+ m as formatTime,
56
+ d as getFrameClass,
57
+ c as getPlayerClass,
58
+ o as isFrameAt
59
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/terminal",
3
- "version": "2.13.69",
3
+ "version": "3.0.0",
4
4
  "description": "A react wrapper for xterm allowing you to easily render a terminal in the browser",
5
5
  "keywords": [
6
6
  "react",
@@ -19,8 +19,8 @@
19
19
  },
20
20
  "scripts": {
21
21
  "lint": "eslint src tests --ext js --ext jsx",
22
- "build": "babel src --out-dir lib --copy-files --no-copy-ignored",
23
- "watch": "babel src --out-dir lib -w --copy-files --no-copy-ignored",
22
+ "build": "vite build",
23
+ "watch": "vite build --watch",
24
24
  "precommit": "CI=1 npm run lint",
25
25
  "prepush": "CI=1 npm run lint",
26
26
  "prepublish": "npm run build",
@@ -34,26 +34,19 @@
34
34
  "access": "public"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/cli": "^7.19.3",
38
- "@babel/core": "^7.19.3",
39
- "@babel/plugin-proposal-class-properties": "^7.18.6",
40
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
41
- "@babel/preset-env": "^7.19.3",
42
- "@babel/preset-react": "^7.18.6",
43
- "eslint-plugin-react-hooks": "^4.6.0",
37
+ "eslint-plugin-react-hooks": "^4.6.2",
44
38
  "jest": "^29.7.0"
45
39
  },
46
40
  "peerDependencies": {
47
- "react": ">=18.2.0"
41
+ "react": "^19.0.0"
48
42
  },
49
- "gitHead": "d8a03a6d869bf5f7be34b448463a07c435b21cea",
43
+ "gitHead": "b001c32ca85d40d8a0784ca581bfd54d90550b24",
50
44
  "dependencies": {
51
- "@arcblock/react-hooks": "^2.13.69",
52
- "@arcblock/ux": "^2.13.69",
53
- "@emotion/react": "^11.10.4",
54
- "@emotion/styled": "^11.10.4",
55
- "ahooks": "^3.7.10",
56
- "core-js": "^3.25.5",
45
+ "@arcblock/react-hooks": "3.0.0",
46
+ "@arcblock/ux": "3.0.0",
47
+ "@emotion/react": "^11.14.0",
48
+ "@emotion/styled": "^11.14.0",
49
+ "ahooks": "^3.8.5",
57
50
  "lodash": "^4.17.21",
58
51
  "xterm": "4.19.0",
59
52
  "xterm-addon-fit": "^0.2.1",
@@ -3,6 +3,7 @@ import { useReducer, useState, useRef, useEffect } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import useInterval from '@arcblock/react-hooks/lib/useInterval';
5
5
  import { useSize } from 'ahooks';
6
+ import isUndefined from 'lodash/isUndefined';
6
7
  import noop from 'lodash/noop';
7
8
 
8
9
  import Terminal from './Terminal';
@@ -20,7 +21,27 @@ import {
20
21
  defaultState,
21
22
  } from './util';
22
23
 
23
- export default function Player(props) {
24
+ export default function Player(rawProps) {
25
+ const props = Object.assign({}, rawProps);
26
+ if (isUndefined(props.onComplete)) {
27
+ props.onComplete = noop;
28
+ }
29
+ if (isUndefined(props.onStart)) {
30
+ props.onStart = noop;
31
+ }
32
+ if (isUndefined(props.onStop)) {
33
+ props.onStop = noop;
34
+ }
35
+ if (isUndefined(props.onPause)) {
36
+ props.onPause = noop;
37
+ }
38
+ if (isUndefined(props.onTick)) {
39
+ props.onTick = noop;
40
+ }
41
+ if (isUndefined(props.onJump)) {
42
+ props.onJump = noop;
43
+ }
44
+
24
45
  const options = Object.assign({}, defaultOptions, props.options);
25
46
  const { frames, totalDuration } = formatFrames(props.frames, options);
26
47
 
@@ -353,12 +374,3 @@ Player.propTypes = {
353
374
  onTick: PropTypes.func,
354
375
  onJump: PropTypes.func,
355
376
  };
356
-
357
- Player.defaultProps = {
358
- onComplete: noop,
359
- onStart: noop,
360
- onStop: noop,
361
- onPause: noop,
362
- onTick: noop,
363
- onJump: noop,
364
- };
@@ -0,0 +1,14 @@
1
+ export { default as Player } from './demo/player';
2
+
3
+ export default {
4
+ title: 'Data Display/Terminal/Player',
5
+
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component:
10
+ 'Terminal Player is a react wrapper for `xterm` allowing you to easily render a terminal in the browser.',
11
+ },
12
+ },
13
+ },
14
+ };