@gloom-sh/terminal 0.19.3 → 0.19.5

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 (226) hide show
  1. package/package.json +4 -2
  2. package/src/api-client/errors.ts +8 -0
  3. package/src/api-client/index.ts +18 -0
  4. package/src/api-client/request.ts +295 -42
  5. package/src/api-client/socket.ts +95 -0
  6. package/src/app/keybindings/actions.ts +1 -1
  7. package/src/app/pane-runtime/index.tsx +1 -1
  8. package/src/app/pane-runtime/ticker-inspector-runtime.ts +1 -1
  9. package/src/app/pane-runtime/ticker-open-runtime.ts +1 -1
  10. package/src/app/pane-runtime/ticker-open-target.ts +12 -2
  11. package/src/cli/commands/command-utils.ts +4 -0
  12. package/src/cli/commands/market.ts +119 -27
  13. package/src/cli/commands/search.ts +1 -1
  14. package/src/cli/commands/ticker.ts +10 -6
  15. package/src/cli/currency-name-hint.ts +60 -0
  16. package/src/cli/desktop-pane-shot-api-policy.ts +10 -2
  17. package/src/cli/desktop-pane-shot.ts +2 -1
  18. package/src/cli/history-rows.ts +18 -1
  19. package/src/cli/known-gaps.ts +17 -2
  20. package/src/cli/not-a-ticker.ts +5 -3
  21. package/src/cli/pane-functions/catalog.ts +9 -1
  22. package/src/cli/pane-functions/headless.ts +7 -3
  23. package/src/cli/pane-functions/market-session.ts +6 -7
  24. package/src/cli/series-search.ts +4 -5
  25. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  26. package/src/components/chart/composite/time-axis.ts +17 -2
  27. package/src/components/command-bar/action-runtime.ts +2 -0
  28. package/src/components/command-bar/commands/direct/runtime.ts +3 -3
  29. package/src/components/command-bar/helpers.ts +2 -0
  30. package/src/components/command-bar/list/model.ts +9 -0
  31. package/src/components/command-bar/pane-actions.ts +46 -35
  32. package/src/components/command-bar/pane-templates/workflow.ts +6 -0
  33. package/src/components/command-bar/panel/index.tsx +30 -3
  34. package/src/components/command-bar/panel/types.ts +7 -0
  35. package/src/components/command-bar/routes/root/results.ts +4 -4
  36. package/src/components/command-bar/routes/root/selection.ts +3 -2
  37. package/src/components/command-bar/routes/ticker-search/actions.ts +21 -16
  38. package/src/components/command-bar/routing/launch-request.ts +3 -2
  39. package/src/components/command-bar/routing/list-state.ts +4 -1
  40. package/src/components/command-bar/surface/index.tsx +15 -1
  41. package/src/components/layout/floating-pane.tsx +10 -0
  42. package/src/components/layout/pane/frame.tsx +6 -0
  43. package/src/components/layout/pane/header.tsx +244 -42
  44. package/src/components/layout/pane/index.tsx +20 -2
  45. package/src/components/layout/shell/active-drag.ts +160 -28
  46. package/src/components/layout/shell/drag/index.ts +99 -96
  47. package/src/components/layout/shell/drag/live.ts +3 -17
  48. package/src/components/layout/shell/drag/magnets.ts +304 -0
  49. package/src/components/layout/shell/drag/overlays.tsx +77 -75
  50. package/src/components/layout/shell/drag/runtime.ts +12 -7
  51. package/src/components/layout/shell/index.tsx +66 -32
  52. package/src/components/layout/shell/native/pointer-runtime.ts +7 -2
  53. package/src/components/layout/shell/native/surfaces.ts +1 -9
  54. package/src/components/layout/shell/native/window-state.ts +21 -25
  55. package/src/components/layout/shell/pane/layers.tsx +153 -24
  56. package/src/components/layout/shell/shortcuts.ts +4 -1
  57. package/src/components/layout/shell/terminal-pointer-runtime.ts +24 -1
  58. package/src/components/layout/shell/window-mode/overlays.tsx +14 -6
  59. package/src/components/layout/status-bar.tsx +75 -6
  60. package/src/components/layout/window-controls.tsx +96 -35
  61. package/src/components/layout/window-fullscreen.ts +20 -0
  62. package/src/components/quote-flash.ts +36 -32
  63. package/src/core/app-runtime.ts +4 -1
  64. package/src/core/connection-health.ts +76 -1
  65. package/src/core/state/app/command-bar-launch.ts +12 -0
  66. package/src/core/state/app/layout.ts +4 -3
  67. package/src/core/state/app/types.ts +4 -1
  68. package/src/data/config/layout.ts +2 -2
  69. package/src/data/config/store/fold-panes.ts +6 -1
  70. package/src/i18n/es.ts +8 -1
  71. package/src/i18n/ja.ts +8 -1
  72. package/src/i18n/ko.ts +8 -1
  73. package/src/i18n/zh-cn.ts +8 -1
  74. package/src/i18n/zh-tw.ts +8 -1
  75. package/src/layout/pane-follow.ts +3 -2
  76. package/src/layout/pane-layout-move.ts +2 -1
  77. package/src/layout/pane-manager/dock-stack.ts +38 -0
  78. package/src/layout/pane-manager/dock-tree.ts +76 -15
  79. package/src/layout/pane-manager/docking.ts +48 -6
  80. package/src/layout/pane-manager/floating-actions.ts +12 -3
  81. package/src/layout/pane-manager/floating-placement.ts +189 -0
  82. package/src/layout/pane-manager/floating.ts +23 -4
  83. package/src/layout/pane-manager/gridlock.ts +16 -4
  84. package/src/layout/pane-manager/hidden-panes.ts +30 -1
  85. package/src/layout/pane-manager/index.ts +2 -0
  86. package/src/layout/pane-manager/layout-state.ts +17 -0
  87. package/src/layout/pane-manager/types.ts +4 -1
  88. package/src/layout/ticker-retarget.ts +88 -0
  89. package/src/layout-marketplace/cloud.ts +9 -1
  90. package/src/market-data/connection-follow.ts +68 -0
  91. package/src/market-data/coordinator/entries.ts +15 -3
  92. package/src/market-data/coordinator/events.ts +17 -1
  93. package/src/market-data/coordinator/financials.ts +20 -7
  94. package/src/market-data/coordinator/index.ts +217 -4
  95. package/src/market-data/coordinator/quotes.ts +10 -0
  96. package/src/market-data/frame-scheduler.ts +47 -10
  97. package/src/market-data/frame-wake.ts +74 -0
  98. package/src/market-data/futures-board.ts +7 -6
  99. package/src/market-data/hooks.tsx +43 -3
  100. package/src/market-data/performance.ts +78 -9
  101. package/src/market-data/request-types.ts +6 -3
  102. package/src/news/aggregator.ts +12 -1
  103. package/src/plugins/builtin/alerts/cli.ts +2 -1
  104. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  105. package/src/plugins/builtin/attention/evidence.ts +1 -1
  106. package/src/plugins/builtin/awards/client.ts +1 -1
  107. package/src/plugins/builtin/awards/evidence.ts +1 -1
  108. package/src/plugins/builtin/awards/pane.tsx +2 -1
  109. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  110. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  111. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  112. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  113. package/src/plugins/builtin/buildout/company/pane.tsx +2 -1
  114. package/src/plugins/builtin/buildout/model/index.ts +6 -0
  115. package/src/plugins/builtin/buildout/pane/index.tsx +2 -1
  116. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  117. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  118. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  119. package/src/plugins/builtin/chart-composer/index.tsx +13 -0
  120. package/src/plugins/builtin/chat/controller/index.ts +10 -3
  121. package/src/plugins/builtin/chat/controller/session-runtime.ts +9 -2
  122. package/src/plugins/builtin/chat/status-widget.tsx +3 -1
  123. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  124. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  125. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  126. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  127. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  128. package/src/plugins/builtin/cot/headless.ts +9 -3
  129. package/src/plugins/builtin/cot/model.ts +44 -3
  130. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  131. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  132. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  133. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  134. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  135. package/src/plugins/builtin/econ/calendar-model.ts +2 -0
  136. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  137. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  138. package/src/plugins/builtin/futures/series.ts +16 -1
  139. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  140. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  141. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  142. package/src/plugins/builtin/gpu/headless.ts +2 -1
  143. package/src/plugins/builtin/help/function-card.tsx +2 -1
  144. package/src/plugins/builtin/help/index.tsx +3 -2
  145. package/src/plugins/builtin/insider/display.ts +45 -6
  146. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  147. package/src/plugins/builtin/iv-history/client.ts +2 -1
  148. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  149. package/src/plugins/builtin/jobs/pages.ts +4 -4
  150. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  151. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  152. package/src/plugins/builtin/members/client.ts +1 -1
  153. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  154. package/src/plugins/builtin/mna/pane.tsx +4 -1
  155. package/src/plugins/builtin/options/market-reference.ts +1 -1
  156. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  157. package/src/plugins/builtin/options/view.tsx +2 -1
  158. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  159. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  160. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  161. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  162. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  163. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  164. package/src/plugins/builtin/perps/client.ts +1 -1
  165. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
  166. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  167. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  168. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  169. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  170. package/src/plugins/builtin/research/index.tsx +1 -0
  171. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  172. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  173. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  174. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  175. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  176. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  177. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  178. package/src/plugins/builtin/sec/index.tsx +7 -4
  179. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  180. package/src/plugins/builtin/sectors/client.ts +18 -8
  181. package/src/plugins/builtin/sectors/index.tsx +19 -5
  182. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  183. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  184. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  185. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  186. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  187. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  188. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  189. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  190. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  191. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -1
  192. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -2
  193. package/src/plugins/builtin/time-sales/client.ts +1 -0
  194. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  195. package/src/plugins/builtin/yield-curve/headless.ts +3 -1
  196. package/src/portfolio/column-values.ts +76 -10
  197. package/src/react/async-resource.ts +12 -0
  198. package/src/remote/controller.ts +3 -1
  199. package/src/renderers/browser/app-services.ts +8 -1
  200. package/src/renderers/browser/cloud-transport.ts +6 -1
  201. package/src/renderers/cloudflare/worker.ts +24 -2
  202. package/src/renderers/dom/host/box.tsx +204 -176
  203. package/src/renderers/dom/host/style.ts +49 -20
  204. package/src/renderers/dom/host/text.tsx +3 -2
  205. package/src/renderers/dom/styles.css +32 -0
  206. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  207. package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
  208. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  209. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  210. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  211. package/src/renderers/electrobun/shared/protocol.ts +6 -0
  212. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  213. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  214. package/src/shares/portable-layout.ts +99 -2
  215. package/src/sources/provider-router/index.ts +9 -3
  216. package/src/sources/provider-router/sources.ts +26 -1
  217. package/src/sync/core-contributors.ts +18 -4
  218. package/src/time-series/price-units.ts +11 -0
  219. package/src/time-series/resolve.ts +12 -0
  220. package/src/types/config.ts +17 -1
  221. package/src/types/plugin.ts +6 -0
  222. package/src/ui/host.tsx +2 -0
  223. package/src/utils/currency-names.ts +20 -0
  224. package/src/utils/currency-pair.ts +6 -0
  225. package/src/utils/exchange-rate-snapshot.ts +20 -2
  226. package/src/utils/fx-market-hours.ts +43 -0
