@next_term/react 0.1.0-next.0 → 0.1.0-next.10
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/LICENSE +21 -0
- package/README.md +193 -0
- package/dist/Terminal.d.ts +9 -0
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +22 -4
- package/dist/Terminal.js.map +1 -1
- package/dist/TerminalPane.d.ts +5 -2
- package/dist/TerminalPane.d.ts.map +1 -1
- package/dist/TerminalPane.js +104 -9
- package/dist/TerminalPane.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/pane-layout.d.ts +20 -0
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rahul Pandita
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# @next_term/react
|
|
2
|
+
|
|
3
|
+
React components for the react-term terminal emulator.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @next_term/react @next_term/core @next_term/web
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Terminal } from "@next_term/react";
|
|
15
|
+
import type { TerminalHandle } from "@next_term/react";
|
|
16
|
+
import { useEffect, useRef } from "react";
|
|
17
|
+
|
|
18
|
+
function App() {
|
|
19
|
+
const termRef = useRef<TerminalHandle>(null);
|
|
20
|
+
|
|
21
|
+
// Write PTY/WebSocket data to the terminal
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const ws = new WebSocket("ws://localhost:8080");
|
|
24
|
+
ws.binaryType = "arraybuffer";
|
|
25
|
+
ws.onmessage = (e) => termRef.current?.write(new Uint8Array(e.data));
|
|
26
|
+
return () => ws.close();
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Terminal
|
|
31
|
+
ref={termRef}
|
|
32
|
+
autoFit
|
|
33
|
+
fontSize={14}
|
|
34
|
+
fontFamily="monospace"
|
|
35
|
+
onData={(data) => {
|
|
36
|
+
// User typed something — send to your backend
|
|
37
|
+
ws.send(data);
|
|
38
|
+
}}
|
|
39
|
+
onResize={({ cols, rows }) => {
|
|
40
|
+
// Terminal was resized — notify PTY
|
|
41
|
+
ws.send(`\x1b[8;${rows};${cols}t`);
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Multi-Pane Layout
|
|
49
|
+
|
|
50
|
+
`<TerminalPane>` manages multiple terminals in a split layout with a single shared WebGL context (avoids Chrome's 16-context limit).
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { TerminalPane } from "@next_term/react";
|
|
54
|
+
import type { TerminalPaneHandle, PaneLayout } from "@next_term/react";
|
|
55
|
+
|
|
56
|
+
const layout: PaneLayout = {
|
|
57
|
+
type: "horizontal",
|
|
58
|
+
children: [
|
|
59
|
+
{ type: "single", id: "editor" },
|
|
60
|
+
{
|
|
61
|
+
type: "vertical",
|
|
62
|
+
children: [
|
|
63
|
+
{ type: "single", id: "terminal" },
|
|
64
|
+
{ type: "single", id: "logs" },
|
|
65
|
+
],
|
|
66
|
+
sizes: [0.6, 0.4],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
sizes: [0.5, 0.5],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function IDE() {
|
|
73
|
+
const paneRef = useRef<TerminalPaneHandle>(null);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<TerminalPane
|
|
77
|
+
ref={paneRef}
|
|
78
|
+
layout={layout}
|
|
79
|
+
fontSize={13}
|
|
80
|
+
fontFamily="monospace"
|
|
81
|
+
onData={(paneId, data) => {
|
|
82
|
+
connections.get(paneId)?.send(data);
|
|
83
|
+
}}
|
|
84
|
+
style={{ width: "100%", height: "100vh" }}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Write to a specific pane
|
|
90
|
+
paneRef.current?.getTerminal("logs")?.write("Build complete.\r\n");
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Props
|
|
94
|
+
|
|
95
|
+
### `<Terminal>`
|
|
96
|
+
|
|
97
|
+
| Prop | Type | Default | Description |
|
|
98
|
+
|------|------|---------|-------------|
|
|
99
|
+
| `cols` | `number` | `80` | Initial column count |
|
|
100
|
+
| `rows` | `number` | `24` | Initial row count |
|
|
101
|
+
| `fontSize` | `number` | `16` | Font size in pixels |
|
|
102
|
+
| `fontFamily` | `string` | `"'Courier New', monospace"` | CSS font-family |
|
|
103
|
+
| `fontWeight` | `number` | `400` | Normal text weight |
|
|
104
|
+
| `fontWeightBold` | `number` | `700` | Bold text weight |
|
|
105
|
+
| `theme` | `Partial<Theme>` | Dark theme | Terminal colors |
|
|
106
|
+
| `scrollback` | `number` | `1000` | Scrollback buffer lines |
|
|
107
|
+
| `autoFit` | `boolean` | `false` | Auto-resize to container |
|
|
108
|
+
| `renderer` | `"auto" \| "webgl" \| "canvas2d"` | `"auto"` | Rendering backend |
|
|
109
|
+
| `renderMode` | `"auto" \| "offscreen" \| "main"` | `"auto"` | Where rendering runs |
|
|
110
|
+
| `useWorker` | `boolean` | auto | VT parser in Web Worker |
|
|
111
|
+
| `sharedContext` | `SharedWebGLContext` | -- | Shared WebGL context for multi-pane |
|
|
112
|
+
| `paneId` | `string` | -- | Pane ID (required with sharedContext) |
|
|
113
|
+
| `onData` | `(data: Uint8Array) => void` | -- | User input callback |
|
|
114
|
+
| `onResize` | `(size) => void` | -- | Resize callback |
|
|
115
|
+
| `onTitleChange` | `(title: string) => void` | -- | OSC title change |
|
|
116
|
+
| `className` | `string` | -- | CSS class on container |
|
|
117
|
+
| `style` | `React.CSSProperties` | -- | Inline styles on container |
|
|
118
|
+
|
|
119
|
+
### `<TerminalPane>`
|
|
120
|
+
|
|
121
|
+
| Prop | Type | Description |
|
|
122
|
+
|------|------|-------------|
|
|
123
|
+
| `layout` | `PaneLayout` | Split layout tree |
|
|
124
|
+
| `onData` | `(paneId, data) => void` | Input from any pane |
|
|
125
|
+
| `fontSize` | `number` | Shared font size |
|
|
126
|
+
| `fontFamily` | `string` | Shared font family |
|
|
127
|
+
| `fontWeight` | `number` | Shared normal text weight |
|
|
128
|
+
| `fontWeightBold` | `number` | Shared bold text weight |
|
|
129
|
+
| `theme` | `Partial<Theme>` | Shared theme |
|
|
130
|
+
| `className` | `string` | CSS class on root container |
|
|
131
|
+
| `style` | `React.CSSProperties` | Inline styles on root container |
|
|
132
|
+
|
|
133
|
+
### `TerminalPaneHandle`
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
interface TerminalPaneHandle {
|
|
137
|
+
getTerminal(paneId: string): TerminalHandle | null;
|
|
138
|
+
getPaneIds(): string[];
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### `TerminalHandle`
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
interface TerminalHandle {
|
|
146
|
+
write(data: string | Uint8Array): void;
|
|
147
|
+
resize(cols: number, rows: number): void;
|
|
148
|
+
focus(): void;
|
|
149
|
+
blur(): void;
|
|
150
|
+
fit(): void;
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Best Practices
|
|
155
|
+
|
|
156
|
+
### Font Configuration
|
|
157
|
+
|
|
158
|
+
Use generic families or system-installed fonts. Web fonts loaded via `@font-face` are loaded automatically via the CSS Font Loading API, but may cause a brief flash of fallback text (FOUT) on first render:
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
// Good: generic family, always available
|
|
162
|
+
<Terminal fontFamily="monospace" />
|
|
163
|
+
|
|
164
|
+
// Good: system font with generic fallback
|
|
165
|
+
<Terminal fontFamily="'Menlo', 'Consolas', monospace" />
|
|
166
|
+
|
|
167
|
+
// Works: web font — loaded async, brief FOUT on first render
|
|
168
|
+
<Terminal fontFamily="'Fira Code', monospace" />
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### COOP/COEP Headers for Worker Support
|
|
172
|
+
|
|
173
|
+
SharedArrayBuffer (required for Web Worker parsing) needs cross-origin isolation. Without these headers, the terminal falls back to main-thread parsing automatically:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
Cross-Origin-Opener-Policy: same-origin
|
|
177
|
+
Cross-Origin-Embedder-Policy: require-corp
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Theme
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
import { DEFAULT_THEME } from "@next_term/core";
|
|
184
|
+
|
|
185
|
+
// Override specific colors
|
|
186
|
+
<Terminal theme={{ background: "#1a1b26", foreground: "#c0caf5" }} />
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
All CSS color formats are supported: `#rgb`, `#rrggbb`, `rgb()`, `hsl()`, `oklch()`, named colors.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT
|
package/dist/Terminal.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Theme } from "@next_term/core";
|
|
2
|
+
import type { SharedWebGLContext } from "@next_term/web";
|
|
2
3
|
import type React from "react";
|
|
3
4
|
export interface TerminalProps {
|
|
4
5
|
cols?: number;
|
|
5
6
|
rows?: number;
|
|
6
7
|
fontSize?: number;
|
|
7
8
|
fontFamily?: string;
|
|
9
|
+
/** CSS font-weight for normal text (default: 400). */
|
|
10
|
+
fontWeight?: number;
|
|
11
|
+
/** CSS font-weight for bold text (default: 700). */
|
|
12
|
+
fontWeightBold?: number;
|
|
8
13
|
theme?: Partial<Theme>;
|
|
9
14
|
scrollback?: number;
|
|
10
15
|
onData?: (data: Uint8Array) => void;
|
|
@@ -22,6 +27,10 @@ export interface TerminalProps {
|
|
|
22
27
|
renderer?: "auto" | "webgl" | "canvas2d";
|
|
23
28
|
/** Whether to use a Web Worker for VT parsing. */
|
|
24
29
|
useWorker?: boolean;
|
|
30
|
+
/** Shared WebGL context for multi-pane rendering. */
|
|
31
|
+
sharedContext?: SharedWebGLContext;
|
|
32
|
+
/** Pane ID within the shared context. Required when sharedContext is provided. */
|
|
33
|
+
paneId?: string;
|
|
25
34
|
}
|
|
26
35
|
export interface TerminalHandle {
|
|
27
36
|
write(data: string | Uint8Array): void;
|
package/dist/Terminal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../src/Terminal.tsx"],"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,CAAC,EAAE,OAAO,CAAC;IACpB,qDAAqD;IACrD,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;IACb,GAAG,IAAI,IAAI,CAAC;CACb;AAED,eAAO,MAAM,QAAQ,sFAqMnB,CAAC"}
|
package/dist/Terminal.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { calculateFit, WebTerminal } from "@next_term/web";
|
|
3
3
|
import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
4
4
|
export const Terminal = forwardRef(function Terminal(props, ref) {
|
|
5
|
-
const { cols = 80, rows = 24, fontSize = 16, fontFamily = "'Courier New', monospace", theme, scrollback = 1000, onData, onResize, onTitleChange, autoFit = false, className, style, renderMode, renderer: rendererProp, useWorker, } = props;
|
|
5
|
+
const { cols = 80, rows = 24, fontSize = 16, fontFamily = "'Courier New', monospace", fontWeight, fontWeightBold, theme, scrollback = 1000, onData, onResize, onTitleChange, autoFit = false, className, style, renderMode, renderer: rendererProp, useWorker, sharedContext, paneId, } = props;
|
|
6
6
|
const containerRef = useRef(null);
|
|
7
7
|
const termRef = useRef(null);
|
|
8
8
|
const initialized = useRef(false);
|
|
@@ -58,11 +58,15 @@ export const Terminal = forwardRef(function Terminal(props, ref) {
|
|
|
58
58
|
rows,
|
|
59
59
|
fontSize,
|
|
60
60
|
fontFamily,
|
|
61
|
+
fontWeight,
|
|
62
|
+
fontWeightBold,
|
|
61
63
|
theme,
|
|
62
64
|
scrollback,
|
|
63
65
|
renderMode,
|
|
64
66
|
renderer: rendererProp,
|
|
65
67
|
useWorker,
|
|
68
|
+
sharedContext,
|
|
69
|
+
paneId,
|
|
66
70
|
onData: (data) => onDataRef.current?.(data),
|
|
67
71
|
onResize: (size) => onResizeRef.current?.(size),
|
|
68
72
|
onTitleChange: (title) => onTitleChangeRef.current?.(title),
|
|
@@ -73,7 +77,21 @@ export const Terminal = forwardRef(function Terminal(props, ref) {
|
|
|
73
77
|
termRef.current = null;
|
|
74
78
|
initialized.current = false;
|
|
75
79
|
};
|
|
76
|
-
}, [
|
|
80
|
+
}, [
|
|
81
|
+
cols,
|
|
82
|
+
fontFamily,
|
|
83
|
+
fontSize,
|
|
84
|
+
fontWeight,
|
|
85
|
+
fontWeightBold,
|
|
86
|
+
paneId,
|
|
87
|
+
renderMode,
|
|
88
|
+
rendererProp,
|
|
89
|
+
rows,
|
|
90
|
+
scrollback,
|
|
91
|
+
sharedContext,
|
|
92
|
+
theme,
|
|
93
|
+
useWorker,
|
|
94
|
+
]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
77
95
|
// Update theme when it changes
|
|
78
96
|
useEffect(() => {
|
|
79
97
|
if (termRef.current && theme) {
|
|
@@ -83,9 +101,9 @@ export const Terminal = forwardRef(function Terminal(props, ref) {
|
|
|
83
101
|
// Update font when it changes
|
|
84
102
|
useEffect(() => {
|
|
85
103
|
if (termRef.current) {
|
|
86
|
-
termRef.current.setFont(fontSize, fontFamily);
|
|
104
|
+
termRef.current.setFont(fontSize, fontFamily, fontWeight, fontWeightBold);
|
|
87
105
|
}
|
|
88
|
-
}, [fontSize, fontFamily]);
|
|
106
|
+
}, [fontSize, fontFamily, fontWeight, fontWeightBold]);
|
|
89
107
|
// AutoFit: observe container size via ResizeObserver, debounced with rAF.
|
|
90
108
|
// Also listen to visualViewport resize for iOS keyboard show/hide.
|
|
91
109
|
useEffect(() => {
|
package/dist/Terminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../src/Terminal.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../src/Terminal.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAuC3E,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAgC,SAAS,QAAQ,CAAC,KAAK,EAAE,GAAG;IAC5F,MAAM,EACJ,IAAI,GAAG,EAAE,EACT,IAAI,GAAG,EAAE,EACT,QAAQ,GAAG,EAAE,EACb,UAAU,GAAG,0BAA0B,EACvC,UAAU,EACV,cAAc,EACd,KAAK,EACL,UAAU,GAAG,IAAI,EACjB,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,GAAG,KAAK,EACf,SAAS,EACT,KAAK,EACL,UAAU,EACV,QAAQ,EAAE,YAAY,EACtB,SAAS,EACT,aAAa,EACb,MAAM,GACP,GAAG,KAAK,CAAC;IAEV,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAElC,8DAA8D;IAC9D,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,gBAAgB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAE/C,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7B,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,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AE,CAAC;gBAC5B,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;YACjC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,cAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;AACxE,CAAC,CAAC,CAAC"}
|
package/dist/TerminalPane.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* TerminalPane — a container component that manages multiple terminal
|
|
3
3
|
* instances in a split-pane layout.
|
|
4
4
|
*
|
|
5
|
-
* All panes share rendering resources
|
|
6
|
-
*
|
|
5
|
+
* All panes share rendering resources via a single SharedWebGLContext,
|
|
6
|
+
* which avoids hitting Chrome's 16-context limit. If WebGL2 initialization
|
|
7
|
+
* fails, panes fall back to independent per-pane rendering.
|
|
7
8
|
*
|
|
8
9
|
* Layout is described as a recursive tree of horizontal / vertical splits.
|
|
9
10
|
*/
|
|
@@ -18,6 +19,8 @@ export interface TerminalPaneProps {
|
|
|
18
19
|
theme?: Partial<Theme>;
|
|
19
20
|
fontSize?: number;
|
|
20
21
|
fontFamily?: string;
|
|
22
|
+
fontWeight?: number;
|
|
23
|
+
fontWeightBold?: number;
|
|
21
24
|
className?: string;
|
|
22
25
|
style?: React.CSSProperties;
|
|
23
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminalPane.d.ts","sourceRoot":"","sources":["../src/TerminalPane.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"TerminalPane.d.ts","sourceRoot":"","sources":["../src/TerminalPane.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMnD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACpD,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;IACnD,wBAAwB;IACxB,UAAU,IAAI,MAAM,EAAE,CAAC;CACxB;AAgMD,eAAO,MAAM,YAAY,8FA6IxB,CAAC"}
|
package/dist/TerminalPane.js
CHANGED
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { SharedWebGLContext } from "@next_term/web";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
4
|
import { collectPaneIds } from "./pane-layout.js";
|
|
4
5
|
import { Terminal } from "./Terminal.js";
|
|
5
|
-
function PaneLeaf({ id, onData, theme, fontSize, fontFamily, onRef }) {
|
|
6
|
+
function PaneLeaf({ id, onData, theme, fontSize, fontFamily, fontWeight, fontWeightBold, onRef, sharedContext, }) {
|
|
6
7
|
const termRef = useRef(null);
|
|
8
|
+
const containerRef = useRef(null);
|
|
7
9
|
useEffect(() => {
|
|
8
10
|
onRef(id, termRef.current);
|
|
9
11
|
return () => {
|
|
10
12
|
onRef(id, null);
|
|
11
13
|
};
|
|
12
14
|
}, [id, onRef]);
|
|
15
|
+
// Sync viewport position with shared context via ResizeObserver
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!sharedContext || !containerRef.current)
|
|
18
|
+
return;
|
|
19
|
+
const syncViewport = () => {
|
|
20
|
+
const el = containerRef.current;
|
|
21
|
+
const parent = sharedContext.getCanvas().parentElement;
|
|
22
|
+
if (!el || !parent)
|
|
23
|
+
return;
|
|
24
|
+
const parentRect = parent.getBoundingClientRect();
|
|
25
|
+
const elRect = el.getBoundingClientRect();
|
|
26
|
+
sharedContext.setViewport(id, elRect.left - parentRect.left, elRect.top - parentRect.top, elRect.width, elRect.height);
|
|
27
|
+
};
|
|
28
|
+
// Measure once on mount so panes that are already laid out get a viewport
|
|
29
|
+
syncViewport();
|
|
30
|
+
const observer = new ResizeObserver(syncViewport);
|
|
31
|
+
observer.observe(containerRef.current);
|
|
32
|
+
return () => observer.disconnect();
|
|
33
|
+
}, [id, sharedContext]);
|
|
13
34
|
const handleData = useCallback((data) => {
|
|
14
35
|
onData?.(id, data);
|
|
15
36
|
}, [id, onData]);
|
|
16
|
-
return (_jsx(Terminal, { ref: termRef, autoFit: true, theme: theme, fontSize: fontSize, fontFamily: fontFamily, onData: handleData, style: { width: "100%", height: "100%" } }));
|
|
37
|
+
return (_jsx("div", { ref: containerRef, style: { width: "100%", height: "100%" }, children: _jsx(Terminal, { ref: termRef, autoFit: true, theme: theme, fontSize: fontSize, fontFamily: fontFamily, fontWeight: fontWeight, fontWeightBold: fontWeightBold, onData: handleData, sharedContext: sharedContext ?? undefined, paneId: sharedContext ? id : undefined, style: { width: "100%", height: "100%" } }) }));
|
|
17
38
|
}
|
|
18
|
-
function PaneNode({ layout, onData, theme, fontSize, fontFamily, onRef }) {
|
|
39
|
+
function PaneNode({ layout, onData, theme, fontSize, fontFamily, fontWeight, fontWeightBold, onRef, sharedContext, }) {
|
|
19
40
|
if (layout.type === "single") {
|
|
20
|
-
return (_jsx(PaneLeaf, { id: layout.id, onData: onData, theme: theme, fontSize: fontSize, fontFamily: fontFamily, onRef: onRef }));
|
|
41
|
+
return (_jsx(PaneLeaf, { id: layout.id, onData: onData, theme: theme, fontSize: fontSize, fontFamily: fontFamily, fontWeight: fontWeight, fontWeightBold: fontWeightBold, onRef: onRef, sharedContext: sharedContext }));
|
|
21
42
|
}
|
|
22
43
|
const isHorizontal = layout.type === "horizontal";
|
|
23
44
|
const children = layout.children;
|
|
@@ -41,15 +62,18 @@ function PaneNode({ layout, onData, theme, fontSize, fontFamily, onRef }) {
|
|
|
41
62
|
? { borderLeft: "1px solid #444" }
|
|
42
63
|
: { borderTop: "1px solid #444" }
|
|
43
64
|
: {}),
|
|
44
|
-
}, children: _jsx(PaneNode, { layout: child, onData: onData, theme: theme, fontSize: fontSize, fontFamily: fontFamily, onRef: onRef }) }, child.type === "single" ? child.id : `split-${i}`));
|
|
65
|
+
}, children: _jsx(PaneNode, { layout: child, onData: onData, theme: theme, fontSize: fontSize, fontFamily: fontFamily, fontWeight: fontWeight, fontWeightBold: fontWeightBold, onRef: onRef, sharedContext: sharedContext }) }, child.type === "single" ? child.id : `split-${i}`));
|
|
45
66
|
}) }));
|
|
46
67
|
}
|
|
47
68
|
// ---------------------------------------------------------------------------
|
|
48
69
|
// TerminalPane
|
|
49
70
|
// ---------------------------------------------------------------------------
|
|
50
71
|
export const TerminalPane = forwardRef(function TerminalPane(props, ref) {
|
|
51
|
-
const { layout, onData, theme, fontSize, fontFamily, className, style } = props;
|
|
72
|
+
const { layout, onData, theme, fontSize, fontFamily, fontWeight, fontWeightBold, className, style, } = props;
|
|
73
|
+
const containerRef = useRef(null);
|
|
52
74
|
const terminalsRef = useRef(new Map());
|
|
75
|
+
const sharedContextRef = useRef(null);
|
|
76
|
+
const [sharedContext, setSharedContext] = useState(null);
|
|
53
77
|
const handleRef = useCallback((id, handle) => {
|
|
54
78
|
if (handle) {
|
|
55
79
|
terminalsRef.current.set(id, handle);
|
|
@@ -58,6 +82,77 @@ export const TerminalPane = forwardRef(function TerminalPane(props, ref) {
|
|
|
58
82
|
terminalsRef.current.delete(id);
|
|
59
83
|
}
|
|
60
84
|
}, []);
|
|
85
|
+
// Create and manage the shared WebGL context
|
|
86
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: theme handled via separate setTheme effect
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const container = containerRef.current;
|
|
89
|
+
if (!container)
|
|
90
|
+
return;
|
|
91
|
+
let ctx = null;
|
|
92
|
+
try {
|
|
93
|
+
ctx = new SharedWebGLContext({
|
|
94
|
+
fontSize,
|
|
95
|
+
fontFamily,
|
|
96
|
+
theme,
|
|
97
|
+
});
|
|
98
|
+
const canvas = ctx.getCanvas();
|
|
99
|
+
canvas.style.position = "absolute";
|
|
100
|
+
canvas.style.top = "0";
|
|
101
|
+
canvas.style.left = "0";
|
|
102
|
+
canvas.style.width = "100%";
|
|
103
|
+
canvas.style.height = "100%";
|
|
104
|
+
canvas.style.pointerEvents = "none";
|
|
105
|
+
canvas.style.zIndex = "1";
|
|
106
|
+
container.appendChild(canvas);
|
|
107
|
+
ctx.init();
|
|
108
|
+
// Sync canvas size with container (debounced via rAF to avoid
|
|
109
|
+
// clearing the canvas on every pixel of a drag-resize)
|
|
110
|
+
const activeCtx = ctx;
|
|
111
|
+
let resizeRafId = 0;
|
|
112
|
+
const ro = new ResizeObserver((entries) => {
|
|
113
|
+
cancelAnimationFrame(resizeRafId);
|
|
114
|
+
resizeRafId = requestAnimationFrame(() => {
|
|
115
|
+
for (const entry of entries) {
|
|
116
|
+
const { width, height } = entry.contentRect;
|
|
117
|
+
activeCtx.syncCanvasSize(width, height);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
ro.observe(container);
|
|
122
|
+
ctx.startRenderLoop();
|
|
123
|
+
sharedContextRef.current = ctx;
|
|
124
|
+
setSharedContext(ctx);
|
|
125
|
+
return () => {
|
|
126
|
+
cancelAnimationFrame(resizeRafId);
|
|
127
|
+
activeCtx.stopRenderLoop();
|
|
128
|
+
activeCtx.dispose();
|
|
129
|
+
ro.disconnect();
|
|
130
|
+
sharedContextRef.current = null;
|
|
131
|
+
setSharedContext(null);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// WebGL2 init failed — fall back to independent per-pane rendering
|
|
136
|
+
console.warn("[TerminalPane] SharedWebGLContext init failed, falling back to per-pane rendering");
|
|
137
|
+
if (ctx) {
|
|
138
|
+
try {
|
|
139
|
+
ctx.dispose();
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// ignore
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
sharedContextRef.current = null;
|
|
146
|
+
setSharedContext(null);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}, [fontSize, fontFamily]); // theme handled via separate setTheme effect below
|
|
150
|
+
// Update theme on existing context without recreating GL resources
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (sharedContextRef.current && theme) {
|
|
153
|
+
sharedContextRef.current.setTheme(theme);
|
|
154
|
+
}
|
|
155
|
+
}, [theme]);
|
|
61
156
|
useImperativeHandle(ref, () => ({
|
|
62
157
|
getTerminal(paneId) {
|
|
63
158
|
return terminalsRef.current.get(paneId) ?? null;
|
|
@@ -66,10 +161,10 @@ export const TerminalPane = forwardRef(function TerminalPane(props, ref) {
|
|
|
66
161
|
return collectPaneIds(layout);
|
|
67
162
|
},
|
|
68
163
|
}), [layout]);
|
|
69
|
-
return (_jsx("div", { className: className, style: {
|
|
164
|
+
return (_jsx("div", { ref: containerRef, className: className, style: {
|
|
70
165
|
position: "relative",
|
|
71
166
|
overflow: "hidden",
|
|
72
167
|
...style,
|
|
73
|
-
}, children: _jsx(PaneNode, { layout: layout, onData: onData, theme: theme, fontSize: fontSize, fontFamily: fontFamily, onRef: handleRef }) }));
|
|
168
|
+
}, children: _jsx(PaneNode, { layout: layout, onData: onData, theme: theme, fontSize: fontSize, fontFamily: fontFamily, fontWeight: fontWeight, fontWeightBold: fontWeightBold, onRef: handleRef, sharedContext: sharedContext }) }));
|
|
74
169
|
});
|
|
75
170
|
//# sourceMappingURL=TerminalPane.js.map
|
package/dist/TerminalPane.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminalPane.js","sourceRoot":"","sources":["../src/TerminalPane.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TerminalPane.js","sourceRoot":"","sources":["../src/TerminalPane.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAiDzC,SAAS,QAAQ,CAAC,EAChB,EAAE,EACF,MAAM,EACN,KAAK,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,cAAc,EACd,KAAK,EACL,aAAa,GACC;IACd,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC;IACJ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AAU,EACtB,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,SAAS,EAChB,aAAa,EAAE,aAAa,GAC5B,GACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { collectPaneIds } from "./pane-layout.js";
|
|
2
|
+
export type { TerminalHandle, TerminalProps } from "./Terminal.js";
|
|
3
|
+
export { Terminal } from "./Terminal.js";
|
|
4
|
+
export type { PaneLayout, TerminalPaneHandle, TerminalPaneProps } from "./TerminalPane.js";
|
|
5
|
+
export { TerminalPane } from "./TerminalPane.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaneLayout — recursive layout tree for TerminalPane.
|
|
3
|
+
* Kept in a separate module so pure layout logic can be unit-tested without
|
|
4
|
+
* pulling in React/JSX.
|
|
5
|
+
*/
|
|
6
|
+
export type PaneLayout = {
|
|
7
|
+
type: "single";
|
|
8
|
+
id: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "horizontal";
|
|
11
|
+
children: PaneLayout[];
|
|
12
|
+
sizes?: number[];
|
|
13
|
+
} | {
|
|
14
|
+
type: "vertical";
|
|
15
|
+
children: PaneLayout[];
|
|
16
|
+
sizes?: number[];
|
|
17
|
+
};
|
|
18
|
+
/** Collect all leaf pane ids from a layout tree (depth-first, left-to-right). */
|
|
19
|
+
export declare function collectPaneIds(layout: PaneLayout): string[];
|
|
20
|
+
//# sourceMappingURL=pane-layout.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next_term/react",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
"import": "./dist/index.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc"
|
|
21
|
-
},
|
|
22
19
|
"files": [
|
|
23
20
|
"dist",
|
|
24
21
|
"!dist/__tests__"
|
|
@@ -31,8 +28,8 @@
|
|
|
31
28
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
32
29
|
},
|
|
33
30
|
"dependencies": {
|
|
34
|
-
"@next_term/core": "
|
|
35
|
-
"@next_term/web": "
|
|
31
|
+
"@next_term/core": "0.0.1-next.10",
|
|
32
|
+
"@next_term/web": "0.1.0-next.10"
|
|
36
33
|
},
|
|
37
34
|
"devDependencies": {
|
|
38
35
|
"typescript": "^5.5.0",
|
|
@@ -40,5 +37,8 @@
|
|
|
40
37
|
"react-dom": "^19.0.0",
|
|
41
38
|
"@types/react": "^19.0.0",
|
|
42
39
|
"@types/react-dom": "^19.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc"
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|