gloomberb 0.19.4 → 0.19.6

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 (321) hide show
  1. package/package.json +3 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
  3. package/src/api-client/equity-screener.ts +23 -0
  4. package/src/app/pane-runtime/index.tsx +2 -0
  5. package/src/app/pane-runtime/plugin-bindings.ts +10 -1
  6. package/src/app.tsx +63 -16
  7. package/src/cli/commands/command-utils.ts +4 -0
  8. package/src/cli/commands/market.ts +264 -33
  9. package/src/cli/commands/search.ts +22 -4
  10. package/src/cli/commands/ticker.ts +84 -39
  11. package/src/cli/currency-name-hint.ts +60 -0
  12. package/src/cli/glossary.ts +3 -3
  13. package/src/cli/history-rows.ts +18 -1
  14. package/src/cli/known-gaps.ts +25 -2
  15. package/src/cli/listing-arg.ts +12 -0
  16. package/src/cli/not-a-ticker.ts +5 -3
  17. package/src/cli/pane-functions/capabilities.ts +2 -0
  18. package/src/cli/pane-functions/catalog.ts +31 -5
  19. package/src/cli/pane-functions/function-help.ts +8 -5
  20. package/src/cli/pane-functions/headless.ts +11 -6
  21. package/src/cli/pane-functions/market-session.ts +6 -7
  22. package/src/cli/pane-functions/resolver.ts +75 -2
  23. package/src/cli/quote-answer.ts +9 -0
  24. package/src/cli/series-search.ts +4 -5
  25. package/src/cli/symbol-list.ts +54 -2
  26. package/src/cli/symbol-rows.ts +14 -2
  27. package/src/cli/ticker-resolution.ts +89 -20
  28. package/src/components/chart/composite/axis-overlays.tsx +60 -27
  29. package/src/components/chart/composite/composite-chart.tsx +118 -63
  30. package/src/components/chart/composite/cursor-source.ts +111 -0
  31. package/src/components/chart/composite/format.ts +168 -6
  32. package/src/components/chart/composite/legend.tsx +8 -4
  33. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  34. package/src/components/chart/composite/panel-labels.ts +20 -1
  35. package/src/components/chart/composite/panel-surface.tsx +201 -92
  36. package/src/components/chart/composite/price-axis-labels.tsx +92 -46
  37. package/src/components/chart/composite/price-series.ts +31 -8
  38. package/src/components/chart/composite/scene.ts +154 -59
  39. package/src/components/chart/composite/series-axis-tags.tsx +4 -2
  40. package/src/components/chart/composite/time-axis.ts +30 -7
  41. package/src/components/chart/composite/time-scale.ts +211 -56
  42. package/src/components/chart/composite/types.ts +11 -1
  43. package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
  44. package/src/components/chart/curve/curve-surface.tsx +5 -2
  45. package/src/components/chart/curve/model.ts +4 -1
  46. package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
  47. package/src/components/chart/static/series.ts +3 -0
  48. package/src/components/command-bar/commands/collection-list.ts +81 -0
  49. package/src/components/command-bar/commands/direct/index.ts +6 -0
  50. package/src/components/command-bar/commands/registry.ts +8 -0
  51. package/src/components/command-bar/layout-items/current-layout.ts +22 -1
  52. package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
  53. package/src/components/command-bar/pane-templates/items.ts +19 -3
  54. package/src/components/command-bar/pane-templates/workflow.ts +5 -0
  55. package/src/components/command-bar/routes/root/results.ts +23 -3
  56. package/src/components/command-bar/routes/root/selection.ts +4 -2
  57. package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
  58. package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
  59. package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
  60. package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
  61. package/src/components/command-bar/surface/environment.ts +2 -0
  62. package/src/components/command-bar/view-model.ts +7 -0
  63. package/src/components/command-bar/workflow/ops.ts +2 -1
  64. package/src/components/command-bar/workflow/tickers.ts +20 -0
  65. package/src/components/layout/shell/active-drag.ts +38 -7
  66. package/src/components/layout/shell/drag/magnets.ts +106 -0
  67. package/src/components/layout/shell/menu.ts +15 -1
  68. package/src/components/layout/shell/pane/actions.ts +4 -0
  69. package/src/components/layout/shell/ticker-link-menu.ts +12 -3
  70. package/src/components/layout/status-bar.tsx +20 -0
  71. package/src/components/layout/window-controls.tsx +96 -35
  72. package/src/components/layout/window-fullscreen.ts +20 -0
  73. package/src/components/onboarding/onboarding-keyboard.ts +5 -1
  74. package/src/components/onboarding/onboarding-wizard.tsx +15 -4
  75. package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
  76. package/src/components/onboarding/use-onboarding-progress.ts +20 -1
  77. package/src/components/price-sparkline/view.tsx +14 -6
  78. package/src/components/quote-flash.ts +36 -32
  79. package/src/components/ticker/badge/index.tsx +8 -4
  80. package/src/components/ticker/badge/list.tsx +23 -7
  81. package/src/components/ui/column-grid.tsx +8 -2
  82. package/src/components/ui/data-table/opentui/model.ts +4 -1
  83. package/src/components/ui/tabs.tsx +5 -2
  84. package/src/core/state/app/layout.ts +18 -3
  85. package/src/core/state/app/state.ts +2 -0
  86. package/src/core/state/app/types.ts +5 -0
  87. package/src/data/config/layout.ts +3 -0
  88. package/src/data/config/store/normalize.ts +39 -4
  89. package/src/i18n/es.ts +10 -0
  90. package/src/i18n/ja.ts +10 -0
  91. package/src/i18n/ko.ts +10 -0
  92. package/src/i18n/zh-cn.ts +10 -0
  93. package/src/i18n/zh-tw.ts +10 -0
  94. package/src/layout/pane-manager/floating-placement.ts +7 -4
  95. package/src/layout/pane-manager/floating.ts +5 -2
  96. package/src/market-data/bond-funds.ts +19 -0
  97. package/src/market-data/coordinator/events.ts +17 -1
  98. package/src/market-data/frame-scheduler.ts +47 -10
  99. package/src/market-data/frame-wake.ts +74 -0
  100. package/src/market-data/futures-board.ts +7 -6
  101. package/src/market-data/futures-contract.ts +14 -3
  102. package/src/market-data/hooks.tsx +12 -3
  103. package/src/market-data/market/freshness.ts +18 -0
  104. package/src/market-data/market/status.ts +15 -2
  105. package/src/market-data/performance.ts +78 -9
  106. package/src/market-data/request-types.ts +6 -3
  107. package/src/plugins/builtin/alerts/cli.ts +2 -1
  108. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  109. package/src/plugins/builtin/attention/evidence.ts +1 -1
  110. package/src/plugins/builtin/awards/client.ts +1 -1
  111. package/src/plugins/builtin/awards/evidence.ts +1 -1
  112. package/src/plugins/builtin/awards/pane.tsx +2 -1
  113. package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
  114. package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
  115. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  116. package/src/plugins/builtin/bond-calculator/model.ts +14 -5
  117. package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
  118. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  119. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  120. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  121. package/src/plugins/builtin/buildout/cells.tsx +25 -45
  122. package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
  123. package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
  124. package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
  125. package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
  126. package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
  127. package/src/plugins/builtin/buildout/format.ts +23 -1
  128. package/src/plugins/builtin/buildout/model/types.ts +1 -0
  129. package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
  130. package/src/plugins/builtin/buildout/table-model.ts +12 -4
  131. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  132. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  133. package/src/plugins/builtin/cds/headless.ts +1 -0
  134. package/src/plugins/builtin/cds/index.tsx +1 -1
  135. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  136. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  137. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
  138. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  139. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  140. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  141. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  142. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  143. package/src/plugins/builtin/correlation/headless.ts +3 -2
  144. package/src/plugins/builtin/cot/headless.ts +9 -3
  145. package/src/plugins/builtin/cot/model.ts +44 -3
  146. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  147. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  148. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  149. package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
  150. package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
  151. package/src/plugins/builtin/debt-maturities/model.ts +66 -0
  152. package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
  153. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  154. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  155. package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
  156. package/src/plugins/builtin/econ/calendar-model.ts +30 -6
  157. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  158. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  159. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  160. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
  161. package/src/plugins/builtin/equity-screener/headless.ts +4 -2
  162. package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
  163. package/src/plugins/builtin/equity-screener/model.ts +180 -12
  164. package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
  165. package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
  166. package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
  167. package/src/plugins/builtin/futures/series.ts +16 -1
  168. package/src/plugins/builtin/futures-curve/client.ts +19 -0
  169. package/src/plugins/builtin/futures-curve/headless.ts +52 -13
  170. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  171. package/src/plugins/builtin/futures-curve/model.ts +77 -6
  172. package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
  173. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  174. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  175. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  176. package/src/plugins/builtin/gpu/headless.ts +2 -1
  177. package/src/plugins/builtin/help/function-card.tsx +2 -1
  178. package/src/plugins/builtin/help/index.tsx +2 -1
  179. package/src/plugins/builtin/insider/display.ts +45 -6
  180. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  181. package/src/plugins/builtin/iv-history/client.ts +2 -1
  182. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  183. package/src/plugins/builtin/jobs/pages.ts +4 -4
  184. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  185. package/src/plugins/builtin/macro-day/client.ts +41 -0
  186. package/src/plugins/builtin/macro-day/headless.ts +19 -9
  187. package/src/plugins/builtin/macro-day/model.ts +3 -1
  188. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  189. package/src/plugins/builtin/market-movers/index.tsx +4 -3
  190. package/src/plugins/builtin/members/client.ts +1 -1
  191. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  192. package/src/plugins/builtin/mna/distress/headless.ts +1 -0
  193. package/src/plugins/builtin/mna/pane.tsx +4 -1
  194. package/src/plugins/builtin/options/market-reference.ts +1 -1
  195. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  196. package/src/plugins/builtin/options/view.tsx +2 -1
  197. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  198. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  199. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  200. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  201. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  202. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  203. package/src/plugins/builtin/perps/client.ts +1 -1
  204. package/src/plugins/builtin/perps/pane.tsx +3 -1
  205. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
  206. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
  207. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +4 -2
  208. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  209. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  210. package/src/plugins/builtin/rate-path/headless.ts +24 -10
  211. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  212. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  213. package/src/plugins/builtin/research/event-model.ts +10 -3
  214. package/src/plugins/builtin/research/events-headless.ts +20 -2
  215. package/src/plugins/builtin/research/index.tsx +1 -0
  216. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  217. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  218. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  219. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  220. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  221. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  222. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  223. package/src/plugins/builtin/sec/fund-facts.ts +17 -1
  224. package/src/plugins/builtin/sec/index.tsx +8 -5
  225. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  226. package/src/plugins/builtin/shared/members-menu.tsx +103 -38
  227. package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
  228. package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
  229. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  230. package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
  231. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  232. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  233. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  234. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  235. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  236. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  237. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  238. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  239. package/src/plugins/builtin/time-sales/client.ts +1 -0
  240. package/src/plugins/builtin/time-sales/pane.tsx +3 -2
  241. package/src/plugins/builtin/trace-bonds/client.ts +7 -4
  242. package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
  243. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  244. package/src/plugins/builtin/volatility/client.ts +6 -1
  245. package/src/plugins/builtin/volatility/headless.ts +0 -1
  246. package/src/plugins/builtin/yield-curve/curves.ts +15 -0
  247. package/src/plugins/builtin/yield-curve/headless.ts +9 -2
  248. package/src/plugins/builtin/yield-curve/index.tsx +5 -8
  249. package/src/plugins/host-modules.ts +22 -3
  250. package/src/plugins/host-smoke.ts +6 -3
  251. package/src/portfolio/collection-name.ts +19 -0
  252. package/src/portfolio/column-values.ts +76 -10
  253. package/src/renderers/browser/http-proxy-transport.ts +78 -8
  254. package/src/renderers/cloudflare/http-proxy.ts +13 -2
  255. package/src/renderers/cloudflare/proxy-session.ts +47 -24
  256. package/src/renderers/cloudflare/worker.ts +15 -2
  257. package/src/renderers/desktop/geometry.ts +279 -0
  258. package/src/renderers/desktop/screen-setup.ts +246 -0
  259. package/src/renderers/desktop/sequential-window-host.ts +179 -0
  260. package/src/renderers/desktop/test-utils.ts +71 -0
  261. package/src/renderers/desktop/window-controller.ts +433 -0
  262. package/src/renderers/desktop/window-host.ts +70 -0
  263. package/src/renderers/desktop/window-layouts.ts +630 -0
  264. package/src/renderers/dom/data-frames.ts +15 -4
  265. package/src/renderers/dom/host/box.tsx +204 -176
  266. package/src/renderers/dom/host/style.ts +49 -20
  267. package/src/renderers/dom/host/text.tsx +3 -2
  268. package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
  269. package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
  270. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
  271. package/src/renderers/electrobun/bun/desktop/backend.ts +322 -19
  272. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
  273. package/src/renderers/electrobun/bun/desktop/host-requests.ts +29 -15
  274. package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
  275. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  276. package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
  277. package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
  278. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  279. package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
  280. package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
  281. package/src/renderers/electrobun/bun/index.ts +4 -97
  282. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
  283. package/src/renderers/electrobun/bun/window/focus.ts +0 -25
  284. package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
  285. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  286. package/src/renderers/electrobun/shared/protocol.ts +50 -2
  287. package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
  288. package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
  289. package/src/renderers/electrobun/view/main.tsx +13 -7
  290. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  291. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  292. package/src/series/fred-argument.ts +17 -0
  293. package/src/sources/provider-router/financial-routes.ts +7 -1
  294. package/src/sources/provider-router/index.ts +7 -1
  295. package/src/state/app/context/index.tsx +16 -2
  296. package/src/state/desktop-windows.ts +63 -0
  297. package/src/sync/other-window-tabs.ts +62 -0
  298. package/src/tickers/company-name-listing.ts +23 -3
  299. package/src/tickers/listing-fate.ts +147 -1
  300. package/src/tickers/terminal-codes.ts +5 -0
  301. package/src/time-series/price-units.ts +11 -0
  302. package/src/time-series/types.ts +6 -0
  303. package/src/types/config.ts +10 -1
  304. package/src/types/desktop-window.ts +71 -2
  305. package/src/types/financials.ts +4 -0
  306. package/src/types/headless.ts +19 -0
  307. package/src/types/plugin.ts +6 -0
  308. package/src/ui/host.tsx +2 -0
  309. package/src/ui/index.tsx +14 -13
  310. package/src/ui/same-props.ts +58 -0
  311. package/src/utils/cli-output.ts +33 -4
  312. package/src/utils/currency-names.ts +20 -0
  313. package/src/utils/currency-pair.ts +6 -0
  314. package/src/utils/exchange-rate-snapshot.ts +20 -2
  315. package/src/utils/format.ts +7 -2
  316. package/src/utils/futures-generic.ts +12 -0
  317. package/src/utils/fx-market-hours.ts +43 -0
  318. package/src/utils/http-proxy-upstream.ts +6 -2
  319. package/src/utils/plugin-proxy-hosts.json +0 -4
  320. package/src/utils/plugin-proxy-hosts.ts +22 -0
  321. package/src/utils/sec-filings.ts +7 -1
