@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.
Files changed (262) hide show
  1. package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts +23 -4
  2. package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts.map +1 -1
  3. package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts +2 -2
  4. package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts.map +1 -1
  5. package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.js +292 -31
  6. package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts +7 -0
  7. package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts.map +1 -1
  8. package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.js +6 -1
  9. package/dist/react-ui/ui/DynamicToggle/{DynamicToggle-Cm6-VceQ.css → DynamicToggle-DJLwEkHr.css} +116 -51
  10. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.css +116 -51
  11. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts +1 -0
  12. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts.map +1 -1
  13. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.js +9 -3
  14. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts +61 -31
  15. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts.map +1 -1
  16. package/dist/react-ui/ui/DynamicToggle/index.d.ts +9 -3
  17. package/dist/react-ui/ui/DynamicToggle/index.d.ts.map +1 -1
  18. package/dist/react-ui/ui/DynamicToggle/index.js +68 -37
  19. package/package.json +52 -13
  20. package/src/assets/react.svg +0 -1
  21. package/src/core/index.ts +0 -7
  22. package/src/core/types.ts +0 -82
  23. package/src/css.d.ts +0 -7
  24. package/src/index.css +0 -129
  25. package/src/index.ts +0 -29
  26. package/src/react-ui/blocks/Terminal/ResttyAdapter.ts +0 -278
  27. package/src/react-ui/blocks/Terminal/Terminal.adapter.ts +0 -97
  28. package/src/react-ui/blocks/Terminal/Terminal.theme.restty.ts +0 -155
  29. package/src/react-ui/blocks/Terminal/Terminal.theme.ts +0 -80
  30. package/src/react-ui/blocks/Terminal/Terminal.types.ts +0 -438
  31. package/src/react-ui/blocks/Terminal/TerminalDisplay.styles.ts +0 -38
  32. package/src/react-ui/blocks/Terminal/TerminalDisplay.tsx +0 -254
  33. package/src/react-ui/blocks/Terminal/TerminalDisplay.types.ts +0 -73
  34. package/src/react-ui/blocks/Terminal/TerminalPanel.tsx +0 -269
  35. package/src/react-ui/blocks/Terminal/TerminalRestty.tsx +0 -326
  36. package/src/react-ui/blocks/Terminal/TerminalXterm.tsx +0 -230
  37. package/src/react-ui/blocks/Terminal/XTermAdapter.ts +0 -163
  38. package/src/react-ui/blocks/Terminal/chrome.ts +0 -25
  39. package/src/react-ui/blocks/Terminal/components/LogLineBadges.tsx +0 -316
  40. package/src/react-ui/blocks/Terminal/components/SpecializedSyntaxHighlighter.tsx +0 -218
  41. package/src/react-ui/blocks/Terminal/components/SyntaxHighlight.tsx +0 -386
  42. package/src/react-ui/blocks/Terminal/components/TerminalLogBadge.tsx +0 -67
  43. package/src/react-ui/blocks/Terminal/components/index.ts +0 -10
  44. package/src/react-ui/blocks/Terminal/display.ts +0 -46
  45. package/src/react-ui/blocks/Terminal/hooks/index.ts +0 -22
  46. package/src/react-ui/blocks/Terminal/hooks/useTerminalSettings.ts +0 -229
  47. package/src/react-ui/blocks/Terminal/hooks/useTerminalWebSocket.ts +0 -292
  48. package/src/react-ui/blocks/Terminal/index.ts +0 -111
  49. package/src/react-ui/blocks/Terminal/panel/LogLinesViewer.tsx +0 -330
  50. package/src/react-ui/blocks/Terminal/panel/TerminalDebugPanel.tsx +0 -242
  51. package/src/react-ui/blocks/Terminal/panel/TerminalFilterDropdown.tsx +0 -202
  52. package/src/react-ui/blocks/Terminal/panel/TerminalFilterTabs.tsx +0 -140
  53. package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanel.tsx +0 -68
  54. package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanel.types.ts +0 -85
  55. package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanelRestty.tsx +0 -383
  56. package/src/react-ui/blocks/Terminal/panel/TerminalInteractivePanelXterm.tsx +0 -439
  57. package/src/react-ui/blocks/Terminal/panel/TerminalLogsPanel.tsx +0 -550
  58. package/src/react-ui/blocks/Terminal/panel/TerminalLogsPanel.types.ts +0 -259
  59. package/src/react-ui/blocks/Terminal/panel/TerminalPanelChrome.styles.ts +0 -75
  60. package/src/react-ui/blocks/Terminal/panel/TerminalPanelChrome.tsx +0 -266
  61. package/src/react-ui/blocks/Terminal/panel/TerminalPanelChrome.types.ts +0 -82
  62. package/src/react-ui/blocks/Terminal/panel/TerminalPanelFooter.tsx +0 -112
  63. package/src/react-ui/blocks/Terminal/panel/TerminalPanelHeader.tsx +0 -178
  64. package/src/react-ui/blocks/Terminal/panel/TerminalPanelToolbar.tsx +0 -203
  65. package/src/react-ui/blocks/Terminal/panel/TerminalSessionControl.tsx +0 -252
  66. package/src/react-ui/blocks/Terminal/panel/TerminalSessionTabs.tsx +0 -334
  67. package/src/react-ui/blocks/Terminal/panel/TerminalSettingsPopover.tsx +0 -261
  68. package/src/react-ui/blocks/Terminal/panel/TerminalThemeSelector.tsx +0 -248
  69. package/src/react-ui/blocks/Terminal/panel/index.ts +0 -72
  70. package/src/react-ui/blocks/Terminal/panel/terminal-filter-dropdown.module.css +0 -59
  71. package/src/react-ui/blocks/Terminal/panel/terminal-session-tabs.module.css +0 -59
  72. package/src/react-ui/blocks/Terminal/parsing/BadgeFormatter.ts +0 -180
  73. package/src/react-ui/blocks/Terminal/parsing/HttpLogParser.ts +0 -248
  74. package/src/react-ui/blocks/Terminal/parsing/LogParser.types.ts +0 -283
  75. package/src/react-ui/blocks/Terminal/parsing/LogParserService.ts +0 -686
  76. package/src/react-ui/blocks/Terminal/parsing/MultilineAggregator.ts +0 -466
  77. package/src/react-ui/blocks/Terminal/parsing/PersistentLogBuffer.ts +0 -343
  78. package/src/react-ui/blocks/Terminal/parsing/SyntaxHighlighter.ts +0 -167
  79. package/src/react-ui/blocks/Terminal/parsing/TableParser.ts +0 -348
  80. package/src/react-ui/blocks/Terminal/parsing/ansi/AnsiColorMapper.ts +0 -251
  81. package/src/react-ui/blocks/Terminal/parsing/ansi/AnsiParser.ts +0 -390
  82. package/src/react-ui/blocks/Terminal/parsing/ansi/ansi.constants.ts +0 -320
  83. package/src/react-ui/blocks/Terminal/parsing/ansi/index.ts +0 -20
  84. package/src/react-ui/blocks/Terminal/parsing/index.ts +0 -69
  85. package/src/react-ui/blocks/Terminal/parsing/levels/LogLevel.types.ts +0 -68
  86. package/src/react-ui/blocks/Terminal/parsing/levels/LogLevelDetector.ts +0 -436
  87. package/src/react-ui/blocks/Terminal/parsing/levels/index.ts +0 -14
  88. package/src/react-ui/blocks/index.ts +0 -11
  89. package/src/react-ui/components/MorphingPopover/MorphingPopover.types.ts +0 -49
  90. package/src/react-ui/components/MorphingPopover/index.tsx +0 -186
  91. package/src/react-ui/components/MorphingPopover/morphing-popover.module.css +0 -153
  92. package/src/react-ui/components/index.ts +0 -9
  93. package/src/react-ui/hooks/Animation/UseAutoHeight.tsx +0 -123
  94. package/src/react-ui/hooks/DOM/UseIsInView.tsx +0 -44
  95. package/src/react-ui/hooks/Formatting/UseListFormat.ts +0 -134
  96. package/src/react-ui/hooks/State/UseControlledState.tsx +0 -57
  97. package/src/react-ui/hooks/State/UseDataState.tsx +0 -76
  98. package/src/react-ui/hooks/index.ts +0 -20
  99. package/src/react-ui/icons/index.ts +0 -12
  100. package/src/react-ui/icons/lucide-animated/activity.tsx +0 -109
  101. package/src/react-ui/icons/lucide-animated/arrow-down-to-line.tsx +0 -51
  102. package/src/react-ui/icons/lucide-animated/arrow-up.tsx +0 -50
  103. package/src/react-ui/icons/lucide-animated/bell-electric.tsx +0 -124
  104. package/src/react-ui/icons/lucide-animated/bell.tsx +0 -93
  105. package/src/react-ui/icons/lucide-animated/bot.tsx +0 -122
  106. package/src/react-ui/icons/lucide-animated/box.tsx +0 -117
  107. package/src/react-ui/icons/lucide-animated/check.tsx +0 -21
  108. package/src/react-ui/icons/lucide-animated/circle-check.tsx +0 -107
  109. package/src/react-ui/icons/lucide-animated/delete.tsx +0 -133
  110. package/src/react-ui/icons/lucide-animated/download.tsx +0 -99
  111. package/src/react-ui/icons/lucide-animated/edit-2.tsx +0 -21
  112. package/src/react-ui/icons/lucide-animated/globe.tsx +0 -23
  113. package/src/react-ui/icons/lucide-animated/home.tsx +0 -103
  114. package/src/react-ui/icons/lucide-animated/index.ts +0 -38
  115. package/src/react-ui/icons/lucide-animated/layers.tsx +0 -23
  116. package/src/react-ui/icons/lucide-animated/layout-panel-top.tsx +0 -143
  117. package/src/react-ui/icons/lucide-animated/list.tsx +0 -54
  118. package/src/react-ui/icons/lucide-animated/package.tsx +0 -24
  119. package/src/react-ui/icons/lucide-animated/palette.tsx +0 -25
  120. package/src/react-ui/icons/lucide-animated/plus.tsx +0 -92
  121. package/src/react-ui/icons/lucide-animated/refresh-cw.tsx +0 -24
  122. package/src/react-ui/icons/lucide-animated/rocket.tsx +0 -24
  123. package/src/react-ui/icons/lucide-animated/save.tsx +0 -23
  124. package/src/react-ui/icons/lucide-animated/search.tsx +0 -94
  125. package/src/react-ui/icons/lucide-animated/settings.tsx +0 -92
  126. package/src/react-ui/icons/lucide-animated/terminal.tsx +0 -46
  127. package/src/react-ui/icons/lucide-animated/trash-2.tsx +0 -25
  128. package/src/react-ui/icons/lucide-animated/trending-down.tsx +0 -151
  129. package/src/react-ui/icons/lucide-animated/trending-up.tsx +0 -150
  130. package/src/react-ui/icons/lucide-animated/type.tsx +0 -23
  131. package/src/react-ui/icons/lucide-animated/upload.tsx +0 -23
  132. package/src/react-ui/icons/lucide-animated/x.tsx +0 -102
  133. package/src/react-ui/index.ts +0 -30
  134. package/src/react-ui/lib/get-strict-context.tsx +0 -56
  135. package/src/react-ui/lib/icon-wrapper.tsx +0 -70
  136. package/src/react-ui/lib/index.ts +0 -9
  137. package/src/react-ui/lib/utils.ts +0 -24
  138. package/src/react-ui/primitives/AutoHeight/index.tsx +0 -74
  139. package/src/react-ui/primitives/CountingNumber/index.tsx +0 -147
  140. package/src/react-ui/primitives/Highlight/Highlight.types.ts +0 -136
  141. package/src/react-ui/primitives/Highlight/index.tsx +0 -577
  142. package/src/react-ui/primitives/Slot/index.tsx +0 -128
  143. package/src/react-ui/primitives/index.ts +0 -16
  144. package/src/react-ui/primitives/waapi/Gooey/Gooey.types.ts +0 -123
  145. package/src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx +0 -80
  146. package/src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx +0 -77
  147. package/src/react-ui/primitives/waapi/Gooey/MorphPath.tsx +0 -58
  148. package/src/react-ui/primitives/waapi/Gooey/gooey-utils.ts +0 -244
  149. package/src/react-ui/primitives/waapi/Gooey/index.ts +0 -50
  150. package/src/react-ui/primitives/waapi/Gooey/useMorphPath.ts +0 -48
  151. package/src/react-ui/primitives/waapi/Morph/Morph.types.ts +0 -106
  152. package/src/react-ui/primitives/waapi/Morph/MorphContext.tsx +0 -21
  153. package/src/react-ui/primitives/waapi/Morph/index.tsx +0 -56
  154. package/src/react-ui/primitives/waapi/Morph/techniques/index.ts +0 -12
  155. package/src/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.ts +0 -89
  156. package/src/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.ts +0 -176
  157. package/src/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.ts +0 -87
  158. package/src/react-ui/primitives/waapi/Morph/useMorph.ts +0 -101
  159. package/src/react-ui/primitives/waapi/Reorder/Reorder.types.ts +0 -177
  160. package/src/react-ui/primitives/waapi/Reorder/index.tsx +0 -260
  161. package/src/react-ui/primitives/waapi/Reorder/useReorder.ts +0 -47
  162. package/src/react-ui/primitives/waapi/Reorder/useReorderPresence.ts +0 -209
  163. package/src/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.ts +0 -104
  164. package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.ts +0 -14
  165. package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.ts +0 -84
  166. package/src/react-ui/primitives/waapi/SlidingNumber/index.tsx +0 -474
  167. package/src/react-ui/primitives/waapi/SlidingText/SlidingText.styles.ts +0 -32
  168. package/src/react-ui/primitives/waapi/SlidingText/SlidingText.types.ts +0 -69
  169. package/src/react-ui/primitives/waapi/SlidingText/index.tsx +0 -140
  170. package/src/react-ui/primitives/waapi/core/animationConstants.ts +0 -215
  171. package/src/react-ui/primitives/waapi/core/index.ts +0 -53
  172. package/src/react-ui/primitives/waapi/core/types.ts +0 -200
  173. package/src/react-ui/primitives/waapi/core/useAnimationOrchestrator.ts +0 -430
  174. package/src/react-ui/primitives/waapi/core/useElementRegistry.ts +0 -81
  175. package/src/react-ui/primitives/waapi/core/useFLIPAnimation.ts +0 -138
  176. package/src/react-ui/primitives/waapi/core/usePositionCapture.ts +0 -106
  177. package/src/react-ui/primitives/waapi/index.ts +0 -139
  178. package/src/react-ui/styles/animations.css +0 -369
  179. package/src/react-ui/ui/Accordion/Accordion.styles.ts +0 -72
  180. package/src/react-ui/ui/Accordion/Accordion.types.ts +0 -199
  181. package/src/react-ui/ui/Accordion/index.tsx +0 -362
  182. package/src/react-ui/ui/AlertDialog/AlertDialog.styles.ts +0 -38
  183. package/src/react-ui/ui/AlertDialog/AlertDialog.types.ts +0 -296
  184. package/src/react-ui/ui/AlertDialog/index.tsx +0 -540
  185. package/src/react-ui/ui/Badge/Badge.styles.ts +0 -43
  186. package/src/react-ui/ui/Badge/Badge.types.ts +0 -26
  187. package/src/react-ui/ui/Badge/index.tsx +0 -34
  188. package/src/react-ui/ui/Button/Button.styles.ts +0 -57
  189. package/src/react-ui/ui/Button/Button.types.ts +0 -63
  190. package/src/react-ui/ui/Button/index.tsx +0 -155
  191. package/src/react-ui/ui/Card/Card.styles.ts +0 -32
  192. package/src/react-ui/ui/Card/Card.types.ts +0 -39
  193. package/src/react-ui/ui/Card/index.tsx +0 -130
  194. package/src/react-ui/ui/Checkbox/Checkbox.styles.ts +0 -40
  195. package/src/react-ui/ui/Checkbox/Checkbox.types.ts +0 -98
  196. package/src/react-ui/ui/Checkbox/index.tsx +0 -233
  197. package/src/react-ui/ui/Combobox/Combobox.styles.ts +0 -34
  198. package/src/react-ui/ui/Combobox/Combobox.types.ts +0 -89
  199. package/src/react-ui/ui/Combobox/index.tsx +0 -331
  200. package/src/react-ui/ui/CornerBracket/CornerBracket.styles.ts +0 -38
  201. package/src/react-ui/ui/CornerBracket/CornerBracket.types.ts +0 -15
  202. package/src/react-ui/ui/CornerBracket/index.tsx +0 -49
  203. package/src/react-ui/ui/DataCard/DataCard.styles.ts +0 -94
  204. package/src/react-ui/ui/DataCard/DataCard.types.ts +0 -125
  205. package/src/react-ui/ui/DataCard/index.tsx +0 -340
  206. package/src/react-ui/ui/Dialog/Dialog.styles.ts +0 -59
  207. package/src/react-ui/ui/Dialog/Dialog.types.ts +0 -284
  208. package/src/react-ui/ui/Dialog/index.tsx +0 -452
  209. package/src/react-ui/ui/DropdownMenu/DropdownMenu.styles.ts +0 -35
  210. package/src/react-ui/ui/DropdownMenu/DropdownMenu.types.ts +0 -81
  211. package/src/react-ui/ui/DropdownMenu/index.tsx +0 -300
  212. package/src/react-ui/ui/DynamicToggle/DynamicToggle.css +0 -303
  213. package/src/react-ui/ui/DynamicToggle/DynamicToggle.styles.ts +0 -85
  214. package/src/react-ui/ui/DynamicToggle/DynamicToggle.types.ts +0 -174
  215. package/src/react-ui/ui/DynamicToggle/index.tsx +0 -294
  216. package/src/react-ui/ui/DynamicToggle/prototype-v7.html +0 -615
  217. package/src/react-ui/ui/DynamicToggle/prototype.html +0 -419
  218. package/src/react-ui/ui/Field/Field.styles.ts +0 -47
  219. package/src/react-ui/ui/Field/Field.types.ts +0 -60
  220. package/src/react-ui/ui/Field/index.tsx +0 -254
  221. package/src/react-ui/ui/Input/Input.styles.ts +0 -11
  222. package/src/react-ui/ui/Input/Input.types.ts +0 -10
  223. package/src/react-ui/ui/Input/index.tsx +0 -32
  224. package/src/react-ui/ui/InputGroup/InputGroup.styles.ts +0 -53
  225. package/src/react-ui/ui/InputGroup/InputGroup.types.ts +0 -44
  226. package/src/react-ui/ui/InputGroup/index.tsx +0 -149
  227. package/src/react-ui/ui/Label/Label.styles.ts +0 -10
  228. package/src/react-ui/ui/Label/Label.types.ts +0 -9
  229. package/src/react-ui/ui/Label/index.tsx +0 -27
  230. package/src/react-ui/ui/Menu/Menu.styles.ts +0 -71
  231. package/src/react-ui/ui/Menu/Menu.types.ts +0 -425
  232. package/src/react-ui/ui/Menu/index.tsx +0 -900
  233. package/src/react-ui/ui/Popover/Popover.styles.ts +0 -55
  234. package/src/react-ui/ui/Popover/Popover.types.ts +0 -261
  235. package/src/react-ui/ui/Popover/index.tsx +0 -422
  236. package/src/react-ui/ui/Progress/Progress.styles.ts +0 -36
  237. package/src/react-ui/ui/Progress/Progress.types.ts +0 -162
  238. package/src/react-ui/ui/Progress/index.tsx +0 -254
  239. package/src/react-ui/ui/Select/Select.styles.ts +0 -30
  240. package/src/react-ui/ui/Select/Select.types.ts +0 -51
  241. package/src/react-ui/ui/Select/index.tsx +0 -225
  242. package/src/react-ui/ui/Separator/Separator.styles.ts +0 -10
  243. package/src/react-ui/ui/Separator/Separator.types.ts +0 -10
  244. package/src/react-ui/ui/Separator/index.tsx +0 -37
  245. package/src/react-ui/ui/Switch/Switch.styles.ts +0 -50
  246. package/src/react-ui/ui/Switch/Switch.types.ts +0 -155
  247. package/src/react-ui/ui/Switch/index.tsx +0 -253
  248. package/src/react-ui/ui/Tabs/Tabs.css +0 -39
  249. package/src/react-ui/ui/Tabs/Tabs.styles.ts +0 -148
  250. package/src/react-ui/ui/Tabs/Tabs.types.ts +0 -255
  251. package/src/react-ui/ui/Tabs/index.tsx +0 -529
  252. package/src/react-ui/ui/TextFlow/TextFlow.styles.ts +0 -36
  253. package/src/react-ui/ui/TextFlow/TextFlow.types.ts +0 -118
  254. package/src/react-ui/ui/TextFlow/index.tsx +0 -276
  255. package/src/react-ui/ui/Textarea/Textarea.styles.ts +0 -10
  256. package/src/react-ui/ui/Textarea/Textarea.types.ts +0 -9
  257. package/src/react-ui/ui/Textarea/index.tsx +0 -27
  258. package/src/react-ui/ui/Tooltip/Tooltip.styles.ts +0 -43
  259. package/src/react-ui/ui/Tooltip/Tooltip.types.ts +0 -253
  260. package/src/react-ui/ui/Tooltip/index.tsx +0 -394
  261. package/src/react-ui/ui/index.ts +0 -41
  262. package/src/types/css-modules.d.ts +0 -18
