@gloom-sh/terminal 0.20.21 → 0.20.23

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 (694) hide show
  1. package/package.json +4 -3
  2. package/patches/electrobun-devkit@2.0.5.patch +169 -3
  3. package/src/account/heard-from-question.tsx +6 -4
  4. package/src/account/heard-from.ts +3 -4
  5. package/src/api-client/buybacks.ts +108 -0
  6. package/src/api-client/data.ts +213 -1
  7. package/src/api-client/dilution.ts +183 -0
  8. package/src/api-client/earnings.ts +2 -2
  9. package/src/api-client/equity-screener.ts +7 -0
  10. package/src/api-client/exchange-announcements.ts +16 -5
  11. package/src/api-client/exchange-short-balances.ts +24 -0
  12. package/src/api-client/heard-from.ts +5 -7
  13. package/src/api-client/hk-cbbc.ts +134 -0
  14. package/src/api-client/hk-ccass.ts +233 -0
  15. package/src/api-client/index.ts +55 -3
  16. package/src/api-client/jpx-short-positions.ts +24 -0
  17. package/src/api-client/market-discovery.ts +34 -6
  18. package/src/api-client/members.ts +5 -0
  19. package/src/api-client/ownership-disclosures.ts +68 -0
  20. package/src/api-client/paths.ts +2 -2
  21. package/src/api-client/request.ts +39 -10
  22. package/src/api-client/revenue-breakdown.ts +6 -2
  23. package/src/api-client/sfc-short-positions.ts +19 -0
  24. package/src/api-client/supply-chain.ts +22 -0
  25. package/src/api-client/taiwan-revenue.ts +134 -0
  26. package/src/api-client/types/jobs.ts +1 -0
  27. package/src/api-client/types/ticker-data.ts +3 -1
  28. package/src/api-client/types/world-venues.ts +1 -0
  29. package/src/app/language-observer.tsx +6 -1
  30. package/src/app/pane-runtime/plugin-bindings.ts +9 -4
  31. package/src/app/runtime/plugin-bindings.ts +20 -2
  32. package/src/architecture/core-builtin-allowlist.json +2 -2
  33. package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
  34. package/src/architecture/dom-text-cuts-allowlist.json +2 -2
  35. package/src/architecture/floating-promise-allowlist.json +2 -2
  36. package/src/architecture/pane-tabs-allowlist.json +3 -0
  37. package/src/brokers/account-cache.ts +2 -1
  38. package/src/brokers/account-choice.ts +121 -0
  39. package/src/brokers/broker-portfolio-sync.ts +30 -5
  40. package/src/brokers/profile-form.ts +3 -0
  41. package/src/brokers/signed-in/adapter.ts +16 -5
  42. package/src/brokers/sync-broker-instance.ts +27 -3
  43. package/src/capabilities/asset-data-inputs.ts +8 -0
  44. package/src/capabilities/factories.ts +4 -0
  45. package/src/cli/commands/market.ts +141 -76
  46. package/src/cli/commands/news-search.ts +12 -0
  47. package/src/cli/commands/options-chain.ts +9 -3
  48. package/src/cli/commands/options-leaps.ts +55 -30
  49. package/src/cli/commands/overview.ts +20 -23
  50. package/src/cli/commands/search.ts +2 -1
  51. package/src/cli/commands/ticker.ts +17 -18
  52. package/src/cli/csv-export.ts +9 -5
  53. package/src/cli/desktop-pane-shot-browser.ts +143 -53
  54. package/src/cli/desktop-pane-shot.ts +50 -64
  55. package/src/cli/export-source.ts +9 -4
  56. package/src/cli/history-demergers.ts +134 -11
  57. package/src/cli/history-rows.ts +47 -7
  58. package/src/cli/listing-arg.ts +45 -18
  59. package/src/cli/pane-functions/catalog-snapshot.json +26 -22
  60. package/src/cli/pane-functions/catalog.ts +6 -2
  61. package/src/cli/pane-functions/data.ts +3 -1
  62. package/src/cli/pane-functions/dom.ts +8 -5
  63. package/src/cli/pane-functions/freshness.ts +6 -1
  64. package/src/cli/pane-functions/function-help.ts +32 -2
  65. package/src/cli/pane-functions/headless.ts +79 -27
  66. package/src/cli/pane-functions/index.ts +2 -1
  67. package/src/cli/pane-functions/market-session.ts +13 -3
  68. package/src/cli/pane-functions/resolver.ts +4 -1
  69. package/src/cli/pane-functions/screenshot-assessment.ts +26 -10
  70. package/src/cli/pane-functions/screenshot-bridge.ts +4 -1
  71. package/src/cli/pane-functions/screenshot-data-evidence.ts +11 -5
  72. package/src/cli/pane-functions/screenshot-payload.ts +21 -3
  73. package/src/cli/pane-functions/screenshot-render.ts +2 -0
  74. package/src/cli/pane-functions/ticker-question.ts +52 -47
  75. package/src/cli/rendered-table-rows.ts +75 -0
  76. package/src/cli/report-tables.ts +7 -1
  77. package/src/cli/result.ts +9 -2
  78. package/src/cli/symbol-list.ts +52 -14
  79. package/src/cli/ticker-resolution.ts +133 -38
  80. package/src/cli/visible-key-values.ts +3 -2
  81. package/src/components/chart/composite/composite-chart.tsx +12 -0
  82. package/src/components/chart/composite/format.ts +14 -1
  83. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +37 -14
  84. package/src/components/chart/composite/panel-surface.tsx +1 -0
  85. package/src/components/chart/composite/text-renderer.ts +104 -44
  86. package/src/components/chart/composite/types.ts +18 -0
  87. package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
  88. package/src/components/chart/curve/model.ts +4 -1
  89. package/src/components/chart-table/header.tsx +11 -5
  90. package/src/components/chart-table/selection.ts +20 -1
  91. package/src/components/command-bar/routes/root/start-here.ts +1 -1
  92. package/src/components/command-bar/routes/ticker-search/results.ts +2 -1
  93. package/src/components/data-table/export.ts +3 -1
  94. package/src/components/data-table/sections.ts +12 -1
  95. package/src/components/data-table/view.tsx +52 -8
  96. package/src/components/feed-data-table/stack-view.tsx +88 -5
  97. package/src/components/index.ts +3 -3
  98. package/src/components/layout/floating-pane.tsx +5 -2
  99. package/src/components/layout/pane/header.tsx +33 -32
  100. package/src/components/layout/pane/index.tsx +6 -2
  101. package/src/components/layout/pane/link-note.ts +12 -0
  102. package/src/components/layout/pane/title.ts +1 -3
  103. package/src/components/market-board/index.tsx +8 -11
  104. package/src/components/reader/reader-text.tsx +25 -2
  105. package/src/components/ticker/badge/index.tsx +9 -4
  106. package/src/components/ticker/badge/list.tsx +3 -1
  107. package/src/components/ticker/list-table-view.tsx +4 -0
  108. package/src/components/ui/data-table/column-fit.ts +129 -0
  109. package/src/components/ui/data-table/display-columns.ts +28 -9
  110. package/src/components/ui/data-table/index.tsx +64 -16
  111. package/src/components/ui/data-table/muted-row.tsx +47 -0
  112. package/src/components/ui/data-table/opentui/index.tsx +47 -11
  113. package/src/components/ui/data-table/spill.ts +36 -0
  114. package/src/components/ui/data-table/types.ts +113 -6
  115. package/src/components/ui/data-table/use-column-order.ts +11 -0
  116. package/src/components/ui/data-table/visible-range.ts +9 -1
  117. package/src/components/ui/day-cell.ts +30 -0
  118. package/src/components/ui/icon.tsx +50 -3
  119. package/src/components/ui/index.ts +3 -1
  120. package/src/components/ui/list-view.tsx +2 -2
  121. package/src/components/ui/prose.tsx +3 -1
  122. package/src/components/ui/table-layout.ts +220 -6
  123. package/src/components/ui/terminal-hover-label.tsx +49 -0
  124. package/src/components/use-pinned-moment.ts +222 -13
  125. package/src/core/state/app/layout.ts +7 -2
  126. package/src/core/state/app/state.ts +17 -4
  127. package/src/core/state/app/types.ts +2 -1
  128. package/src/data/config/store/legacy-tabs.ts +51 -0
  129. package/src/data/config/store/node.ts +2 -2
  130. package/src/data/config/store/normalize.ts +11 -5
  131. package/src/data/config/store/shared-file.ts +8 -7
  132. package/src/data/config/store/shared-layout.ts +146 -0
  133. package/src/data/sqlite/access.ts +90 -12
  134. package/src/data/sqlite/checkpointer.ts +75 -12
  135. package/src/data/sqlite/database.ts +18 -1
  136. package/src/data/sqlite/retry.ts +1 -1
  137. package/src/docs/load.ts +5 -2
  138. package/src/docs/snapshot.json +1862 -4456
  139. package/src/i18n/es.ts +109 -0
  140. package/src/i18n/index.ts +74 -4
  141. package/src/i18n/ja.ts +109 -0
  142. package/src/i18n/ko.ts +109 -0
  143. package/src/i18n/react.ts +10 -2
  144. package/src/i18n/zh-cn.ts +109 -0
  145. package/src/i18n/zh-tw.ts +109 -0
  146. package/src/layout/pane-manager/dock-normalization.ts +61 -0
  147. package/src/market-data/ah-pair.ts +7 -2
  148. package/src/market-data/fund-actions.ts +21 -0
  149. package/src/market-data/market/freshness.ts +39 -35
  150. package/src/market-data/market/globex-day.ts +14 -0
  151. package/src/market-data/market/split-price-basis.ts +55 -0
  152. package/src/market-data/market/status.ts +2 -4
  153. package/src/market-data/price-adjustments.ts +115 -0
  154. package/src/market-data/published-us-sessions.ts +3 -2
  155. package/src/market-data/quotes/balance-sheet-rate.ts +6 -2
  156. package/src/market-data/quotes/day-range.ts +24 -9
  157. package/src/market-data/quotes/freshness.ts +4 -3
  158. package/src/market-data/quotes/live-valuation.ts +4 -2
  159. package/src/market-data/quotes/metadata.ts +48 -5
  160. package/src/market-data/quotes/regular-session-valuation.ts +18 -1
  161. package/src/market-data/quotes/resolution.ts +18 -29
  162. package/src/market-data/quotes/time.ts +138 -14
  163. package/src/news/query-presets.ts +6 -4
  164. package/src/plugins/builtin/alerts/cli-forms.ts +3 -0
  165. package/src/plugins/builtin/alerts/cli.ts +19 -7
  166. package/src/plugins/builtin/alerts/events-pane.tsx +1 -0
  167. package/src/plugins/builtin/alerts/format.ts +22 -10
  168. package/src/plugins/builtin/alerts/headless.ts +7 -4
  169. package/src/plugins/builtin/alerts/history-pane.tsx +93 -36
  170. package/src/plugins/builtin/alerts/history-rows.ts +24 -1
  171. package/src/plugins/builtin/alerts/index.tsx +8 -10
  172. package/src/plugins/builtin/alerts/metric-data.ts +24 -6
  173. package/src/plugins/builtin/alerts/pane.tsx +9 -0
  174. package/src/plugins/builtin/alerts/pro-rules.ts +1 -0
  175. package/src/plugins/builtin/alerts/research-builder.ts +6 -2
  176. package/src/plugins/builtin/alerts/research-rules.ts +12 -0
  177. package/src/plugins/builtin/alerts/types.ts +1 -0
  178. package/src/plugins/builtin/awards/detail.tsx +5 -4
  179. package/src/plugins/builtin/awards/headless.ts +13 -4
  180. package/src/plugins/builtin/awards/model.ts +36 -1
  181. package/src/plugins/builtin/awards/pane.tsx +29 -9
  182. package/src/plugins/builtin/backtest/pane.tsx +4 -2
  183. package/src/plugins/builtin/bond-calculator/pane.tsx +2 -1
  184. package/src/plugins/builtin/broker-manager/detail.tsx +67 -4
  185. package/src/plugins/builtin/broker-manager/index.tsx +35 -4
  186. package/src/plugins/builtin/broker-manager/keyboard.ts +10 -0
  187. package/src/plugins/builtin/broker-manager/pane-actions.tsx +35 -2
  188. package/src/plugins/builtin/broker-trading/orders.tsx +14 -5
  189. package/src/plugins/builtin/broker-trading/ticket.tsx +1 -0
  190. package/src/plugins/builtin/buildout/format.ts +3 -1
  191. package/src/plugins/builtin/buybacks/client.ts +48 -0
  192. package/src/plugins/builtin/buybacks/index.tsx +22 -0
  193. package/src/plugins/builtin/buybacks/model.ts +151 -0
  194. package/src/plugins/builtin/buybacks/pane.tsx +140 -0
  195. package/src/plugins/builtin/buybacks/series.ts +36 -0
  196. package/src/plugins/builtin/catalysts/detail.tsx +14 -8
  197. package/src/plugins/builtin/catalysts/evidence.ts +11 -3
  198. package/src/plugins/builtin/catalysts/headless.ts +51 -8
  199. package/src/plugins/builtin/catalysts/kinds.ts +413 -0
  200. package/src/plugins/builtin/catalysts/model.ts +61 -18
  201. package/src/plugins/builtin/catalysts/pane.tsx +85 -19
  202. package/src/plugins/builtin/cds/client.ts +9 -2
  203. package/src/plugins/builtin/cds/headless.ts +25 -10
  204. package/src/plugins/builtin/cds/model.ts +37 -12
  205. package/src/plugins/builtin/cds/pane.tsx +18 -10
  206. package/src/plugins/builtin/chart-composer/chart-spec-edit.ts +68 -7
  207. package/src/plugins/builtin/chart-composer/chart-title.ts +114 -0
  208. package/src/plugins/builtin/chart-composer/cli-options.ts +1 -1
  209. package/src/plugins/builtin/chart-composer/headless.ts +13 -1
  210. package/src/plugins/builtin/chart-composer/index.tsx +2 -68
  211. package/src/plugins/builtin/chart-composer/leverage-overlay.ts +2 -4
  212. package/src/plugins/builtin/chart-composer/pane.tsx +11 -3
  213. package/src/plugins/builtin/chart-composer/presets.ts +1 -1
  214. package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
  215. package/src/plugins/builtin/chat/channels.ts +5 -2
  216. package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
  217. package/src/plugins/builtin/chat/content/footer.tsx +17 -7
  218. package/src/plugins/builtin/chat/content/index.tsx +108 -36
  219. package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
  220. package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
  221. package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
  222. package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
  223. package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
  224. package/src/plugins/builtin/chat/content/types.ts +2 -0
  225. package/src/plugins/builtin/chat/controller/channels.ts +15 -15
  226. package/src/plugins/builtin/chat/controller/draft-sync.ts +13 -7
  227. package/src/plugins/builtin/chat/controller/index.ts +140 -34
  228. package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
  229. package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
  230. package/src/plugins/builtin/chat/controller/send.ts +41 -17
  231. package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
  232. package/src/plugins/builtin/chat/controller/state.ts +21 -8
  233. package/src/plugins/builtin/chat/controller/storage.ts +41 -4
  234. package/src/plugins/builtin/chat/controller/view.ts +6 -3
  235. package/src/plugins/builtin/chat/index.tsx +1 -1
  236. package/src/plugins/builtin/chat/layout.ts +8 -1
  237. package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
  238. package/src/plugins/builtin/chat/message/header.tsx +112 -30
  239. package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
  240. package/src/plugins/builtin/chat/message/render-state.ts +4 -2
  241. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  242. package/src/plugins/builtin/chat/message/types.ts +5 -0
  243. package/src/plugins/builtin/chat/pane-requests.ts +8 -4
  244. package/src/plugins/builtin/clinical-trials/model.ts +2 -2
  245. package/src/plugins/builtin/clinical-trials/pane.tsx +3 -3
  246. package/src/plugins/builtin/cloud/askg/pane.tsx +60 -50
  247. package/src/plugins/builtin/cloud/auth-actions.tsx +2 -1
  248. package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
  249. package/src/plugins/builtin/comment-letters/pane.tsx +4 -2
  250. package/src/plugins/builtin/commodity-balances/headless.ts +2 -1
  251. package/src/plugins/builtin/company-attention/building-model.ts +3 -4
  252. package/src/plugins/builtin/company-attention/building.tsx +2 -0
  253. package/src/plugins/builtin/company-attention/headless.ts +2 -2
  254. package/src/plugins/builtin/company-attention/model.ts +2 -0
  255. package/src/plugins/builtin/company-attention/moves-model.ts +2 -1
  256. package/src/plugins/builtin/company-attention/moves.tsx +2 -0
  257. package/src/plugins/builtin/company-attention/pane.tsx +17 -3
  258. package/src/plugins/builtin/company-attention/signals-model.ts +3 -4
  259. package/src/plugins/builtin/company-attention/signals.tsx +5 -0
  260. package/src/plugins/builtin/company-kpis/headless.ts +26 -10
  261. package/src/plugins/builtin/company-kpis/model.ts +58 -10
  262. package/src/plugins/builtin/company-kpis/pane.tsx +36 -19
  263. package/src/plugins/builtin/company-kpis/taiwan-monthly-model.ts +99 -0
  264. package/src/plugins/builtin/company-kpis/taiwan-monthly-view.tsx +327 -0
  265. package/src/plugins/builtin/composite/ownership-browser.ts +28 -0
  266. package/src/plugins/builtin/composite/ownership.ts +5 -1
  267. package/src/plugins/builtin/congress-trades/detail.tsx +44 -8
  268. package/src/plugins/builtin/congress-trades/headless.ts +15 -11
  269. package/src/plugins/builtin/congress-trades/model.ts +104 -11
  270. package/src/plugins/builtin/congress-trades/pane.tsx +11 -6
  271. package/src/plugins/builtin/congress-trades/table.tsx +17 -10
  272. package/src/plugins/builtin/congress-trades/use-feed.ts +13 -2
  273. package/src/plugins/builtin/correlation/compute.ts +6 -1
  274. package/src/plugins/builtin/correlation/headless.ts +2 -2
  275. package/src/plugins/builtin/correlation/relationship/pane.tsx +11 -8
  276. package/src/plugins/builtin/correlation/relationship/view-model.ts +1 -19
  277. package/src/plugins/builtin/cot/headless.ts +1 -1
  278. package/src/plugins/builtin/cot/pane.tsx +7 -2
  279. package/src/plugins/builtin/cpi/headless.ts +2 -1
  280. package/src/plugins/builtin/credit-conditions/headless.ts +2 -1
  281. package/src/plugins/builtin/credit-documents/detail.tsx +2 -1
  282. package/src/plugins/builtin/credit-documents/export.ts +18 -12
  283. package/src/plugins/builtin/credit-documents/model.ts +106 -25
  284. package/src/plugins/builtin/credit-documents/pane.tsx +9 -5
  285. package/src/plugins/builtin/crypto-board/defi-view.tsx +2 -1
  286. package/src/plugins/builtin/crypto-board/defi.ts +5 -4
  287. package/src/plugins/builtin/crypto-board/headless.ts +7 -2
  288. package/src/plugins/builtin/crypto-board/model.ts +6 -4
  289. package/src/plugins/builtin/crypto-board/pane.tsx +2 -1
  290. package/src/plugins/builtin/crypto-board/supply.ts +4 -3
  291. package/src/plugins/builtin/crypto-etf-flows/headless.ts +15 -8
  292. package/src/plugins/builtin/crypto-etf-flows/pane.tsx +6 -5
  293. package/src/plugins/builtin/custom-view/loader.ts +95 -34
  294. package/src/plugins/builtin/custom-view/pane.tsx +31 -41
  295. package/src/plugins/builtin/custom-view/table.ts +201 -0
  296. package/src/plugins/builtin/debt-maturities/headless.ts +56 -38
  297. package/src/plugins/builtin/debt-maturities/model.ts +2 -1
  298. package/src/plugins/builtin/debt-maturities/pane.tsx +24 -22
  299. package/src/plugins/builtin/dilution/index.tsx +74 -0
  300. package/src/plugins/builtin/dilution/model.ts +159 -0
  301. package/src/plugins/builtin/dilution/pane.tsx +592 -0
  302. package/src/plugins/builtin/dividend-yield/client.ts +14 -17
  303. package/src/plugins/builtin/dividend-yield/headless.ts +24 -16
  304. package/src/plugins/builtin/dividend-yield/index.tsx +2 -1
  305. package/src/plugins/builtin/dividend-yield/model.ts +52 -10
  306. package/src/plugins/builtin/dividend-yield/pane.tsx +89 -17
  307. package/src/plugins/builtin/dividend-yield/ranking-view.tsx +6 -2
  308. package/src/plugins/builtin/dividend-yield/ranking.ts +7 -3
  309. package/src/plugins/builtin/dividend-yield/types.ts +2 -3
  310. package/src/plugins/builtin/dividend-yield/view.ts +58 -12
  311. package/src/plugins/builtin/docs/index.tsx +1 -1
  312. package/src/plugins/builtin/docs/pane.tsx +7 -3
  313. package/src/plugins/builtin/docs/use-docs.ts +2 -1
  314. package/src/plugins/builtin/earnings/board-model.ts +19 -6
  315. package/src/plugins/builtin/earnings/board-table.ts +64 -48
  316. package/src/plugins/builtin/earnings/board.tsx +93 -51
  317. package/src/plugins/builtin/earnings/headless.ts +71 -12
  318. package/src/plugins/builtin/earnings/history-model.ts +28 -15
  319. package/src/plugins/builtin/earnings/history.tsx +1 -1
  320. package/src/plugins/builtin/earnings-calls/calendar.tsx +23 -10
  321. package/src/plugins/builtin/earnings-calls/format.ts +34 -0
  322. package/src/plugins/builtin/earnings-calls/headless.ts +5 -4
  323. package/src/plugins/builtin/earnings-calls/pane.tsx +22 -17
  324. package/src/plugins/builtin/earnings-calls/transcript-view.tsx +14 -12
  325. package/src/plugins/builtin/earnings-ripple/pane.tsx +4 -3
  326. package/src/plugins/builtin/econ/calendar-model.ts +207 -3
  327. package/src/plugins/builtin/econ/columns.ts +132 -0
  328. package/src/plugins/builtin/econ/index.tsx +27 -79
  329. package/src/plugins/builtin/econ-statistics/detail.tsx +2 -2
  330. package/src/plugins/builtin/econ-statistics/headless.ts +10 -5
  331. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -3
  332. package/src/plugins/builtin/econ-statistics/view.ts +15 -4
  333. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  334. package/src/plugins/builtin/equity-screener/model.ts +12 -3
  335. package/src/plugins/builtin/estimate-revisions/headless.ts +23 -2
  336. package/src/plugins/builtin/estimate-revisions/model.ts +63 -13
  337. package/src/plugins/builtin/estimate-revisions/pane.tsx +228 -225
  338. package/src/plugins/builtin/estimate-revisions/sorting.ts +8 -16
  339. package/src/plugins/builtin/exposure/drivers.ts +5 -2
  340. package/src/plugins/builtin/exposure/headless.ts +6 -3
  341. package/src/plugins/builtin/exposure/model.ts +2 -1
  342. package/src/plugins/builtin/exposure/pane.tsx +16 -7
  343. package/src/plugins/builtin/fear-greed/format.ts +7 -7
  344. package/src/plugins/builtin/fear-greed/pane.tsx +21 -7
  345. package/src/plugins/builtin/futures-curve/headless.ts +14 -9
  346. package/src/plugins/builtin/futures-curve/model.ts +12 -4
  347. package/src/plugins/builtin/futures-curve/pane.tsx +18 -15
  348. package/src/plugins/builtin/fx-matrix/headless.ts +3 -2
  349. package/src/plugins/builtin/gpu/headless.ts +10 -4
  350. package/src/plugins/builtin/holders/beneficial-model.ts +1 -1
  351. package/src/plugins/builtin/holders/beneficial-view.tsx +3 -2
  352. package/src/plugins/builtin/holders/ccass-market-pane.tsx +363 -0
  353. package/src/plugins/builtin/holders/ccass-view.tsx +323 -0
  354. package/src/plugins/builtin/holders/disclosures-view.tsx +66 -0
  355. package/src/plugins/builtin/holders/disclosures.ts +47 -0
  356. package/src/plugins/builtin/holders/headless.ts +9 -2
  357. package/src/plugins/builtin/holders/index.tsx +75 -1
  358. package/src/plugins/builtin/holders/pane.tsx +37 -10
  359. package/src/plugins/builtin/holders/report-rows.ts +2 -0
  360. package/src/plugins/builtin/holders/table-model.ts +14 -6
  361. package/src/plugins/builtin/holders/types.ts +2 -2
  362. package/src/plugins/builtin/insider/activity-chart.ts +141 -0
  363. package/src/plugins/builtin/insider/headless.ts +2 -1
  364. package/src/plugins/builtin/insider/index.tsx +74 -12
  365. package/src/plugins/builtin/insider/signals-cells.tsx +15 -8
  366. package/src/plugins/builtin/insider/signals.tsx +6 -5
  367. package/src/plugins/builtin/insider/table-model.ts +17 -17
  368. package/src/plugins/builtin/insider/table.tsx +18 -10
  369. package/src/plugins/builtin/ipo-calendar/headless.ts +55 -11
  370. package/src/plugins/builtin/ipo-calendar/listing-ipo.ts +31 -4
  371. package/src/plugins/builtin/ipo-calendar/model.ts +238 -48
  372. package/src/plugins/builtin/ipo-calendar/pane.tsx +91 -25
  373. package/src/plugins/builtin/iv-history/client.ts +17 -8
  374. package/src/plugins/builtin/iv-history/format.ts +23 -12
  375. package/src/plugins/builtin/iv-history/headless.ts +9 -5
  376. package/src/plugins/builtin/iv-history/model.ts +15 -13
  377. package/src/plugins/builtin/iv-history/pane.tsx +5 -2
  378. package/src/plugins/builtin/iv-history/screen-pane.tsx +46 -24
  379. package/src/plugins/builtin/jobs/headless.ts +4 -3
  380. package/src/plugins/builtin/jobs/pane.tsx +6 -5
  381. package/src/plugins/builtin/jodi/headless.ts +15 -2
  382. package/src/plugins/builtin/jodi/model.ts +46 -5
  383. package/src/plugins/builtin/jodi/pane.tsx +17 -13
  384. package/src/plugins/builtin/kelly-sizer/headless.ts +11 -4
  385. package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
  386. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -1
  387. package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
  388. package/src/plugins/builtin/macro-day/pane.tsx +12 -5
  389. package/src/plugins/builtin/market-halts/model.ts +10 -8
  390. package/src/plugins/builtin/market-halts/pane.tsx +15 -3
  391. package/src/plugins/builtin/market-heatmap/data.ts +17 -2
  392. package/src/plugins/builtin/market-heatmap/headless.ts +56 -6
  393. package/src/plugins/builtin/market-heatmap/index.tsx +55 -1
  394. package/src/plugins/builtin/market-heatmap/model.ts +27 -1
  395. package/src/plugins/builtin/market-movers/model.ts +7 -1
  396. package/src/plugins/builtin/market-movers/session-table.ts +1 -0
  397. package/src/plugins/builtin/market-movers/session.ts +1 -1
  398. package/src/plugins/builtin/market-movers/table.ts +1 -1
  399. package/src/plugins/builtin/members/headless.ts +13 -5
  400. package/src/plugins/builtin/members/model.ts +35 -1
  401. package/src/plugins/builtin/members/pane.tsx +16 -8
  402. package/src/plugins/builtin/mna/distress/detail.tsx +7 -6
  403. package/src/plugins/builtin/mna/distress/model.ts +7 -7
  404. package/src/plugins/builtin/mna/distress/pane.tsx +8 -7
  405. package/src/plugins/builtin/mna/headless.ts +40 -7
  406. package/src/plugins/builtin/mna/model.ts +66 -6
  407. package/src/plugins/builtin/mna/pane.tsx +118 -60
  408. package/src/plugins/builtin/news/wire/industry-pane.tsx +1 -0
  409. package/src/plugins/builtin/news/wire/news/row.ts +5 -12
  410. package/src/plugins/builtin/news/wire/news/table.tsx +46 -44
  411. package/src/plugins/builtin/notes/index.tsx +2 -1
  412. package/src/plugins/builtin/openfda/model.ts +1 -1
  413. package/src/plugins/builtin/openfda/pane.tsx +37 -9
  414. package/src/plugins/builtin/options/analytics.ts +30 -6
  415. package/src/plugins/builtin/options/calc-seed.ts +38 -3
  416. package/src/plugins/builtin/options/footer.ts +18 -1
  417. package/src/plugins/builtin/options/live-quotes.ts +21 -6
  418. package/src/plugins/builtin/options/open-interest-as-of.ts +5 -0
  419. package/src/plugins/builtin/options/quote-context.tsx +21 -8
  420. package/src/plugins/builtin/options/table.ts +17 -2
  421. package/src/plugins/builtin/options/view.tsx +97 -46
  422. package/src/plugins/builtin/options-calculator/model.ts +65 -3
  423. package/src/plugins/builtin/options-calculator/pane.tsx +11 -3
  424. package/src/plugins/builtin/options-calculator/valuation.ts +33 -0
  425. package/src/plugins/builtin/options-positioning/cbbc-model.ts +160 -0
  426. package/src/plugins/builtin/options-positioning/cbbc-view.tsx +453 -0
  427. package/src/plugins/builtin/options-positioning/index.tsx +22 -1
  428. package/src/plugins/builtin/options-positioning/pane.tsx +16 -1
  429. package/src/plugins/builtin/options-scenario/charts.tsx +2 -1
  430. package/src/plugins/builtin/options-scenario/csp-screen-headless.ts +5 -5
  431. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +11 -14
  432. package/src/plugins/builtin/options-scenario/csp-screen.ts +9 -1
  433. package/src/plugins/builtin/options-scenario/headless.ts +3 -3
  434. package/src/plugins/builtin/options-scenario/index.tsx +1 -1
  435. package/src/plugins/builtin/options-scenario/model.ts +7 -0
  436. package/src/plugins/builtin/options-scenario/pane.tsx +24 -14
  437. package/src/plugins/builtin/pe-band/headless.ts +1 -1
  438. package/src/plugins/builtin/pe-band/model.ts +41 -18
  439. package/src/plugins/builtin/pe-band/pane.tsx +8 -6
  440. package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
  441. package/src/plugins/builtin/perps/cascade.ts +4 -3
  442. package/src/plugins/builtin/perps/equity-row.tsx +4 -6
  443. package/src/plugins/builtin/perps/headless.ts +19 -12
  444. package/src/plugins/builtin/perps/markets-section.tsx +19 -15
  445. package/src/plugins/builtin/perps/model.ts +14 -5
  446. package/src/plugins/builtin/portfolio-list/cached-account.ts +3 -1
  447. package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
  448. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
  449. package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
  450. package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
  451. package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
  452. package/src/plugins/builtin/portfolio-list/settings.ts +4 -3
  453. package/src/plugins/builtin/portfolio-list/table.tsx +19 -2
  454. package/src/plugins/builtin/power/client.ts +2 -2
  455. package/src/plugins/builtin/power/detail.tsx +11 -8
  456. package/src/plugins/builtin/power/gas-model.ts +2 -1
  457. package/src/plugins/builtin/power/gas.tsx +3 -2
  458. package/src/plugins/builtin/power/headless.ts +4 -1
  459. package/src/plugins/builtin/power/model.ts +19 -0
  460. package/src/plugins/builtin/power/pane.tsx +5 -4
  461. package/src/plugins/builtin/power/prices-headless.ts +4 -3
  462. package/src/plugins/builtin/power/prices.tsx +7 -6
  463. package/src/plugins/builtin/primary-dealers/headless.ts +1 -1
  464. package/src/plugins/builtin/primary-dealers/model.ts +2 -1
  465. package/src/plugins/builtin/rate-path/headless.ts +5 -2
  466. package/src/plugins/builtin/rate-path/pane.tsx +13 -10
  467. package/src/plugins/builtin/realized-vol/fx-proxy.ts +7 -8
  468. package/src/plugins/builtin/realized-vol/headless.ts +3 -4
  469. package/src/plugins/builtin/realized-vol/pane.tsx +5 -4
  470. package/src/plugins/builtin/relative-rotation/headless.ts +2 -1
  471. package/src/plugins/builtin/research/analyst-model.ts +1 -1
  472. package/src/plugins/builtin/research/analyst-pane.tsx +2 -1
  473. package/src/plugins/builtin/research/earnings-estimates-pane.tsx +262 -0
  474. package/src/plugins/builtin/research/event-charts.ts +322 -0
  475. package/src/plugins/builtin/research/event-data.ts +140 -0
  476. package/src/plugins/builtin/research/event-detail.tsx +442 -0
  477. package/src/plugins/builtin/research/event-model.ts +338 -39
  478. package/src/plugins/builtin/research/event-sources.ts +58 -8
  479. package/src/plugins/builtin/research/event-views.tsx +397 -0
  480. package/src/plugins/builtin/research/events-headless.ts +60 -4
  481. package/src/plugins/builtin/research/headless-schema.ts +2 -2
  482. package/src/plugins/builtin/research/headless.ts +84 -7
  483. package/src/plugins/builtin/research/index.tsx +19 -17
  484. package/src/plugins/builtin/research/relative-valuation-columns.ts +39 -14
  485. package/src/plugins/builtin/research/relative-valuation-headless.ts +9 -5
  486. package/src/plugins/builtin/research/relative-valuation-model.ts +23 -8
  487. package/src/plugins/builtin/research/relative-valuation-pane.tsx +10 -0
  488. package/src/plugins/builtin/revenue-breakdown/client.ts +9 -4
  489. package/src/plugins/builtin/revenue-breakdown/headless.ts +1 -1
  490. package/src/plugins/builtin/revenue-breakdown/index.tsx +2 -1
  491. package/src/plugins/builtin/revenue-breakdown/model.ts +2 -0
  492. package/src/plugins/builtin/revenue-breakdown/pane.tsx +10 -0
  493. package/src/plugins/builtin/risk-factors/pane.tsx +14 -9
  494. package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
  495. package/src/plugins/builtin/scanner/headless.ts +2 -0
  496. package/src/plugins/builtin/scanner/lock-note.ts +5 -9
  497. package/src/plugins/builtin/sec/exchange-filings.ts +69 -0
  498. package/src/plugins/builtin/sec/fund-facts.ts +10 -8
  499. package/src/plugins/builtin/sec/headless.ts +60 -8
  500. package/src/plugins/builtin/sec/index.tsx +169 -61
  501. package/src/plugins/builtin/sec/model.ts +10 -4
  502. package/src/plugins/builtin/sec/row-summaries.ts +1 -0
  503. package/src/plugins/builtin/series-inventory.ts +4 -0
  504. package/src/plugins/builtin/shared/beat-miss-chart.ts +66 -0
  505. package/src/plugins/builtin/shared/day-entries.ts +41 -0
  506. package/src/plugins/builtin/shared/earnings-calendar.ts +80 -53
  507. package/src/plugins/builtin/shared/earnings-report.ts +53 -15
  508. package/src/plugins/builtin/shared/history-span.ts +2 -1
  509. package/src/plugins/builtin/shared/locked-rows.tsx +1 -1
  510. package/src/plugins/builtin/shared/pro-lock-note.ts +8 -12
  511. package/src/plugins/builtin/shared/report-freshness.ts +4 -1
  512. package/src/plugins/builtin/shared/ticker-request.ts +4 -2
  513. package/src/plugins/builtin/shared/volatility/live-session.ts +6 -7
  514. package/src/plugins/builtin/shared/volatility/option-snapshot.ts +30 -0
  515. package/src/plugins/builtin/shared/volatility/quote-session.ts +49 -0
  516. package/src/plugins/builtin/short-interest/exchange-balances.ts +76 -0
  517. package/src/plugins/builtin/short-interest/exchange-positions-pane.tsx +55 -0
  518. package/src/plugins/builtin/short-interest/headless.ts +15 -2
  519. package/src/plugins/builtin/short-interest/index.tsx +7 -3
  520. package/src/plugins/builtin/short-interest/jpx.ts +38 -0
  521. package/src/plugins/builtin/short-interest/model.ts +3 -2
  522. package/src/plugins/builtin/short-interest/pane.tsx +4 -3
  523. package/src/plugins/builtin/short-interest/publications-model.ts +73 -2
  524. package/src/plugins/builtin/short-interest/publications-pane.tsx +16 -4
  525. package/src/plugins/builtin/short-interest/sfc.ts +40 -0
  526. package/src/plugins/builtin/short-interest/surface.tsx +16 -2
  527. package/src/plugins/builtin/short-volume/headless.ts +18 -3
  528. package/src/plugins/builtin/short-volume/model.ts +6 -1
  529. package/src/plugins/builtin/short-volume/pane.tsx +8 -7
  530. package/src/plugins/builtin/short-volume/sgx.ts +23 -0
  531. package/src/plugins/builtin/social-mentions/outliers-model.ts +2 -1
  532. package/src/plugins/builtin/social-mentions/pane.tsx +10 -8
  533. package/src/plugins/builtin/supply-chain/client.ts +10 -2
  534. package/src/plugins/builtin/supply-chain/directories.ts +18 -0
  535. package/src/plugins/builtin/supply-chain/evidence.ts +12 -4
  536. package/src/plugins/builtin/supply-chain/headless.ts +20 -7
  537. package/src/plugins/builtin/supply-chain/pane.tsx +40 -11
  538. package/src/plugins/builtin/thirteenf/api.ts +299 -31
  539. package/src/plugins/builtin/thirteenf/data.ts +126 -32
  540. package/src/plugins/builtin/thirteenf/format.ts +4 -6
  541. package/src/plugins/builtin/thirteenf/headless.ts +68 -29
  542. package/src/plugins/builtin/thirteenf/model.ts +24 -11
  543. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +16 -8
  544. package/src/plugins/builtin/thirteenf/pane.tsx +45 -22
  545. package/src/plugins/builtin/thirteenf/report-notes.ts +52 -2
  546. package/src/plugins/builtin/thirteenf/session-scope.ts +57 -0
  547. package/src/plugins/builtin/thirteenf/signals-pane.tsx +17 -4
  548. package/src/plugins/builtin/thirteenf/split-history.ts +119 -0
  549. package/src/plugins/builtin/thirteenf/table.ts +6 -6
  550. package/src/plugins/builtin/thirteenf/types.ts +17 -1
  551. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +11 -0
  552. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +12 -8
  553. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +5 -4
  554. package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +7 -0
  555. package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +12 -5
  556. package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +35 -5
  557. package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
  558. package/src/plugins/builtin/ticker-detail/financials/model.ts +210 -43
  559. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +69 -8
  560. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +64 -10
  561. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +132 -68
  562. package/src/plugins/builtin/ticker-detail/headless.ts +37 -13
  563. package/src/plugins/builtin/ticker-detail/overview/components.tsx +75 -14
  564. package/src/plugins/builtin/ticker-detail/overview/model.ts +87 -35
  565. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -8
  566. package/src/plugins/builtin/ticker-detail/overview/types.ts +2 -0
  567. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +50 -17
  568. package/src/plugins/builtin/ticker-detail/pane.tsx +5 -3
  569. package/src/plugins/builtin/ticker-detail/research-groups.ts +15 -2
  570. package/src/plugins/builtin/ticker-detail/research-tabs.ts +2 -1
  571. package/src/plugins/builtin/time-sales/headless.ts +3 -3
  572. package/src/plugins/builtin/time-sales/model.ts +16 -9
  573. package/src/plugins/builtin/time-sales/pane.tsx +27 -24
  574. package/src/plugins/builtin/trace-bonds/pane.tsx +3 -2
  575. package/src/plugins/builtin/treasury-auctions/cache.ts +44 -19
  576. package/src/plugins/builtin/treasury-auctions/client.ts +9 -4
  577. package/src/plugins/builtin/treasury-daily/client.ts +43 -9
  578. package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
  579. package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
  580. package/src/plugins/builtin/vol-surface/charts.tsx +3 -1
  581. package/src/plugins/builtin/vol-surface/events.ts +8 -5
  582. package/src/plugins/builtin/vol-surface/evidence.ts +2 -2
  583. package/src/plugins/builtin/vol-surface/headless.ts +46 -28
  584. package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
  585. package/src/plugins/builtin/vol-surface/model.ts +34 -9
  586. package/src/plugins/builtin/vol-surface/pane.tsx +35 -67
  587. package/src/plugins/builtin/vol-surface/quote-coverage.ts +68 -0
  588. package/src/plugins/builtin/vol-surface/tables.ts +57 -6
  589. package/src/plugins/builtin/volatility/charts.tsx +7 -3
  590. package/src/plugins/builtin/volatility/headless.ts +5 -5
  591. package/src/plugins/builtin/volatility/pane.tsx +8 -5
  592. package/src/plugins/builtin/world-indices/headless.ts +5 -3
  593. package/src/plugins/builtin/world-venue-map/headless.ts +15 -1
  594. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +5 -3
  595. package/src/plugins/builtin/world-venue-map/pane.tsx +4 -3
  596. package/src/plugins/builtin/world-venue-map/venue-exceptions.ts +72 -0
  597. package/src/plugins/builtin/world-venue-map/venue-header.tsx +20 -11
  598. package/src/plugins/builtin/yield-curve/headless.ts +4 -2
  599. package/src/plugins/builtin/yield-curve/index.tsx +4 -3
  600. package/src/plugins/catalog-browser.ts +3 -34
  601. package/src/plugins/marketplace/feed.ts +3 -2
  602. package/src/plugins/registry/contributions.ts +37 -10
  603. package/src/plugins/registry/index.ts +2 -1
  604. package/src/portfolio/column-values.ts +8 -9
  605. package/src/portfolio/positions-import/parse.ts +14 -6
  606. package/src/portfolio/positions-import/plan.ts +3 -2
  607. package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
  608. package/src/public/i18n.ts +3 -2
  609. package/src/react/async-resource.ts +3 -1
  610. package/src/renderers/dom/css.d.ts +1 -0
  611. package/src/renderers/dom/data-table/index.tsx +100 -8
  612. package/src/renderers/dom/data-table/row.tsx +40 -4
  613. package/src/renderers/dom/desktop/icons.tsx +147 -3
  614. package/src/renderers/dom/desktop/popover.tsx +2 -2
  615. package/src/renderers/dom/host/media-surface.tsx +204 -45
  616. package/src/renderers/dom/host/tabs.tsx +1 -0
  617. package/src/renderers/dom/styles.css +14 -2
  618. package/src/renderers/electrobun/bun/desktop/backend.ts +14 -1
  619. package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
  620. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  621. package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
  622. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +7 -1
  623. package/src/renderers/electrobun/view/remote/asset-data-client.ts +2 -0
  624. package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
  625. package/src/sources/gloomberb-cloud/batched-lookups.ts +12 -1
  626. package/src/sources/gloomberb-cloud/index.ts +44 -10
  627. package/src/sources/gloomberb-cloud/normalizers.ts +8 -2
  628. package/src/sources/listing-symbols.ts +7 -1
  629. package/src/sources/provider-router/cache.ts +5 -4
  630. package/src/sources/provider-router/financials.ts +44 -22
  631. package/src/sources/provider-router/index.ts +9 -1
  632. package/src/state/app/context/index.tsx +12 -4
  633. package/src/state/app/tab-cursor.ts +47 -6
  634. package/src/sync/broker-instances.ts +63 -11
  635. package/src/sync/config-merge.ts +1 -1
  636. package/src/sync/sanitize.ts +2 -0
  637. package/src/telemetry/stall-clocks.ts +3 -0
  638. package/src/telemetry/stall-reports.ts +12 -3
  639. package/src/telemetry/windows-process-activity.ts +41 -0
  640. package/src/telemetry/windows-time.ts +32 -0
  641. package/src/test-support/cloud-api.ts +34 -0
  642. package/src/test-support/scoped-earnings.ts +24 -0
  643. package/src/test-support/strict-table-capture.tsx +83 -0
  644. package/src/tickers/search/index.ts +23 -7
  645. package/src/tickers/terminal-codes.ts +1 -6
  646. package/src/time-series/alignment.ts +14 -4
  647. package/src/time-series/base-series.ts +5 -4
  648. package/src/time-series/chart-data.ts +2 -0
  649. package/src/time-series/chart-seed.ts +3 -1
  650. package/src/time-series/daily-valuation.ts +13 -6
  651. package/src/time-series/filed-trailing-eps.ts +16 -3
  652. package/src/time-series/fundamentals/current-valuation.ts +30 -5
  653. package/src/time-series/fundamentals/historical-valuation.ts +20 -0
  654. package/src/time-series/fundamentals/history-link.ts +25 -0
  655. package/src/time-series/fundamentals/quarterly-ttm.ts +50 -5
  656. package/src/time-series/fundamentals/series.ts +13 -1
  657. package/src/time-series/market.ts +30 -4
  658. package/src/time-series/price-comparison.ts +39 -60
  659. package/src/time-series/resolve.ts +18 -11
  660. package/src/time-series/spec.ts +2 -1
  661. package/src/time-series/studies/formula.ts +4 -2
  662. package/src/time-series/studies/indicators.ts +2 -0
  663. package/src/time-series/studies/pair.ts +4 -2
  664. package/src/time-series/studies/shared.ts +1 -0
  665. package/src/time-series/types.ts +2 -1
  666. package/src/time-series/use-chart-resolution.ts +32 -14
  667. package/src/time-series/valuation-currency.ts +2 -0
  668. package/src/types/config.ts +13 -61
  669. package/src/types/data-provider.ts +8 -0
  670. package/src/types/financials.ts +94 -15
  671. package/src/types/headless.ts +30 -0
  672. package/src/types/plugin-context.ts +8 -1
  673. package/src/ui/dialog-context.ts +8 -0
  674. package/src/utils/crypto-pair.ts +10 -0
  675. package/src/utils/datetime-format.ts +23 -1
  676. package/src/utils/day-format.ts +104 -0
  677. package/src/utils/declared-dividends.ts +12 -2
  678. package/src/utils/exchange-announcements.ts +38 -12
  679. package/src/utils/exchange-notation.generated.ts +3 -1
  680. package/src/utils/exchanges.ts +2 -1
  681. package/src/utils/financial-statements.ts +40 -46
  682. package/src/utils/format.ts +39 -12
  683. package/src/utils/forward-dividend.ts +2 -1
  684. package/src/utils/fundamentals.ts +1 -0
  685. package/src/utils/main-thread-stall.ts +9 -1
  686. package/src/utils/rpc-timeout-error.ts +36 -11
  687. package/src/utils/sec.ts +3 -1
  688. package/src/utils/share-multiples.ts +1 -1
  689. package/src/utils/stall-process-activity.ts +70 -0
  690. package/src/utils/statement-scope.ts +103 -0
  691. package/src/utils/trailing-dividend.ts +47 -0
  692. package/src/utils/trailing-eps.ts +1 -1
  693. package/src/utils/zoned-date-time.ts +1 -0
  694. package/src/plugins/builtin/research/corporate-actions-pane.tsx +0 -771
