@industry-theme/xterm-terminal-panel 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Principal ADE Team
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,298 @@
1
+ # @principal-ade/industry-themed-terminal
2
+
3
+ Industry-themed terminal wrapper with integrated theming support for `xterm.js`.
4
+
5
+ ## Features
6
+
7
+ - Seamless integration with `@a24z/industry-theme`
8
+ - Automatic theme synchronization with xterm.js
9
+ - Built on pure UI component architecture (no backend dependencies)
10
+ - TypeScript support with full type definitions
11
+ - Custom CSS theming via CSS custom properties
12
+ - Customizable header, badges, and overlays
13
+ - Support for all xterm.js addons (FitAddon, SearchAddon, WebLinksAddon, etc.)
14
+ - Programmatic control via imperative ref API
15
+ - Scroll preservation and user intent tracking
16
+ - Optional WebGL rendering support
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @principal-ade/industry-themed-terminal @xterm/xterm @a24z/industry-theme
22
+ ```
23
+
24
+ or with bun:
25
+
26
+ ```bash
27
+ bun add @principal-ade/industry-themed-terminal @xterm/xterm @a24z/industry-theme
28
+ ```
29
+
30
+ ### Optional addons:
31
+
32
+ ```bash
33
+ npm install @xterm/addon-fit @xterm/addon-search @xterm/addon-web-links
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### Basic Usage with Theme Provider
39
+
40
+ ```tsx
41
+ import { ThemedTerminalWithProvider } from '@principal-ade/industry-themed-terminal';
42
+ import '@xterm/xterm/css/xterm.css';
43
+ import '@principal-ade/industry-themed-terminal/styles.css';
44
+
45
+ function App() {
46
+ const handleData = (data: string) => {
47
+ // Send data to your backend (WebSocket, HTTP, etc.)
48
+ console.log('User input:', data);
49
+ };
50
+
51
+ return (
52
+ <ThemedTerminalWithProvider
53
+ onData={handleData}
54
+ headerTitle="Terminal"
55
+ headerSubtitle="/home/user/project"
56
+ />
57
+ );
58
+ }
59
+ ```
60
+
61
+ ### Usage with Explicit Theme
62
+
63
+ ```tsx
64
+ import { ThemedTerminal } from '@principal-ade/industry-themed-terminal';
65
+ import { useTheme } from '@a24z/industry-theme';
66
+ import '@xterm/xterm/css/xterm.css';
67
+ import '@principal-ade/industry-themed-terminal/styles.css';
68
+
69
+ function Terminal() {
70
+ const { theme } = useTheme();
71
+
72
+ const handleData = (data: string) => {
73
+ // Send to backend
74
+ websocket.send(data);
75
+ };
76
+
77
+ return (
78
+ <ThemedTerminal
79
+ theme={theme}
80
+ onData={handleData}
81
+ headerTitle="Terminal"
82
+ />
83
+ );
84
+ }
85
+ ```
86
+
87
+ ### With Programmatic Control
88
+
89
+ ```tsx
90
+ import { ThemedTerminal, ThemedTerminalRef } from '@principal-ade/industry-themed-terminal';
91
+ import { useRef, useEffect } from 'react';
92
+
93
+ function Terminal() {
94
+ const terminalRef = useRef<ThemedTerminalRef>(null);
95
+
96
+ useEffect(() => {
97
+ // Connect to backend
98
+ const ws = new WebSocket('wss://terminal-server.example.com');
99
+
100
+ ws.onmessage = (event) => {
101
+ // Write data from backend to terminal
102
+ terminalRef.current?.write(event.data);
103
+ };
104
+
105
+ return () => ws.close();
106
+ }, []);
107
+
108
+ const handleData = (data: string) => {
109
+ ws.send(data);
110
+ };
111
+
112
+ const handleClear = () => {
113
+ terminalRef.current?.clear();
114
+ };
115
+
116
+ return (
117
+ <>
118
+ <button onClick={handleClear}>Clear Terminal</button>
119
+ <ThemedTerminal
120
+ ref={terminalRef}
121
+ onData={handleData}
122
+ headerTitle="Terminal"
123
+ />
124
+ </>
125
+ );
126
+ }
127
+ ```
128
+
129
+ ### With Custom Header and Actions
130
+
131
+ ```tsx
132
+ import { ThemedTerminal } from '@principal-ade/industry-themed-terminal';
133
+
134
+ function Terminal() {
135
+ return (
136
+ <ThemedTerminal
137
+ onData={handleData}
138
+ headerTitle="Terminal"
139
+ headerSubtitle="/home/user/project"
140
+ headerBadge={{ label: 'Running', color: '#50fa7b' }}
141
+ onClose={() => console.log('Hide terminal')}
142
+ onPopOut={() => console.log('Pop out terminal')}
143
+ onDestroy={() => console.log('Destroy terminal')}
144
+ />
145
+ );
146
+ }
147
+ ```
148
+
149
+ ### With Overlay State
150
+
151
+ ```tsx
152
+ import { ThemedTerminal } from '@principal-ade/industry-themed-terminal';
153
+ import { Monitor } from 'lucide-react';
154
+
155
+ function Terminal() {
156
+ const overlayState = {
157
+ message: 'Terminal is owned by another window',
158
+ subtitle: 'This terminal is currently active in a different window.',
159
+ opacity: 1.0, // Full opacity (default) - completely hides terminal content
160
+ actions: [
161
+ {
162
+ label: 'Claim Ownership',
163
+ primary: true,
164
+ onClick: () => console.log('Claim ownership'),
165
+ },
166
+ ],
167
+ };
168
+
169
+ return (
170
+ <ThemedTerminal
171
+ onData={handleData}
172
+ overlayState={overlayState}
173
+ />
174
+ );
175
+ }
176
+ ```
177
+
178
+ The `opacity` property controls the overlay background opacity (0-1):
179
+ - `1.0` (default): Full opacity - completely hides terminal content
180
+ - `0.85`: Semi-transparent - terminal content slightly visible
181
+ - `0.5`: Very transparent - terminal content clearly visible
182
+ - Omitted: Defaults to `1.0` for full opacity
183
+
184
+ ## API
185
+
186
+ ### ThemedTerminal Props
187
+
188
+ | Prop | Type | Default | Description |
189
+ |------|------|---------|-------------|
190
+ | `theme` | `Theme` | Required | Industry theme object |
191
+ | `onData` | `(data: string) => void` | - | Callback when user types |
192
+ | `onBinary` | `(data: string) => void` | - | Callback for binary data |
193
+ | `onResize` | `(cols: number, rows: number) => void` | - | Callback when terminal resizes |
194
+ | `onLinkClick` | `(url: string, isLocalhost: boolean) => void` | - | Callback when link is clicked |
195
+ | `headerTitle` | `string` | `'Terminal'` | Header title text |
196
+ | `headerSubtitle` | `string` | - | Header subtitle text |
197
+ | `headerBadge` | `{ label: string; color?: string }` | - | Header badge |
198
+ | `hideHeader` | `boolean` | `false` | Hide the header |
199
+ | `autoFocus` | `boolean` | `true` | Auto-focus on mount |
200
+ | `isVisible` | `boolean` | `true` | Visibility state |
201
+ | `scrollbarStyle` | `'overlay' \| 'hidden' \| 'thin' \| 'auto-hide'` | `'overlay'` | Scrollbar style |
202
+ | `onClose` | `() => void` | - | Hide button callback |
203
+ | `onDestroy` | `() => void` | - | Destroy button callback |
204
+ | `onPopOut` | `() => void` | - | Pop-out button callback |
205
+ | `overlayState` | `OverlayState` | - | Overlay message state |
206
+ | `className` | `string` | - | Additional CSS classes |
207
+
208
+ ### ThemedTerminalWithProvider Props
209
+
210
+ Same as `ThemedTerminal` but without the `theme` prop (uses theme from context).
211
+
212
+ ### ThemedTerminalRef Methods
213
+
214
+ ```typescript
215
+ interface ThemedTerminalRef {
216
+ write: (data: string | Uint8Array) => void;
217
+ writeln: (data: string) => void;
218
+ clear: () => void;
219
+ scrollToBottom: () => void;
220
+ focus: () => void;
221
+ getTerminal: () => Terminal | null;
222
+ findNext: (term: string, options?: ISearchOptions) => boolean;
223
+ findPrevious: (term: string, options?: ISearchOptions) => boolean;
224
+ clearSearch: () => void;
225
+ fit: () => void;
226
+ }
227
+ ```
228
+
229
+ ### useThemedTerminal Hook
230
+
231
+ ```typescript
232
+ const { theme, getTerminalOptions } = useThemedTerminal();
233
+ ```
234
+
235
+ Returns:
236
+ - `theme` - Processed theme object with terminal-specific values
237
+ - `getTerminalOptions()` - Function that returns xterm.js terminal options
238
+
239
+ ## Backend Integration
240
+
241
+ This package provides only the UI component. You need to provide your own backend for terminal functionality:
242
+
243
+ ### WebSocket Example
244
+
245
+ ```typescript
246
+ import { ThemedTerminal, ThemedTerminalRef } from '@principal-ade/industry-themed-terminal';
247
+ import { useRef, useEffect } from 'react';
248
+
249
+ function Terminal() {
250
+ const terminalRef = useRef<ThemedTerminalRef>(null);
251
+ const ws = useRef<WebSocket>();
252
+
253
+ useEffect(() => {
254
+ ws.current = new WebSocket('wss://your-terminal-backend.com');
255
+
256
+ ws.current.onmessage = (event) => {
257
+ terminalRef.current?.write(event.data);
258
+ };
259
+
260
+ ws.current.onclose = () => {
261
+ terminalRef.current?.write('\r\nConnection closed\r\n');
262
+ };
263
+
264
+ return () => ws.current?.close();
265
+ }, []);
266
+
267
+ const handleData = (data: string) => {
268
+ ws.current?.send(data);
269
+ };
270
+
271
+ const handleResize = (cols: number, rows: number) => {
272
+ ws.current?.send(JSON.stringify({ type: 'resize', cols, rows }));
273
+ };
274
+
275
+ return (
276
+ <ThemedTerminal
277
+ ref={terminalRef}
278
+ onData={handleData}
279
+ onResize={handleResize}
280
+ />
281
+ );
282
+ }
283
+ ```
284
+
285
+ ## CSS Custom Properties
286
+
287
+ The package uses CSS custom properties for theming:
288
+
289
+ - `--terminal-bg` - Background color
290
+ - `--terminal-fg` - Foreground (text) color
291
+ - `--terminal-border` - Border color
292
+ - `--terminal-header-bg` - Header background
293
+ - `--terminal-font-family` - Font family
294
+ - `--terminal-font-size` - Font size
295
+
296
+ ## License
297
+
298
+ MIT © Principal ADE Team
package/dist/index.css ADDED
@@ -0,0 +1,114 @@
1
+ /* src/styles/terminal-theme.css */
2
+ .terminal-container-fix {
3
+ box-sizing: border-box;
4
+ margin: 0;
5
+ padding: 0;
6
+ }
7
+
8
+ .terminal-container-fix .xterm {
9
+ font-variant-ligatures: none;
10
+ -webkit-font-smoothing: antialiased;
11
+ -moz-osx-font-smoothing: grayscale;
12
+ width: 100%;
13
+ height: 100%;
14
+ margin: 0;
15
+ padding: 5px 0 0 5px;
16
+ }
17
+
18
+ .xterm-helper-textarea {
19
+ position: absolute !important;
20
+ opacity: 0 !important;
21
+ z-index: -5 !important;
22
+ white-space: nowrap !important;
23
+ overflow: hidden !important;
24
+ resize: none !important;
25
+ width: 0 !important;
26
+ height: 0 !important;
27
+ top: 0 !important;
28
+ left: -9999em !important;
29
+ }
30
+
31
+ .xterm-viewport {
32
+ overflow-y: auto !important;
33
+ overflow-x: hidden !important;
34
+ }
35
+
36
+ .terminal-container-fix .xterm-viewport {
37
+ scrollbar-width: thin;
38
+ overflow-y: overlay !important;
39
+ overflow-y: auto !important;
40
+ }
41
+
42
+ .terminal-container-fix .xterm-viewport::-webkit-scrollbar {
43
+ background: none;
44
+ width: 10px;
45
+ }
46
+
47
+ .terminal-container-fix .xterm-viewport::-webkit-scrollbar-track {
48
+ background: #0000001a;
49
+ border-radius: 10px;
50
+ }
51
+
52
+ .terminal-container-fix .xterm-viewport::-webkit-scrollbar-thumb {
53
+ background: #fff3 padding-box content-box;
54
+ border: 2px solid #0000;
55
+ border-radius: 10px;
56
+ }
57
+
58
+ .terminal-container-fix .xterm-viewport::-webkit-scrollbar-thumb:hover {
59
+ background: #ffffff4d padding-box content-box;
60
+ }
61
+
62
+ .terminal-container-fix .xterm-viewport::-webkit-scrollbar-thumb:active {
63
+ background: #fff6 padding-box content-box;
64
+ }
65
+
66
+ .terminal-container-fix.hide-scrollbar .xterm-viewport {
67
+ scrollbar-width: none;
68
+ -ms-overflow-style: none;
69
+ }
70
+
71
+ .terminal-container-fix.hide-scrollbar .xterm-viewport::-webkit-scrollbar {
72
+ display: none;
73
+ }
74
+
75
+ .terminal-container-fix.thin-scrollbar .xterm-viewport::-webkit-scrollbar {
76
+ width: 4px;
77
+ }
78
+
79
+ .terminal-container-fix.thin-scrollbar .xterm-viewport::-webkit-scrollbar-track {
80
+ background: none;
81
+ }
82
+
83
+ .terminal-container-fix.thin-scrollbar .xterm-viewport::-webkit-scrollbar-thumb {
84
+ background: #ffffff26;
85
+ border-radius: 4px;
86
+ }
87
+
88
+ .terminal-container-fix.auto-hide-scrollbar .xterm-viewport::-webkit-scrollbar {
89
+ opacity: 0;
90
+ width: 10px;
91
+ transition: opacity .3s;
92
+ }
93
+
94
+ .terminal-container-fix.auto-hide-scrollbar:hover .xterm-viewport::-webkit-scrollbar {
95
+ opacity: 1;
96
+ }
97
+
98
+ .terminal-container-fix.auto-hide-scrollbar .xterm-viewport::-webkit-scrollbar-thumb {
99
+ background: #fff0;
100
+ transition: background .3s;
101
+ }
102
+
103
+ .terminal-container-fix.auto-hide-scrollbar:hover .xterm-viewport::-webkit-scrollbar-thumb {
104
+ background: #fff3;
105
+ }
106
+
107
+ :root {
108
+ --terminal-bg: #1e1e1e;
109
+ --terminal-fg: #ccc;
110
+ --terminal-border: #3c3c3c;
111
+ --terminal-header-bg: #2d2d2d;
112
+ --terminal-font-family: "Menlo", "Monaco", "Courier New", monospace;
113
+ --terminal-font-size: 14px;
114
+ }
@@ -0,0 +1,16 @@
1
+ export { ThemedTerminal } from './src/components/ThemedTerminal';
2
+ export { ThemedTerminalWithProvider } from './src/components/ThemedTerminalWithProvider';
3
+ export type { ThemedTerminalProps, ThemedTerminalRef, TerminalHeaderBadge, TerminalOverlayState, TerminalScrollPosition, } from './src/types/terminal.types';
4
+ export { useThemedTerminal } from './src/hooks/useThemedTerminal';
5
+ export type { UseThemedTerminalReturn } from './src/hooks/useThemedTerminal';
6
+ export { createTerminalTheme, getTerminalCSSVariables, } from './src/utils/terminalTheme';
7
+ export { TerminalPanel } from './src/panels/TerminalPanel';
8
+ export { TabbedTerminalPanel } from './src/panels/TabbedTerminalPanel';
9
+ export type { TerminalTabContentRef } from './src/panels/TabbedTerminalPanel';
10
+ export { panels, onPackageLoad, onPackageUnload } from './src/panel-exports';
11
+ export type { PanelDefinition, PanelMetadata, PanelComponentProps, PanelContextValue, PanelActions, PanelEventEmitter, TerminalSessionInfo, CreateTerminalSessionOptions, TerminalPanelActions, TerminalEventType, TerminalScope, TerminalPanelProps, TerminalTab, TabbedTerminalPanelProps, OwnershipStatus, OwnershipResult, PortReadyData, } from './src/panel-types';
12
+ export { getTerminalSessions, getTerminalSession, isTerminalLoading, getRepositoryPath, getWorkspacePath, getTerminalDirectory, getTerminalSlice, } from './src/panel-types';
13
+ export type { Theme } from '@principal-ade/industry-theme';
14
+ export type { Terminal, ITheme as XTermTheme, ITerminalOptions } from '@xterm/xterm';
15
+ export type { ISearchOptions } from '@xterm/addon-search';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAGzF,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,YAAY,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAG9E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG7E,YAAY,EACV,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAO3B,YAAY,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAG3D,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrF,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}