@tangle-network/sandbox-ui 0.37.1 → 0.38.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/dist/terminal.d.ts +8 -1
- package/dist/terminal.js +13 -2
- package/package.json +1 -1
package/dist/terminal.d.ts
CHANGED
|
@@ -37,6 +37,13 @@ interface TerminalViewProps {
|
|
|
37
37
|
subtitle?: string;
|
|
38
38
|
/** @deprecated No longer used — the PTY provides its own prompt. */
|
|
39
39
|
prompt?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Monospace font size in CSS pixels. Default 13. Changing it updates
|
|
42
|
+
* the live terminal and refits so xterm recomputes cols/rows from the
|
|
43
|
+
* new measured cell size instead of re-creating the terminal (which
|
|
44
|
+
* would drop scrollback).
|
|
45
|
+
*/
|
|
46
|
+
fontSize?: number;
|
|
40
47
|
/** Whether the terminal tab is currently active and visible. */
|
|
41
48
|
isActive?: boolean;
|
|
42
49
|
/**
|
|
@@ -47,6 +54,6 @@ interface TerminalViewProps {
|
|
|
47
54
|
connectionId?: string;
|
|
48
55
|
}
|
|
49
56
|
declare const DEFAULT_TERMINAL_THEME: TerminalTheme;
|
|
50
|
-
declare function TerminalView({ apiUrl, token, theme, title, subtitle, isActive, connectionId, }: TerminalViewProps): react_jsx_runtime.JSX.Element;
|
|
57
|
+
declare function TerminalView({ apiUrl, token, theme, title, subtitle, isActive, connectionId, fontSize, }: TerminalViewProps): react_jsx_runtime.JSX.Element;
|
|
51
58
|
|
|
52
59
|
export { DEFAULT_TERMINAL_THEME, type TerminalTheme, TerminalView, type TerminalViewProps };
|
package/dist/terminal.js
CHANGED
|
@@ -40,12 +40,16 @@ function TerminalView({
|
|
|
40
40
|
title = "Terminal",
|
|
41
41
|
subtitle = "Connected to PTY session",
|
|
42
42
|
isActive = true,
|
|
43
|
-
connectionId
|
|
43
|
+
connectionId,
|
|
44
|
+
fontSize = 13
|
|
44
45
|
}) {
|
|
45
46
|
const resolvedTheme = useMemo(
|
|
46
47
|
() => ({ ...DEFAULT_TERMINAL_THEME, ...theme }),
|
|
47
48
|
[theme]
|
|
48
49
|
);
|
|
50
|
+
const resolvedFontSize = Number.isFinite(fontSize) && fontSize > 0 ? fontSize : 13;
|
|
51
|
+
const fontSizeRef = useRef(resolvedFontSize);
|
|
52
|
+
fontSizeRef.current = resolvedFontSize;
|
|
49
53
|
const containerRef = useRef(null);
|
|
50
54
|
const termRef = useRef(null);
|
|
51
55
|
const fitAddonRef = useRef(null);
|
|
@@ -74,7 +78,7 @@ function TerminalView({
|
|
|
74
78
|
const term = new Terminal({
|
|
75
79
|
theme: resolvedTheme,
|
|
76
80
|
fontFamily: '"JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, monospace',
|
|
77
|
-
fontSize:
|
|
81
|
+
fontSize: fontSizeRef.current,
|
|
78
82
|
lineHeight: 1.4,
|
|
79
83
|
cursorBlink: true,
|
|
80
84
|
cursorStyle: "bar",
|
|
@@ -152,6 +156,13 @@ function TerminalView({
|
|
|
152
156
|
termRef.current.options.theme = resolvedTheme;
|
|
153
157
|
}
|
|
154
158
|
}, [resolvedTheme]);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
const term = termRef.current;
|
|
161
|
+
if (!term || term.options.fontSize === resolvedFontSize) return;
|
|
162
|
+
term.options.fontSize = resolvedFontSize;
|
|
163
|
+
const rafId = requestAnimationFrame(() => fitAddonRef.current?.fit());
|
|
164
|
+
return () => cancelAnimationFrame(rafId);
|
|
165
|
+
}, [resolvedFontSize]);
|
|
155
166
|
useEffect(() => {
|
|
156
167
|
if (isConnected && termRef.current) {
|
|
157
168
|
resizeTerminal(termRef.current.cols, termRef.current.rows).catch(console.error);
|
package/package.json
CHANGED