@@ -11,7 +11,8 @@ export interface TableWidthColumn {
11
11
 
12
12
  const TRAILING_COLUMN_GUTTER_WIDTH = 1;
13
13
  const HIDDEN_COLUMNS = Symbol("hidden table columns");
14
- type HiddenColumn = { id: string; label: string };
14
+ /** `restorable`: the table's own fit left it out, so its More draws it again; a pane's own choice needs a wider pane. */
15
+ type HiddenColumn = { id: string; label: string; restorable?: boolean };
15
16
  type WithHiddenColumns = { [HIDDEN_COLUMNS]?: readonly HiddenColumn[] };
16
17
 
17
18
  function hiddenColumnEntries(columns: readonly TableWidthColumn[]): HiddenColumn[] {
@@ -27,17 +28,53 @@ export function hiddenTableColumnRows(columns: readonly TableWidthColumn[], item
27
28
  return itemCount > 0 && columns.some((column: TableWidthColumn & WithHiddenColumns) => column[HIDDEN_COLUMNS]?.length) ? 1 : 0;
28
29
  }
29
30
 
31
+ function hiddenColumnNames(labels: readonly string[]): string {
32
+ const counts = new Map<string, number>();
33
+ for (const label of labels) counts.set(label, (counts.get(label) ?? 0) + 1);
34
+ return [...counts].map(([label, count]) => count > 1 ? `${label} ×${count}` : label).join(", ");
35
+ }
36
+
30
37
  export function hiddenTableColumnText(columns: readonly TableWidthColumn[]): string | null {
31
38
  const hidden = hiddenTableColumns(columns);
32
39
  if (!hidden.length) return null;
33
- const labels = new Map<string, number>();
34
- for (const label of hidden) labels.set(label, (labels.get(label) ?? 0) + 1);
35
- return `${hidden.length} hidden · ${[...labels].map(([label, count]) => count > 1 ? `${label} ×${count}` : label).join(", ")}`;
40
+ return `${hidden.length} hidden · ${hiddenColumnNames(hidden)}`;
36
41
  }
37
42
 
38
- export function markHiddenTableColumns<C extends TableWidthColumn & { id: string }>(original: readonly C[], shown: C[]): C[] {
43
+ /**
44
+ * The line a table that offers its left-out columns back writes above its
45
+ * header, in the two parts that come back differently. `restorable` names
46
+ * what the table's own fit left out, which the press on More draws again;
47
+ * `pane` names what the pane itself left out for width, which only a wider
48
+ * pane shows. With both, the pane's part says so ("3 need a wider pane ·
49
+ * AS OF UTC, 1M"), so the words beside More name what More reveals and
50
+ * nothing else. Either alone reads as it always did (`2 hidden · FY2023,
51
+ * FY2022`). Null where nothing is hidden.
52
+ */
53
+ export function hiddenTableColumnDisclosure(columns: readonly TableWidthColumn[]): { restorable: string | null; pane: string | null } | null {
54
+ const entries = hiddenColumnEntries(columns);
55
+ if (!entries.length) return null;
56
+ const restorable = entries.filter((entry) => entry.restorable).map(({ label }) => label);
57
+ const pane = entries.filter((entry) => !entry.restorable).map(({ label }) => label);
58
+ const hidden = (labels: readonly string[]) => `${labels.length} hidden · ${hiddenColumnNames(labels)}`;
59
+ return {
60
+ restorable: restorable.length ? hidden(restorable) : null,
61
+ pane: !pane.length ? null : restorable.length ? `${pane.length} need a wider pane · ${hiddenColumnNames(pane)}` : hidden(pane),
62
+ };
63
+ }
64
+
65
+ /**
66
+ * `shown` with the columns of `original` it leaves out named on its first
67
+ * column, after the ones `original` already names. `restorable` marks them as
68
+ * left out by the table's own fit (`fitColumnsToWidth`), which its More draws
69
+ * again; unmarked, they are the pane's own choice for this width.
70
+ */
71
+ export function markHiddenTableColumns<C extends TableWidthColumn & { id: string }>(
72
+ original: readonly C[],
73
+ shown: C[],
74
+ { restorable = false }: { restorable?: boolean } = {},
75
+ ): C[] {
39
76
  const hidden = [...hiddenColumnEntries(original), ...original.filter(({ id }) => !shown.some((column) => column.id === id))
40
- .map(({ id, label }) => ({ id, label: label?.trim() || id }))];
77
+ .map(({ id, label }) => ({ id, label: label?.trim() || id, ...(restorable ? { restorable: true } : {}) }))];
41
78
  if (!shown[0] || !hidden.length) return shown;
42
79
  return [Object.assign({ ...shown[0] }, { [HIDDEN_COLUMNS]: hidden }), ...shown.slice(1)];
43
80
  }
@@ -170,6 +207,183 @@ export function dropColumnsToFit<C extends TableWidthColumn & { id: string }>(
170
207
  return markHiddenTableColumns(columns, shown);
171
208
  }
172
209
 
210
+ /** A table's own narrow-pane order: the columns that leave first, least needed first (`dropColumnsToFit`). */
211
+ export type TableColumnDropOrder = readonly (string | readonly string[])[];
212
+
213
+ /**
214
+ * `columns` with the cells only a long value needs given to the name column
215
+ * beside them. A column as wide as the widest value in the whole list holds,
216
+ * on every row, the cells one value weeks out takes (`1.522B AUD`, a rate
217
+ * range): while the name column gets fewer than `need` cells (the longest
218
+ * name listed, say), the widest of `columns` gives up a cell at a time, down
219
+ * to `plain` cells (what an ordinary value takes) and never under its header.
220
+ * That long value is then cut with an ellipsis, whole in the row's detail,
221
+ * and a name is cut only once every column is down to its floor. A column
222
+ * already as narrow is left as it is. `room` is the cells the name column
223
+ * gets beside the columns given. The list's widths, not the rows in view, so
224
+ * no column moves as the reader scrolls.
225
+ */
226
+ export function narrowColumnsForName<C extends TableWidthColumn>(
227
+ columns: readonly C[],
228
+ room: (columns: readonly C[]) => number,
229
+ need: number,
230
+ plain: number | ((column: C) => number),
231
+ ): C[] {
232
+ const floor = (column: C) => Math.max(typeof plain === "number" ? plain : plain(column), tableColumnWidth({ width: 1, label: column.label }));
233
+ let fitted = [...columns];
234
+ while (room(fitted) < need) {
235
+ let widest = -1;
236
+ for (const [index, column] of fitted.entries()) {
237
+ if (column.width > floor(column) && (widest < 0 || column.width > fitted[widest]!.width)) widest = index;
238
+ }
239
+ if (widest < 0) break;
240
+ fitted = fitted.map((column, index) => (index === widest ? { ...column, width: column.width - 1 } : column));
241
+ }
242
+ return fitted;
243
+ }
244
+
245
+ /** The fewest cells a column set to grow is narrowed to by a fit: under it a name or a sentence reads as nothing. */
246
+ const FIT_TEXT_FLOOR = 12;
247
+
248
+ /**
249
+ * The cells a column cannot go under in a table fitted to its width
250
+ * (`fitColumnsToWidth`). A column the pane set to grow (`flexGrow`) is the
251
+ * one that takes up a change in the pane's width, so it gives up length
252
+ * first: down to half its set width, never under `FIT_TEXT_FLOOR` cells or
253
+ * its own header. Any other column is drawn at its set width or not at all,
254
+ * since a figure or a date cut short reads as another one.
255
+ */
256
+ export function tableColumnFitFloor(column: TableWidthColumn): number {
257
+ const width = tableColumnWidth(column);
258
+ if (!((column.flexGrow ?? 0) > 0)) return width;
259
+ const header = column.label ? displayWidth(column.label) + HEADER_RESERVED_WIDTH : 0;
260
+ return Math.min(width, Math.max(header, FIT_TEXT_FLOOR, Math.ceil(width / 2)));
261
+ }
262
+
263
+ /**
264
+ * A column headed "As of": the date the row's figures are good for, which a
265
+ * figure is misread without. A fit gives it up after the table's other
266
+ * columns unless the pane's own order names it.
267
+ */
268
+ export function isAsOfColumn(column: TableWidthColumn): boolean {
269
+ return /^as of\b/i.test(column.label?.trim() ?? "");
270
+ }
271
+
272
+ /**
273
+ * `columns` with the ones set to grow narrowed until the table is `width`
274
+ * cells wide or each is at its floor: each gives up its share of what is
275
+ * over, in whole cells, by how much it has to give.
276
+ */
277
+ function narrowColumnsToWidth<C extends TableWidthColumn>(columns: readonly C[], width: number, columnGap: number, horizontalPadding: number): C[] {
278
+ const over = getTableWidth(columns, columnGap, horizontalPadding) - width;
279
+ const set = columns.map(tableColumnWidth);
280
+ const slack = columns.map((column, index) => set[index]! - tableColumnFitFloor(column));
281
+ const total = slack.reduce((sum, cells) => sum + cells, 0);
282
+ if (over <= 0 || total <= 0) return [...columns];
283
+ const take = Math.min(over, total);
284
+ const cut = slack.map((cells) => Math.floor(cells * take / total));
285
+ let left = take - cut.reduce((sum, cells) => sum + cells, 0);
286
+ // The cells a rounding left over come off the columns with the most still to give.
287
+ for (const index of slack.map((_, at) => at).sort((a, b) => (slack[b]! - cut[b]!) - (slack[a]! - cut[a]!))) {
288
+ if (left <= 0) break;
289
+ if (slack[index]! > cut[index]!) { cut[index]! += 1; left -= 1; }
290
+ }
291
+ return columns.map((column, index) => cut[index] ? { ...column, width: set[index]! - cut[index]! } : column);
292
+ }
293
+
294
+ /**
295
+ * The columns a table `width` cells wide draws, where it cuts a column at its
296
+ * edge rather than fit what the column holds (the desktop and the web): none
297
+ * is drawn cut or past the edge. The columns set to grow narrow first, to
298
+ * their floor (`tableColumnFitFloor`); where that is not enough whole columns
299
+ * leave until the rest fit. `dropOrder` goes first, least needed first; then
300
+ * the columns it does not list, from the last one back, so a table that names
301
+ * no order gives up its trailing columns, the date its figures are as of
302
+ * after the others (`asOf`, else the ones headed so: `isAsOfColumn`).
303
+ *
304
+ * What a row means is kept, by column id, wherever the reader moved the
305
+ * columns:
306
+ *
307
+ * - The `identifier` columns, which say what each row is, and the `sorted`
308
+ * one never leave.
309
+ * - An entry of several ids in `dropOrder` is a set that means little apart
310
+ * (a call's field and the put's, a figure and the date it is as of): it
311
+ * leaves whole, and stays whole while one of it is kept. A set is the
312
+ * columns of it the table has, and sets that share one of those are one
313
+ * set, whether or not any of it is kept: two figures that each name the
314
+ * date they share leave with it or stay with it, and neither is left
315
+ * beside another figure's date. It takes the place of its first entry.
316
+ * - A row is never left with its identifier alone or beside nothing but a
317
+ * date: the last figure stays.
318
+ *
319
+ * Where what is kept does not fit either, nothing is left out: the same
320
+ * array, and the table scrolls sideways with every column as it did. The same
321
+ * array too when everything fits as set, by the table's own measure of an
322
+ * overflow (`hasMeaningfulTableHorizontalOverflow`). The columns that left
323
+ * are marked hidden as the fit's own, so the table names them and its More
324
+ * draws them again (`hiddenTableColumnDisclosure`).
325
+ */
326
+ export function fitColumnsToWidth<C extends TableWidthColumn & { id: string }>(
327
+ columns: readonly C[],
328
+ width: number,
329
+ { dropOrder = [], identifier = [], sorted = null, asOf, columnGap = TABLE_COLUMN_GAP, horizontalPadding = 1 }: {
330
+ dropOrder?: TableColumnDropOrder;
331
+ /** The columns that say what each row is. */
332
+ identifier?: readonly string[];
333
+ /** The column the rows are sorted by. */
334
+ sorted?: string | null;
335
+ /** The date columns, where `columns` carry a label that no longer says so (a translated header). */
336
+ asOf?: readonly string[];
337
+ columnGap?: number;
338
+ horizontalPadding?: number;
339
+ } = {},
340
+ ): C[] {
341
+ const overflows = (shown: readonly TableWidthColumn[]) => hasMeaningfulTableHorizontalOverflow(getTableWidth(shown, columnGap, horizontalPadding), width, columnGap);
342
+ if (width <= 0 || !overflows(columns)) return columns as C[];
343
+ // Whether the columns fit once the ones set to grow are at their floor.
344
+ const fits = (shown: readonly C[]) => !overflows(shown.map((column) => ({ ...column, width: tableColumnFitFloor(column) })));
345
+ const names = new Set(identifier);
346
+ const stays = new Set([...identifier, ...sorted ? [sorted] : []]);
347
+ // The order as sets of the columns this table has. Sets that share one of them are one set, in the place of the
348
+ // first: `named` keeps every id its entries wrote, so a set stays for a column the pane sorts by and does not draw.
349
+ const present = new Set(columns.map((column) => column.id));
350
+ const sets: { ids: string[]; named: string[] }[] = [];
351
+ for (const entry of dropOrder) {
352
+ const named = typeof entry === "string" ? [entry] : [...entry];
353
+ const ids = named.filter((id) => present.has(id));
354
+ if (!ids.length) continue;
355
+ const [first, ...others] = sets.filter((set) => set.ids.some((id) => ids.includes(id)));
356
+ if (!first) { sets.push({ ids, named }); continue; }
357
+ for (const joined of [...others, { ids, named }]) {
358
+ first.ids.push(...joined.ids.filter((id) => !first.ids.includes(id)));
359
+ first.named.push(...joined.named);
360
+ }
361
+ for (const joined of others) sets.splice(sets.indexOf(joined), 1);
362
+ }
363
+ const listed = new Set(dropOrder.flat());
364
+ const unlisted = columns.filter((column) => !listed.has(column.id));
365
+ const dates = new Set(asOf ?? columns.filter(isAsOfColumn).map((column) => column.id));
366
+ const alone = (column: C) => ({ ids: [column.id], named: [column.id] });
367
+ const steps = [
368
+ ...sets,
369
+ ...unlisted.filter((column) => !dates.has(column.id)).map(alone).reverse(),
370
+ ...unlisted.filter((column) => dates.has(column.id)).map(alone).reverse(),
371
+ ];
372
+ const hasFigure = (shown: readonly C[]) => shown.some((column) => !names.has(column.id) && !dates.has(column.id));
373
+ let shown = [...columns];
374
+ for (const step of steps) {
375
+ if (fits(shown)) break;
376
+ // A set with one column that stays, stays whole.
377
+ if (step.named.some((id) => stays.has(id))) continue;
378
+ const rest = shown.filter((column) => !step.ids.includes(column.id));
379
+ if (rest.length === shown.length || (hasFigure(shown) && !hasFigure(rest))) continue;
380
+ shown = rest;
381
+ }
382
+ // The least worth drawing does not fit: every column, in a table that scrolls sideways.
383
+ if (!fits(shown)) return columns as C[];
384
+ return markHiddenTableColumns(columns, narrowColumnsToWidth(shown, width, columnGap, horizontalPadding), { restorable: true });
385
+ }
386
+
173
387
  /**
174
388
  * Where each column's content starts, in cells from the first column, counting
175
389
  * the gap after every column and any lead gap before it. Takes columns already
@@ -0,0 +1,49 @@
1
+ import { Box, Text } from "../../ui";
2
+ import { colors } from "../../theme/colors";
3
+ import { displayWidth, truncateToDisplayWidth } from "../../utils/format";
4
+
5
+ /** A hover label shorter than this (its padding and a letter with the ellipsis) is not drawn. */
6
+ const HOVER_LABEL_MIN_WIDTH = 4;
7
+
8
+ /**
9
+ * Terminal: which side of the controls under the pointer their name goes and
10
+ * its text with a space either side, given the free cells before and after
11
+ * them in the row: after when it fits, else before, else on the roomier side
12
+ * cut to fit, else nowhere. It never covers the controls, which keep the
13
+ * pointer. The desktop names a control in its tooltip instead.
14
+ */
15
+ export function terminalHoverLabelSide(
16
+ label: string,
17
+ { before, after }: { before: number; after: number },
18
+ ): { side: "before" | "after"; text: string } | null {
19
+ const text = ` ${label} `;
20
+ const textWidth = displayWidth(text);
21
+ if (textWidth <= after) return { side: "after", text };
22
+ if (textWidth <= before) return { side: "before", text };
23
+ const room = Math.max(after, before);
24
+ if (room < HOVER_LABEL_MIN_WIDTH) return null;
25
+ const cut = ` ${truncateToDisplayWidth(label, room - 2)} `;
26
+ return { side: after >= before ? "after" : "before", text: cut };
27
+ }
28
+
29
+ /**
30
+ * Terminal: the name of the control under the pointer, drawn over its own
31
+ * row `left` cells from the left of the box that places it, in the tooltip
32
+ * surface. Nothing in the row moves for it.
33
+ */
34
+ export function TerminalHoverLabel({ text, left, role }: { text: string; left: number; role: string }) {
35
+ return (
36
+ <Box
37
+ position="absolute"
38
+ top={0}
39
+ left={left}
40
+ height={1}
41
+ width={displayWidth(text)}
42
+ zIndex={1}
43
+ backgroundColor={colors.panel}
44
+ data-gloom-role={role}
45
+ >
46
+ <Text fg={colors.textBright} selectable={false}>{text}</Text>
47
+ </Box>
48
+ );
49
+ }
@@ -1,19 +1,228 @@
1
- import { usePinnedTabTime, useUnpinTab } from "../state/app/tab-cursor";
2
- import { usePaneFooter } from "./layout/pane/footer";
1
+ import { useCallback, useContext, useEffect, useId, useMemo, useRef } from "react";
2
+ import { AppContext, useOptionalPaneInstanceId, type AppState } from "../state/app/context";
3
+ import { usePinnedTabMoment, usePinnedTabMomentReader, useUnpinTab, type PinnedMoment } from "../state/app/tab-cursor";
4
+ import { findPaneInstance } from "../types/config";
5
+ import { formatDetailDate, formatZonedMoment } from "../utils/datetime-format";
6
+ import { usePaneFooter, type PaneFooterSegment } from "./layout/pane/footer";
7
+
8
+ /**
9
+ * The footer's one form for a list that follows the tab's pinned crosshair:
10
+ * `pinned 20 Nov 14:30 HKT`. Every list names the pin on the same clock, the
11
+ * host's, with its zone said, whatever clock its own rows are on (the tape's
12
+ * New York, a column in UTC), so no list reads the moment on another clock
13
+ * without saying so. Kept in a capture of the pane: it is why the later rows
14
+ * read muted.
15
+ */
16
+ export function pinnedMomentFooterSegment(at: number, now = Date.now(), timeZone?: string): PaneFooterSegment {
17
+ return {
18
+ id: "pinned-moment",
19
+ capture: true,
20
+ title: `Crosshair pinned at ${formatDetailDate(at, "", timeZone)}`,
21
+ parts: [{ text: `pinned ${formatZonedMoment(at, now, timeZone)}`, tone: "muted" }],
22
+ variants: [[{ text: "pinned", tone: "muted" }]],
23
+ };
24
+ }
3
25
 
4
26
  /**
5
27
  * For a list that follows the tab's pinned crosshair (news, the tape): the
6
- * pinned moment, null while nothing is pinned, and while it is pinned an
7
- * `[Esc]unpin` footer hint, so the pin can be seen and lifted from a pane with
8
- * no chart, the way Esc lifts it on one. `enabled: false` while Esc means
9
- * something else here, such as going back from an open item.
28
+ * pinned moment, null while nothing is pinned. While it is pinned the footer
29
+ * says so, focused or not, and a focused pane's footer offers `[Esc]unpin`, so
30
+ * the pin can be seen and lifted from a pane with no chart, the way Esc lifts
31
+ * it on one. Only the focused pane binds the key. `enabled: false` while Esc
32
+ * means something else here, such as going back from an open item; through
33
+ * `usePinnedList` it also holds the selection still under the open item.
10
34
  */
11
- export function usePinnedMoment(registrationId: string, { enabled = true }: { enabled?: boolean } = {}): number | null {
12
- const pinnedAt = usePinnedTabTime();
35
+ function usePinnedMoment(
36
+ registrationId: string,
37
+ { enabled = true, follows = true }: {
38
+ enabled?: boolean;
39
+ /** False for a list whose rows have no time of day to read a pin against: it neither follows nor says so. */
40
+ follows?: boolean;
41
+ } = {},
42
+ ): PinnedMoment | null {
43
+ const tabPin = usePinnedTabMoment();
44
+ const pinned = follows ? tabPin : null;
13
45
  const unpin = useUnpinTab();
14
- const offered = enabled && pinnedAt !== null;
15
- usePaneFooter(registrationId, () => offered
16
- ? { hints: [{ id: "unpin", key: "Esc", label: "unpin", title: "Unpin Crosshair", onPress: unpin }] }
17
- : null, [offered, unpin]);
18
- return pinnedAt;
46
+ const at = pinned?.at ?? null;
47
+ const offered = enabled && at !== null;
48
+ // After the pane's own status and keys.
49
+ usePaneFooter(registrationId, () => at === null ? null : {
50
+ order: 1,
51
+ info: [pinnedMomentFooterSegment(at)],
52
+ hints: offered ? [{ id: "unpin", key: "Esc", label: "unpin", title: "Unpin Crosshair", onPress: unpin }] : [],
53
+ }, [at, offered, unpin]);
54
+ return pinned;
55
+ }
56
+
57
+ export interface PinFollowOptions<T> {
58
+ /** The pin the list follows; null while there is none. */
59
+ pin: PinnedMoment | null;
60
+ rows: readonly T[];
61
+ getId: (row: T) => string;
62
+ /**
63
+ * When the row came out, in ms: an instant, to the minute or finer. Null for
64
+ * a row with no time of day (a filing day): it is never picked or muted, as
65
+ * a day cannot say whether it came before a moment in it.
66
+ */
67
+ moment: (row: T) => number | null;
68
+ /** Whether a row is later than the pinned moment, for a clock finer than `moment` (the tape's nanoseconds). */
69
+ isAfter?: (row: T, at: number) => boolean;
70
+ /**
71
+ * Orders two rows by when they came out, negative when `a` is earlier, for
72
+ * a clock finer than `moment`: two prints in one millisecond are told apart
73
+ * by their nanoseconds. By `moment` when unset.
74
+ */
75
+ order?: (a: T, b: T) => number;
76
+ /**
77
+ * The id the list keeps selected, as stored: null when it has picked none,
78
+ * even if it shows its first row then, and kept while its row is gone, so
79
+ * the pin can tell a pick from a fallback.
80
+ */
81
+ selectedId: string | null;
82
+ select: (id: string) => void;
83
+ /** Follows the pin again when this changes under it: the tape's trades and quotes tabs. */
84
+ followKey?: string;
85
+ /** Names the list in its pane, which remembers what it followed for as long as the pin stays. */
86
+ name: string;
87
+ /**
88
+ * Holds the selection still while an item is open over the list, so the
89
+ * item stays the one opened; back on the list, it follows a pin that moved
90
+ * meanwhile, and keeps its row otherwise.
91
+ */
92
+ paused?: boolean;
93
+ }
94
+
95
+ export interface PinFollow<T> {
96
+ /** The row the list goes to under the pin: the newest at or before it, else the earliest; null while nothing is pinned. */
97
+ pinnedRow: T | null;
98
+ /** The pin is earlier than every row with a time. */
99
+ beforeRows: boolean;
100
+ /** A row out after the pinned moment, which reads muted. */
101
+ isAfterPin: (row: T) => boolean;
102
+ }
103
+
104
+ /**
105
+ * The row a list goes to at a pinned moment: the newest out at or before it,
106
+ * else, when every row is later, the earliest. Of rows out at the same time,
107
+ * the first in the list is the newest and the last the earliest, so a list
108
+ * newest first gets the print nearest the moment either way. Rows with no
109
+ * time are left out.
110
+ */
111
+ export function pinnedRowOf<T>(
112
+ rows: readonly T[],
113
+ at: number,
114
+ moment: (row: T) => number | null,
115
+ after: (row: T, at: number) => boolean,
116
+ order?: (a: T, b: T) => number,
117
+ ): Pick<PinFollow<T>, "pinnedRow" | "beforeRows"> {
118
+ let newest: { row: T; at: number } | null = null;
119
+ let earliest: { row: T; at: number } | null = null;
120
+ const earlier = (row: T, rowAt: number, than: { row: T; at: number }) => (order ? order(row, than.row) : rowAt - than.at);
121
+ for (const row of rows) {
122
+ const rowAt = moment(row);
123
+ if (rowAt === null || !Number.isFinite(rowAt)) continue;
124
+ if (!earliest || earlier(row, rowAt, earliest) <= 0) earliest = { row, at: rowAt };
125
+ if (!after(row, at) && (!newest || earlier(row, rowAt, newest) > 0)) newest = { row, at: rowAt };
126
+ }
127
+ return { pinnedRow: newest?.row ?? earliest?.row ?? null, beforeRows: !newest && !!earliest };
128
+ }
129
+
130
+ const NOT_PINNED = { pinnedRow: null, beforeRows: false } as const;
131
+
132
+ /**
133
+ * What each list followed of a pin, by pane and list, kept with the pin: a
134
+ * list mounted again under the same pin (back from another layout tab) keeps
135
+ * the row picked there by hand, as a list left mounted does. A pin moved or
136
+ * lifted, or gone with its tab, takes its entries with it; a list closed with
137
+ * its pane drops its own, whether or not it still followed the pin then.
138
+ */
139
+ const followedPins = new WeakMap<PinnedMoment, Map<string, string>>();
140
+
141
+ /** How many lists remember following `pin`, for tests of what a closed pane leaves behind. */
142
+ export function pinFollowersForTests(pin: PinnedMoment): number {
143
+ return followedPins.get(pin)?.size ?? 0;
144
+ }
145
+
146
+ /** Whether a pane is still open in a layout tab, the active one or one switched away from. */
147
+ function paneInLayouts(state: AppState, paneId: string): boolean {
148
+ const { layout, layouts, activeLayoutIndex } = state.config;
149
+ return findPaneInstance(layout, paneId) !== undefined
150
+ || layouts.some((tab, index) => index !== activeLayoutIndex && findPaneInstance(tab.layout, paneId) !== undefined);
151
+ }
152
+
153
+ /**
154
+ * A list that follows the tab's pinned crosshair. The selection goes to the
155
+ * newest row out by the pinned moment when the pin moves, and when the rows
156
+ * first arrive under it, never when a row streams in, so a row picked by hand
157
+ * stays picked; lifting the pin leaves the selection where it is. A pin
158
+ * before every row selects the earliest row, the one nearest the moment,
159
+ * rather than keeping the row an earlier pin picked. Following commits the
160
+ * row's id, so rows streaming in above it never move it. Rows out after the
161
+ * moment are muted (`isAfterPin`, a table's `isRowMuted`).
162
+ */
163
+ export function usePinFollow<T>({ pin, rows, getId, moment, isAfter, order, selectedId, select, followKey = "", name, paused = false }: PinFollowOptions<T>): PinFollow<T> {
164
+ const at = pin?.at ?? null;
165
+ const after = useCallback((row: T, time: number) => {
166
+ if (isAfter) return isAfter(row, time);
167
+ const rowAt = moment(row);
168
+ return rowAt !== null && rowAt > time;
169
+ }, [isAfter, moment]);
170
+ const { pinnedRow, beforeRows } = useMemo(() => at === null ? NOT_PINNED
171
+ : pinnedRowOf(rows, at, moment, after, order), [after, at, moment, order, rows]);
172
+ const targetId = pinnedRow === null ? null : getId(pinnedRow);
173
+ // Read only under a pin: a list follows nothing without one, so its renders
174
+ // never look through the rows for the selection.
175
+ const selectedShown = pin !== null && selectedId !== null && rows.some((row) => getId(row) === selectedId);
176
+ const paneId = useOptionalPaneInstanceId();
177
+ const ownId = useId();
178
+ // A list outside a pane remembers only while it stays mounted.
179
+ const memoryKey = `${paneId ?? ownId}\u0000${name}`;
180
+ const selectRef = useRef(select);
181
+ selectRef.current = select;
182
+ useEffect(() => {
183
+ if (pin === null || paused) return;
184
+ const followed = followedPins.get(pin);
185
+ // Nothing loaded yet: the rows follow once they come. Already followed:
186
+ // the selection is the user's, unless it is gone from the list.
187
+ if (targetId === null || (followed?.get(memoryKey) === followKey && selectedShown)) return;
188
+ if (followed) followed.set(memoryKey, followKey);
189
+ else followedPins.set(pin, new Map([[memoryKey, followKey]]));
190
+ if (targetId !== selectedId) selectRef.current(targetId);
191
+ }, [followKey, memoryKey, paused, pin, selectedId, selectedShown, targetId]);
192
+
193
+ // A pane closed forgets what its list followed. Read once the unmount
194
+ // settles, from the app's state then: a pane switched away from with its
195
+ // tab, or remounted in place, is still in a layout and keeps it. The entry
196
+ // is found under the tab's pin, not the one the list was given: a list that
197
+ // stopped following before it closed (a tab of its pane with no list, a
198
+ // folded chart) was given none, though its entry stays under the tab's.
199
+ const app = useContext(AppContext);
200
+ const tabPin = usePinnedTabMomentReader();
201
+ useEffect(() => () => {
202
+ queueMicrotask(() => {
203
+ if (paneId !== null && app) {
204
+ const state = "getState" in app ? app.getState() : app.state;
205
+ if (paneInLayouts(state, paneId)) return;
206
+ }
207
+ const left = tabPin();
208
+ if (left !== null) followedPins.get(left)?.delete(memoryKey);
209
+ });
210
+ }, [app, memoryKey, paneId, tabPin]);
211
+
212
+ const isAfterPin = useCallback((row: T) => at !== null && after(row, at), [after, at]);
213
+ return { pinnedRow, beforeRows, isAfterPin };
214
+ }
215
+
216
+ /**
217
+ * `usePinnedMoment` and `usePinFollow` together, for a list beside the tab's
218
+ * charts. `enabled: false`, for an item open over the list, also holds the
219
+ * selection still until it closes.
220
+ */
221
+ export function usePinnedList<T>(
222
+ registrationId: string,
223
+ options: Omit<PinFollowOptions<T>, "pin" | "name" | "paused"> & { enabled?: boolean; follows?: boolean },
224
+ ): PinFollow<T> & { pin: PinnedMoment | null } {
225
+ const { enabled, follows, ...follow } = options;
226
+ const pin = usePinnedMoment(registrationId, { enabled, follows });
227
+ return { ...usePinFollow({ ...follow, pin, name: registrationId, paused: enabled === false }), pin };
19
228
  }
@@ -18,6 +18,7 @@ import {
18
18
  import type { DesktopSharedStateSnapshot } from "../../../types/desktop-window";
19
19
  import type { BrokerAccount } from "../../../types/trading";
20
20
  import { isBrokerPortfolioId } from "../../../utils/broker-instances";
21
+ import { includedBrokerAccounts } from "../../../brokers/account-choice";
21
22
  import type { AppState, LayoutHistoryEntry, OpeningPaneSettlement, PaneRuntimeState } from "./types";
22
23
 
23
24
  function getDefaultCollectionId(config: AppConfig): string {
@@ -200,13 +201,17 @@ export function reconcilePaneState(
200
201
  return next;
201
202
  }
202
203
 
204
+ /** The accounts of the profiles that remain, without any the user left out of one. */
203
205
  function reconcileBrokerAccounts(
204
206
  config: AppConfig,
205
207
  brokerAccounts: Record<string, BrokerAccount[]>,
206
208
  ): Record<string, BrokerAccount[]> {
207
- const validInstanceIds = new Set(config.brokerInstances.map((instance) => instance.id));
209
+ const instances = new Map(config.brokerInstances.map((instance) => [instance.id, instance]));
208
210
  return Object.fromEntries(
209
- Object.entries(brokerAccounts).filter(([instanceId]) => validInstanceIds.has(instanceId)),
211
+ Object.entries(brokerAccounts).flatMap(([instanceId, accounts]) => {
212
+ const instance = instances.get(instanceId);
213
+ return instance ? [[instanceId, includedBrokerAccounts(instance, accounts)]] : [];
214
+ }),
210
215
  );
211
216
  }
212
217
 
@@ -1,4 +1,5 @@
1
1
  import type { AppConfig } from "../../../types/config";
2
+ import { includedBrokerAccounts } from "../../../brokers/account-choice";
2
3
  import { updateKeybindingsConfig } from "../../../app/keybindings/config";
3
4
  import { recordCommandBarOpen } from "../../../app/command-bar-intro";
4
5
  import { resolveTickerFinancialsQuoteState } from "../../../market-data/quotes/resolution";
@@ -41,6 +42,8 @@ export {
41
42
  };
42
43
  export type { AppAction, AppState, CollectionSortPreference, PaneRuntimeState };
43
44
 
45
+ const defaultInputCaptureOwner = {};
46
+
44
47
  /** One more open of the empty command bar; past the introduction the count stays put. */
45
48
  function countEmptyCommandBarOpen(state: AppState): AppState {
46
49
  const commandBarOpens = recordCommandBarOpen(state.config.commandBarOpens);
@@ -197,14 +200,17 @@ export function appReducer(state: AppState, action: AppAction): AppState {
197
200
  return { ...state, refreshing };
198
201
  }
199
202
 
200
- case "SET_BROKER_ACCOUNTS":
203
+ case "SET_BROKER_ACCOUNTS": {
204
+ // An account the user left out of the profile is shown nowhere, whoever read it.
205
+ const instance = state.config.brokerInstances.find((entry) => entry.id === action.instanceId);
201
206
  return {
202
207
  ...state,
203
208
  brokerAccounts: {
204
209
  ...state.brokerAccounts,
205
- [action.instanceId]: action.accounts,
210
+ [action.instanceId]: instance ? includedBrokerAccounts(instance, action.accounts) : action.accounts,
206
211
  },
207
212
  };
213
+ }
208
214
 
209
215
  case "SET_BROKER_SYNC_ERROR": {
210
216
  if (!state.config.brokerInstances.some((instance) => instance.id === action.instanceId)) return state;
@@ -247,8 +253,15 @@ export function appReducer(state: AppState, action: AppAction): AppState {
247
253
  : { ...state, config };
248
254
  }
249
255
 
250
- case "SET_INPUT_CAPTURED":
251
- return { ...state, inputCaptured: action.captured };
256
+ case "SET_INPUT_CAPTURED": {
257
+ const owner = action.owner ?? defaultInputCaptureOwner;
258
+ const owners = state.inputCaptureOwners ?? (state.inputCaptured ? [defaultInputCaptureOwner] : []);
259
+ const inputCaptureOwners = new Set(owners);
260
+ if (inputCaptureOwners.has(owner) === action.captured) return state;
261
+ if (action.captured) inputCaptureOwners.add(owner);
262
+ else inputCaptureOwners.delete(owner);
263
+ return { ...state, inputCaptureOwners, inputCaptured: inputCaptureOwners.size > 0 };
264
+ }
252
265
 
253
266
  case "SET_EXCHANGE_RATE": {
254
267
  const exchangeRates = new Map(state.exchangeRates);
@@ -113,6 +113,7 @@ export interface AppState {
113
113
  initialized: boolean;
114
114
  statusBarVisible: boolean;
115
115
  inputCaptured: boolean;
116
+ inputCaptureOwners?: ReadonlySet<object>;
116
117
  updateAvailable: ReleaseInfo | null;
117
118
  updateProgress: UpdateProgress | null;
118
119
  updateCheckInProgress: boolean;
@@ -172,7 +173,7 @@ export type AppAction =
172
173
  | { type: "SET_UPDATE_NOTICE"; notice: string | null }
173
174
  /** Plugins switched on or off; `focusedPaneId` moves focus off a pane that just went hidden. */
174
175
  | { type: "SET_DISABLED_PLUGINS"; disabledPlugins: string[]; focusedPaneId?: string | null }
175
- | { type: "SET_INPUT_CAPTURED"; captured: boolean }
176
+ | { type: "SET_INPUT_CAPTURED"; captured: boolean; owner?: object }
176
177
  /** @deprecated Only writes the unused `AppState.exchangeRates`. Use `useFxRatesMap`. */
177
178
  | { type: "SET_EXCHANGE_RATE"; currency: string; rate: number }
178
179
  /** @deprecated Only writes the unused `AppState.exchangeRates`. Use `useFxRatesMap`. */