@arcblock/terminal 3.1.17 → 3.1.18

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 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} autoPlay={true} loop={true} />;
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 F, jsx as a } from "react/jsx-runtime";
2
- import { useRef as P, useState as _, useReducer as U, useEffect as q, useCallback as g } from "react";
3
- import o from "prop-types";
4
- import { useSize as Y } from "ahooks";
5
- import x from "lodash/isUndefined";
6
- import b from "lodash/noop";
7
- import X from "./Terminal.js";
8
- import { PlayerRoot as $ } from "./styles.js";
9
- import { defaultOptions as G, formatFrames as K, defaultState as Q, findFrameAt as M, getPlayerClass as V, getFrameClass as Z, formatTime as ee } from "./util.js";
10
- const me = 24;
11
- function te({ ...j }) {
12
- const s = Object.assign({}, j);
13
- x(s.onComplete) && (s.onComplete = b), x(s.onStart) && (s.onStart = b), x(s.onStop) && (s.onStop = b), x(s.onPause) && (s.onPause = b), x(s.onTick) && (s.onTick = b), x(s.onJump) && (s.onJump = b);
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
- }, E = (t, r) => {
26
- switch (r.type) {
24
+ theme: e.enableTheme ? e.theme : {}
25
+ }, J = (r, t) => {
26
+ switch (t.type) {
27
27
  case "jump":
28
- return { ...t, ...r.payload };
28
+ return { ...r, ...t.payload };
29
29
  case "start":
30
- return { ...t, isStarted: !0, lastTickTime: Date.now() };
30
+ return { ...r, isStarted: !0, lastTickTime: Date.now() };
31
31
  case "play":
32
- return { ...t, isPlaying: !0, lastTickTime: Date.now(), ...r.payload };
32
+ return { ...r, isPlaying: !0, lastTickTime: Date.now(), ...t.payload };
33
33
  case "pause":
34
- return { ...t, isPlaying: !1, ...r.payload };
34
+ return { ...r, isPlaying: !1, ...t.payload };
35
35
  case "tickStart":
36
- return { ...t, isRendering: !0, lastTickTime: Date.now(), ...r.payload };
36
+ return { ...r, isRendering: !0, lastTickTime: Date.now(), ...t.payload };
37
37
  case "tickEnd":
38
- return { ...t, isRendering: !1, lastTickTime: Date.now(), ...r.payload };
38
+ return { ...r, isRendering: !1, lastTickTime: Date.now(), ...t.payload };
39
39
  case "reset":
40
- return { ...t, currentFrame: -1, currentTime: 0, ...r.payload };
40
+ return { ...r, currentFrame: -1, currentTime: 0, ...t.payload };
41
41
  default:
42
- return { ...t, lastTickTime: Date.now(), ...r.payload };
42
+ return { ...r, lastTickTime: Date.now(), ...t.payload };
43
43
  }
44
- }, l = P(null), R = P(null), S = P(null), p = P(null), d = P(null), [z, J] = _(0), L = Y(document.body), [n, u] = U(E, Q), O = L?.width || 0;
45
- q(() => {
46
- if (l.current)
47
- try {
48
- const t = 8.03305785123967, r = S.current.getBoundingClientRect();
49
- let i = r.x < 0 ? r.width + r.x : r.width;
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
- [c, n.requireReset]
68
- ), m = g(
69
- (t) => {
70
- typeof s[t] == "function" && s[t]({ state: n, frames: c, options: e });
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, c, e]
73
- ), C = g(
74
- async (t) => {
75
- if (!l.current) return;
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
- [c, k]
83
- ), I = g(
84
- (t) => {
85
- if (!R.current || !l.current || !n.isStarted)
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 r = R.current.getBoundingClientRect().width, i = t.nativeEvent.offsetX, f = Math.floor(w * i / r), y = M(c, f), T = n.isPlaying;
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: f,
92
- currentFrame: y,
93
- isPlaying: T
81
+ currentTime: h,
82
+ currentFrame: T,
83
+ isPlaying: x
94
84
  // Keep the same playing state
95
85
  }
96
- }), d.current = null, C(f), m("onJump"), !1;
86
+ }), p.current = null, R(h), m("onJump"), !1;
97
87
  },