@@ -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>
@@ -35,6 +35,7 @@ function normalizeApplicationMenuCommand(value: unknown): ElectrobunApplicationM
35
35
  case "layout-redo":
36
36
  case "layout-gridlock":
37
37
  case "open-devtools":
38
+ case "new-window":
38
39
  case "quit":
39
40
  return { type: command.type };
40
41
  default:
@@ -9,7 +9,8 @@ const GITHUB_ISSUE_URL = "https://github.com/gloom-sh/gloomberb/issues/new/choos
9
9
 
10
10
  export type ElectrobunApplicationMenuCommand =
11
11
  | DesktopApplicationMenuCommand
12
- | { type: "open-devtools" };
12
+ | { type: "open-devtools" }
13
+ | { type: "new-window" };
13
14
 
14
15
  function commandItem(
15
16
  label: string,
@@ -49,6 +50,8 @@ function buildApplicationMenu(keybindings: ResolvedKeybindings): ApplicationMenu
49
50
  {
50
51
  label: "File",
51
52
  submenu: [
53
+ commandItem("New Window", { type: "new-window" }),
54
+ { type: "divider" },
52
55
  openCommandBar("Search Ticker...", "DES ", accelerator("ticker-search")),
53
56
  { type: "divider" },
54
57
  commandItem("New Portfolio...", { type: "open-builtin-workflow", actionId: "new-portfolio" }),
@@ -13,7 +13,7 @@ import type {
13
13
  } from "../../shared/protocol";
14
14
  import { encodeRpcValue } from "../../shared/rpc-codec";
15
15
  import { desktopBootFramePath, removeDesktopBootFrame } from "../window/boot-frame";
16
- import { paneIdFromDetachedRpcKey } from "../window/focus";
16
+ import { MAIN_WINDOW_RPC_KEY, paneIdFromDetachedRpcKey } from "../window/focus";
17
17
  import type { DesktopBackend, DesktopRpc } from "./backend";
18
18
  import { createElectrobunDesktopUpdater } from "./update";
19
19
 
@@ -29,9 +29,13 @@ function sendUpdateProgress(rpc: DesktopRpc, progress: UpdateProgress): void {
29
29
  }
30
30
  }
31
31
 
32
- /** Every window loses its popped-out panes, workspace and services before the data they read is replaced. */
32
+ /**
33
+ * Every window but the main one closes, and the workspace and services go,
34
+ * before the data they read is replaced. Extra windows open again with the
35
+ * next session where their tabs are still there.
36
+ */
33
37
  function closeDesktopSession(backend: DesktopBackend): void {
34
- backend.detachedWindows.closeAll();
38
+ backend.closeAllWindows();
35
39
  backend.workspace = null;
36
40
  backend.teardownServices();
37
41
  }
@@ -68,11 +72,13 @@ export async function handleDesktopBackendRequest(
68
72
  case "config.save": {
69
73
  const desktopWorkspace = backend.workspace;
70
74
  if (desktopWorkspace) {
71
- // Null for the main window; a popped-out window's save counts only for its own pane.
72
- const senderDetachedPaneId = paneIdFromDetachedRpcKey(backend.rpcs.getRpcWindowKey(rpc));
75
+ // A popped-out window's save counts only for its own pane; a full
76
+ // window's for what it changed, among its own tabs.
77
+ const senderKey = backend.rpcs.getRpcWindowKey(rpc);
78
+ const senderDetachedPaneId = paneIdFromDetachedRpcKey(senderKey);
73
79
  await backend.commitDesktopSnapshot(senderDetachedPaneId
74
80
  ? desktopWorkspace.replaceConfigFromDetachedPane(senderDetachedPaneId, request.payload.config)
75
- : desktopWorkspace.replaceConfig(request.payload.config, { layoutChanged: true }));
81
+ : desktopWorkspace.replaceConfigFromWindow(senderKey ?? MAIN_WINDOW_RPC_KEY, request.payload.config));
76
82
  return null;
77
83
  }
78
84
  backend.setConfig(request.payload.config);
@@ -86,9 +92,14 @@ export async function handleDesktopBackendRequest(
86
92
  removeDesktopBootFrame(desktopBootFramePath());
87
93
  await resetAllData(request.payload.dataDir);
88
94
  return null;
89
- case "config.export":
90
- await exportConfig(request.payload.config, request.payload.destPath);
95
+ case "config.export": {
96
+ // With more than one window, each has only its own tabs: the export is
97
+ // the whole config, every window's tabs included.
98
+ const workspace = backend.workspace;
99
+ const config = workspace && workspace.windowIds().length > 1 ? workspace.getSnapshot().config : request.payload.config;
100
+ await exportConfig(config, request.payload.destPath);
91
101
  return null;
102
+ }
92
103
  case "config.import": {
93
104
  closeDesktopSession(backend);
94
105
  await backend.startServices(await importConfig(request.payload.dataDir, request.payload.srcPath));