@@ -26,7 +26,7 @@ import { hideDragShield, showDragShield } from "./drag-shield";
26
26
  import { applyLiveFrame } from "./live-frame";
27
27
  import { observeCellSize } from "./size-observer";
28
28
  import { fitSurface, surfaceFollows, trackSurface } from "./surface-fit";
29
- import { cleanDomProps, commonStyle } from "./style";
29
+ import { cleanDomProps, commonStyle, useStableStyle } from "./style";
30
30
 
31
31
  /** Farther than this from the pointer, in px, a predicted point is noise. */
32
32
  const MAX_PREDICTION_PX = 48;
@@ -74,6 +74,17 @@ function releasePointer(captured: { element: HTMLElement; pointerId: number } |
74
74
  }
75
75
  }
76
76
 
77
+ interface BoxHandlers {
78
+ cancelPendingFrame(): void;
79
+ handleMouseDown(event: MouseEvent): void;
80
+ handlePointerDown(event: PointerEvent): void;
81
+ handleMouseDownCapture(event: MouseEvent): void;
82
+ handleMouseOver(event: MouseEvent): void;
83
+ handleMouseOut(event: MouseEvent): void;
84
+ handleMouseMove(event: MouseEvent): void;
85
+ handleMouseUp(event: MouseEvent): void;
86
+ }
87
+
77
88
  export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { children?: ReactNode }>(
78
89
  function WebBox({ children, ...props }, ref: Ref<HTMLDivElement>) {
79
90
  const elementRef = useRef<HTMLDivElement | null>(null);
@@ -101,62 +112,6 @@ export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { chi
101
112
  return handle as unknown as HTMLDivElement;
102
113
  }, []);
103
114
 
104
- const cancelPendingFrame = () => {
105
- if (frameRef.current !== null) {
106
- cancelWebFrame(frameRef.current);
107
- frameRef.current = null;
108
- }
109
- };
110
-
111
- const flushPendingFrameMouseHandlers = () => {
112
- const moveEvent = pendingMoveRef.current;
113
- const dragEvent = pendingDragRef.current;
114
- pendingMoveRef.current = null;
115
- pendingDragRef.current = null;
116
-
117
- if (moveEvent) {
118
- callCellMouseHandler(propsRef.current.onMouseMove, moveEvent);
119
- }
120
- if (dragEvent) {
121
- callCellMouseHandler(propsRef.current.onMouse, dragEvent);
122
- callCellMouseHandler(propsRef.current.onMouseDrag, dragEvent);
123
- }
124
- };
125
-
126
- const flushPendingFrameNow = () => {
127
- cancelPendingFrame();
128
- flushPendingFrameMouseHandlers();
129
- };
130
-
131
- const scheduleFrameMouseHandler = (
132
- event: MouseLikeEvent,
133
- type: "move" | "drag",
134
- ahead: { clientX: number; clientY: number } | null = null,
135
- ) => {
136
- // The DOM keeps firing mousemove while a button is held. A move means no
137
- // button anywhere else in the app, so drags must not surface as moves.
138
- if (type === "move" && draggingRef.current) return;
139
- if (type === "move" && typeof propsRef.current.onMouseMove !== "function") return;
140
- if (type === "drag"
141
- && typeof propsRef.current.onMouse !== "function"
142
- && typeof propsRef.current.onMouseDrag !== "function") {
143
- return;
144
- }
145
-
146
- const nextEvent = cellMouseEvent(event, type, ahead);
147
- if (type === "move") {
148
- pendingMoveRef.current = nextEvent;
149
- } else {
150
- pendingDragRef.current = nextEvent;
151
- }
152
-
153
- if (frameRef.current !== null) return;
154
- frameRef.current = requestWebFrame(() => {
155
- frameRef.current = null;
156
- flushPendingFrameMouseHandlers();
157
- });
158
- };
159
-
160
115
  const lastPointRef = useRef({ x: 0, y: 0 });
161
116
  // The pointer that pressed this box, so a drag can capture it.
162
117
  const pressedPointerRef = useRef<number | null>(null);
@@ -176,38 +131,186 @@ export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { chi
176
131
  * took the pointer), so a move can put things back.
177
132
  */
178
133
  const endDocumentDragRef = useRef<(event: globalThis.MouseEvent | null, outcome: "end" | "cancel") => void>(() => {});
179
- endDocumentDragRef.current = (event, outcome) => {
180
- const session = dragSessionRef.current;
181
- const wasDragging = draggingRef.current;
182
- if (!session && !wasDragging) return;
183
- draggingRef.current = false;
184
- const shielded = session?.shielded === true;
185
- dragSessionRef.current = null;
186
- if (shielded) hideDragShield();
187
- if (session) {
188
- document.removeEventListener("pointermove", session.move);
189
- document.removeEventListener("mousemove", session.move);
190
- document.removeEventListener("mouseup", session.up);
191
- document.removeEventListener("pointerup", session.up);
192
- document.removeEventListener("pointercancel", session.cancel);
193
- window.removeEventListener("blur", session.cancel);
194
- releasePointer(session.captured);
195
- }
196
- if (!wasDragging) return;
197
- const point = event ?? new MouseEvent("mouseup", {
198
- clientX: lastPointRef.current.x,
199
- clientY: lastPointRef.current.y,
200
- button: 0,
201
- bubbles: true,
202
- });
203
- flushPendingFrameNow();
204
- callMouseHandler(propsRef.current.onMouse, point, "up");
205
- callMouseHandler(propsRef.current.onMouseUp, point, "up");
206
- callMouseHandler(propsRef.current.onMouseDragEnd, point, outcome === "cancel" ? "drag-cancel" : "drag-end");
207
- };
134
+ const handlersRef = useRef<BoxHandlers | null>(null);
135
+ // Created once: they read the latest props through propsRef, so a re-render
136
+ // hands React the same listeners instead of a dozen new closures.
137
+ const handlers = handlersRef.current ??= (() => {
138
+ const cancelPendingFrame = () => {
139
+ if (frameRef.current !== null) {
140
+ cancelWebFrame(frameRef.current);
141
+ frameRef.current = null;
142
+ }
143
+ };
144
+
145
+ const flushPendingFrameMouseHandlers = () => {
146
+ const moveEvent = pendingMoveRef.current;
147
+ const dragEvent = pendingDragRef.current;
148
+ pendingMoveRef.current = null;
149
+ pendingDragRef.current = null;
150
+
151
+ if (moveEvent) {
152
+ callCellMouseHandler(propsRef.current.onMouseMove, moveEvent);
153
+ }
154
+ if (dragEvent) {
155
+ callCellMouseHandler(propsRef.current.onMouse, dragEvent);
156
+ callCellMouseHandler(propsRef.current.onMouseDrag, dragEvent);
157
+ }
158
+ };
159
+
160
+ const flushPendingFrameNow = () => {
161
+ cancelPendingFrame();
162
+ flushPendingFrameMouseHandlers();
163
+ };
164
+
165
+ const scheduleFrameMouseHandler = (
166
+ event: MouseLikeEvent,
167
+ type: "move" | "drag",
168
+ ahead: { clientX: number; clientY: number } | null = null,
169
+ ) => {
170
+ // The DOM keeps firing mousemove while a button is held. A move means no
171
+ // button anywhere else in the app, so drags must not surface as moves.
172
+ if (type === "move" && draggingRef.current) return;
173
+ if (type === "move" && typeof propsRef.current.onMouseMove !== "function") return;
174
+ if (type === "drag"
175
+ && typeof propsRef.current.onMouse !== "function"
176
+ && typeof propsRef.current.onMouseDrag !== "function") {
177
+ return;
178
+ }
179
+
180
+ const nextEvent = cellMouseEvent(event, type, ahead);
181
+ if (type === "move") {
182
+ pendingMoveRef.current = nextEvent;
183
+ } else {
184
+ pendingDragRef.current = nextEvent;
185
+ }
186
+
187
+ if (frameRef.current !== null) return;
188
+ frameRef.current = requestWebFrame(() => {
189
+ frameRef.current = null;
190
+ flushPendingFrameMouseHandlers();
191
+ });
192
+ };
193
+
194
+ endDocumentDragRef.current = (event, outcome) => {
195
+ const session = dragSessionRef.current;
196
+ const wasDragging = draggingRef.current;
197
+ if (!session && !wasDragging) return;
198
+ draggingRef.current = false;
199
+ const shielded = session?.shielded === true;
200
+ dragSessionRef.current = null;
201
+ if (shielded) hideDragShield();
202
+ if (session) {
203
+ document.removeEventListener("pointermove", session.move);
204
+ document.removeEventListener("mousemove", session.move);
205
+ document.removeEventListener("mouseup", session.up);
206
+ document.removeEventListener("pointerup", session.up);
207
+ document.removeEventListener("pointercancel", session.cancel);
208
+ window.removeEventListener("blur", session.cancel);
209
+ releasePointer(session.captured);
210
+ }
211
+ if (!wasDragging) return;
212
+ const point = event ?? new MouseEvent("mouseup", {
213
+ clientX: lastPointRef.current.x,
214
+ clientY: lastPointRef.current.y,
215
+ button: 0,
216
+ bubbles: true,
217
+ });
218
+ flushPendingFrameNow();
219
+ callMouseHandler(propsRef.current.onMouse, point, "up");
220
+ callMouseHandler(propsRef.current.onMouseUp, point, "up");
221
+ callMouseHandler(propsRef.current.onMouseDragEnd, point, outcome === "cancel" ? "drag-cancel" : "drag-end");
222
+ };
223
+
224
+ const handleMouseDown = (event: MouseEvent) => {
225
+ const hasSyntheticDrag = typeof propsRef.current.onMouse === "function";
226
+ const hasDirectDrag = typeof propsRef.current.onMouseDrag === "function" || typeof propsRef.current.onMouseDragEnd === "function";
227
+ pendingMoveRef.current = null;
228
+ // A press that never saw mouseup (the window move took the pointer) is still tracked.
229
+ // Finish it before the new press, so its drag-end cannot clear the drag this press starts.
230
+ endDocumentDragRef.current(null, "end");
231
+ callMouseHandler(propsRef.current.onMouseDown, event, "down");
232
+ if (event.button !== 0 || (event.isPropagationStopped() && !hasDirectDrag)) return;
233
+ if (!hasSyntheticDrag && !hasDirectDrag) return;
234
+ callMouseHandler(propsRef.current.onMouse, event, "down");
235
+ draggingRef.current = true;
236
+ lastPointRef.current = { x: event.clientX, y: event.clientY };
237
+ const originX = event.clientX;
238
+ const originY = event.clientY;
239
+ const move = (moveEvent: globalThis.MouseEvent) => {
240
+ if (!draggingRef.current) return;
241
+ const current = dragSessionRef.current;
242
+ if (isPointerMove(moveEvent)) {
243
+ if (current) current.pointerMoves = true;
244
+ } else if (current?.pointerMoves) {
245
+ return;
246
+ }
247
+ lastPointRef.current = { x: moveEvent.clientX, y: moveEvent.clientY };
248
+ // The button is up and mouseup never arrived. End the drag instead of following the cursor.
249
+ if (moveEvent.buttons === 0) {
250
+ endDocumentDragRef.current(moveEvent, "end");
251
+ return;
252
+ }
253
+ const dx = moveEvent.clientX - originX;
254
+ const dy = moveEvent.clientY - originY;
255
+ if (current && !current.shielded) {
256
+ if (dx * dx + dy * dy < 9) return;
257
+ current.shielded = true;
258
+ showDragShield(elementRef.current);
259
+ // Captured once it is a drag (a click keeps its usual target), the
260
+ // moves skip hit testing and leave every other element's hover state
261
+ // alone: nothing under the pointer restyles or repaints while a pane,
262
+ // divider or chart is dragged across it. The document listeners still
263
+ // see every move.
264
+ if (!current.captured) current.captured = capturePointer(elementRef.current, pressedPointerRef.current);
265
+ }
266
+ scheduleFrameMouseHandler(moveEvent, "drag", predictedPoint(moveEvent));
267
+ };
268
+ const up = (upEvent: globalThis.MouseEvent) => {
269
+ endDocumentDragRef.current(upEvent, "end");
270
+ };
271
+ const cancel = () => {
272
+ endDocumentDragRef.current(null, "cancel");
273
+ };
274
+ dragSessionRef.current = { move, up, cancel, captured: null, pointerMoves: false, shielded: false };
275
+ document.addEventListener("pointermove", move);
276
+ document.addEventListener("mousemove", move);
277
+ document.addEventListener("mouseup", up);
278
+ document.addEventListener("pointerup", up);
279
+ document.addEventListener("pointercancel", cancel);
280
+ window.addEventListener("blur", cancel);
281
+ };
282
+
283
+ const handlePointerDown = (event: PointerEvent) => {
284
+ pressedPointerRef.current = event.pointerId;
285
+ };
286
+
287
+ const handleMouseDownCapture = (event: MouseEvent) => {
288
+ callMouseHandler(propsRef.current.onMouseDownCapture, event, "down");
289
+ };
290
+
291
+ const handleMouseOver = (event: MouseEvent) => {
292
+ callMouseHandler(propsRef.current.onMouseOver, event, "over");
293
+ };
294
+
295
+ const handleMouseOut = (event: MouseEvent) => {
296
+ pendingMoveRef.current = null;
297
+ callMouseHandler(propsRef.current.onMouseOut, event, "out");
298
+ };
299
+
300
+ return {
301
+ cancelPendingFrame,
302
+ handleMouseDown,
303
+ handlePointerDown,
304
+ handleMouseDownCapture,
305
+ handleMouseOver,
306
+ handleMouseOut,
307
+ handleMouseMove: (event: MouseEvent) => scheduleFrameMouseHandler(event, "move"),
308
+ handleMouseUp: (event: MouseEvent) => callMouseHandler(propsRef.current.onMouseUp, event, "up"),
309
+ };
310
+ })();
208
311
 
209
312
  useEffect(() => () => {
210
- cancelPendingFrame();
313
+ handlers.cancelPendingFrame();
211
314
  pendingMoveRef.current = null;
212
315
  pendingDragRef.current = null;
213
316
  endDocumentDragRef.current(null, "end");
@@ -263,103 +366,28 @@ export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { chi
263
366
  };
264
367
  }, [handlesWheel, pinchAsWheel]);
265
368
 
266
- const handleMouseDown = (event: MouseEvent) => {
267
- const hasSyntheticDrag = typeof propsRef.current.onMouse === "function";
268
- const hasDirectDrag = typeof propsRef.current.onMouseDrag === "function" || typeof propsRef.current.onMouseDragEnd === "function";
269
- pendingMoveRef.current = null;
270
- // A press that never saw mouseup (the window move took the pointer) is still tracked.
271
- // Finish it before the new press, so its drag-end cannot clear the drag this press starts.
272
- endDocumentDragRef.current(null, "end");
273
- callMouseHandler(propsRef.current.onMouseDown, event, "down");
274
- if (event.button !== 0 || (event.isPropagationStopped() && !hasDirectDrag)) return;
275
- if (!hasSyntheticDrag && !hasDirectDrag) return;
276
- callMouseHandler(propsRef.current.onMouse, event, "down");
277
- draggingRef.current = true;
278
- lastPointRef.current = { x: event.clientX, y: event.clientY };
279
- const originX = event.clientX;
280
- const originY = event.clientY;
281
- const move = (moveEvent: globalThis.MouseEvent) => {
282
- if (!draggingRef.current) return;
283
- const current = dragSessionRef.current;
284
- if (isPointerMove(moveEvent)) {
285
- if (current) current.pointerMoves = true;
286
- } else if (current?.pointerMoves) {
287
- return;
288
- }
289
- lastPointRef.current = { x: moveEvent.clientX, y: moveEvent.clientY };
290
- // The button is up and mouseup never arrived. End the drag instead of following the cursor.
291
- if (moveEvent.buttons === 0) {
292
- endDocumentDragRef.current(moveEvent, "end");
293
- return;
294
- }
295
- const dx = moveEvent.clientX - originX;
296
- const dy = moveEvent.clientY - originY;
297
- if (current && !current.shielded) {
298
- if (dx * dx + dy * dy < 9) return;
299
- current.shielded = true;
300
- showDragShield(elementRef.current);
301
- // Captured once it is a drag (a click keeps its usual target), the
302
- // moves skip hit testing and leave every other element's hover state
303
- // alone: nothing under the pointer restyles or repaints while a pane,
304
- // divider or chart is dragged across it. The document listeners still
305
- // see every move.
306
- if (!current.captured) current.captured = capturePointer(elementRef.current, pressedPointerRef.current);
307
- }
308
- scheduleFrameMouseHandler(moveEvent, "drag", predictedPoint(moveEvent));
309
- };
310
- const up = (upEvent: globalThis.MouseEvent) => {
311
- endDocumentDragRef.current(upEvent, "end");
312
- };
313
- const cancel = () => {
314
- endDocumentDragRef.current(null, "cancel");
315
- };
316
- dragSessionRef.current = { move, up, cancel, captured: null, pointerMoves: false, shielded: false };
317
- document.addEventListener("pointermove", move);
318
- document.addEventListener("mousemove", move);
319
- document.addEventListener("mouseup", up);
320
- document.addEventListener("pointerup", up);
321
- document.addEventListener("pointercancel", cancel);
322
- window.addEventListener("blur", cancel);
323
- };
324
-
325
369
  const handlesDrag = typeof props.onMouse === "function"
326
370
  || typeof props.onMouseDrag === "function"
327
371
  || typeof props.onMouseDragEnd === "function";
328
- const handlePointerDown = (event: PointerEvent) => {
329
- pressedPointerRef.current = event.pointerId;
330
- };
331
-
332
- const handleMouseDownCapture = (event: MouseEvent) => {
333
- callMouseHandler(propsRef.current.onMouseDownCapture, event, "down");
334
- };
335
-
336
- const handleMouseOver = (event: MouseEvent) => {
337
- callMouseHandler(propsRef.current.onMouseOver, event, "over");
338
- };
339
-
340
- const handleMouseOut = (event: MouseEvent) => {
341
- pendingMoveRef.current = null;
342
- callMouseHandler(propsRef.current.onMouseOut, event, "out");
343
- };
344
-
372
+ const style = useStableStyle({
373
+ ...commonStyle(props),
374
+ "--gloom-box-hover-bg": hoverBackgroundColor,
375
+ ...(props.style as CSSProperties | undefined),
376
+ ...(props.visible === false ? { display: "none" } : undefined),
377
+ } as CSSProperties);
345
378
  return (
346
379
  <div
347
380
  {...cleanDomProps(props)}
348
381
  data-gloom-hover-bg={hoverBackgroundColor ? "true" : undefined}
349
382
  ref={elementRef}
350
- onMouseDownCapture={typeof props.onMouseDownCapture === "function" ? handleMouseDownCapture : undefined}
351
- onPointerDown={handlesDrag ? handlePointerDown : undefined}
352
- onMouseDown={handleMouseDown}
353
- onMouseOver={handleMouseOver}
354
- onMouseMove={(event) => scheduleFrameMouseHandler(event, "move")}
355
- onMouseUp={(event) => callMouseHandler(propsRef.current.onMouseUp, event, "up")}
356
- onMouseOut={handleMouseOut}
357
- style={{
358
- ...commonStyle(props),
359
- "--gloom-box-hover-bg": hoverBackgroundColor,
360
- ...(props.style as CSSProperties | undefined),
361
- ...(props.visible === false ? { display: "none" } : undefined),
362
- } as CSSProperties}
383
+ onMouseDownCapture={typeof props.onMouseDownCapture === "function" ? handlers.handleMouseDownCapture : undefined}
384
+ onPointerDown={handlesDrag ? handlers.handlePointerDown : undefined}
385
+ onMouseDown={handlers.handleMouseDown}
386
+ onMouseOver={handlers.handleMouseOver}
387
+ onMouseMove={handlers.handleMouseMove}
388
+ onMouseUp={handlers.handleMouseUp}
389
+ onMouseOut={handlers.handleMouseOut}
390
+ style={style}
363
391
  >
364
392
  {children as ReactNode}
365
393
  </div>
@@ -1,4 +1,4 @@
1
- import type { CSSProperties } from "react";
1
+ import { useRef, type CSSProperties } from "react";
2
2
  import { TextAttributes, type TextProps } from "../../../ui/host";
3
3
  import { WEB_CELL_HEIGHT, WEB_CELL_WIDTH } from "../../../theme/font-scale";
4
4
 
@@ -113,30 +113,59 @@ export function textStyle(props: TextProps): CSSProperties {
113
113
  };
114
114
  }
115
115
 
116
+ /** Kit props a host element takes that are not DOM attributes (`onMouse*` handlers are left out too). */
117
+ const NON_DOM_PROPS: ReadonlySet<string> = new Set([
118
+ "fg", "bg", "backgroundColor", "flexDirection", "flexGrow", "flexShrink", "flexBasis", "flexWrap",
119
+ "alignItems", "justifyContent",
120
+ "padding", "paddingX", "paddingY", "paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
121
+ "margin", "marginX", "marginY", "marginLeft", "marginRight", "marginTop", "marginBottom",
122
+ "bold", "underline", "inverse", "dim", "italic", "strikethrough", "attributes", "content", "position", "left", "right", "top", "bottom",
123
+ "zIndex", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "gap", "columnGap", "rowGap",
124
+ "border", "borderStyle", "borderColor", "overflow", "selectable", "visible", "name", "color",
125
+ "focused", "focusedBackgroundColor", "textColor", "focusedTextColor", "placeholderColor",
126
+ "cursorColor", "selectionBg", "selectionFg", "showCursor", "keyBindings", "wrapText", "wrapMode",
127
+ "initialValue", "value", "onInput", "onChange", "onSubmit", "onEscape", "onCursorChange", "onMouse",
128
+ "scrollX", "scrollY", "focusable", "bitmap", "bitmaps", "crosshair", "vectors", "text", "font",
129
+ "hoverBackgroundColor", "joinPastedLines", "stickyScroll", "stickyStart", "onStickyPinChange", "pinchAsWheel",
130
+ ]);
131
+
132
+ /**
133
+ * The props a host element passes on to its DOM node, in their order. Built in
134
+ * one pass: every box and text run calls this on every render.
135
+ */
116
136
  export function cleanDomProps(props: Record<string, unknown>): Record<string, unknown> {
117
- const next = { ...props };
118
- for (const key of [
119
- "fg", "bg", "backgroundColor", "flexDirection", "flexGrow", "flexShrink", "flexBasis", "flexWrap",
120
- "alignItems", "justifyContent",
121
- "padding", "paddingX", "paddingY", "paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
122
- "margin", "marginX", "marginY", "marginLeft", "marginRight", "marginTop", "marginBottom",
123
- "bold", "underline", "inverse", "dim", "italic", "strikethrough", "attributes", "content", "position", "left", "right", "top", "bottom",
124
- "zIndex", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "gap", "columnGap", "rowGap",
125
- "border", "borderStyle", "borderColor", "overflow", "selectable", "visible", "name", "color",
126
- "focused", "focusedBackgroundColor", "textColor", "focusedTextColor", "placeholderColor",
127
- "cursorColor", "selectionBg", "selectionFg", "showCursor", "keyBindings", "wrapText", "wrapMode",
128
- "initialValue", "value", "onInput", "onChange", "onSubmit", "onEscape", "onCursorChange", "onMouse",
129
- "scrollX", "scrollY", "focusable", "bitmap", "bitmaps", "crosshair", "vectors", "text", "font",
130
- "hoverBackgroundColor", "joinPastedLines", "stickyScroll", "stickyStart", "onStickyPinChange", "pinchAsWheel",
131
- ]) {
132
- delete next[key];
133
- }
134
- for (const key of Object.keys(next)) {
135
- if (key.startsWith("onMouse")) delete next[key];
137
+ const next: Record<string, unknown> = {};
138
+ for (const key of Object.keys(props)) {
139
+ if (NON_DOM_PROPS.has(key) || key.startsWith("onMouse")) continue;
140
+ next[key] = props[key];
136
141
  }
137
142
  return next;
138
143
  }
139
144
 
145
+ /**
146
+ * `style` as it was last rendered while nothing in it changed, so React skips
147
+ * the element's inline style on a re-render instead of comparing every
148
+ * property again (and reading `element.style`). A host box re-renders with
149
+ * each render of its parent, and most leave its style as it was.
150
+ */
151
+ export function useStableStyle<T extends object>(style: T): T {
152
+ const previousRef = useRef<{ style: T; keys: string[] } | null>(null);
153
+ const previous = previousRef.current;
154
+ if (previous && sameStyle(previous.style as Record<string, unknown>, previous.keys, style as Record<string, unknown>)) return previous.style;
155
+ previousRef.current = { style, keys: Object.keys(style) };
156
+ return style;
157
+ }
158
+
159
+ /** The same keys with the same values, so React would write nothing. Read in order, which a rebuilt style keeps. */
160
+ function sameStyle(left: Record<string, unknown>, leftKeys: readonly string[], right: Record<string, unknown>): boolean {
161
+ let index = 0;
162
+ for (const key in right) {
163
+ if (leftKeys[index] !== key || left[key] !== right[key]) return false;
164
+ index += 1;
165
+ }
166
+ return index === leftKeys.length;
167
+ }
168
+
140
169
  function allowsZeroMinSize(props: Record<string, unknown>, axis: "inline" | "block"): boolean {
141
170
  if (props.overflow === "hidden" || props.overflow === "clip") return true;
142
171
  if (typeof props.flexShrink === "number" && props.flexShrink > 0) return true;
@@ -11,7 +11,7 @@ import { renderAsciiText } from "../../../ui/ascii-font";
11
11
  import { webAsciiTextLines, webAsciiTextWordmarkVariant } from "./ascii-text";
12
12
  import { BlockGlyphCanvas } from "./block-glyph-canvas";
13
13
  import { mouseHandlers } from "./mouse";
14
- import { cleanDomProps, commonStyle, selectionStyle, textStyle } from "./style";
14
+ import { cleanDomProps, commonStyle, selectionStyle, textStyle, useStableStyle } from "./style";
15
15
 
16
16
  // Read per render: the cell width tracks the configured font size.
17
17
  function wordmarkCharWidthPx(): number {
@@ -60,11 +60,12 @@ function renderTextContent(children: ReactNode, content: TextProps["content"], b
60
60
  }
61
61
 
62
62
  export function WebText({ children, ...props }: TextProps) {
63
+ const style = useStableStyle({ ...textStyle(props), ...(props.style as CSSProperties | undefined) });
63
64
  return (
64
65
  <span
65
66
  {...cleanDomProps(props)}
66
67
  {...mouseHandlers(props)}
67
- style={{ ...textStyle(props), ...(props.style as CSSProperties | undefined) }}
68
+ style={style}
68
69
  >
69
70
  {renderTextContent(children, props.content, props)}
70
71
  </span>
@@ -176,6 +176,21 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
176
176
  border: 0;
177
177
  border-radius: 0;
178
178
  }
179
+ /* Docked panes sit a small gap apart (the shell's dock geometry). Each one
180
+ rules the sides that face another pane across it, in the colour of the line
181
+ that ran between them, so the gap reads in every theme. */
182
+ [data-gloom-role="pane-window"][data-floating="false"][data-dock-edges]::after {
183
+ content: "";
184
+ position: absolute;
185
+ inset: 0;
186
+ border: 0 solid var(--gloom-border);
187
+ pointer-events: none;
188
+ z-index: 100;
189
+ }
190
+ [data-gloom-role="pane-window"][data-floating="false"][data-dock-edges~="left"]::after { border-left-width: 1px; }
191
+ [data-gloom-role="pane-window"][data-floating="false"][data-dock-edges~="right"]::after { border-right-width: 1px; }
192
+ [data-gloom-role="pane-window"][data-floating="false"][data-dock-edges~="top"]::after { border-top-width: 1px; }
193
+ [data-gloom-role="pane-window"][data-floating="false"][data-dock-edges~="bottom"]::after { border-bottom-width: 1px; }
179
194
  [data-gloom-role="pane-window"][data-floating="false"][data-focused="true"] {
180
195
  box-shadow: inset 0 0 0 1px var(--pane-border-color, var(--gloom-border-focused));
181
196
  }
@@ -663,10 +678,25 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
663
678
  [data-gloom-role="dock-divider"] {
664
679
  background: transparent !important;
665
680
  }
681
+ /* Where a moving pane would land (a spot it would join or stack in, a
682
+ screen-edge snap, window mode's keyboard move): the exact rectangle,
683
+ outlined in the accent over a light tint of it, so the panes under it still
684
+ show. */
685
+ [data-gloom-role="drop-preview"],
686
+ [data-gloom-role="window-mode-drop-preview"] {
687
+ border: 2px solid var(--gloom-accent);
688
+ border-radius: var(--gloom-radius-md);
689
+ background: color-mix(in srgb, var(--gloom-accent) 12%, transparent);
690
+ }
691
+ /* The gap between the panes is the divider at rest; its line shows while it
692
+ is dragged or resized from the keyboard. */
666
693
  [data-gloom-role="dock-divider"]::before {
667
694
  content: "";
668
695
  position: absolute;
669
696
  background: var(--divider-color);
697
+ opacity: 0;
698
+ }
699
+ [data-gloom-role="dock-divider"][data-active="true"]::before {
670
700
  opacity: .9;
671
701
  }
672
702
  [data-gloom-role="dock-divider"][data-axis="horizontal"] {
@@ -1288,6 +1318,7 @@ html[data-gloom-screenshot="true"] [data-gloom-role="chart-watermark"] {
1288
1318
  overflow clip without changing the layout size. */
1289
1319
  [data-gloom-role="pane-header"] [data-gloom-role="pane-title"],
1290
1320
  [data-gloom-role="pane-header-tabs"] [data-gloom-role="tab-label"],
1321
+ [data-gloom-role="pane-stack-tabs"] [data-gloom-role="tab-label"],
1291
1322
  .gloom-qb-label,
1292
1323
  .gloom-qb-value,
1293
1324
  .gloom-qb-text,
@@ -1298,6 +1329,7 @@ html[data-gloom-screenshot="true"] [data-gloom-role="chart-watermark"] {
1298
1329
  }
1299
1330
  [data-gloom-role="pane-header"] [data-gloom-role="pane-title"],
1300
1331
  [data-gloom-role="pane-header-tabs"] [data-gloom-role="tab-label"],
1332
+ [data-gloom-role="pane-stack-tabs"] [data-gloom-role="tab-label"],
1301
1333
  .gloom-qb-title,
1302
1334
  .gloom-qb-meta {
1303
1335
  padding-block: var(--gloom-space-xs);
@@ -570,7 +570,9 @@ export class DesktopBackend {
570
570
  case "host.exit":
571
571
  case "host.windowControl":
572
572
  case "host.windowFullscreen":
573
+ case "host.windowMaximized":
573
574
  case "host.startWindowDrag":
575
+ case "host.startWindowResize":
574
576
  case "host.openExternal":
575
577
  case "host.copyText":
576
578
  case "host.focusWindow":