98
- [n.isStarted, n.isPlaying, w, c, C, m]
99
- ), N = g(() => (n.isStarted === !1 && (u({ type: "start" }), l.current && l.current.reset()), d.current = null, u({ type: "play", payload: { currentFrame: -1, currentTime: 0 } }), m("onStart"), !1), [n.isStarted, m]), W = g(() => (u({ type: "pause" }), m("onPause"), !1), [m]), H = g(() => (n.currentFrame >= c.length - 1 ? (u({ type: "reset", payload: { currentFrame: -1, currentTime: 0 } }), l.current && l.current.reset(), d.current = null, u({ type: "play", payload: { currentFrame: -1, currentTime: 0 } })) : (d.current = null, u({ type: "play" })), m("onPlay"), !1), [n.currentFrame, c.length, m]);
100
- q(() => {
101
- if (l.current) {
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 v = P(n);
111
- v.current = n;
112
- const B = g(async () => {
113
- const t = v.current;
114
- if (!t.isPlaying || t.isRendering)
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 r = performance.now();
117
- if (!d.current) {
118
- const h = t.currentFrame >= 0 && c[t.currentFrame]?.startTime || 0;
119
- d.current = r - h;
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 i = r - d.current, { currentFrame: f } = t, y = f + 1;
122
- if (f >= c.length - 1) {
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
- d.current = r, u({ type: "reset", payload: { currentTime: 0, currentFrame: -1 } });
107
+ p.current = t, u({ type: "reset", payload: { currentTime: 0, currentFrame: -1 } });
125
108
  return;
126
109
  }
127
- const h = {
128
- currentTime: w,
129
- currentFrame: c.length - 1,
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: h }), d.current = null;
116
+ u({ type: "pause", payload: d }), p.current = null;
134
117
  return;
135
118
  }
136
- const T = c[y];
137
- if (!T) {
138
- n.isPlaying && (p.current = requestAnimationFrame(B));
119
+ const x = s[T];
120
+ if (!x) {
121
+ n.isPlaying && (f.current = requestAnimationFrame(N));
139
122
  return;
140
123
  }
141
- const A = T.startTime || 0;
142
- if (i >= A) {
124
+ const B = x.startTime || 0;
125
+ if (l >= B) {
143
126
  u({
144
127
  type: "tickStart",
145
128
  payload: {
146
- currentTime: A,
147
- currentFrame: y
129
+ currentTime: B,
130
+ currentFrame: T
148
131
  }
149
132
  });
150
133
  try {
151
- await k(y);
152
- const h = {
153
- currentTime: A,
154
- currentFrame: y
134
+ await C(T);
135
+ const d = {
136
+ currentTime: B,
137
+ currentFrame: T
155
138
  };
156
- t.requireReset && (h.requireReset = !1), u({ type: "tickEnd", payload: h }), m("onTick");
157
- } catch (h) {
158
- console.error("Frame rendering error:", h);
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: i } });
162
- }, [c, k, m, e.repeat, w]);
163
- return q(() => {
164
- let t = !0;
165
- const r = async () => {
166
- for (; t && v.current.isPlaying; )
167
- await new Promise((i) => {
168
- p.current = requestAnimationFrame(i);
169
- }), t && v.current.isPlaying && await B();
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 ? r() : (p.current && (cancelAnimationFrame(p.current), p.current = null), d.current = null), () => {
172
- t = !1, p.current && (cancelAnimationFrame(p.current), p.current = null);
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, B]), 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__ */ F($, { className: V(e, n), ref: S, children: [
175
- /* @__PURE__ */ a("div", { className: "cover", onClick: N }),
176
- /* @__PURE__ */ a("div", { className: "start", onClick: N, children: /* @__PURE__ */ F("svg", { style: { enableBackground: "new 0 0 30 30" }, viewBox: "0 0 30 30", children: [
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__ */ F("div", { className: Z(e), style: e.frameBox.style || {}, children: [
184
- /* @__PURE__ */ F("div", { className: "terminal-titlebar", children: [
185
- /* @__PURE__ */ F("div", { className: "buttons", children: [
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(X, { ref: l, options: D }) })
175
+ /* @__PURE__ */ a("div", { className: "terminal-body", children: /* @__PURE__ */ a(I, { ref: o, options: D }) })
193
176
  ] }) }),
194
- /* @__PURE__ */ F("div", { className: "controller", children: [
195
- n.isPlaying && /* @__PURE__ */ a("div", { className: "pause", onClick: W, title: "Pause", children: /* @__PURE__ */ a("span", { className: "icon" }) }),
196
- !n.isPlaying && n.isStarted && /* @__PURE__ */ a("div", { className: "play", onClick: H, title: "Play", children: /* @__PURE__ */ a("span", { className: "icon" }) }),
197
- !n.isPlaying && !n.isStarted && /* @__PURE__ */ a("div", { className: "play", onClick: N, title: "Start", children: /* @__PURE__ */ a("span", { className: "icon" }) }),
198
- /* @__PURE__ */ a("div", { className: "timer", children: ee(n.currentTime) }),
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
- te.propTypes = {
204
- frames: o.array.isRequired,
205
- options: o.shape({
206
- autoplay: o.bool,
207
- repeat: o.bool,
208
- controls: o.bool,
209
- frameBox: o.object,
210
- theme: o.object,
211
- cols: o.number,
212
- rows: o.number
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: o.func,
215
- onStart: o.func,
216
- onStop: o.func,
217
- onPause: o.func,
218
- onTick: o.func,
219
- onJump: o.func
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
- me as PLAYER_FRAME_DELAY,
223
- te as default
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 m from "react";
2
+ import h from "react";
3
3
  import i from "prop-types";
4
- import { Terminal as h } from "xterm";
5
- import { WebLinksAddon as a } from "xterm-addon-web-links";
6
- import { FitAddon as d } from "xterm-addon-fit";
7
- import p from "lodash/debounce";
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 f } from "./styles.js";
10
- class x extends m.Component {
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 h(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), setTimeout(() => {
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
- }, 600), window.addEventListener("resize", this.debounceFit);
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(t, e) {
51
- this.xterm && this.xterm.resize(Math.round(t), Math.round(e));
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.setOption(t, e);
58
+ this.xterm && (this.xterm.options[t] = e);
55
59
  }
56
60
  getOption(t) {
57
- this.xterm && this.xterm.setOption(t);
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
- f,
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
- x.propTypes = {
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
- x as default
90
+ u as default
86
91
  };