@arcblock/terminal 3.1.17 → 3.1.19
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/README.md +1 -3
- package/lib/Player.js +134 -152
- package/lib/Terminal.js +24 -19
- package/lib/styles.js +122 -161
- package/package.json +8 -8
- package/src/Player.jsx +30 -73
- package/src/Terminal.jsx +21 -14
- package/src/styles.js +132 -186
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ import { Player } from '@arcblock/terminal';
|
|
|
26
26
|
import recordingData from './my-recording.json';
|
|
27
27
|
|
|
28
28
|
export default function Demo() {
|
|
29
|
-
return <Player frames={recordingData.records} options={recordingData.config}
|
|
29
|
+
return <Player frames={recordingData.records} options={recordingData.config} loop={true} />;
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -36,8 +36,6 @@ export default function Demo() {
|
|
|
36
36
|
| ------------ | ---------- | ------------ | -------------------------------- |
|
|
37
37
|
| `frames` | `Array` | **required** | Array of terminal frames to play |
|
|
38
38
|
| `options` | `Object` | **required** | Player configuration and theme |
|
|
39
|
-
| `autoPlay` | `Boolean` | `false` | Auto-start playback when mounted |
|
|
40
|
-
| `loop` | `Boolean` | `false` | Loop playback infinitely |
|
|
41
39
|
| `onStart` | `Function` | - | Callback when playback starts |
|
|
42
40
|
| `onPause` | `Function` | - | Callback when playback pauses |
|
|
43
41
|
| `onComplete` | `Function` | - | Callback when playback completes |
|
package/lib/Player.js
CHANGED
|
@@ -1,224 +1,206 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const e = Object.assign({}, G, s.options), { frames: c, totalDuration: w } = K(s.frames, e), D = {
|
|
1
|
+
import { jsxs as k, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as S, useReducer as O, useCallback as y, useEffect as A } from "react";
|
|
3
|
+
import c from "prop-types";
|
|
4
|
+
import b from "lodash/isUndefined";
|
|
5
|
+
import F from "lodash/noop";
|
|
6
|
+
import I from "./Terminal.js";
|
|
7
|
+
import { PlayerRoot as H } from "./styles.js";
|
|
8
|
+
import { defaultOptions as Y, formatFrames as _, defaultState as U, findFrameAt as j, getPlayerClass as X, getFrameClass as $, formatTime as G } from "./util.js";
|
|
9
|
+
const ae = 8;
|
|
10
|
+
function K({ ...E }) {
|
|
11
|
+
const i = Object.assign({}, E);
|
|
12
|
+
b(i.onComplete) && (i.onComplete = F), b(i.onStart) && (i.onStart = F), b(i.onStop) && (i.onStop = F), b(i.onPause) && (i.onPause = F), b(i.onTick) && (i.onTick = F), b(i.onJump) && (i.onJump = F);
|
|
13
|
+
const e = Object.assign({}, Y, i.options), { frames: s, totalDuration: g } = _(i.frames, e), D = {
|
|
15
14
|
cols: e.cols,
|
|
16
15
|
rows: e.rows,
|
|
17
16
|
cursorStyle: e.cursorStyle,
|
|
17
|
+
cursorBlink: e.cursorBlink ?? !0,
|
|
18
18
|
fontFamily: e.fontFamily,
|
|
19
19
|
fontSize: e.fontSize,
|
|
20
20
|
lineHeight: e.lineHeight,
|
|
21
21
|
letterSpacing: e.letterSpacing,
|
|
22
22
|
allowTransparency: !0,
|
|
23
23
|
scrollback: 0,
|
|
24
|
-
theme: e.theme
|
|
25
|
-
},
|
|
26
|
-
switch (
|
|
24
|
+
theme: e.enableTheme ? e.theme : {}
|
|
25
|
+
}, J = (r, t) => {
|
|
26
|
+
switch (t.type) {
|
|
27
27
|
case "jump":
|
|
28
|
-
return { ...
|
|
28
|
+
return { ...r, ...t.payload };
|
|
29
29
|
case "start":
|
|
30
|
-
return { ...
|
|
30
|
+
return { ...r, isStarted: !0, lastTickTime: Date.now() };
|
|
31
31
|
case "play":
|
|
32
|
-
return { ...
|
|
32
|
+
return { ...r, isPlaying: !0, lastTickTime: Date.now(), ...t.payload };
|
|
33
33
|
case "pause":
|
|
34
|
-
return { ...
|
|
34
|
+
return { ...r, isPlaying: !1, ...t.payload };
|
|
35
35
|
case "tickStart":
|
|
36
|
-
return { ...
|
|
36
|
+
return { ...r, isRendering: !0, lastTickTime: Date.now(), ...t.payload };
|
|
37
37
|
case "tickEnd":
|
|
38
|
-
return { ...
|
|
38
|
+
return { ...r, isRendering: !1, lastTickTime: Date.now(), ...t.payload };
|
|
39
39
|
case "reset":
|
|
40
|
-
return { ...
|
|
40
|
+
return { ...r, currentFrame: -1, currentTime: 0, ...t.payload };
|
|
41
41
|
default:
|
|
42
|
-
return { ...
|
|
42
|
+
return { ...r, lastTickTime: Date.now(), ...t.payload };
|
|
43
43
|
}
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (S.current.parentNode) {
|
|
51
|
-
const T = S.current.parentNode.getBoundingClientRect();
|
|
52
|
-
r.width > T.width && (i = T.width);
|
|
53
|
-
}
|
|
54
|
-
e.controls && (i -= 12);
|
|
55
|
-
const f = Math.ceil(i / t), y = Math.min(Math.max(f, 40), e.cols);
|
|
56
|
-
l.current.resize(y, e.rows);
|
|
57
|
-
} catch {
|
|
58
|
-
}
|
|
59
|
-
}, [O, z]);
|
|
60
|
-
const k = g(
|
|
61
|
-
(t) => new Promise((r) => {
|
|
62
|
-
const i = c[t];
|
|
63
|
-
i && i.content && l.current ? (n.requireReset && l.current.reset(), l.current.write(i.content, () => {
|
|
64
|
-
r();
|
|
65
|
-
})) : r();
|
|
44
|
+
}, o = S(null), v = S(null), z = S(null), f = S(null), p = S(null), [n, u] = O(J, U), C = y(
|
|
45
|
+
(r) => new Promise((t) => {
|
|
46
|
+
const l = s[r];
|
|
47
|
+
l && l.content && o.current ? (n.requireReset && o.current.reset(), o.current.write(l.content, () => {
|
|
48
|
+
t();
|
|
49
|
+
})) : t();
|
|
66
50
|
}),
|
|
67
|
-
[
|
|
68
|
-
),
|
|
69
|
-
(
|
|
70
|
-
|
|
51
|
+
[s, n.requireReset]
|
|
52
|
+
), q = y(
|
|
53
|
+
(r) => {
|
|
54
|
+
const t = s[r];
|
|
55
|
+
t && t.content && o.current && (n.requireReset && o.current.reset(), o.current.write(t.content));
|
|
71
56
|
},
|
|
72
|
-
[s, n
|
|
73
|
-
),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
l.current.reset();
|
|
77
|
-
const r = M(c, t);
|
|
78
|
-
if (r >= 0)
|
|
79
|
-
for (let i = 0; i <= r; i++)
|
|
80
|
-
await k(i);
|
|
57
|
+
[s, n.requireReset]
|
|
58
|
+
), m = y(
|
|
59
|
+
(r) => {
|
|
60
|
+
typeof i[r] == "function" && i[r]({ state: n, frames: s, options: e });
|
|
81
61
|
},
|
|
82
|
-
[
|
|
83
|
-
),
|
|
84
|
-
(
|
|
85
|
-
if (!
|
|
62
|
+
[i, n, s, e]
|
|
63
|
+
), R = y(
|
|
64
|
+
(r) => {
|
|
65
|
+
if (!o.current) return;
|
|
66
|
+
o.current.reset();
|
|
67
|
+
const t = j(s, r);
|
|
68
|
+
if (t >= 0)
|
|
69
|
+
for (let l = 0; l <= t; l++)
|
|
70
|
+
q(l);
|
|
71
|
+
},
|
|
72
|
+
[s, q]
|
|
73
|
+
), L = y(
|
|
74
|
+
(r) => {
|
|
75
|
+
if (!v.current || !o.current || !n.isStarted)
|
|
86
76
|
return !1;
|
|
87
|
-
const
|
|
77
|
+
const t = v.current.getBoundingClientRect().width, l = r.nativeEvent.offsetX, h = Math.floor(g * l / t), T = j(s, h), x = n.isPlaying;
|
|
88
78
|
return u({
|
|
89
79
|
type: "jump",
|
|
90
80
|
payload: {
|
|
91
|
-
currentTime:
|
|
92
|
-
currentFrame:
|
|
93
|
-
isPlaying:
|
|
81
|
+
currentTime: h,
|
|
82
|
+
currentFrame: T,
|
|
83
|
+
isPlaying: x
|
|
94
84
|
// Keep the same playing state
|
|
95
85
|
}
|
|
96
|
-
}),
|
|
86
|
+
}), p.current = null, R(h), m("onJump"), !1;
|
|
97
87
|
},
|
|
98
|
-
[n.isStarted, n.isPlaying,
|
|
99
|
-
),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (S.current)
|
|
103
|
-
try {
|
|
104
|
-
J(S.current.getBoundingClientRect().width);
|
|
105
|
-
} catch {
|
|
106
|
-
}
|
|
107
|
-
e.autoplay ? N() : C(Math.min(Math.abs(e.thumbnailTime), w));
|
|
108
|
-
}
|
|
88
|
+
[n.isStarted, n.isPlaying, g, s, R, m]
|
|
89
|
+
), P = y(() => (n.isStarted === !1 && (o.current.resize(), u({ type: "start" }), o.current && o.current.reset()), p.current = null, u({ type: "play", payload: { currentFrame: -1, currentTime: 0 } }), m("onStart"), !1), [n.isStarted, m]), M = y(() => (u({ type: "pause" }), m("onPause"), !1), [m]);
|
|
90
|
+
A(() => {
|
|
91
|
+
o.current && (o.current.focus(), e.autoplay ? P() : R(Math.min(Math.abs(e.thumbnailTime), g)));
|
|
109
92
|
}, []);
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
93
|
+
const w = S(n);
|
|
94
|
+
w.current = n;
|
|
95
|
+
const N = y(async () => {
|
|
96
|
+
const r = w.current;
|
|
97
|
+
if (!r.isPlaying || r.isRendering)
|
|
115
98
|
return;
|
|
116
|
-
const
|
|
117
|
-
if (!
|
|
118
|
-
const
|
|
119
|
-
|
|
99
|
+
const t = performance.now();
|
|
100
|
+
if (!p.current) {
|
|
101
|
+
const d = r.currentFrame >= 0 && s[r.currentFrame]?.startTime || 0;
|
|
102
|
+
p.current = t - d;
|
|
120
103
|
}
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
104
|
+
const l = t - p.current, { currentFrame: h } = r, T = h + 1;
|
|
105
|
+
if (h >= s.length - 1) {
|
|
123
106
|
if (m("onComplete"), e.repeat) {
|
|
124
|
-
|
|
107
|
+
p.current = t, u({ type: "reset", payload: { currentTime: 0, currentFrame: -1 } });
|
|
125
108
|
return;
|
|
126
109
|
}
|
|
127
|
-
const
|
|
128
|
-
currentTime:
|
|
129
|
-
currentFrame:
|
|
110
|
+
const d = {
|
|
111
|
+
currentTime: g,
|
|
112
|
+
currentFrame: s.length - 1,
|
|
130
113
|
requireReset: !0,
|
|
131
114
|
isStarted: !1
|
|
132
115
|
};
|
|
133
|
-
u({ type: "pause", payload:
|
|
116
|
+
u({ type: "pause", payload: d }), p.current = null;
|
|
134
117
|
return;
|
|
135
118
|
}
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
138
|
-
n.isPlaying && (
|
|
119
|
+
const x = s[T];
|
|
120
|
+
if (!x) {
|
|
121
|
+
n.isPlaying && (f.current = requestAnimationFrame(N));
|
|
139
122
|
return;
|
|
140
123
|
}
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
124
|
+
const B = x.startTime || 0;
|
|
125
|
+
if (l >= B) {
|
|
143
126
|
u({
|
|
144
127
|
type: "tickStart",
|
|
145
128
|
payload: {
|
|
146
|
-
currentTime:
|
|
147
|
-
currentFrame:
|
|
129
|
+
currentTime: B,
|
|
130
|
+
currentFrame: T
|
|
148
131
|
}
|
|
149
132
|
});
|
|
150
133
|
try {
|
|
151
|
-
await
|
|
152
|
-
const
|
|
153
|
-
currentTime:
|
|
154
|
-
currentFrame:
|
|
134
|
+
await C(T);
|
|
135
|
+
const d = {
|
|
136
|
+
currentTime: B,
|
|
137
|
+
currentFrame: T
|
|
155
138
|
};
|
|
156
|
-
|
|
157
|
-
} catch (
|
|
158
|
-
console.error("Frame rendering error:",
|
|
139
|
+
r.requireReset && (d.requireReset = !1), u({ type: "tickEnd", payload: d }), m("onTick");
|
|
140
|
+
} catch (d) {
|
|
141
|
+
console.error("Frame rendering error:", d);
|
|
159
142
|
}
|
|
160
143
|
} else
|
|
161
|
-
u({ type: "tick", payload: { currentTime:
|
|
162
|
-
}, [
|
|
163
|
-
return
|
|
164
|
-
let
|
|
165
|
-
const
|
|
166
|
-
for (;
|
|
167
|
-
await new Promise((
|
|
168
|
-
|
|
169
|
-
}),
|
|
144
|
+
u({ type: "tick", payload: { currentTime: l } });
|
|
145
|
+
}, [s, C, m, e.repeat, g]);
|
|
146
|
+
return A(() => {
|
|
147
|
+
let r = !0;
|
|
148
|
+
const t = async () => {
|
|
149
|
+
for (; r && w.current.isPlaying; )
|
|
150
|
+
await new Promise((l) => {
|
|
151
|
+
f.current = requestAnimationFrame(l);
|
|
152
|
+
}), r && w.current.isPlaying && await N();
|
|
170
153
|
};
|
|
171
|
-
return n.isPlaying ?
|
|
172
|
-
|
|
154
|
+
return n.isPlaying ? t() : (f.current && (cancelAnimationFrame(f.current), f.current = null), p.current = null), () => {
|
|
155
|
+
r = !1, f.current && (cancelAnimationFrame(f.current), f.current = null);
|
|
173
156
|
};
|
|
174
|
-
}, [n.isPlaying,
|
|
175
|
-
/* @__PURE__ */ a("div", { className: "cover", onClick:
|
|
176
|
-
/* @__PURE__ */ a("div", { className: "start", onClick:
|
|
157
|
+
}, [n.isPlaying, N]), e.controls && (e.frameBox.title = null, e.frameBox.type = null, e.frameBox.style = {}, e.theme?.background === "transparent" ? e.frameBox.style.background = "black" : e.theme?.background && (e.frameBox.style.background = e.theme.background), e.frameBox.style.padding = "10px", e.frameBox.style.paddingBottom = "40px"), /* @__PURE__ */ k(H, { className: X(e, n), ref: z, children: [
|
|
158
|
+
/* @__PURE__ */ a("div", { className: "cover", onClick: P }),
|
|
159
|
+
/* @__PURE__ */ a("div", { className: "start", onClick: P, children: /* @__PURE__ */ k("svg", { style: { enableBackground: "new 0 0 30 30" }, viewBox: "0 0 30 30", children: [
|
|
177
160
|
/* @__PURE__ */ a("polygon", { points: "6.583,3.186 5,4.004 5,15 26,15 26.483,14.128 " }),
|
|
178
161
|
/* @__PURE__ */ a("polygon", { points: "6.583,26.814 5,25.996 5,15 26,15 26.483,15.872 " }),
|
|
179
162
|
/* @__PURE__ */ a("circle", { cx: "26", cy: "15", r: "1" }),
|
|
180
163
|
/* @__PURE__ */ a("circle", { cx: "6", cy: "4", r: "1" }),
|
|
181
164
|
/* @__PURE__ */ a("circle", { cx: "6", cy: "26", r: "1" })
|
|
182
165
|
] }) }),
|
|
183
|
-
/* @__PURE__ */ a("div", { className: "terminal", children: /* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
/* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ a("div", { className: "terminal", children: /* @__PURE__ */ k("div", { className: $(e), style: e.frameBox.style || {}, children: [
|
|
167
|
+
/* @__PURE__ */ k("div", { className: "terminal-titlebar", children: [
|
|
168
|
+
/* @__PURE__ */ k("div", { className: "buttons", children: [
|
|
186
169
|
/* @__PURE__ */ a("div", { className: "close-button" }),
|
|
187
170
|
/* @__PURE__ */ a("div", { className: "minimize-button" }),
|
|
188
171
|
/* @__PURE__ */ a("div", { className: "maximize-button" })
|
|
189
172
|
] }),
|
|
190
173
|
/* @__PURE__ */ a("div", { className: "title", children: e.frameBox.title || "" })
|
|
191
174
|
] }),
|
|
192
|
-
/* @__PURE__ */ a("div", { className: "terminal-body", children: /* @__PURE__ */ a(
|
|
175
|
+
/* @__PURE__ */ a("div", { className: "terminal-body", children: /* @__PURE__ */ a(I, { ref: o, options: D }) })
|
|
193
176
|
] }) }),
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
n.isPlaying && /* @__PURE__ */ a("div", { className: "pause", onClick:
|
|
196
|
-
!n.isPlaying && n.isStarted && /* @__PURE__ */ a("div", { className: "play", onClick:
|
|
197
|
-
|
|
198
|
-
/* @__PURE__ */ a("div", { className: "
|
|
199
|
-
/* @__PURE__ */ a("div", { className: "progressbar-wrapper", children: /* @__PURE__ */ a("div", { className: "progressbar", ref: R, onClick: I, children: /* @__PURE__ */ a("div", { className: "progress", style: { width: `${n.currentTime / w * 100}%` } }) }) })
|
|
177
|
+
/* @__PURE__ */ k("div", { className: "controller", children: [
|
|
178
|
+
n.isPlaying && /* @__PURE__ */ a("div", { className: "pause", onClick: M, title: "Pause", children: /* @__PURE__ */ a("span", { className: "icon" }) }),
|
|
179
|
+
!n.isPlaying && !n.isStarted && /* @__PURE__ */ a("div", { className: "play", onClick: P, title: "Start", children: /* @__PURE__ */ a("span", { className: "icon" }) }),
|
|
180
|
+
/* @__PURE__ */ a("div", { className: "timer", children: G(n.currentTime) }),
|
|
181
|
+
/* @__PURE__ */ a("div", { className: "progressbar-wrapper", children: /* @__PURE__ */ a("div", { className: "progressbar", ref: v, onClick: L, children: /* @__PURE__ */ a("div", { className: "progress", style: { width: `${n.currentTime / g * 100}%` } }) }) })
|
|
200
182
|
] })
|
|
201
183
|
] });
|
|
202
184
|
}
|
|
203
|
-
|
|
204
|
-
frames:
|
|
205
|
-
options:
|
|
206
|
-
autoplay:
|
|
207
|
-
repeat:
|
|
208
|
-
controls:
|
|
209
|
-
frameBox:
|
|
210
|
-
theme:
|
|
211
|
-
cols:
|
|
212
|
-
rows:
|
|
185
|
+
K.propTypes = {
|
|
186
|
+
frames: c.array.isRequired,
|
|
187
|
+
options: c.shape({
|
|
188
|
+
autoplay: c.bool,
|
|
189
|
+
repeat: c.bool,
|
|
190
|
+
controls: c.bool,
|
|
191
|
+
frameBox: c.object,
|
|
192
|
+
theme: c.object,
|
|
193
|
+
cols: c.number,
|
|
194
|
+
rows: c.number
|
|
213
195
|
}).isRequired,
|
|
214
|
-
onComplete:
|
|
215
|
-
onStart:
|
|
216
|
-
onStop:
|
|
217
|
-
onPause:
|
|
218
|
-
onTick:
|
|
219
|
-
onJump:
|
|
196
|
+
onComplete: c.func,
|
|
197
|
+
onStart: c.func,
|
|
198
|
+
onStop: c.func,
|
|
199
|
+
onPause: c.func,
|
|
200
|
+
onTick: c.func,
|
|
201
|
+
onJump: c.func
|
|
220
202
|
};
|
|
221
203
|
export {
|
|
222
|
-
|
|
223
|
-
|
|
204
|
+
ae as PLAYER_FRAME_DELAY,
|
|
205
|
+
K as default
|
|
224
206
|
};
|
package/lib/Terminal.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import h from "react";
|
|
3
3
|
import i from "prop-types";
|
|
4
|
-
import { Terminal as
|
|
5
|
-
import { WebLinksAddon as a } from "xterm
|
|
6
|
-
import { FitAddon as d } from "xterm
|
|
7
|
-
import
|
|
4
|
+
import { Terminal as m } from "@xterm/xterm";
|
|
5
|
+
import { WebLinksAddon as a } from "@xterm/addon-web-links";
|
|
6
|
+
import { FitAddon as d } from "@xterm/addon-fit";
|
|
7
|
+
import l from "lodash/debounce";
|
|
8
8
|
import s from "lodash/noop";
|
|
9
|
-
import { TerminalRoot as
|
|
10
|
-
class
|
|
9
|
+
import { TerminalRoot as p } from "./styles.js";
|
|
10
|
+
class u extends h.Component {
|
|
11
11
|
xterm = null;
|
|
12
12
|
container = null;
|
|
13
|
+
shouldTriggerFitWhenWrite = !1;
|
|
13
14
|
componentDidMount() {
|
|
14
15
|
const { value: t = "", options: e = {} } = this.props;
|
|
15
|
-
this.fitAddon = new d(), this.xterm = new
|
|
16
|
-
this.xterm && this.fitAddon.fit();
|
|
17
|
-
}, 0), this.debounceFit = p(() => {
|
|
16
|
+
this.fitAddon = new d(), this.xterm = new m(e), this.xterm.loadAddon(new a()), 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), this.debounceFit = l(() => {
|
|
18
17
|
this.fitAddon.fit();
|
|
19
|
-
},
|
|
18
|
+
}, 500), window.addEventListener("resize", this.debounceFit);
|
|
20
19
|
}
|
|
21
20
|
componentWillUnmount() {
|
|
22
21
|
this.xterm && (this.xterm.dispose(), this.xterm = null), window.removeEventListener("resize", this.debounceFit);
|
|
@@ -31,7 +30,7 @@ class x extends m.Component {
|
|
|
31
30
|
return this.xterm;
|
|
32
31
|
}
|
|
33
32
|
write(t, e) {
|
|
34
|
-
this.xterm && this.xterm.write(t, e);
|
|
33
|
+
this.xterm && (this.xterm.write(t, e), this.shouldTriggerFitWhenWrite && (this.debounceFit(), this.shouldTriggerFitWhenWrite = !1));
|
|
35
34
|
}
|
|
36
35
|
focus() {
|
|
37
36
|
this.xterm && this.xterm.focus();
|
|
@@ -47,14 +46,20 @@ class x extends m.Component {
|
|
|
47
46
|
const { onRender: e = s } = this.props;
|
|
48
47
|
e(t);
|
|
49
48
|
};
|
|
50
|
-
resize(
|
|
51
|
-
|
|
49
|
+
resize() {
|
|
50
|
+
if (this.xterm) {
|
|
51
|
+
const { cols: t, rows: e } = this.props.options;
|
|
52
|
+
this.shouldTriggerFitWhenWrite = !0, setTimeout(() => {
|
|
53
|
+
this.xterm.resize(Math.round(t), Math.round(e)), this.shouldTriggerFitWhenWrite = !0;
|
|
54
|
+
}, 250);
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
setOption(t, e) {
|
|
54
|
-
this.xterm && this.xterm.
|
|
58
|
+
this.xterm && (this.xterm.options[t] = e);
|
|
55
59
|
}
|
|
56
60
|
getOption(t) {
|
|
57
|
-
|
|
61
|
+
if (this.xterm)
|
|
62
|
+
return this.xterm.options[t];
|
|
58
63
|
}
|
|
59
64
|
refresh() {
|
|
60
65
|
this.xterm && this.xterm.refresh(0, this.xterm.rows - 1);
|
|
@@ -62,7 +67,7 @@ class x extends m.Component {
|
|
|
62
67
|
render() {
|
|
63
68
|
const { className: t = "", style: e = {} } = this.props, r = ["react-xterm", t].filter(Boolean).join(" ");
|
|
64
69
|
return /* @__PURE__ */ n(
|
|
65
|
-
|
|
70
|
+
p,
|
|
66
71
|
{
|
|
67
72
|
ref: (o) => {
|
|
68
73
|
this.container = o;
|
|
@@ -73,7 +78,7 @@ class x extends m.Component {
|
|
|
73
78
|
);
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
|
-
|
|
81
|
+
u.propTypes = {
|
|
77
82
|
onData: i.func,
|
|
78
83
|
onRender: i.func,
|
|
79
84
|
options: i.object,
|
|
@@ -82,5 +87,5 @@ x.propTypes = {
|
|
|
82
87
|
style: i.object
|
|
83
88
|
};
|
|
84
89
|
export {
|
|
85
|
-
|
|
90
|
+
u as default
|
|
86
91
|
};
|