@arcblock/terminal 2.13.70 → 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/Player.js +148 -408
- package/lib/Terminal.js +55 -116
- package/lib/index.js +6 -20
- package/lib/terminal.css +32 -0
- package/lib/util.js +52 -159
- package/package.json +11 -18
- package/src/{Player.js → Player.jsx} +22 -10
- package/src/Player.stories.jsx +14 -0
- package/src/{Terminal.js → Terminal.jsx} +13 -20
- package/vite.config.mjs +29 -0
- package/lib/demo/fixtures/recording.json +0 -860
- package/lib/demo/fixtures/recording2.json +0 -556
- package/lib/player.css +0 -378
- package/lib/xterm.css +0 -171
|
@@ -15,7 +15,7 @@ export default class Terminal extends React.Component {
|
|
|
15
15
|
container = null;
|
|
16
16
|
|
|
17
17
|
componentDidMount() {
|
|
18
|
-
const { value, options } = this.props;
|
|
18
|
+
const { value = '', options = {} } = this.props;
|
|
19
19
|
this.fitAddon = new FitAddon();
|
|
20
20
|
|
|
21
21
|
this.xterm = new XTerm(options);
|
|
@@ -53,12 +53,15 @@ export default class Terminal extends React.Component {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
shouldComponentUpdate(nextProps) {
|
|
56
|
+
const { value: nextValue = '' } = nextProps;
|
|
57
|
+
const { value: currentValue = '' } = this.props;
|
|
58
|
+
|
|
56
59
|
// eslint-disable-next-line no-prototype-builtins
|
|
57
|
-
if (nextProps.hasOwnProperty('value') &&
|
|
60
|
+
if (nextProps.hasOwnProperty('value') && nextValue !== currentValue) {
|
|
58
61
|
if (this.xterm) {
|
|
59
62
|
this.xterm.clear();
|
|
60
63
|
setTimeout(() => {
|
|
61
|
-
this.xterm.write(
|
|
64
|
+
this.xterm.write(nextValue);
|
|
62
65
|
}, 0);
|
|
63
66
|
}
|
|
64
67
|
}
|
|
@@ -88,15 +91,13 @@ export default class Terminal extends React.Component {
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
onData = (data) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
+
const { onData = noop } = this.props;
|
|
95
|
+
onData(data);
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
onRender = (data) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
99
|
+
const { onRender = noop } = this.props;
|
|
100
|
+
onRender(data);
|
|
100
101
|
};
|
|
101
102
|
|
|
102
103
|
resize(cols, rows) {
|
|
@@ -124,10 +125,11 @@ export default class Terminal extends React.Component {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
render() {
|
|
127
|
-
const className =
|
|
128
|
+
const { className = '', style = {} } = this.props;
|
|
129
|
+
const combinedClassName = ['react-xterm', className].filter(Boolean).join(' ');
|
|
128
130
|
return (
|
|
129
131
|
// eslint-disable-next-line no-return-assign
|
|
130
|
-
<div ref={(ref) => (this.container = ref)} className={
|
|
132
|
+
<div ref={(ref) => (this.container = ref)} className={combinedClassName} style={style} />
|
|
131
133
|
);
|
|
132
134
|
}
|
|
133
135
|
}
|
|
@@ -140,12 +142,3 @@ Terminal.propTypes = {
|
|
|
140
142
|
className: PropTypes.string,
|
|
141
143
|
style: PropTypes.object,
|
|
142
144
|
};
|
|
143
|
-
|
|
144
|
-
Terminal.defaultProps = {
|
|
145
|
-
onData: noop,
|
|
146
|
-
onRender: noop,
|
|
147
|
-
options: {},
|
|
148
|
-
value: '',
|
|
149
|
-
className: '',
|
|
150
|
-
style: {},
|
|
151
|
-
};
|
package/vite.config.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import svgr from 'vite-plugin-svgr';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import noBundlePlugin from 'vite-plugin-no-bundle';
|
|
5
|
+
import fg from 'fast-glob';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [
|
|
9
|
+
react({ jsxRuntime: 'automatic' }),
|
|
10
|
+
svgr({
|
|
11
|
+
include: ['**/*.svg', '**/*.svg?react'],
|
|
12
|
+
}),
|
|
13
|
+
noBundlePlugin({
|
|
14
|
+
root: 'src',
|
|
15
|
+
copy: ['**/*.png', '**/*.gif', '**/*.jpg', '**/*.jpeg', '**/*.d.ts'],
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
build: {
|
|
19
|
+
lib: {
|
|
20
|
+
entry: fg.sync('src/**/*.{tsx,ts,jsx,js}', {
|
|
21
|
+
ignore: ['**/stories/**', '**/demo/**', '**/*.d.ts', '**/*.stories.*'],
|
|
22
|
+
}),
|
|
23
|
+
formats: ['es'],
|
|
24
|
+
fileName: (format, entryName) => `${entryName}.js`,
|
|
25
|
+
},
|
|
26
|
+
outDir: 'lib',
|
|
27
|
+
emptyOutDir: true,
|
|
28
|
+
},
|
|
29
|
+
});
|