@gkoreli/ghostty-vt-js 0.3.2

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 (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -0
  3. package/THIRD_PARTY_NOTICES.md +45 -0
  4. package/dist/browser-terminal/buffer.d.ts +93 -0
  5. package/dist/browser-terminal/buffer.d.ts.map +1 -0
  6. package/dist/browser-terminal/buffer.js +337 -0
  7. package/dist/browser-terminal/buffer.js.map +1 -0
  8. package/dist/browser-terminal/encoding.d.ts +17 -0
  9. package/dist/browser-terminal/encoding.d.ts.map +1 -0
  10. package/dist/browser-terminal/encoding.js +22 -0
  11. package/dist/browser-terminal/encoding.js.map +1 -0
  12. package/dist/browser-terminal/event-emitter.d.ts +8 -0
  13. package/dist/browser-terminal/event-emitter.d.ts.map +1 -0
  14. package/dist/browser-terminal/event-emitter.js +27 -0
  15. package/dist/browser-terminal/event-emitter.js.map +1 -0
  16. package/dist/browser-terminal/frame-hold.d.ts +13 -0
  17. package/dist/browser-terminal/frame-hold.d.ts.map +1 -0
  18. package/dist/browser-terminal/frame-hold.js +17 -0
  19. package/dist/browser-terminal/frame-hold.js.map +1 -0
  20. package/dist/browser-terminal/geometry.d.ts +229 -0
  21. package/dist/browser-terminal/geometry.d.ts.map +1 -0
  22. package/dist/browser-terminal/geometry.js +299 -0
  23. package/dist/browser-terminal/geometry.js.map +1 -0
  24. package/dist/browser-terminal/ghostty.d.ts +478 -0
  25. package/dist/browser-terminal/ghostty.d.ts.map +1 -0
  26. package/dist/browser-terminal/ghostty.js +1212 -0
  27. package/dist/browser-terminal/ghostty.js.map +1 -0
  28. package/dist/browser-terminal/gpu/adapter.d.ts +70 -0
  29. package/dist/browser-terminal/gpu/adapter.d.ts.map +1 -0
  30. package/dist/browser-terminal/gpu/adapter.js +260 -0
  31. package/dist/browser-terminal/gpu/adapter.js.map +1 -0
  32. package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.d.ts +33 -0
  33. package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.d.ts.map +1 -0
  34. package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.js +159 -0
  35. package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.js.map +1 -0
  36. package/dist/browser-terminal/gpu/core/context-loss-watchdog.d.ts +35 -0
  37. package/dist/browser-terminal/gpu/core/context-loss-watchdog.d.ts.map +1 -0
  38. package/dist/browser-terminal/gpu/core/context-loss-watchdog.js +73 -0
  39. package/dist/browser-terminal/gpu/core/context-loss-watchdog.js.map +1 -0
  40. package/dist/browser-terminal/gpu/core/frame.d.ts +68 -0
  41. package/dist/browser-terminal/gpu/core/frame.d.ts.map +1 -0
  42. package/dist/browser-terminal/gpu/core/frame.js +167 -0
  43. package/dist/browser-terminal/gpu/core/frame.js.map +1 -0
  44. package/dist/browser-terminal/gpu/core/glyph-atlas.d.ts +136 -0
  45. package/dist/browser-terminal/gpu/core/glyph-atlas.d.ts.map +1 -0
  46. package/dist/browser-terminal/gpu/core/glyph-atlas.js +281 -0
  47. package/dist/browser-terminal/gpu/core/glyph-atlas.js.map +1 -0
  48. package/dist/browser-terminal/gpu/core/procedural-shapes.d.ts +24 -0
  49. package/dist/browser-terminal/gpu/core/procedural-shapes.d.ts.map +1 -0
  50. package/dist/browser-terminal/gpu/core/procedural-shapes.js +316 -0
  51. package/dist/browser-terminal/gpu/core/procedural-shapes.js.map +1 -0
  52. package/dist/browser-terminal/gpu/core/webgl2-renderer.d.ts +107 -0
  53. package/dist/browser-terminal/gpu/core/webgl2-renderer.d.ts.map +1 -0
  54. package/dist/browser-terminal/gpu/core/webgl2-renderer.js +698 -0
  55. package/dist/browser-terminal/gpu/core/webgl2-renderer.js.map +1 -0
  56. package/dist/browser-terminal/gpu/create-renderer.d.ts +15 -0
  57. package/dist/browser-terminal/gpu/create-renderer.d.ts.map +1 -0
  58. package/dist/browser-terminal/gpu/create-renderer.js +33 -0
  59. package/dist/browser-terminal/gpu/create-renderer.js.map +1 -0
  60. package/dist/browser-terminal/index.d.ts +47 -0
  61. package/dist/browser-terminal/index.d.ts.map +1 -0
  62. package/dist/browser-terminal/index.js +75 -0
  63. package/dist/browser-terminal/index.js.map +1 -0
  64. package/dist/browser-terminal/input-handler.d.ts +262 -0
  65. package/dist/browser-terminal/input-handler.d.ts.map +1 -0
  66. package/dist/browser-terminal/input-handler.js +978 -0
  67. package/dist/browser-terminal/input-handler.js.map +1 -0
  68. package/dist/browser-terminal/interfaces.d.ts +230 -0
  69. package/dist/browser-terminal/interfaces.d.ts.map +1 -0
  70. package/dist/browser-terminal/interfaces.js +5 -0
  71. package/dist/browser-terminal/interfaces.js.map +1 -0
  72. package/dist/browser-terminal/link-detector.d.ts +76 -0
  73. package/dist/browser-terminal/link-detector.d.ts.map +1 -0
  74. package/dist/browser-terminal/link-detector.js +165 -0
  75. package/dist/browser-terminal/link-detector.js.map +1 -0
  76. package/dist/browser-terminal/providers/osc8-link-provider.d.ts +56 -0
  77. package/dist/browser-terminal/providers/osc8-link-provider.d.ts.map +1 -0
  78. package/dist/browser-terminal/providers/osc8-link-provider.js +204 -0
  79. package/dist/browser-terminal/providers/osc8-link-provider.js.map +1 -0
  80. package/dist/browser-terminal/providers/url-regex-provider.d.ts +68 -0
  81. package/dist/browser-terminal/providers/url-regex-provider.d.ts.map +1 -0
  82. package/dist/browser-terminal/providers/url-regex-provider.js +107 -0
  83. package/dist/browser-terminal/providers/url-regex-provider.js.map +1 -0
  84. package/dist/browser-terminal/renderer-interface.d.ts +59 -0
  85. package/dist/browser-terminal/renderer-interface.d.ts.map +1 -0
  86. package/dist/browser-terminal/renderer-interface.js +2 -0
  87. package/dist/browser-terminal/renderer-interface.js.map +1 -0
  88. package/dist/browser-terminal/renderer.d.ts +254 -0
  89. package/dist/browser-terminal/renderer.d.ts.map +1 -0
  90. package/dist/browser-terminal/renderer.js +905 -0
  91. package/dist/browser-terminal/renderer.js.map +1 -0
  92. package/dist/browser-terminal/scrollbar-overlay.d.ts +45 -0
  93. package/dist/browser-terminal/scrollbar-overlay.d.ts.map +1 -0
  94. package/dist/browser-terminal/scrollbar-overlay.js +89 -0
  95. package/dist/browser-terminal/scrollbar-overlay.js.map +1 -0
  96. package/dist/browser-terminal/selection-manager.d.ts +180 -0
  97. package/dist/browser-terminal/selection-manager.d.ts.map +1 -0
  98. package/dist/browser-terminal/selection-manager.js +913 -0
  99. package/dist/browser-terminal/selection-manager.js.map +1 -0
  100. package/dist/browser-terminal/terminal.d.ts +423 -0
  101. package/dist/browser-terminal/terminal.d.ts.map +1 -0
  102. package/dist/browser-terminal/terminal.js +1754 -0
  103. package/dist/browser-terminal/terminal.js.map +1 -0
  104. package/dist/browser-terminal/types.d.ts +595 -0
  105. package/dist/browser-terminal/types.d.ts.map +1 -0
  106. package/dist/browser-terminal/types.js +467 -0
  107. package/dist/browser-terminal/types.js.map +1 -0
  108. package/dist/browser-terminal/viewport-scroller.d.ts +94 -0
  109. package/dist/browser-terminal/viewport-scroller.d.ts.map +1 -0
  110. package/dist/browser-terminal/viewport-scroller.js +159 -0
  111. package/dist/browser-terminal/viewport-scroller.js.map +1 -0
  112. package/dist/browser-terminal/vt/effects.d.ts +114 -0
  113. package/dist/browser-terminal/vt/effects.d.ts.map +1 -0
  114. package/dist/browser-terminal/vt/effects.js +143 -0
  115. package/dist/browser-terminal/vt/effects.js.map +1 -0
  116. package/dist/browser-terminal/vt/enums.d.ts +155 -0
  117. package/dist/browser-terminal/vt/enums.d.ts.map +1 -0
  118. package/dist/browser-terminal/vt/enums.js +161 -0
  119. package/dist/browser-terminal/vt/enums.js.map +1 -0
  120. package/dist/browser-terminal/vt/mouse.d.ts +166 -0
  121. package/dist/browser-terminal/vt/mouse.d.ts.map +1 -0
  122. package/dist/browser-terminal/vt/mouse.js +259 -0
  123. package/dist/browser-terminal/vt/mouse.js.map +1 -0
  124. package/dist/browser-terminal/vt/paste.d.ts +53 -0
  125. package/dist/browser-terminal/vt/paste.d.ts.map +1 -0
  126. package/dist/browser-terminal/vt/paste.js +89 -0
  127. package/dist/browser-terminal/vt/paste.js.map +1 -0
  128. package/dist/browser-terminal/vt/render-state.d.ts +208 -0
  129. package/dist/browser-terminal/vt/render-state.d.ts.map +1 -0
  130. package/dist/browser-terminal/vt/render-state.js +776 -0
  131. package/dist/browser-terminal/vt/render-state.js.map +1 -0
  132. package/dist/browser-terminal/vt/style.d.ts +54 -0
  133. package/dist/browser-terminal/vt/style.d.ts.map +1 -0
  134. package/dist/browser-terminal/vt/style.js +92 -0
  135. package/dist/browser-terminal/vt/style.js.map +1 -0
  136. package/dist/browser-terminal/wasm-loader.d.ts +39 -0
  137. package/dist/browser-terminal/wasm-loader.d.ts.map +1 -0
  138. package/dist/browser-terminal/wasm-loader.js +73 -0
  139. package/dist/browser-terminal/wasm-loader.js.map +1 -0
  140. package/dist/browser-terminal/write-buffer.d.ts +40 -0
  141. package/dist/browser-terminal/write-buffer.d.ts.map +1 -0
  142. package/dist/browser-terminal/write-buffer.js +144 -0
  143. package/dist/browser-terminal/write-buffer.js.map +1 -0
  144. package/dist/protocol/index.d.ts +135 -0
  145. package/dist/protocol/index.d.ts.map +1 -0
  146. package/dist/protocol/index.js +76 -0
  147. package/dist/protocol/index.js.map +1 -0
  148. package/dist/react/index.d.ts +59 -0
  149. package/dist/react/index.d.ts.map +1 -0
  150. package/dist/react/index.js +146 -0
  151. package/dist/react/index.js.map +1 -0
  152. package/dist/server/index.d.ts +130 -0
  153. package/dist/server/index.d.ts.map +1 -0
  154. package/dist/server/index.js +191 -0
  155. package/dist/server/index.js.map +1 -0
  156. package/dist/terminal-screen-emulator/emulator.d.ts +66 -0
  157. package/dist/terminal-screen-emulator/emulator.d.ts.map +1 -0
  158. package/dist/terminal-screen-emulator/emulator.js +286 -0
  159. package/dist/terminal-screen-emulator/emulator.js.map +1 -0
  160. package/dist/terminal-screen-emulator/index.d.ts +82 -0
  161. package/dist/terminal-screen-emulator/index.d.ts.map +1 -0
  162. package/dist/terminal-screen-emulator/index.js +92 -0
  163. package/dist/terminal-screen-emulator/index.js.map +1 -0
  164. package/dist/terminal-screen-emulator/types.d.ts +382 -0
  165. package/dist/terminal-screen-emulator/types.d.ts.map +1 -0
  166. package/dist/terminal-screen-emulator/types.js +91 -0
  167. package/dist/terminal-screen-emulator/types.js.map +1 -0
  168. package/dist/terminal-screen-emulator/wasm-loader.d.ts +71 -0
  169. package/dist/terminal-screen-emulator/wasm-loader.d.ts.map +1 -0
  170. package/dist/terminal-screen-emulator/wasm-loader.js +162 -0
  171. package/dist/terminal-screen-emulator/wasm-loader.js.map +1 -0
  172. package/dist/themes/index.d.ts +6 -0
  173. package/dist/themes/index.d.ts.map +1 -0
  174. package/dist/themes/index.js +51 -0
  175. package/dist/themes/index.js.map +1 -0
  176. package/dist/wasm/alloc.d.ts +170 -0
  177. package/dist/wasm/alloc.d.ts.map +1 -0
  178. package/dist/wasm/alloc.js +307 -0
  179. package/dist/wasm/alloc.js.map +1 -0
  180. package/dist/wasm/compile.d.ts +73 -0
  181. package/dist/wasm/compile.d.ts.map +1 -0
  182. package/dist/wasm/compile.js +82 -0
  183. package/dist/wasm/compile.js.map +1 -0
  184. package/dist/wasm/exports.d.ts +234 -0
  185. package/dist/wasm/exports.d.ts.map +1 -0
  186. package/dist/wasm/exports.js +15 -0
  187. package/dist/wasm/exports.js.map +1 -0
  188. package/dist/wasm/fn-table.d.ts +119 -0
  189. package/dist/wasm/fn-table.d.ts.map +1 -0
  190. package/dist/wasm/fn-table.js +168 -0
  191. package/dist/wasm/fn-table.js.map +1 -0
  192. package/dist/wasm/memory.d.ts +59 -0
  193. package/dist/wasm/memory.d.ts.map +1 -0
  194. package/dist/wasm/memory.js +89 -0
  195. package/dist/wasm/memory.js.map +1 -0
  196. package/dist/wasm/type-layouts.d.ts +61 -0
  197. package/dist/wasm/type-layouts.d.ts.map +1 -0
  198. package/dist/wasm/type-layouts.js +32 -0
  199. package/dist/wasm/type-layouts.js.map +1 -0
  200. package/package.json +94 -0
  201. package/wasm/ghostty-vt.wasm +0 -0
@@ -0,0 +1,467 @@
1
+ // Portions originally derived from coder/ghostty-web (MIT — see ./LICENSE):
2
+ // https://github.com/coder/ghostty-web/blob/6a1a50df5b4f6b34d1b1de10fad3a0fc811bfbc0/lib/types.ts
3
+ // Substantially rewritten since; this file is ours and does not track that project.
4
+ // Modified: rewrote against vendored Ghostty C API (vendor/ghostty/include/ghostty/vt/*.h).
5
+ // All TS types here mirror C structs/enums in the headers; legacy upstream-only shapes
6
+ // (TerminalHandle, GhosttyWasmExports, GHOSTTY_CONFIG_SIZE, packed cursor struct, etc.)
7
+ // were dropped because they invented an ABI that doesn't exist in our local WASM.
8
+ /**
9
+ * @module browser-terminal/types
10
+ *
11
+ * TypeScript type mirrors of Ghostty's VT C API.
12
+ *
13
+ * Each export here corresponds to a C type in `vendor/ghostty/include/ghostty/vt/*.h`.
14
+ * The header citation is in JSDoc on the type. When the C ABI changes, this file
15
+ * is the first thing to update.
16
+ */
17
+ // =============================================================================
18
+ // Result codes — types.h
19
+ // =============================================================================
20
+ /**
21
+ * Result codes returned by Ghostty C API functions.
22
+ *
23
+ * Mirrors `GhosttyResult` from `vendor/ghostty/include/ghostty/vt/types.h`.
24
+ */
25
+ export var GhosttyResult;
26
+ (function (GhosttyResult) {
27
+ GhosttyResult[GhosttyResult["SUCCESS"] = 0] = "SUCCESS";
28
+ GhosttyResult[GhosttyResult["INVALID_VALUE"] = 1] = "INVALID_VALUE";
29
+ GhosttyResult[GhosttyResult["OUT_OF_MEMORY"] = 2] = "OUT_OF_MEMORY";
30
+ GhosttyResult[GhosttyResult["OUT_OF_SPACE"] = 3] = "OUT_OF_SPACE";
31
+ GhosttyResult[GhosttyResult["NO_VALUE"] = 4] = "NO_VALUE";
32
+ })(GhosttyResult || (GhosttyResult = {}));
33
+ // =============================================================================
34
+ // Point — point.h
35
+ // =============================================================================
36
+ /**
37
+ * Coordinate-system tag for a point in the terminal grid.
38
+ *
39
+ * Mirrors `GhosttyPointTag` from `point.h`.
40
+ */
41
+ export var PointTag;
42
+ (function (PointTag) {
43
+ /** Active area where the cursor can move. */
44
+ PointTag[PointTag["ACTIVE"] = 0] = "ACTIVE";
45
+ /** Visible viewport (changes when scrolled). */
46
+ PointTag[PointTag["VIEWPORT"] = 1] = "VIEWPORT";
47
+ /** Full screen including scrollback. */
48
+ PointTag[PointTag["SCREEN"] = 2] = "SCREEN";
49
+ /** Scrollback history only (before active area). */
50
+ PointTag[PointTag["HISTORY"] = 3] = "HISTORY";
51
+ })(PointTag || (PointTag = {}));
52
+ /**
53
+ * Construct a packed mode value.
54
+ *
55
+ * Mirrors the inline `ghostty_mode_new(value, ansi)` from `modes.h`. Replicated
56
+ * in TS because the C function is `static inline` and not exported by the WASM.
57
+ */
58
+ export function vtMode(value, ansi) {
59
+ return (value & 0x7fff) | (ansi ? 0x8000 : 0);
60
+ }
61
+ /** Extract the numeric mode value. Mirrors `ghostty_mode_value`. */
62
+ export function vtModeValue(mode) {
63
+ return mode & 0x7fff;
64
+ }
65
+ /** Check whether a mode is an ANSI mode. Mirrors `ghostty_mode_ansi`. */
66
+ export function vtModeIsAnsi(mode) {
67
+ return (mode & 0x8000) !== 0;
68
+ }
69
+ /**
70
+ * Named ANSI / DEC private modes that are commonly read by browser-terminal.
71
+ *
72
+ * Each value is computed via {@link vtMode} and matches the corresponding
73
+ * `GHOSTTY_MODE_*` macro in `modes.h`.
74
+ */
75
+ export const VtModes = {
76
+ /** ANSI mode 4 — insert. */
77
+ INSERT: vtMode(4, true),
78
+ /** DEC private mode 1 — DECCKM (cursor key application). */
79
+ DECCKM: vtMode(1, false),
80
+ /** DEC private mode 25 — DECTCEM (cursor visible). */
81
+ CURSOR_VISIBLE: vtMode(25, false),
82
+ /** DEC private mode 1000 — normal mouse tracking. */
83
+ MOUSE_NORMAL: vtMode(1000, false),
84
+ /** DEC private mode 1002 — button-event mouse tracking. */
85
+ MOUSE_BUTTON: vtMode(1002, false),
86
+ /** DEC private mode 1003 — any-event mouse tracking. */
87
+ MOUSE_ANY: vtMode(1003, false),
88
+ /** DEC private mode 1004 — focus in/out events. */
89
+ FOCUS_EVENT: vtMode(1004, false),
90
+ /** DEC private mode 1006 — SGR mouse format. */
91
+ MOUSE_SGR: vtMode(1006, false),
92
+ /** DEC private mode 1047 — alternate screen (legacy). */
93
+ ALT_SCREEN: vtMode(1047, false),
94
+ /** DEC private mode 1049 — alt screen + save cursor + clear. */
95
+ ALT_SCREEN_SAVE: vtMode(1049, false),
96
+ /** DEC private mode 2004 — bracketed paste. */
97
+ BRACKETED_PASTE: vtMode(2004, false),
98
+ /** DEC private mode 2026 — synchronized output. */
99
+ SYNC_OUTPUT: vtMode(2026, false),
100
+ };
101
+ // =============================================================================
102
+ // Style — style.h
103
+ // =============================================================================
104
+ /**
105
+ * Style color tag from `GhosttyStyleColorTag` in `style.h`.
106
+ */
107
+ export var StyleColorTag;
108
+ (function (StyleColorTag) {
109
+ StyleColorTag[StyleColorTag["NONE"] = 0] = "NONE";
110
+ StyleColorTag[StyleColorTag["PALETTE"] = 1] = "PALETTE";
111
+ StyleColorTag[StyleColorTag["RGB"] = 2] = "RGB";
112
+ })(StyleColorTag || (StyleColorTag = {}));
113
+ /**
114
+ * A flat boolean bitmask over the {@link Style} flags, used by the canvas
115
+ * renderer for fast per-cell flag checks. The bit positions match the legacy
116
+ * upstream `CellFlags` enum so the renderer's flag tests don't need rewriting.
117
+ *
118
+ * VT_NOTE: this is a renderer-side convenience; it is not part of the C ABI.
119
+ * Build it from {@link Style} via {@link styleToFlags}.
120
+ */
121
+ export var CellFlags;
122
+ (function (CellFlags) {
123
+ CellFlags[CellFlags["BOLD"] = 1] = "BOLD";
124
+ CellFlags[CellFlags["ITALIC"] = 2] = "ITALIC";
125
+ CellFlags[CellFlags["UNDERLINE"] = 4] = "UNDERLINE";
126
+ CellFlags[CellFlags["STRIKETHROUGH"] = 8] = "STRIKETHROUGH";
127
+ CellFlags[CellFlags["INVERSE"] = 16] = "INVERSE";
128
+ CellFlags[CellFlags["INVISIBLE"] = 32] = "INVISIBLE";
129
+ CellFlags[CellFlags["BLINK"] = 64] = "BLINK";
130
+ CellFlags[CellFlags["FAINT"] = 128] = "FAINT";
131
+ })(CellFlags || (CellFlags = {}));
132
+ export function styleToFlags(style) {
133
+ let flags = 0;
134
+ if (style.bold)
135
+ flags |= CellFlags.BOLD;
136
+ if (style.italic)
137
+ flags |= CellFlags.ITALIC;
138
+ if (style.underline > 0)
139
+ flags |= CellFlags.UNDERLINE;
140
+ if (style.strikethrough)
141
+ flags |= CellFlags.STRIKETHROUGH;
142
+ if (style.inverse)
143
+ flags |= CellFlags.INVERSE;
144
+ if (style.invisible)
145
+ flags |= CellFlags.INVISIBLE;
146
+ if (style.blink)
147
+ flags |= CellFlags.BLINK;
148
+ if (style.faint)
149
+ flags |= CellFlags.FAINT;
150
+ return flags;
151
+ }
152
+ // =============================================================================
153
+ // Screen — screen.h
154
+ // =============================================================================
155
+ /** Cell content classification. Mirrors `GhosttyCellContentTag` from `screen.h`. */
156
+ export var CellContentTag;
157
+ (function (CellContentTag) {
158
+ CellContentTag[CellContentTag["CODEPOINT"] = 0] = "CODEPOINT";
159
+ CellContentTag[CellContentTag["CODEPOINT_GRAPHEME"] = 1] = "CODEPOINT_GRAPHEME";
160
+ CellContentTag[CellContentTag["BG_COLOR_PALETTE"] = 2] = "BG_COLOR_PALETTE";
161
+ CellContentTag[CellContentTag["BG_COLOR_RGB"] = 3] = "BG_COLOR_RGB";
162
+ })(CellContentTag || (CellContentTag = {}));
163
+ /** Cell width property. Mirrors `GhosttyCellWide` from `screen.h`. */
164
+ export var CellWide;
165
+ (function (CellWide) {
166
+ CellWide[CellWide["NARROW"] = 0] = "NARROW";
167
+ CellWide[CellWide["WIDE"] = 1] = "WIDE";
168
+ CellWide[CellWide["SPACER_TAIL"] = 2] = "SPACER_TAIL";
169
+ CellWide[CellWide["SPACER_HEAD"] = 3] = "SPACER_HEAD";
170
+ })(CellWide || (CellWide = {}));
171
+ // =============================================================================
172
+ // Render State — render.h
173
+ // =============================================================================
174
+ /** Render-state dirty kind. Mirrors `GhosttyRenderStateDirty` from `render.h`. */
175
+ export var RenderStateDirty;
176
+ (function (RenderStateDirty) {
177
+ RenderStateDirty[RenderStateDirty["NONE"] = 0] = "NONE";
178
+ RenderStateDirty[RenderStateDirty["PARTIAL"] = 1] = "PARTIAL";
179
+ RenderStateDirty[RenderStateDirty["FULL"] = 2] = "FULL";
180
+ })(RenderStateDirty || (RenderStateDirty = {}));
181
+ /** Cursor visual style. Mirrors `GhosttyRenderStateCursorVisualStyle` from `render.h`. */
182
+ export var CursorVisualStyle;
183
+ (function (CursorVisualStyle) {
184
+ CursorVisualStyle[CursorVisualStyle["BAR"] = 0] = "BAR";
185
+ CursorVisualStyle[CursorVisualStyle["BLOCK"] = 1] = "BLOCK";
186
+ CursorVisualStyle[CursorVisualStyle["UNDERLINE"] = 2] = "UNDERLINE";
187
+ CursorVisualStyle[CursorVisualStyle["BLOCK_HOLLOW"] = 3] = "BLOCK_HOLLOW";
188
+ })(CursorVisualStyle || (CursorVisualStyle = {}));
189
+ // =============================================================================
190
+ // Key — key/event.h + key/encoder.h
191
+ // =============================================================================
192
+ /** Key action. Mirrors `GhosttyKeyAction` from `key/event.h`. */
193
+ export var KeyAction;
194
+ (function (KeyAction) {
195
+ KeyAction[KeyAction["RELEASE"] = 0] = "RELEASE";
196
+ KeyAction[KeyAction["PRESS"] = 1] = "PRESS";
197
+ KeyAction[KeyAction["REPEAT"] = 2] = "REPEAT";
198
+ })(KeyAction || (KeyAction = {}));
199
+ /**
200
+ * Modifier mask. Mirrors `GhosttyMods` (uint16_t) from `key/event.h`.
201
+ *
202
+ * The bit layout matches `GHOSTTY_MODS_*` macros in the header.
203
+ */
204
+ export var Mods;
205
+ (function (Mods) {
206
+ Mods[Mods["NONE"] = 0] = "NONE";
207
+ Mods[Mods["SHIFT"] = 1] = "SHIFT";
208
+ Mods[Mods["CTRL"] = 2] = "CTRL";
209
+ Mods[Mods["ALT"] = 4] = "ALT";
210
+ Mods[Mods["SUPER"] = 8] = "SUPER";
211
+ Mods[Mods["CAPS_LOCK"] = 16] = "CAPS_LOCK";
212
+ Mods[Mods["NUM_LOCK"] = 32] = "NUM_LOCK";
213
+ Mods[Mods["SHIFT_SIDE"] = 64] = "SHIFT_SIDE";
214
+ Mods[Mods["CTRL_SIDE"] = 128] = "CTRL_SIDE";
215
+ Mods[Mods["ALT_SIDE"] = 256] = "ALT_SIDE";
216
+ Mods[Mods["SUPER_SIDE"] = 512] = "SUPER_SIDE";
217
+ })(Mods || (Mods = {}));
218
+ /**
219
+ * Physical key code. Mirrors `GhosttyKey` enum from `key/event.h`.
220
+ *
221
+ * Values match the C enum order exactly. Use the `code` property of a
222
+ * browser `KeyboardEvent` to look these up (the codes are W3C
223
+ * UI-Events code names).
224
+ */
225
+ export var Key;
226
+ (function (Key) {
227
+ Key[Key["UNIDENTIFIED"] = 0] = "UNIDENTIFIED";
228
+ // Writing System Keys
229
+ Key[Key["BACKQUOTE"] = 1] = "BACKQUOTE";
230
+ Key[Key["BACKSLASH"] = 2] = "BACKSLASH";
231
+ Key[Key["BRACKET_LEFT"] = 3] = "BRACKET_LEFT";
232
+ Key[Key["BRACKET_RIGHT"] = 4] = "BRACKET_RIGHT";
233
+ Key[Key["COMMA"] = 5] = "COMMA";
234
+ Key[Key["DIGIT_0"] = 6] = "DIGIT_0";
235
+ Key[Key["DIGIT_1"] = 7] = "DIGIT_1";
236
+ Key[Key["DIGIT_2"] = 8] = "DIGIT_2";
237
+ Key[Key["DIGIT_3"] = 9] = "DIGIT_3";
238
+ Key[Key["DIGIT_4"] = 10] = "DIGIT_4";
239
+ Key[Key["DIGIT_5"] = 11] = "DIGIT_5";
240
+ Key[Key["DIGIT_6"] = 12] = "DIGIT_6";
241
+ Key[Key["DIGIT_7"] = 13] = "DIGIT_7";
242
+ Key[Key["DIGIT_8"] = 14] = "DIGIT_8";
243
+ Key[Key["DIGIT_9"] = 15] = "DIGIT_9";
244
+ Key[Key["EQUAL"] = 16] = "EQUAL";
245
+ Key[Key["INTL_BACKSLASH"] = 17] = "INTL_BACKSLASH";
246
+ Key[Key["INTL_RO"] = 18] = "INTL_RO";
247
+ Key[Key["INTL_YEN"] = 19] = "INTL_YEN";
248
+ Key[Key["A"] = 20] = "A";
249
+ Key[Key["B"] = 21] = "B";
250
+ Key[Key["C"] = 22] = "C";
251
+ Key[Key["D"] = 23] = "D";
252
+ Key[Key["E"] = 24] = "E";
253
+ Key[Key["F"] = 25] = "F";
254
+ Key[Key["G"] = 26] = "G";
255
+ Key[Key["H"] = 27] = "H";
256
+ Key[Key["I"] = 28] = "I";
257
+ Key[Key["J"] = 29] = "J";
258
+ Key[Key["K"] = 30] = "K";
259
+ Key[Key["L"] = 31] = "L";
260
+ Key[Key["M"] = 32] = "M";
261
+ Key[Key["N"] = 33] = "N";
262
+ Key[Key["O"] = 34] = "O";
263
+ Key[Key["P"] = 35] = "P";
264
+ Key[Key["Q"] = 36] = "Q";
265
+ Key[Key["R"] = 37] = "R";
266
+ Key[Key["S"] = 38] = "S";
267
+ Key[Key["T"] = 39] = "T";
268
+ Key[Key["U"] = 40] = "U";
269
+ Key[Key["V"] = 41] = "V";
270
+ Key[Key["W"] = 42] = "W";
271
+ Key[Key["X"] = 43] = "X";
272
+ Key[Key["Y"] = 44] = "Y";
273
+ Key[Key["Z"] = 45] = "Z";
274
+ Key[Key["MINUS"] = 46] = "MINUS";
275
+ Key[Key["PERIOD"] = 47] = "PERIOD";
276
+ Key[Key["QUOTE"] = 48] = "QUOTE";
277
+ Key[Key["SEMICOLON"] = 49] = "SEMICOLON";
278
+ Key[Key["SLASH"] = 50] = "SLASH";
279
+ // Functional Keys
280
+ Key[Key["ALT_LEFT"] = 51] = "ALT_LEFT";
281
+ Key[Key["ALT_RIGHT"] = 52] = "ALT_RIGHT";
282
+ Key[Key["BACKSPACE"] = 53] = "BACKSPACE";
283
+ Key[Key["CAPS_LOCK"] = 54] = "CAPS_LOCK";
284
+ Key[Key["CONTEXT_MENU"] = 55] = "CONTEXT_MENU";
285
+ Key[Key["CONTROL_LEFT"] = 56] = "CONTROL_LEFT";
286
+ Key[Key["CONTROL_RIGHT"] = 57] = "CONTROL_RIGHT";
287
+ Key[Key["ENTER"] = 58] = "ENTER";
288
+ Key[Key["META_LEFT"] = 59] = "META_LEFT";
289
+ Key[Key["META_RIGHT"] = 60] = "META_RIGHT";
290
+ Key[Key["SHIFT_LEFT"] = 61] = "SHIFT_LEFT";
291
+ Key[Key["SHIFT_RIGHT"] = 62] = "SHIFT_RIGHT";
292
+ Key[Key["SPACE"] = 63] = "SPACE";
293
+ Key[Key["TAB"] = 64] = "TAB";
294
+ Key[Key["CONVERT"] = 65] = "CONVERT";
295
+ Key[Key["KANA_MODE"] = 66] = "KANA_MODE";
296
+ Key[Key["NON_CONVERT"] = 67] = "NON_CONVERT";
297
+ // Control Pad
298
+ Key[Key["DELETE"] = 68] = "DELETE";
299
+ Key[Key["END"] = 69] = "END";
300
+ Key[Key["HELP"] = 70] = "HELP";
301
+ Key[Key["HOME"] = 71] = "HOME";
302
+ Key[Key["INSERT"] = 72] = "INSERT";
303
+ Key[Key["PAGE_DOWN"] = 73] = "PAGE_DOWN";
304
+ Key[Key["PAGE_UP"] = 74] = "PAGE_UP";
305
+ // Arrow Pad
306
+ Key[Key["ARROW_DOWN"] = 75] = "ARROW_DOWN";
307
+ Key[Key["ARROW_LEFT"] = 76] = "ARROW_LEFT";
308
+ Key[Key["ARROW_RIGHT"] = 77] = "ARROW_RIGHT";
309
+ Key[Key["ARROW_UP"] = 78] = "ARROW_UP";
310
+ // Numpad
311
+ Key[Key["NUM_LOCK"] = 79] = "NUM_LOCK";
312
+ Key[Key["NUMPAD_0"] = 80] = "NUMPAD_0";
313
+ Key[Key["NUMPAD_1"] = 81] = "NUMPAD_1";
314
+ Key[Key["NUMPAD_2"] = 82] = "NUMPAD_2";
315
+ Key[Key["NUMPAD_3"] = 83] = "NUMPAD_3";
316
+ Key[Key["NUMPAD_4"] = 84] = "NUMPAD_4";
317
+ Key[Key["NUMPAD_5"] = 85] = "NUMPAD_5";
318
+ Key[Key["NUMPAD_6"] = 86] = "NUMPAD_6";
319
+ Key[Key["NUMPAD_7"] = 87] = "NUMPAD_7";
320
+ Key[Key["NUMPAD_8"] = 88] = "NUMPAD_8";
321
+ Key[Key["NUMPAD_9"] = 89] = "NUMPAD_9";
322
+ Key[Key["NUMPAD_ADD"] = 90] = "NUMPAD_ADD";
323
+ Key[Key["NUMPAD_BACKSPACE"] = 91] = "NUMPAD_BACKSPACE";
324
+ Key[Key["NUMPAD_CLEAR"] = 92] = "NUMPAD_CLEAR";
325
+ Key[Key["NUMPAD_CLEAR_ENTRY"] = 93] = "NUMPAD_CLEAR_ENTRY";
326
+ Key[Key["NUMPAD_COMMA"] = 94] = "NUMPAD_COMMA";
327
+ Key[Key["NUMPAD_DECIMAL"] = 95] = "NUMPAD_DECIMAL";
328
+ Key[Key["NUMPAD_DIVIDE"] = 96] = "NUMPAD_DIVIDE";
329
+ Key[Key["NUMPAD_ENTER"] = 97] = "NUMPAD_ENTER";
330
+ Key[Key["NUMPAD_EQUAL"] = 98] = "NUMPAD_EQUAL";
331
+ Key[Key["NUMPAD_MEMORY_ADD"] = 99] = "NUMPAD_MEMORY_ADD";
332
+ Key[Key["NUMPAD_MEMORY_CLEAR"] = 100] = "NUMPAD_MEMORY_CLEAR";
333
+ Key[Key["NUMPAD_MEMORY_RECALL"] = 101] = "NUMPAD_MEMORY_RECALL";
334
+ Key[Key["NUMPAD_MEMORY_STORE"] = 102] = "NUMPAD_MEMORY_STORE";
335
+ Key[Key["NUMPAD_MEMORY_SUBTRACT"] = 103] = "NUMPAD_MEMORY_SUBTRACT";
336
+ Key[Key["NUMPAD_MULTIPLY"] = 104] = "NUMPAD_MULTIPLY";
337
+ Key[Key["NUMPAD_PAREN_LEFT"] = 105] = "NUMPAD_PAREN_LEFT";
338
+ Key[Key["NUMPAD_PAREN_RIGHT"] = 106] = "NUMPAD_PAREN_RIGHT";
339
+ Key[Key["NUMPAD_SUBTRACT"] = 107] = "NUMPAD_SUBTRACT";
340
+ Key[Key["NUMPAD_SEPARATOR"] = 108] = "NUMPAD_SEPARATOR";
341
+ Key[Key["NUMPAD_UP"] = 109] = "NUMPAD_UP";
342
+ Key[Key["NUMPAD_DOWN"] = 110] = "NUMPAD_DOWN";
343
+ Key[Key["NUMPAD_RIGHT"] = 111] = "NUMPAD_RIGHT";
344
+ Key[Key["NUMPAD_LEFT"] = 112] = "NUMPAD_LEFT";
345
+ Key[Key["NUMPAD_BEGIN"] = 113] = "NUMPAD_BEGIN";
346
+ Key[Key["NUMPAD_HOME"] = 114] = "NUMPAD_HOME";
347
+ Key[Key["NUMPAD_END"] = 115] = "NUMPAD_END";
348
+ Key[Key["NUMPAD_INSERT"] = 116] = "NUMPAD_INSERT";
349
+ Key[Key["NUMPAD_DELETE"] = 117] = "NUMPAD_DELETE";
350
+ Key[Key["NUMPAD_PAGE_UP"] = 118] = "NUMPAD_PAGE_UP";
351
+ Key[Key["NUMPAD_PAGE_DOWN"] = 119] = "NUMPAD_PAGE_DOWN";
352
+ // Function
353
+ Key[Key["ESCAPE"] = 120] = "ESCAPE";
354
+ Key[Key["F1"] = 121] = "F1";
355
+ Key[Key["F2"] = 122] = "F2";
356
+ Key[Key["F3"] = 123] = "F3";
357
+ Key[Key["F4"] = 124] = "F4";
358
+ Key[Key["F5"] = 125] = "F5";
359
+ Key[Key["F6"] = 126] = "F6";
360
+ Key[Key["F7"] = 127] = "F7";
361
+ Key[Key["F8"] = 128] = "F8";
362
+ Key[Key["F9"] = 129] = "F9";
363
+ Key[Key["F10"] = 130] = "F10";
364
+ Key[Key["F11"] = 131] = "F11";
365
+ Key[Key["F12"] = 132] = "F12";
366
+ Key[Key["F13"] = 133] = "F13";
367
+ Key[Key["F14"] = 134] = "F14";
368
+ Key[Key["F15"] = 135] = "F15";
369
+ Key[Key["F16"] = 136] = "F16";
370
+ Key[Key["F17"] = 137] = "F17";
371
+ Key[Key["F18"] = 138] = "F18";
372
+ Key[Key["F19"] = 139] = "F19";
373
+ Key[Key["F20"] = 140] = "F20";
374
+ Key[Key["F21"] = 141] = "F21";
375
+ Key[Key["F22"] = 142] = "F22";
376
+ Key[Key["F23"] = 143] = "F23";
377
+ Key[Key["F24"] = 144] = "F24";
378
+ Key[Key["F25"] = 145] = "F25";
379
+ Key[Key["FN"] = 146] = "FN";
380
+ Key[Key["FN_LOCK"] = 147] = "FN_LOCK";
381
+ Key[Key["PRINT_SCREEN"] = 148] = "PRINT_SCREEN";
382
+ Key[Key["SCROLL_LOCK"] = 149] = "SCROLL_LOCK";
383
+ Key[Key["PAUSE"] = 150] = "PAUSE";
384
+ // Media
385
+ Key[Key["BROWSER_BACK"] = 151] = "BROWSER_BACK";
386
+ Key[Key["BROWSER_FAVORITES"] = 152] = "BROWSER_FAVORITES";
387
+ Key[Key["BROWSER_FORWARD"] = 153] = "BROWSER_FORWARD";
388
+ Key[Key["BROWSER_HOME"] = 154] = "BROWSER_HOME";
389
+ Key[Key["BROWSER_REFRESH"] = 155] = "BROWSER_REFRESH";
390
+ Key[Key["BROWSER_SEARCH"] = 156] = "BROWSER_SEARCH";
391
+ Key[Key["BROWSER_STOP"] = 157] = "BROWSER_STOP";
392
+ Key[Key["EJECT"] = 158] = "EJECT";
393
+ Key[Key["LAUNCH_APP_1"] = 159] = "LAUNCH_APP_1";
394
+ Key[Key["LAUNCH_APP_2"] = 160] = "LAUNCH_APP_2";
395
+ Key[Key["LAUNCH_MAIL"] = 161] = "LAUNCH_MAIL";
396
+ Key[Key["MEDIA_PLAY_PAUSE"] = 162] = "MEDIA_PLAY_PAUSE";
397
+ Key[Key["MEDIA_SELECT"] = 163] = "MEDIA_SELECT";
398
+ Key[Key["MEDIA_STOP"] = 164] = "MEDIA_STOP";
399
+ Key[Key["MEDIA_TRACK_NEXT"] = 165] = "MEDIA_TRACK_NEXT";
400
+ Key[Key["MEDIA_TRACK_PREVIOUS"] = 166] = "MEDIA_TRACK_PREVIOUS";
401
+ Key[Key["POWER"] = 167] = "POWER";
402
+ Key[Key["SLEEP"] = 168] = "SLEEP";
403
+ Key[Key["AUDIO_VOLUME_DOWN"] = 169] = "AUDIO_VOLUME_DOWN";
404
+ Key[Key["AUDIO_VOLUME_MUTE"] = 170] = "AUDIO_VOLUME_MUTE";
405
+ Key[Key["AUDIO_VOLUME_UP"] = 171] = "AUDIO_VOLUME_UP";
406
+ Key[Key["WAKE_UP"] = 172] = "WAKE_UP";
407
+ // Legacy / clipboard
408
+ Key[Key["COPY"] = 173] = "COPY";
409
+ Key[Key["CUT"] = 174] = "CUT";
410
+ Key[Key["PASTE"] = 175] = "PASTE";
411
+ })(Key || (Key = {}));
412
+ /**
413
+ * Key encoder option kind. Mirrors `GhosttyKeyEncoderOption` from `key/encoder.h`.
414
+ */
415
+ export var KeyEncoderOption;
416
+ (function (KeyEncoderOption) {
417
+ KeyEncoderOption[KeyEncoderOption["CURSOR_KEY_APPLICATION"] = 0] = "CURSOR_KEY_APPLICATION";
418
+ KeyEncoderOption[KeyEncoderOption["KEYPAD_KEY_APPLICATION"] = 1] = "KEYPAD_KEY_APPLICATION";
419
+ KeyEncoderOption[KeyEncoderOption["IGNORE_KEYPAD_WITH_NUMLOCK"] = 2] = "IGNORE_KEYPAD_WITH_NUMLOCK";
420
+ KeyEncoderOption[KeyEncoderOption["ALT_ESC_PREFIX"] = 3] = "ALT_ESC_PREFIX";
421
+ KeyEncoderOption[KeyEncoderOption["MODIFY_OTHER_KEYS_STATE_2"] = 4] = "MODIFY_OTHER_KEYS_STATE_2";
422
+ KeyEncoderOption[KeyEncoderOption["KITTY_FLAGS"] = 5] = "KITTY_FLAGS";
423
+ KeyEncoderOption[KeyEncoderOption["MACOS_OPTION_AS_ALT"] = 6] = "MACOS_OPTION_AS_ALT";
424
+ KeyEncoderOption[KeyEncoderOption["BACKARROW_KEY_MODE"] = 7] = "BACKARROW_KEY_MODE";
425
+ })(KeyEncoderOption || (KeyEncoderOption = {}));
426
+ /** Kitty keyboard protocol flag bitmask. Mirrors `GhosttyKittyKeyFlags` from `key/encoder.h`. */
427
+ export var KittyKeyFlags;
428
+ (function (KittyKeyFlags) {
429
+ KittyKeyFlags[KittyKeyFlags["DISABLED"] = 0] = "DISABLED";
430
+ KittyKeyFlags[KittyKeyFlags["DISAMBIGUATE"] = 1] = "DISAMBIGUATE";
431
+ KittyKeyFlags[KittyKeyFlags["REPORT_EVENTS"] = 2] = "REPORT_EVENTS";
432
+ KittyKeyFlags[KittyKeyFlags["REPORT_ALTERNATES"] = 4] = "REPORT_ALTERNATES";
433
+ KittyKeyFlags[KittyKeyFlags["REPORT_ALL"] = 8] = "REPORT_ALL";
434
+ KittyKeyFlags[KittyKeyFlags["REPORT_ASSOCIATED"] = 16] = "REPORT_ASSOCIATED";
435
+ KittyKeyFlags[KittyKeyFlags["ALL"] = 31] = "ALL";
436
+ })(KittyKeyFlags || (KittyKeyFlags = {}));
437
+ /**
438
+ * Convert a {@link RenderCell} into the legacy packed-RGB {@link GhosttyCell} shape.
439
+ *
440
+ * `null` `fg` / `bg` from the WASM render state mean "no explicit color, use the
441
+ * terminal default". Those defaults live on the `Terminal` (set via
442
+ * `setForegroundColor` / `setBackgroundColor` and read back via `getColors()`)
443
+ * and must be threaded in here — otherwise we'd have to invent a fallback,
444
+ * which is theme-incorrect on anything but the legacy dark palette.
445
+ *
446
+ * @param cell - The render-state cell to convert.
447
+ * @param defaultFg - Theme foreground (`Terminal.getColors().foreground`).
448
+ * @param defaultBg - Theme background (`Terminal.getColors().background`).
449
+ */
450
+ export function toGhosttyCell(cell, defaultFg, defaultBg) {
451
+ const fg = cell.fg ?? defaultFg;
452
+ const bg = cell.bg ?? defaultBg;
453
+ return {
454
+ codepoint: cell.codepoint,
455
+ fg_r: fg.r,
456
+ fg_g: fg.g,
457
+ fg_b: fg.b,
458
+ bg_r: bg.r,
459
+ bg_g: bg.g,
460
+ bg_b: bg.b,
461
+ flags: cell.flags,
462
+ width: cell.width,
463
+ hyperlink_id: cell.hyperlinkId,
464
+ grapheme_len: cell.graphemeLen,
465
+ };
466
+ }
467
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/browser-terminal/types.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,oGAAoG;AACpG,oFAAoF;AACpF,4FAA4F;AAC5F,uFAAuF;AACvF,wFAAwF;AACxF,kFAAkF;AAElF;;;;;;;;GAQG;AAEH,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAN,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,uDAAW,CAAA;IACX,mEAAiB,CAAA;IACjB,mEAAiB,CAAA;IACjB,iEAAgB,CAAA;IAChB,yDAAY,CAAA;AACd,CAAC,EANW,aAAa,KAAb,aAAa,QAMxB;AAmBD,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAN,IAAY,QASX;AATD,WAAY,QAAQ;IAClB,6CAA6C;IAC7C,2CAAU,CAAA;IACV,gDAAgD;IAChD,+CAAY,CAAA;IACZ,wCAAwC;IACxC,2CAAU,CAAA;IACV,oDAAoD;IACpD,6CAAW,CAAA;AACb,CAAC,EATW,QAAQ,KAAR,QAAQ,QASnB;AA8BD;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,IAAa;IACjD,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,GAAG,MAAM,CAAC;AACvB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,O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EAAqB,CAAA;IACrB,mEAAsB,CAAA;IACtB,2EAA0B,CAAA;IAC1B,6DAAmB,CAAA;IACnB,4EAA0B,CAAA;IAC1B,gDAAU,CAAA;AACZ,CAAC,EARW,aAAa,KAAb,aAAa,QAQxB;AAkGD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,IAAgB,EAAE,SAAc,EAAE,SAAc;IAC5E,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,SAAS,CAAC;IAChC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,SAAS,CAAC;IAChC,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,IAAI,EAAE,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,YAAY,EAAE,IAAI,CAAC,WAAW;QAC9B,YAAY,EAAE,IAAI,CAAC,WAAW;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * ViewportScroller — scrollback viewport position + smooth-scroll animation.
3
+ *
4
+ * Extracted from `terminal.ts` (which had grown monolithic) as the owner of
5
+ * one cohesive piece of state: **where the viewport is** in the scrollback
6
+ * buffer, and how it animates between positions.
7
+ *
8
+ * ## Coordinate model
9
+ *
10
+ * `y` counts lines *up* from the live screen: `0` = at bottom (following
11
+ * output), `scrollbackLength` = at the very top of history. It can be
12
+ * fractional mid-animation — consumers that index buffers must
13
+ * `Math.floor()` it (the renderer and hit-testing already do).
14
+ *
15
+ * ## Smooth scrolling
16
+ *
17
+ * Asymptotic ease-out (move a fixed fraction of the remaining distance per
18
+ * frame), matching the feel of native terminal scrolling. Re-targeting while
19
+ * an animation is in flight does NOT restart it — the running animation
20
+ * simply steers toward the new target, which is what makes continuous wheel
21
+ * input feel smooth instead of choppy.
22
+ *
23
+ * ## Write anchoring
24
+ *
25
+ * When new output pushes lines into scrollback while the user is scrolled
26
+ * up, the viewport must shift by the same delta or the content they're
27
+ * reading visually jumps. `shiftAnchor()` applies that correction to the
28
+ * position AND any in-flight animation's target/origin (otherwise the
29
+ * animation would unwind the correction and snap to the bottom). See
30
+ * coder/ghostty-web#150 for the original bug this fixes.
31
+ */
32
+ /** Dependencies injected by {@link Terminal} — kept as closures so the scroller owns no Terminal reference. */
33
+ export interface ViewportScrollerDeps {
34
+ /** Current scrollback length in lines (also the max scroll position). */
35
+ getScrollbackLength: () => number;
36
+ /** Visible rows (for page-sized scrolling). */
37
+ getRows: () => number;
38
+ /** Smooth-scroll duration in ms; 0 = jump instantly. */
39
+ getSmoothScrollDuration: () => number;
40
+ /** Fired on every position change with the floored (integer) position. */
41
+ onScroll: (y: number) => void;
42
+ /** Ask the host to show its scrollbar affordance (auto-hide is the host's concern). */
43
+ showScrollbar: () => void;
44
+ }
45
+ export declare class ViewportScroller {
46
+ private readonly deps;
47
+ /** Viewport position in lines above the live screen. Fractional during animation. */
48
+ private _y;
49
+ private targetY;
50
+ private animationStartTime?;
51
+ private animationFrame?;
52
+ constructor(deps: ViewportScrollerDeps);
53
+ /** Current position (fractional mid-animation — floor before indexing buffers). */
54
+ get y(): number;
55
+ /**
56
+ * The position scrolling is heading toward: the animation target while one
57
+ * is in flight, else the current position. Wheel input accumulates against
58
+ * this (not `y`) so successive wheel ticks compound instead of fighting
59
+ * the animation.
60
+ */
61
+ get currentTarget(): number;
62
+ /** Scroll by lines (positive = down toward live output, negative = up into history). */
63
+ scrollLines(amount: number): void;
64
+ /** Scroll by pages (one page = visible rows). */
65
+ scrollPages(amount: number): void;
66
+ scrollToTop(): void;
67
+ scrollToBottom(): void;
68
+ /** Jump to an absolute line (0 = bottom, scrollbackLength = top), clamped. */
69
+ scrollToLine(line: number): void;
70
+ /**
71
+ * Animate toward `targetY` (clamped). Respects the host's smooth-scroll
72
+ * duration; 0 jumps. Retargeting mid-flight steers the running animation.
73
+ */
74
+ smoothScrollTo(targetY: number): void;
75
+ /**
76
+ * Shift position (and any in-flight animation anchors) after new output
77
+ * grew the scrollback while scrolled up — keeps the content the user is
78
+ * reading visually stable. No-op when `delta <= 0`.
79
+ */
80
+ shiftAnchor(delta: number): void;
81
+ /** True when the viewport is scrolled up into history. */
82
+ get scrolledUp(): boolean;
83
+ /** Cancel any in-flight animation (dispose / teardown path). */
84
+ cancelAnimation(): void;
85
+ private jumpTo;
86
+ /**
87
+ * Asymptotic ease-out: move `1 - (1/frames)^2` of the remaining distance
88
+ * each frame, snapping when within 0.01 lines. Duration is honored
89
+ * approximately (frame-rate dependent), which is fine for a feel-driven
90
+ * animation.
91
+ */
92
+ private readonly animate;
93
+ }
94
+ //# sourceMappingURL=viewport-scroller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport-scroller.d.ts","sourceRoot":"","sources":["../../src/browser-terminal/viewport-scroller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,+GAA+G;AAC/G,MAAM,WAAW,oBAAoB;IACnC,yEAAyE;IACzE,mBAAmB,EAAE,MAAM,MAAM,CAAC;IAClC,+CAA+C;IAC/C,OAAO,EAAE,MAAM,MAAM,CAAC;IACtB,wDAAwD;IACxD,uBAAuB,EAAE,MAAM,MAAM,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,uFAAuF;IACvF,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,qBAAa,gBAAgB;IAOf,OAAO,CAAC,QAAQ,CAAC,IAAI;IANjC,qFAAqF;IACrF,OAAO,CAAC,EAAE,CAAK;IACf,OAAO,CAAC,OAAO,CAAK;I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