@mks2508/mks-ui 0.5.4 → 0.5.8
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/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts +23 -4
- package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts.map +1 -1
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts +2 -2
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts.map +1 -1
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.js +292 -31
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts.map +1 -1
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.js +6 -1
- package/dist/react-ui/ui/DynamicToggle/{DynamicToggle-Cm6-VceQ.css → DynamicToggle-DJLwEkHr.css} +116 -51
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.css +116 -51
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts +1 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.js +9 -3
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts +61 -31
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/index.d.ts +9 -3
- package/dist/react-ui/ui/DynamicToggle/index.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/index.js +68 -37
- package/package.json +52 -13
- package/src/assets/react.svg +0 -1
- package/src/core/index.ts +0 -7
- package/src/core/types.ts +0 -82
- package/src/css.d.ts +0 -7
- package/src/index.css +0 -129
- package/src/index.ts +0 -29
- package/src/react-ui/blocks/Terminal/ResttyAdapter.ts +0 -278
- package/src/react-ui/blocks/Terminal/Terminal.adapter.ts +0 -97
- package/src/react-ui/blocks/Terminal/Terminal.theme.restty.ts +0 -155
- package/src/react-ui/blocks/Terminal/Terminal.theme.ts +0 -80
- package/src/react-ui/blocks/Terminal/Terminal.types.ts +0 -438
- package/src/react-ui/blocks/Terminal/TerminalDisplay.styles.ts +0 -38
- package/src/react-ui/blocks/Terminal/TerminalDisplay.tsx +0 -254
- package/src/react-ui/blocks/Terminal/TerminalDisplay.types.ts +0 -73
- package/src/react-ui/blocks/Terminal/TerminalPanel.tsx +0 -269
- package/src/react-ui/blocks/Terminal/TerminalRestty.tsx +0 -326
- package/src/react-ui/blocks/Terminal/TerminalXterm.tsx +0 -230
- package/src/react-ui/blocks/Terminal/XTermAdapter.ts +0 -163
- package/src/react-ui/blocks/Terminal/chrome.ts +0 -25
- package/src/react-ui/blocks/Terminal/components/LogLineBadges.tsx +0 -316
- package/src/react-ui/blocks/Terminal/components/SpecializedSyntaxHighlighter.tsx +0 -218
- package/src/react-ui/blocks/Terminal/components/SyntaxHighlight.tsx +0 -386
- package/src/react-ui/blocks/Terminal/components/TerminalLogBadge.tsx +0 -67
- package/src/react-ui/blocks/Terminal/components/index.ts +0 -10
- package/src/react-ui/blocks/Terminal/display.ts +0 -46
- package/src/react-ui/blocks/Terminal/hooks/index.ts +0 -22
- package/src/react-ui/blocks/Terminal/hooks/useTerminalSettings.ts +0 -229
- package/src/react-ui/blocks/Terminal/hooks/useTerminalWebSocket.ts +0 -292
- package/src/react-ui/blocks/Terminal/index.ts +0 -111
- package/src/react-ui/blocks/Terminal/panel/LogLinesViewer.tsx +0 -330
- package/src/react-ui/blocks/Terminal/panel/TerminalDebugPanel.tsx +0 -242
- package/src/react-ui/blocks/Terminal/panel/TerminalFilterDropdown.tsx +0 -202
- package/src/react-ui/blocks/Terminal/panel/TerminalFilterTabs.tsx +0 -140
- package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanel.tsx +0 -68
- package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanel.types.ts +0 -85
- package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanelRestty.tsx +0 -383
- package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanelXterm.tsx +0 -439
- package/src/react-ui/blocks/Terminal/panel/TerminalLogsPanel.tsx +0 -550
- package/src/react-ui/blocks/Terminal/panel/TerminalLogsPanel.types.ts +0 -259
- package/src/react-ui/blocks/Terminal/panel/TerminalPanelChrome.styles.ts +0 -75
- package/src/react-ui/blocks/Terminal/panel/TerminalPanelChrome.tsx +0 -266
- package/src/react-ui/blocks/Terminal/panel/TerminalPanelChrome.types.ts +0 -82
- package/src/react-ui/blocks/Terminal/panel/TerminalPanelFooter.tsx +0 -112
- package/src/react-ui/blocks/Terminal/panel/TerminalPanelHeader.tsx +0 -178
- package/src/react-ui/blocks/Terminal/panel/TerminalPanelToolbar.tsx +0 -203
- package/src/react-ui/blocks/Terminal/panel/TerminalSessionControl.tsx +0 -252
- package/src/react-ui/blocks/Terminal/panel/TerminalSessionTabs.tsx +0 -334
- package/src/react-ui/blocks/Terminal/panel/TerminalSettingsPopover.tsx +0 -261
- package/src/react-ui/blocks/Terminal/panel/TerminalThemeSelector.tsx +0 -248
- package/src/react-ui/blocks/Terminal/panel/index.ts +0 -72
- package/src/react-ui/blocks/Terminal/panel/terminal-filter-dropdown.module.css +0 -59
- package/src/react-ui/blocks/Terminal/panel/terminal-session-tabs.module.css +0 -59
- package/src/react-ui/blocks/Terminal/parsing/BadgeFormatter.ts +0 -180
- package/src/react-ui/blocks/Terminal/parsing/HttpLogParser.ts +0 -248
- package/src/react-ui/blocks/Terminal/parsing/LogParser.types.ts +0 -283
- package/src/react-ui/blocks/Terminal/parsing/LogParserService.ts +0 -686
- package/src/react-ui/blocks/Terminal/parsing/MultilineAggregator.ts +0 -466
- package/src/react-ui/blocks/Terminal/parsing/PersistentLogBuffer.ts +0 -343
- package/src/react-ui/blocks/Terminal/parsing/SyntaxHighlighter.ts +0 -167
- package/src/react-ui/blocks/Terminal/parsing/TableParser.ts +0 -348
- package/src/react-ui/blocks/Terminal/parsing/ansi/AnsiColorMapper.ts +0 -251
- package/src/react-ui/blocks/Terminal/parsing/ansi/AnsiParser.ts +0 -390
- package/src/react-ui/blocks/Terminal/parsing/ansi/ansi.constants.ts +0 -320
- package/src/react-ui/blocks/Terminal/parsing/ansi/index.ts +0 -20
- package/src/react-ui/blocks/Terminal/parsing/index.ts +0 -69
- package/src/react-ui/blocks/Terminal/parsing/levels/LogLevel.types.ts +0 -68
- package/src/react-ui/blocks/Terminal/parsing/levels/LogLevelDetector.ts +0 -436
- package/src/react-ui/blocks/Terminal/parsing/levels/index.ts +0 -14
- package/src/react-ui/blocks/index.ts +0 -11
- package/src/react-ui/components/MorphingPopover/MorphingPopover.types.ts +0 -49
- package/src/react-ui/components/MorphingPopover/index.tsx +0 -186
- package/src/react-ui/components/MorphingPopover/morphing-popover.module.css +0 -153
- package/src/react-ui/components/index.ts +0 -9
- package/src/react-ui/hooks/Animation/UseAutoHeight.tsx +0 -123
- package/src/react-ui/hooks/DOM/UseIsInView.tsx +0 -44
- package/src/react-ui/hooks/Formatting/UseListFormat.ts +0 -134
- package/src/react-ui/hooks/State/UseControlledState.tsx +0 -57
- package/src/react-ui/hooks/State/UseDataState.tsx +0 -76
- package/src/react-ui/hooks/index.ts +0 -20
- package/src/react-ui/icons/index.ts +0 -12
- package/src/react-ui/icons/lucide-animated/activity.tsx +0 -109
- package/src/react-ui/icons/lucide-animated/arrow-down-to-line.tsx +0 -51
- package/src/react-ui/icons/lucide-animated/arrow-up.tsx +0 -50
- package/src/react-ui/icons/lucide-animated/bell-electric.tsx +0 -124
- package/src/react-ui/icons/lucide-animated/bell.tsx +0 -93
- package/src/react-ui/icons/lucide-animated/bot.tsx +0 -122
- package/src/react-ui/icons/lucide-animated/box.tsx +0 -117
- package/src/react-ui/icons/lucide-animated/check.tsx +0 -21
- package/src/react-ui/icons/lucide-animated/circle-check.tsx +0 -107
- package/src/react-ui/icons/lucide-animated/delete.tsx +0 -133
- package/src/react-ui/icons/lucide-animated/download.tsx +0 -99
- package/src/react-ui/icons/lucide-animated/edit-2.tsx +0 -21
- package/src/react-ui/icons/lucide-animated/globe.tsx +0 -23
- package/src/react-ui/icons/lucide-animated/home.tsx +0 -103
- package/src/react-ui/icons/lucide-animated/index.ts +0 -38
- package/src/react-ui/icons/lucide-animated/layers.tsx +0 -23
- package/src/react-ui/icons/lucide-animated/layout-panel-top.tsx +0 -143
- package/src/react-ui/icons/lucide-animated/list.tsx +0 -54
- package/src/react-ui/icons/lucide-animated/package.tsx +0 -24
- package/src/react-ui/icons/lucide-animated/palette.tsx +0 -25
- package/src/react-ui/icons/lucide-animated/plus.tsx +0 -92
- package/src/react-ui/icons/lucide-animated/refresh-cw.tsx +0 -24
- package/src/react-ui/icons/lucide-animated/rocket.tsx +0 -24
- package/src/react-ui/icons/lucide-animated/save.tsx +0 -23
- package/src/react-ui/icons/lucide-animated/search.tsx +0 -94
- package/src/react-ui/icons/lucide-animated/settings.tsx +0 -92
- package/src/react-ui/icons/lucide-animated/terminal.tsx +0 -46
- package/src/react-ui/icons/lucide-animated/trash-2.tsx +0 -25
- package/src/react-ui/icons/lucide-animated/trending-down.tsx +0 -151
- package/src/react-ui/icons/lucide-animated/trending-up.tsx +0 -150
- package/src/react-ui/icons/lucide-animated/type.tsx +0 -23
- package/src/react-ui/icons/lucide-animated/upload.tsx +0 -23
- package/src/react-ui/icons/lucide-animated/x.tsx +0 -102
- package/src/react-ui/index.ts +0 -30
- package/src/react-ui/lib/get-strict-context.tsx +0 -56
- package/src/react-ui/lib/icon-wrapper.tsx +0 -70
- package/src/react-ui/lib/index.ts +0 -9
- package/src/react-ui/lib/utils.ts +0 -24
- package/src/react-ui/primitives/AutoHeight/index.tsx +0 -74
- package/src/react-ui/primitives/CountingNumber/index.tsx +0 -147
- package/src/react-ui/primitives/Highlight/Highlight.types.ts +0 -136
- package/src/react-ui/primitives/Highlight/index.tsx +0 -577
- package/src/react-ui/primitives/Slot/index.tsx +0 -128
- package/src/react-ui/primitives/index.ts +0 -16
- package/src/react-ui/primitives/waapi/Gooey/Gooey.types.ts +0 -123
- package/src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx +0 -80
- package/src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx +0 -77
- package/src/react-ui/primitives/waapi/Gooey/MorphPath.tsx +0 -58
- package/src/react-ui/primitives/waapi/Gooey/gooey-utils.ts +0 -244
- package/src/react-ui/primitives/waapi/Gooey/index.ts +0 -50
- package/src/react-ui/primitives/waapi/Gooey/useMorphPath.ts +0 -48
- package/src/react-ui/primitives/waapi/Morph/Morph.types.ts +0 -106
- package/src/react-ui/primitives/waapi/Morph/MorphContext.tsx +0 -21
- package/src/react-ui/primitives/waapi/Morph/index.tsx +0 -56
- package/src/react-ui/primitives/waapi/Morph/techniques/index.ts +0 -12
- package/src/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.ts +0 -89
- package/src/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.ts +0 -176
- package/src/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.ts +0 -87
- package/src/react-ui/primitives/waapi/Morph/useMorph.ts +0 -101
- package/src/react-ui/primitives/waapi/Reorder/Reorder.types.ts +0 -177
- package/src/react-ui/primitives/waapi/Reorder/index.tsx +0 -260
- package/src/react-ui/primitives/waapi/Reorder/useReorder.ts +0 -47
- package/src/react-ui/primitives/waapi/Reorder/useReorderPresence.ts +0 -209
- package/src/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.ts +0 -104
- package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.ts +0 -14
- package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.ts +0 -84
- package/src/react-ui/primitives/waapi/SlidingNumber/index.tsx +0 -474
- package/src/react-ui/primitives/waapi/SlidingText/SlidingText.styles.ts +0 -32
- package/src/react-ui/primitives/waapi/SlidingText/SlidingText.types.ts +0 -69
- package/src/react-ui/primitives/waapi/SlidingText/index.tsx +0 -140
- package/src/react-ui/primitives/waapi/core/animationConstants.ts +0 -215
- package/src/react-ui/primitives/waapi/core/index.ts +0 -53
- package/src/react-ui/primitives/waapi/core/types.ts +0 -200
- package/src/react-ui/primitives/waapi/core/useAnimationOrchestrator.ts +0 -430
- package/src/react-ui/primitives/waapi/core/useElementRegistry.ts +0 -81
- package/src/react-ui/primitives/waapi/core/useFLIPAnimation.ts +0 -138
- package/src/react-ui/primitives/waapi/core/usePositionCapture.ts +0 -106
- package/src/react-ui/primitives/waapi/index.ts +0 -139
- package/src/react-ui/styles/animations.css +0 -369
- package/src/react-ui/ui/Accordion/Accordion.styles.ts +0 -72
- package/src/react-ui/ui/Accordion/Accordion.types.ts +0 -199
- package/src/react-ui/ui/Accordion/index.tsx +0 -362
- package/src/react-ui/ui/AlertDialog/AlertDialog.styles.ts +0 -38
- package/src/react-ui/ui/AlertDialog/AlertDialog.types.ts +0 -296
- package/src/react-ui/ui/AlertDialog/index.tsx +0 -540
- package/src/react-ui/ui/Badge/Badge.styles.ts +0 -43
- package/src/react-ui/ui/Badge/Badge.types.ts +0 -26
- package/src/react-ui/ui/Badge/index.tsx +0 -34
- package/src/react-ui/ui/Button/Button.styles.ts +0 -57
- package/src/react-ui/ui/Button/Button.types.ts +0 -63
- package/src/react-ui/ui/Button/index.tsx +0 -155
- package/src/react-ui/ui/Card/Card.styles.ts +0 -32
- package/src/react-ui/ui/Card/Card.types.ts +0 -39
- package/src/react-ui/ui/Card/index.tsx +0 -130
- package/src/react-ui/ui/Checkbox/Checkbox.styles.ts +0 -40
- package/src/react-ui/ui/Checkbox/Checkbox.types.ts +0 -98
- package/src/react-ui/ui/Checkbox/index.tsx +0 -233
- package/src/react-ui/ui/Combobox/Combobox.styles.ts +0 -34
- package/src/react-ui/ui/Combobox/Combobox.types.ts +0 -89
- package/src/react-ui/ui/Combobox/index.tsx +0 -331
- package/src/react-ui/ui/CornerBracket/CornerBracket.styles.ts +0 -38
- package/src/react-ui/ui/CornerBracket/CornerBracket.types.ts +0 -15
- package/src/react-ui/ui/CornerBracket/index.tsx +0 -49
- package/src/react-ui/ui/DataCard/DataCard.styles.ts +0 -94
- package/src/react-ui/ui/DataCard/DataCard.types.ts +0 -125
- package/src/react-ui/ui/DataCard/index.tsx +0 -340
- package/src/react-ui/ui/Dialog/Dialog.styles.ts +0 -59
- package/src/react-ui/ui/Dialog/Dialog.types.ts +0 -284
- package/src/react-ui/ui/Dialog/index.tsx +0 -452
- package/src/react-ui/ui/DropdownMenu/DropdownMenu.styles.ts +0 -35
- package/src/react-ui/ui/DropdownMenu/DropdownMenu.types.ts +0 -81
- package/src/react-ui/ui/DropdownMenu/index.tsx +0 -300
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.css +0 -303
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.styles.ts +0 -85
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.types.ts +0 -174
- package/src/react-ui/ui/DynamicToggle/index.tsx +0 -294
- package/src/react-ui/ui/DynamicToggle/prototype-v7.html +0 -615
- package/src/react-ui/ui/DynamicToggle/prototype.html +0 -419
- package/src/react-ui/ui/Field/Field.styles.ts +0 -47
- package/src/react-ui/ui/Field/Field.types.ts +0 -60
- package/src/react-ui/ui/Field/index.tsx +0 -254
- package/src/react-ui/ui/Input/Input.styles.ts +0 -11
- package/src/react-ui/ui/Input/Input.types.ts +0 -10
- package/src/react-ui/ui/Input/index.tsx +0 -32
- package/src/react-ui/ui/InputGroup/InputGroup.styles.ts +0 -53
- package/src/react-ui/ui/InputGroup/InputGroup.types.ts +0 -44
- package/src/react-ui/ui/InputGroup/index.tsx +0 -149
- package/src/react-ui/ui/Label/Label.styles.ts +0 -10
- package/src/react-ui/ui/Label/Label.types.ts +0 -9
- package/src/react-ui/ui/Label/index.tsx +0 -27
- package/src/react-ui/ui/Menu/Menu.styles.ts +0 -71
- package/src/react-ui/ui/Menu/Menu.types.ts +0 -425
- package/src/react-ui/ui/Menu/index.tsx +0 -900
- package/src/react-ui/ui/Popover/Popover.styles.ts +0 -55
- package/src/react-ui/ui/Popover/Popover.types.ts +0 -261
- package/src/react-ui/ui/Popover/index.tsx +0 -422
- package/src/react-ui/ui/Progress/Progress.styles.ts +0 -36
- package/src/react-ui/ui/Progress/Progress.types.ts +0 -162
- package/src/react-ui/ui/Progress/index.tsx +0 -254
- package/src/react-ui/ui/Select/Select.styles.ts +0 -30
- package/src/react-ui/ui/Select/Select.types.ts +0 -51
- package/src/react-ui/ui/Select/index.tsx +0 -225
- package/src/react-ui/ui/Separator/Separator.styles.ts +0 -10
- package/src/react-ui/ui/Separator/Separator.types.ts +0 -10
- package/src/react-ui/ui/Separator/index.tsx +0 -37
- package/src/react-ui/ui/Switch/Switch.styles.ts +0 -50
- package/src/react-ui/ui/Switch/Switch.types.ts +0 -155
- package/src/react-ui/ui/Switch/index.tsx +0 -253
- package/src/react-ui/ui/Tabs/Tabs.css +0 -39
- package/src/react-ui/ui/Tabs/Tabs.styles.ts +0 -148
- package/src/react-ui/ui/Tabs/Tabs.types.ts +0 -255
- package/src/react-ui/ui/Tabs/index.tsx +0 -529
- package/src/react-ui/ui/TextFlow/TextFlow.styles.ts +0 -36
- package/src/react-ui/ui/TextFlow/TextFlow.types.ts +0 -118
- package/src/react-ui/ui/TextFlow/index.tsx +0 -276
- package/src/react-ui/ui/Textarea/Textarea.styles.ts +0 -10
- package/src/react-ui/ui/Textarea/Textarea.types.ts +0 -9
- package/src/react-ui/ui/Textarea/index.tsx +0 -27
- package/src/react-ui/ui/Tooltip/Tooltip.styles.ts +0 -43
- package/src/react-ui/ui/Tooltip/Tooltip.types.ts +0 -253
- package/src/react-ui/ui/Tooltip/index.tsx +0 -394
- package/src/react-ui/ui/index.ts +0 -41
- package/src/types/css-modules.d.ts +0 -18
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TerminalRestty - React wrapper for restty GPU terminal renderer.
|
|
3
|
-
*
|
|
4
|
-
* Manages the restty lifecycle within React's component model,
|
|
5
|
-
* handling mount/unmount, dynamic import (SSR-safe), font loading,
|
|
6
|
-
* theme application, and PTY connection via custom DevenvPtyTransport.
|
|
7
|
-
*
|
|
8
|
-
* @module components/devenv/terminal/TerminalRestty
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use client';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
useRef,
|
|
15
|
-
useEffect,
|
|
16
|
-
useCallback,
|
|
17
|
-
forwardRef,
|
|
18
|
-
useImperativeHandle,
|
|
19
|
-
useState,
|
|
20
|
-
} from 'react';
|
|
21
|
-
import type { Restty } from 'restty';
|
|
22
|
-
import type { ITerminalTheme, IPtyTransport, IPtyTransportFactory } from './Terminal.types';
|
|
23
|
-
import { getSynthwaveGhosttyTheme, xtermThemeToGhostty } from './Terminal.theme.restty';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Props for the TerminalRestty React wrapper.
|
|
27
|
-
*/
|
|
28
|
-
export interface ITerminalResttyProps {
|
|
29
|
-
/**
|
|
30
|
-
* Factory to create a custom PTY transport.
|
|
31
|
-
* If not provided, restty manages its own PTY connection internally.
|
|
32
|
-
* Use this to inject custom WebSocket protocol bridging (e.g., mks-devenv).
|
|
33
|
-
*/
|
|
34
|
-
createPtyTransport?: IPtyTransportFactory;
|
|
35
|
-
|
|
36
|
-
/** PTY WebSocket URL to connect to */
|
|
37
|
-
wsUrl?: string;
|
|
38
|
-
|
|
39
|
-
/** Font size in CSS pixels (default: 14) */
|
|
40
|
-
fontSize?: number;
|
|
41
|
-
|
|
42
|
-
/** Terminal theme in xterm.js format (auto-converted to Ghostty format) */
|
|
43
|
-
theme?: ITerminalTheme;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Restty built-in theme name from the 458-theme catalog.
|
|
47
|
-
* Takes precedence over the `theme` prop when set.
|
|
48
|
-
*/
|
|
49
|
-
resttyThemeName?: string;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* GPU renderer preference.
|
|
53
|
-
* - `auto`: WebGPU with WebGL2 fallback (default, recommended)
|
|
54
|
-
* - `webgpu`: Force WebGPU only
|
|
55
|
-
* - `webgl2`: Force WebGL2 only
|
|
56
|
-
*/
|
|
57
|
-
gpuRenderer?: 'auto' | 'webgpu' | 'webgl2';
|
|
58
|
-
|
|
59
|
-
/** Callback when restty instance is initialized and ready */
|
|
60
|
-
onReady?: (restty: Restty) => void;
|
|
61
|
-
|
|
62
|
-
/** Callback when terminal dimensions change */
|
|
63
|
-
onResize?: (cols: number, rows: number) => void;
|
|
64
|
-
|
|
65
|
-
/** Callback when PTY connection status changes */
|
|
66
|
-
onPtyStatus?: (status: string) => void;
|
|
67
|
-
|
|
68
|
-
/** Callback when PTY connection opens */
|
|
69
|
-
onConnect?: () => void;
|
|
70
|
-
|
|
71
|
-
/** Callback when PTY connection closes */
|
|
72
|
-
onDisconnect?: () => void;
|
|
73
|
-
|
|
74
|
-
/** Callback when PTY reports an error */
|
|
75
|
-
onError?: (message: string) => void;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Callback when the terminal receives a desktop notification (OSC 9/777).
|
|
79
|
-
* Available in restty v0.1.24+.
|
|
80
|
-
*
|
|
81
|
-
* @param notification - Notification data with title, body, and paneId
|
|
82
|
-
*/
|
|
83
|
-
onDesktopNotification?: (notification: { title?: string; body?: string; paneId: number }) => void;
|
|
84
|
-
|
|
85
|
-
/** Custom class name for the container div */
|
|
86
|
-
className?: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Imperative handle for TerminalRestty component.
|
|
91
|
-
*/
|
|
92
|
-
export interface ITerminalResttyRef {
|
|
93
|
-
/** Get the underlying Restty instance */
|
|
94
|
-
getRestty: () => Restty | null;
|
|
95
|
-
|
|
96
|
-
/** Send raw input to the terminal PTY */
|
|
97
|
-
sendInput: (data: string) => void;
|
|
98
|
-
|
|
99
|
-
/** Clear the terminal screen */
|
|
100
|
-
clear: () => void;
|
|
101
|
-
|
|
102
|
-
/** Focus the terminal for keyboard input */
|
|
103
|
-
focus: () => void;
|
|
104
|
-
|
|
105
|
-
/** Remove focus from the terminal */
|
|
106
|
-
blur: () => void;
|
|
107
|
-
|
|
108
|
-
/** Update font size */
|
|
109
|
-
setFontSize: (size: number) => void;
|
|
110
|
-
|
|
111
|
-
/** Resize terminal to explicit dimensions (v0.1.21+) */
|
|
112
|
-
resize: (cols: number, rows: number) => void;
|
|
113
|
-
|
|
114
|
-
/** Check if PTY is connected */
|
|
115
|
-
isPtyConnected: () => boolean;
|
|
116
|
-
|
|
117
|
-
/** Connect to a PTY URL */
|
|
118
|
-
connectPty: (url: string) => void;
|
|
119
|
-
|
|
120
|
-
/** Disconnect from PTY */
|
|
121
|
-
disconnectPty: () => void;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* TerminalRestty - React component wrapping restty's GPU terminal.
|
|
126
|
-
*
|
|
127
|
-
* Handles the full lifecycle: dynamic WASM/WebGPU import, font loading,
|
|
128
|
-
* theme application, PTY connection via custom transport, and cleanup.
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```tsx
|
|
132
|
-
* const resttyRef = useRef<ITerminalResttyRef>(null);
|
|
133
|
-
*
|
|
134
|
-
* <TerminalRestty
|
|
135
|
-
* ref={resttyRef}
|
|
136
|
-
* wsUrl="ws://localhost:3100/terminal/session-1"
|
|
137
|
-
* fontSize={14}
|
|
138
|
-
* onResize={(cols, rows) => console.log(`${cols}x${rows}`)}
|
|
139
|
-
* onConnect={() => console.log('PTY connected')}
|
|
140
|
-
* />
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
export const TerminalRestty = forwardRef<ITerminalResttyRef, ITerminalResttyProps>(
|
|
144
|
-
(
|
|
145
|
-
{
|
|
146
|
-
createPtyTransport,
|
|
147
|
-
wsUrl,
|
|
148
|
-
fontSize = 14,
|
|
149
|
-
theme,
|
|
150
|
-
resttyThemeName,
|
|
151
|
-
gpuRenderer = 'auto',
|
|
152
|
-
onReady,
|
|
153
|
-
onResize,
|
|
154
|
-
onPtyStatus,
|
|
155
|
-
onConnect,
|
|
156
|
-
onDisconnect,
|
|
157
|
-
onError,
|
|
158
|
-
onDesktopNotification,
|
|
159
|
-
className,
|
|
160
|
-
},
|
|
161
|
-
ref
|
|
162
|
-
) => {
|
|
163
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
164
|
-
const resttyRef = useRef<Restty | null>(null);
|
|
165
|
-
const transportRef = useRef<IPtyTransport | null>(null);
|
|
166
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
167
|
-
|
|
168
|
-
// Store callbacks in refs to avoid re-creating restty on callback changes
|
|
169
|
-
const callbacksRef = useRef({ onReady, onResize, onPtyStatus, onConnect, onDisconnect, onError, onDesktopNotification });
|
|
170
|
-
callbacksRef.current = { onReady, onResize, onPtyStatus, onConnect, onDisconnect, onError, onDesktopNotification };
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Initialize restty on mount.
|
|
174
|
-
* Dynamic import ensures SSR safety (WASM + WebGPU require browser).
|
|
175
|
-
*/
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
if (!containerRef.current) return;
|
|
178
|
-
let destroyed = false;
|
|
179
|
-
|
|
180
|
-
const initRestty = async () => {
|
|
181
|
-
const { Restty, getBuiltinTheme } = await import('restty');
|
|
182
|
-
if (destroyed || !containerRef.current) return;
|
|
183
|
-
|
|
184
|
-
// Create custom PtyTransport if factory provided
|
|
185
|
-
const transport = createPtyTransport?.() ?? null;
|
|
186
|
-
transportRef.current = transport;
|
|
187
|
-
|
|
188
|
-
const restty = new Restty({
|
|
189
|
-
root: containerRef.current,
|
|
190
|
-
appOptions: {
|
|
191
|
-
renderer: gpuRenderer,
|
|
192
|
-
fontSize,
|
|
193
|
-
autoResize: true,
|
|
194
|
-
...(transport ? { ptyTransport: transport } : {}),
|
|
195
|
-
callbacks: {
|
|
196
|
-
onTermSize: (cols: number, rows: number) => {
|
|
197
|
-
callbacksRef.current.onResize?.(cols, rows);
|
|
198
|
-
},
|
|
199
|
-
onPtyStatus: (status: string) => {
|
|
200
|
-
callbacksRef.current.onPtyStatus?.(status);
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
fontSources: [
|
|
205
|
-
{
|
|
206
|
-
type: 'local',
|
|
207
|
-
matchers: [
|
|
208
|
-
'jetbrains mono',
|
|
209
|
-
'fira code',
|
|
210
|
-
'sf mono',
|
|
211
|
-
'cascadia code',
|
|
212
|
-
'meslo',
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
],
|
|
216
|
-
onDesktopNotification: (notification: { title?: string; body?: string; paneId: number }) => {
|
|
217
|
-
callbacksRef.current.onDesktopNotification?.(notification);
|
|
218
|
-
},
|
|
219
|
-
createInitialPane: true,
|
|
220
|
-
shortcuts: false,
|
|
221
|
-
defaultContextMenu: true,
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
resttyRef.current = restty;
|
|
225
|
-
|
|
226
|
-
// Apply theme
|
|
227
|
-
if (resttyThemeName) {
|
|
228
|
-
const builtinTheme = getBuiltinTheme(resttyThemeName);
|
|
229
|
-
if (builtinTheme) restty.applyTheme(builtinTheme);
|
|
230
|
-
} else if (theme) {
|
|
231
|
-
restty.applyTheme(xtermThemeToGhostty(theme));
|
|
232
|
-
} else {
|
|
233
|
-
restty.applyTheme(getSynthwaveGhosttyTheme());
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Connect to PTY if URL provided
|
|
237
|
-
if (wsUrl) {
|
|
238
|
-
restty.connectPty(wsUrl);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
setIsInitialized(true);
|
|
242
|
-
callbacksRef.current.onReady?.(restty);
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
initRestty().catch((err) => {
|
|
246
|
-
if (!destroyed) {
|
|
247
|
-
callbacksRef.current.onError?.(
|
|
248
|
-
`Failed to initialize restty: ${err instanceof Error ? err.message : String(err)}`
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
return () => {
|
|
254
|
-
destroyed = true;
|
|
255
|
-
resttyRef.current?.destroy();
|
|
256
|
-
resttyRef.current = null;
|
|
257
|
-
transportRef.current = null;
|
|
258
|
-
setIsInitialized(false);
|
|
259
|
-
};
|
|
260
|
-
}, []); // Mount once — prop changes handled by separate effects
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Handle wsUrl changes after initialization.
|
|
264
|
-
*/
|
|
265
|
-
useEffect(() => {
|
|
266
|
-
if (!isInitialized || !resttyRef.current) return;
|
|
267
|
-
|
|
268
|
-
if (wsUrl) {
|
|
269
|
-
resttyRef.current.disconnectPty();
|
|
270
|
-
resttyRef.current.connectPty(wsUrl);
|
|
271
|
-
} else {
|
|
272
|
-
resttyRef.current.disconnectPty();
|
|
273
|
-
}
|
|
274
|
-
}, [wsUrl, isInitialized]);
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Handle fontSize changes after initialization.
|
|
278
|
-
*/
|
|
279
|
-
useEffect(() => {
|
|
280
|
-
if (!isInitialized || !resttyRef.current) return;
|
|
281
|
-
resttyRef.current.setFontSize(fontSize);
|
|
282
|
-
}, [fontSize, isInitialized]);
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Handle theme changes after initialization.
|
|
286
|
-
*/
|
|
287
|
-
useEffect(() => {
|
|
288
|
-
if (!isInitialized || !resttyRef.current) return;
|
|
289
|
-
|
|
290
|
-
if (resttyThemeName) {
|
|
291
|
-
import('restty').then(({ getBuiltinTheme }) => {
|
|
292
|
-
const builtinTheme = getBuiltinTheme(resttyThemeName);
|
|
293
|
-
if (builtinTheme) resttyRef.current?.applyTheme(builtinTheme);
|
|
294
|
-
});
|
|
295
|
-
} else if (theme) {
|
|
296
|
-
resttyRef.current.applyTheme(xtermThemeToGhostty(theme));
|
|
297
|
-
}
|
|
298
|
-
}, [theme, resttyThemeName, isInitialized]);
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Expose imperative handle for parent component control.
|
|
302
|
-
*/
|
|
303
|
-
useImperativeHandle(ref, () => ({
|
|
304
|
-
getRestty: () => resttyRef.current,
|
|
305
|
-
sendInput: (data: string) => resttyRef.current?.sendInput(data),
|
|
306
|
-
clear: () => resttyRef.current?.clearScreen(),
|
|
307
|
-
focus: () => resttyRef.current?.focus(),
|
|
308
|
-
blur: () => resttyRef.current?.blur(),
|
|
309
|
-
setFontSize: (size: number) => resttyRef.current?.setFontSize(size),
|
|
310
|
-
resize: (cols: number, rows: number) => resttyRef.current?.resize(cols, rows),
|
|
311
|
-
isPtyConnected: () => resttyRef.current?.isPtyConnected() ?? false,
|
|
312
|
-
connectPty: (url: string) => resttyRef.current?.connectPty(url),
|
|
313
|
-
disconnectPty: () => resttyRef.current?.disconnectPty(),
|
|
314
|
-
}));
|
|
315
|
-
|
|
316
|
-
return (
|
|
317
|
-
<div
|
|
318
|
-
ref={containerRef}
|
|
319
|
-
className={className}
|
|
320
|
-
style={{ width: '100%', height: '100%', minHeight: '400px' }}
|
|
321
|
-
/>
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
TerminalRestty.displayName = 'TerminalRestty';
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* xterm.js wrapper component.
|
|
3
|
-
*
|
|
4
|
-
* Encapsulates xterm.js initialization, addon loading,
|
|
5
|
-
* and cleanup following React best practices with proper
|
|
6
|
-
* ref management and effect hooks.
|
|
7
|
-
*
|
|
8
|
-
* @module components/devenv/terminal/xterm
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use client';
|
|
12
|
-
|
|
13
|
-
import { useEffect, useRef, useCallback } from 'react';
|
|
14
|
-
import { Terminal } from '@xterm/xterm';
|
|
15
|
-
import { FitAddon } from '@xterm/addon-fit';
|
|
16
|
-
import { WebLinksAddon } from '@xterm/addon-web-links';
|
|
17
|
-
import { SearchAddon } from '@xterm/addon-search';
|
|
18
|
-
import { Unicode11Addon } from '@xterm/addon-unicode11';
|
|
19
|
-
import type { ITerminalOptions, ITerminalTheme } from './Terminal.types';
|
|
20
|
-
import '@xterm/xterm/css/xterm.css';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Props for the XTermWrapper component.
|
|
24
|
-
*/
|
|
25
|
-
export interface IXTermWrapperProps {
|
|
26
|
-
/** Terminal initialization options */
|
|
27
|
-
options: ITerminalOptions;
|
|
28
|
-
|
|
29
|
-
/** Terminal theme (defaults to Synthwave if not provided) */
|
|
30
|
-
theme?: ITerminalTheme;
|
|
31
|
-
|
|
32
|
-
/** Callback when user types data in interactive mode */
|
|
33
|
-
onData?: (data: string) => void;
|
|
34
|
-
|
|
35
|
-
/** Callback when terminal is ready for interaction */
|
|
36
|
-
onReady?: (terminal: Terminal) => void;
|
|
37
|
-
|
|
38
|
-
/** Callback when terminal resizes */
|
|
39
|
-
onResize?: (cols: number, rows: number) => void;
|
|
40
|
-
|
|
41
|
-
/** Custom class name for the container */
|
|
42
|
-
className?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* xterm.js wrapper component.
|
|
47
|
-
*
|
|
48
|
-
* Manages xterm.js lifecycle including initialization, addon loading,
|
|
49
|
-
* WebSocket/SSE connections, and cleanup. Provides auto-resize via
|
|
50
|
-
* FitAddon and clickable URLs via WebLinksAddon.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```tsx
|
|
54
|
-
* <XTermWrapper
|
|
55
|
-
* options={{ mode: 'interactive', wsUrl: 'ws://localhost:3100/terminal' }}
|
|
56
|
-
* onData={(data) => console.log('User input:', data)}
|
|
57
|
-
* onReady={(terminal) => console.log('Terminal ready')}
|
|
58
|
-
* />
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export function XTermWrapper({
|
|
62
|
-
options,
|
|
63
|
-
theme,
|
|
64
|
-
onData,
|
|
65
|
-
onReady,
|
|
66
|
-
onResize,
|
|
67
|
-
className,
|
|
68
|
-
}: IXTermWrapperProps) {
|
|
69
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
70
|
-
const terminalRef = useRef<Terminal | null>(null);
|
|
71
|
-
const fitAddonRef = useRef<FitAddon | null>(null);
|
|
72
|
-
const searchAddonRef = useRef<SearchAddon | null>(null);
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Handle terminal data input from user.
|
|
76
|
-
*/
|
|
77
|
-
const handleData = useCallback(
|
|
78
|
-
(data: string) => {
|
|
79
|
-
if (options.mode === 'interactive' && onData) {
|
|
80
|
-
onData(data);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
[options.mode, onData]
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Initialize xterm.js instance and load addons.
|
|
88
|
-
*
|
|
89
|
-
* Note: LigaturesAddon uses `fs` (Node.js module) internally,
|
|
90
|
-
* so it must be loaded via dynamic import to avoid SSR/bundler
|
|
91
|
-
* errors. All other addons are browser-safe static imports.
|
|
92
|
-
*/
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (!containerRef.current) return;
|
|
95
|
-
|
|
96
|
-
let disposed = false;
|
|
97
|
-
|
|
98
|
-
// Create terminal instance with options
|
|
99
|
-
const terminal = new Terminal({
|
|
100
|
-
cursorBlink: options.cursorBlink ?? true,
|
|
101
|
-
scrollback: options.scrollback ?? 1000,
|
|
102
|
-
fontSize: options.fontSize ?? 14,
|
|
103
|
-
fontFamily:
|
|
104
|
-
options.fontFamily ??
|
|
105
|
-
"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Monaco', 'Inconsolata', monospace",
|
|
106
|
-
theme: theme ?? {},
|
|
107
|
-
convertEol: true,
|
|
108
|
-
allowProposedApi: true,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Load browser-safe addons (static imports)
|
|
112
|
-
const fitAddon = new FitAddon();
|
|
113
|
-
const webLinksAddon = new WebLinksAddon();
|
|
114
|
-
const searchAddon = new SearchAddon();
|
|
115
|
-
const unicode11Addon = new Unicode11Addon();
|
|
116
|
-
|
|
117
|
-
terminal.loadAddon(fitAddon);
|
|
118
|
-
terminal.loadAddon(webLinksAddon);
|
|
119
|
-
terminal.loadAddon(searchAddon);
|
|
120
|
-
terminal.loadAddon(unicode11Addon);
|
|
121
|
-
|
|
122
|
-
// Enable Unicode 11 support
|
|
123
|
-
terminal.unicode.activeVersion = '11';
|
|
124
|
-
|
|
125
|
-
// Open terminal in container
|
|
126
|
-
terminal.open(containerRef.current);
|
|
127
|
-
fitAddon.fit();
|
|
128
|
-
|
|
129
|
-
// Store references
|
|
130
|
-
terminalRef.current = terminal;
|
|
131
|
-
fitAddonRef.current = fitAddon;
|
|
132
|
-
searchAddonRef.current = searchAddon;
|
|
133
|
-
|
|
134
|
-
// Load LigaturesAddon dynamically (requires `fs` — Node.js only at import time)
|
|
135
|
-
import('@xterm/addon-ligatures').then(({ LigaturesAddon }) => {
|
|
136
|
-
if (disposed) return;
|
|
137
|
-
terminal.loadAddon(new LigaturesAddon());
|
|
138
|
-
}).catch(() => {
|
|
139
|
-
// Ligatures addon is optional — gracefully degrade if unavailable
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// Handle data callback
|
|
143
|
-
if (options.mode === 'interactive') {
|
|
144
|
-
terminal.onData(handleData);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Notify ready
|
|
148
|
-
onReady?.(terminal);
|
|
149
|
-
|
|
150
|
-
// Cleanup on unmount
|
|
151
|
-
return () => {
|
|
152
|
-
disposed = true;
|
|
153
|
-
terminal.dispose();
|
|
154
|
-
};
|
|
155
|
-
// Only run on mount/unmount
|
|
156
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
157
|
-
}, []);
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Handle window resize with auto-fit.
|
|
161
|
-
*/
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
const handleResize = () => {
|
|
164
|
-
if (!fitAddonRef.current || !terminalRef.current) return;
|
|
165
|
-
|
|
166
|
-
const previousDims = { cols: terminalRef.current.cols, rows: terminalRef.current.rows };
|
|
167
|
-
fitAddonRef.current.fit();
|
|
168
|
-
|
|
169
|
-
// Notify parent of resize if dimensions changed
|
|
170
|
-
if (
|
|
171
|
-
onResize &&
|
|
172
|
-
(terminalRef.current.cols !== previousDims.cols ||
|
|
173
|
-
terminalRef.current.rows !== previousDims.rows)
|
|
174
|
-
) {
|
|
175
|
-
onResize(terminalRef.current.cols, terminalRef.current.rows);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
window.addEventListener('resize', handleResize);
|
|
180
|
-
return () => window.removeEventListener('resize', handleResize);
|
|
181
|
-
}, [onResize]);
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Handle theme updates.
|
|
185
|
-
*/
|
|
186
|
-
useEffect(() => {
|
|
187
|
-
if (!terminalRef.current || !theme) return;
|
|
188
|
-
|
|
189
|
-
terminalRef.current.options.theme = theme;
|
|
190
|
-
}, [theme]);
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Handle data callback updates.
|
|
194
|
-
*/
|
|
195
|
-
useEffect(() => {
|
|
196
|
-
if (!terminalRef.current) return;
|
|
197
|
-
|
|
198
|
-
// Remove previous listener
|
|
199
|
-
terminalRef.current.onData(undefined!);
|
|
200
|
-
|
|
201
|
-
// Add new listener if interactive mode
|
|
202
|
-
if (options.mode === 'interactive' && onData) {
|
|
203
|
-
terminalRef.current.onData(onData);
|
|
204
|
-
}
|
|
205
|
-
}, [options.mode, onData]);
|
|
206
|
-
|
|
207
|
-
return (
|
|
208
|
-
<div
|
|
209
|
-
ref={containerRef}
|
|
210
|
-
className={className ?? 'xterm-container w-full h-full'}
|
|
211
|
-
style={{ minHeight: '400px' }}
|
|
212
|
-
data-terminal-mode={options.mode ?? 'interactive'}
|
|
213
|
-
/>
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Export search addon reference for external access.
|
|
219
|
-
*
|
|
220
|
-
* Allows parent components to trigger search in the terminal buffer.
|
|
221
|
-
*/
|
|
222
|
-
export function useTerminalSearch(terminalRef: React.RefObject<Terminal | null>) {
|
|
223
|
-
const search = useCallback((_term: string, _options?: { caseSensitive?: boolean; regex?: boolean }) => {
|
|
224
|
-
// The search addon needs to be accessed differently
|
|
225
|
-
// This is a placeholder for future search functionality
|
|
226
|
-
return false;
|
|
227
|
-
}, [terminalRef]);
|
|
228
|
-
|
|
229
|
-
return { search };
|
|
230
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* XTerm Adapter - ITerminalAdapter implementation for xterm.js.
|
|
3
|
-
*
|
|
4
|
-
* Wrapper class that adapts xterm.js Terminal to the ITerminalAdapter
|
|
5
|
-
* interface, enabling consistent API across different backends.
|
|
6
|
-
*
|
|
7
|
-
* @module components/devenv/terminal/XTermAdapter
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { Terminal } from '@xterm/xterm';
|
|
11
|
-
import { FitAddon } from '@xterm/addon-fit';
|
|
12
|
-
import type {
|
|
13
|
-
ITerminalAdapter,
|
|
14
|
-
ITerminalAdapterCapabilities,
|
|
15
|
-
ITerminalOptions,
|
|
16
|
-
ITerminalMode,
|
|
17
|
-
} from './Terminal.types';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* XTermAdapter implements ITerminalAdapter for xterm.js.
|
|
21
|
-
*
|
|
22
|
-
* Provides xterm.js functionality through the standardized adapter interface.
|
|
23
|
-
* Manages terminal lifecycle including initialization, data writing,
|
|
24
|
-
* resizing, and cleanup.
|
|
25
|
-
*/
|
|
26
|
-
export class XTermAdapter implements ITerminalAdapter {
|
|
27
|
-
/** Backend type identifier */
|
|
28
|
-
public readonly type = 'xterm' as const;
|
|
29
|
-
|
|
30
|
-
/** Adapter capabilities for runtime feature detection */
|
|
31
|
-
public readonly capabilities: ITerminalAdapterCapabilities = {
|
|
32
|
-
managesOwnConnection: false,
|
|
33
|
-
gpuRendering: false,
|
|
34
|
-
multiPane: false,
|
|
35
|
-
builtinThemes: false,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/** xterm.js Terminal instance */
|
|
39
|
-
private terminal: Terminal | null = null;
|
|
40
|
-
|
|
41
|
-
/** FitAddon for auto-resize */
|
|
42
|
-
private fitAddon: FitAddon | null = null;
|
|
43
|
-
|
|
44
|
-
/** Current options */
|
|
45
|
-
private options: ITerminalOptions;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Create XTermAdapter instance.
|
|
49
|
-
*
|
|
50
|
-
* @param options - Terminal initialization options
|
|
51
|
-
*/
|
|
52
|
-
constructor(options: ITerminalOptions) {
|
|
53
|
-
this.options = options;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Initialize the terminal in the given container element.
|
|
58
|
-
*
|
|
59
|
-
* Creates xterm.js Terminal instance, loads addons, and opens
|
|
60
|
-
* in the provided container.
|
|
61
|
-
*
|
|
62
|
-
* @param container - DOM element to render terminal into
|
|
63
|
-
* @param options - Terminal initialization options
|
|
64
|
-
* @returns Promise that resolves when terminal is ready
|
|
65
|
-
*/
|
|
66
|
-
async initialize(container: HTMLElement, options: ITerminalOptions): Promise<void> {
|
|
67
|
-
this.options = options;
|
|
68
|
-
|
|
69
|
-
// Create terminal instance
|
|
70
|
-
this.terminal = new Terminal({
|
|
71
|
-
cursorBlink: options.cursorBlink ?? true,
|
|
72
|
-
scrollback: options.scrollback ?? 1000,
|
|
73
|
-
fontSize: options.fontSize ?? 14,
|
|
74
|
-
fontFamily:
|
|
75
|
-
options.fontFamily ??
|
|
76
|
-
"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Monaco', 'Inconsolata', monospace",
|
|
77
|
-
theme: options.theme ?? {},
|
|
78
|
-
convertEol: true,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// Load fit addon
|
|
82
|
-
this.fitAddon = new FitAddon();
|
|
83
|
-
this.terminal.loadAddon(this.fitAddon);
|
|
84
|
-
|
|
85
|
-
// Open terminal
|
|
86
|
-
this.terminal.open(container);
|
|
87
|
-
this.fitAddon.fit();
|
|
88
|
-
|
|
89
|
-
// Setup data handler for interactive mode
|
|
90
|
-
if (options.mode === 'interactive' && options.onData) {
|
|
91
|
-
this.terminal.onData(options.onData);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Write data to the terminal without newline.
|
|
97
|
-
*
|
|
98
|
-
* @param data - String data to write
|
|
99
|
-
*/
|
|
100
|
-
write(data: string): void {
|
|
101
|
-
this.terminal?.write(data);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Write data to the terminal with newline.
|
|
106
|
-
*
|
|
107
|
-
* @param data - String data to write
|
|
108
|
-
*/
|
|
109
|
-
writeln(data: string): void {
|
|
110
|
-
this.terminal?.writeln(data);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Clear the terminal buffer.
|
|
115
|
-
*/
|
|
116
|
-
clear(): void {
|
|
117
|
-
this.terminal?.clear();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Resize the terminal to the given dimensions.
|
|
122
|
-
*
|
|
123
|
-
* @param cols - Number of columns
|
|
124
|
-
* @param rows - Number of rows
|
|
125
|
-
*/
|
|
126
|
-
resize(cols: number, rows: number): void {
|
|
127
|
-
this.terminal?.resize(cols, rows);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Dispose of the terminal and release resources.
|
|
132
|
-
*/
|
|
133
|
-
dispose(): void {
|
|
134
|
-
this.terminal?.dispose();
|
|
135
|
-
this.terminal = null;
|
|
136
|
-
this.fitAddon = null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Switch between interactive and readonly modes.
|
|
141
|
-
*
|
|
142
|
-
* @param mode - Target mode
|
|
143
|
-
*/
|
|
144
|
-
setMode(mode: ITerminalMode): void {
|
|
145
|
-
// xterm.js doesn't have a built-in readonly mode
|
|
146
|
-
// We handle this at the component level by not attaching onData handler
|
|
147
|
-
this.options = { ...this.options, mode };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Focus the terminal for input.
|
|
152
|
-
*/
|
|
153
|
-
focus(): void {
|
|
154
|
-
this.terminal?.focus();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Remove focus from the terminal.
|
|
159
|
-
*/
|
|
160
|
-
blur(): void {
|
|
161
|
-
this.terminal?.blur();
|
|
162
|
-
}
|
|
163
|
-
}
|