@bigpixelrocket/uiok 0.0.0-stage → 0.1.1

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 (280) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +569 -0
  4. package/README.md +44 -2
  5. package/dist/VisuallyHidden.d.ts +13 -0
  6. package/dist/VisuallyHidden.js +13 -0
  7. package/dist/activity/ActivityBar.d.ts +29 -0
  8. package/dist/activity/ActivityBar.js +21 -0
  9. package/dist/activity/activity.css +43 -0
  10. package/dist/activity/index.d.ts +2 -0
  11. package/dist/activity/index.js +2 -0
  12. package/dist/button/Button.d.ts +26 -0
  13. package/dist/button/Button.js +14 -0
  14. package/dist/button/IconButton.d.ts +18 -0
  15. package/dist/button/IconButton.js +14 -0
  16. package/dist/button/button.css +95 -0
  17. package/dist/button/index.d.ts +3 -0
  18. package/dist/button/index.js +3 -0
  19. package/dist/charts/Drawing.d.ts +27 -0
  20. package/dist/charts/Drawing.js +117 -0
  21. package/dist/charts/Drawing.logic.d.ts +2 -0
  22. package/dist/charts/Drawing.logic.js +22 -0
  23. package/dist/charts/Line.logic.d.ts +33 -0
  24. package/dist/charts/Line.logic.js +72 -0
  25. package/dist/charts/LineChart.d.ts +34 -0
  26. package/dist/charts/LineChart.js +100 -0
  27. package/dist/charts/Pie.logic.d.ts +16 -0
  28. package/dist/charts/Pie.logic.js +28 -0
  29. package/dist/charts/PieChart.d.ts +20 -0
  30. package/dist/charts/PieChart.js +16 -0
  31. package/dist/charts/ResultChart.d.ts +47 -0
  32. package/dist/charts/ResultChart.js +175 -0
  33. package/dist/charts/ResultChart.logic.d.ts +42 -0
  34. package/dist/charts/ResultChart.logic.js +165 -0
  35. package/dist/charts/Scatter.logic.d.ts +55 -0
  36. package/dist/charts/Scatter.logic.js +134 -0
  37. package/dist/charts/ScatterChart.d.ts +36 -0
  38. package/dist/charts/ScatterChart.js +99 -0
  39. package/dist/charts/charts.css +310 -0
  40. package/dist/charts/index.d.ts +14 -0
  41. package/dist/charts/index.js +11 -0
  42. package/dist/charts/seriesColour.d.ts +2 -0
  43. package/dist/charts/seriesColour.js +8 -0
  44. package/dist/clock/index.d.ts +2 -0
  45. package/dist/clock/index.js +2 -0
  46. package/dist/clock/useClock.d.ts +14 -0
  47. package/dist/clock/useClock.js +57 -0
  48. package/dist/datetime/DateTimePicker.d.ts +50 -0
  49. package/dist/datetime/DateTimePicker.js +98 -0
  50. package/dist/datetime/DateTimePicker.logic.d.ts +59 -0
  51. package/dist/datetime/DateTimePicker.logic.js +103 -0
  52. package/dist/datetime/datetime.css +115 -0
  53. package/dist/datetime/index.d.ts +7 -0
  54. package/dist/datetime/index.js +7 -0
  55. package/dist/dialog/ConfirmDialog.d.ts +73 -0
  56. package/dist/dialog/ConfirmDialog.js +30 -0
  57. package/dist/dialog/DialogLegend.d.ts +21 -0
  58. package/dist/dialog/DialogLegend.js +28 -0
  59. package/dist/dialog/DialogLegend.logic.d.ts +145 -0
  60. package/dist/dialog/DialogLegend.logic.js +71 -0
  61. package/dist/dialog/ModalDialog.d.ts +101 -0
  62. package/dist/dialog/ModalDialog.js +184 -0
  63. package/dist/dialog/dialog.css +283 -0
  64. package/dist/dialog/index.d.ts +8 -0
  65. package/dist/dialog/index.js +8 -0
  66. package/dist/filter/FilterEscape.d.ts +16 -0
  67. package/dist/filter/FilterEscape.js +15 -0
  68. package/dist/filter/FilterIcon.d.ts +8 -0
  69. package/dist/filter/FilterIcon.js +11 -0
  70. package/dist/filter/filter.css +42 -0
  71. package/dist/filter/index.d.ts +3 -0
  72. package/dist/filter/index.js +3 -0
  73. package/dist/grid/DataGrid.d.ts +149 -0
  74. package/dist/grid/DataGrid.js +373 -0
  75. package/dist/grid/DataGrid.logic.d.ts +57 -0
  76. package/dist/grid/DataGrid.logic.js +121 -0
  77. package/dist/grid/grid.css +206 -0
  78. package/dist/grid/index.d.ts +7 -0
  79. package/dist/grid/index.js +7 -0
  80. package/dist/index.d.ts +32 -0
  81. package/dist/index.js +32 -0
  82. package/dist/keyboard/BrowserKeys.d.ts +15 -0
  83. package/dist/keyboard/BrowserKeys.js +28 -0
  84. package/dist/keyboard/KeyChord.logic.d.ts +25 -0
  85. package/dist/keyboard/KeyChord.logic.js +50 -0
  86. package/dist/keyboard/Keyboard.logic.d.ts +84 -0
  87. package/dist/keyboard/Keyboard.logic.js +137 -0
  88. package/dist/keyboard/OverlayWatch.d.ts +28 -0
  89. package/dist/keyboard/OverlayWatch.js +119 -0
  90. package/dist/keyboard/PageSelectAll.d.ts +14 -0
  91. package/dist/keyboard/PageSelectAll.js +22 -0
  92. package/dist/keyboard/index.d.ts +9 -0
  93. package/dist/keyboard/index.js +9 -0
  94. package/dist/keychord/KeyChord.d.ts +16 -0
  95. package/dist/keychord/KeyChord.js +55 -0
  96. package/dist/keychord/index.d.ts +2 -0
  97. package/dist/keychord/index.js +2 -0
  98. package/dist/keychord/keychord.css +41 -0
  99. package/dist/labels/UiokLabels.d.ts +41 -0
  100. package/dist/labels/UiokLabels.js +31 -0
  101. package/dist/labels/UiokProvider.d.ts +44 -0
  102. package/dist/labels/UiokProvider.js +54 -0
  103. package/dist/labels/charts.d.ts +34 -0
  104. package/dist/labels/charts.js +15 -0
  105. package/dist/labels/dateTime.d.ts +32 -0
  106. package/dist/labels/dateTime.js +14 -0
  107. package/dist/labels/dialog.d.ts +18 -0
  108. package/dist/labels/dialog.js +6 -0
  109. package/dist/labels/index.d.ts +13 -0
  110. package/dist/labels/index.js +13 -0
  111. package/dist/labels/keys.d.ts +28 -0
  112. package/dist/labels/keys.js +53 -0
  113. package/dist/labels/legend.d.ts +21 -0
  114. package/dist/labels/legend.js +7 -0
  115. package/dist/labels/listing.d.ts +16 -0
  116. package/dist/labels/listing.js +8 -0
  117. package/dist/labels/pager.d.ts +32 -0
  118. package/dist/labels/pager.js +20 -0
  119. package/dist/labels/palette.d.ts +17 -0
  120. package/dist/labels/palette.js +6 -0
  121. package/dist/labels/selectAll.d.ts +15 -0
  122. package/dist/labels/selectAll.js +6 -0
  123. package/dist/labels/terminal.d.ts +25 -0
  124. package/dist/labels/terminal.js +9 -0
  125. package/dist/legend/KeyLegend.logic.d.ts +84 -0
  126. package/dist/legend/KeyLegend.logic.js +109 -0
  127. package/dist/legend/KeyLegendStrip.d.ts +36 -0
  128. package/dist/legend/KeyLegendStrip.js +82 -0
  129. package/dist/legend/index.d.ts +3 -0
  130. package/dist/legend/index.js +3 -0
  131. package/dist/legend/legend.css +148 -0
  132. package/dist/listing/CurrentDot.d.ts +15 -0
  133. package/dist/listing/CurrentDot.js +13 -0
  134. package/dist/listing/Listing.d.ts +230 -0
  135. package/dist/listing/Listing.js +265 -0
  136. package/dist/listing/PathParts.logic.d.ts +17 -0
  137. package/dist/listing/PathParts.logic.js +18 -0
  138. package/dist/listing/index.d.ts +10 -0
  139. package/dist/listing/index.js +10 -0
  140. package/dist/listing/listing.css +867 -0
  141. package/dist/menu/MenuQuery.logic.d.ts +69 -0
  142. package/dist/menu/MenuQuery.logic.js +75 -0
  143. package/dist/menu/fuzzyMatch.d.ts +31 -0
  144. package/dist/menu/fuzzyMatch.js +296 -0
  145. package/dist/menu/index.d.ts +9 -0
  146. package/dist/menu/index.js +9 -0
  147. package/dist/menu/menu.css +203 -0
  148. package/dist/menu/useBellBeat.d.ts +8 -0
  149. package/dist/menu/useBellBeat.js +26 -0
  150. package/dist/namecut/NameCut.d.ts +22 -0
  151. package/dist/namecut/NameCut.js +28 -0
  152. package/dist/namecut/NameCut.logic.d.ts +51 -0
  153. package/dist/namecut/NameCut.logic.js +120 -0
  154. package/dist/namecut/index.d.ts +3 -0
  155. package/dist/namecut/index.js +3 -0
  156. package/dist/namecut/namecut.css +67 -0
  157. package/dist/pager/Pager.d.ts +37 -0
  158. package/dist/pager/Pager.js +38 -0
  159. package/dist/pager/Pager.logic.d.ts +13 -0
  160. package/dist/pager/Pager.logic.js +63 -0
  161. package/dist/pager/index.d.ts +7 -0
  162. package/dist/pager/index.js +7 -0
  163. package/dist/pager/pager.css +62 -0
  164. package/dist/palette/Palette.d.ts +79 -0
  165. package/dist/palette/Palette.js +60 -0
  166. package/dist/palette/index.d.ts +6 -0
  167. package/dist/palette/index.js +6 -0
  168. package/dist/palette/palette.css +159 -0
  169. package/dist/pane/PaneActions.d.ts +104 -0
  170. package/dist/pane/PaneActions.js +62 -0
  171. package/dist/pane/PaneFrame.d.ts +51 -0
  172. package/dist/pane/PaneFrame.js +28 -0
  173. package/dist/pane/PaneKeys.d.ts +41 -0
  174. package/dist/pane/PaneKeys.js +104 -0
  175. package/dist/pane/PaneKeys.logic.d.ts +95 -0
  176. package/dist/pane/PaneKeys.logic.js +109 -0
  177. package/dist/pane/index.d.ts +11 -0
  178. package/dist/pane/index.js +11 -0
  179. package/dist/pane/usePaneKeys.d.ts +141 -0
  180. package/dist/pane/usePaneKeys.js +313 -0
  181. package/dist/run/RunHeader.d.ts +50 -0
  182. package/dist/run/RunHeader.js +31 -0
  183. package/dist/run/RunProgress.logic.d.ts +29 -0
  184. package/dist/run/RunProgress.logic.js +34 -0
  185. package/dist/run/index.d.ts +3 -0
  186. package/dist/run/index.js +3 -0
  187. package/dist/run/run.css +190 -0
  188. package/dist/segmented/SegmentedChoice.d.ts +22 -0
  189. package/dist/segmented/SegmentedChoice.js +31 -0
  190. package/dist/segmented/index.d.ts +2 -0
  191. package/dist/segmented/index.js +2 -0
  192. package/dist/segmented/segmented.css +49 -0
  193. package/dist/selectall/CheckRange.logic.d.ts +8 -0
  194. package/dist/selectall/CheckRange.logic.js +23 -0
  195. package/dist/selectall/SelectAllBar.d.ts +25 -0
  196. package/dist/selectall/SelectAllBar.js +24 -0
  197. package/dist/selectall/index.d.ts +7 -0
  198. package/dist/selectall/index.js +7 -0
  199. package/dist/selectall/selectall.css +31 -0
  200. package/dist/store/KeepUnchanged.logic.d.ts +19 -0
  201. package/dist/store/KeepUnchanged.logic.js +33 -0
  202. package/dist/store/SameProps.d.ts +15 -0
  203. package/dist/store/SameProps.js +46 -0
  204. package/dist/store/ValueStore.d.ts +17 -0
  205. package/dist/store/ValueStore.js +23 -0
  206. package/dist/store/index.d.ts +8 -0
  207. package/dist/store/index.js +8 -0
  208. package/dist/store/useStableHandlers.d.ts +13 -0
  209. package/dist/store/useStableHandlers.js +22 -0
  210. package/dist/styles.css +85 -0
  211. package/dist/tabs/PageTabs.d.ts +38 -0
  212. package/dist/tabs/PageTabs.js +33 -0
  213. package/dist/tabs/index.d.ts +2 -0
  214. package/dist/tabs/index.js +2 -0
  215. package/dist/tabs/tabs.css +64 -0
  216. package/dist/terminal/Terminal.d.ts +104 -0
  217. package/dist/terminal/Terminal.js +309 -0
  218. package/dist/terminal/Terminal.logic.d.ts +66 -0
  219. package/dist/terminal/Terminal.logic.js +156 -0
  220. package/dist/terminal/TerminalMenu.d.ts +36 -0
  221. package/dist/terminal/TerminalMenu.js +87 -0
  222. package/dist/terminal/TerminalMenu.logic.d.ts +78 -0
  223. package/dist/terminal/TerminalMenu.logic.js +68 -0
  224. package/dist/terminal/TerminalScrollback.d.ts +10 -0
  225. package/dist/terminal/TerminalScrollback.js +11 -0
  226. package/dist/terminal/ghostty/LICENSE +21 -0
  227. package/dist/terminal/ghostty/core.d.ts +315 -0
  228. package/dist/terminal/ghostty/core.js +1189 -0
  229. package/dist/terminal/ghostty/fallbackColors.d.ts +12 -0
  230. package/dist/terminal/ghostty/fallbackColors.js +23 -0
  231. package/dist/terminal/ghostty/fonts/LICENSE +21 -0
  232. package/dist/terminal/ghostty/fonts/SymbolsNerdFontMono-Regular.woff2 +0 -0
  233. package/dist/terminal/ghostty/keyCodes.logic.d.ts +20 -0
  234. package/dist/terminal/ghostty/keyCodes.logic.js +249 -0
  235. package/dist/terminal/ghostty/links.logic.d.ts +39 -0
  236. package/dist/terminal/ghostty/links.logic.js +84 -0
  237. package/dist/terminal/ghostty/renderer.d.ts +98 -0
  238. package/dist/terminal/ghostty/renderer.js +481 -0
  239. package/dist/terminal/ghostty/runtime.d.ts +126 -0
  240. package/dist/terminal/ghostty/runtime.js +346 -0
  241. package/dist/terminal/ghostty/spriteGlyphs.logic.d.ts +64 -0
  242. package/dist/terminal/ghostty/spriteGlyphs.logic.js +546 -0
  243. package/dist/terminal/ghostty/surface.d.ts +285 -0
  244. package/dist/terminal/ghostty/surface.js +1565 -0
  245. package/dist/terminal/ghostty/surface.logic.d.ts +181 -0
  246. package/dist/terminal/ghostty/surface.logic.js +392 -0
  247. package/dist/terminal/ghostty/vendor/LICENSE +21 -0
  248. package/dist/terminal/ghostty/vendor/ghostty-effects.wasm +0 -0
  249. package/dist/terminal/ghostty/vendor/ghostty-vt.wasm +0 -0
  250. package/dist/terminal/index.d.ts +12 -0
  251. package/dist/terminal/index.js +12 -0
  252. package/dist/terminal/terminal.css +169 -0
  253. package/dist/text/MarkedText.d.ts +14 -0
  254. package/dist/text/MarkedText.js +11 -0
  255. package/dist/text/highlightSegments.d.ts +13 -0
  256. package/dist/text/highlightSegments.js +29 -0
  257. package/dist/text/index.d.ts +3 -0
  258. package/dist/text/index.js +3 -0
  259. package/dist/text/text.css +11 -0
  260. package/dist/themes/attributes.d.ts +21 -0
  261. package/dist/themes/attributes.js +41 -0
  262. package/dist/themes/catalog.d.ts +125 -0
  263. package/dist/themes/catalog.js +940 -0
  264. package/dist/themes/color.d.ts +29 -0
  265. package/dist/themes/color.js +52 -0
  266. package/dist/themes/ids.d.ts +139 -0
  267. package/dist/themes/ids.js +59 -0
  268. package/dist/themes/index.d.ts +12 -0
  269. package/dist/themes/index.js +12 -0
  270. package/dist/themes/themes.generated.css +1830 -0
  271. package/dist/themes/tokens.d.ts +189 -0
  272. package/dist/themes/tokens.js +462 -0
  273. package/dist/tooltip/Tooltip.d.ts +21 -0
  274. package/dist/tooltip/Tooltip.js +105 -0
  275. package/dist/tooltip/Tooltip.logic.d.ts +49 -0
  276. package/dist/tooltip/Tooltip.logic.js +50 -0
  277. package/dist/tooltip/index.d.ts +3 -0
  278. package/dist/tooltip/index.js +3 -0
  279. package/dist/tooltip/tooltip.css +45 -0
  280. package/package.json +91 -4