@@ -1,229 +0,0 @@
1
- /**
2
- * Global terminal settings hook with localStorage persistence.
3
- *
4
- * Manages renderer, PTY backend, theme, and font size preferences
5
- * using `useSyncExternalStore` for SSR safety and cross-component sync.
6
- *
7
- * @module components/devenv/terminal/hooks/useTerminalSettings
8
- */
9
-
10
- import { useSyncExternalStore, useCallback } from 'react';
11
- import type { ITerminalRendererType, ITerminalPtyBackendType } from '../Terminal.types';
12
-
13
- /**
14
- * Persisted terminal settings.
15
- */
16
- export interface ITerminalSettings {
17
- /** Terminal renderer engine (default: 'xterm') */
18
- renderer: ITerminalRendererType;
19
-
20
- /** PTY backend type (default: 'nodepty') */
21
- ptyBackend: ITerminalPtyBackendType;
22
-
23
- /** Restty built-in theme name (default: 'Synthwave Alpha') */
24
- resttyThemeName: string;
25
-
26
- /** Font size in CSS pixels (default: 14) */
27
- fontSize: number;
28
-
29
- /** Enable CRT shader effects (scanlines, bloom, vignette) */
30
- crtEffect: boolean;
31
-
32
- /** Show debug panel below the terminal */
33
- debugPanel: boolean;
34
- }
35
-
36
- /**
37
- * Return type for the useTerminalSettings hook.
38
- */
39
- export interface IUseTerminalSettingsReturn {
40
- /** Current settings snapshot */
41
- settings: ITerminalSettings;
42
-
43
- /** Switch terminal renderer */
44
- setRenderer: (renderer: ITerminalRendererType) => void;
45
-
46
- /** Switch PTY backend */
47
- setPtyBackend: (backend: ITerminalPtyBackendType) => void;
48
-
49
- /** Set restty built-in theme by name */
50
- setResttyThemeName: (name: string) => void;
51
-
52
- /** Set font size (clamped to 10-24) */
53
- setFontSize: (size: number) => void;
54
-
55
- /** Toggle CRT shader effects (scanlines, bloom, vignette) */
56
- setCrtEffect: (enabled: boolean) => void;
57
-
58
- /** Toggle debug panel visibility */
59
- setDebugPanel: (enabled: boolean) => void;
60
-
61
- /** Reset all settings to defaults */
62
- resetToDefaults: () => void;
63
- }
64
-
65
- /** localStorage key for terminal settings */
66
- const STORAGE_KEY = 'mks-terminal-settings';
67
-
68
- /** Min/max font size bounds */
69
- const MIN_FONT_SIZE = 10;
70
- const MAX_FONT_SIZE = 24;
71
-
72
- /**
73
- * Default terminal settings.
74
- */
75
- const DEFAULT_SETTINGS: ITerminalSettings = {
76
- renderer: 'xterm',
77
- ptyBackend: 'nodepty',
78
- resttyThemeName: 'Synthwave Alpha',
79
- fontSize: 14,
80
- crtEffect: false,
81
- debugPanel: false,
82
- };
83
-
84
- /** Set of subscribed listeners for useSyncExternalStore */
85
- const listeners = new Set<() => void>();
86
-
87
- /** Cached settings snapshot — avoids re-parsing on every subscribe call */
88
- let cachedSettings: ITerminalSettings | null = null;
89
-
90
- /**
91
- * Notify all subscribers that settings have changed.
92
- */
93
- function emitChange(): void {
94
- cachedSettings = null;
95
- for (const listener of listeners) {
96
- listener();
97
- }
98
- }
99
-
100
- /**
101
- * Read current settings from localStorage with fallback to defaults.
102
- */
103
- function readSettings(): ITerminalSettings {
104
- if (cachedSettings) return cachedSettings;
105
-
106
- try {
107
- const raw = localStorage.getItem(STORAGE_KEY);
108
- if (!raw) {
109
- cachedSettings = DEFAULT_SETTINGS;
110
- return DEFAULT_SETTINGS;
111
- }
112
-
113
- const parsed = JSON.parse(raw) as Partial<ITerminalSettings>;
114
- cachedSettings = {
115
- renderer: parsed.renderer === 'restty' ? 'restty' : 'xterm',
116
- ptyBackend: parsed.ptyBackend === 'webcontainer' ? 'webcontainer' : 'nodepty',
117
- resttyThemeName: typeof parsed.resttyThemeName === 'string' ? parsed.resttyThemeName : DEFAULT_SETTINGS.resttyThemeName,
118
- fontSize: typeof parsed.fontSize === 'number'
119
- ? Math.min(MAX_FONT_SIZE, Math.max(MIN_FONT_SIZE, parsed.fontSize))
120
- : DEFAULT_SETTINGS.fontSize,
121
- crtEffect: typeof parsed.crtEffect === 'boolean' ? parsed.crtEffect : DEFAULT_SETTINGS.crtEffect,
122
- debugPanel: typeof parsed.debugPanel === 'boolean' ? parsed.debugPanel : DEFAULT_SETTINGS.debugPanel,
123
- };
124
- return cachedSettings;
125
- } catch {
126
- cachedSettings = DEFAULT_SETTINGS;
127
- return DEFAULT_SETTINGS;
128
- }
129
- }
130
-
131
- /**
132
- * Write settings to localStorage and notify subscribers.
133
- *
134
- * @param settings - Settings object to persist
135
- */
136
- function writeSettings(settings: ITerminalSettings): void {
137
- try {
138
- localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
139
- } catch {
140
- // localStorage unavailable — settings stay in-memory only
141
- }
142
- emitChange();
143
- }
144
-
145
- /**
146
- * Subscribe function for useSyncExternalStore.
147
- */
148
- function subscribe(listener: () => void): () => void {
149
- listeners.add(listener);
150
- return () => listeners.delete(listener);
151
- }
152
-
153
- /**
154
- * Snapshot function for useSyncExternalStore.
155
- */
156
- function getSnapshot(): ITerminalSettings {
157
- return readSettings();
158
- }
159
-
160
- /**
161
- * Server snapshot — returns defaults (SSR-safe).
162
- */
163
- function getServerSnapshot(): ITerminalSettings {
164
- return DEFAULT_SETTINGS;
165
- }
166
-
167
- /**
168
- * Hook for reading and mutating global terminal settings.
169
- *
170
- * Settings persist to localStorage and sync across all components
171
- * using `useSyncExternalStore`. SSR-safe via `getServerSnapshot`.
172
- *
173
- * @returns Settings state and mutation functions
174
- *
175
- * @example
176
- * ```tsx
177
- * const { settings, setRenderer, setResttyThemeName } = useTerminalSettings();
178
- *
179
- * // Read
180
- * console.log(settings.renderer); // 'xterm' | 'restty'
181
- *
182
- * // Mutate — triggers re-render in all consumers
183
- * setRenderer('restty');
184
- * setResttyThemeName('Dracula');
185
- * ```
186
- */
187
- export function useTerminalSettings(): IUseTerminalSettingsReturn {
188
- const settings = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
189
-
190
- const setRenderer = useCallback((renderer: ITerminalRendererType) => {
191
- writeSettings({ ...readSettings(), renderer });
192
- }, []);
193
-
194
- const setPtyBackend = useCallback((ptyBackend: ITerminalPtyBackendType) => {
195
- writeSettings({ ...readSettings(), ptyBackend });
196
- }, []);
197
-
198
- const setResttyThemeName = useCallback((resttyThemeName: string) => {
199
- writeSettings({ ...readSettings(), resttyThemeName });
200
- }, []);
201
-
202
- const setFontSize = useCallback((fontSize: number) => {
203
- const clamped = Math.min(MAX_FONT_SIZE, Math.max(MIN_FONT_SIZE, fontSize));
204
- writeSettings({ ...readSettings(), fontSize: clamped });
205
- }, []);
206
-
207
- const setCrtEffect = useCallback((enabled: boolean) => {
208
- writeSettings({ ...readSettings(), crtEffect: enabled });
209
- }, []);
210
-
211
- const setDebugPanel = useCallback((enabled: boolean) => {
212
- writeSettings({ ...readSettings(), debugPanel: enabled });
213
- }, []);
214
-
215
- const resetToDefaults = useCallback(() => {
216
- writeSettings({ ...DEFAULT_SETTINGS });
217
- }, []);
218
-
219
- return {
220
- settings,
221
- setRenderer,
222
- setPtyBackend,
223
- setResttyThemeName,
224
- setFontSize,
225
- setCrtEffect,
226
- setDebugPanel,
227
- resetToDefaults,
228
- };
229
- }
@@ -1,292 +0,0 @@
1
- /**
2
- * useTerminalWebSocket Hook.
3
- *
4
- * Manages WebSocket lifecycle for interactive terminal connections.
5
- * Handles connect, disconnect, auto-reconnect with exponential backoff,
6
- * and message send/receive for terminal I/O.
7
- *
8
- * @module components/devenv/terminal/hooks/useTerminalWebSocket
9
- */
10
-
11
- 'use client';
12
-
13
- import { useRef, useState, useCallback, useEffect } from 'react';
14
-
15
- /**
16
- * Connection status for terminal WebSocket.
17
- */
18
- export type TTerminalWsStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
19
-
20
- /**
21
- * Options for useTerminalWebSocket hook.
22
- */
23
- export interface IUseTerminalWebSocketOptions {
24
- /** WebSocket URL (ws:// or wss://) */
25
- wsUrl: string;
26
-
27
- /** Enable auto-reconnect on disconnect (default: true) */
28
- autoReconnect?: boolean;
29
-
30
- /** Maximum reconnect attempts (default: 3) */
31
- maxReconnectAttempts?: number;
32
-
33
- /** Base delay for exponential backoff in ms (default: 500) */
34
- baseReconnectDelay?: number;
35
-
36
- /** Callback when connection opens */
37
- onConnect?: () => void;
38
-
39
- /** Callback when connection closes */
40
- onDisconnect?: () => void;
41
-
42
- /** Callback when output data is received */
43
- onOutput?: (data: string) => void;
44
-
45
- /** Callback when an error message is received */
46
- onError?: (error: string) => void;
47
-
48
- /** Callback when any server message is received */
49
- onMessage?: (message: ITerminalWsServerMessage) => void;
50
- }
51
-
52
- /**
53
- * Return value from useTerminalWebSocket hook.
54
- */
55
- export interface IUseTerminalWebSocketReturn {
56
- /** Current connection status */
57
- status: TTerminalWsStatus;
58
-
59
- /** Send raw input data to server */
60
- sendInput: (data: string) => void;
61
-
62
- /** Send resize event to server */
63
- sendResize: (cols: number, rows: number) => void;
64
-
65
- /** Send attach to session */
66
- sendAttach: (sessionId: string) => void;
67
-
68
- /** Send create session request */
69
- sendCreate: (options?: { name?: string; workspaceId?: string; cwd?: string }) => void;
70
-
71
- /** Send kill session request */
72
- sendKill: (sessionId: string) => void;
73
-
74
- /** Send detach from current session */
75
- sendDetach: () => void;
76
-
77
- /** Manually reconnect */
78
- reconnect: () => void;
79
-
80
- /** Manually disconnect */
81
- disconnect: () => void;
82
- }
83
-
84
- /**
85
- * Server → Client message types.
86
- */
87
- export interface ITerminalWsServerMessage {
88
- type: 'welcome' | 'attached' | 'detached' | 'created' | 'output' | 'error' | 'sessions' | 'killed' | 'resized';
89
- sessionId?: string;
90
- session?: string;
91
- data?: string;
92
- error?: string;
93
- sessions?: Array<{ id: string; name: string; isActive: boolean }>;
94
- }
95
-
96
- /**
97
- * Client → Server message types.
98
- */
99
- type TTerminalWsClientMessage =
100
- | { type: 'attach'; session: string }
101
- | { type: 'detach' }
102
- | { type: 'create'; name?: string; workspaceId?: string; cwd?: string }
103
- | { type: 'input'; data: string }
104
- | { type: 'resize'; cols: number; rows: number; session?: string }
105
- | { type: 'kill'; session: string }
106
- | { type: 'list' };
107
-
108
- /**
109
- * useTerminalWebSocket - WebSocket hook for interactive terminal connections.
110
- *
111
- * Manages the full WebSocket lifecycle including connection establishment,
112
- * reconnection with exponential backoff, and typed message send/receive.
113
- *
114
- * @param options - Hook configuration options
115
- * @returns Connection status and message send functions
116
- *
117
- * @example
118
- * ```tsx
119
- * const { status, sendInput, sendResize, sendAttach } = useTerminalWebSocket({
120
- * wsUrl: 'ws://localhost:3100/terminal/session-1',
121
- * onOutput: (data) => terminal.write(data),
122
- * onConnect: () => console.log('Connected'),
123
- * });
124
- *
125
- * // Send user input
126
- * terminal.onData((data) => sendInput(data));
127
- *
128
- * // Send resize
129
- * terminal.onResize(({ cols, rows }) => sendResize(cols, rows));
130
- * ```
131
- */
132
- export function useTerminalWebSocket(options: IUseTerminalWebSocketOptions): IUseTerminalWebSocketReturn {
133
- const {
134
- wsUrl,
135
- autoReconnect = true,
136
- maxReconnectAttempts = 3,
137
- baseReconnectDelay = 500,
138
- onConnect,
139
- onDisconnect,
140
- onOutput,
141
- onError,
142
- onMessage,
143
- } = options;
144
-
145
- const [status, setStatus] = useState<TTerminalWsStatus>('disconnected');
146
- const wsRef = useRef<WebSocket | null>(null);
147
- const reconnectAttemptsRef = useRef(0);
148
- const reconnectTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
149
- const intentionalCloseRef = useRef(false);
150
-
151
- /**
152
- * Send a typed message over the WebSocket.
153
- */
154
- const sendMessage = useCallback((message: TTerminalWsClientMessage) => {
155
- if (wsRef.current?.readyState === WebSocket.OPEN) {
156
- wsRef.current.send(JSON.stringify(message));
157
- }
158
- }, []);
159
-
160
- /**
161
- * Connect to the WebSocket server.
162
- */
163
- const connect = useCallback(() => {
164
- // Cleanup existing connection
165
- if (wsRef.current) {
166
- intentionalCloseRef.current = true;
167
- wsRef.current.close();
168
- wsRef.current = null;
169
- }
170
-
171
- intentionalCloseRef.current = false;
172
- setStatus('connecting');
173
-
174
- const ws = new WebSocket(wsUrl);
175
- wsRef.current = ws;
176
-
177
- ws.onopen = () => {
178
- setStatus('connected');
179
- reconnectAttemptsRef.current = 0;
180
- onConnect?.();
181
- };
182
-
183
- ws.onmessage = (event) => {
184
- try {
185
- const message: ITerminalWsServerMessage = JSON.parse(
186
- typeof event.data === 'string' ? event.data : event.data.toString()
187
- );
188
-
189
- onMessage?.(message);
190
-
191
- switch (message.type) {
192
- case 'output':
193
- if (message.data) {
194
- onOutput?.(message.data);
195
- }
196
- break;
197
- case 'error':
198
- if (message.error) {
199
- onError?.(message.error);
200
- }
201
- break;
202
- default:
203
- break;
204
- }
205
- } catch {
206
- // Raw text data - treat as output
207
- onOutput?.(typeof event.data === 'string' ? event.data : event.data.toString());
208
- }
209
- };
210
-
211
- ws.onerror = () => {
212
- setStatus('error');
213
- };
214
-
215
- ws.onclose = () => {
216
- wsRef.current = null;
217
-
218
- if (intentionalCloseRef.current) {
219
- setStatus('disconnected');
220
- onDisconnect?.();
221
- return;
222
- }
223
-
224
- setStatus('disconnected');
225
- onDisconnect?.();
226
-
227
- // Auto-reconnect with exponential backoff
228
- if (autoReconnect && reconnectAttemptsRef.current < maxReconnectAttempts) {
229
- const delay = baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current);
230
- reconnectAttemptsRef.current += 1;
231
-
232
- reconnectTimerRef.current = setTimeout(() => {
233
- connect();
234
- }, delay);
235
- }
236
- };
237
- }, [wsUrl, autoReconnect, maxReconnectAttempts, baseReconnectDelay, onConnect, onDisconnect, onOutput, onError, onMessage]);
238
-
239
- /**
240
- * Disconnect from the WebSocket server.
241
- */
242
- const disconnect = useCallback(() => {
243
- if (reconnectTimerRef.current) {
244
- clearTimeout(reconnectTimerRef.current);
245
- reconnectTimerRef.current = null;
246
- }
247
-
248
- intentionalCloseRef.current = true;
249
- reconnectAttemptsRef.current = maxReconnectAttempts; // Prevent auto-reconnect
250
-
251
- if (wsRef.current) {
252
- wsRef.current.close();
253
- wsRef.current = null;
254
- }
255
-
256
- setStatus('disconnected');
257
- }, [maxReconnectAttempts]);
258
-
259
- /**
260
- * Manually trigger reconnection.
261
- */
262
- const reconnect = useCallback(() => {
263
- reconnectAttemptsRef.current = 0;
264
- connect();
265
- }, [connect]);
266
-
267
- // Connect on mount, disconnect on unmount
268
- useEffect(() => {
269
- connect();
270
-
271
- return () => {
272
- if (reconnectTimerRef.current) {
273
- clearTimeout(reconnectTimerRef.current);
274
- }
275
- intentionalCloseRef.current = true;
276
- wsRef.current?.close();
277
- wsRef.current = null;
278
- };
279
- }, [connect]);
280
-
281
- return {
282
- status,
283
- sendInput: useCallback((data: string) => sendMessage({ type: 'input', data }), [sendMessage]),
284
- sendResize: useCallback((cols: number, rows: number) => sendMessage({ type: 'resize', cols, rows }), [sendMessage]),
285
- sendAttach: useCallback((sessionId: string) => sendMessage({ type: 'attach', session: sessionId }), [sendMessage]),
286
- sendCreate: useCallback((opts) => sendMessage({ type: 'create', ...opts }), [sendMessage]),
287
- sendKill: useCallback((sessionId: string) => sendMessage({ type: 'kill', session: sessionId }), [sendMessage]),
288
- sendDetach: useCallback(() => sendMessage({ type: 'detach' }), [sendMessage]),
289
- reconnect,
290
- disconnect,
291
- };
292
- }
@@ -1,111 +0,0 @@
1
- /**
2
- * Terminal Block barrel export.
3
- *
4
- * Full-featured terminal UI with xterm.js and restty GPU renderers,
5
- * log parsing, ANSI handling, multi-session panels, and glassmorphism chrome.
6
- *
7
- * NOTE: This module uses xterm.js/restty which are browser-only.
8
- * Consumers must load this module client-side only (e.g. next/dynamic with { ssr: false }).
9
- *
10
- * @module @mks2508/mks-ui/react/blocks/Terminal
11
- */
12
-
13
- // Main component
14
- export { TerminalPanel, type ITerminalPanelProps } from './TerminalPanel';
15
-
16
- // Parsing module
17
- export * from './parsing';
18
-
19
- // React badge and syntax highlighting components
20
- export * from './components';
21
-
22
- // Hooks
23
- export {
24
- useTerminalWebSocket,
25
- type IUseTerminalWebSocketOptions,
26
- type IUseTerminalWebSocketReturn,
27
- type ITerminalWsServerMessage,
28
- type TTerminalWsStatus,
29
- useTerminalSettings,
30
- type ITerminalSettings,
31
- type IUseTerminalSettingsReturn,
32
- } from './hooks';
33
-
34
- // Panel components
35
- export { TerminalLogsPanel } from './panel/TerminalLogsPanel';
36
- export { TerminalInteractivePanel } from './panel/TerminalInteractivePanel';
37
- export { TerminalInteractivePanelRestty } from './panel/TerminalInteractivePanelRestty';
38
- export { TerminalPanelChrome, NOISE_TEXTURE_SVG, terminalScrollStyles } from './panel/TerminalPanelChrome';
39
- export { TerminalPanelHeader } from './panel/TerminalPanelHeader';
40
- export { TerminalPanelFooter } from './panel/TerminalPanelFooter';
41
- export { LogLinesViewer } from './panel/LogLinesViewer';
42
-
43
- // Settings UI
44
- export { TerminalSettingsPopover } from './panel/TerminalSettingsPopover';
45
- export { TerminalThemeSelector } from './panel/TerminalThemeSelector';
46
-
47
- // Restty adapter
48
- export { ResttyAdapter } from './ResttyAdapter';
49
-
50
- // Restty React wrapper
51
- export { TerminalRestty, type ITerminalResttyProps, type ITerminalResttyRef } from './TerminalRestty';
52
-
53
- // Theme
54
- export { SYNTHWAVE_TERMINAL_THEME, getTerminalTheme } from './Terminal.theme';
55
-
56
- // Restty theme bridge
57
- export {
58
- hexToResttyColor,
59
- xtermThemeToGhostty,
60
- getSynthwaveGhosttyTheme,
61
- type IResttyThemeColor,
62
- type IResttyGhosttyTheme,
63
- } from './Terminal.theme.restty';
64
-
65
- // Adapters
66
- export { createTerminalAdapter, createTerminalAdapterForRenderer } from './Terminal.adapter';
67
- export { XTermAdapter } from './XTermAdapter';
68
-
69
- // XTerm wrapper
70
- export { XTermWrapper, type IXTermWrapperProps, useTerminalSearch } from './TerminalXterm';
71
-
72
- // Types
73
- export type {
74
- ITerminalRendererType,
75
- ITerminalPtyBackendType,
76
- ITerminalBackendType,
77
- ITerminalMode,
78
- ITerminalConnectionStatus,
79
- ITerminalSession,
80
- ITerminalOptions,
81
- ITerminalTheme,
82
- ITerminalAdapter,
83
- ITerminalAdapterCapabilities,
84
- IPtyTransport,
85
- IPtyTransportFactory,
86
- IPtyTransportCallbacks,
87
- IPtyTransportConnectOptions,
88
- } from './Terminal.types';
89
-
90
- export type { ITerminalPanelChromeProps } from './panel/TerminalPanelChrome.types';
91
- export type { ITerminalInteractivePanelProps, ITerminalInteractivePanelRef } from './panel/TerminalInteractivePanel.types';
92
- export type { ITerminalThemeSelectorProps } from './panel/TerminalThemeSelector';
93
- export type {
94
- ITerminalLogsPanelProps,
95
- ITerminalLogsPanelRef,
96
- ITerminalPanelHeaderProps,
97
- ITerminalPanelToolbarProps,
98
- ITerminalPanelFooterProps,
99
- ILevelFilterButton,
100
- TTerminalAction,
101
- } from './panel/TerminalLogsPanel.types';
102
- export type { ILogLinesViewerProps } from './panel/LogLinesViewer';
103
- export type { TLogLevelFilter } from './parsing/LogParser.types';
104
-
105
- // TerminalDisplay (lightweight readonly restty terminal)
106
- export { TerminalDisplay } from './TerminalDisplay';
107
- export type { ITerminalDisplayProps, ITerminalDisplayRef, TerminalDisplaySlot } from './TerminalDisplay.types';
108
- export { terminalDisplayStyles, terminalDisplayVariants, type TerminalDisplayVariantProps } from './TerminalDisplay.styles';
109
-
110
- // Chrome StyleSlots + CVA variants
111
- export { terminalChromeStyles, terminalChromeVariants, ACCENT_GRADIENTS, type TerminalChromeSlot, type TerminalChromeVariantProps } from './panel/TerminalPanelChrome.styles';