@@ -0,0 +1,12 @@
1
+ import type { GhosttyColor, GhosttyTheme } from './core.js';
2
+ /**
3
+ * Catppuccin Mocha's terminal ground, text, cursor, and selection, for a
4
+ * stylesheet that defines no terminal tokens.
5
+ */
6
+ export declare const FALLBACK_TERMINAL_THEME: GhosttyTheme;
7
+ /** The text colour a snapshot falls back to when the engine reports none. */
8
+ export declare const ENGINE_DEFAULT_FOREGROUND: GhosttyColor;
9
+ /** The ground colour a snapshot falls back to when the engine reports none. */
10
+ export declare const ENGINE_DEFAULT_BACKGROUND: GhosttyColor;
11
+ /** The selection tint the renderer paints when its caller gives none. */
12
+ export declare const DEFAULT_SELECTION_BACKGROUND = "rgba(72, 122, 191, 0.35)";
@@ -0,0 +1,23 @@
1
+ /*
2
+ * The terminal's only colour literals. The engine paints on a canvas and
3
+ * needs concrete colours before it can draw anything, so when the page's
4
+ * stylesheet sets no `--terminal-*` tokens (UIOK's stylesheet was not
5
+ * imported) or the engine reports none, these stand in. Every themed colour
6
+ * still comes from the tokens; the colour guard skips this module alone.
7
+ */
8
+ /**
9
+ * Catppuccin Mocha's terminal ground, text, cursor, and selection, for a
10
+ * stylesheet that defines no terminal tokens.
11
+ */
12
+ export const FALLBACK_TERMINAL_THEME = {
13
+ background: { r: 30, g: 30, b: 46 },
14
+ foreground: { r: 205, g: 214, b: 244 },
15
+ cursor: { r: 245, g: 224, b: 220 },
16
+ selectionBackground: 'rgba(137, 180, 250, 0.28)'
17
+ };
18
+ /** The text colour a snapshot falls back to when the engine reports none. */
19
+ export const ENGINE_DEFAULT_FOREGROUND = { r: 229, g: 231, b: 235 };
20
+ /** The ground colour a snapshot falls back to when the engine reports none. */
21
+ export const ENGINE_DEFAULT_BACKGROUND = { r: 0, g: 0, b: 0 };
22
+ /** The selection tint the renderer paints when its caller gives none. */
23
+ export const DEFAULT_SELECTION_BACKGROUND = 'rgba(72, 122, 191, 0.35)';
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Ryan L McIntyre
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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Browser keyboard events mapped onto libghostty-vt's key encoder inputs: the
3
+ * physical key enum, consumed modifiers, and the unshifted codepoint.
4
+ */
5
+ /** Ghostty's key enum value for a `KeyboardEvent.code`; 0 (unidentified) when unknown. */
6
+ export declare function ghosttyKeyForCode(code: string): number;
7
+ /** The part of the browser's `KeyboardLayoutMap` the encoder reads. */
8
+ export interface GhosttyKeyboardLayoutMap {
9
+ get(code: string): string | undefined;
10
+ }
11
+ /**
12
+ * Browsers do not expose consumed modifiers; treat Shift as consumed for
13
+ * unchorded character input.
14
+ */
15
+ export declare function ghosttyConsumedMods(event: Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'key' | 'metaKey' | 'shiftKey'>): number;
16
+ /**
17
+ * The key's unshifted character as a codepoint (the Kitty protocol's base key),
18
+ * preferring the active layout; 0 when it cannot be known.
19
+ */
20
+ export declare function ghosttyUnshiftedCodepoint(event: Pick<KeyboardEvent, 'code' | 'key' | 'shiftKey'>, layoutMap?: GhosttyKeyboardLayoutMap): number;
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Browser keyboard events mapped onto libghostty-vt's key encoder inputs: the
3
+ * physical key enum, consumed modifiers, and the unshifted codepoint.
4
+ */
5
+ // This order mirrors GhosttyKey in ghostty/vt/key/event.h. The values are
6
+ // intentionally derived from the official W3C-aligned enum instead of
7
+ // maintaining a second keyboard protocol.
8
+ const ghosttyKeyboardCodes = [
9
+ 'Unidentified',
10
+ 'Backquote',
11
+ 'Backslash',
12
+ 'BracketLeft',
13
+ 'BracketRight',
14
+ 'Comma',
15
+ 'Digit0',
16
+ 'Digit1',
17
+ 'Digit2',
18
+ 'Digit3',
19
+ 'Digit4',
20
+ 'Digit5',
21
+ 'Digit6',
22
+ 'Digit7',
23
+ 'Digit8',
24
+ 'Digit9',
25
+ 'Equal',
26
+ 'IntlBackslash',
27
+ 'IntlRo',
28
+ 'IntlYen',
29
+ 'KeyA',
30
+ 'KeyB',
31
+ 'KeyC',
32
+ 'KeyD',
33
+ 'KeyE',
34
+ 'KeyF',
35
+ 'KeyG',
36
+ 'KeyH',
37
+ 'KeyI',
38
+ 'KeyJ',
39
+ 'KeyK',
40
+ 'KeyL',
41
+ 'KeyM',
42
+ 'KeyN',
43
+ 'KeyO',
44
+ 'KeyP',
45
+ 'KeyQ',
46
+ 'KeyR',
47
+ 'KeyS',
48
+ 'KeyT',
49
+ 'KeyU',
50
+ 'KeyV',
51
+ 'KeyW',
52
+ 'KeyX',
53
+ 'KeyY',
54
+ 'KeyZ',
55
+ 'Minus',
56
+ 'Period',
57
+ 'Quote',
58
+ 'Semicolon',
59
+ 'Slash',
60
+ 'AltLeft',
61
+ 'AltRight',
62
+ 'Backspace',
63
+ 'CapsLock',
64
+ 'ContextMenu',
65
+ 'ControlLeft',
66
+ 'ControlRight',
67
+ 'Enter',
68
+ 'MetaLeft',
69
+ 'MetaRight',
70
+ 'ShiftLeft',
71
+ 'ShiftRight',
72
+ 'Space',
73
+ 'Tab',
74
+ 'Convert',
75
+ 'KanaMode',
76
+ 'NonConvert',
77
+ 'Delete',
78
+ 'End',
79
+ 'Help',
80
+ 'Home',
81
+ 'Insert',
82
+ 'PageDown',
83
+ 'PageUp',
84
+ 'ArrowDown',
85
+ 'ArrowLeft',
86
+ 'ArrowRight',
87
+ 'ArrowUp',
88
+ 'NumLock',
89
+ 'Numpad0',
90
+ 'Numpad1',
91
+ 'Numpad2',
92
+ 'Numpad3',
93
+ 'Numpad4',
94
+ 'Numpad5',
95
+ 'Numpad6',
96
+ 'Numpad7',
97
+ 'Numpad8',
98
+ 'Numpad9',
99
+ 'NumpadAdd',
100
+ 'NumpadBackspace',
101
+ 'NumpadClear',
102
+ 'NumpadClearEntry',
103
+ 'NumpadComma',
104
+ 'NumpadDecimal',
105
+ 'NumpadDivide',
106
+ 'NumpadEnter',
107
+ 'NumpadEqual',
108
+ 'NumpadMemoryAdd',
109
+ 'NumpadMemoryClear',
110
+ 'NumpadMemoryRecall',
111
+ 'NumpadMemoryStore',
112
+ 'NumpadMemorySubtract',
113
+ 'NumpadMultiply',
114
+ 'NumpadParenLeft',
115
+ 'NumpadParenRight',
116
+ 'NumpadSubtract',
117
+ 'NumpadSeparator',
118
+ 'NumpadArrowUp',
119
+ 'NumpadArrowDown',
120
+ 'NumpadArrowRight',
121
+ 'NumpadArrowLeft',
122
+ 'NumpadBegin',
123
+ 'NumpadHome',
124
+ 'NumpadEnd',
125
+ 'NumpadInsert',
126
+ 'NumpadDelete',
127
+ 'NumpadPageUp',
128
+ 'NumpadPageDown',
129
+ 'Escape',
130
+ 'F1',
131
+ 'F2',
132
+ 'F3',
133
+ 'F4',
134
+ 'F5',
135
+ 'F6',
136
+ 'F7',
137
+ 'F8',
138
+ 'F9',
139
+ 'F10',
140
+ 'F11',
141
+ 'F12',
142
+ 'F13',
143
+ 'F14',
144
+ 'F15',
145
+ 'F16',
146
+ 'F17',
147
+ 'F18',
148
+ 'F19',
149
+ 'F20',
150
+ 'F21',
151
+ 'F22',
152
+ 'F23',
153
+ 'F24',
154
+ 'F25',
155
+ 'Fn',
156
+ 'FnLock',
157
+ 'PrintScreen',
158
+ 'ScrollLock',
159
+ 'Pause',
160
+ 'BrowserBack',
161
+ 'BrowserFavorites',
162
+ 'BrowserForward',
163
+ 'BrowserHome',
164
+ 'BrowserRefresh',
165
+ 'BrowserSearch',
166
+ 'BrowserStop',
167
+ 'Eject',
168
+ 'LaunchApp1',
169
+ 'LaunchApp2',
170
+ 'LaunchMail',
171
+ 'MediaPlayPause',
172
+ 'MediaSelect',
173
+ 'MediaStop',
174
+ 'MediaTrackNext',
175
+ 'MediaTrackPrevious',
176
+ 'Power',
177
+ 'Sleep',
178
+ 'AudioVolumeDown',
179
+ 'AudioVolumeMute',
180
+ 'AudioVolumeUp',
181
+ 'WakeUp',
182
+ 'Copy',
183
+ 'Cut',
184
+ 'Paste'
185
+ ];
186
+ const codeToGhosttyKey = new Map(ghosttyKeyboardCodes.map((code, index) => [code, index]));
187
+ /** Ghostty's key enum value for a `KeyboardEvent.code`; 0 (unidentified) when unknown. */
188
+ export function ghosttyKeyForCode(code) {
189
+ return codeToGhosttyKey.get(code) ?? 0;
190
+ }
191
+ const shiftedToUnshiftedCharacter = new Map([
192
+ ['!', '1'],
193
+ ['@', '2'],
194
+ ['#', '3'],
195
+ ['$', '4'],
196
+ ['%', '5'],
197
+ ['^', '6'],
198
+ ['&', '7'],
199
+ ['*', '8'],
200
+ ['(', '9'],
201
+ [')', '0'],
202
+ ['~', '`'],
203
+ ['_', '-'],
204
+ ['+', '='],
205
+ ['{', '['],
206
+ ['}', ']'],
207
+ ['|', '\\'],
208
+ [':', ';'],
209
+ ['"', "'"],
210
+ ['<', ','],
211
+ ['>', '.'],
212
+ ['?', '/']
213
+ ]);
214
+ /**
215
+ * Browsers do not expose consumed modifiers; treat Shift as consumed for
216
+ * unchorded character input.
217
+ */
218
+ export function ghosttyConsumedMods(event) {
219
+ if (!event.shiftKey || event.ctrlKey || event.altKey || event.metaKey)
220
+ return 0;
221
+ return [...event.key].length === 1 ? 1 : 0;
222
+ }
223
+ /**
224
+ * The key's unshifted character as a codepoint (the Kitty protocol's base key),
225
+ * preferring the active layout; 0 when it cannot be known.
226
+ */
227
+ export function ghosttyUnshiftedCodepoint(event, layoutMap) {
228
+ if ([...event.key].length !== 1)
229
+ return 0;
230
+ const layoutCharacter = layoutMap?.get(event.code);
231
+ if (layoutCharacter && [...layoutCharacter].length === 1) {
232
+ return layoutCharacter.codePointAt(0) ?? 0;
233
+ }
234
+ if (/^[A-Z]$/u.test(event.key))
235
+ return event.key.charCodeAt(0) + 32;
236
+ if (event.shiftKey) {
237
+ const unshiftedCharacter = shiftedToUnshiftedCharacter.get(event.key);
238
+ if (unshiftedCharacter)
239
+ return unshiftedCharacter.codePointAt(0) ?? 0;
240
+ const lowercase = event.key.toLowerCase();
241
+ if (lowercase !== event.key && [...lowercase].length === 1) {
242
+ return lowercase.codePointAt(0) ?? 0;
243
+ }
244
+ // Without layout data the unshifted form of a shifted key is unknowable;
245
+ // reporting the shifted character as unshifted corrupts Kitty alternate keys.
246
+ return 0;
247
+ }
248
+ return event.key.codePointAt(0) ?? 0;
249
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Web links in terminal text: finding `http(s)` URLs in a line and joining
3
+ * soft-wrapped rows back into the logical line a URL may span.
4
+ */
5
+ /** A URL found in a line, as UTF-16 offsets into it. */
6
+ export interface TerminalLinkMatch {
7
+ readonly text: string;
8
+ readonly start: number;
9
+ readonly end: number;
10
+ }
11
+ /** The view of a terminal row link detection needs. */
12
+ export interface TerminalBufferLineLike {
13
+ /** Whether this row continues the previous one after a soft wrap. */
14
+ readonly isWrapped?: boolean;
15
+ translateToString(trimRight?: boolean): string;
16
+ }
17
+ /** One row's slice of a wrapped logical line. */
18
+ interface WrappedTerminalLinkLineSegment {
19
+ readonly bufferLineNumber: number;
20
+ readonly text: string;
21
+ readonly startIndex: number;
22
+ readonly endIndex: number;
23
+ }
24
+ /** A logical line rebuilt from its soft-wrapped rows. */
25
+ export interface WrappedTerminalLinkLine {
26
+ readonly text: string;
27
+ readonly segments: ReadonlyArray<WrappedTerminalLinkLineSegment>;
28
+ }
29
+ /** Every `http(s)` URL in a line, without trailing punctuation or unbalanced closing brackets. */
30
+ export declare function extractTerminalLinks(line: string): TerminalLinkMatch[];
31
+ /** Whether a link target is a web URL, whatever the scheme's case. */
32
+ export declare function isTerminalUrl(value: string): boolean;
33
+ /**
34
+ * Rebuilds the logical line around a 1-based row number by walking back to
35
+ * its first row and forward through its soft-wrapped continuations; null
36
+ * when a row it needs is unavailable.
37
+ */
38
+ export declare function collectWrappedTerminalLinkLine(bufferLineNumber: number, getLine: (bufferLineIndex: number) => TerminalBufferLineLike | null | undefined): WrappedTerminalLinkLine | null;
39
+ export {};
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Web links in terminal text: finding `http(s)` URLs in a line and joining
3
+ * soft-wrapped rows back into the logical line a URL may span.
4
+ */
5
+ const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/giu;
6
+ const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
7
+ function trimClosingDelimiters(value) {
8
+ let output = value.replace(TRAILING_PUNCTUATION_PATTERN, '');
9
+ if (output.length === 0)
10
+ return output;
11
+ const trimUnbalanced = (open, close) => {
12
+ while (output.endsWith(close)) {
13
+ const opens = output.split(open).length - 1;
14
+ const closes = output.split(close).length - 1;
15
+ if (opens >= closes)
16
+ return;
17
+ output = output.slice(0, -1);
18
+ }
19
+ };
20
+ trimUnbalanced('(', ')');
21
+ trimUnbalanced('[', ']');
22
+ trimUnbalanced('{', '}');
23
+ return output;
24
+ }
25
+ /** Every `http(s)` URL in a line, without trailing punctuation or unbalanced closing brackets. */
26
+ export function extractTerminalLinks(line) {
27
+ const matches = [];
28
+ for (const rawMatch of line.matchAll(URL_PATTERN)) {
29
+ const start = rawMatch.index;
30
+ const trimmed = trimClosingDelimiters(rawMatch[0]);
31
+ if (trimmed.length === 0)
32
+ continue;
33
+ matches.push({ text: trimmed, start, end: start + trimmed.length });
34
+ }
35
+ return matches;
36
+ }
37
+ /** Whether a link target is a web URL, whatever the scheme's case. */
38
+ export function isTerminalUrl(value) {
39
+ return /^https?:\/\//iu.test(value);
40
+ }
41
+ /**
42
+ * Rebuilds the logical line around a 1-based row number by walking back to
43
+ * its first row and forward through its soft-wrapped continuations; null
44
+ * when a row it needs is unavailable.
45
+ */
46
+ export function collectWrappedTerminalLinkLine(bufferLineNumber, getLine) {
47
+ const anchorLine = getLine(bufferLineNumber - 1);
48
+ if (!anchorLine)
49
+ return null;
50
+ let startBufferLineNumber = bufferLineNumber;
51
+ let startLine = anchorLine;
52
+ while (startBufferLineNumber > 1 && startLine.isWrapped) {
53
+ const previousLine = getLine(startBufferLineNumber - 2);
54
+ if (!previousLine)
55
+ return null;
56
+ startBufferLineNumber -= 1;
57
+ startLine = previousLine;
58
+ }
59
+ const segments = [];
60
+ let nextStartIndex = 0;
61
+ let currentBufferLineNumber = startBufferLineNumber;
62
+ while (true) {
63
+ const currentLine = getLine(currentBufferLineNumber - 1);
64
+ if (!currentLine)
65
+ break;
66
+ const nextLine = getLine(currentBufferLineNumber);
67
+ const hasWrappedContinuation = nextLine?.isWrapped === true;
68
+ const text = currentLine.translateToString(!hasWrappedContinuation);
69
+ segments.push({
70
+ bufferLineNumber: currentBufferLineNumber,
71
+ text,
72
+ startIndex: nextStartIndex,
73
+ endIndex: nextStartIndex + text.length
74
+ });
75
+ nextStartIndex += text.length;
76
+ if (!hasWrappedContinuation)
77
+ break;
78
+ currentBufferLineNumber += 1;
79
+ }
80
+ return {
81
+ text: segments.map((segment) => segment.text).join(''),
82
+ segments
83
+ };
84
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Canvas 2D drawing of a Ghostty render snapshot: backgrounds and selection
3
+ * in runs, text in same-style runs clipped to their cells, block elements and
4
+ * box drawing as shapes snapped to device pixels, decorations, and the cursor.
5
+ * Only dirty rows are repainted unless a full frame is forced.
6
+ */
7
+ import { type GhosttyCell, type GhosttySnapshot } from './core.js';
8
+ /** One cell's size in CSS pixels and its text baseline offset. */
9
+ export interface GhosttyCellMetrics {
10
+ readonly width: number;
11
+ readonly height: number;
12
+ readonly baseline: number;
13
+ }
14
+ /** An inclusive range of viewport cells. */
15
+ export interface GhosttyCellRange {
16
+ readonly start: {
17
+ readonly x: number;
18
+ readonly y: number;
19
+ };
20
+ readonly end: {
21
+ readonly x: number;
22
+ readonly y: number;
23
+ };
24
+ }
25
+ /**
26
+ * The end (exclusive) of the text run starting at `start`, absorbing
27
+ * wide-glyph spacer tails. Exported for `renderer.test.ts`, which checks the
28
+ * run boundaries directly.
29
+ */
30
+ export declare function ghosttyTextRunEnd(cells: readonly GhosttyCell[], start: number, sameStyle: (cell: GhosttyCell) => boolean): number;
31
+ /** Where a string inks when drawn at the origin on the alphabetic baseline, in CSS pixels. */
32
+ export interface GhosttyTextInk {
33
+ readonly left: number;
34
+ readonly right: number;
35
+ readonly ascent: number;
36
+ readonly descent: number;
37
+ }
38
+ /** A box in CSS pixels, by its edges. */
39
+ export interface GhosttyInkBox {
40
+ readonly left: number;
41
+ readonly top: number;
42
+ readonly right: number;
43
+ readonly bottom: number;
44
+ }
45
+ /**
46
+ * The ink of each run of text a surface draws, measured once per font and
47
+ * text, so the renderer knows which runs can share one clip with every other
48
+ * run of their font and colour.
49
+ */
50
+ export declare class GhosttyTextInkCache {
51
+ private readonly fonts;
52
+ /** The ink of `text` in `font`, which must be the context's current font. */
53
+ measure(context: CanvasRenderingContext2D, font: string, text: string): GhosttyTextInk;
54
+ /** Forgets every measurement, for when a face loads and its glyphs change under the same font. */
55
+ clear(): void;
56
+ }
57
+ /**
58
+ * Whether text with this ink, drawn at (`x`, `y`), stays inside `box` with
59
+ * `margin` to spare on every side, so it paints no pixel outside the box.
60
+ * The canvas only ever squeezes text drawn wider than its maximum width, so
61
+ * the unsqueezed ink is the widest it can paint.
62
+ */
63
+ export declare function ghosttyInkInside(ink: GhosttyTextInk, x: number, y: number, box: GhosttyInkBox, margin: number): boolean;
64
+ /**
65
+ * Measures a cell for the face: the `M` advance, the requested line height
66
+ * (never shorter than the face's ascent plus descent), and a baseline that
67
+ * centres the glyphs in it.
68
+ */
69
+ export declare function measureGhosttyCell(context: CanvasRenderingContext2D, fontSize: number, fontFamily: string, lineHeight: number): GhosttyCellMetrics;
70
+ /** How many whole cells fit in a box after padding; never less than one by one. */
71
+ export declare function terminalGridSize(width: number, height: number, metrics: GhosttyCellMetrics, padding: number): {
72
+ cols: number;
73
+ rows: number;
74
+ };
75
+ /** Paints a snapshot onto the canvas context. */
76
+ export declare function renderGhosttySnapshot(options: {
77
+ readonly context: CanvasRenderingContext2D;
78
+ readonly snapshot: GhosttySnapshot;
79
+ readonly metrics: GhosttyCellMetrics;
80
+ readonly fontSize: number;
81
+ readonly fontFamily: string;
82
+ readonly padding: number;
83
+ readonly forceFull: boolean;
84
+ readonly cursorOn: boolean;
85
+ readonly previousCursorY?: number | null;
86
+ readonly focused?: boolean;
87
+ readonly selectionBackground?: string;
88
+ readonly hoveredLinkRange?: GhosttyCellRange | null;
89
+ /** The device pixels per CSS pixel the context's transform scales by; 1 when omitted. */
90
+ readonly pixelRatio?: number;
91
+ /**
92
+ * Measured text ink, so runs that ink near their cells share one clip per
93
+ * font and colour; without it, and in a frame that draws a bar, underline,
94
+ * or outline cursor (an unfocused terminal's included), every run gets a
95
+ * clip of its own.
96
+ */
97
+ readonly textInk?: GhosttyTextInkCache;
98
+ }): void;